Browse Source

Merge pull request #1248 from gravitl/bugfix_v0.14.4_server_mq_startup

update server mq connection logic to match client
dcarns 3 years ago
parent
commit
99db823789
3 changed files with 3 additions and 3 deletions
  1. 1 1
      logic/wireguard.go
  2. 1 1
      mq/mq.go
  3. 1 1
      mq/util.go

+ 1 - 1
logic/wireguard.go

@@ -166,7 +166,7 @@ func initWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
 		if network.AddressRange6 != "" {
 			net := strings.Split(network.AddressRange6, "/")
 			mask6 = net[len(net)-1]
-			address6 = node.Address
+			address6 = node.Address6
 		}
 
 		setKernelDevice(ifacename, address4, mask4, address6, mask6)

+ 1 - 1
mq/mq.go

@@ -54,7 +54,7 @@ func SetupMQTT(publish bool) mqtt.Client {
 	client := mqtt.NewClient(opts)
 	tperiod := time.Now().Add(10 * time.Second)
 	for {
-		if token := client.Connect(); token.WaitTimeout(MQ_TIMEOUT*time.Second) && token.Error() != nil {
+		if token := client.Connect(); !token.WaitTimeout(MQ_TIMEOUT*time.Second) || token.Error() != nil {
 			logger.Log(2, "unable to connect to broker, retrying ...")
 			if time.Now().After(tperiod) {
 				if token.Error() == nil {

+ 1 - 1
mq/util.go

@@ -67,7 +67,7 @@ func publish(node *models.Node, dest string, msg []byte) error {
 	if encryptErr != nil {
 		return encryptErr
 	}
-	if token := client.Publish(dest, 0, true, encrypted); token.WaitTimeout(MQ_TIMEOUT*time.Second) && token.Error() != nil {
+	if token := client.Publish(dest, 0, true, encrypted); !token.WaitTimeout(MQ_TIMEOUT*time.Second) || token.Error() != nil {
 		var err error
 		if token.Error() == nil {
 			err = errors.New("connection timeout")