peers

package
v0.0.0-...-b43479a Latest Latest
Warning

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

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

Documentation

Overview

Package peers owns an explicit coordinator's peer inventory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

Types

type Peer

type Peer struct {
	URL    string `json:"url"`
	Name   string `json:"name,omitempty"`
	ID     string `json:"id,omitempty"`
	Accent string `json:"accent,omitempty"`
	Glyph  string `json:"glyph,omitempty"`
	// Verifier is this peer's own PBKDF2 access-password verifier,
	// captured once when it was enrolled with a password (see
	// handlePeerAdd), never the plaintext. It authenticates this server
	// to that peer on every proxied request going forward — a peer with
	// a password is just another client who knows it, and this is how
	// this server proves it does too, without asking again each time.
	Verifier string `json:"verifier,omitempty"`
	// SSHDestination, when set, means this PC is reached by running eta on
	// it over SSH rather than by talking to one already listening. It is
	// what the user typed and what ssh resolves, and it is this peer's
	// durable identity: URL holds an ephemeral forwarded loopback port
	// that changes on every reconnect, so it cannot be the key. Empty for
	// an ordinary peer, and absent from older inventories.
	SSHDestination string `json:"ssh_destination,omitempty"`
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func New

func New(path string) *Store

func (*Store) Add

func (s *Store) Add(peer Peer) error

func (*Store) Find

func (s *Store) Find(raw string) (Peer, bool, error)

func (*Store) FindBySSHDestination

func (s *Store) FindBySSHDestination(destination string) (Peer, bool, error)

FindBySSHDestination looks a peer up by the identity that survives reconnects, rather than by its current URL.

func (*Store) List

func (s *Store) List() ([]Peer, error)

func (*Store) Remove

func (s *Store) Remove(raw string) error

func (*Store) Update

func (s *Store) Update(peer Peer) error

Update replaces an existing peer's details, keyed by URL. Identity is not immutable: a PC can be renamed or have its colour changed, and the inventory holds a copy taken at enrolment that would otherwise stay wrong forever.

func (*Store) UpsertBySSHDestination

func (s *Store) UpsertBySSHDestination(peer Peer) error

UpsertBySSHDestination records an SSH-backed peer, matching on its destination so a reconnect updates the existing entry's URL in place instead of adding a second one. Keying on URL cannot do this: the forwarded port differs every session, so each reconnect would append a new entry and strand the old one pointing at a closed port — or worse, at a port now serving a different tunnel.

Jump to

Keyboard shortcuts

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