Browse Source

NET-664: Local Connections improvements (#2651)

* deprecate endpoint detection form config

* add peer network info to pull
Abhishek K 1 year ago
parent
commit
916694b2cf
8 changed files with 25 additions and 43 deletions
  1. 6 5
      controllers/hosts.go
  2. 0 2
      logic/peers.go
  3. 11 12
      models/mqtt.go
  4. 6 5
      models/structs.go
  5. 0 1
      scripts/netmaker.default.env
  6. 1 1
      scripts/nm-quick.sh
  7. 1 1
      scripts/nm-upgrade.sh
  8. 0 16
      servercfg/serverconf.go

+ 6 - 5
controllers/hosts.go

@@ -123,11 +123,12 @@ func pull(w http.ResponseWriter, r *http.Request) {
 
 	serverConf.TrafficKey = key
 	response := models.HostPull{
-		Host:         *host,
-		Nodes:        logic.GetHostNodes(host),
-		ServerConfig: serverConf,
-		Peers:        hPU.Peers,
-		PeerIDs:      hPU.PeerIDs,
+		Host:            *host,
+		Nodes:           logic.GetHostNodes(host),
+		ServerConfig:    serverConf,
+		Peers:           hPU.Peers,
+		PeerIDs:         hPU.PeerIDs,
+		HostNetworkInfo: hPU.HostNetworkInfo,
 	}
 
 	logger.Log(1, hostID, "completed a pull")

+ 0 - 2
logic/peers.go

@@ -38,8 +38,6 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 		HostNetworkInfo: models.HostInfoMap{},
 	}
 
-	// endpoint detection always comes from the server
-	hostPeerUpdate.EndpointDetection = servercfg.EndpointDetectionEnabled()
 	slog.Debug("peer update for host", "hostId", host.ID.String())
 	peerIndexMap := make(map[string]int)
 	for _, nodeID := range host.Nodes {

+ 11 - 12
models/mqtt.go

@@ -8,18 +8,17 @@ import (
 
 // HostPeerUpdate - struct for host peer updates
 type HostPeerUpdate struct {
-	Host              Host                 `json:"host" bson:"host" yaml:"host"`
-	NodeAddrs         []net.IPNet          `json:"nodes_addrs" yaml:"nodes_addrs"`
-	Server            string               `json:"server" bson:"server" yaml:"server"`
-	ServerVersion     string               `json:"serverversion" bson:"serverversion" yaml:"serverversion"`
-	ServerAddrs       []ServerAddr         `json:"serveraddrs" bson:"serveraddrs" yaml:"serveraddrs"`
-	NodePeers         []wgtypes.PeerConfig `json:"peers" bson:"peers" yaml:"peers"`
-	Peers             []wgtypes.PeerConfig
-	PeerIDs           PeerMap               `json:"peerids" bson:"peerids" yaml:"peerids"`
-	EndpointDetection bool                  `json:"endpointdetection" yaml:"endpointdetection"`
-	HostNetworkInfo   HostInfoMap           `json:"host_network_info,omitempty" bson:"host_network_info,omitempty" yaml:"host_network_info,omitempty"`
-	EgressRoutes      []EgressNetworkRoutes `json:"egress_network_routes"`
-	FwUpdate          FwUpdate              `json:"fw_update"`
+	Host            Host                 `json:"host" bson:"host" yaml:"host"`
+	NodeAddrs       []net.IPNet          `json:"nodes_addrs" yaml:"nodes_addrs"`
+	Server          string               `json:"server" bson:"server" yaml:"server"`
+	ServerVersion   string               `json:"serverversion" bson:"serverversion" yaml:"serverversion"`
+	ServerAddrs     []ServerAddr         `json:"serveraddrs" bson:"serveraddrs" yaml:"serveraddrs"`
+	NodePeers       []wgtypes.PeerConfig `json:"peers" bson:"peers" yaml:"peers"`
+	Peers           []wgtypes.PeerConfig
+	PeerIDs         PeerMap               `json:"peerids" bson:"peerids" yaml:"peerids"`
+	HostNetworkInfo HostInfoMap           `json:"host_network_info,omitempty" bson:"host_network_info,omitempty" yaml:"host_network_info,omitempty"`
+	EgressRoutes    []EgressNetworkRoutes `json:"egress_network_routes"`
+	FwUpdate        FwUpdate              `json:"fw_update"`
 }
 
 // IngressInfo - struct for ingress info

+ 6 - 5
models/structs.go

@@ -223,11 +223,12 @@ type TrafficKeys struct {
 
 // HostPull - response of a host's pull
 type HostPull struct {
-	Host         Host                 `json:"host" yaml:"host"`
-	Nodes        []Node               `json:"nodes" yaml:"nodes"`
-	Peers        []wgtypes.PeerConfig `json:"peers" yaml:"peers"`
-	ServerConfig ServerConfig         `json:"server_config" yaml:"server_config"`
-	PeerIDs      PeerMap              `json:"peer_ids,omitempty" yaml:"peer_ids,omitempty"`
+	Host            Host                 `json:"host" yaml:"host"`
+	Nodes           []Node               `json:"nodes" yaml:"nodes"`
+	Peers           []wgtypes.PeerConfig `json:"peers" yaml:"peers"`
+	ServerConfig    ServerConfig         `json:"server_config" yaml:"server_config"`
+	PeerIDs         PeerMap              `json:"peer_ids,omitempty" yaml:"peer_ids,omitempty"`
+	HostNetworkInfo HostInfoMap          `json:"host_network_info,omitempty"  yaml:"host_network_info,omitempty"`
 }
 
 // NodeGet - struct for a single node get response

+ 0 - 1
scripts/netmaker.default.env

@@ -19,7 +19,6 @@ NETMAKER_TENANT_ID=
 LICENSE_KEY=
 SERVER_IMAGE_TAG=
 UI_IMAGE_TAG=
-NETCLIENT_ENDPOINT_DETECTION=disabled
 # used for HA - identifies this server vs other servers
 NODE_ID=netmaker-server-1
 METRICS_EXPORTER=off

+ 1 - 1
scripts/nm-quick.sh

@@ -309,7 +309,7 @@ save_config() { (
 		"INSTALL_TYPE" "NODE_ID" "DNS_MODE" "NETCLIENT_AUTO_UPDATE" "API_PORT"
 		"CORS_ALLOWED_ORIGIN" "DISPLAY_KEYS" "DATABASE" "SERVER_BROKER_ENDPOINT" "STUN_PORT" "VERBOSITY"
 		"TURN_PORT" "USE_TURN" "DEBUG_MODE" "TURN_API_PORT" "REST_BACKEND"
-		"DISABLE_REMOTE_IP_CHECK" "NETCLIENT_ENDPOINT_DETECTION" "TELEMETRY" "AUTH_PROVIDER" "CLIENT_ID" "CLIENT_SECRET"
+		"DISABLE_REMOTE_IP_CHECK" "TELEMETRY" "AUTH_PROVIDER" "CLIENT_ID" "CLIENT_SECRET"
 		"FRONTEND_URL" "AZURE_TENANT" "OIDC_ISSUER" "EXPORTER_API_PORT" "JWT_VALIDITY_DURATION" "RAC_AUTO_DISABLE")
 	for name in "${toCopy[@]}"; do
 		save_config_item $name "${!name}"

+ 1 - 1
scripts/nm-upgrade.sh

@@ -179,7 +179,7 @@ save_config() { (
 		"INSTALL_TYPE" "NODE_ID" "DNS_MODE" "NETCLIENT_AUTO_UPDATE" "API_PORT"
 		"CORS_ALLOWED_ORIGIN" "DISPLAY_KEYS" "DATABASE" "SERVER_BROKER_ENDPOINT" "STUN_PORT" "VERBOSITY"
 		"TURN_PORT" "USE_TURN" "DEBUG_MODE" "TURN_API_PORT" "REST_BACKEND"
-		"DISABLE_REMOTE_IP_CHECK" "NETCLIENT_ENDPOINT_DETECTION" "TELEMETRY" "AUTH_PROVIDER" "CLIENT_ID" "CLIENT_SECRET"
+		"DISABLE_REMOTE_IP_CHECK" "TELEMETRY" "AUTH_PROVIDER" "CLIENT_ID" "CLIENT_SECRET"
 		"FRONTEND_URL" "AZURE_TENANT" "OIDC_ISSUER" "EXPORTER_API_PORT" "JWT_VALIDITY_DURATION" "RAC_AUTO_DISABLE")
 	for name in "${toCopy[@]}"; do
 		save_config_item $name "${!name}"

+ 0 - 16
servercfg/serverconf.go

@@ -53,11 +53,6 @@ func GetServerConfig() config.ServerConfig {
 	} else {
 		cfg.NetclientAutoUpdate = "disabled"
 	}
-	if EndpointDetectionEnabled() {
-		cfg.NetclientEndpointDetection = "enabled"
-	} else {
-		cfg.NetclientEndpointDetection = "disabled"
-	}
 	if IsRestBackend() {
 		cfg.RestBackend = "on"
 	}
@@ -405,17 +400,6 @@ func AutoUpdateEnabled() bool {
 	return true
 }
 
-// EndpointDetectionEnabled returns a boolean indicating whether netclient endpoint detection is enabled or disabled
-// default is enabled
-func EndpointDetectionEnabled() bool {
-	if os.Getenv("NETCLIENT_ENDPOINT_DETECTION") == "disabled" {
-		return false
-	} else if config.Config.Server.NetclientEndpointDetection == "disabled" {
-		return false
-	}
-	return true
-}
-
 // IsDNSMode - should it run with DNS
 func IsDNSMode() bool {
 	isdns := true