Selaa lähdekoodia

add comments to exported items

Abhishek Kondur 2 vuotta sitten
vanhempi
commit
feda5e4245
4 muutettua tiedostoa jossa 15 lisäystä ja 12 poistoa
  1. 1 4
      controllers/network.go
  2. 3 3
      logic/peers.go
  3. 10 5
      models/mqtt.go
  4. 1 0
      mq/publishers.go

+ 1 - 4
controllers/network.go

@@ -144,10 +144,7 @@ func updateNetworkACL(w http.ResponseWriter, r *http.Request) {
 
 	// send peer updates
 	if servercfg.IsMessageQueueBackend() {
-		// if err = mq.PublishPeerUpdate(); err != nil {
-		// 	logger.Log(0, "failed to publish peer update after ACL update on", netname)
-		// }
-		mq.BroadCastAclUpdate(netname)
+		go mq.BroadCastAclUpdate(netname)
 
 	}
 	w.WriteHeader(http.StatusOK)

+ 3 - 3
logic/peers.go

@@ -428,14 +428,14 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
 // GetPeerListenPort - given a host, retrieve it's appropriate listening port
 func GetPeerListenPort(host *models.Host) int {
 	peerPort := host.ListenPort
-	if host.PublicListenPort != 0 {
-		peerPort = host.PublicListenPort
-	}
 	if host.ProxyEnabled {
 		if host.ProxyListenPort != 0 {
 			peerPort = host.ProxyListenPort
 		}
 	}
+	if host.PublicListenPort != 0 {
+		peerPort = host.PublicListenPort
+	}
 	return peerPort
 }
 

+ 10 - 5
models/mqtt.go

@@ -61,15 +61,20 @@ type KeyUpdate struct {
 	Interface string `json:"interface" bson:"interface"`
 }
 
-type PeerActionType string
+// PeerMqActionType - peer update action type
+type PeerMqActionType string
 
 const (
-	AddPeer    PeerActionType = "ADD_PEER"
-	UpdatePeer PeerActionType = "UPDATE_PEER"
-	RemovePeer PeerActionType = "REMOVE_PEER"
+	// AddPeer - peer mq action type for adding peers
+	AddPeer PeerMqActionType = "ADD_PEER"
+	// UpdatePeer - peer mq action type for updating peers
+	UpdatePeer PeerMqActionType = "UPDATE_PEER"
+	// RemovePeer - peer mq action type for removing peers
+	RemovePeer PeerMqActionType = "REMOVE_PEER"
 )
 
+// PeerAction - struct for mq peer actions
 type PeerAction struct {
-	Action PeerActionType       `json:"action"`
+	Action PeerMqActionType     `json:"action"`
 	Peers  []wgtypes.PeerConfig `json:"peers"`
 }

+ 1 - 0
mq/publishers.go

@@ -203,6 +203,7 @@ func BroadCastDelPeer(host *models.Host, network string) error {
 	return nil
 }
 
+// BroadCastAclUpdate - sends new acl updates to peers
 func BroadCastAclUpdate(network string) error {
 	nodes, err := logic.GetNetworkNodes(network)
 	if err != nil {