link

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 55 Imported by: 0 modules, 0 packages

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

Index

Constants

View Source
const DefaultPairingService = "https://sailry.link.dux.plus"

Variables

View Source
var ProductVersion = identity.OfficialVersion

Functions

func CheckHost

func CheckHost(hostProtocol *uint16, hostVersion *string) error

func NetworkRelayURLs

func NetworkRelayURLs(_ context.Context, selection protocol.NetworkSelection) ([]string, error)

NetworkRelayURLs retains its historical name; active relay selections use Libp2p multiaddrs. Direct returns a non-nil empty list.

func ProbeRelay added in v0.2.5

func ProbeRelay(ctx context.Context, address string) (time.Duration, error)

func RelayInputAddress added in v0.2.5

func RelayInputAddress(value string) string

RelayInputAddress formats a pinned relay for editing without changing the address used by the transport. Unresolved input stays editable as entered.

func ResolveNetworkSelection added in v0.2.5

func ResolveNetworkSelection(ctx context.Context, selection protocol.NetworkSelection, presets []protocol.NetworkPreset) (protocol.NetworkSelection, error)

ResolveNetworkSelection resolves user input before a selection is applied or persisted. Stored selections and transport addresses never depend on DNSADDR to recover the relay's identity.

func StreamPair

func StreamPair() (Stream, Stream)

StreamPair supplies the same independently closable read/write directions as a remote bidirectional stream. Standard pipes apply backpressure to each side.

func ValidHostRemovalState

func ValidHostRemovalState(state string) bool

Types

type Admission

type Admission struct {
	Receipt    protocol.Receipt
	Completion <-chan Response
}

Admission separates acknowledgment from work that outlives its observer.

type ConnectionInfo

type ConnectionInfo struct {
	Route *Route  `json:"route"`
	RTTMS *uint64 `json:"rtt_ms"`
}

type EndpointAddress

type EndpointAddress = peertransport.Address

func CandidateAddress

func CandidateAddress(address EndpointAddress, selection protocol.NetworkSelection) (EndpointAddress, error)

type EndpointOptions

type EndpointOptions struct {
	Identity        Identity
	Scope           NetworkScope
	Handler         Handler
	Peers           PeerStore
	SoftwareVersion string
	Name            string
	// Paired runs after an outbound invitation has been accepted and saved.
	Paired func(protocol.NodeID)
}

type FaultError

type FaultError struct{ Fault protocol.Fault }

FaultError carries a protocol fault through an ordinary Go error boundary.

func (*FaultError) Error

func (err *FaultError) Error() string

func (*FaultError) Unwrap

func (err *FaultError) Unwrap() error

type Handler

Handler is implemented by the execution Node, which owns the request ledger.

type HostRemovalAttempt

type HostRemovalAttempt struct {
	Request protocol.Request `json:"request"`
	State   string           `json:"state"`
	Fault   *protocol.Fault  `json:"fault,omitempty"`
	Active  bool             `json:"active"`
}

HostRemovalAttempt retains the exact remote self-revocation request even after local trust is removed. It is diagnostic history, never a retry worker.

type HostRemovalNotice

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

HostRemovalNotice owns one already authenticated connection after local trust is removed. It can only notify the saved self-revocation or inspect its ID. It never reconnects, and belongs to the Link rather than the caller's view.

func (*HostRemovalNotice) Close

func (notice *HostRemovalNotice) Close()

Close abandons an unstarted reservation after a failed local save, or releases the detached connection after notification, re-pairing or Link shutdown.

func (*HostRemovalNotice) Start

func (notice *HostRemovalNotice) Start() error

Start follows successful local removal. Its ten-second budget includes queue time, stream admission and completion; no request survives for a later retry.

type HostRemovalStore

