瀏覽代碼

remove related fields and code

Abhishek Kondur 2 年之前
父節點
當前提交
70c98687a2
共有 15 個文件被更改,包括 93 次插入485 次删除
  1. 54 62
      config/config.go
  2. 2 5
      controllers/ext_client.go
  3. 11 41
      logic/host_test.go
  4. 1 36
      logic/hosts.go
  5. 16 186
      logic/peers.go
  6. 0 6
      models/api_host.go
  7. 0 8
      models/host.go
  8. 8 11
      models/metrics.go
  9. 0 2
      models/mqtt.go
  10. 0 3
      models/node.go
  11. 0 68
      models/proxy.go
  12. 0 14
      mq/publishers.go
  13. 0 4
      scripts/netmaker.default.env
  14. 1 1
      scripts/nm-quick.sh
  15. 0 38
      servercfg/serverconf.go

+ 54 - 62
config/config.go

@@ -32,68 +32,60 @@ type EnvironmentConfig struct {
 
 // ServerConfig - server conf struct
 type ServerConfig struct {
-	CoreDNSAddr                string    `yaml:"corednsaddr"`
-	APIConnString              string    `yaml:"apiconn"`
-	APIHost                    string    `yaml:"apihost"`
-	APIPort                    string    `yaml:"apiport"`
-	Broker                     string    `yam:"broker"`
-	ServerBrokerEndpoint       string    `yaml:"serverbrokerendpoint"`
-	BrokerType                 string    `yaml:"brokertype"`
-	EmqxRestEndpoint           string    `yaml:"emqxrestendpoint"`
-	NetclientAutoUpdate        string    `yaml:"netclientautoupdate"`
-	NetclientEndpointDetection string    `yaml:"netclientendpointdetection"`
-	MasterKey                  string    `yaml:"masterkey"`
-	DNSKey                     string    `yaml:"dnskey"`
-	AllowedOrigin              string    `yaml:"allowedorigin"`
-	NodeID                     string    `yaml:"nodeid"`
-	RestBackend                string    `yaml:"restbackend"`
-	MessageQueueBackend        string    `yaml:"messagequeuebackend"`
-	DNSMode                    string    `yaml:"dnsmode"`
-	DisableRemoteIPCheck       string    `yaml:"disableremoteipcheck"`
-	Version                    string    `yaml:"version"`
-	SQLConn                    string    `yaml:"sqlconn"`
-	Platform                   string    `yaml:"platform"`
-	Database                   string    `yaml:"database"`
-	Verbosity                  int32     `yaml:"verbosity"`
-	AuthProvider               string    `yaml:"authprovider"`
-	OIDCIssuer                 string    `yaml:"oidcissuer"`
-	ClientID                   string    `yaml:"clientid"`
-	ClientSecret               string    `yaml:"clientsecret"`
-	FrontendURL                string    `yaml:"frontendurl"`
-	DisplayKeys                string    `yaml:"displaykeys"`
-	AzureTenant                string    `yaml:"azuretenant"`
-	Telemetry                  string    `yaml:"telemetry"`
-	HostNetwork                string    `yaml:"hostnetwork"`
-	Server                     string    `yaml:"server"`
-	PublicIPService            string    `yaml:"publicipservice"`
-	MQPassword                 string    `yaml:"mqpassword"`
-	MQUserName                 string    `yaml:"mqusername"`
-	MetricsExporter            string    `yaml:"metrics_exporter"`
-	BasicAuth                  string    `yaml:"basic_auth"`
-	LicenseValue               string    `yaml:"license_value"`
-	NetmakerTenantID           string    `yaml:"netmaker_tenant_id"`
-	IsEE                       string    `yaml:"is_ee"`
-	StunPort                   int       `yaml:"stun_port"`
-	StunList                   string    `yaml:"stun_list"`
-	Proxy                      string    `yaml:"proxy"`
-	DefaultProxyMode           ProxyMode `yaml:"defaultproxymode"`
-	TurnServer                 string    `yaml:"turn_server"`
-	TurnApiServer              string    `yaml:"turn_api_server"`
-	TurnPort                   int       `yaml:"turn_port"`
-	TurnUserName               string    `yaml:"turn_username"`
-	TurnPassword               string    `yaml:"turn_password"`
-	UseTurn                    bool      `yaml:"use_turn"`
-	UsersLimit                 int       `yaml:"user_limit"`
-	ClientsLimit               int       `yaml:"client_limit"`
-	NetworksLimit              int       `yaml:"network_limit"`
-	HostsLimit                 int       `yaml:"host_limit"`
-	DeployedByOperator         bool      `yaml:"deployed_by_operator"`
-}
-
-// ProxyMode - default proxy mode for server
-type ProxyMode struct {
-	Set   bool
-	Value bool
+	CoreDNSAddr                string `yaml:"corednsaddr"`
+	APIConnString              string `yaml:"apiconn"`
+	APIHost                    string `yaml:"apihost"`
+	APIPort                    string `yaml:"apiport"`
+	Broker                     string `yam:"broker"`
+	ServerBrokerEndpoint       string `yaml:"serverbrokerendpoint"`
+	BrokerType                 string `yaml:"brokertype"`
+	EmqxRestEndpoint           string `yaml:"emqxrestendpoint"`
+	NetclientAutoUpdate        string `yaml:"netclientautoupdate"`
+	NetclientEndpointDetection string `yaml:"netclientendpointdetection"`
+	MasterKey                  string `yaml:"masterkey"`
+	DNSKey                     string `yaml:"dnskey"`
+	AllowedOrigin              string `yaml:"allowedorigin"`
+	NodeID                     string `yaml:"nodeid"`
+	RestBackend                string `yaml:"restbackend"`
+	MessageQueueBackend        string `yaml:"messagequeuebackend"`
+	DNSMode                    string `yaml:"dnsmode"`
+	DisableRemoteIPCheck       string `yaml:"disableremoteipcheck"`
+	Version                    string `yaml:"version"`
+	SQLConn                    string `yaml:"sqlconn"`
+	Platform                   string `yaml:"platform"`
+	Database                   string `yaml:"database"`
+	Verbosity                  int32  `yaml:"verbosity"`
+	AuthProvider               string `yaml:"authprovider"`
+	OIDCIssuer                 string `yaml:"oidcissuer"`
+	ClientID                   string `yaml:"clientid"`
+	ClientSecret               string `yaml:"clientsecret"`
+	FrontendURL                string `yaml:"frontendurl"`
+	DisplayKeys                string `yaml:"displaykeys"`
+	AzureTenant                string `yaml:"azuretenant"`
+	Telemetry                  string `yaml:"telemetry"`
+	HostNetwork                string `yaml:"hostnetwork"`
+	Server                     string `yaml:"server"`
+	PublicIPService            string `yaml:"publicipservice"`
+	MQPassword                 string `yaml:"mqpassword"`
+	MQUserName                 string `yaml:"mqusername"`
+	MetricsExporter            string `yaml:"metrics_exporter"`
+	BasicAuth                  string `yaml:"basic_auth"`
+	LicenseValue               string `yaml:"license_value"`
+	NetmakerTenantID           string `yaml:"netmaker_tenant_id"`
+	IsEE                       string `yaml:"is_ee"`
+	StunPort                   int    `yaml:"stun_port"`
+	StunList                   string `yaml:"stun_list"`
+	TurnServer                 string `yaml:"turn_server"`
+	TurnApiServer              string `yaml:"turn_api_server"`
+	TurnPort                   int    `yaml:"turn_port"`
+	TurnUserName               string `yaml:"turn_username"`
+	TurnPassword               string `yaml:"turn_password"`
+	UseTurn                    bool   `yaml:"use_turn"`
+	UsersLimit                 int    `yaml:"user_limit"`
+	ClientsLimit               int    `yaml:"client_limit"`
+	NetworksLimit              int    `yaml:"network_limit"`
+	HostsLimit                 int    `yaml:"host_limit"`
+	DeployedByOperator         bool   `yaml:"deployed_by_operator"`
 }
 
 // SQLConfig - Generic SQL Config

+ 2 - 5
controllers/ext_client.go

@@ -348,11 +348,8 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
 		logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
 		return
 	}
