2
0
Эх сурвалжийг харах

set isstatic field on peer update

Abhishek Kondur 2 жил өмнө
parent
commit
5cf3fcd279

+ 3 - 1
logic/peers.go

@@ -181,6 +181,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 				hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
 				hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
 					Interfaces: peerHost.Interfaces,
 					Interfaces: peerHost.Interfaces,
 					ListenPort: peerPort,
 					ListenPort: peerPort,
+					IsStatic:   peerHost.IsStatic,
 				}
 				}
 				nodePeer = peerConfig
 				nodePeer = peerConfig
 			} else {
 			} else {
@@ -191,6 +192,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 				hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
 				hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
 					Interfaces: peerHost.Interfaces,
 					Interfaces: peerHost.Interfaces,
 					ListenPort: peerPort,
 					ListenPort: peerPort,
+					IsStatic:   peerHost.IsStatic,
 				}
 				}
 				nodePeer = hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]]
 				nodePeer = hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]]
 			}
 			}
@@ -285,7 +287,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 // GetPeerListenPort - given a host, retrieve it's appropriate listening port
 // GetPeerListenPort - given a host, retrieve it's appropriate listening port
 func GetPeerListenPort(host *models.Host) int {
 func GetPeerListenPort(host *models.Host) int {
 	peerPort := host.ListenPort
 	peerPort := host.ListenPort
-	if host.WgPublicListenPort != 0 {
+	if !host.IsStatic && host.WgPublicListenPort != 0 {
 		peerPort = host.WgPublicListenPort
 		peerPort = host.WgPublicListenPort
 	}
 	}
 	return peerPort
 	return peerPort

+ 1 - 0
models/metrics.go

@@ -44,6 +44,7 @@ type HostInfoMap map[string]HostNetworkInfo
 type HostNetworkInfo struct {
 type HostNetworkInfo struct {
 	Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
 	Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
 	ListenPort int     `json:"listen_port" yaml:"listen_port"`
 	ListenPort int     `json:"listen_port" yaml:"listen_port"`
+	IsStatic   bool    `json:"is_static"`
 }
 }
 
 
 // PeerMap - peer map for ids and addresses in metrics
 // PeerMap - peer map for ids and addresses in metrics