mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-08 14:15:25 +08:00
get right listen for ext conf file
This commit is contained in:
parent
eb2c98d45c
commit
6e59eae1ef
2 changed files with 10 additions and 10 deletions
|
@ -214,7 +214,7 @@ func getExtClientConf(w http.ResponseWriter, r *http.Request) {
|
|||
if network.DefaultKeepalive != 0 {
|
||||
keepalive = "PersistentKeepalive = " + strconv.Itoa(int(network.DefaultKeepalive))
|
||||
}
|
||||
gwendpoint := host.EndpointIP.String() + ":" + strconv.Itoa(host.ListenPort)
|
||||
gwendpoint := host.EndpointIP.String() + ":" + strconv.Itoa(logic.GetPeerListenPort(host))
|
||||
newAllowedIPs := network.AddressRange
|
||||
if newAllowedIPs != "" && network.AddressRange6 != "" {
|
||||
newAllowedIPs += ","
|
||||
|
|
|
@ -201,7 +201,7 @@ func GetProxyUpdateForHost(host *models.Host) (models.ProxyManagerPayload, error
|
|||
if host.IsRelayed {
|
||||
relayHost, err := GetHost(host.RelayedBy)
|
||||
if err == nil {
|
||||
relayEndpoint, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", relayHost.EndpointIP, getPeerListenPort(relayHost)))
|
||||
relayEndpoint, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", relayHost.EndpointIP, GetPeerListenPort(relayHost)))
|
||||
if err != nil {
|
||||
logger.Log(1, "failed to resolve relay node endpoint: ", err.Error())
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ func GetProxyUpdateForHost(host *models.Host) (models.ProxyManagerPayload, error
|
|||
relayedHost := relayedHost
|
||||
payload, err := GetPeerUpdateForHost(&relayedHost)
|
||||
if err == nil {
|
||||
relayedEndpoint, udpErr := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", relayedHost.EndpointIP, getPeerListenPort(&relayedHost)))
|
||||
relayedEndpoint, udpErr := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", relayedHost.EndpointIP, GetPeerListenPort(&relayedHost)))
|
||||
if udpErr == nil {
|
||||
relayPeersMap[relayedHost.PublicKey.String()] = models.RelayedConf{
|
||||
RelayedPeerEndpoint: relayedEndpoint,
|
||||
|
@ -259,14 +259,14 @@ func GetProxyUpdateForHost(host *models.Host) (models.ProxyManagerPayload, error
|
|||
if currPeerConf, found = peerConfMap[peerHost.PublicKey.String()]; !found {
|
||||
currPeerConf = models.PeerConf{
|
||||
Proxy: peerHost.ProxyEnabled,
|
||||
PublicListenPort: int32(getPeerListenPort(peerHost)),
|
||||
PublicListenPort: int32(GetPeerListenPort(peerHost)),
|
||||
}
|
||||
}
|
||||
|
||||
if peerHost.IsRelayed && peerHost.RelayedBy != host.ID.String() {
|
||||
relayHost, err := GetHost(peerHost.RelayedBy)
|
||||
if err == nil {
|
||||
relayTo, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", relayHost.EndpointIP, getPeerListenPort(relayHost)))
|
||||
relayTo, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", relayHost.EndpointIP, GetPeerListenPort(relayHost)))
|
||||
if err == nil {
|
||||
currPeerConf.IsRelayed = true
|
||||
currPeerConf.RelayedTo = relayTo
|
||||
|
@ -375,7 +375,7 @@ func GetPeerUpdateForHost(host *models.Host) (models.HostPeerUpdate, error) {
|
|||
}
|
||||
peerConfig.Endpoint = &net.UDPAddr{
|
||||
IP: peerHost.EndpointIP,
|
||||
Port: getPeerListenPort(peerHost),
|
||||
Port: GetPeerListenPort(peerHost),
|
||||
}
|
||||
|
||||
if uselocal {
|
||||
|
@ -490,7 +490,7 @@ func GetPeerUpdateForHost(host *models.Host) (models.HostPeerUpdate, error) {
|
|||
return hostPeerUpdate, nil
|
||||
}
|
||||
|
||||
func getPeerListenPort(host *models.Host) int {
|
||||
func GetPeerListenPort(host *models.Host) int {
|
||||
peerPort := host.ListenPort
|
||||
if host.ProxyEnabled {
|
||||
if host.PublicListenPort != 0 {
|
||||
|
@ -560,7 +560,7 @@ func GetPeerUpdate(node *models.Node, host *models.Host) (models.PeerUpdate, err
|
|||
Port: peerHost.ListenPort,
|
||||
}
|
||||
if peerHost.ProxyEnabled {
|
||||
peerConfig.Endpoint.Port = getPeerListenPort(peerHost)
|
||||
peerConfig.Endpoint.Port = GetPeerListenPort(peerHost)
|
||||
}
|
||||
if uselocal {
|
||||
peerConfig.Endpoint.IP = peer.LocalAddress.IP
|
||||
|
@ -693,7 +693,7 @@ func GetPeerUpdateLegacy(node *models.Node) (models.PeerUpdate, error) {
|
|||
if node.LocalAddress.String() != peer.LocalAddress.String() && peer.LocalAddress.IP != nil {
|
||||
peerHost.EndpointIP = peer.LocalAddress.IP
|
||||
if peerHost.ListenPort != 0 {
|
||||
peerHost.ListenPort = getPeerListenPort(peerHost)
|
||||
peerHost.ListenPort = GetPeerListenPort(peerHost)
|
||||
}
|
||||
} else {
|
||||
continue
|
||||
|
@ -726,7 +726,7 @@ func GetPeerUpdateLegacy(node *models.Node) (models.PeerUpdate, error) {
|
|||
// or, if port is for some reason zero use the LocalListenPort
|
||||
// but only do this if LocalListenPort is not zero
|
||||
if ((!setUDPPort) || peerHost.ListenPort == 0) && peerHost.ListenPort != 0 {
|
||||
peerHost.ListenPort = getPeerListenPort(peerHost)
|
||||
peerHost.ListenPort = GetPeerListenPort(peerHost)
|
||||
}
|
||||
|
||||
endpoint := peerHost.EndpointIP.String() + ":" + strconv.FormatInt(int64(peerHost.ListenPort), 10)
|
||||
|
|
Loading…
Add table
Reference in a new issue