master
go 136 lines 5.03 KB
Raw
1 package config
2
3 type SwarmConfig struct {
4 // AddrFilters specifies a set libp2p addresses that we should never
5 // dial or receive connections from.
6 AddrFilters []string
7
8 // DisableBandwidthMetrics disables recording of bandwidth metrics for a
9 // slight reduction in memory usage. You probably don't need to set this
10 // flag.
11 DisableBandwidthMetrics bool
12
13 // DisableNatPortMap turns off NAT port mapping (UPnP, etc.).
14 DisableNatPortMap bool
15
16 // RelayClient controls the client side of "auto relay" feature.
17 // When enabled, the node will use relays if it is not publicly reachable.
18 RelayClient RelayClient
19
20 // RelayService.* controls the "relay service".
21 // When enabled, node will provide a limited relay service to other peers.
22 RelayService RelayService
23
24 // EnableHolePunching enables the hole punching service.
25 EnableHolePunching Flag `json:",omitempty"`
26
27 // Transports contains flags to enable/disable libp2p transports.
28 Transports Transports
29
30 // ConnMgr configures the connection manager.
31 ConnMgr ConnMgr
32
33 // ResourceMgr configures the libp2p Network Resource Manager
34 ResourceMgr ResourceMgr
35 }
36
37 type RelayClient struct {
38 // Enables the auto relay feature: will use relays if it is not publicly reachable.
39 Enabled Flag `json:",omitempty"`
40
41 // StaticRelays configures static relays to use when this node is not
42 // publicly reachable. If set, auto relay will not try to find any
43 // other relay servers.
44 StaticRelays []string `json:",omitempty"`
45 }
46
47 // RelayService configures the resources of the circuit v2 relay.
48 // For every field a reasonable default will be defined in go-ipfs.
49 type RelayService struct {
50 // Enables the limited relay service for other peers (circuit v2 relay).
51 Enabled Flag `json:",omitempty"`
52
53 // ConnectionDurationLimit is the time limit before resetting a relayed connection.
54 ConnectionDurationLimit *OptionalDuration `json:",omitempty"`
55 // ConnectionDataLimit is the limit of data relayed (on each direction) before resetting the connection.
56 ConnectionDataLimit *OptionalInteger `json:",omitempty"`
57
58 // ReservationTTL is the duration of a new (or refreshed reservation).
59 ReservationTTL *OptionalDuration `json:",omitempty"`
60
61 // MaxReservations is the maximum number of active relay slots.
62 MaxReservations *OptionalInteger `json:",omitempty"`
63 // MaxCircuits is the maximum number of open relay connections for each peer; defaults to 16.
64 MaxCircuits *OptionalInteger `json:",omitempty"`
65 // BufferSize is the size of the relayed connection buffers.
66 BufferSize *OptionalInteger `json:",omitempty"`
67
68 // MaxReservationsPerIP is the maximum number of reservations originating from the same IP address.
69 MaxReservationsPerIP *OptionalInteger `json:",omitempty"`
70 // MaxReservationsPerASN is the maximum number of reservations origination from the same ASN.
71 MaxReservationsPerASN *OptionalInteger `json:",omitempty"`
72 }
73
74 type Transports struct {
75 // Network specifies the base transports we'll use for dialing. To
76 // listen on a transport, add the transport to your Addresses.Swarm.
77 Network struct {
78 // All default to on.
79 QUIC Flag `json:",omitempty"`
80 TCP Flag `json:",omitempty"`
81 Websocket Flag `json:",omitempty"`
82 Relay Flag `json:",omitempty"`
83 WebTransport Flag `json:",omitempty"`
84 // except WebRTCDirect which is experimental and opt-in.
85 WebRTCDirect Flag `json:",omitempty"`
86 }
87
88 // Security specifies the transports used to encrypt insecure network
89 // transports.
90 Security struct {
91 // Defaults to 100.
92 TLS Priority `json:",omitempty"`
93 // Defaults to 300.
94 Noise Priority `json:",omitempty"`
95 }
96
97 // Multiplexers specifies the transports used to multiplex multiple
98 // connections over a single duplex connection.
99 Multiplexers struct {
100 // Defaults to 100.
101 Yamux Priority `json:",omitempty"`
102 }
103 }
104
105 // ConnMgr defines configuration options for the libp2p connection manager.
106 type ConnMgr struct {
107 Type *OptionalString `json:",omitempty"`
108 LowWater *OptionalInteger `json:",omitempty"`
109 HighWater *OptionalInteger `json:",omitempty"`
110 GracePeriod *OptionalDuration `json:",omitempty"`
111 SilencePeriod *OptionalDuration `json:",omitempty"`
112 }
113
114 // ResourceMgr defines configuration options for the libp2p Network Resource Manager
115 // <https://github.com/libp2p/go-libp2p/tree/master/p2p/host/resource-manager#readme>
116 type ResourceMgr struct {
117 // Enables the Network Resource Manager feature, default to on.
118 Enabled Flag `json:",omitempty"`
119 Limits swarmLimits `json:",omitempty"`
120
121 MaxMemory *OptionalBytes `json:",omitempty"`
122 MaxFileDescriptors *OptionalInteger `json:",omitempty"`
123
124 // A list of multiaddrs that can bypass normal system limits (but are still
125 // limited by the allowlist scope). Convenience config around
126 // https://pkg.go.dev/github.com/libp2p/go-libp2p/p2p/host/resource-manager#Allowlist.Add
127 Allowlist []string `json:",omitempty"`
128 }
129
130 const (
131 ResourceMgrSystemScope = "system"
132 ResourceMgrTransientScope = "transient"
133 ResourceMgrServiceScopePrefix = "svc:"
134 ResourceMgrProtocolScopePrefix = "proto:"
135 ResourceMgrPeerScopePrefix = "peer:"
136 )