Browse Source

Merge pull request #165 from gravitl/feature_v0.5_clientgrpc

Feature v0.5 clientgrpc
Alex 4 years ago
parent
commit
77d0ed7991

+ 0 - 1
config/config.go

@@ -55,7 +55,6 @@ type WG struct {
   GRPCWGInterface  string `yaml:"grpciface"`
   GRPCWGInterface  string `yaml:"grpciface"`
   GRPCWGAddress  string `yaml:"grpcaddr"`
   GRPCWGAddress  string `yaml:"grpcaddr"`
   GRPCWGAddressRange  string `yaml:"grpcaddrrange"`
   GRPCWGAddressRange  string `yaml:"grpcaddrrange"`
-  GRPCWGEndpoint  string `yaml:"grpcendpoint"`
   GRPCWGPort  string  `yaml:"grpcport"`
   GRPCWGPort  string  `yaml:"grpcport"`
   GRPCWGPubKey  string  `yaml:"pubkey"`
   GRPCWGPubKey  string  `yaml:"pubkey"`
   GRPCWGPrivKey  string  `yaml:"privkey"`
   GRPCWGPrivKey  string  `yaml:"privkey"`

+ 8 - 11
controllers/intClientHttpController.go

@@ -138,16 +138,13 @@ func RegisterIntClient(client models.IntClient) (models.IntClient, error) {
 		client.Address = newAddress
 		client.Address = newAddress
 	}
 	}
         if client.Network == "" { client.Network = "comms" }
         if client.Network == "" { client.Network = "comms" }
