lan

package
v0.1.0-preview.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 38 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 ChunkSize = 64 << 10
View Source
const MaxSize = int64(1) << 40
View Source
const Protocol = 1
View Source
const ServiceType = "_pinelink._tcp"

Variables

View Source
var ErrConflict = errors.New("local transfer state conflict")
View Source
var ErrForbidden = errors.New("local peer is not authorized")
View Source
var ErrUnauthorized = errors.New("local peer authentication required")

Functions

func Advertise(peer Peer) (func(), error)

func ConfigureCloudSync

func ConfigureCloudSync(identity *secure.Identity, directory, address, pin, owner, device string) error

func DefaultAddress

func DefaultAddress(listener net.Listener) (string, error)

func DisableCloudSync

func DisableCloudSync(identity *secure.Identity, directory string) error

func RunSync

func RunSync(ctx context.Context, identity *secure.Identity, directory string) error

func SyncOnce

func SyncOnce(ctx context.Context, identity *secure.Identity, directory string) error

Types

type Change

type Change struct {
	Sequence    int64           `json:"sequence"`
	EventID     string          `json:"event_id"`
	Kind        string          `json:"kind"`
	AggregateID string          `json:"aggregate_id"`
	Payload     json.RawMessage `json:"payload"`
	CreatedAt   string          `json:"created_at"`
}

type ChangePage

type ChangePage struct {
	DeviceID string   `json:"source_device_id"`
	StreamID string   `json:"stream_id"`
	Items    []Change `json:"items"`
	Next     int64    `json:"next_sequence"`
}

func Changes

func Changes(identity *secure.Identity, directory string, after int64, limit int, stream string) (ChangePage, error)

type Client

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

func NewClient

func NewClient(identity *secure.Identity, peer Peer, directory string) (*Client, error)

func (*Client) Action

func (c *Client) Action(ctx context.Context, id, action string, version int64) (Transfer, error)

func (*Client) AutomaticSend

func (c *Client) AutomaticSend(id string, enabled bool) error

func (*Client) Close

func (c *Client) Close()

func (*Client) Forget

func (c *Client) Forget(ctx context.Context, id string) error

func (*Client) Info

func (c *Client) Info(ctx context.Context) (Peer, error)

func (*Client) Invite

func (c *Client) Invite(ctx context.Context) (Invitation, error)

func (*Client) Pair

func (c *Client) Pair(ctx context.Context, invitation Invitation, name string) (PairRequest, error)

func (*Client) PairAction

func (c *Client) PairAction(ctx context.Context, id, action string) (PairRequest, error)

func (*Client) PairRequests

func (c *Client) PairRequests(ctx context.Context) ([]PairRequest, error)

func (*Client) PairStatus

func (c *Client) PairStatus(ctx context.Context, id string) (PairRequest, error)

func (*Client) Peer

func (c *Client) Peer() Peer

func (*Client) PrepareFile

func (c *Client) PrepareFile(ctx context.Context, input string) (Transfer, error)

func (*Client) Remember

func (c *Client) Remember() error

func (*Client) Send

func (c *Client) Send(ctx context.Context, id string, observe func(Transfer)) (result Transfer, resultErr error)

func (*Client) Transfer

func (c *Client) Transfer(ctx context.Context, id string) (Transfer, error)

func (*Client) Transfers

func (c *Client) Transfers(ctx context.Context) ([]Transfer, error)

type Config

type Config struct {
	Directory        string
	ReceiveDirectory string
	Name             string
	Address          string
	AutoPair         bool
	AutoAccept       bool
	TransferTTL      time.Duration
	Sync             bool
}

type Invitation

type Invitation struct {
	Version   int    `json:"version"`
	Peer      Peer   `json:"peer"`
	Token     string `json:"token"`
	ExpiresIn int    `json:"expires_in"`
	Signature string `json:"signature"`
}

func ParseInvitation

func ParseInvitation(code string) (Invitation, error)

func (Invitation) Code

func (i Invitation) Code() (string, error)

type Nearby

type Nearby struct {
	ID        string   `json:"id"`
	Name      string   `json:"name"`
	Addresses []string `json:"addresses"`
}

func Discover

func Discover(ctx context.Context) ([]Nearby, error)

type Offer

type Offer struct {
	ID         string `json:"id"`
	CipherRoot string `json:"cipher_root"`
	Size       int64  `json:"size_bytes"`
	Envelope   []byte `json:"envelope"`
}

type PairRequest

type PairRequest struct {
	ID    string `json:"id"`
	Peer  Peer   `json:"peer"`
	State string `json:"state"`
	Code  string `json:"code"`
}

type Peer

type Peer struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	SigningKey    string `json:"signing_key"`
	EncryptionKey string `json:"encryption_key"`
	Address       string `json:"address"`
	Revoked       bool   `json:"revoked,omitempty"`
}

func Describe

func Describe(identity *secure.Identity, name, address string) Peer

func LocalPeer

func LocalPeer(identity *secure.Identity, directory string) (Peer, error)

func ReadContact

