netclient working for ingress controller

This commit is contained in:
afeiszli
2021-05-27 14:57:59 -04:00
parent c27c863d6a
commit 112b01f526
16 changed files with 373 additions and 144 deletions

View File

@@ -32,7 +32,7 @@ func HandleRESTRequests(wg *sync.WaitGroup) {
fileHandlers(r) fileHandlers(r)
serverHandlers(r) serverHandlers(r)
extClientHandlers(r) extClientHandlers(r)
intClientHandlers(r)
port := servercfg.GetAPIPort() port := servercfg.GetAPIPort()

View File

@@ -0,0 +1,142 @@
package controller
import (
// "fmt"
"errors"
"context"
"encoding/json"
"net/http"
"time"
"github.com/gorilla/mux"
"github.com/gravitl/netmaker/functions"
"github.com/gravitl/netmaker/serverctl"
"github.com/gravitl/netmaker/servercfg"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/mongoconn"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)
func intClientHandlers(r *mux.Router) {
r.HandleFunc("/api/intclient/{clientid}", securityCheck(http.HandlerFunc(getIntClient))).Methods("GET")
r.HandleFunc("/api/intclients", securityCheck(http.HandlerFunc(getAllIntClients))).Methods("GET")
r.HandleFunc("/api/intclients/deleteall", securityCheck(http.HandlerFunc(deleteAllIntClients))).Methods("POST")
r.HandleFunc("/api/intclient/register", http.HandlerFunc(registerIntClient)).Methods("POST")
}
func getAllIntClients(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
clients, err := functions.GetAllIntClients()
if err != nil {
returnErrorResponse(w, r, formatError(err, "internal"))
return
}
//Return all the extclients in JSON format
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(clients)
}
func deleteAllIntClients(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
err := functions.DeleteAllIntClients()
if err != nil {
returnErrorResponse(w, r, formatError(err, "internal"))
return
}
//Return all the extclients in JSON format
w.WriteHeader(http.StatusOK)
}
func getIntClient(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
clients, err := functions.GetAllIntClients()
if err != nil {
returnErrorResponse(w, r, formatError(err, "internal"))
return
}
//Return all the extclients in JSON format
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(clients)
}
func RegisterIntClient(client models.IntClient) (models.IntClient, error) {
if client.PrivateKey == "" {
privateKey, err := wgtypes.GeneratePrivateKey()
if err != nil {
return client, err
}
client.PrivateKey = privateKey.String()
client.PublicKey = privateKey.PublicKey().String()
}
if client.Address == "" {
newAddress, err := functions.UniqueAddress6(client.Network)
if err != nil {
return client, err
}
if newAddress == "" {
return client, errors.New("Could not find an address.")
}
client.Address6 = newAddress
}
if client.Network == "" { client.Network = "comms" }
server, err := serverctl.GetServerWGConf()
if err != nil {
return client, err
}
client.ServerEndpoint = server.ServerEndpoint
client.ServerAddress = server.ServerAddress
client.ServerPort = server.ServerPort
client.ServerKey = server.ServerKey
collection := mongoconn.Client.Database("netmaker").Collection("intclients")
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
// insert our network into the network table
_, err = collection.InsertOne(ctx, client)
defer cancel()
if err != nil {
return client, err
}
err = serverctl.ReconfigureServerWireGuard()
return client, err
}
func registerIntClient(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
var errorResponse = models.ErrorResponse{
Code: http.StatusInternalServerError, Message: "W1R3: It's not you it's me.",
}
var clientreq models.IntClient
//get node from body of request
err := json.NewDecoder(r.Body).Decode(&clientreq)
if err != nil {
returnErrorResponse(w, r, formatError(err, "internal"))
return
}
if servercfg.IsRegisterKeyRequired() {
validKey := functions.IsKeyValidGlobal(clientreq.AccessKey)
if !validKey {
errorResponse = models.ErrorResponse{
Code: http.StatusUnauthorized, Message: "W1R3: Key invalid, or none provided.",
}
returnErrorResponse(w, r, errorResponse)
return
}
}
client, err := RegisterIntClient(clientreq)
if err != nil {
returnErrorResponse(w, r, formatError(err, "internal"))
return
}
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(client)
}

View File

@@ -62,6 +62,7 @@ func (s *NodeServiceServer) ReadNode(ctx context.Context, req *nodepb.ReadNodeRe
Dnsoff: !servercfg.IsDNSMode(), Dnsoff: !servercfg.IsDNSMode(),
Ispending: node.IsPending, Ispending: node.IsPending,
Isingressgateway: node.IsIngressGateway, Isingressgateway: node.IsIngressGateway,
Ingressgatewayrange: node.IngressGatewayRange,
Publickey: node.PublicKey, Publickey: node.PublicKey,
Listenport: node.ListenPort, Listenport: node.ListenPort,
Keepalive: node.PersistentKeepalive, Keepalive: node.PersistentKeepalive,
@@ -77,7 +78,7 @@ func (s *NodeServiceServer) GetConn(ctx context.Context, data *nodepb.Client) (*
// 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
// Now we have to convert this into a NodeItem type to convert into BSON // Now we have to convert this into a NodeItem type to convert into BSON
clientreq := models.ServerClient{ clientreq := models.IntClient{
// ID: primitive.NilObjectID, // ID: primitive.NilObjectID,
Address: data.GetAddress(), Address: data.GetAddress(),
Address6: data.GetAddress6(), Address6: data.GetAddress6(),
@@ -100,7 +101,7 @@ func (s *NodeServiceServer) GetConn(ctx context.Context, data *nodepb.Client) (*
) )
} }
} }
client, err := RegisterClient(clientreq) client, err := RegisterIntClient(clientreq)
if err != nil { if err != nil {
// return internal gRPC error to be handled later // return internal gRPC error to be handled later

View File

@@ -8,7 +8,7 @@ import (
"net/http" "net/http"
"strings" "strings"
"time" "time"
"log"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/gravitl/netmaker/functions" "github.com/gravitl/netmaker/functions"
"github.com/gravitl/netmaker/models" "github.com/gravitl/netmaker/models"
@@ -244,7 +244,7 @@ func getNetworkNodes(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
var nodes []models.ReturnNode var nodes []models.Node
var params = mux.Vars(r) var params = mux.Vars(r)
nodes, err := GetNetworkNodes(params["network"]) nodes, err := GetNetworkNodes(params["network"])
if err != nil { if err != nil {
@@ -257,34 +257,34 @@ func getNetworkNodes(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(nodes) json.NewEncoder(w).Encode(nodes)
} }
func GetNetworkNodes(network string) ([]models.ReturnNode, error) { func GetNetworkNodes(network string) ([]models.Node, error) {
var nodes []models.ReturnNode var nodes []models.Node
collection := mongoconn.Client.Database("netmaker").Collection("nodes") collection := mongoconn.Client.Database("netmaker").Collection("nodes")
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
filter := bson.M{"network": network} filter := bson.M{"network": network}
//Filtering out the ID field cuz Dillon doesn't like it. May want to filter out other fields in the future //Filtering out the ID field cuz Dillon doesn't like it. May want to filter out other fields in the future
cur, err := collection.Find(ctx, filter, options.Find().SetProjection(bson.M{"_id": 0})) cur, err := collection.Find(ctx, filter, options.Find().SetProjection(bson.M{"_id": 0}))
if err != nil { if err != nil {
return []models.ReturnNode{}, err return []models.Node{}, err
} }
defer cancel() defer cancel()
for cur.Next(context.TODO()) { for cur.Next(context.TODO()) {
//Using a different model for the ReturnNode (other than regular node). //Using a different model for the Node (other than regular node).
//Either we should do this for ALL structs (so Networks and Keys) //Either we should do this for ALL structs (so Networks and Keys)
//OR we should just use the original struct //OR we should just use the original struct
//My preference is to make some new return structs //My preference is to make some new return structs
//TODO: Think about this. Not an immediate concern. Just need to get some consistency eventually //TODO: Think about this. Not an immediate concern. Just need to get some consistency eventually
var node models.ReturnNode var node models.Node
err := cur.Decode(&node) err := cur.Decode(&node)
if err != nil { if err != nil {
return []models.ReturnNode{}, err return []models.Node{}, err
} }
// add item our array of nodes // add item our array of nodes
nodes = append(nodes, node) nodes = append(nodes, node)
} }
//TODO: Another fatal error we should take care of. //TODO: Another fatal error we should take care of.
if err := cur.Err(); err != nil { if err := cur.Err(); err != nil {
return []models.ReturnNode{}, err return []models.Node{}, err
} }
return nodes, nil return nodes, nil
} }
@@ -581,7 +581,7 @@ func CreateEgressGateway(gateway models.EgressGatewayRequest) (models.Node, erro
{"postup", nodechange.PostUp}, {"postup", nodechange.PostUp},
{"postdown", nodechange.PostDown}, {"postdown", nodechange.PostDown},
{"isegressgateway", nodechange.IsEgressGateway}, {"isegressgateway", nodechange.IsEgressGateway},
{"gatewayrange", nodechange.EgressGatewayRange}, {"egressgatewayrange", nodechange.EgressGatewayRange},
{"lastmodified", nodechange.LastModified}, {"lastmodified", nodechange.LastModified},
}}, }},
} }
@@ -687,33 +687,58 @@ func createIngressGateway(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(node) json.NewEncoder(w).Encode(node)
} }
func CreateIngressGateway(network string, macaddress string) (models.Node, error) { func CreateIngressGateway(netid string, macaddress string) (models.Node, error) {
node, err := functions.GetNodeByMacAddress(network, macaddress)
node, err := functions.GetNodeByMacAddress(netid, macaddress)
if err != nil { if err != nil {
return models.Node{}, err return models.Node{}, err
} }
network, err := functions.GetParentNetwork(netid)
if err != nil {
log.Println("Could not find network.")
return models.Node{}, err
}
if node.IsEgressGateway {
errors.New("Node cannot be both Ingress and Egress Gateway in same network.")
return models.Node{}, err
}
node.IngressGatewayRange = network.AddressRange
node.PostUp = "iptables -A FORWARD -i " + node.Interface + " -j ACCEPT; iptables -t nat -A POSTROUTING -o " + node.Interface + " -j MASQUERADE"
node.PostDown = "iptables -D FORWARD -i " + node.Interface + " -j ACCEPT; iptables -t nat -D POSTROUTING -o " + node.Interface + " -j MASQUERADE"
collection := mongoconn.Client.Database("netmaker").Collection("nodes") collection := mongoconn.Client.Database("netmaker").Collection("nodes")
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
// Create filter // Create filter
filter := bson.M{"macaddress": macaddress, "network": network} filter := bson.M{"macaddress": macaddress, "network": netid}
node.SetLastModified()
// prepare update model. // prepare update model.
update := bson.D{ update := bson.D{
{"$set", bson.D{ {"$set", bson.D{
{"postup", node.PostUp},
{"postdown", node.PostDown},
{"isingressgateway", true}, {"isingressgateway", true},
{"lastmodified", time.Now().Unix()}, {"ingressgatewayrange", node.IngressGatewayRange},
{"lastmodified", node.LastModified},
}}, }},
} }
var nodeupdate models.Node var nodeupdate models.Node
err = collection.FindOneAndUpdate(ctx, filter, update).Decode(&nodeupdate) err = collection.FindOneAndUpdate(ctx, filter, update).Decode(&nodeupdate)
defer cancel() defer cancel()
if err != nil { if err != nil {
log.Println("error updating node to gateway")
return models.Node{}, err return models.Node{}, err
} }
//Get updated values to return err = SetNetworkNodesLastModified(netid)
node, err = functions.GetNodeByMacAddress(network, macaddress)
if err != nil { if err != nil {
return models.Node{}, err return node, err
}
//Get updated values to return
node, err = functions.GetNodeByMacAddress(netid, macaddress)
if err != nil {
log.Println("error finding node after update")
return node, err
} }
return node, nil return node, nil
} }