-	server, err := serverctl.GetServerWGConf()
-	if err != nil {
-		return client, err
-	}
-  gcfg := servercfg.GetConfig()
-  client.ServerWGEndpoint = server.ServerWGEndpoint
-  client.ServerAPIEndpoint = gcfg.APIHost + ":" + gcfg.APIPort
-	client.ServerAddress = server.ServerAddress
-	client.ServerPort = server.ServerPort
-	client.ServerKey = server.ServerKey
+
+	wgconfig := servercfg.GetWGConfig()
+        client.ServerPublicEndpoint = servercfg.GetAPIHost()
+        client.ServerAPIPort = servercfg.GetAPIPort()
+        client.ServerPrivateAddress = wgconfig.GRPCWGAddress
+        client.ServerWGPort = wgconfig.GRPCWGPort
+        client.ServerGRPCPort = servercfg.GetGRPCPort()
 
 
         if client.ClientID == "" {
         if client.ClientID == "" {
                 clientid := StringWithCharset(7, charset)
                 clientid := StringWithCharset(7, charset)
@@ -159,7 +156,7 @@ func RegisterIntClient(client models.IntClient) (models.IntClient, error) {
 	collection := mongoconn.Client.Database("netmaker").Collection("intclients")
 	collection := mongoconn.Client.Database("netmaker").Collection("intclients")
 	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
 	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
 	// insert our network into the network table
 	// insert our network into the network table
-	_, err = collection.InsertOne(ctx, client)
+	_, err := collection.InsertOne(ctx, client)
 	defer cancel()
 	defer cancel()
 
 
 	if err != nil {
 	if err != nil {

+ 2 - 1
controllers/networkHttpController.go

@@ -631,8 +631,9 @@ func CreateAccessKey(accesskey models.AccessKey, network models.Network) (models
 	netID := network.NetID
 	netID := network.NetID
 	grpcaddress := servercfg.GetGRPCHost() + ":" + servercfg.GetGRPCPort()
 	grpcaddress := servercfg.GetGRPCHost() + ":" + servercfg.GetGRPCPort()
 	apiaddress := servercfg.GetAPIHost() + ":" + servercfg.GetAPIPort()
 	apiaddress := servercfg.GetAPIHost() + ":" + servercfg.GetAPIPort()
+	wgport := servercfg.GetGRPCWGPort()
 
 
-	accessstringdec := grpcaddress + "|" + apiaddress + "|" + netID + "|" + accesskey.Value + "|" + privAddr
+	accessstringdec := wgport + "|" +grpcaddress + "|" + apiaddress + "|" + netID + "|" + accesskey.Value + "|" + privAddr
 	accesskey.AccessString = base64.StdEncoding.EncodeToString([]byte(accessstringdec))
 	accesskey.AccessString = base64.StdEncoding.EncodeToString([]byte(accessstringdec))
 	//validate accesskey
 	//validate accesskey
 	v := validator.New()
 	v := validator.New()

+ 2 - 2
controllers/nodeGrpcController.go

@@ -73,7 +73,7 @@ func (s *NodeServiceServer) ReadNode(ctx context.Context, req *nodepb.ReadNodeRe
 	}
 	}
 	return response, nil
 	return response, nil
 }
 }
-
+/*
 func (s *NodeServiceServer) GetConn(ctx context.Context, data *nodepb.Client) (*nodepb.Client, error) {
 func (s *NodeServiceServer) GetConn(ctx context.Context, data *nodepb.Client) (*nodepb.Client, error) {
         // Get the protobuf node type from the protobuf request type
         // Get the protobuf node type from the protobuf request type
         // Essentially doing req.Node to access the struct with a nil check
         // Essentially doing req.Node to access the struct with a nil check
@@ -124,7 +124,7 @@ func (s *NodeServiceServer) GetConn(ctx context.Context, data *nodepb.Client) (*
 
 
         return response, nil
         return response, nil
 }
 }
-
+*/
 func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNodeReq) (*nodepb.CreateNodeRes, error) {
 func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNodeReq) (*nodepb.CreateNodeRes, error) {
 	// Get the protobuf node type from the protobuf request type
 	// Get the protobuf node type from the protobuf request type
 	// Essentially doing req.Node to access the struct with a nil check
 	// Essentially doing req.Node to access the struct with a nil check

BIN
docs/_build/doctrees/environment.pickle


BIN
docs/_build/doctrees/support.doctree


+ 6 - 0
docs/_build/html/_sources/support.rst.txt

@@ -21,6 +21,12 @@ How do I install the Netclient on X?
 
 
 As per the above, there are many unsupported operating systems. You are still welcome to try, it is just an executable binary file after all. If the system is unix-based and has kernel WireGuard installed, netclient may very well mesh the device into the network. However, the service likely will encounter problems retrieving updates.
 As per the above, there are many unsupported operating systems. You are still welcome to try, it is just an executable binary file after all. If the system is unix-based and has kernel WireGuard installed, netclient may very well mesh the device into the network. However, the service likely will encounter problems retrieving updates.
 
 
+Why MongoDB? SQL is better and smaller.
+----------------------------------------
+
+We are in a phase of rapid iteration. Every week the database schema changes. MongoDB makes our development process much more flexible. That said, we agree! SQL will be better for production, and indeed, we plan to switch over to SQL before v1.0, so please be patient with the resource consumption of MongoDB for the time being; it is helping to support a rapid pace of development. 
+
+
 Is Netmaker a VPN like NordNPN?
 Is Netmaker a VPN like NordNPN?
 --------------------------------
 --------------------------------
 
 

File diff suppressed because it is too large
+ 0 - 0
docs/_build/html/searchindex.js


+ 8 - 0
docs/_build/html/support.html

@@ -604,6 +604,8 @@
         </li>
         </li>
         <li class="md-nav__item"><a href="#how-do-i-install-the-netclient-on-x" class="md-nav__link">How do I install the Netclient on X?</a>
         <li class="md-nav__item"><a href="#how-do-i-install-the-netclient-on-x" class="md-nav__link">How do I install the Netclient on X?</a>
         </li>
         </li>
+        <li class="md-nav__item"><a href="#why-mongodb-sql-is-better-and-smaller" class="md-nav__link">Why MongoDB? SQL is better and smaller.</a>
+        </li>
         <li class="md-nav__item"><a href="#is-netmaker-a-vpn-like-nordnpn" class="md-nav__link">Is Netmaker a VPN like NordNPN?</a>
         <li class="md-nav__item"><a href="#is-netmaker-a-vpn-like-nordnpn" class="md-nav__link">Is Netmaker a VPN like NordNPN?</a>
         </li>
         </li>
         <li class="md-nav__item"><a href="#do-you-offer-any-paid-support" class="md-nav__link">Do you offer any paid support?</a>
         <li class="md-nav__item"><a href="#do-you-offer-any-paid-support" class="md-nav__link">Do you offer any paid support?</a>
@@ -756,6 +758,8 @@
         </li>
         </li>
         <li class="md-nav__item"><a href="#how-do-i-install-the-netclient-on-x" class="md-nav__link">How do I install the Netclient on X?</a>
         <li class="md-nav__item"><a href="#how-do-i-install-the-netclient-on-x" class="md-nav__link">How do I install the Netclient on X?</a>
         </li>
         </li>
+        <li class="md-nav__item"><a href="#why-mongodb-sql-is-better-and-smaller" class="md-nav__link">Why MongoDB? SQL is better and smaller.</a>
+        </li>
         <li class="md-nav__item"><a href="#is-netmaker-a-vpn-like-nordnpn" class="md-nav__link">Is Netmaker a VPN like NordNPN?</a>
         <li class="md-nav__item"><a href="#is-netmaker-a-vpn-like-nordnpn" class="md-nav__link">Is Netmaker a VPN like NordNPN?</a>
         </li>
         </li>
         <li class="md-nav__item"><a href="#do-you-offer-any-paid-support" class="md-nav__link">Do you offer any paid support?</a>
         <li class="md-nav__item"><a href="#do-you-offer-any-paid-support" class="md-nav__link">Do you offer any paid support?</a>
@@ -801,6 +805,10 @@
 <p>As per the above, there are many unsupported operating systems. You are still welcome to try, it is just an executable binary file after all. If the system is unix-based and has kernel WireGuard installed, netclient may very well mesh the device into the network. However, the service likely will encounter problems retrieving updates.</p>
 <p>As per the above, there are many unsupported operating systems. You are still welcome to try, it is just an executable binary file after all. If the system is unix-based and has kernel WireGuard installed, netclient may very well mesh the device into the network. However, the service likely will encounter problems retrieving updates.</p>
 
 
 
 
+<h3 id="why-mongodb-sql-is-better-and-smaller">Why MongoDB? SQL is better and smaller.<a class="headerlink" href="#why-mongodb-sql-is-better-and-smaller" title="Permalink to this headline">¶</a></h3>
+<p>We are in a phase of rapid iteration. Every week the database schema changes. MongoDB makes our development process much more flexible. That said, we agree! SQL will be better for production, and indeed, we plan to switch over to SQL before v1.0, so please be patient with the resource consumption of MongoDB for the time being; it is helping to support a rapid pace of development.</p>
+
+
 <h3 id="is-netmaker-a-vpn-like-nordnpn">Is Netmaker a VPN like NordNPN?<a class="headerlink" href="#is-netmaker-a-vpn-like-nordnpn" title="Permalink to this headline">¶</a></h3>
 <h3 id="is-netmaker-a-vpn-like-nordnpn">Is Netmaker a VPN like NordNPN?<a class="headerlink" href="#is-netmaker-a-vpn-like-nordnpn" title="Permalink to this headline">¶</a></h3>
 <p>No. Netmaker makes Virtual Networks, which are technically VPNs, but different. It’s more like a corporate VPN, or a VPC (if you’re familiar with AWS).</p>
 <p>No. Netmaker makes Virtual Networks, which are technically VPNs, but different. It’s more like a corporate VPN, or a VPC (if you’re familiar with AWS).</p>
 <p>If you’re looking to achieve self-hosted web browsing, with functionality similar to NordVPN, ExpressVPN, Surfshark, Tunnelbear, or Private Internet Access, this is probably not the project for you. Technically, you can accomplish this with Netmaker, but it would be a little like using a all-terrain vehicle for stock car racing.</p>
 <p>If you’re looking to achieve self-hosted web browsing, with functionality similar to NordVPN, ExpressVPN, Surfshark, Tunnelbear, or Private Internet Access, this is probably not the project for you. Technically, you can accomplish this with Netmaker, but it would be a little like using a all-terrain vehicle for stock car racing.</p>

+ 1 - 1
functions/helpers.go

@@ -45,7 +45,7 @@ func CreateServerToken(netID string) (string, error) {
 		privAddr = network.LocalRange
 		privAddr = network.LocalRange
 	}
 	}
 
 
-        accessstringdec := address + "|" + address + "|" + netID + "|" + accesskey.Value + "|" + privAddr
+        accessstringdec := " " + "|"+ address + "|" + address + "|" + netID + "|" + accesskey.Value + "|" + privAddr
 
 
 	accesskey.AccessString = base64.StdEncoding.EncodeToString([]byte(accessstringdec))
 	accesskey.AccessString = base64.StdEncoding.EncodeToString([]byte(accessstringdec))
 
 

+ 5 - 4
models/intclient.go

@@ -8,10 +8,11 @@ type IntClient struct {
 	Address        string             `json:"address" bson:"address"`
 	Address        string             `json:"address" bson:"address"`
 	Address6       string             `json:"address6" bson:"address6"`
 	Address6       string             `json:"address6" bson:"address6"`
 	Network        string             `json:"network" bson:"network"`
 	Network        string             `json:"network" bson:"network"`
-	ServerWGEndpoint  string          `json:"serverwgendpoint" bson:"serverwgendpoint"`
-	ServerAPIEndpoint  string         `json:"serverapiendpoint" bson:"serverapiendpoint"`
-	ServerAddress  string             `json:"serveraddress" bson:"serveraddress"`
-	ServerPort     string             `json:"serverport" bson:"serverport"`
+	ServerPublicEndpoint  string `json:"serverwgendpoint" bson:"serverwgendpoint"`
+	ServerAPIPort  string      `json:"serverapiendpoint" bson:"serverapiendpoint"`
+	ServerPrivateAddress  string       `json:"serveraddress" bson:"serveraddress"`
+	ServerWGPort     string             `json:"serverport" bson:"serverport"`
+	ServerGRPCPort     string             `json:"serverport" bson:"serverport"`
 	ServerKey      string             `json:"serverkey" bson:"serverkey"`
 	ServerKey      string             `json:"serverkey" bson:"serverkey"`
 	IsServer       string             `json:"isserver" bson:"isserver"`
 	IsServer       string             `json:"isserver" bson:"isserver"`
 }
 }

+ 30 - 24
netclient/config/config.go

@@ -240,8 +240,14 @@ func ModGlobalConfig(cfg models.IntClient) error{
                 }
                 }
                 modconfig = *useconfig
                 modconfig = *useconfig
         }
         }
