scp2p_core/config.rs
1// Copyright (c) 2024-2026 Vanyo Vanev / Tech Art Ltd
2// SPDX-License-Identifier: MPL-2.0
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at https://mozilla.org/MPL/2.0/.
7use std::net::SocketAddr;
8
9use crate::capabilities::Capabilities;
10
11#[derive(Debug, Clone)]
12pub struct NodeConfig {
13 pub bind_quic: Option<SocketAddr>,
14 pub bind_tcp: Option<SocketAddr>,
15 pub capabilities: Capabilities,
16 pub bootstrap_peers: Vec<String>,
17 /// Maximum number of share subscriptions this node will hold.
18 ///
19 /// Subscriptions drive sync I/O, search-index RAM, and SQLite FTS5 write
20 /// volume. An unbounded count causes O(N²) persist I/O and multi-GB RAM
21 /// use in active communities. Default: 200.
22 pub max_subscriptions: usize,
23 /// When `true` (default), newly created publisher identities are
24 /// encrypted at rest using a key derived from the node's stable identity
25 /// key via blake3. On restart, if the node key is available in persisted
26 /// state, encrypted publisher identities are automatically decrypted
27 /// without user interaction. When the node key itself is passphrase-
28 /// protected, publisher key unlocking follows the same gate.
29 pub auto_protect_publisher_keys: bool,
30 /// When `true`, `ListCommunityPublicShares` requests to this node must
31 /// include a valid, unexpired `CommunityMembershipToken` for the
32 /// requester. In permissive mode (default `false`), any caller can
33 /// enumerate this node's community public shares.
34 pub community_strict_mode: bool,
35}
36
37impl Default for NodeConfig {
38 fn default() -> Self {
39 Self {
40 bind_quic: Some("0.0.0.0:7000".parse().expect("valid socket")),
41 bind_tcp: Some("0.0.0.0:7001".parse().expect("valid socket")),
42 capabilities: Capabilities {
43 dht: true,
44 store: true,
45 relay: false,
46 content_seed: true,
47 mobile_light: false,
48 },
49 bootstrap_peers: vec![],
50 max_subscriptions: 200,
51 auto_protect_publisher_keys: true,
52 community_strict_mode: false,
53 }
54 }
55}