mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-14 00:54:21 +08:00
change public listen port field
This commit is contained in:
parent
e290994021
commit
10f724310c
3 changed files with 41 additions and 37 deletions
|
@ -433,8 +433,8 @@ func GetPeerUpdateForHost(host *models.Host) (models.HostPeerUpdate, error) {
|
||||||
func getPeerListenPort(host *models.Host) int {
|
func getPeerListenPort(host *models.Host) int {
|
||||||
peerPort := host.ListenPort
|
peerPort := host.ListenPort
|
||||||
if host.ProxyEnabled {
|
if host.ProxyEnabled {
|
||||||
if host.ProxyPublicListenPort != 0 {
|
if host.PublicListenPort != 0 {
|
||||||
peerPort = host.ProxyPublicListenPort
|
peerPort = host.PublicListenPort
|
||||||
} else if host.ProxyListenPort != 0 {
|
} else if host.ProxyListenPort != 0 {
|
||||||
peerPort = host.ProxyListenPort
|
peerPort = host.ProxyListenPort
|
||||||
}
|
}
|
||||||
|
@ -633,7 +633,7 @@ func GetPeerUpdateLegacy(node *models.Node) (models.PeerUpdate, error) {
|
||||||
if node.LocalAddress.String() != peer.LocalAddress.String() && peer.LocalAddress.IP != nil {
|
if node.LocalAddress.String() != peer.LocalAddress.String() && peer.LocalAddress.IP != nil {
|
||||||
peerHost.EndpointIP = peer.LocalAddress.IP
|
peerHost.EndpointIP = peer.LocalAddress.IP
|
||||||
if peerHost.ListenPort != 0 {
|
if peerHost.ListenPort != 0 {
|
||||||
peerHost.ListenPort = peerHost.ListenPort
|
peerHost.ListenPort = getPeerListenPort(peerHost)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue
|
||||||
|
@ -666,7 +666,7 @@ func GetPeerUpdateLegacy(node *models.Node) (models.PeerUpdate, error) {
|
||||||
// or, if port is for some reason zero use the LocalListenPort
|
// or, if port is for some reason zero use the LocalListenPort
|
||||||
// but only do this if LocalListenPort is not zero
|
// but only do this if LocalListenPort is not zero
|
||||||
if ((!setUDPPort) || peerHost.ListenPort == 0) && peerHost.ListenPort != 0 {
|
if ((!setUDPPort) || peerHost.ListenPort == 0) && peerHost.ListenPort != 0 {
|
||||||
peerHost.ListenPort = peerHost.ListenPort
|
peerHost.ListenPort = getPeerListenPort(peerHost)
|
||||||
}
|
}
|
||||||
|
|
||||||
endpoint := peerHost.EndpointIP.String() + ":" + strconv.FormatInt(int64(peerHost.ListenPort), 10)
|
endpoint := peerHost.EndpointIP.String() + ":" + strconv.FormatInt(int64(peerHost.ListenPort), 10)
|
||||||
|
|
|
@ -12,39 +12,39 @@ const WIREGUARD_INTERFACE = "netmaker"
|
||||||
|
|
||||||
// Host - represents a host on the network
|
// Host - represents a host on the network
|
||||||
type Host struct {
|
type Host struct {
|
||||||
ID uuid.UUID `json:"id" yaml:"id"`
|
ID uuid.UUID `json:"id" yaml:"id"`
|
||||||
Verbosity int `json:"verbosity" yaml:"verbosity"`
|
Verbosity int `json:"verbosity" yaml:"verbosity"`
|
||||||
FirewallInUse string `json:"firewallinuse" yaml:"firewallinuse"`
|
FirewallInUse string `json:"firewallinuse" yaml:"firewallinuse"`
|
||||||
Version string `json:"version" yaml:"version"`
|
Version string `json:"version" yaml:"version"`
|
||||||
IPForwarding bool `json:"ipforwarding" yaml:"ipforwarding"`
|
IPForwarding bool `json:"ipforwarding" yaml:"ipforwarding"`
|
||||||
DaemonInstalled bool `json:"daemoninstalled" yaml:"daemoninstalled"`
|
DaemonInstalled bool `json:"daemoninstalled" yaml:"daemoninstalled"`
|
||||||
HostPass string `json:"hostpass" yaml:"hostpass"`
|
HostPass string `json:"hostpass" yaml:"hostpass"`
|
||||||
Name string `json:"name" yaml:"name"`
|
Name string `json:"name" yaml:"name"`
|
||||||
OS string `json:"os" yaml:"os"`
|
OS string `json:"os" yaml:"os"`
|
||||||
Interface string `json:"interface" yaml:"interface"`
|
Interface string `json:"interface" yaml:"interface"`
|
||||||
Debug bool `json:"debug" yaml:"debug"`
|
Debug bool `json:"debug" yaml:"debug"`
|
||||||
ListenPort int `json:"listenport" yaml:"listenport"`
|
ListenPort int `json:"listenport" yaml:"listenport"`
|
||||||
LocalAddress net.IPNet `json:"localaddress" yaml:"localaddress"`
|
LocalAddress net.IPNet `json:"localaddress" yaml:"localaddress"`
|
||||||
LocalRange net.IPNet `json:"localrange" yaml:"localrange"`
|
LocalRange net.IPNet `json:"localrange" yaml:"localrange"`
|
||||||
ProxyPublicListenPort int `json:"proxy_public_listen_port" yaml:"proxy_public_listen_port"`
|
PublicListenPort int `json:"proxy_public_listen_port" yaml:"proxy_public_listen_port"`
|
||||||
ProxyListenPort int `json:"proxy_listen_port" yaml:"proxy_listen_port"`
|
ProxyListenPort int `json:"proxy_listen_port" yaml:"proxy_listen_port"`
|
||||||
MTU int `json:"mtu" yaml:"mtu"`
|
MTU int `json:"mtu" yaml:"mtu"`
|
||||||
PublicKey wgtypes.Key `json:"publickey" yaml:"publickey"`
|
PublicKey wgtypes.Key `json:"publickey" yaml:"publickey"`
|
||||||
MacAddress net.HardwareAddr `json:"macaddress" yaml:"macaddress"`
|
MacAddress net.HardwareAddr `json:"macaddress" yaml:"macaddress"`
|
||||||
TrafficKeyPublic []byte `json:"traffickeypublic" yaml:"trafficekeypublic"`
|
TrafficKeyPublic []byte `json:"traffickeypublic" yaml:"trafficekeypublic"`
|
||||||
InternetGateway net.UDPAddr `json:"internetgateway" yaml:"internetgateway"`
|
InternetGateway net.UDPAddr `json:"internetgateway" yaml:"internetgateway"`
|
||||||
Nodes []string `json:"nodes" yaml:"nodes"`
|
Nodes []string `json:"nodes" yaml:"nodes"`
|
||||||
IsRelayed bool `json:"isrelayed" yaml:"isrelayed"`
|
IsRelayed bool `json:"isrelayed" yaml:"isrelayed"`
|
||||||
RelayedBy string `json:"relayed_by" yaml:"relayed_by"`
|
RelayedBy string `json:"relayed_by" yaml:"relayed_by"`
|
||||||
IsRelay bool `json:"isrelay" yaml:"isrelay"`
|
IsRelay bool `json:"isrelay" yaml:"isrelay"`
|
||||||
RelayedHosts []string `json:"relay_hosts" yaml:"relay_hosts"`
|
RelayedHosts []string `json:"relay_hosts" yaml:"relay_hosts"`
|
||||||
Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
|
Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
|
||||||
EndpointIP net.IP `json:"endpointip" yaml:"endpointip"`
|
EndpointIP net.IP `json:"endpointip" yaml:"endpointip"`
|
||||||
ProxyEnabled bool `json:"proxy_enabled" yaml:"proxy_enabled"`
|
ProxyEnabled bool `json:"proxy_enabled" yaml:"proxy_enabled"`
|
||||||
IsDocker bool `json:"isdocker" yaml:"isdocker"`
|
IsDocker bool `json:"isdocker" yaml:"isdocker"`
|
||||||
IsK8S bool `json:"isk8s" yaml:"isk8s"`
|
IsK8S bool `json:"isk8s" yaml:"isk8s"`
|
||||||
IsStatic bool `json:"isstatic" yaml:"isstatic"`
|
IsStatic bool `json:"isstatic" yaml:"isstatic"`
|
||||||
IsDefault bool `json:"isdefault" yaml:"isdefault"`
|
IsDefault bool `json:"isdefault" yaml:"isdefault"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FormatBool converts a boolean to a [yes|no] string
|
// FormatBool converts a boolean to a [yes|no] string
|
||||||
|
|
|
@ -188,6 +188,10 @@ func updateHostFromClient(newHost, currHost *models.Host) (sendPeerUpdate bool)
|
||||||
currHost.ProxyListenPort = newHost.ProxyListenPort
|
currHost.ProxyListenPort = newHost.ProxyListenPort
|
||||||
sendPeerUpdate = true
|
sendPeerUpdate = true
|
||||||
}
|
}
|
||||||
|
if newHost.PublicListenPort != 0 && currHost.PublicListenPort != newHost.PublicListenPort {
|
||||||
|
currHost.PublicListenPort = newHost.PublicListenPort
|
||||||
|
sendPeerUpdate = true
|
||||||
|
}
|
||||||
if currHost.ProxyEnabled != newHost.ProxyEnabled {
|
if currHost.ProxyEnabled != newHost.ProxyEnabled {
|
||||||
currHost.ProxyEnabled = newHost.ProxyEnabled
|
currHost.ProxyEnabled = newHost.ProxyEnabled
|
||||||
sendPeerUpdate = true
|
sendPeerUpdate = true
|
||||||
|
|
Loading…
Add table
Reference in a new issue