From 9e0809774bf990e7514327d1683ac8b03923167c 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 --- config/swarm.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/config/swarm.go b/config/swarm.go index 95d4a3d8912..5f02b08376d 100644 --- a/config/swarm.go +++ b/config/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 51834c3c704eb137f3ba38c6973fa798897a3817 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 --- config/swarm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/swarm.go b/config/swarm.go index 5f02b08376d..2d2a3813377 100644 --- a/config/swarm.go +++ b/config/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 2d6478587bd60d1ef4d451bef8ab8129ee68e17e 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 --- config/swarm.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/swarm.go b/config/swarm.go index 2d2a3813377..e79d42c97ee 100644 --- a/config/swarm.go +++ b/config/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.