Documentation
¶
Overview ¶
Package lanid manages this device's persistent LAN identity (an Ed25519 keypair) and the trusted-devices store, shared by the `s2u` CLI and the desktop GUI. Both store under os.UserConfigDir()/share2us (the same base cli-core uses for credentials/config), so a device's identity and the devices it trusts are shared across the CLI and GUI on one machine.
Trust is keyed by the peer's verified public-key fingerprint (never its name or IP), so a device recognised once needs no per-transfer verify code — and can be revoked.
Index ¶
- Constants
- func ActivityAppend(e ActivityEntry)
- func ActivityClear()
- func Code() string
- func Fingerprint() string
- func GetScanInterval() int
- func Identity() (ed25519.PrivateKey, error)
- func NormalizeMode(v string) (string, error)
- func SetMode(fingerprint, mode string) error
- func SetScanInterval(sec int) error
- func Trust(fingerprint, name string) error
- func TrustWithMode(fingerprint, name, mode string) error
- func Untrust(fingerprint string) error
- type ActivityEntry
- type TrustedDevice
Constants ¶
const ( // ModeAsk: trusted, but every transfer still needs a one-tap approval (no // verify code, no anti-spam caps). The default. ModeAsk = "ask" // ModeAuto: trusted and its transfers are saved without asking. ModeAuto = "auto" )
Trust modes.
Variables ¶
This section is empty.
Functions ¶
func ActivityAppend ¶
func ActivityAppend(e ActivityEntry)
ActivityAppend records an event, keeping the newest maxActivity entries.
func Code ¶
func Code() string
Code is the short human-verifiable code for this device's fingerprint.
func GetScanInterval ¶
func GetScanInterval() int
GetScanInterval returns the broadcast-discovery scan interval in seconds (default 60; 0 = manual refresh only).
func Identity ¶
func Identity() (ed25519.PrivateKey, error)
Identity returns this device's persistent Ed25519 identity, creating and saving it (0600) on first use.
func NormalizeMode ¶ added in v0.12.0
NormalizeMode maps user input to a mode constant ("" -> ModeAsk).
func SetScanInterval ¶
SetScanInterval persists the scan interval (seconds; 0 = manual only).
func Trust ¶
Trust adds/updates a trusted device in the default ModeAsk (revocable). An existing record keeps its mode; use TrustWithMode or SetMode to change it.
func TrustWithMode ¶ added in v0.12.0
TrustWithMode adds/updates a trusted device with an explicit mode.
Types ¶
type ActivityEntry ¶
type ActivityEntry struct {
Kind string `json:"kind"` // sent | received | downloaded | broadcast | link
Peer string `json:"peer"`
Name string `json:"name"`
Size int64 `json:"size"`
Link string `json:"link,omitempty"` // for kind "link": the share URL (re-copyable)
TS int64 `json:"ts"` // unix seconds
}
ActivityEntry is one logged transfer/broadcast event. Metadata only — never file contents.
type TrustedDevice ¶
type TrustedDevice struct {
Fingerprint string `json:"fingerprint"`
Name string `json:"name"`
// Mode is ModeAsk or ModeAuto. Empty (records written before modes existed)
// means ModeAsk: the safer reading, never fewer prompts than the user expects.
Mode string `json:"mode,omitempty"`
}
TrustedDevice is a device we've trusted, keyed by its verified Ed25519 key fingerprint. Trust skips the verify-code compare and the anti-spam caps; what happens next depends on Mode: ModeAsk (the default) still asks the receiver to approve each transfer, ModeAuto lets its transfers land without a prompt. Untrusted devices always go through the full prompt. Revocable.
func Lookup ¶
func Lookup(fingerprint string) (TrustedDevice, bool)
Lookup returns the trusted device for a fingerprint (ok=false if untrusted or the fingerprint is empty/anonymous).
func (TrustedDevice) AutoAccept ¶ added in v0.12.0
func (d TrustedDevice) AutoAccept() bool
AutoAccept reports whether transfers from this device may land without asking.
func (TrustedDevice) EffectiveMode ¶ added in v0.12.0
func (d TrustedDevice) EffectiveMode() string
EffectiveMode returns the device's mode with the legacy empty value read as ask.