NetworkConfig class

Network configuration for the IPFS node.

Defines listen addresses, bootstrap peers, connection limits, STUN/TURN servers for WebRTC, and other networking parameters.

Example:

final config = NetworkConfig(
  listenAddresses: ['/ip4/0.0.0.0/tcp/4001'],
  maxConnections: 100,
);

Constructors

NetworkConfig({List<String> listenAddresses = defaultListenAddresses, List<String> bootstrapPeers = defaultBootstrapPeers, int maxConnections = 50, Duration connectionTimeout = const Duration(seconds: 30), bool enableNatTraversal = false, bool enableMDNS = true, bool enableWebTransport = true, bool enableWebRtc = true, bool enableQuic = false, int quicListenPort = 4002, int quicMaxStreams = 100, bool preferQuic = false, CircuitRelayConfig circuitRelay = const CircuitRelayConfig(), List<String> stunServers = const [], List<TurnServer> turnServers = const [], String? nodeId, String? delegatedRoutingEndpoint})
Creates a network configuration with the given options.
NetworkConfig.fromJson(Map<String, dynamic> json)
Creates a network configuration from a JSON map.
factory
NetworkConfig.withGeneratedId({List<String> listenAddresses = defaultListenAddresses, List<String> bootstrapPeers = defaultBootstrapPeers, int maxConnections = 50, Duration connectionTimeout = const Duration(seconds: 30), bool enableNatTraversal = false, bool enableMDNS = true, bool enableWebTransport = true, bool enableWebRtc = true, bool enableQuic = false, int quicListenPort = 4002, int quicMaxStreams = 100, bool preferQuic = false, CircuitRelayConfig? circuitRelay, List<String> stunServers = const [], List<TurnServer> turnServers = const []})
Creates a network configuration with the given options and a generated Peer ID.
factory

Properties

bootstrapPeers List<String>
Peers to connect to on startup.
final
circuitRelay CircuitRelayConfig
Circuit relay client configuration.
final
connectionTimeout Duration
Timeout for connection attempts.
final
delegatedRoutingEndpoint String?
Optional HTTP endpoint for delegated routing.
final
enableMDNS bool
Whether to enable mDNS for local peer discovery. Defaults to true.
final
enableNatTraversal bool
Whether to enable NAT traversal (UPnP/NAT-PMP). Defaults to false for security.
final
enableQuic bool
Whether to enable the native QUIC transport.
final
enableWebRtc bool
Whether to enable WebRTC.
final
enableWebTransport bool
Whether to enable WebTransport.
final
hashCode int
The hash code for this object.
no setterinherited
listenAddresses List<String>
Addresses to listen on for incoming connections.
final
maxConnections int
Maximum number of concurrent connections.
final
nodeId String
Unique identifier for this node.
final
preferQuic bool
Whether to prefer QUIC over TCP when dialing a peer that advertises both.
final
quicListenPort int
UDP port the QUIC transport will listen on when enabled and available.
final
quicMaxStreams int
Maximum number of concurrent QUIC streams per connection.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stunServers List<String>
STUN servers for WebRTC ICE negotiation. Default is empty; no production STUN servers are hardcoded.
final
turnServers List<TurnServer>
TURN servers for WebRTC relay fallback. Default is empty.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts the network configuration to a JSON map.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

defaultBootstrapPeers → const List<String>
Default IPFS bootstrap peers.
defaultListenAddresses → const List<String>
Default multiaddr listen addresses for TCP.