network

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package network provides LAN discovery (mDNS) and PIN-based credential exchange for sync setup.

Index

Constants

View Source
const DingovaultService = "_dingovault._tcp"

DingovaultService is the mDNS DNS-SD service name for peer discovery.

Variables

This section is empty.

Functions

func StartPINAdvertiser

func StartPINAdvertiser(ctx context.Context, instance string, pairingPort int, cred PairingCredentials) (pin string, stop func(), err error)

StartPINAdvertiser listens for pairing connections, publishes mDNS, and returns a 4-digit PIN. stop closes the listener and mDNS server; it is safe to call more than once.

Types

type PairingCredentials

type PairingCredentials struct {
	WebDAVURL        string `json:"webdavUrl"`
	WebDAVUser       string `json:"webdavUser"`
	WebDAVPassword   string `json:"webdavPassword"`
	WebDAVRemoteRoot string `json:"webdavRemoteRoot,omitempty"`
	S3Region         string `json:"s3Region,omitempty"`
	S3Bucket         string `json:"s3Bucket,omitempty"`
	S3Prefix         string `json:"s3Prefix,omitempty"`
	S3AccessKey      string `json:"s3AccessKey,omitempty"`
	S3SecretKey      string `json:"s3SecretKey,omitempty"`
	S3Endpoint       string `json:"s3Endpoint,omitempty"`
}

PairingCredentials is exchanged after a successful PIN check (plaintext on LAN — use only on trusted networks).

func PairWithPeer

func PairWithPeer(ctx context.Context, host string, port int, pin string) (PairingCredentials, error)

PairWithPeer connects to a discovered host, sends the PIN, and decodes sync credentials (WebDAV and optional S3).

type Peer

type Peer struct {
	Name string   `json:"name"`
	Host string   `json:"host"`
	IP   string   `json:"ip"`
	Port int      `json:"port"`
	TXT  []string `json:"txt,omitempty"`
}

Peer is one Dingovault instance discovered on the local network.

func BrowseDingovaultPeers

func BrowseDingovaultPeers(ctx context.Context, timeout time.Duration) ([]Peer, error)

BrowseDingovaultPeers runs a short mDNS query for other Dingovault advertisers on the LAN.

Jump to

Keyboard shortcuts

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