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'],
);

Constructors

NetworkConfig({List<String> listenAddresses = defaultListenAddresses, List<String> bootstrapPeers = defaultBootstrapPeers, @Deprecated('No connection-limit enforcement exists; this option is ignored.') int maxConnections = 50, @Deprecated('Dial timeouts are not configurable; this option is ignored.') Duration connectionTimeout = const Duration(seconds: 30), bool enableNatTraversal = false, bool enableMDNS = true, bool enableWebTransport = true, bool enableWebRtc = true, bool enableQuic = false, int quicListenPort = 4002, @Deprecated('No QUIC transport exists; this option is ignored.') int quicMaxStreams = 100, @Deprecated('No QUIC transport exists; this option is ignored.') bool preferQuic = false, CircuitRelayConfig circuitRelay = const CircuitRelayConfig(), List<String> stunServers = const [], List<TurnServer> turnServers = const [], @Deprecated('Node identity is derived from the libp2p keypair; ' 'IPFSConfig.nodeId names the mDNS instance. This option is ignored.') String? nodeId, String? delegatedRoutingEndpoint, List<String> ipniEndpoints = const <String>[], List<String> reframeEndpoints = const <String>[], String? swarmKeyPath, Uint8List? privateNetworkPsk})
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, @Deprecated('No connection-limit enforcement exists; this option is ignored.') int maxConnections = 50, @Deprecated('Dial timeouts are not configurable; this option is ignored.') Duration connectionTimeout = const Duration(seconds: 30), bool enableNatTraversal = false, bool enableMDNS = true, bool enableWebTransport = true, bool enableWebRtc = true, bool enableQuic = false, int quicListenPort = 4002, @Deprecated('No QUIC transport exists; this option is ignored.') int quicMaxStreams = 100, @Deprecated('No QUIC transport exists; this option is ignored.') bool preferQuic = false, CircuitRelayConfig? circuitRelay, List<String> stunServers = const [], List<TurnServer> turnServers = const [], String? swarmKeyPath, Uint8List? privateNetworkPsk})
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
ipniEndpoints → List<String>
Optional IPNI endpoints for content routing.
final
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
privateNetworkPsk ↔ Uint8List?
The 32-byte pre-shared key loaded from swarmKeyPath.
getter/setter pair
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
reframeEndpoints → List<String>
Optional Reframe endpoints for delegated routing.
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
swarmKeyPath ↔ String?
Optional path to a libp2p private-network swarm key file.
getter/setter pair
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.
defaultIpniEndpoints → const List<String>
Default IPNI endpoints used when no custom endpoints are configured.
defaultListenAddresses → const List<String>
Default multiaddr listen addresses for TCP.
defaultReframeEndpoints → const List<String>
Default Reframe endpoints used when no custom endpoints are configured.