-	listenPort := host.ListenPort
-	if host.ProxyEnabled {
-		listenPort = host.ProxyListenPort
-	}
-	extclient.IngressGatewayEndpoint = host.EndpointIP.String() + ":" + strconv.FormatInt(int64(listenPort), 10)
+	listenPort := logic.GetPeerListenPort(host)
+	extclient.IngressGatewayEndpoint = fmt.Sprintf("%s:%d", host.EndpointIP.String(), listenPort)
 	extclient.Enabled = true
 	parentNetwork, err := logic.GetNetwork(networkName)
 	if err == nil { // check if parent network default ACL is enabled (yes) or not (no)

+ 11 - 41
logic/host_test.go

@@ -30,16 +30,14 @@ func TestMain(m *testing.M) {
 
 func TestCheckPorts(t *testing.T) {
 	h := models.Host{
-		ID:              uuid.New(),
-		EndpointIP:      net.ParseIP("192.168.1.1"),
-		ListenPort:      51821,
-		ProxyListenPort: maxPort,
+		ID:         uuid.New(),
+		EndpointIP: net.ParseIP("192.168.1.1"),
+		ListenPort: 51821,
 	}
 	testHost := models.Host{
-		ID:              uuid.New(),
-		EndpointIP:      net.ParseIP("192.168.1.1"),
-		ListenPort:      51830,
-		ProxyListenPort: 51730,
+		ID:         uuid.New(),
+		EndpointIP: net.ParseIP("192.168.1.1"),
+		ListenPort: 51830,
 	}
 	//not sure why this initialization is required but without it
 	// RemoveHost returns database is closed
@@ -49,45 +47,17 @@ func TestCheckPorts(t *testing.T) {
 	t.Run("no change", func(t *testing.T) {
 		is := is.New(t)
 		CheckHostPorts(&testHost)
-		t.Log(testHost.ListenPort, testHost.ProxyListenPort)
-		t.Log(h.ListenPort, h.ProxyListenPort)
+		t.Log(testHost.ListenPort)
+		t.Log(h.ListenPort)
 		is.Equal(testHost.ListenPort, 51830)
-		is.Equal(testHost.ProxyListenPort, 51730)
 	})
 	t.Run("same listen port", func(t *testing.T) {
 		is := is.New(t)
 		testHost.ListenPort = 51821
 		CheckHostPorts(&testHost)
-		t.Log(testHost.ListenPort, testHost.ProxyListenPort)
-		t.Log(h.ListenPort, h.ProxyListenPort)
+		t.Log(testHost.ListenPort)
+		t.Log(h.ListenPort)
 		is.Equal(testHost.ListenPort, 51822)
-		is.Equal(testHost.ProxyListenPort, 51730)
-	})
-	t.Run("same proxy port", func(t *testing.T) {
-		is := is.New(t)
-		testHost.ProxyListenPort = 65535
-		CheckHostPorts(&testHost)
-		t.Log(testHost.ListenPort, testHost.ProxyListenPort)
-		t.Log(h.ListenPort, h.ProxyListenPort)
-		is.Equal(testHost.ListenPort, 51822)
-		is.Equal(testHost.ProxyListenPort, minPort)
-	})
-	t.Run("listenport equals proxy port", func(t *testing.T) {
-		is := is.New(t)
-		testHost.ListenPort = maxPort
-		CheckHostPorts(&testHost)
-		t.Log(testHost.ListenPort, testHost.ProxyListenPort)
-		t.Log(h.ListenPort, h.ProxyListenPort)
-		is.Equal(testHost.ListenPort, minPort)
-		is.Equal(testHost.ProxyListenPort, minPort+1)
-	})
-	t.Run("proxyport equals listenport", func(t *testing.T) {
-		is := is.New(t)
-		testHost.ProxyListenPort = 51821
-		CheckHostPorts(&testHost)
-		t.Log(testHost.ListenPort, testHost.ProxyListenPort)
-		t.Log(h.ListenPort, h.ProxyListenPort)
-		is.Equal(testHost.ListenPort, minPort)
-		is.Equal(testHost.ProxyListenPort, 51822)
 	})
+
 }

+ 1 - 36
logic/hosts.go

@@ -6,7 +6,6 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
-	"log"
 	"net/http"
 	"sort"
 	"strconv"
@@ -184,15 +183,6 @@ func CreateHost(h *models.Host) error {
 	}
 	h.HostPass = string(hash)
 	h.AutoUpdate = servercfg.AutoUpdateEnabled()
-	// if another server has already updated proxyenabled, leave it alone
-	if !h.ProxyEnabledSet {
-		log.Println("checking default proxy", servercfg.GetServerConfig().DefaultProxyMode)
-		if servercfg.GetServerConfig().DefaultProxyMode.Set {
-			h.ProxyEnabledSet = true
-			h.ProxyEnabled = servercfg.GetServerConfig().DefaultProxyMode.Value
-			log.Println("set proxy enabled to ", h.ProxyEnabled)
-		}
-	}
 	checkForZombieHosts(h)
 	return UpsertHost(h)
 }
@@ -228,11 +218,6 @@ func UpdateHost(newHost, currentHost *models.Host) {
 		newHost.ListenPort = currentHost.ListenPort
 	}
 
-	if newHost.ProxyListenPort == 0 {
-		newHost.ProxyListenPort = currentHost.ProxyListenPort
-	}
-	newHost.PublicListenPort = currentHost.PublicListenPort
-
 }
 
 // UpdateHostFromClient - used for updating host on server with update recieved from client
@@ -250,18 +235,6 @@ func UpdateHostFromClient(newHost, currHost *models.Host) (sendPeerUpdate bool)
 		currHost.WgPublicListenPort = newHost.WgPublicListenPort
 		sendPeerUpdate = true
 	}
