Back to Site
Loading...
Searching...
No Matches
librats::NodeConfig Struct Reference

#include <config.h>

Collaboration diagram for librats::NodeConfig:
[legend]

Public Types

enum class  Security { Noise , Plaintext }
 Secure channel to use for peer connections. More...
 

Public Attributes

uint16_t listen_port = 0
 Listen port for inbound peers.
 
bool enable_listen = true
 
std::string bind_address = ""
 Interface to bind the listener to.
 
size_t reactor_threads = 1
 Number of reactor threads.
 
size_t max_peers = 0
 Maximum number of established peers.
 
Security security = Security::Noise
 
std::string protocol_name = "librats"
 Application protocol identity.
 
std::string protocol_version = "1.0"
 
std::string data_dir = ""
 Directory for persistent state.
 
bool enable_network_monitor = true
 Watch the host for network configuration changes (interface up/down, IP add/remove, route flip, wake-from-sleep) and publish NetworkChanged on the node's EventBus so subsystems can renew port mappings, re-run STUN and re-announce.
 

Detailed Description

Definition at line 13 of file config.h.

Member Enumeration Documentation

◆ Security

enum class librats::NodeConfig::Security
strong

Secure channel to use for peer connections.

Enumerator
Noise 
Plaintext 

Definition at line 40 of file config.h.

Member Data Documentation

◆ bind_address

std::string librats::NodeConfig::bind_address = ""

Interface to bind the listener to.

The address family is derived from it:

  • "" or "::" → dual-stack wildcard: reachable over both IPv6 and IPv4 (IPv4-mapped) on all interfaces. This is the default.
  • "0.0.0.0" → IPv4 on all interfaces.
  • an IPv6 literal → IPv6-only, that interface (e.g. "::1" for v6 loopback).
  • an IPv4 literal → IPv4, that interface (e.g. "127.0.0.1" for v4 loopback). Bare IPv6 literals are written without brackets here; peer endpoints rendered as text use bracketed "[ip]:port" form (see core/address.h).

Definition at line 27 of file config.h.

◆ data_dir

std::string librats::NodeConfig::data_dir = ""

Directory for persistent state.

Empty = ephemeral (a fresh random identity each run). When set, the node's Noise keypair is loaded from / saved to "<data_dir>/identity.key", giving a stable PeerId across restarts.

Definition at line 53 of file config.h.

◆ enable_listen

bool librats::NodeConfig::enable_listen = true

Definition at line 17 of file config.h.

◆ enable_network_monitor

bool librats::NodeConfig::enable_network_monitor = true

Watch the host for network configuration changes (interface up/down, IP add/remove, route flip, wake-from-sleep) and publish NetworkChanged on the node's EventBus so subsystems can renew port mappings, re-run STUN and re-announce.

Costs one mostly-idle monitor thread. See node/host_events.h.

Definition at line 59 of file config.h.

◆ listen_port

uint16_t librats::NodeConfig::listen_port = 0

Listen port for inbound peers.

0 picks an ephemeral port. Ignored if enable_listen is false (client-only node).

Definition at line 16 of file config.h.

◆ max_peers

size_t librats::NodeConfig::max_peers = 0

Maximum number of established peers.

0 means unlimited. The limit guards inbound connections (a flood is refused at accept, before any handshake); outbound dials we initiate are always honored. Runtime-adjustable via Node::set_max_peers().

Definition at line 37 of file config.h.

◆ protocol_name

std::string librats::NodeConfig::protocol_name = "librats"

Application protocol identity.

Bound into the Noise handshake prologue, so two nodes whose (name, version) differ cannot complete a handshake — a cheap, cryptographically-enforced way to keep separate apps from cross- connecting. Both peers must match exactly. (No effect under Plaintext.)

Definition at line 47 of file config.h.

Referenced by librats::Node::protocol_name().

◆ protocol_version

std::string librats::NodeConfig::protocol_version = "1.0"

Definition at line 48 of file config.h.

Referenced by librats::Node::protocol_version().

◆ reactor_threads

size_t librats::NodeConfig::reactor_threads = 1

Number of reactor threads.

1 is plenty for thousands of peers; larger pools shard outbound connections across cores.

Definition at line 31 of file config.h.

◆ security

Security librats::NodeConfig::security = Security::Noise

Definition at line 41 of file config.h.


The documentation for this struct was generated from the following file: