From a26f871c3d5224bbe1d79b7eb1df6c99efeb1ae5 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 14 Nov 2021 16:49:10 +0400 Subject: [PATCH 1/3] improve AutoRelay configuration, add config option for static relays --- swarm.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/swarm.go b/swarm.go index 95d4a3d..5f02b08 100644 --- a/swarm.go +++ b/swarm.go @@ -22,9 +22,16 @@ type SwarmConfig struct { // 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.AutoRelay.Enabled` if specified. EnableAutoRelay bool - // RelayService.* controls the "auto relay service" feature. + // AutoRelay controls the "auto relay service" feature. + // When enabled, the node will use relays if it is not publicly reachable. + AutoRelay AutoRelay + + // RelayService.* controls the "relay service". // When enabled, node will provide a limited relay service to other peers. RelayService RelayService @@ -35,6 +42,16 @@ type SwarmConfig struct { ConnMgr ConnMgr } +type AutoRelay struct { + // Enables the AutoRelay. + 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 { From 3e9e247eb0fc6f495c4475ea13ede36037958c2d Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 15 Nov 2021 17:34:58 +0400 Subject: [PATCH 2/3] set Swarm.EnableAutoRelay to omitempty Co-authored-by: Marcin Rataj --- swarm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swarm.go b/swarm.go index 5f02b08..2d2a381 100644 --- a/swarm.go +++ b/swarm.go @@ -25,7 +25,7 @@ type SwarmConfig struct { // // Deprecated: This flag is deprecated and is overriden by // `Swarm.AutoRelay.Enabled` if specified. - EnableAutoRelay bool + EnableAutoRelay bool `json:",omitempty"` // AutoRelay controls the "auto relay service" feature. // When enabled, the node will use relays if it is not publicly reachable. From 4cb1c6f894b72cdaecb2861dc9c467745127cfe0 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 15 Nov 2021 15:44:27 +0100 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20AutoRelay=20=E2=86=92=20RelayCl?= =?UTF-8?q?ient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/ipfs/go-ipfs-config/pull/154#discussion_r749324695 --- swarm.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/swarm.go b/swarm.go index 2d2a381..e79d42c 100644 --- a/swarm.go +++ b/swarm.go @@ -27,9 +27,9 @@ type SwarmConfig struct { // `Swarm.AutoRelay.Enabled` if specified. EnableAutoRelay bool `json:",omitempty"` - // AutoRelay controls the "auto relay service" feature. + // RelayClient controls the client side of "auto relay" feature. // When enabled, the node will use relays if it is not publicly reachable. - AutoRelay AutoRelay + RelayClient RelayClient // RelayService.* controls the "relay service". // When enabled, node will provide a limited relay service to other peers. @@ -42,8 +42,8 @@ type SwarmConfig struct { ConnMgr ConnMgr } -type AutoRelay struct { - // Enables the AutoRelay. +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 @@ -55,7 +55,7 @@ type AutoRelay struct { // 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 (circuit v2 relay). + // 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.