Documentation
¶
Index ¶
- type Config
- type Node
- func (n *Node) Connect(addr string) error
- func (n *Node) ListenPort() int
- func (n *Node) MeshInfoJSON() string
- func (n *Node) NATType() 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) 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
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"`
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) 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) SetEventCallback ¶
SetEventCallback registers a callback for lifecycle and network events. 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.
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. |