Parcourir la source

NET-282: Remove Proxy fields (#2388)

* remove proxy fields

* remove proxy fields

* remove tests related to proxy port

* rm unused func
Abhishek K il y a 2 ans
Parent
commit
90bbd41aa1

+ 48 - 56
config/config.go

@@ -32,62 +32,54 @@ 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"`
-	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"`
-	NetmakerAccountID    string    `yaml:"netmaker_account_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"`
-}
-
-// 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"`
+	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"`
+	NetmakerAccountID    string `yaml:"netmaker_account_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"`
 }
 
 // SQLConfig - Generic SQL Config

+ 2 - 2
controllers/ext_client.go

@@ -350,8 +350,8 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 	listenPort := host.ListenPort
-	if host.ProxyEnabled {
-		listenPort = host.ProxyListenPort
+	if host.WgPublicListenPort != 0 {
+		listenPort = host.WgPublicListenPort
 	}
 	extclient.IngressGatewayEndpoint = host.EndpointIP.String() + ":" + strconv.FormatInt(int64(listenPort), 10)
 	extclient.Enabled = true

+ 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 - 35
logic/hosts.go

@@ -6,7 +6,6 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
-	"log"
 	"net/http"
 	"sort"
 	"strconv"
@@ -111,15 +110,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)
 }
@@ -154,12 +144,7 @@ func UpdateHost(newHost, currentHost *models.Host) {
 	if newHost.ListenPort == 0 {
 		newHost.ListenPort = currentHost.ListenPort
 	}
-
-	if newHost.ProxyListenPort == 0 {
-		newHost.ProxyListenPort = currentHost.ProxyListenPort
-	}
-	newHost.PublicListenPort = currentHost.PublicListenPort
-
+	newHost.WgPublicListenPort = currentHost.WgPublicListenPort
 }
 
 // UpdateHostFromClient - used for updating host on server with update recieved from client
@@ -177,18 +162,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
@@ -418,7 +391,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++ {
@@ -429,12 +401,6 @@ func CheckHostPorts(h *models.Host) {
 	}
 	// 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

+ 14 - 160
logic/peers.go

@@ -23,67 +23,6 @@ var (
 	PeerUpdateStop context.CancelFunc
 )
 
-// GetProxyUpdateForHost - gets the proxy update for host
-func GetProxyUpdateForHost(ctx context.Context, 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
-}
-
 // ResetPeerUpdateContext - kills any current peer updates and resets the context
 func ResetPeerUpdateContext() {
 	if PeerUpdateCtx != nil && PeerUpdateStop != nil {
@@ -202,23 +141,19 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
 					(deletedNode == nil || (deletedNode != nil && peer.ID.String() != deletedNode.ID.String())) {
 					peerConfig.AllowedIPs = allowedips // only append allowed IPs if valid connection
 				}
-
-				peerProxyPort := GetProxyListenPort(peerHost)
 				var nodePeer wgtypes.PeerConfig
 				if _, ok := hostPeerUpdate.HostPeerIDs[peerHost.PublicKey.String()]; !ok {
 					hostPeerUpdate.HostPeerIDs[peerHost.PublicKey.String()] = make(map[string]models.IDandAddr)
 					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,
+						ID:      peer.ID.String(),
+						Address: peer.PrimaryAddress(),
+						Name:    peerHost.Name,
+						Network: peer.Network,
 					}
 					hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
-						Interfaces:      peerHost.Interfaces,
-						ProxyListenPort: peerProxyPort,
+						Interfaces: peerHost.Interfaces,
 					}
 					nodePeer = peerConfig
 				} else {
@@ -226,26 +161,23 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
 					peerAllowedIPs = append(peerAllowedIPs, allowedips...)
 					hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].AllowedIPs = peerAllowedIPs
 					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),
+						ID:      peer.ID.String(),
+						Address: peer.PrimaryAddress(),
+						Name:    peerHost.Name,
+						Network: peer.Network,
 					}
 					hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
-						Interfaces:      peerHost.Interfaces,
-						ProxyListenPort: peerProxyPort,
+						Interfaces: peerHost.Interfaces,
 					}
 					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,
 					}
 					hostPeerUpdate.NodePeers = append(hostPeerUpdate.NodePeers, nodePeer)
 				}
@@ -452,25 +384,9 @@ func GetPeerListenPort(host *models.Host) int {
 	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
@@ -537,68 +453,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

+ 1 - 8
models/api_host.go

@@ -59,10 +59,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
@@ -93,8 +90,7 @@ 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.WgPublicListenPort = currentHost.WgPublicListenPort
 	h.MTU = a.MTU
 	h.MacAddress = currentHost.MacAddress
 	h.PublicKey = currentHost.PublicKey
@@ -104,10 +100,7 @@ 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
-
 	return &h
 }

+ 0 - 6
models/host.go

@@ -2,7 +2,6 @@ package models
 
 import (
 	"net"
-	"net/netip"
 
 	"github.com/google/uuid"
 	"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
@@ -54,9 +53,7 @@ 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"`
@@ -70,14 +67,11 @@ type Host struct {
 	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"`
 	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"`
 }
 
 // Client - represents a client on the network

+ 6 - 8
models/metrics.go

@@ -29,12 +29,11 @@ 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"`
 }
 
 // HostInfoMap - map of host public keys to host networking info
@@ -42,8 +41,7 @@ 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"`
 }
 
 // PeerMap - peer map for ids and addresses in metrics

+ 3 - 4
models/mqtt.go

@@ -14,10 +14,9 @@ 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"`
-	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"`
+	HostPeerIDs     HostPeerMap `json:"hostpeerids" bson:"hostpeerids" yaml:"hostpeerids"`
+	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"`
 }
 
 // IngressInfo - struct for ingress info

+ 0 - 3
models/node.go

@@ -475,7 +475,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)
@@ -532,7 +531,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 =
@@ -572,7 +570,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 - 13
mq/publishers.go

@@ -91,19 +91,6 @@ func PublishSingleHostPeerUpdate(ctx context.Context, host *models.Host, deleted
 	if len(peerUpdate.Peers) == 0 { // no peers to send
 		return nil
 	}
-	proxyUpdate, err := logic.GetProxyUpdateForHost(ctx, 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 {
 		return err

+ 0 - 4
scripts/netmaker.default.env

@@ -45,10 +45,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

@@ -303,7 +303,7 @@ save_config() { (
 	local toCopy=("SERVER_HOST" "MASTER_KEY" "TURN_USERNAME" "TURN_PASSWORD" "MQ_USERNAME" "MQ_PASSWORD"
 		"INSTALL_TYPE" "NODE_ID" "METRICS_EXPORTER" "PROMETHEUS" "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" "DISABLE_REMOTE_IP_CHECK"
+		"TURN_PORT" "USE_TURN" "DEBUG_MODE" "TURN_API_PORT" "REST_BACKEND" "DISABLE_REMOTE_IP_CHECK"
 		"TELEMETRY" "AUTH_PROVIDER" "CLIENT_ID" "CLIENT_SECRET" "FRONTEND_URL" "AZURE_TENANT" "OIDC_ISSUER"
 		"EXPORTER_API_PORT")
 	for name in "${toCopy[@]}"; do

+ 0 - 39
servercfg/serverconf.go

@@ -84,8 +84,6 @@ func GetServerConfig() config.ServerConfig {
 	if Is_EE {
 		cfg.IsEE = "yes"
 	}
-	cfg.DefaultProxyMode = GetDefaultProxyMode()
-
 	return cfg
 }
 
@@ -714,43 +712,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
-}
-
-// 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