diff --git a/controllers/authGrpc.go b/controllers/authGrpc.go index 2b5a75d8..9f053c0a 100644 --- a/controllers/authGrpc.go +++ b/controllers/authGrpc.go @@ -121,7 +121,7 @@ func (s *NodeServiceServer) Login(ctx context.Context, req *nodepb.LoginRequest) return nil, err } else { //Search DB for node with Mac Address. Ignore pending nodes (they should not be able to authenticate with API untill approved). - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) var err = collection.FindOne(ctx, bson.M{ "macaddress": macaddress}).Decode(&result) diff --git a/controllers/common.go b/controllers/common.go index 81fdc2a4..689f5cf8 100644 --- a/controllers/common.go +++ b/controllers/common.go @@ -21,7 +21,7 @@ func GetPeersList(groupName string) ([]models.PeersResponse, error) { var peers []models.PeersResponse //Connection mongoDB with mongoconn class - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -178,7 +178,7 @@ func UpdateNode(nodechange models.Node, node models.Node) (models.Node, error) { } //collection := mongoconn.ConnectDB() - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -228,7 +228,7 @@ func DeleteNode(macaddress string, group string) (bool, error) { deleted := false - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") filter := bson.M{"macaddress": macaddress, "group": group} @@ -254,7 +254,7 @@ func GetNode(macaddress string, group string) (models.Node, error) { var node models.Node - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -317,7 +317,7 @@ func CreateNode(node models.Node, groupName string) (models.Node, error) { } // connect db - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -405,7 +405,7 @@ func SetGroupNodesLastModified(groupName string) error { timestamp := time.Now().Unix() - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -441,7 +441,7 @@ func TimestampNode(node models.Node, updatecheckin bool, updatepeers bool, updat node.SetLastPeerUpdate() } - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) diff --git a/controllers/groupHttpController.go b/controllers/groupHttpController.go index df85d3a4..f250a1df 100644 --- a/controllers/groupHttpController.go +++ b/controllers/groupHttpController.go @@ -147,7 +147,7 @@ func getGroupNodeNumber(w http.ResponseWriter, r *http.Request) { //maybe a functions/ folder and then a node.go, group.go, keys.go, misc.go func GetGroupNodeNumber(groupName string) (int, error){ - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -175,7 +175,7 @@ func getGroup(w http.ResponseWriter, r *http.Request) { var group models.Group - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -285,7 +285,7 @@ func updateGroup(w http.ResponseWriter, r *http.Request) { haschange = true } - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -355,7 +355,7 @@ func deleteGroup(w http.ResponseWriter, r *http.Request) { return } - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") filter := bson.M{"nameid": params["groupname"]} @@ -406,7 +406,7 @@ func createGroup(w http.ResponseWriter, r *http.Request) { group.SetGroupLastModified() - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -458,7 +458,7 @@ func createAccessKey(w http.ResponseWriter, r *http.Request) { group.AccessKeys = append(group.AccessKeys, accesskey) - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -497,7 +497,7 @@ func getAccessKeys(w http.ResponseWriter, r *http.Request) { var group models.Group var keys []models.DisplayKey - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -549,7 +549,7 @@ func deleteAccessKey(w http.ResponseWriter, r *http.Request) { } } - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) diff --git a/controllers/nodeHttpController.go b/controllers/nodeHttpController.go index 2abba74b..6be01afa 100644 --- a/controllers/nodeHttpController.go +++ b/controllers/nodeHttpController.go @@ -67,7 +67,7 @@ func authenticate(response http.ResponseWriter, request *http.Request) { } else { //Search DB for node with Mac Address. Ignore pending nodes (they should not be able to authenticate with API untill approved). - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) var err = collection.FindOne(ctx, bson.M{ "macaddress": authRequest.MacAddress, "ispending": false }).Decode(&result) @@ -237,7 +237,7 @@ func getPeerList(w http.ResponseWriter, r *http.Request) { var params = mux.Vars(r) //Connection mongoDB with mongoconn class - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -291,7 +291,7 @@ func getGroupNodes(w http.ResponseWriter, r *http.Request) { var nodes []models.ReturnNode var params = mux.Vars(r) - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -343,7 +343,7 @@ func getAllNodes(w http.ResponseWriter, r *http.Request) { var nodes []models.ReturnNode - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -404,7 +404,7 @@ func checkIn(w http.ResponseWriter, r *http.Request) { //Retrieves node with DB Call which is inefficient. Let's just get the time and set it. //node = functions.GetNodeByMacAddress(params["group"], params["macaddress"]) - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -463,7 +463,7 @@ func getLastModified(w http.ResponseWriter, r *http.Request) { var group models.Group var params = mux.Vars(r) - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -565,7 +565,7 @@ func uncordonNode(w http.ResponseWriter, r *http.Request) { return } - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) diff --git a/controllers/userHttpController.go b/controllers/userHttpController.go index d166baa4..9691eaea 100644 --- a/controllers/userHttpController.go +++ b/controllers/userHttpController.go @@ -60,7 +60,7 @@ func authenticateUser(response http.ResponseWriter, request *http.Request) { } else { //Search DB for node with Mac Address. Ignore pending nodes (they should not be able to authenticate with API untill approved). - collection := mongoconn.Client.Database("wirecat").Collection("users") + collection := mongoconn.Client.Database("netmaker").Collection("users") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) var err = collection.FindOne(ctx, bson.M{ "username": authRequest.UserName }).Decode(&result) @@ -179,7 +179,7 @@ func authorizeUser(next http.Handler) http.HandlerFunc { func HasAdmin() (bool, error){ - collection := mongoconn.Client.Database("wirecat").Collection("users") + collection := mongoconn.Client.Database("netmaker").Collection("users") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -217,7 +217,7 @@ func GetUser(username string) (models.User, error) { var user models.User - collection := mongoconn.Client.Database("wirecat").Collection("users") + collection := mongoconn.Client.Database("netmaker").Collection("users") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -265,7 +265,7 @@ func CreateUser(user models.User) (models.User, error) { } // connect db - collection := mongoconn.Client.Database("wirecat").Collection("users") + collection := mongoconn.Client.Database("netmaker").Collection("users") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) // insert our node to the node db. @@ -336,7 +336,7 @@ func UpdateUser(userchange models.User, user models.User) (models.User, error) { user.Password = userchange.Password } //collection := mongoconn.ConnectDB() - collection := mongoconn.Client.Database("wirecat").Collection("users") + collection := mongoconn.Client.Database("netmaker").Collection("users") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -416,7 +416,7 @@ func DeleteUser(user string) (bool, error) { deleted := false - collection := mongoconn.Client.Database("wirecat").Collection("users") + collection := mongoconn.Client.Database("netmaker").Collection("users") filter := bson.M{"username": user} diff --git a/docs/API.md b/docs/API.md index 097e1d2b..882d520e 100644 --- a/docs/API.md +++ b/docs/API.md @@ -35,7 +35,7 @@ **Authenticate User:** "/users/authenticate", "POST" *note: users API does not use /api/ because of a weird bug. Will fix in future release. -**note: Only able to create Admin at this time. The "user" is only used by the [user interface](https://github.com/falconcat-inc/WireCat-UI) to authenticate the single admin user. +**note: Only able to create Admin at this time. The "user" is only used by the [user interface](https://github.com/gravitl/netmaker-ui) to authenticate the single admin user. ### Files **Get File:** "/meshclient/files/{filename}", "GET" diff --git a/docs/GETTING_STARTED.md b/docs/GETTING_STARTED.md index a7fc98cc..34865b2c 100644 --- a/docs/GETTING_STARTED.md +++ b/docs/GETTING_STARTED.md @@ -2,8 +2,8 @@ ### Server Setup 1. Get yourself a linux server and make sure it has a public IP. 2. Deploy MongoDB `docker volume create mongovol && docker run -d --name mongodb -v mongovol:/data/db --network host -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=mongopass mongo --bind_ip 0.0.0.0 ` - 3. Pull this repo: `git clone https://github.com/falconcat-inc/WireCat.git` - 4. Switch to the directory and source the default env vars `cd WireCat && source defaultvars.sh` + 3. Pull this repo: `git clone https://github.com/gravitl/netmaker.git` + 4. Switch to the directory and source the default env vars `cd netmaker && source defaultvars.sh` 5. Run the server: `go run ./` ### Optional (For Testing): Create Groups and Nodes @@ -13,7 +13,7 @@ 4. Create Nodes: `./test/nodescreate.sh` 5. Check to see if nodes were created: `curl -H "authorization: Bearer secretkey" localhost:8081/api/skynet/nodes | jq` ### UI Setup -Please see [this repo](https://github.com/falconcat-inc/WireCat-UI) for instructions on setting up your UI. +Please see [this repo](https://github.com/gravitl/netmaker-ui) for instructions on setting up your UI. ### Agent Setup diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index a7c54b8d..97e606dd 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -71,7 +71,7 @@ - [ ] "Read Only" mode for nodes (can't update their settings centrally, only read) **Agent:** - - [ ] Do system calls instead of direct comma[this repo](https://github.com/falconcat-inc/WireCat-UI)nds + - [ ] Do system calls instead of direct commands [this repo](https://github.com/gravitl/netmaker-ui) - [ ] Add a prompt for easy setup - [ ] Make it work as a sidecar container!!! diff --git a/functions/helpers.go b/functions/helpers.go index 1cf60fd3..f599a38f 100644 --- a/functions/helpers.go +++ b/functions/helpers.go @@ -29,7 +29,7 @@ func IsFieldUnique(group string, field string, value string) bool { var node models.Node isunique := true - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) filter := bson.M{field: value, "group": group} @@ -51,7 +51,7 @@ func IsFieldUnique(group string, field string, value string) bool { func GroupExists(name string) (bool, error) { - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -78,7 +78,7 @@ func GroupExists(name string) (bool, error) { func UpdateGroupNodeAddresses(groupName string) error { //Connection mongoDB with mongoconn class - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -158,7 +158,7 @@ func IsGroupDisplayNameUnique(name string) bool { func ListGroups() []models.Group{ var groups []models.Group - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -222,7 +222,7 @@ func GetParentGroup(groupname string) (models.Group, error) { var group models.Group - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -275,7 +275,7 @@ func GetNodeObj(id primitive.ObjectID) models.Node { var node models.Node - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) filter := bson.M{"_id": id} @@ -329,7 +329,7 @@ func GetNodeByMacAddress(group string, macaddress string) (models.Node, error) { filter := bson.M{"macaddress": macaddress, "group": group} - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -420,7 +420,7 @@ func IsIPUnique(group string, ip string) bool { isunique := true - collection := mongoconn.Client.Database("wirecat").Collection("nodes") + collection := mongoconn.Client.Database("netmaker").Collection("nodes") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) filter := bson.M{"address": ip, "group": group} @@ -465,7 +465,7 @@ func DecrimentKey(groupName string, keyvalue string) { } } - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -490,7 +490,7 @@ func DeleteKey(group models.Group, i int) { group.AccessKeys = append(group.AccessKeys[:i], group.AccessKeys[i+1:]...) - collection := mongoconn.Client.Database("wirecat").Collection("groups") + collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) diff --git a/models/group.go b/models/group.go index 18827021..f55310da 100644 --- a/models/group.go +++ b/models/group.go @@ -41,10 +41,10 @@ func(group *Group) SetDefaults(){ group.DisplayName = group.NameID } if group.DefaultInterface == "" { - group.DefaultInterface = "wc-" + group.NameID + group.DefaultInterface = "nm-" + group.NameID } if group.DefaultListenPort == 0 { - group.DefaultListenPort = 5555 + group.DefaultListenPort = 51820 } if group.DefaultPreUp == "" { @@ -57,12 +57,10 @@ func(group *Group) SetDefaults(){ group.DefaultKeepalive = 20 } if group.DefaultPostUp == "" { - postup := "sudo wg addconf " + group.DefaultInterface + " /etc/wireguard/peers.conf" - group.DefaultPostUp = postup } //Check-In Interval for Nodes, In Seconds if group.DefaultCheckInInterval == 0 { - group.DefaultCheckInInterval = 120 + group.DefaultCheckInInterval = 30 } if group.AllowManualSignUp == nil { signup := false diff --git a/models/node.go b/models/node.go index 02c9036c..ffb4a79e 100644 --- a/models/node.go +++ b/models/node.go @@ -49,7 +49,7 @@ func(node *Node) GetGroup() (Group, error){ var group Group collection := mongoconn.GroupDB - //collection := mongoconn.Client.Database("wirecat").Collection("groups") + //collection := mongoconn.Client.Database("netmaker").Collection("groups") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) diff --git a/mongoconn/mongoconn.go b/mongoconn/mongoconn.go index 1e951d6a..f8f227bd 100644 --- a/mongoconn/mongoconn.go +++ b/mongoconn/mongoconn.go @@ -93,8 +93,8 @@ func ConnectDatabase() { log.Fatal(err) } - NodeDB = Client.Database("wirecat").Collection("nodes") - GroupDB = Client.Database("wirecat").Collection("groups") + NodeDB = Client.Database("netmaker").Collection("nodes") + GroupDB = Client.Database("netmaker").Collection("groups") log.Println("Database Connected.") } diff --git a/netclient/main.go b/netclient/main.go index 7a17ccbe..c7f30489 100644 --- a/netclient/main.go +++ b/netclient/main.go @@ -15,8 +15,8 @@ import ( const ( // name of the service - name = "wcdaemon" - description = "Wirecat Daemon Service" + name = "netclient" + description = "Netmaker Daemon Service" ) var password string