-	if newHost.ProxyListenPort != 0 && currHost.ProxyListenPort != newHost.ProxyListenPort {
-		currHost.ProxyListenPort = newHost.ProxyListenPort
-		sendPeerUpdate = true
-	}
-	if newHost.PublicListenPort != 0 && currHost.PublicListenPort != newHost.PublicListenPort {
-		currHost.PublicListenPort = newHost.PublicListenPort
-		sendPeerUpdate = true
-	}
-	if currHost.ProxyEnabled != newHost.ProxyEnabled {
-		currHost.ProxyEnabled = newHost.ProxyEnabled
-		sendPeerUpdate = true
-	}
 	if currHost.EndpointIP.String() != newHost.EndpointIP.String() {
 		currHost.EndpointIP = newHost.EndpointIP
 		sendPeerUpdate = true
@@ -514,7 +487,6 @@ func CheckHostPorts(h *models.Host) {
 			continue
 		}
 		portsInUse[host.ListenPort] = true
-		portsInUse[host.ProxyListenPort] = true
 	}
 	// iterate until port is not found or max iteration is reached
 	for i := 0; portsInUse[h.ListenPort] && i < maxPort-minPort+1; i++ {
@@ -523,14 +495,7 @@ func CheckHostPorts(h *models.Host) {
 			h.ListenPort = minPort
 		}
 	}
-	// allocate h.ListenPort so it is unavailable to h.ProxyListenPort
-	portsInUse[h.ListenPort] = true
-	for i := 0; portsInUse[h.ProxyListenPort] && i < maxPort-minPort+1; i++ {
-		h.ProxyListenPort++
-		if h.ProxyListenPort > maxPort {
-			h.ProxyListenPort = minPort
-		}
-	}
+
 }
 
 // HostExists - checks if given host already exists

+ 16 - 186
logic/peers.go

@@ -15,69 +15,9 @@ import (
 	"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
 )
 