type HostRemovalStore interface {
	PrepareHostRemoval(context.Context, protocol.NodeID, protocol.Request) (HostRemovalAttempt, error)
	RecordHostRemoval(context.Context, protocol.NodeID, protocol.RequestID, string, *protocol.Fault) error
	HostRemovals(context.Context) ([]HostRemovalAttempt, error)
}

type Identity

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

Identity belongs to the exclusive profile owner.

func OpenIdentity

func OpenIdentity(directory string) (Identity, error)

func ReadIdentity added in v0.2.4

func ReadIdentity(directory string) (Identity, error)

ReadIdentity loads the existing key without creating one.

func (Identity) GoString

func (Identity) GoString() string

func (Identity) ID

func (identity Identity) ID() protocol.NodeID

func (Identity) SecretKey

func (identity Identity) SecretKey() [ed25519.SeedSize]byte

func (Identity) String

func (Identity) String() string

type Invitation

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

func (*Invitation) Close

func (invitation *Invitation) Close() error

func (*Invitation) ExpiresAtMS

func (invitation *Invitation) ExpiresAtMS() uint64

func (*Invitation) GoString

func (*Invitation) GoString() string

func (*Invitation) IsPaired

func (invitation *Invitation) IsPaired() bool

func (*Invitation) Paired

func (invitation *Invitation) Paired(ctx context.Context) error

func (*Invitation) String

func (*Invitation) String() string

func (*Invitation) Ticket

func (invitation *Invitation) Ticket() string

type InvitationScope

type InvitationScope struct {
	Kind protocol.InvitationKind
	User *protocol.UserID
}

InvitationScope is captured by the endpoint sharing the invitation. User is meaningful only on a Node; it is never accepted from a pairing claimant.

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

func Bind

func Bind(ctx context.Context, options EndpointOptions) (*Link, error)

func OpenController

func OpenController(ctx context.Context, path string, scope NetworkScope) (*Link, error)

func (*Link) Address

func (link *Link) Address(ctx context.Context) (EndpointAddress, error)

func (*Link) ApplyDirectory

func (link *Link) ApplyDirectory(ctx context.Context, directory protocol.HostDirectory) error

ApplyDirectory imports only outbound hosts from an authenticated my-device source. Store provenance preserves direct pairs and explicit local removals.

func (*Link) Close

func (link *Link) Close() error

func (*Link) Direction

func (link *Link) Direction(peer protocol.NodeID) PeerDirection

func (*Link) Disconnect

func (link *Link) Disconnect(peer protocol.NodeID)

Disconnect closes the cached connection to a paired peer; the next use dials again. It is for a caller that knows the peer's process was replaced: a connection to a process that is gone is otherwise noticed only when an operation on it times out.

func (*Link) HostRemovals

func (link *Link) HostRemovals(ctx context.Context) ([]HostRemovalAttempt, error)

func (*Link) Inspect

func (link *Link) Inspect(ctx context.Context, address EndpointAddress) (PeerInfo, error)

func (*Link) Invite

func (link *Link) Invite(ctx context.Context) (*Invitation, error)

func (*Link) InviteFor

func (link *Link) InviteFor(ctx context.Context, scope InvitationScope) (*Invitation, error)

func (*Link) MyDevice

func (link *Link) MyDevice(ctx context.Context, peer protocol.NodeID) (bool, error)

func (*Link) Name

func (link *Link) Name() string

func (*Link) NarrowLegacyController

func (link *Link) NarrowLegacyController(ctx context.Context, peer protocol.NodeID) error

NarrowLegacyController runs only after authenticated inspection positively identifies a controller without execution. The store checks legacy state in the same write, so a newer explicit pairing cannot be narrowed by a stale read.

func (*Link) NetworkChanged

func (link *Link) NetworkChanged(ctx context.Context) error

NetworkChanged rebinds the endpoint, then verifies each cached outgoing connection with one inspection. A libp2p inspection checks only the path carrying its stream; other paths and their admitted streams remain usable.

func (*Link) NetworkSelection

func (link *Link) NetworkSelection() *protocol.NetworkSelection