5
go.mod
View File

@@ -6,7 +6,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-playground/validator/v10 v10.5.0 github.com/go-playground/validator/v10 v10.5.0
github.com/golang/protobuf v1.4.3 // indirect github.com/golang/protobuf v1.5.2 // indirect
github.com/gorilla/handlers v1.5.1 github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
@@ -25,6 +25,7 @@ require (
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20200609130330-bd2cb7843e1b golang.zx2c4.com/wireguard/wgctrl v0.0.0-20200609130330-bd2cb7843e1b
google.golang.org/genproto v0.0.0-20210201151548-94839c025ad4 // indirect google.golang.org/genproto v0.0.0-20210201151548-94839c025ad4 // indirect
google.golang.org/grpc v1.35.0 google.golang.org/grpc v1.35.0
google.golang.org/protobuf v1.25.0 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 // indirect
google.golang.org/protobuf v1.26.0
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
) )

9
go.sum
View File

@@ -73,6 +73,9 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
@@ -82,6 +85,7 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
@@ -269,6 +273,8 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.35.0 h1:TwIQcH3es+MojMVojxxfQ3l3OF2KzlRxML2xZq0kRo8= google.golang.org/grpc v1.35.0 h1:TwIQcH3es+MojMVojxxfQ3l3OF2KzlRxML2xZq0kRo8=
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -280,6 +286,9 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View File