-// GetProxyUpdateForHost - gets the proxy update for host
-func GetProxyUpdateForHost(host *models.Host) (models.ProxyManagerPayload, error) {
-	proxyPayload := models.ProxyManagerPayload{
-		Action: models.ProxyUpdate,
-	}
-	peerConfMap := make(map[string]models.PeerConf)
-	var ingressStatus bool
-	for _, nodeID := range host.Nodes {
-
-		node, err := GetNodeByID(nodeID)
-		if err != nil {
-			continue
-		}
-		if !node.Connected || node.PendingDelete || node.Action == models.NODE_DELETE {
-			continue
-		}
-		currentPeers, err := GetNetworkNodes(node.Network)
-		if err != nil {
-			continue
-		}
-		for _, peer := range currentPeers {
-			if peer.ID == node.ID {
-				//skip yourself
-				continue
-			}
-			if !peer.Connected || peer.PendingDelete || peer.Action == models.NODE_DELETE {
-				continue
-			}
-			peerHost, err := GetHost(peer.HostID.String())
-			if err != nil {
-				continue
-			}
-			var currPeerConf models.PeerConf
-			var found bool
-			if currPeerConf, found = peerConfMap[peerHost.PublicKey.String()]; !found {
-				currPeerConf = models.PeerConf{
-					Proxy:            peerHost.ProxyEnabled,
-					PublicListenPort: int32(GetPeerListenPort(peerHost)),
-					ProxyListenPort:  GetProxyListenPort(peerHost),
-					NatType:          peerHost.NatType,
-				}
-			}
-
-			peerConfMap[peerHost.PublicKey.String()] = currPeerConf
-		}
-		if node.IsIngressGateway {
-			ingressStatus = true
-			_, peerConfMap, err = getExtPeersForProxy(&node, peerConfMap)
-			if err == nil {
-
-			} else if !database.IsEmptyRecord(err) {
-				logger.Log(1, "error retrieving external clients:", err.Error())
-			}
-		}
-
-	}
-	proxyPayload.IsIngress = ingressStatus
-	proxyPayload.PeerMap = peerConfMap
-	return proxyPayload, nil
-}
-
 // GetPeerUpdateForHost - gets the consolidated peer update for the host from all networks
-func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.Node, deletedNode *models.Node, deletedClients []models.ExtClient) (models.HostPeerUpdate, error) {
+func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.Node,
+	deletedNode *models.Node, deletedClients []models.ExtClient) (models.HostPeerUpdate, error) {
 	if host == nil {
 		return models.HostPeerUpdate{}, errors.New("host is nil")
 	}
@@ -87,7 +27,6 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 	hostPeerUpdate := models.HostPeerUpdate{
 		Host:          *host,
 		Server:        servercfg.GetServer(),
-		HostPeerIDs:   make(models.HostPeerMap, 0),
 		ServerVersion: servercfg.GetVersion(),
 		ServerAddrs:   []models.ServerAddr{},
 		IngressInfo: models.IngressInfo{
@@ -145,7 +84,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 				}
 				relayPeer.Endpoint = &net.UDPAddr{
 					IP:   relayHost.EndpointIP,
-					Port: getPeerWgListenPort(relayHost),
+					Port: GetPeerListenPort(relayHost),
 				}
 
 				if uselocal {
@@ -231,7 +170,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 			}
 			if (node.IsRelayed && node.RelayedBy != peer.ID.String()) || (peer.IsRelayed && peer.RelayedBy != node.ID.String()) {
 				// if node is relayed and peer is not the relay, set remove to true
-				if _, ok := hostPeerUpdate.HostPeerIDs[peerHost.PublicKey.String()]; ok {
+				if _, ok := peerIndexMap[peerHost.PublicKey.String()]; ok {
 					continue
 				}
 				peerConfig.Remove = true
@@ -255,7 +194,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 			}
 			peerConfig.Endpoint = &net.UDPAddr{
 				IP:   peerHost.EndpointIP,
-				Port: getPeerWgListenPort(peerHost),
+				Port: GetPeerListenPort(peerHost),
 			}
 
 			if uselocal {
@@ -271,22 +210,14 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 				peerConfig.AllowedIPs = allowedips // only append allowed IPs if valid connection
 			}
 
-			peerProxyPort := GetProxyListenPort(peerHost)
+			peerPort := GetPeerListenPort(peerHost)
 			var nodePeer wgtypes.PeerConfig
-			if _, ok := hostPeerUpdate.HostPeerIDs[peerHost.PublicKey.String()]; !ok {
-				hostPeerUpdate.HostPeerIDs[peerHost.PublicKey.String()] = make(map[string]models.IDandAddr)
+			if _, ok := peerIndexMap[peerHost.PublicKey.String()]; !ok {
 				hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, peerConfig)
 				peerIndexMap[peerHost.PublicKey.String()] = len(hostPeerUpdate.Peers) - 1
-				hostPeerUpdate.HostPeerIDs[peerHost.PublicKey.String()][peer.ID.String()] = models.IDandAddr{
-					ID:              peer.ID.String(),
-					Address:         peer.PrimaryAddress(),
-					Name:            peerHost.Name,
-					Network:         peer.Network,
-					ProxyListenPort: peerProxyPort,
-				}
 				hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
-					Interfaces:      peerHost.Interfaces,
-					ProxyListenPort: peerProxyPort,
+					Interfaces: peerHost.Interfaces,
+					ListenPort: peerPort,
 				}
 				nodePeer = peerConfig
 			} else {
@@ -294,27 +225,20 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 				peerAllowedIPs = append(peerAllowedIPs, peerConfig.AllowedIPs...)
 				hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].AllowedIPs = peerAllowedIPs
 				hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].Remove = false
-				hostPeerUpdate.HostPeerIDs[peerHost.PublicKey.String()][peer.ID.String()] = models.IDandAddr{
-					ID:              peer.ID.String(),
-					Address:         peer.PrimaryAddress(),
-					Name:            peerHost.Name,
-					Network:         peer.Network,
-					ProxyListenPort: GetProxyListenPort(peerHost),
-				}
 				hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
-					Interfaces:      peerHost.Interfaces,
-					ProxyListenPort: peerProxyPort,
+					Interfaces: peerHost.Interfaces,
+					ListenPort: peerPort,
 				}
 				nodePeer = hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]]
 			}
 
 			if node.Network == network { // add to peers map for metrics
 				hostPeerUpdate.PeerIDs[peerHost.PublicKey.String()] = models.IDandAddr{
-					ID:              peer.ID.String(),
-					Address:         peer.PrimaryAddress(),
-					Name:            peerHost.Name,
-					Network:         peer.Network,
-					ProxyListenPort: peerHost.ProxyListenPort,
+					ID:         peer.ID.String(),
+					Address:    peer.PrimaryAddress(),
+					Name:       peerHost.Name,
+					Network:    peer.Network,
+					ListenPort: GetPeerListenPort(peerHost),
 				}
 				hostPeerUpdate.NodePeers = append(hostPeerUpdate.NodePeers, nodePeer)
 			}
