Documentation
¶
Overview ¶
Package remote holds what every phone surface shares: one-time pairing codes, the per-chat allowlist, and the throttle that keeps progress messages from flooding a phone. The surfaces themselves live in remote/telegram and remote/discord.
Index ¶
Constants ¶
const ( // DefaultPairTTL is how long a minted code can be redeemed. DefaultPairTTL = 10 * time.Minute )
Variables ¶
var ( ErrNoCode = errors.New("no pairing code is active; run the pairing command on the host again") ErrWrongCode = errors.New("that code is not valid") ErrLockedOut = errors.New("too many wrong codes; wait a few minutes and try again") )
Errors returned by Redeem. They are safe to show to the person in the chat.
var ErrStaticChat = errors.New("this chat is listed in the config, so it cannot be unpaired from here")
ErrStaticChat means a chat is listed in the config. Only the config can remove it, so /unpair from the phone cannot touch it.
Functions ¶
Types ¶
type Allowlist ¶
type Allowlist struct {
// contains filtered or unexported fields
}
Allowlist is the set of chats allowed to talk to Scribe on one surface. Static ids come from config and are never written. Ids added by pairing are saved to a state file (mode 0600) so a pairing survives a restart. Surfaces default-deny: an empty allowlist admits no chat.
func NewAllowlist ¶
NewAllowlist loads the paired ids from path (a missing file is empty) and merges static. An empty path keeps pairings in memory only.
func (*Allowlist) IsStatic ¶
IsStatic reports whether chat is listed in the config (and so cannot be removed from a phone or the TUI).
type Pairing ¶
type Pairing struct {
// contains filtered or unexported fields
}
Pairing mints one-time codes and redeems them from chats. A code is shown on the host and typed into the chat that should be paired. Five wrong attempts from one chat lock that chat out for ten minutes. The lockout is per chat, so one chat cannot exhaust another's attempts.
func NewPairing ¶
NewPairing returns a Pairing whose codes last ttl (DefaultPairTTL if zero).
type Throttle ¶
type Throttle struct {
// contains filtered or unexported fields
}
Throttle lets an event through at most once per interval for each key. Progress lines use it so a chatty tool cannot flood a phone.
func NewThrottle ¶
NewThrottle returns a Throttle that allows one event per key every d.