lanid

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 10 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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 ActivityClear

func ActivityClear()

ActivityClear empties the log.

func Code

func Code() string

Code is the short human-verifiable code for this device's fingerprint.

func Fingerprint

func Fingerprint() string

Fingerprint / Code identify this device to peers.

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

func NormalizeMode(v string) (string, error)

NormalizeMode maps user input to a mode constant ("" -> ModeAsk).

func SetMode added in v0.12.0

func SetMode(fingerprint, mode string) error

SetMode changes the mode of an already-trusted device.

func SetScanInterval

func SetScanInterval(sec int) error

SetScanInterval persists the scan interval (seconds; 0 = manual only).

func Trust

func Trust(fingerprint, name string) error

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

func TrustWithMode(fingerprint, name, mode string) error

TrustWithMode adds/updates a trusted device with an explicit mode.

func Untrust

func Untrust(fingerprint string) error

Untrust removes a device from the trust store (revoke).

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.

func ActivityList

func ActivityList() []ActivityEntry

ActivityList returns the log, newest first.

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 List

func List() []TrustedDevice

List returns the trusted devices, sorted by name.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL