Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 78d174c

Browse files
author
Hans Moog
committed
Feat: added flags to disable autopeering for entry nodes
1 parent 7d4d561 commit 78d174c

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

plugins/autopeering/parameters/parameters.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package parameters
33
import "github.com/iotaledger/goshimmer/packages/parameter"
44

55
var (
6-
ADDRESS = parameter.AddString("AUTOPEERING/ADDRESS", "0.0.0.0", "address to bind for incoming peering requests")
7-
ENTRY_NODES = parameter.AddString("AUTOPEERING/ENTRY_NODES", "0d828930890386f036eb77982cc067c5429f7b8f@82.165.29.179:14626", "list of trusted entry nodes for auto peering")
8-
PORT = parameter.AddInt("AUTOPEERING/PORT", 14626, "tcp port for incoming peering requests")
6+
ADDRESS = parameter.AddString("AUTOPEERING/ADDRESS", "0.0.0.0", "address to bind for incoming peering requests")
7+
ENTRY_NODES = parameter.AddString("AUTOPEERING/ENTRY_NODES", "0d828930890386f036eb77982cc067c5429f7b8f@82.165.29.179:14626", "list of trusted entry nodes for auto peering")
8+
PORT = parameter.AddInt("AUTOPEERING/PORT", 14626, "tcp port for incoming peering requests")
9+
ACCEPT_REQUESTS = parameter.AddBool("AUTOPEERING/ACCEPT_REQUESTS", true, "accept incoming autopeering requests")
10+
SEND_REQUESTS = parameter.AddBool("AUTOPEERING/SEND_REQUESTS", true, "send autopeering requests")
911
)

plugins/autopeering/protocol/incoming_request_processor.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package protocol
33
import (
44
"math/rand"
55

6+
"github.com/iotaledger/goshimmer/plugins/autopeering/parameters"
7+
68
"github.com/iotaledger/goshimmer/packages/events"
79
"github.com/iotaledger/goshimmer/packages/node"
810
"github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors"
@@ -25,7 +27,7 @@ func processIncomingRequest(plugin *node.Plugin, req *request.Request) {
2527

2628
knownpeers.INSTANCE.AddOrUpdate(req.Issuer)
2729

28-
if requestShouldBeAccepted(req) {
30+
if *parameters.ACCEPT_REQUESTS.Value && requestShouldBeAccepted(req) {
2931
defer acceptedneighbors.INSTANCE.Lock()()
3032

3133
if requestShouldBeAccepted(req) {

plugins/autopeering/protocol/plugin.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package protocol
22

33
import (
4+
"fmt"
5+
46
"github.com/iotaledger/goshimmer/packages/daemon"
57
"github.com/iotaledger/goshimmer/packages/node"
8+
"github.com/iotaledger/goshimmer/plugins/autopeering/parameters"
69
"github.com/iotaledger/goshimmer/plugins/autopeering/server/tcp"
710
"github.com/iotaledger/goshimmer/plugins/autopeering/server/udp"
811
)
@@ -22,6 +25,13 @@ func Configure(plugin *node.Plugin) {
2225
func Run(plugin *node.Plugin) {
2326
daemon.BackgroundWorker("Autopeering Chosen Neighbor Dropper", createChosenNeighborDropper(plugin))
2427
daemon.BackgroundWorker("Autopeering Accepted Neighbor Dropper", createAcceptedNeighborDropper(plugin))
25-
daemon.BackgroundWorker("Autopeering Outgoing Request Processor", createOutgoingRequestProcessor(plugin))
28+
29+
fmt.Println(*parameters.SEND_REQUESTS.Value)
30+
fmt.Println(*parameters.ACCEPT_REQUESTS.Value)
31+
32+
if *parameters.SEND_REQUESTS.Value {
33+
daemon.BackgroundWorker("Autopeering Outgoing Request Processor", createOutgoingRequestProcessor(plugin))
34+
}
35+
2636
daemon.BackgroundWorker("Autopeering Outgoing Ping Processor", createOutgoingPingProcessor(plugin))
2737
}

0 commit comments

Comments
 (0)