mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-07 05:34:38 +08:00
Merge pull request #2958 from gravitl/NET-1268
NET-1268:seperate static port and static endpoint
This commit is contained in:
commit
50d8da2dc2
7 changed files with 23 additions and 11 deletions
|
@ -18,6 +18,7 @@ var (
|
|||
name string
|
||||
listenPort int
|
||||
mtu int
|
||||
isStaticPort bool
|
||||
isStatic bool
|
||||
isDefault bool
|
||||
keepAlive int
|
||||
|
@ -45,6 +46,7 @@ var hostUpdateCmd = &cobra.Command{
|
|||
apiHost.Name = name
|
||||
apiHost.ListenPort = listenPort
|
||||
apiHost.MTU = mtu
|
||||
apiHost.IsStaticPort = isStaticPort
|
||||
apiHost.IsStatic = isStatic
|
||||
apiHost.IsDefault = isDefault
|
||||
apiHost.PersistentKeepalive = keepAlive
|
||||
|
@ -61,7 +63,8 @@ func init() {
|
|||
hostUpdateCmd.Flags().IntVar(&listenPort, "listen_port", 0, "Listen port of the host")
|
||||
hostUpdateCmd.Flags().IntVar(&mtu, "mtu", 0, "Host MTU size")
|
||||
hostUpdateCmd.Flags().IntVar(&keepAlive, "keep_alive", 0, "Interval (seconds) in which packets are sent to keep connections open with peers")
|
||||
hostUpdateCmd.Flags().BoolVar(&isStatic, "static", false, "Make Host Static ?")
|
||||
hostUpdateCmd.Flags().BoolVar(&isStaticPort, "static_port", false, "Make Host Static Port?")
|
||||
hostUpdateCmd.Flags().BoolVar(&isStatic, "static_endpoint", false, "Make Host Static Endpoint?")
|
||||
hostUpdateCmd.Flags().BoolVar(&isDefault, "default", false, "Make Host Default ?")
|
||||
rootCmd.AddCommand(hostUpdateCmd)
|
||||
}
|
||||
|
|
|
@ -150,6 +150,7 @@ func convertLegacyHostNode(legacy models.LegacyNode) (models.Host, models.Node)
|
|||
host.EndpointIP = net.ParseIP(legacy.Endpoint)
|
||||
host.IsDocker = models.ParseBool(legacy.IsDocker)
|
||||
host.IsK8S = models.ParseBool(legacy.IsK8S)
|
||||
host.IsStaticPort = models.ParseBool(legacy.IsStatic)
|
||||
host.IsStatic = models.ParseBool(legacy.IsStatic)
|
||||
host.PersistentKeepalive = time.Duration(legacy.PersistentKeepalive) * time.Second
|
||||
if host.PersistentKeepalive == 0 {
|
||||
|
|
|
@ -266,6 +266,7 @@ func UpdateHostFromClient(newHost, currHost *models.Host) (sendPeerUpdate bool)
|
|||
currHost.Debug = newHost.Debug
|
||||
currHost.Verbosity = newHost.Verbosity
|
||||
currHost.Version = newHost.Version
|
||||
currHost.IsStaticPort = newHost.IsStaticPort
|
||||
currHost.IsStatic = newHost.IsStatic
|
||||
currHost.MTU = newHost.MTU
|
||||
currHost.Name = newHost.Name
|
||||
|
|
|
@ -249,9 +249,10 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
|
|||
hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, peerConfig)
|
||||
peerIndexMap[peerHost.PublicKey.String()] = len(hostPeerUpdate.Peers) - 1
|
||||
hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
|
||||
Interfaces: peerHost.Interfaces,
|
||||
ListenPort: peerHost.ListenPort,
|
||||
IsStatic: peerHost.IsStatic,
|
||||
Interfaces: peerHost.Interfaces,
|
||||
ListenPort: peerHost.ListenPort,
|
||||
IsStaticPort: peerHost.IsStaticPort,
|
||||
IsStatic: peerHost.IsStatic,
|
||||
}
|
||||
nodePeer = peerConfig
|
||||
} else {
|
||||
|
@ -260,9 +261,10 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
|
|||
hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].AllowedIPs = peerAllowedIPs
|
||||
hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].Remove = false
|
||||
hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
|
||||
Interfaces: peerHost.Interfaces,
|
||||
ListenPort: peerHost.ListenPort,
|
||||
IsStatic: peerHost.IsStatic,
|
||||
Interfaces: peerHost.Interfaces,
|
||||
ListenPort: peerHost.ListenPort,
|
||||
IsStaticPort: peerHost.IsStaticPort,
|
||||
IsStatic: peerHost.IsStatic,
|
||||
}
|
||||
nodePeer = hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]]
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ type ApiHost struct {
|
|||
Name string `json:"name"`
|
||||
OS string `json:"os"`
|
||||
Debug bool `json:"debug"`
|
||||
IsStaticPort bool `json:"isstaticport"`
|
||||
IsStatic bool `json:"isstatic"`
|
||||
ListenPort int `json:"listenport"`
|
||||
WgPublicListenPort int `json:"wg_public_listen_port" yaml:"wg_public_listen_port"`
|
||||
|
@ -61,6 +62,7 @@ func (h *Host) ConvertNMHostToAPI() *ApiHost {
|
|||
}
|
||||
}
|
||||
a.DefaultInterface = h.DefaultInterface
|
||||
a.IsStaticPort = h.IsStaticPort
|
||||
a.IsStatic = h.IsStatic
|
||||
a.ListenPort = h.ListenPort
|
||||
a.MTU = h.MTU
|
||||
|
@ -104,6 +106,7 @@ func (a *ApiHost) ConvertAPIHostToNMHost(currentHost *Host) *Host {
|
|||
h.DefaultInterface = currentHost.DefaultInterface
|
||||
h.IsDocker = currentHost.IsDocker
|
||||
h.IsK8S = currentHost.IsK8S
|
||||
h.IsStaticPort = a.IsStaticPort
|
||||
h.IsStatic = a.IsStatic
|
||||
h.ListenPort = a.ListenPort
|
||||
h.MTU = a.MTU
|
||||
|
|
|
@ -66,7 +66,8 @@ type Host struct {
|
|||
EndpointIPv6 net.IP `json:"endpointipv6" yaml:"endpointipv6"`
|
||||
IsDocker bool `json:"isdocker" yaml:"isdocker"`
|
||||
IsK8S bool `json:"isk8s" yaml:"isk8s"`
|
||||
IsStatic bool `json:"isstatic" yaml:"isstatic"`
|
||||
IsStaticPort bool `json:"isstaticport" yaml:"isstaticport"`
|
||||
IsStatic bool `json:"isstatic" yaml:"isstatic"`
|
||||
IsDefault bool `json:"isdefault" yaml:"isdefault"`
|
||||
NatType string `json:"nat_type,omitempty" yaml:"nat_type,omitempty"`
|
||||
TurnEndpoint *netip.AddrPort `json:"turn_endpoint,omitempty" yaml:"turn_endpoint,omitempty"`
|
||||
|
|
|
@ -42,9 +42,10 @@ type HostInfoMap map[string]HostNetworkInfo
|
|||
|
||||
// HostNetworkInfo - holds info related to host networking (used for client side peer calculations)
|
||||
type HostNetworkInfo struct {
|
||||
Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
|
||||
ListenPort int `json:"listen_port" yaml:"listen_port"`
|
||||
IsStatic bool `json:"is_static"`
|
||||
Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
|
||||
ListenPort int `json:"listen_port" yaml:"listen_port"`
|
||||
IsStaticPort bool `json:"is_static_port"`
|
||||
IsStatic bool `json:"is_static"`
|
||||
}
|
||||
|
||||
// PeerMap - peer map for ids and addresses in metrics
|
||||
|
|
Loading…
Add table
Reference in a new issue