func (*Link) Online

func (link *Link) Online(ctx context.Context) error

func (*Link) Pair

func (link *Link) Pair(ctx context.Context, encoded string) (EndpointAddress, error)

func (*Link) PairPIN

func (link *Link) PairPIN(ctx context.Context, origin, pin string, claim *PairingClaim) (EndpointAddress, error)

func (*Link) PairPINOnNetwork

func (link *Link) PairPINOnNetwork(ctx context.Context, origin, pin string, selection protocol.NetworkSelection, claim *PairingClaim) (EndpointAddress, error)

func (*Link) PeerDirections

func (link *Link) PeerDirections(ctx context.Context) ([]PeerTrust, error)

func (*Link) Peers

func (link *Link) Peers(ctx context.Context) ([]EndpointAddress, error)

func (*Link) PrepareHostRemoval

func (link *Link) PrepareHostRemoval(ctx context.Context, host protocol.NodeID) (HostRemovalAttempt, error)

func (*Link) PrepareHostRemovalNotice

func (link *Link) PrepareHostRemovalNotice(ctx context.Context, host protocol.NodeID) (HostRemovalAttempt, *HostRemovalNotice, error)

PrepareHostRemovalNotice persists the original request and reserves only an existing live connection. An offline host needs no notification or dial.

func (*Link) RecordHostRemoval

func (link *Link) RecordHostRemoval(ctx context.Context, host protocol.NodeID, request protocol.RequestID, state string, failure *protocol.Fault) error

func (*Link) RefreshPeers

func (link *Link) RefreshPeers(ctx context.Context) error

RefreshPeers reconciles trust changed by a Node command transaction. Removed inbound access closes existing connections before another request can use it.

func (*Link) Relationships

func (link *Link) Relationships(ctx context.Context) ([]PeerRelationship, error)

func (*Link) RememberPeerName

func (link *Link) RememberPeerName(ctx context.Context, peer protocol.NodeID, name string) error

func (*Link) Remote

func (link *Link) Remote(address EndpointAddress) *Remote

func (*Link) SelectNetwork

func (link *Link) SelectNetwork(ctx context.Context, selection protocol.NetworkSelection) error

func (*Link) SetDirection

func (link *Link) SetDirection(ctx context.Context, peer protocol.NodeID, direction PeerDirection) error

SetDirection changes an existing relationship and releases connections that held access removed by the change. It does not pair an unknown peer.

func (*Link) SetName

func (link *Link) SetName(name string) error

func (*Link) SetTrust

func (link *Link) SetTrust(ctx context.Context, peer protocol.NodeID, trusted bool) error

func (*Link) Share

func (link *Link) Share(ctx context.Context, origin string) (*ShareSession, error)

func (*Link) ShareFor

func (link *Link) ShareFor(ctx context.Context, origin string, scope InvitationScope) (*ShareSession, error)

func (*Link) UpdatePeer

func (link *Link) UpdatePeer(ctx context.Context, address EndpointAddress) error

func (*Link) Via

func (link *Link) Via(entry EndpointAddress, target protocol.NodeID) *Remote

Via opens a target through a directly paired entry Node. It never pairs the target or grants it the entry's identity.

func (*Link) WatchPeers

func (link *Link) WatchPeers(ctx context.Context, callback func()) error

type Local

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

Local is constructed by the Node owner; caller identity never comes from wire data.

func NewLocal

func NewLocal(target, caller protocol.NodeID, handler Handler) *Local

func (*Local) Dispatch

func (local *Local) Dispatch(ctx context.Context, request protocol.Request) (Admission, error)

func (*Local) ForTarget

func (local *Local) ForTarget(target protocol.NodeID) Transport

ForTarget lets the local controller's resource router choose a directly connected storage Node without changing the prepared request or caller.

func (*Local) LocalResource

func (local *Local) LocalResource(ctx context.Context, call protocol.ResourceCall) (Admission, error)

