mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-19 23:26:19 +08:00
NET-186: Wg public listen port (#2344)
* fetch public listen of wg if present * check if wg pub listen port has been changed on host update * wg public port to host api model for visibility * rm comment
This commit is contained in:
@@ -220,11 +220,12 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
|
||||
}
|
||||
peerConfig.Endpoint = &net.UDPAddr{
|
||||
IP: peerHost.EndpointIP,
|
||||
Port: peerHost.ListenPort,
|
||||
Port: getPeerWgListenPort(peerHost),
|
||||
}
|
||||
|
||||
if uselocal {
|
||||
peerConfig.Endpoint.IP = peer.LocalAddress.IP
|
||||
peerConfig.Endpoint.Port = peerHost.ListenPort
|
||||
}
|
||||
allowedips := GetAllowedIPs(&node, &peer, nil)
|
||||
if peer.IsIngressGateway {
|
||||
@@ -425,9 +426,21 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
|
||||
return hostPeerUpdate, nil
|
||||
}
|
||||
|
||||
// getPeerWgListenPort - fetches the wg listen port for the host
|
||||
func getPeerWgListenPort(host *models.Host) int {
|
||||
peerPort := host.ListenPort
|
||||
if host.WgPublicListenPort != 0 {
|
||||
peerPort = host.WgPublicListenPort
|
||||
}
|
||||
return peerPort
|
||||
}
|
||||
|
||||
// GetPeerListenPort - given a host, retrieve it's appropriate listening port
|
||||
func GetPeerListenPort(host *models.Host) int {
|
||||
peerPort := host.ListenPort
|
||||
if host.WgPublicListenPort != 0 {
|
||||
peerPort = host.WgPublicListenPort
|
||||
}
|
||||
if host.ProxyEnabled {
|
||||
if host.PublicListenPort != 0 {
|
||||
peerPort = host.PublicListenPort
|
||||
|
Reference in New Issue
Block a user