This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
/
swarm.go
131 lines (109 loc) · 4.69 KB
/
swarm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package config
type SwarmConfig struct {
// AddrFilters specifies a set libp2p addresses that we should never
// dial or receive connections from.
AddrFilters []string
// DisableBandwidthMetrics disables recording of bandwidth metrics for a
// slight reduction in memory usage. You probably don't need to set this
// flag.
DisableBandwidthMetrics bool
// DisableNatPortMap turns off NAT port mapping (UPnP, etc.).
DisableNatPortMap bool
// DisableRelay explicitly disables the relay transport.
//
// Deprecated: This flag is deprecated and is overridden by
// `Swarm.Transports.Relay` if specified.
DisableRelay bool `json:",omitempty"`
// EnableRelayHop makes this node act as a public relay v1
//
// Deprecated: The circuit v1 protocol is deprecated.
// Use `Swarm.RelayService` to configure the circuit v2 relay.
EnableRelayHop bool `json:",omitempty"`
// EnableAutoRelay enables the "auto relay user" feature.
// Node will find and use advertised public relays when it determines that
// it's not reachable from the public internet.
//
// Deprecated: This flag is deprecated and is overriden by
// `Swarm.RelayClient.Enabled` if specified.
EnableAutoRelay bool `json:",omitempty"`
// RelayClient controls the client side of "auto relay" feature.
// When enabled, the node will use relays if it is not publicly reachable.
RelayClient RelayClient
// RelayService.* controls the "relay service".
// When enabled, node will provide a limited relay service to other peers.
RelayService RelayService
// EnableHolePunching enables the hole punching service.
EnableHolePunching Flag `json:",omitempty"`
// Transports contains flags to enable/disable libp2p transports.
Transports Transports
// ConnMgr configures the connection manager.
ConnMgr ConnMgr
}
type RelayClient struct {
// Enables the auto relay feature: will use relays if it is not publicly reachable.
Enabled Flag `json:",omitempty"`
// StaticRelays configures static relays to use when this node is not
// publicly reachable. If set, auto relay will not try to find any
// other relay servers.
StaticRelays []string `json:",omitempty"`
}
// RelayService configures the resources of the circuit v2 relay.
// For every field a reasonable default will be defined in go-ipfs.
type RelayService struct {
// Enables the limited relay service for other peers (circuit v2 relay).
Enabled Flag `json:",omitempty"`
// ConnectionDurationLimit is the time limit before resetting a relayed connection.
ConnectionDurationLimit *OptionalDuration `json:",omitempty"`
// ConnectionDataLimit is the limit of data relayed (on each direction) before resetting the connection.
ConnectionDataLimit *OptionalInteger `json:",omitempty"`
// ReservationTTL is the duration of a new (or refreshed reservation).
ReservationTTL *OptionalDuration `json:",omitempty"`
// MaxReservations is the maximum number of active relay slots.
MaxReservations *OptionalInteger `json:",omitempty"`
// MaxCircuits is the maximum number of open relay connections for each peer; defaults to 16.
MaxCircuits *OptionalInteger `json:",omitempty"`
// BufferSize is the size of the relayed connection buffers.
BufferSize *OptionalInteger `json:",omitempty"`
// MaxReservationsPerPeer is the maximum number of reservations originating from the same peer.
MaxReservationsPerPeer *OptionalInteger `json:",omitempty"`
// MaxReservationsPerIP is the maximum number of reservations originating from the same IP address.
MaxReservationsPerIP *OptionalInteger `json:",omitempty"`
// MaxReservationsPerASN is the maximum number of reservations origination from the same ASN.
MaxReservationsPerASN *OptionalInteger `json:",omitempty"`
}
type Transports struct {
// Network specifies the base transports we'll use for dialing. To
// listen on a transport, add the transport to your Addresses.Swarm.
Network struct {
// All default to on.
QUIC Flag `json:",omitempty"`
TCP Flag `json:",omitempty"`
Websocket Flag `json:",omitempty"`
Relay Flag `json:",omitempty"`
}
// Security specifies the transports used to encrypt insecure network
// transports.
Security struct {
// Defaults to 100.
TLS Priority `json:",omitempty"`
// Defaults to 200.
SECIO Priority `json:",omitempty"`
// Defaults to 300.
Noise Priority `json:",omitempty"`
}
// Multiplexers specifies the transports used to multiplex multiple
// connections over a single duplex connection.
Multiplexers struct {
// Defaults to 100.
Yamux Priority `json:",omitempty"`
// Defaults to 200.
Mplex Priority `json:",omitempty"`
}
}
// ConnMgr defines configuration options for the libp2p connection manager
type ConnMgr struct {
Type string
LowWater int
HighWater int
GracePeriod string
}