Documentation
¶
Index ¶
- type Config
- type Node
- func (n *Node) Connect(addr string) error
- func (n *Node) ListenPort() int
- func (n *Node) LogEvent(level, kind, message string, fields map[string]any)
- func (n *Node) MeshInfoJSON() string
- func (n *Node) NATType() string
- func (n *Node) NoiseStaticPublicHex() string
- func (n *Node) PublicKey() [32]byte
- func (n *Node) Publish(channel string, data []byte) error
- func (n *Node) SetEventCallback(cb func(eventType int32, detailJSON string))
- func (n *Node) SetMessageCallback(cb func(channel string, senderID [32]byte, data []byte))
- func (n *Node) SetRelayCallback(cb func(senderID [32]byte, data []byte))
- func (n *Node) Start() error
- func (n *Node) Stop() error
- func (n *Node) Subscribe(channel string) error
- type VeilConfig
- type VeilRelay
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// NetworkID selects the shared substrate (discovery + handshake + relay).
// Leave empty to join the one public network; set only for an isolated
// testnet. This is NOT the room — the room is the meshID passed to NewNode.
NetworkID string `json:"network_id,omitempty"`
Trackers []string `json:"trackers,omitempty"`
AnnounceIntervalSec int `json:"announce_interval_sec,omitempty"`
ListenPort int `json:"listen_port,omitempty"`
MaxPeers int `json:"max_peers,omitempty"`
StaticPeers []string `json:"static_peers,omitempty"`
BootstrapTimeoutSec int `json:"bootstrap_timeout_sec,omitempty"`
LANDiscoveryEnabled *bool `json:"lan_discovery_enabled,omitempty"`
RelayMaxBandwidthKBPS int `json:"relay_max_bandwidth_kbps,omitempty"`
RelayMaxSessions int `json:"relay_max_sessions,omitempty"`
RelaySessionTTLSec int `json:"relay_session_ttl_sec,omitempty"`
SuperNodeMinUptimeSec int `json:"supernode_min_uptime_sec,omitempty"`
UPnPEnabled *bool `json:"upnp_enabled,omitempty"`
NATPMPEnabled *bool `json:"natpmp_enabled,omitempty"`
PCPEnabled *bool `json:"pcp_enabled,omitempty"`
HolePunchAttempts int `json:"hole_punch_attempts,omitempty"`
HighThroughput *bool `json:"high_throughput,omitempty"`
StreamBufferSize int `json:"stream_buffer_size,omitempty"`
UDPBufferSize int `json:"udp_buffer_size,omitempty"`
HandshakeTimeoutSec int `json:"handshake_timeout_sec,omitempty"`
MaxMessageSizeBytes int `json:"max_message_size_bytes,omitempty"`
// TelemetryEnabled turns on the privacy-preserving observability layer: the
// node contributes DP-noised, per-epoch aggregate metrics under an
// unlinkable ephemeral id and gossips a self-verifying network snapshot.
// Nothing here exposes the node's address or stable identity.
TelemetryEnabled *bool `json:"telemetry_enabled,omitempty"`
TelemetryEpochSec int `json:"telemetry_epoch_sec,omitempty"`
TelemetryKAnon int `json:"telemetry_k_anon,omitempty"`
// Axiom error/log telemetry (opt-in). When AxiomToken and AxiomDataset are
// both set, the node ships structured errors (listen/relay/handshake
// failures, plus anything reported via LogEvent) and periodic node-stats
// (peer/supernode/relay counts) to Axiom. AxiomEndpoint is the ingest base
// URL — leave empty for the cloud default, or set the region edge (e.g.
// https://eu-central-1.aws.edge.axiom.co). AxiomService identifies the host
// (e.g. "mossspore-0.6.9", "gse-4576510"). The token is ingest-only.
AxiomToken string `json:"axiom_token,omitempty"`
AxiomDataset string `json:"axiom_dataset,omitempty"`
AxiomEndpoint string `json:"axiom_endpoint,omitempty"`
AxiomService string `json:"axiom_service,omitempty"`
// DHTEnabled toggles the BitTorrent-DHT peer-discovery source. Nil keeps the
// default (on). Set false to rely solely on trackers/static peers.
DHTEnabled *bool `json:"dht_enabled,omitempty"`
// Veil configures the DPI-resistant "Reality" transport bearer. A relay
// sets Role="listener"; a client behind DPI lists the relays to reach in
// Relays. Omitted (nil) leaves it disabled.
Veil *VeilConfig `json:"veil,omitempty"`
IdentityPath string `json:"identity_path,omitempty"`
}
Config mirrors the subset of mesh.Config relevant for external consumers.
func ConfigFromJSON ¶
ConfigFromJSON parses a JSON-encoded configuration string.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node wraps the internal mesh node, providing the public API for MossSpore and other consumers of the Moss library.
func NewNode ¶
NewNode creates a new Moss node with the given mesh ID, optional PSK, and configuration. The identity is either loaded from the path specified in Config.IdentityPath or generated and saved to that path.
func (*Node) ListenPort ¶
ListenPort returns the port the node is listening on. Useful when ListenPort was set to 0 (OS-assigned port).
func (*Node) LogEvent ¶ added in v0.6.18
LogEvent ships a structured event to Axiom when the sink is enabled (a no-op otherwise). level is "error" | "warn" | "info", kind a short slug, message free text, and fields optional context (no PII). Lets a Go host report its own errors alongside moss's.
func (*Node) MeshInfoJSON ¶
MeshInfoJSON returns a JSON string describing the current node state, including peer count, NAT type, relay status, and channel subscriptions.
func (*Node) NATType ¶
NATType returns the detected NAT type as a string (e.g. "public", "full_cone", "restricted_cone", "symmetric_nat").
func (*Node) NoiseStaticPublicHex ¶ added in v0.6.21
NoiseStaticPublicHex returns the node's X25519 Noise static public key as hex. A relay operator publishes this so Veil dialers can pin it in their veil relay config (`pubkey`); it is the key the masked-tunnel auth secret is derived from, distinct from PublicKey (the Ed25519 identity key).
func (*Node) SetEventCallback ¶
SetEventCallback registers a callback for lifecycle and network events. Pass nil to clear.
func (*Node) SetMessageCallback ¶ added in v0.6.19
SetMessageCallback registers a callback for pub/sub messages delivered on the channels this node is subscribed to. cb receives the channel, the sender's public key, and the payload. Pass nil to clear.
func (*Node) SetRelayCallback ¶
SetRelayCallback registers a callback for relayed data packets. Pass nil to clear.
func (*Node) Start ¶
Start starts the node, binding to the configured listen port and beginning peer discovery, relay service, and gossip protocol.
type VeilConfig ¶ added in v0.6.21
type VeilConfig struct {
Enabled bool `json:"enabled"`
Role string `json:"role,omitempty"` // "listener" or "dialer" (default)
ListenAddr string `json:"listen_addr,omitempty"` // listener bind, host:port
CoverSNI string `json:"cover_sni,omitempty"`
TargetAddr string `json:"target_addr,omitempty"` // listener: real origin for spliced probes
Relays []VeilRelay `json:"relays,omitempty"` // dialer: known Veil-fronted relays
}
VeilConfig is the public mirror of the Veil "Reality" DPI-mask settings (see mesh.VeilConfig). CoverSNI must match on both legs and SHOULD be a real domain the listener can reach.
type VeilRelay ¶ added in v0.6.21
type VeilRelay struct {
Addr string `json:"addr"`
CoverSNI string `json:"cover_sni"`
PubKeyHex string `json:"pubkey"`
}
VeilRelay is a public mirror of mesh.VeilRelay: a Veil-fronted relay a dialer bootstraps through. PubKeyHex is the relay's 32-byte static Noise public key in hex.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
moss-ffi
command
|
|
|
moss-gateway
command
Command moss-gateway runs Moss nodes with telemetry enabled and exposes a read-only HTTP surface so a browser explorer (e.g.
|
Command moss-gateway runs Moss nodes with telemetry enabled and exposes a read-only HTTP surface so a browser explorer (e.g. |
|
moss-node-wasm
command
This package targets WebAssembly (GOOS=js GOARCH=wasm).
|
This package targets WebAssembly (GOOS=js GOARCH=wasm). |
|
moss-signal
command
Command moss-signal is a minimal WebRTC signaling relay for browser Moss peers.
|
Command moss-signal is a minimal WebRTC signaling relay for browser Moss peers. |
|
moss-wasm
command
This package targets WebAssembly (GOOS=js GOARCH=wasm).
|
This package targets WebAssembly (GOOS=js GOARCH=wasm). |
|
internal
|
|
|
geo
Package geo maps peer IP addresses to a coarse location (country / continent) so relay selection can prefer a relay close to the peer it must reach, shortening the relay↔target leg.
|
Package geo maps peer IP addresses to a coarse location (country / continent) so relay selection can prefer a relay close to the peer it must reach, shortening the relay↔target leg. |
|
observe
Package observe provides the read-only, client-side primitives a network explorer needs to TRUST telemetry it did not produce: hash-chain continuity verification, cross-gateway agreement, and a deterministic topology *simulation* derived from aggregate statistics.
|
Package observe provides the read-only, client-side primitives a network explorer needs to TRUST telemetry it did not produce: hash-chain continuity verification, cross-gateway agreement, and a deterministic topology *simulation* derived from aggregate statistics. |
|
overlay
Package overlay implements the Kademlia-style routing layer moss uses to find things at scale: which nodes exist, where a peer is attached, and who subscribes to a channel.
|
Package overlay implements the Kademlia-style routing layer moss uses to find things at scale: which nodes exist, where a peer is attached, and who subscribes to a channel. |
|
telemetry
Package telemetry provides an opt-in, best-effort sink that ships structured events (errors and host-supplied logs) to Axiom.
|
Package telemetry provides an opt-in, best-effort sink that ships structured events (errors and host-supplied logs) to Axiom. |