Skip to content

Commit aeb7676

Browse files
authored
NET-1357: add endpoint to exisiting peer config (#2973)
* debug logs * add endpoint to exisiting peer config * rm debug logs * don't set port to public port when host is static
1 parent 1ce38f7 commit aeb7676

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

logic/peers.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
9191
if err != nil {
9292
continue
9393
}
94+
9495
if !node.Connected || node.PendingDelete || node.Action == models.NODE_DELETE {
9596
continue
9697
}
@@ -260,6 +261,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
260261
peerAllowedIPs = append(peerAllowedIPs, peerConfig.AllowedIPs...)
261262
hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].AllowedIPs = peerAllowedIPs
262263
hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].Remove = false
264+
hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].Endpoint = peerConfig.Endpoint
263265
hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
264266
Interfaces: peerHost.Interfaces,
265267
ListenPort: peerHost.ListenPort,
@@ -344,6 +346,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
344346
},
345347
}
346348
}
349+
347350
}
348351
// == post peer calculations ==
349352
// indicate removal if no allowed IPs were calculated
@@ -394,7 +397,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
394397
// GetPeerListenPort - given a host, retrieve it's appropriate listening port
395398
func GetPeerListenPort(host *models.Host) int {
396399
peerPort := host.ListenPort
397-
if host.WgPublicListenPort != 0 {
400+
if !host.IsStaticPort && host.WgPublicListenPort != 0 {
398401
peerPort = host.WgPublicListenPort
399402
}
400403
return peerPort

0 commit comments

Comments
 (0)