@@ -339,13 +263,6 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 				hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, extPeers...)
 				for _, extPeerIdAndAddr := range extPeerIDAndAddrs {
 					extPeerIdAndAddr := extPeerIdAndAddr
-					hostPeerUpdate.HostPeerIDs[extPeerIdAndAddr.ID] = make(map[string]models.IDandAddr)
-					hostPeerUpdate.HostPeerIDs[extPeerIdAndAddr.ID][extPeerIdAndAddr.ID] = models.IDandAddr{
-						ID:      extPeerIdAndAddr.ID,
-						Address: extPeerIdAndAddr.Address,
-						Name:    extPeerIdAndAddr.Name,
-						Network: node.Network,
-					}
 
 					hostPeerUpdate.IngressInfo.ExtPeers[extPeerIdAndAddr.ID] = models.ExtClientInfo{
 						Masquerade: true,
@@ -429,40 +346,15 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 	return hostPeerUpdate, nil
 }
 
-// getPeerWgListenPort - fetches the wg listen port for the host
-func getPeerWgListenPort(host *models.Host) int {
-	peerPort := host.ListenPort
-	if host.WgPublicListenPort != 0 {
-		peerPort = host.WgPublicListenPort
-	}
-	return peerPort
-}
-
 // GetPeerListenPort - given a host, retrieve it's appropriate listening port
 func GetPeerListenPort(host *models.Host) int {
 	peerPort := host.ListenPort
 	if host.WgPublicListenPort != 0 {
 		peerPort = host.WgPublicListenPort
 	}
-	if host.ProxyEnabled {
-		if host.PublicListenPort != 0 {
-			peerPort = host.PublicListenPort
-		} else if host.ProxyListenPort != 0 {
-			peerPort = host.ProxyListenPort
-		}
-	}
 	return peerPort
 }
 
-// GetProxyListenPort - fetches the proxy listen port
-func GetProxyListenPort(host *models.Host) int {
-	proxyPort := host.ProxyListenPort
-	if host.PublicListenPort != 0 {
-		proxyPort = host.PublicListenPort
-	}
-	return proxyPort
-}
-
 func getExtPeers(node *models.Node) ([]wgtypes.PeerConfig, []models.IDandAddr, error) {
 	var peers []wgtypes.PeerConfig
 	var idsAndAddr []models.IDandAddr
@@ -529,68 +421,6 @@ func getExtPeers(node *models.Node) ([]wgtypes.PeerConfig, []models.IDandAddr, e
 
 }
 
-func getExtPeersForProxy(node *models.Node, proxyPeerConf map[string]models.PeerConf) ([]wgtypes.PeerConfig, map[string]models.PeerConf, error) {
-	var peers []wgtypes.PeerConfig
-	host, err := GetHost(node.HostID.String())
-	if err != nil {
-		logger.Log(0, "error retrieving host for node", node.ID.String(), err.Error())
-	}
-
-	extPeers, err := GetNetworkExtClients(node.Network)
-	if err != nil {
-		return peers, proxyPeerConf, err
-	}
-	for _, extPeer := range extPeers {
-		pubkey, err := wgtypes.ParseKey(extPeer.PublicKey)
-		if err != nil {
-			logger.Log(1, "error parsing ext pub key:", err.Error())
-			continue
-		}
-
-		if host.PublicKey.String() == extPeer.PublicKey ||
-			extPeer.IngressGatewayID != node.ID.String() || !extPeer.Enabled {
-			continue
-		}
-
-		var allowedips []net.IPNet
-		var peer wgtypes.PeerConfig
-		if extPeer.Address != "" {
-			var peeraddr = net.IPNet{
-				IP:   net.ParseIP(extPeer.Address),
-				Mask: net.CIDRMask(32, 32),
-			}
-			if peeraddr.IP != nil && peeraddr.Mask != nil {
-				allowedips = append(allowedips, peeraddr)
-			}
-		}
-
-		if extPeer.Address6 != "" {
-			var addr6 = net.IPNet{
-				IP:   net.ParseIP(extPeer.Address6),
-				Mask: net.CIDRMask(128, 128),
-			}
-			if addr6.IP != nil && addr6.Mask != nil {
-				allowedips = append(allowedips, addr6)
-			}
-		}
-
-		peer = wgtypes.PeerConfig{
-			PublicKey:         pubkey,
-			ReplaceAllowedIPs: true,
-			AllowedIPs:        allowedips,
-		}
-		extConf := models.PeerConf{
-			IsExtClient: true,
-			Address:     net.ParseIP(extPeer.Address),
-		}
-		proxyPeerConf[peer.PublicKey.String()] = extConf
-
-		peers = append(peers, peer)
-	}
-	return peers, proxyPeerConf, nil
-
-}
-
 // GetAllowedIPs - calculates the wireguard allowedip field for a peer of a node based on the peer and node settings
 func GetAllowedIPs(node, peer *models.Node, metrics *models.Metrics) []net.IPNet {
 	var allowedips []net.IPNet

+ 0 - 6
models/api_host.go

@@ -60,10 +60,7 @@ func (h *Host) ConvertNMHostToAPI() *ApiHost {
 	a.Name = h.Name
 	a.OS = h.OS
 	a.Nodes = h.Nodes
-	a.ProxyEnabled = h.ProxyEnabled
-	a.PublicListenPort = h.PublicListenPort
 	a.WgPublicListenPort = h.WgPublicListenPort
-	a.ProxyListenPort = h.ProxyListenPort
 	a.PublicKey = h.PublicKey.String()
 	a.Verbosity = h.Verbosity
 	a.Version = h.Version
@@ -95,8 +92,6 @@ func (a *ApiHost) ConvertAPIHostToNMHost(currentHost *Host) *Host {
 	h.IsK8S = currentHost.IsK8S
 	h.IsStatic = a.IsStatic
 	h.ListenPort = a.ListenPort
-	h.ProxyListenPort = a.ProxyListenPort
-	h.PublicListenPort = currentHost.PublicListenPort
 	h.MTU = a.MTU
 	h.MacAddress = currentHost.MacAddress
 	h.PublicKey = currentHost.PublicKey
@@ -106,7 +101,6 @@ func (a *ApiHost) ConvertAPIHostToNMHost(currentHost *Host) *Host {
 	h.Nodes = currentHost.Nodes
 	h.TrafficKeyPublic = currentHost.TrafficKeyPublic
 	h.OS = currentHost.OS
-	h.ProxyEnabled = a.ProxyEnabled
 	h.IsDefault = a.IsDefault
 	h.NatType = currentHost.NatType
 	h.TurnEndpoint = currentHost.TurnEndpoint

+ 0 - 8
models/host.go

@@ -54,24 +54,16 @@ type Host struct {
 	Interface          string           `json:"interface" yaml:"interface"`
 	Debug              bool             `json:"debug" yaml:"debug"`
 	ListenPort         int              `json:"listenport" yaml:"listenport"`
-	PublicListenPort   int              `json:"public_listen_port" yaml:"public_listen_port"`
 	WgPublicListenPort int              `json:"wg_public_listen_port" yaml:"wg_public_listen_port"`
-	ProxyListenPort    int              `json:"proxy_listen_port" yaml:"proxy_listen_port"`
 	MTU                int              `json:"mtu" yaml:"mtu"`
 	PublicKey          wgtypes.Key      `json:"publickey" yaml:"publickey"`
 	MacAddress         net.HardwareAddr `json:"macaddress" yaml:"macaddress"`
 	TrafficKeyPublic   []byte           `json:"traffickeypublic" yaml:"traffickeypublic"`
 	InternetGateway    net.UDPAddr      `json:"internetgateway" yaml:"internetgateway"`
 	Nodes              []string         `json:"nodes" yaml:"nodes"`
-	IsRelayed          bool             `json:"isrelayed" yaml:"isrelayed"`
-	RelayedBy          string           `json:"relayed_by" yaml:"relayed_by"`
-	IsRelay            bool             `json:"isrelay" yaml:"isrelay"`
-	RelayedHosts       []string         `json:"relay_hosts" yaml:"relay_hosts"`
 	Interfaces         []Iface          `json:"interfaces" yaml:"interfaces"`
 	DefaultInterface   string           `json:"defaultinterface" yaml:"defaultinterface"`
 	EndpointIP         net.IP           `json:"endpointip" yaml:"endpointip"`
-	ProxyEnabled       bool             `json:"proxy_enabled" yaml:"proxy_enabled"`
-	ProxyEnabledSet    bool             `json:"proxy_enabled_updated" yaml:"proxy_enabled_updated"`
 	IsDocker           bool             `json:"isdocker" yaml:"isdocker"`
 	IsK8S              bool             `json:"isk8s" yaml:"isk8s"`
 	IsStatic           bool             `json:"isstatic" yaml:"isstatic"`

+ 8 - 11
models/metrics.go

@@ -29,12 +29,12 @@ type Metric struct {
 
 // IDandAddr - struct to hold ID and primary Address
 type IDandAddr struct {
-	ID              string `json:"id" bson:"id" yaml:"id"`
-	Address         string `json:"address" bson:"address" yaml:"address"`
-	Name            string `json:"name" bson:"name" yaml:"name"`
-	IsServer        string `json:"isserver" bson:"isserver" yaml:"isserver" validate:"checkyesorno"`
-	Network         string `json:"network" bson:"network" yaml:"network" validate:"network"`
-	ProxyListenPort int    `json:"proxy_listen_port" yaml:"proxy_listen_port"`
+	ID         string `json:"id" bson:"id" yaml:"id"`
+	Address    string `json:"address" bson:"address" yaml:"address"`
+	Name       string `json:"name" bson:"name" yaml:"name"`
+	IsServer   string `json:"isserver" bson:"isserver" yaml:"isserver" validate:"checkyesorno"`
+	Network    string `json:"network" bson:"network" yaml:"network" validate:"network"`
+	ListenPort int    `json:"listen_port" yaml:"listen_port"`
 }
 
 // HostInfoMap - map of host public keys to host networking info
@@ -42,16 +42,13 @@ 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"`
-	ProxyListenPort int     `json:"proxy_listen_port" yaml:"proxy_listen_port"`
+	Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
+	ListenPort int     `json:"listen_port" yaml:"listen_port"`
 }
 
 // PeerMap - peer map for ids and addresses in metrics
 type PeerMap map[string]IDandAddr
 
-// HostPeerMap - host peer map for ids and addresses
-type HostPeerMap map[string]map[string]IDandAddr
-
 // MetricsMap - map for holding multiple metrics in memory
 type MetricsMap map[string]Metrics
 

+ 0 - 2
models/mqtt.go

@@ -15,8 +15,6 @@ type HostPeerUpdate struct {
 	ServerAddrs       []ServerAddr         `json:"serveraddrs" bson:"serveraddrs" yaml:"serveraddrs"`
 	NodePeers         []wgtypes.PeerConfig `json:"peers" bson:"peers" yaml:"peers"`
 	Peers             []wgtypes.PeerConfig
-	HostPeerIDs       HostPeerMap           `json:"hostpeerids" bson:"hostpeerids" yaml:"hostpeerids"`
-	ProxyUpdate       ProxyManagerPayload   `json:"proxy_update" bson:"proxy_update" yaml:"proxy_update"`
 	EgressInfo        map[string]EgressInfo `json:"egress_info" bson:"egress_info" yaml:"egress_info"` // map key is node ID
 	IngressInfo       IngressInfo           `json:"ingress_info" bson:"ext_peers" yaml:"ext_peers"`
 	PeerIDs           PeerMap               `json:"peerids" bson:"peerids" yaml:"peerids"`

+ 0 - 3
models/node.go

@@ -483,7 +483,6 @@ func (ln *LegacyNode) ConvertToNewNode() (*Host, *Node) {
 		host.HostPass = ln.Password
 		host.Name = ln.Name
 		host.ListenPort = int(ln.ListenPort)
-		host.ProxyListenPort = int(ln.ProxyListenPort)
 		host.MTU = int(ln.MTU)
 		host.PublicKey, _ = wgtypes.ParseKey(ln.PublicKey)
 		host.MacAddress, _ = net.ParseMAC(ln.MacAddress)
@@ -540,7 +539,6 @@ func (n *Node) Legacy(h *Host, s *ServerConfig, net *Network) *LegacyNode {
 	l.Name = h.Name
 	l.NetworkSettings = *net
 	l.ListenPort = int32(h.ListenPort)
-	l.ProxyListenPort = int32(h.ProxyListenPort)
 	l.PublicKey = h.PublicKey.String()
 	l.Endpoint = h.EndpointIP.String()
 	//l.AllowedIPs =
@@ -580,7 +578,6 @@ func (n *Node) Legacy(h *Host, s *ServerConfig, net *Network) *LegacyNode {
 	l.InternetGateway = h.InternetGateway.String()
 	l.Connected = formatBool(n.Connected)
 	//l.PendingDelete = formatBool(n.PendingDelete)
-	l.Proxy = h.ProxyEnabled
 	l.DefaultACL = n.DefaultACL
 	l.OwnerID = n.OwnerID
 	//l.Failover = n.Failover

+ 0 - 68
models/proxy.go

@@ -1,68 +0,0 @@
-package models
-
-import (
-	"net"
-	"time"
-
-	"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
-)
-
-// ProxyAction - type for proxy action
-type ProxyAction string
-
-const (
-	// default proxy port
-	NmProxyPort = 51722
-	// PersistentKeepaliveInterval - default keepalive for wg peer
-	DefaultPersistentKeepaliveInterval = time.Duration(time.Second * 20)
-
-	// ProxyUpdate - constant for proxy update action
-	ProxyUpdate ProxyAction = "PROXY_UPDATE"
-	// ProxyDeletePeers - constant for proxy delete peers action
-	ProxyDeletePeers ProxyAction = "PROXY_DELETE"
-	// ProxyDeleteAllPeers - constant for proxy delete all peers action
-	ProxyDeleteAllPeers ProxyAction = "PROXY_DELETE_ALL"
-	// NoProxy - constant for no ProxyAction
-	NoProxy ProxyAction = "NO_PROXY"
-)
-
-// RelayedConf - struct relayed peers config
-type RelayedConf struct {
-	RelayedPeerEndpoint *net.UDPAddr         `json:"relayed_peer_endpoint"`
-	RelayedPeerPubKey   string               `json:"relayed_peer_pub_key"`
-	Peers               []wgtypes.PeerConfig `json:"relayed_peers"`
-}
-
-// PeerConf - struct for peer config in the network
-type PeerConf struct {
-	Proxy            bool         `json:"proxy"`
-	PublicListenPort int32        `json:"public_listen_port"`
-	ProxyListenPort  int          `json:"proxy_listen_port"`
-	IsExtClient      bool         `json:"is_ext_client"`
-	Address          net.IP       `json:"address"`
-	IsRelayed        bool         `json:"is_relayed"`
-	RelayedTo        *net.UDPAddr `json:"relayed_to"`
-	NatType          string       `json:"nat_type"`
-}
-
-// ProxyManagerPayload - struct for proxy manager payload
-type ProxyManagerPayload struct {
-	Action          ProxyAction            `json:"action"`
-	InterfaceName   string                 `json:"interface_name"`
-	Server          string                 `json:"server"`
-	Peers           []wgtypes.PeerConfig   `json:"peers"`
-	PeerMap         map[string]PeerConf    `json:"peer_map"`
-	IsIngress       bool                   `json:"is_ingress"`
-	IsRelayed       bool                   `json:"is_relayed"`
-	RelayedTo       *net.UDPAddr           `json:"relayed_to"`
-	IsRelay         bool                   `json:"is_relay"`
-	RelayedPeerConf map[string]RelayedConf `json:"relayed_conf"`
-}
-
-// Metric - struct for metric data
-type ProxyMetric struct {
-	NodeConnectionStatus map[string]bool `json:"node_connection_status"`
-	LastRecordedLatency  uint64          `json:"last_recorded_latency"`
-	TrafficSent          int64           `json:"traffic_sent"`     // stored in MB
-	TrafficRecieved      int64           `json:"traffic_recieved"` // stored in MB
-}

+ 0 - 14
mq/publishers.go

@@ -96,20 +96,6 @@ func PublishSingleHostPeerUpdate(host *models.Host, allNodes []models.Node, dele
 	if len(peerUpdate.Peers) == 0 { // no peers to send
 		return nil
 	}
-	if host.OS != models.OS_Types.IoT {
-		proxyUpdate, err := logic.GetProxyUpdateForHost(host)
-		if err != nil {
-			return err
-		}
-		proxyUpdate.Server = servercfg.GetServer()
-		if host.ProxyEnabled {
-			proxyUpdate.Action = models.ProxyUpdate
-		} else {
-			proxyUpdate.Action = models.NoProxy
-		}
-
-		peerUpdate.ProxyUpdate = proxyUpdate
-	}
 
 	data, err := json.Marshal(&peerUpdate)
 	if err != nil {

+ 0 - 4
scripts/netmaker.default.env

@@ -46,10 +46,6 @@ SERVER_BROKER_ENDPOINT="ws://mq:1883"
 STUN_PORT="3478"
 # Logging verbosity level - 1, 2, or 3
 VERBOSITY="1"
-# If ON, all new clients will enable proxy by default
-# If OFF, all new clients will disable proxy by default
-# If AUTO, stick with the existing logic for NAT detection
-DEFAULT_PROXY_MODE="off"
 # Port to access turn server
 TURN_PORT="3479"
 # Config for using turn, accepts either true/false

+ 1 - 1
scripts/nm-quick.sh

@@ -310,7 +310,7 @@ save_config() { (
 	local toCopy=("SERVER_HOST" "MASTER_KEY" "TURN_USERNAME" "TURN_PASSWORD" "MQ_USERNAME" "MQ_PASSWORD"
 		"INSTALL_TYPE" "NODE_ID" "DNS_MODE" "NETCLIENT_AUTO_UPDATE" "API_PORT"
 		"CORS_ALLOWED_ORIGIN" "DISPLAY_KEYS" "DATABASE" "SERVER_BROKER_ENDPOINT" "STUN_PORT" "VERBOSITY"
-		"DEFAULT_PROXY_MODE" "TURN_PORT" "USE_TURN" "DEBUG_MODE" "TURN_API_PORT" "REST_BACKEND"
+		"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"
 		"FRONTEND_URL" "AZURE_TENANT" "OIDC_ISSUER" "EXPORTER_API_PORT")
 	for name in "${toCopy[@]}"; do

+ 0 - 38
servercfg/serverconf.go

@@ -90,7 +90,6 @@ func GetServerConfig() config.ServerConfig {
 	if Is_EE {
 		cfg.IsEE = "yes"
 	}
-	cfg.DefaultProxyMode = GetDefaultProxyMode()
 
 	return cfg
 }
@@ -731,17 +730,6 @@ func GetTurnPassword() string {
 
 }
 
-// IsProxyEnabled - is proxy on or off
-func IsProxyEnabled() bool {
-	var enabled = false //default
-	if os.Getenv("PROXY") != "" {
-		enabled = os.Getenv("PROXY") == "on"
-	} else if config.Config.Server.Proxy != "" {
-		enabled = config.Config.Server.Proxy == "on"
-	}
-	return enabled
-}
-
 // GetNetworkLimit - fetches free tier limits on users
 func GetUserLimit() int {
 	var userslimit int
@@ -794,32 +782,6 @@ func DeployedByOperator() bool {
 	return config.Config.Server.DeployedByOperator
 }
 
-// GetDefaultProxyMode - default proxy mode for a server
-func GetDefaultProxyMode() config.ProxyMode {
-	var (
-		mode config.ProxyMode
-		def  string
-	)
-	if os.Getenv("DEFAULT_PROXY_MODE") != "" {
-		def = os.Getenv("DEFAULT_PROXY_MODE")
-	} else if config.Config.Server.DefaultProxyMode.Set {
-		return config.Config.Server.DefaultProxyMode
-	}
-	switch strings.ToUpper(def) {
-	case "ON":
-		mode.Set = true
-		mode.Value = true
-	case "OFF":
-		mode.Set = true
-		mode.Value = false
-	// AUTO or any other value
-	default:
-		mode.Set = false
-	}
-	return mode
-
-}
-
 // parseStunList - turn string into slice of StunServers
 func parseStunList(stunString string) ([]models.StunServer, error) {
 	var err error