diff --git a/plugins/autopeering/parameters/parameters.go b/plugins/autopeering/parameters/parameters.go index 7f365c60d81efae5894574dd762f042a811c39d9..72992708d062bf7376c88d28810b72bbee4490ea 100644 --- a/plugins/autopeering/parameters/parameters.go +++ b/plugins/autopeering/parameters/parameters.go @@ -3,7 +3,9 @@ package parameters import "github.com/iotaledger/goshimmer/packages/parameter" var ( - ADDRESS = parameter.AddString("AUTOPEERING/ADDRESS", "0.0.0.0", "address to bind for incoming peering requests") - ENTRY_NODES = parameter.AddString("AUTOPEERING/ENTRY_NODES", "0d828930890386f036eb77982cc067c5429f7b8f@82.165.29.179:14626", "list of trusted entry nodes for auto peering") - PORT = parameter.AddInt("AUTOPEERING/PORT", 14626, "tcp port for incoming peering requests") + ADDRESS = parameter.AddString("AUTOPEERING/ADDRESS", "0.0.0.0", "address to bind for incoming peering requests") + ENTRY_NODES = parameter.AddString("AUTOPEERING/ENTRY_NODES", "0d828930890386f036eb77982cc067c5429f7b8f@82.165.29.179:14626", "list of trusted entry nodes for auto peering") + PORT = parameter.AddInt("AUTOPEERING/PORT", 14626, "tcp port for incoming peering requests") + ACCEPT_REQUESTS = parameter.AddBool("AUTOPEERING/ACCEPT_REQUESTS", true, "accept incoming autopeering requests") + SEND_REQUESTS = parameter.AddBool("AUTOPEERING/SEND_REQUESTS", true, "send autopeering requests") ) diff --git a/plugins/autopeering/protocol/incoming_request_processor.go b/plugins/autopeering/protocol/incoming_request_processor.go index 460caedb0643fa908c6c7875775e9465ee7849e8..75d580aff2ea45adf8cbee86b8606e44194d0e1f 100644 --- a/plugins/autopeering/protocol/incoming_request_processor.go +++ b/plugins/autopeering/protocol/incoming_request_processor.go @@ -3,6 +3,8 @@ package protocol import ( "math/rand" + "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" + "github.com/iotaledger/goshimmer/packages/events" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" @@ -25,7 +27,7 @@ func processIncomingRequest(plugin *node.Plugin, req *request.Request) { knownpeers.INSTANCE.AddOrUpdate(req.Issuer) - if requestShouldBeAccepted(req) { + if *parameters.ACCEPT_REQUESTS.Value && requestShouldBeAccepted(req) { defer acceptedneighbors.INSTANCE.Lock()() if requestShouldBeAccepted(req) { diff --git a/plugins/autopeering/protocol/plugin.go b/plugins/autopeering/protocol/plugin.go index a1b175fc871798bd195e5b63e055f0792611cdf6..d8cc9eba0e8d586acf5bafc7da16a959d9b54233 100644 --- a/plugins/autopeering/protocol/plugin.go +++ b/plugins/autopeering/protocol/plugin.go @@ -1,8 +1,11 @@ package protocol import ( + "fmt" + "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" "github.com/iotaledger/goshimmer/plugins/autopeering/server/tcp" "github.com/iotaledger/goshimmer/plugins/autopeering/server/udp" ) @@ -22,6 +25,13 @@ func Configure(plugin *node.Plugin) { func Run(plugin *node.Plugin) { daemon.BackgroundWorker("Autopeering Chosen Neighbor Dropper", createChosenNeighborDropper(plugin)) daemon.BackgroundWorker("Autopeering Accepted Neighbor Dropper", createAcceptedNeighborDropper(plugin)) - daemon.BackgroundWorker("Autopeering Outgoing Request Processor", createOutgoingRequestProcessor(plugin)) + + fmt.Println(*parameters.SEND_REQUESTS.Value) + fmt.Println(*parameters.ACCEPT_REQUESTS.Value) + + if *parameters.SEND_REQUESTS.Value { + daemon.BackgroundWorker("Autopeering Outgoing Request Processor", createOutgoingRequestProcessor(plugin)) + } + daemon.BackgroundWorker("Autopeering Outgoing Ping Processor", createOutgoingPingProcessor(plugin)) }