LocalResource restores a prepared resource mutation through the local controller entry. Its user and package are verified by that Node.

func (*Local) Open

func (local *Local) Open(ctx context.Context, id protocol.StreamID) (Stream, error)

func (*Local) ScopedKnowledge

func (local *Local) ScopedKnowledge(ctx context.Context, call protocol.ScopedKnowledgeCall) (Admission, error)

func (*Local) Subscribe

func (local *Local) Subscribe(ctx context.Context, topic protocol.Topic) (Subscription, error)

func (*Local) Target

func (local *Local) Target() protocol.NodeID

func (*Local) WatchConnection

func (local *Local) WatchConnection(ctx context.Context, changed func(ConnectionInfo)) error

type MembershipStore

type MembershipStore interface {
	Relationships(context.Context) ([]PeerRelationship, error)
	ApplyDirectory(context.Context, protocol.NodeID, uint64, []EndpointAddress, ...map[protocol.NodeID]string) error
}

MembershipStore extends persistent peer stores. The base interface remains usable by transports that do not support identity invitations or directories.

type NetworkScope

type NetworkScope struct {
	Bind     string
	Internet bool
	Relays   []string
}

type PairingClaim

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

func (*PairingClaim) GoString

func (*PairingClaim) GoString() string

func (*PairingClaim) String

func (*PairingClaim) String() string

type PeerDirection

type PeerDirection string

PeerDirection describes which endpoint may call the other's execution service.

const (
	DirectionController PeerDirection = "controller"
	DirectionHost       PeerDirection = "host"
	DirectionBoth       PeerDirection = "both"
)

func (PeerDirection) AllowsInbound

func (direction PeerDirection) AllowsInbound() bool

func (PeerDirection) AllowsOutbound

func (direction PeerDirection) AllowsOutbound() bool

func (PeerDirection) Valid

func (direction PeerDirection) Valid() bool

type PeerIdentityStore

type PeerIdentityStore interface {
	ClassifyPeer(context.Context, protocol.NodeID, bool) error
}

PeerIdentityStore binds the type reported by an authenticated peer to its existing membership. Classification cannot add trust or execution direction.

type PeerInfo

type PeerInfo struct {
	Execution       bool
	Name            *string
	Platform        string
	SoftwareVersion *string
	Protocol        *uint16
	Latency         time.Duration
	Zstd            bool
	HasNode         *bool
}

func (PeerInfo) Compatibility

func (info PeerInfo) Compatibility() error

type PeerNameStore

type PeerNameStore interface {
	RememberPeerName(context.Context, protocol.NodeID, string) error
}

PeerNameStore retains display metadata learned from authenticated endpoints. Names never establish trust or change an address's certified identity.

type PeerRelationship

type PeerRelationship struct {
	ID                protocol.NodeID   `json:"id"`
	Name              string            `json:"name,omitempty"`
	Direct            bool              `json:"direct"`
	DirectDirection   PeerDirection     `json:"direct_direction,omitempty"`
	MyDevice          bool              `json:"my_device"`
	Removed           bool              `json:"removed"`
	Sources           []protocol.NodeID `json:"sources"`
	DirectoryRevision uint64            `json:"directory_revision"`
}

type PeerStore

type PeerStore interface {
	Peers(context.Context) ([]protocol.NodeID, error)
	Addresses(context.Context) ([]EndpointAddress, error)
	Remember(context.Context, EndpointAddress) error
	SetTrust(context.Context, protocol.NodeID, bool) error
	Directions(context.Context) ([]PeerTrust, error)
	PairPeer(context.Context, protocol.NodeID, PeerDirection) error
	// A resumed invitation can refresh an existing inbound peer's address, but
	// cannot grant access again or change its membership.
	SavePairing(ctx context.Context, address EndpointAddress, direction PeerDirection, scope InvitationScope, hasNode *bool, resume bool) error
	SetDirection(context.Context, protocol.NodeID, PeerDirection) error
}

