mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-20 07:16:06 +08:00
seperate static port and static endpoint
This commit is contained in:
parent
2bd38def35
commit
81a6c9cf8a
|
@ -18,7 +18,8 @@ var (
|
|||
name string
|
||||
listenPort int
|
||||
mtu int
|
||||
isStatic bool
|
||||
isStaticPort bool
|
||||
isStaticEndpoint bool
|
||||
isDefault bool
|
||||
keepAlive int
|
||||
)
|
||||
|
@ -45,7 +46,8 @@ var hostUpdateCmd = &cobra.Command{
|
|||
apiHost.Name = name
|
||||
apiHost.ListenPort = listenPort
|
||||
apiHost.MTU = mtu
|
||||
apiHost.IsStatic = isStatic
|
||||
apiHost.IsStaticPort = isStaticPort
|
||||
apiHost.IsStaticEndpoint = isStaticEndpoint
|
||||
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(&isStaticEndpoint, "static_endpoint", false, "Make Host Static Endpoint?")
|
||||
hostUpdateCmd.Flags().BoolVar(&isDefault, "default", false, "Make Host Default ?")
|
||||
rootCmd.AddCommand(hostUpdateCmd)
|
||||
}
|
||||
|
|
|
@ -150,7 +150,8 @@ 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.IsStatic = models.ParseBool(legacy.IsStatic)
|
||||
host.IsStaticPort = models.ParseBool(legacy.IsStatic)
|
||||
host.IsStaticEndpoint = models.ParseBool(legacy.IsStatic)
|
||||
host.PersistentKeepalive = time.Duration(legacy.PersistentKeepalive) * time.Second
|
||||
if host.PersistentKeepalive == 0 {
|
||||
host.PersistentKeepalive = models.DefaultPersistentKeepAlive
|
||||
|
|
|
@ -266,7 +266,8 @@ func UpdateHostFromClient(newHost, currHost *models.Host) (sendPeerUpdate bool)
|
|||
currHost.Debug = newHost.Debug
|
||||
currHost.Verbosity = newHost.Verbosity
|
||||
currHost.Version = newHost.Version
|
||||
currHost.IsStatic = newHost.IsStatic
|
||||
currHost.IsStaticPort = newHost.IsStaticPort
|
||||
currHost.IsStaticEndpoint = newHost.IsStaticEndpoint
|
||||
currHost.MTU = newHost.MTU
|
||||
currHost.Name = newHost.Name
|
||||
if len(newHost.NatType) > 0 && newHost.NatType != currHost.NatType {
|
||||
|
|
|
@ -251,7 +251,8 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
|
|||
hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
|
||||
Interfaces: peerHost.Interfaces,
|
||||
ListenPort: peerHost.ListenPort,
|
||||
IsStatic: peerHost.IsStatic,
|
||||
IsStaticPort: peerHost.IsStaticPort,
|
||||
IsStaticEndpoint: peerHost.IsStaticEndpoint,
|
||||
}
|
||||
nodePeer = peerConfig
|
||||
} else {
|
||||
|
@ -262,7 +263,8 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
|
|||
hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
|
||||
Interfaces: peerHost.Interfaces,
|
||||
ListenPort: peerHost.ListenPort,
|
||||
IsStatic: peerHost.IsStatic,
|
||||
IsStaticPort: peerHost.IsStaticPort,
|
||||
IsStaticEndpoint: peerHost.IsStaticEndpoint,
|
||||
}
|
||||
nodePeer = hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]]
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ type ApiHost struct {
|
|||
Name string `json:"name"`
|
||||
OS string `json:"os"`
|
||||
Debug bool `json:"debug"`
|
||||
IsStatic bool `json:"isstatic"`
|
||||
IsStaticPort bool `json:"isstaticport"`
|
||||
IsStaticEndpoint bool `json:"isstaticendpoint"`
|
||||
ListenPort int `json:"listenport"`
|
||||
WgPublicListenPort int `json:"wg_public_listen_port" yaml:"wg_public_listen_port"`
|
||||
MTU int `json:"mtu" yaml:"mtu"`
|
||||
|
@ -61,7 +62,8 @@ func (h *Host) ConvertNMHostToAPI() *ApiHost {
|
|||
}
|
||||
}
|
||||
a.DefaultInterface = h.DefaultInterface
|
||||
a.IsStatic = h.IsStatic
|
||||
a.IsStaticPort = h.IsStaticPort
|
||||
a.IsStaticEndpoint = h.IsStaticEndpoint
|
||||
a.ListenPort = h.ListenPort
|
||||
a.MTU = h.MTU
|
||||
a.MacAddress = h.MacAddress.String()
|
||||
|
@ -104,7 +106,8 @@ func (a *ApiHost) ConvertAPIHostToNMHost(currentHost *Host) *Host {
|
|||
h.DefaultInterface = currentHost.DefaultInterface
|
||||
h.IsDocker = currentHost.IsDocker
|
||||
h.IsK8S = currentHost.IsK8S
|
||||
h.IsStatic = a.IsStatic
|
||||
h.IsStaticPort = a.IsStaticPort
|
||||
h.IsStaticEndpoint = a.IsStaticEndpoint
|
||||
h.ListenPort = a.ListenPort
|
||||
h.MTU = a.MTU
|
||||
h.MacAddress = currentHost.MacAddress
|
||||
|
|
|
@ -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"`
|
||||
IsStaticEndpoint bool `json:"isstaticendpoint" yaml:"isstaticendpoint"`
|
||||
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"`
|
||||
|
|
|
@ -44,7 +44,8 @@ type HostInfoMap map[string]HostNetworkInfo
|
|||
type HostNetworkInfo struct {
|
||||
Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
|
||||
ListenPort int `json:"listen_port" yaml:"listen_port"`
|
||||
IsStatic bool `json:"is_static"`
|
||||
IsStaticPort bool `json:"is_static_port"`
|
||||
IsStaticEndpoint bool `json:"is_static_endpoint"`
|
||||
}
|
||||
|
||||
// PeerMap - peer map for ids and addresses in metrics
|
||||
|
|
|
@ -569,7 +569,7 @@ func (n *Node) Legacy(h *Host, s *ServerConfig, net *Network) *LegacyNode {
|
|||
//l.FailoverNode = n.FailoverNode
|
||||
//l.IngressGatewayRange = n.IngressGatewayRange
|
||||
//l.IngressGatewayRange6 = n.IngressGatewayRange6
|
||||
l.IsStatic = formatBool(h.IsStatic)
|
||||
l.IsStatic = formatBool(h.IsStaticPort)
|
||||
l.UDPHolePunch = formatBool(true)
|
||||
l.DNSOn = formatBool(n.DNSOn)
|
||||
l.Action = n.Action
|
||||
|
|
Loading…
Reference in a new issue