pub struct P2pConfig {
pub bind_addr: Option<SocketAddr>,
pub known_peers: Vec<SocketAddr>,
pub max_connections: usize,
pub auth: AuthConfig,
pub nat: NatConfig,
pub timeouts: TimeoutConfig,
pub pqc: PqcConfig,
pub mtu: MtuConfig,
pub stats_interval: Duration,
}Expand description
Configuration for ant-quic P2P endpoints
This struct provides all configuration options for P2P networking including NAT traversal, authentication, MTU settings, and post-quantum cryptography.
Named P2pConfig to avoid collision with the low-level config::EndpointConfig
which is used for QUIC protocol settings.
§Pure P2P Design (v0.13.0+)
All nodes are symmetric - they can connect, accept connections, and coordinate NAT traversal for peers. There is no role distinction.
Fields§
§bind_addr: Option<SocketAddr>Local address to bind to. If None, an ephemeral port is auto-assigned
with enhanced security through port randomization.
known_peers: Vec<SocketAddr>Known peers for initial discovery and NAT traversal coordination These can be any nodes in the network - all nodes are symmetric.
max_connections: usizeMaximum number of concurrent connections
auth: AuthConfigAuthentication configuration
nat: NatConfigNAT traversal configuration
timeouts: TimeoutConfigTimeout configuration for all operations
pqc: PqcConfigPost-quantum cryptography configuration
mtu: MtuConfigMTU configuration for network packet sizing
stats_interval: DurationInterval for collecting and reporting statistics
Implementations§
Source§impl P2pConfig
impl P2pConfig
Sourcepub fn builder() -> P2pConfigBuilder
pub fn builder() -> P2pConfigBuilder
Create a new configuration builder
Sourcepub fn to_nat_config(&self) -> NatTraversalConfig
pub fn to_nat_config(&self) -> NatTraversalConfig
Convert to NatTraversalConfig for internal use
Sourcepub fn to_nat_config_with_key(
&self,
identity_key: SigningKey,
) -> NatTraversalConfig
pub fn to_nat_config_with_key( &self, identity_key: SigningKey, ) -> NatTraversalConfig
Convert to NatTraversalConfig with a specific identity key
This ensures the same Ed25519 keypair is used for both P2pEndpoint authentication and TLS/RPK identity in NatTraversalEndpoint.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for P2pConfig
impl RefUnwindSafe for P2pConfig
impl Send for P2pConfig
impl Sync for P2pConfig
impl Unpin for P2pConfig
impl UnwindSafe for P2pConfig
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)