-        if cfg.ServerPort != ""{
-                modconfig.Client.ServerPort = cfg.ServerPort
+        if cfg.ServerWGPort != ""{
+                modconfig.Client.ServerWGPort = cfg.ServerWGPort
+        }
+        if cfg.ServerGRPCPort != ""{
+                modconfig.Client.ServerGRPCPort = cfg.ServerGRPCPort
+        }
+        if cfg.ServerAPIPort != ""{
+                modconfig.Client.ServerAPIPort = cfg.ServerAPIPort
         }
         }
         if cfg.PublicKey != ""{
         if cfg.PublicKey != ""{
                 modconfig.Client.PublicKey = cfg.PublicKey
                 modconfig.Client.PublicKey = cfg.PublicKey
@@ -249,11 +255,11 @@ func ModGlobalConfig(cfg models.IntClient) error{
         if cfg.PrivateKey != ""{
         if cfg.PrivateKey != ""{
                 modconfig.Client.PrivateKey = cfg.PrivateKey
                 modconfig.Client.PrivateKey = cfg.PrivateKey
         }
         }
-        if cfg.ServerWGEndpoint != ""{
-                modconfig.Client.ServerWGEndpoint = cfg.ServerWGEndpoint
+        if cfg.ServerPublicEndpoint != ""{
+                modconfig.Client.ServerPublicEndpoint = cfg.ServerPublicEndpoint
         }
         }
-        if cfg.ServerAddress != ""{
-                modconfig.Client.ServerAddress = cfg.ServerAddress
+        if cfg.ServerPrivateAddress != ""{
+                modconfig.Client.ServerPrivateAddress = cfg.ServerPrivateAddress
         }
         }
 	if cfg.Address != ""{
 	if cfg.Address != ""{
                 modconfig.Client.Address = cfg.Address
                 modconfig.Client.Address = cfg.Address
@@ -363,12 +369,12 @@ func GetCLIConfig(c *cli.Context) (ClientConfig, error){
                 }
                 }
                 token := string(tokenbytes)
                 token := string(tokenbytes)
                 tokenvals := strings.Split(token, "|")
                 tokenvals := strings.Split(token, "|")
-                cfg.Server.GRPCAddress = tokenvals[0]
-                cfg.Server.APIAddress = tokenvals[1]
-                cfg.Network = tokenvals[2]
-                cfg.Node.Network = tokenvals[2]
-                cfg.Server.AccessKey = tokenvals[3]
-                cfg.Node.LocalRange = tokenvals[4]
+                cfg.Server.GRPCAddress = tokenvals[1]
+                cfg.Server.APIAddress = tokenvals[2]
+                cfg.Network = tokenvals[3]
+                cfg.Node.Network = tokenvals[4]
+                cfg.Server.AccessKey = tokenvals[5]
+                cfg.Node.LocalRange = tokenvals[6]
 
 
 		if c.String("grpcserver") != "" {
 		if c.String("grpcserver") != "" {
 			cfg.Server.GRPCAddress = c.String("grpcserver")
 			cfg.Server.GRPCAddress = c.String("grpcserver")
@@ -429,21 +435,21 @@ func GetCLIConfigRegister(c *cli.Context) (GlobalConfig, error){
                 }
                 }
                 token := string(tokenbytes)
                 token := string(tokenbytes)
                 tokenvals := strings.Split(token, "|")
                 tokenvals := strings.Split(token, "|")
-                cfg.Client.ServerAddress = tokenvals[0]
-                cfg.Client.ServerAPIEndpoint = tokenvals[1]
-		servervals := strings.Split(tokenvals[1], ":")
-		wgvals := strings.Split(tokenvals[0], ":")
-		cfg.Client.ServerWGEndpoint = servervals[0]
-                cfg.Client.ServerAddress = wgvals[0]
-                cfg.Client.ServerPort = wgvals[1]
+		grpcvals := strings.Split(tokenvals[1],":")
+		apivals := strings.Split(tokenvals[2], ":")
+		cfg.Client.ServerWGPort = tokenvals[0]
+                cfg.Client.ServerPrivateAddress = grpcvals[0]
+                cfg.Client.ServerGRPCPort = grpcvals[1]
+                cfg.Client.ServerPublicEndpoint = apivals[0]
+                cfg.Client.ServerAPIPort = apivals[1]
 
 
-		cfg.Client.ServerKey = tokenvals[3]
+		cfg.Client.ServerKey = tokenvals[4]
 
 
                 if c.String("grpcserver") != "" {
                 if c.String("grpcserver") != "" {
-                        cfg.Client.ServerAddress = c.String("grpcserver")
+                        cfg.Client.ServerPrivateAddress = c.String("grpcserver")
                 }
                 }
                 if c.String("apiserver") != "" {
                 if c.String("apiserver") != "" {
-                        cfg.Client.ServerAPIEndpoint = c.String("apiserver")
+                        cfg.Client.ServerPublicEndpoint = c.String("apiserver")
                 }
                 }
                 if c.String("key") != "" {
                 if c.String("key") != "" {
                         cfg.Client.ServerKey = c.String("key")
                         cfg.Client.ServerKey = c.String("key")
@@ -452,8 +458,8 @@ func GetCLIConfigRegister(c *cli.Context) (GlobalConfig, error){
                         cfg.Client.Network = c.String("network")
                         cfg.Client.Network = c.String("network")
                 }
                 }
         } else {
         } else {
-                cfg.Client.ServerAddress = c.String("grpcserver")
-                cfg.Client.ServerWGEndpoint = c.String("apiserver")
+                cfg.Client.ServerPrivateAddress = c.String("grpcserver")
+                cfg.Client.ServerPublicEndpoint = c.String("apiserver")
                 cfg.Client.ServerKey = c.String("key")
                 cfg.Client.ServerKey = c.String("key")
                 cfg.Client.Network = c.String("network")
                 cfg.Client.Network = c.String("network")
         }
         }

+ 7 - 7
netclient/functions/register.go

@@ -41,8 +41,10 @@ func Register(cfg config.GlobalConfig) error {
         }
         }
 	jsonbytes := []byte(jsonstring)
 	jsonbytes := []byte(jsonstring)
 	body := bytes.NewBuffer(jsonbytes)
 	body := bytes.NewBuffer(jsonbytes)
-	log.Println("registering to http://"+cfg.Client.ServerAPIEndpoint+"/api/client/register")
-	res, err := http.Post("http://"+cfg.Client.ServerAPIEndpoint+"/api/intclient/register","application/json",body)
+	publicaddress := cfg.Client.ServerPublicEndpoint + ":" + cfg.Client.ServerAPIPort
+
+	log.Println("registering to http://"+publicaddress+"/api/client/register")
+	res, err := http.Post("http://"+publicaddress+"/api/intclient/register","application/json",body)
         if err != nil {
         if err != nil {
                 return err
                 return err
         }
         }
@@ -60,9 +62,6 @@ func Register(cfg config.GlobalConfig) error {
         if err != nil {
         if err != nil {
                 return err
                 return err
         }
         }
-	if wgclient.ServerWGEndpoint == "" {
-		wgclient.ServerWGEndpoint = cfg.Client.ServerWGEndpoint
-	}
         spew.Dump(wgclient)
         spew.Dump(wgclient)
 	err = wireguard.InitGRPCWireguard(wgclient)
 	err = wireguard.InitGRPCWireguard(wgclient)
         if err != nil {
         if err != nil {
@@ -74,13 +73,14 @@ func Register(cfg config.GlobalConfig) error {
 
 
 func Unregister(cfg config.GlobalConfig) error {
 func Unregister(cfg config.GlobalConfig) error {
 	client := &http.Client{ Timeout: 7 * time.Second,}
 	client := &http.Client{ Timeout: 7 * time.Second,}
-	req, err := http.NewRequest("DELETE", "http://"+cfg.Client.ServerAPIEndpoint+"/api/intclient/"+cfg.Client.ClientID, nil)
+	publicaddress := cfg.Client.ServerPublicEndpoint + ":" + cfg.Client.ServerAPIPort
+	req, err := http.NewRequest("DELETE", "http://"+publicaddress+"/api/intclient/"+cfg.Client.ClientID, nil)
 	if err != nil {
 	if err != nil {
                 log.Println(err)
                 log.Println(err)
         } else {
         } else {
 		res, err := client.Do(req)
 		res, err := client.Do(req)
 		if res == nil {
 		if res == nil {
-	                err = errors.New("server not reachable at " + "http://"+cfg.Client.ServerAPIEndpoint+"/api/intclient/"+cfg.Client.ClientID)
+	                err = errors.New("server not reachable at " + "http://"+publicaddress+"/api/intclient/"+cfg.Client.ClientID)
 			log.Println(err)
 			log.Println(err)
 		} else if res.StatusCode != http.StatusOK {
 		} else if res.StatusCode != http.StatusOK {
 			err = errors.New("request to server failed: " + res.Status)
 			err = errors.New("request to server failed: " + res.Status)

+ 1 - 1
netclient/main.go

@@ -191,7 +191,7 @@ func main() {
                 if err != nil {
                 if err != nil {
                         return err
                         return err
                 }
                 }
-                if cfg.Client.ServerAddress == "" {
+                if cfg.Client.ServerPrivateAddress == "" {
                         err = errors.New("No server address provided.")
                         err = errors.New("No server address provided.")
                         return err
                         return err
                 }
                 }

+ 4 - 4
netclient/wireguard/kernel.go

@@ -33,7 +33,7 @@ func InitGRPCWireguard(client models.IntClient) error {
         if err !=  nil {
         if err !=  nil {
                 return err
                 return err
         }
         }
-	serverport, err := strconv.Atoi(client.ServerPort)
+	serverport, err := strconv.Atoi(client.ServerWGPort)
         if err !=  nil {
         if err !=  nil {
                 return err
                 return err
         }
         }
@@ -87,16 +87,16 @@ func InitGRPCWireguard(client models.IntClient) error {
         }
         }
 	var peers []wgtypes.PeerConfig
 	var peers []wgtypes.PeerConfig
         var peeraddr = net.IPNet{
         var peeraddr = net.IPNet{
-                 IP: net.ParseIP(client.ServerAddress),
+                 IP: net.ParseIP(client.ServerPrivateAddress),
                  Mask: net.CIDRMask(32, 32),
                  Mask: net.CIDRMask(32, 32),
         }
         }
 	var allowedips []net.IPNet
 	var allowedips []net.IPNet
         allowedips = append(allowedips, peeraddr)
         allowedips = append(allowedips, peeraddr)
-	net.ParseIP(client.ServerWGEndpoint)
+	net.ParseIP(client.ServerPublicEndpoint)
 	peer := wgtypes.PeerConfig{
 	peer := wgtypes.PeerConfig{
                PublicKey: serverkey,
                PublicKey: serverkey,
                Endpoint: &net.UDPAddr{
                Endpoint: &net.UDPAddr{
-                         IP:   net.ParseIP(client.ServerWGEndpoint),
+                         IP:   net.ParseIP(client.ServerPublicEndpoint),
                          Port: serverport,
                          Port: serverport,
                },
                },
                ReplaceAllowedIPs: true,
                ReplaceAllowedIPs: true,

+ 6 - 10
servercfg/serverconf.go

@@ -57,8 +57,8 @@ func GetWGConfig() config.WG{
 	cfg.GRPCWGInterface = GetGRPCWGInterface()
 	cfg.GRPCWGInterface = GetGRPCWGInterface()
 	cfg.GRPCWGAddress = GetGRPCWGAddress()
 	cfg.GRPCWGAddress = GetGRPCWGAddress()
 	cfg.GRPCWGPort = GetGRPCWGPort()
 	cfg.GRPCWGPort = GetGRPCWGPort()
-	cfg.GRPCWGEndpoint = GetGRPCHost()
-
+	cfg.GRPCWGPubKey =  GetGRPCWGPubKey()
+	cfg.GRPCWGPrivKey =  GetGRPCWGPrivKey()
 	return cfg
 	return cfg
 }
 }
 
 
@@ -110,14 +110,10 @@ func GetGRPCHost() string {
 }
 }
 func GetGRPCPort() string {
 func GetGRPCPort() string {
         grpcport := "50051"
         grpcport := "50051"
-        if IsGRPCWireGuard() {
-                grpcport = GetGRPCWGPort()
-        } else {
-	        if os.Getenv("GRPC_PORT") != "" {
-	                grpcport = os.Getenv("GRPC_PORT")
-	        } else if  config.Config.Server.GRPCPort != "" {
-	                grpcport = config.Config.Server.GRPCPort
-	        }
+	if os.Getenv("GRPC_PORT") != "" {
+	        grpcport = os.Getenv("GRPC_PORT")
+	} else if  config.Config.Server.GRPCPort != "" {
+	        grpcport = config.Config.Server.GRPCPort
 	}
 	}
         return grpcport
         return grpcport
 }
 }

+ 5 - 3
serverctl/wireguard.go

@@ -61,9 +61,11 @@ func InitServerWireGuard() error {
 	var client models.IntClient
 	var client models.IntClient
 	client.PrivateKey = wgconfig.GRPCWGPrivKey
 	client.PrivateKey = wgconfig.GRPCWGPrivKey
 	client.PublicKey = wgconfig.GRPCWGPubKey
 	client.PublicKey = wgconfig.GRPCWGPubKey
-	client.ServerWGEndpoint = wgconfig.GRPCWGEndpoint
-	client.ServerAddress = wgconfig.GRPCWGAddress
-	client.ServerPort = wgconfig.GRPCWGPort
+	client.ServerPublicEndpoint = servercfg.GetAPIHost()
+	client.ServerAPIPort = servercfg.GetAPIPort()
+	client.ServerPrivateAddress = wgconfig.GRPCWGAddress
+	client.ServerWGPort = wgconfig.GRPCWGPort
+	client.ServerGRPCPort = servercfg.GetGRPCPort()
 	client.Address = wgconfig.GRPCWGAddress
 	client.Address = wgconfig.GRPCWGAddress
 	client.IsServer = "yes"
 	client.IsServer = "yes"
 	client.Network = "comms"
 	client.Network = "comms"

Some files were not shown because too many files changed in this diff