From de13c698d06a45986a85afbce1b2c4314ed518d0 Mon Sep 17 00:00:00 2001 From: IoTMOD Date: Thu, 12 Dec 2019 14:58:01 +0100 Subject: [PATCH 1/2] Fix ZMQ protocols --- plugins/zeromq/parameters.go | 4 +++- plugins/zeromq/plugin.go | 8 ++++---- plugins/zeromq/publisher.go | 7 +++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/zeromq/parameters.go b/plugins/zeromq/parameters.go index 757d1fb62..ab1d85e27 100644 --- a/plugins/zeromq/parameters.go +++ b/plugins/zeromq/parameters.go @@ -3,5 +3,7 @@ package zeromq import flag "github.com/spf13/pflag" func init() { - flag.Int("zmq.port", 5556, "tcp port used to connect to the zmq feed") + flag.String("zmq.protocol", "tcp", "protocol used to connect to the zmq feed [unix, tcp, udp, inproc]") + flag.String("zmq.host", "*", "host used to connect to the zmq feed") + flag.Int("zmq.port", 5556, "port used to connect to the zmq feed") } diff --git a/plugins/zeromq/plugin.go b/plugins/zeromq/plugin.go index 2d96a9af7..3f02a8ef6 100644 --- a/plugins/zeromq/plugin.go +++ b/plugins/zeromq/plugin.go @@ -3,9 +3,6 @@ package zeromq import ( "time" - daemon "github.com/iotaledger/hive.go/daemon/ordered" - "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/hive.go/parameter" "github.com/gohornet/hornet/packages/logger" "github.com/gohornet/hornet/packages/model/hornet" "github.com/gohornet/hornet/packages/model/milestone_index" @@ -15,6 +12,9 @@ import ( "github.com/gohornet/hornet/packages/timeutil" "github.com/gohornet/hornet/packages/workerpool" "github.com/gohornet/hornet/plugins/tangle" + daemon "github.com/iotaledger/hive.go/daemon/ordered" + "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/parameter" ) const ( @@ -180,5 +180,5 @@ func startPublisher() error { } publisher = pub - return publisher.Start(parameter.NodeConfig.GetInt("zmq.port")) + return publisher.Start() } diff --git a/plugins/zeromq/publisher.go b/plugins/zeromq/publisher.go index d652525e3..4e76733bb 100644 --- a/plugins/zeromq/publisher.go +++ b/plugins/zeromq/publisher.go @@ -6,6 +6,7 @@ import ( "strings" zmq "github.com/go-zeromq/zmq4" + "github.com/iotaledger/hive.go/parameter" ) // Publisher is a simple zmq publisher abstraction @@ -24,8 +25,10 @@ func NewPublisher() (*Publisher, error) { } // Start the publisher on the given port. -func (pub *Publisher) Start(port int) error { - return pub.socket.Listen("tcp://*:" + strconv.Itoa(port)) +func (pub *Publisher) Start() error { + port := parameter.NodeConfig.GetInt("zmq.port") + endpoint := parameter.NodeConfig.GetString("zmq.protocol") + "://" + parameter.NodeConfig.GetString("zmq.host") + return pub.socket.Listen(endpoint + ":" + strconv.Itoa(port)) } // Shutdown stops the publisher. From 58133b6f7beb9f2df0ff7836fa1f5ae1cc44d66a Mon Sep 17 00:00:00 2001 From: IoTMOD Date: Thu, 12 Dec 2019 22:00:38 +0100 Subject: [PATCH 2/2] Use 0.0.0.0 as default host --- plugins/zeromq/parameters.go | 2 +- plugins/zeromq/publisher.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/zeromq/parameters.go b/plugins/zeromq/parameters.go index ab1d85e27..e7423b155 100644 --- a/plugins/zeromq/parameters.go +++ b/plugins/zeromq/parameters.go @@ -4,6 +4,6 @@ import flag "github.com/spf13/pflag" func init() { flag.String("zmq.protocol", "tcp", "protocol used to connect to the zmq feed [unix, tcp, udp, inproc]") - flag.String("zmq.host", "*", "host used to connect to the zmq feed") + flag.String("zmq.host", "0.0.0.0", "host used to connect to the zmq feed") flag.Int("zmq.port", 5556, "port used to connect to the zmq feed") } diff --git a/plugins/zeromq/publisher.go b/plugins/zeromq/publisher.go index 4e76733bb..ca74e8cb2 100644 --- a/plugins/zeromq/publisher.go +++ b/plugins/zeromq/publisher.go @@ -26,9 +26,8 @@ func NewPublisher() (*Publisher, error) { // Start the publisher on the given port. func (pub *Publisher) Start() error { - port := parameter.NodeConfig.GetInt("zmq.port") - endpoint := parameter.NodeConfig.GetString("zmq.protocol") + "://" + parameter.NodeConfig.GetString("zmq.host") - return pub.socket.Listen(endpoint + ":" + strconv.Itoa(port)) + endpoint := parameter.NodeConfig.GetString("zmq.protocol") + "://" + parameter.NodeConfig.GetString("zmq.host") + ":" + strconv.Itoa(parameter.NodeConfig.GetInt("zmq.port")) + return pub.socket.Listen(endpoint) } // Shutdown stops the publisher.