lanid

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 8 Imported by: 0

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

This section is empty.

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 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 (trusted = auto-accept, revocable).

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"`
}

TrustedDevice is a device we've trusted, keyed by its verified Ed25519 key fingerprint. Trusted = auto-accept (its transfers land without a prompt); untrusted devices always 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).

Jump to

Keyboard shortcuts

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