type PeerTrust

type PeerTrust struct {
	ID        protocol.NodeID `json:"id"`
	Direction PeerDirection   `json:"direction"`
	Legacy    bool            `json:"legacy,omitempty"`
}

PeerTrust is one persisted relationship. Both is retained for legacy pairings or two independently accepted invitations in opposite directions.

type Remote

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

func (*Remote) Dispatch

func (remote *Remote) Dispatch(ctx context.Context, request protocol.Request) (Admission, error)

func (*Remote) ForTarget

func (remote *Remote) ForTarget(target protocol.NodeID) Transport

ForTarget retains this authenticated entry for a shell resource selection.

func (*Remote) Open

func (remote *Remote) Open(ctx context.Context, resource protocol.StreamID) (Stream, error)

func (*Remote) Resource

func (remote *Remote) Resource(ctx context.Context, call protocol.ResourceCall) (Admission, error)

Resource carries captured knowledge context between directly paired Nodes. It never enables ordinary reverse commands.

func (*Remote) Route

func (remote *Remote) Route() protocol.RouteKey

Route retains the authenticated entry separately from the resource owner.

func (*Remote) ScopedKnowledge

func (remote *Remote) ScopedKnowledge(ctx context.Context, call protocol.ScopedKnowledgeCall) (Admission, error)

func (*Remote) Subscribe

func (remote *Remote) Subscribe(ctx context.Context, topic protocol.Topic) (Subscription, error)

func (*Remote) Target

func (remote *Remote) Target() protocol.NodeID

func (*Remote) WatchConnection

func (remote *Remote) WatchConnection(ctx context.Context, callback func(ConnectionInfo)) error

type ResourceHandler

type ResourceHandler interface {
	Resource(context.Context, protocol.NodeID, protocol.ResourceCall) (Admission, error)
}

ResourceHandler implements only the limited reverse resource channel. caller is always the authenticated execution peer, never a wire-supplied user.

type Response

type Response struct {
	Output protocol.Output
	Fault  *protocol.Fault
}

Response is the final outcome of an admitted command.

type Route

type Route string
const (
	RouteLocal Route = "local"
	RouteP2P   Route = "p2p"
	RouteRelay Route = "relay"
)

type ScopedKnowledgeHandler

type ScopedKnowledgeHandler interface {
	ScopedKnowledge(context.Context, protocol.NodeID, protocol.ScopedKnowledgeCall) (Admission, error)
}

ScopedKnowledgeHandler validates a controller's plugin scope at its execution Node. Unlike ResourceHandler it accepts no trusted runtime capture.

type ShareSession

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

func (*ShareSession) Close

func (session *ShareSession) Close() error

func (*ShareSession) Next

func (session *ShareSession) Next(ctx context.Context) (ShareState, error)

type ShareState

type ShareState struct {
	Kind        string          `json:"kind"`
	Code        string          `json:"code,omitempty"`
	ExpiresAtMS uint64          `json:"expires_at_ms,omitempty"`
	Fault       *protocol.Fault `json:"fault,omitempty"`
}

type Stream

type Stream interface {
	io.ReadWriteCloser
	CloseWrite() error
}

Stream carries one authorized resource. CloseWrite finishes upload bytes while retaining the read side for the resource owner's publication acknowledgment.

type Subscription

type Subscription interface {
	Next(context.Context) (protocol.Update, error)
	Close() error
}

Subscription observes one resource owned by the selected Node. Next honors its context; Close releases the observation and is safe to call more than once.

type Transport

type Transport interface {
	Open(context.Context, protocol.StreamID) (Stream, error)
	Target() protocol.NodeID
	Dispatch(context.Context, protocol.Request) (Admission, error)
	Subscribe(context.Context, protocol.Topic) (Subscription, error)
	WatchConnection(context.Context, func(ConnectionInfo)) error
}

Transport binds a controller to one Node without owning business state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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