func ReadContact(directory, id string) (Peer, error)

func SavedPeer

func SavedPeer(directory, id string) (Peer, error)

type Receipt

type Receipt struct {
	Version     int       `json:"version"`
	TransferID  string    `json:"transfer_id"`
	SenderID    string    `json:"sender_id"`
	RecipientID string    `json:"recipient_id"`
	CipherRoot  string    `json:"cipher_root"`
	PlainRoot   string    `json:"plaintext_root"`
	PlainSize   int64     `json:"plaintext_size"`
	DeliveredAt time.Time `json:"delivered_at"`
	Signature   string    `json:"signature"`
}

func (Receipt) Verify

func (r Receipt) Verify(peer Peer, offer Offer, sender string) error

type ReplicatedHistory

type ReplicatedHistory struct {
	AuthorityRoot string          `json:"authority_root"`
	AggregateID   string          `json:"aggregate_id"`
	SourceRoot    string          `json:"source_root"`
	Kind          string          `json:"kind"`
	Version       int64           `json:"version"`
	Fact          json.RawMessage `json:"fact"`
}

func ReplicaHistory

func ReplicaHistory(identity *secure.Identity, directory string) ([]ReplicatedHistory, error)

type Server

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

func NewServer

func NewServer(identity *secure.Identity, cfg Config) (*Server, error)

func (*Server) Close

func (s *Server) Close()

func (*Server) Invite

func (s *Server) Invite() (Invitation, error)

func (*Server) Peer

func (s *Server) Peer() Peer

func (*Server) Prepare

func (s *Server) Prepare(listener net.Listener) error

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, listener net.Listener) error

type StatusError

type StatusError struct {
	Status        int
	Code, Message string
}

func (*StatusError) Error

func (e *StatusError) Error() string

type StorageInfo

type StorageInfo struct {
	DeviceID      string `json:"device_id"`
	StreamID      string `json:"stream_id"`
	Schema        int    `json:"schema_version"`
	SQLiteVersion string `json:"sqlite_version"`
	JournalMode   string `json:"journal_mode"`
	Synchronous   int    `json:"synchronous"`
	LastSequence  int64  `json:"last_sequence"`
	UnboundOutbox int64  `json:"unbound_outbox_events"`
	InboxFacts    int64  `json:"inbox_facts"`
	Integrity     string `json:"integrity"`
}

func Storage

func Storage(identity *secure.Identity, directory string) (StorageInfo, error)

type SyncTarget

type SyncTarget struct {
	Target        string  `json:"target"`
	Kind          string  `json:"kind"`
	Address       string  `json:"address"`
	Pin           string  `json:"pin"`
	Owner         string  `json:"owner_id"`
	Device        string  `json:"device_id"`
	Enabled       bool    `json:"enabled"`
	Uploaded      int64   `json:"uploaded_sequence"`
	Epoch         string  `json:"pulled_epoch"`
	Pulled        int64   `json:"pulled_sequence"`
	Bootstrapped  bool    `json:"bootstrapped"`
	SnapshotUpper int64   `json:"snapshot_upper"`
	SnapshotKey   string  `json:"snapshot_key"`
	RosterVersion int64   `json:"roster_version"`
	RosterHash    string  `json:"roster_hash"`
	PendingRoster []byte  `json:"-"`
	Failures      int     `json:"failures"`
	Next          *string `json:"next_attempt_at,omitempty"`
	LastError     string  `json:"last_error,omitempty"`
	LastSuccess   *string `json:"last_success_at,omitempty"`
	BoundEpoch    string  `json:"bound_epoch"`
}

func SyncStatus

func SyncStatus(identity *secure.Identity, directory string) ([]SyncTarget, error)

type Transfer

type Transfer struct {
	SampleAgeMillis int64 `json:"sample_age_ms"`
	Offer
	PeerID          string     `json:"peer_id"`
	FileName        string     `json:"file_name"`
	PlainSize       int64      `json:"plaintext_size"`
	PlainRoot       string     `json:"plaintext_root"`
	State           string     `json:"state"`
	Version         int64      `json:"state_version"`
	Acknowledged    int64      `json:"acknowledged_bytes"`
	Revision        int64      `json:"progress_revision"`
	SampledAt       *time.Time `json:"sampled_at,omitempty"`
	ExpiresAt       time.Time  `json:"expires_at"`
	RemainingMillis int64      `json:"remaining_ms"`
	Route           string     `json:"route"`
	Transport       string     `json:"transport"`
	Authority       string     `json:"authority"`
	AuthorityID     string     `json:"authority_device_id"`
	SpoolState      string     `json:"spool_state"`
	Receipt         *Receipt   `json:"receipt,omitempty"`
	OutputName      string     `json:"output_name,omitempty"`
	Direction       string     `json:"direction"`
	Error           string     `json:"error,omitempty"`
}

func History

func History(identity *secure.Identity, directory string) ([]Transfer, error)

History reads local journals without contacting a device or cloud service. Completed sends remain verifiable after their ciphertext cache is removed.

Jump to

Keyboard shortcuts

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