@@ -140,6 +140,7 @@ type Node struct {
Allowedips string `protobuf:"bytes,22,opt,name=allowedips,proto3" json:"allowedips,omitempty"` Allowedips string `protobuf:"bytes,22,opt,name=allowedips,proto3" json:"allowedips,omitempty"`
Islocal bool `protobuf:"varint,23,opt,name=islocal,proto3" json:"islocal,omitempty"` Islocal bool `protobuf:"varint,23,opt,name=islocal,proto3" json:"islocal,omitempty"`
Isingressgateway bool `protobuf:"varint,28,opt,name=isingressgateway,proto3" json:"isingressgateway,omitempty"` Isingressgateway bool `protobuf:"varint,28,opt,name=isingressgateway,proto3" json:"isingressgateway,omitempty"`
Ingressgatewayrange string `protobuf:"bytes,29,opt,name=ingressgatewayrange,proto3" json:"ingressgatewayrange,omitempty"`
Isdualstack bool `protobuf:"varint,27,opt,name=isdualstack,proto3" json:"isdualstack,omitempty"` Isdualstack bool `protobuf:"varint,27,opt,name=isdualstack,proto3" json:"isdualstack,omitempty"`
Dnsoff bool `protobuf:"varint,24,opt,name=dnsoff,proto3" json:"dnsoff,omitempty"` Dnsoff bool `protobuf:"varint,24,opt,name=dnsoff,proto3" json:"dnsoff,omitempty"`
Localrange string `protobuf:"bytes,25,opt,name=localrange,proto3" json:"localrange,omitempty"` Localrange string `protobuf:"bytes,25,opt,name=localrange,proto3" json:"localrange,omitempty"`
@@ -348,6 +349,13 @@ func (m *Node) GetIsingressgateway() bool {
return false return false
} }
func (m *Node) GetIngressgatewayrange() string {
if m != nil {
return m.Ingressgatewayrange
}
return ""
}
func (m *Node) GetIsdualstack() bool { func (m *Node) GetIsdualstack() bool {
if m != nil { if m != nil {
return m.Isdualstack return m.Isdualstack
@@ -459,6 +467,7 @@ func (m *CheckInResponse) GetNeeddelete() bool {
type PeersResponse struct { type PeersResponse struct {
Isegressgateway bool `protobuf:"varint,1,opt,name=isegressgateway,proto3" json:"isegressgateway,omitempty"` Isegressgateway bool `protobuf:"varint,1,opt,name=isegressgateway,proto3" json:"isegressgateway,omitempty"`
Egressgatewayrange string `protobuf:"bytes,2,opt,name=egressgatewayrange,proto3" json:"egressgatewayrange,omitempty"` Egressgatewayrange string `protobuf:"bytes,2,opt,name=egressgatewayrange,proto3" json:"egressgatewayrange,omitempty"`
Ingressgatewayrange string `protobuf:"bytes,9,opt,name=ingressgatewayrange,proto3" json:"ingressgatewayrange,omitempty"`
Publickey string `protobuf:"bytes,5,opt,name=publickey,proto3" json:"publickey,omitempty"` Publickey string `protobuf:"bytes,5,opt,name=publickey,proto3" json:"publickey,omitempty"`
Endpoint string `protobuf:"bytes,6,opt,name=endpoint,proto3" json:"endpoint,omitempty"` Endpoint string `protobuf:"bytes,6,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"`
@@ -510,6 +519,13 @@ func (m *PeersResponse) GetEgressgatewayrange() string {
return "" return ""
} }
func (m *PeersResponse) GetIngressgatewayrange() string {
if m != nil {
return m.Ingressgatewayrange
}
return ""
}
func (m *PeersResponse) GetPublickey() string { func (m *PeersResponse) GetPublickey() string {
if m != nil { if m != nil {
return m.Publickey return m.Publickey
@@ -1346,74 +1362,75 @@ func init() {
func init() { proto.RegisterFile("grpc/node.proto", fileDescriptor_d13bd996b67da4ef) } func init() { proto.RegisterFile("grpc/node.proto", fileDescriptor_d13bd996b67da4ef) }
var fileDescriptor_d13bd996b67da4ef = []byte{ var fileDescriptor_d13bd996b67da4ef = []byte{
// 1093 bytes of a gzipped FileDescriptorProto // 1112 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x57, 0x4d, 0x6f, 0x1b, 0x45, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x57, 0x4f, 0x6f, 0x23, 0x35,
0x18, 0x96, 0x9d, 0xd8, 0x71, 0x5f, 0xd7, 0x49, 0x3a, 0x6d, 0xc3, 0x60, 0xaa, 0x2a, 0x5a, 0xa1, 0x14, 0x57, 0xd2, 0xa6, 0x49, 0x5f, 0x9a, 0xb6, 0xeb, 0xee, 0x16, 0x13, 0x96, 0x55, 0x15, 0xa1,
0x2a, 0x45, 0x24, 0x0e, 0x41, 0xaa, 0x90, 0x38, 0x20, 0x91, 0xa2, 0x08, 0x04, 0x15, 0x2c, 0xe2, 0x55, 0x17, 0xd1, 0xa6, 0x14, 0x69, 0x85, 0xc4, 0x01, 0x89, 0x2e, 0xaa, 0x40, 0xb0, 0x82, 0x41,
0xc2, 0x6d, 0xb2, 0xfb, 0x7a, 0x3b, 0xf2, 0x66, 0x66, 0xb3, 0x33, 0xb6, 0x9b, 0x1b, 0x17, 0x7e, 0x5c, 0xb8, 0xb9, 0x33, 0x2f, 0xb3, 0x56, 0xa6, 0xf6, 0x74, 0xec, 0x24, 0xdb, 0x1b, 0x17, 0x6e,
0x14, 0xe2, 0x9f, 0x70, 0xe6, 0x87, 0xa0, 0xf9, 0x58, 0xef, 0xec, 0xc6, 0x4d, 0x52, 0xe5, 0xc6, 0x7c, 0x21, 0xbe, 0x0f, 0x57, 0xbe, 0x03, 0xf2, 0x9f, 0xc9, 0x78, 0xa6, 0xe9, 0x9f, 0x65, 0x6f,
0xcd, 0xf3, 0xcc, 0xfb, 0xf9, 0xbc,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x7f, 0x03, 0x00, 0x00, 0xff, 0xff,
0xf3, 0x46, 0x2a, 0x24, 0xe2, 0x0d, 0x00, 0x00,
} }

View File

@@ -47,6 +47,7 @@ message Node {
string allowedips = 22; string allowedips = 22;
bool islocal = 23; bool islocal = 23;
bool isingressgateway = 28; bool isingressgateway = 28;
string ingressgatewayrange = 29;
bool isdualstack = 27; bool isdualstack = 27;
bool dnsoff = 24; bool dnsoff = 24;
string localrange = 25; string localrange = 25;
@@ -65,6 +66,7 @@ message CheckInResponse {
message PeersResponse { message PeersResponse {
bool isegressgateway = 1; bool isegressgateway = 1;
string egressgatewayrange = 2; string egressgatewayrange = 2;
string ingressgatewayrange = 9;
string publickey = 5; string publickey = 5;
string endpoint = 6; string endpoint = 6;
string address = 3; string address = 3;

View File

@@ -9,6 +9,7 @@ import (
"github.com/gravitl/netmaker/servercfg" "github.com/gravitl/netmaker/servercfg"
"github.com/gravitl/netmaker/serverctl" "github.com/gravitl/netmaker/serverctl"
"github.com/gravitl/netmaker/mongoconn" "github.com/gravitl/netmaker/mongoconn"
"github.com/gravitl/netmaker/functions"
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
@@ -60,6 +61,8 @@ func main() {
} }
if servercfg.IsGRPCWireGuard() { if servercfg.IsGRPCWireGuard() {
exists, err := functions.ServerIntClientExists()
if err == nil && !exists {
err = serverctl.InitServerWireGuard() err = serverctl.InitServerWireGuard()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
@@ -69,6 +72,7 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
} }
}
//NOTE: Removed Check and Logic for DNS Mode //NOTE: Removed Check and Logic for DNS Mode
//Reasoning. DNS Logic is very small on server. Can run with little/no impact. Just sets a tiny config file. //Reasoning. DNS Logic is very small on server. Can run with little/no impact. Just sets a tiny config file.
//Real work is done by CoreDNS //Real work is done by CoreDNS

17
models/intclient.go Normal file
View File

@@ -0,0 +1,17 @@
package models
import (
)
type IntClient struct {
PrivateKey string `json:"privatekey" bson:"privatekey"`
PublicKey string `json:"publickey" bson:"publickey"`
AccessKey string `json:"accesskey" bson:"accesskey"`
Address string `json:"address" bson:"address"`
Address6 string `json:"address6" bson:"address6"`
Network string `json:"network" bson:"network"`
ServerEndpoint string `json:"serverendpoint" bson:"serverendpoint"`
ServerAddress string `json:"serveraddress" bson:"serveraddress"`
ServerPort string `json:"serverport" bson:"serverport"`
ServerKey string `json:"serverkey" bson:"serverkey"`
IsServer string `json:"isserver" bson:"isserver"`
}

View File

@@ -95,8 +95,8 @@ type PeersResponse 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"`
LocalAddress string `json:"localaddress" bson:"localaddress"` LocalAddress string `json:"localaddress" bson:"localaddress"`
IsEgressGateway bool `json:"isgateway" bson:"isgateway"` IsEgressGateway bool `json:"isegressgateway" bson:"isegressgateway"`
EgressGatewayRange string `json:"gatewayrange" bson:"gatewayrange"` EgressGatewayRange string `json:"egressgatewayrange" bson:"egressgatewayrange"`
ListenPort int32 `json:"listenport" bson:"listenport"` ListenPort int32 `json:"listenport" bson:"listenport"`
KeepAlive int32 `json:"persistentkeepalive" bson:"persistentkeepalive"` KeepAlive int32 `json:"persistentkeepalive" bson:"persistentkeepalive"`
} }

View File

@@ -14,7 +14,7 @@ import (
"github.com/gravitl/netmaker/models" "github.com/gravitl/netmaker/models"
) )
type GlobalConfig struct { type GlobalConfig struct {
Client models.ServerClient Client models.IntClient
} }
type ClientConfig struct { type ClientConfig struct {
@@ -222,7 +222,7 @@ func(config *ClientConfig) ReadConfig() {
} }
} }
} }
func ModGlobalConfig(cfg models.ServerClient) error{ func ModGlobalConfig(cfg models.IntClient) error{
var modconfig GlobalConfig var modconfig GlobalConfig
var err error var err error
if FileExists("/etc/netclient/netconfig-global-001") { if FileExists("/etc/netclient/netconfig-global-001") {

View File

@@ -70,6 +70,11 @@ func GetAPIHost() string {
serverhost = config.Config.Server.APIHost serverhost = config.Config.Server.APIHost
} else if os.Getenv("SERVER_HOST") != "" { } else if os.Getenv("SERVER_HOST") != "" {
serverhost = os.Getenv("SERVER_HOST") serverhost = os.Getenv("SERVER_HOST")
} else {
remoteip, _ := GetPublicIP()
if remoteip != "" {
serverhost = remoteip
}
} }
return serverhost return serverhost
} }
@@ -91,6 +96,11 @@ func GetGRPCHost() string {
serverhost = config.Config.Server.GRPCHost serverhost = config.Config.Server.GRPCHost
} else if os.Getenv("SERVER_HOST") != "" { } else if os.Getenv("SERVER_HOST") != "" {
serverhost = os.Getenv("SERVER_HOST") serverhost = os.Getenv("SERVER_HOST")
} else {
remoteip, _ := GetPublicIP()
if remoteip != "" {
serverhost = remoteip
}
} }
return serverhost return serverhost
} }

View File

@@ -40,7 +40,7 @@ func GetGRPCWGInterface() string {
return iface return iface
} }
func GetGRPCWGAddress() string { func GetGRPCWGAddress() string {
address := "fd73:0093:84f3:a13d:0000:0000:0000:0001" address := "10.101.0.1"
if os.Getenv("SERVER_GRPC_WG_ADDRESS") != "" { if os.Getenv("SERVER_GRPC_WG_ADDRESS") != "" {
address = os.Getenv("SERVER_GRPC_WG_ADDRESS") address = os.Getenv("SERVER_GRPC_WG_ADDRESS")
} else if config.Config.WG.GRPCWGAddress != "" { } else if config.Config.WG.GRPCWGAddress != "" {

View File

@@ -61,9 +61,9 @@ func CreateDefaultNetwork() (bool, error) {
} }
func GetServerWGConf() (models.ServerClient, error) { func GetServerWGConf() (models.IntClient, error) {
var server models.ServerClient var server models.IntClient
collection := mongoconn.Client.Database("netmaker").Collection("serverclients") 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)
filter := bson.M{"network": "comms", "isserver": "yes"} filter := bson.M{"network": "comms", "isserver": "yes"}
err := collection.FindOne(ctx, filter, options.FindOne().SetProjection(bson.M{"_id": 0})).Decode(&server) err := collection.FindOne(ctx, filter, options.FindOne().SetProjection(bson.M{"_id": 0})).Decode(&server)

View File

@@ -44,7 +44,7 @@ func InitServerWireGuard() error {
return err return err
} }
} }
address, err := netlink.ParseAddr(wgconfig.GRPCWGAddress + "/32") address, err := netlink.ParseAddr(wgconfig.GRPCWGAddress + "/24")
if err != nil { if err != nil {
return err return err
} }
@@ -63,18 +63,20 @@ func InitServerWireGuard() error {
log.Println("could not bring up wireguard interface") log.Println("could not bring up wireguard interface")
return err return err
} }
var client models.ServerClient var client models.IntClient
client.PrivateKey = servercfg.GetGRPCWGPrivKey() client.PrivateKey = wgconfig.GRPCWGPrivKey
client.PublicKey = servercfg.GetGRPCWGPubKey() client.PublicKey = wgconfig.GRPCWGPubKey
client.ServerEndpoint = servercfg.GetGRPCHost() client.ServerEndpoint = wgconfig.GRPCWGEndpoint
client.Address6 = servercfg.GetGRPCWGAddress() client.ServerAddress = wgconfig.GRPCWGAddress
client.ServerPort = wgconfig.GRPCWGPort
client.Address = wgconfig.GRPCWGAddress
client.IsServer = "yes" client.IsServer = "yes"
client.Network = "comms" client.Network = "comms"
err = RegisterServer(client) err = RegisterServer(client)
return err return err
} }
func RegisterServer(client models.ServerClient) error { func RegisterServer(client models.IntClient) error {
if client.PrivateKey == "" { if client.PrivateKey == "" {
privateKey, err := wgtypes.GeneratePrivateKey() privateKey, err := wgtypes.GeneratePrivateKey()
if err != nil { if err != nil {
@@ -86,16 +88,19 @@ func RegisterServer(client models.ServerClient) error {
} }
if client.Address == "" { if client.Address == "" {
newAddress, err := functions.UniqueAddress6(client.Network) newAddress, err := functions.UniqueAddress(client.Network)
if err != nil { if err != nil {
return err return err
} }
client.Address6 = newAddress if newAddress == "" {
return errors.New("Could not retrieve address")
}
client.Address = newAddress
} }
if client.Network == "" { client.Network = "comms" } if client.Network == "" { client.Network = "comms" }
client.ServerKey = client.PublicKey client.ServerKey = client.PublicKey
collection := mongoconn.Client.Database("netmaker").Collection("serverclients") 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)
@@ -120,7 +125,7 @@ func ReconfigureServerWireGuard() error {
return err return err
} }
peers, err := functions.GetPeersList("comms") peers, err := functions.GetIntPeersList()
if err != nil { if err != nil {
return err return err
} }
@@ -141,7 +146,7 @@ func ReconfigureServerWireGuard() error {
if peer.Address != "" { if peer.Address != "" {
var peeraddr = net.IPNet{ var peeraddr = net.IPNet{
IP: net.ParseIP(peer.Address), IP: net.ParseIP(peer.Address),
Mask: net.CIDRMask(32, 32), Mask: net.CIDRMask(128, 128),
} }
allowedips = append(allowedips, peeraddr) allowedips = append(allowedips, peeraddr)
} }
@@ -154,10 +159,6 @@ func ReconfigureServerWireGuard() error {
} }
peercfg = wgtypes.PeerConfig{ peercfg = wgtypes.PeerConfig{
PublicKey: pubkey, PublicKey: pubkey,
Endpoint: &net.UDPAddr{
IP: net.ParseIP(peer.Endpoint),
Port: int(peer.ListenPort),
},
ReplaceAllowedIPs: true, ReplaceAllowedIPs: true,
AllowedIPs: allowedips, AllowedIPs: allowedips,
} }