mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-09 02:30:49 +08:00
changed wirecat --> netmaker. Changed defaults to be more sensible
This commit is contained in:
@@ -121,7 +121,7 @@ func (s *NodeServiceServer) Login(ctx context.Context, req *nodepb.LoginRequest)
|
|||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
//Search DB for node with Mac Address. Ignore pending nodes (they should not be able to authenticate with API untill approved).
|
//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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
var err = collection.FindOne(ctx, bson.M{ "macaddress": macaddress}).Decode(&result)
|
var err = collection.FindOne(ctx, bson.M{ "macaddress": macaddress}).Decode(&result)
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ func GetPeersList(groupName string) ([]models.PeersResponse, error) {
|
|||||||
var peers []models.PeersResponse
|
var peers []models.PeersResponse
|
||||||
|
|
||||||
//Connection mongoDB with mongoconn class
|
//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)
|
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.ConnectDB()
|
||||||
collection := mongoconn.Client.Database("wirecat").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)
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ func DeleteNode(macaddress string, group string) (bool, error) {
|
|||||||
|
|
||||||
deleted := false
|
deleted := false
|
||||||
|
|
||||||
collection := mongoconn.Client.Database("wirecat").Collection("nodes")
|
collection := mongoconn.Client.Database("netmaker").Collection("nodes")
|
||||||
|
|
||||||
filter := bson.M{"macaddress": macaddress, "group": group}
|
filter := bson.M{"macaddress": macaddress, "group": group}
|
||||||
|
|
||||||
@@ -254,7 +254,7 @@ func GetNode(macaddress string, group string) (models.Node, error) {
|
|||||||
|
|
||||||
var node 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)
|
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
|
// 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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ func SetGroupNodesLastModified(groupName string) error {
|
|||||||
|
|
||||||
timestamp := time.Now().Unix()
|
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)
|
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()
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
|
@@ -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
|
//maybe a functions/ folder and then a node.go, group.go, keys.go, misc.go
|
||||||
func GetGroupNodeNumber(groupName string) (int, error){
|
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)
|
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
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
@@ -285,7 +285,7 @@ func updateGroup(w http.ResponseWriter, r *http.Request) {
|
|||||||
haschange = true
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
@@ -355,7 +355,7 @@ func deleteGroup(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
collection := mongoconn.Client.Database("wirecat").Collection("groups")
|
collection := mongoconn.Client.Database("netmaker").Collection("groups")
|
||||||
|
|
||||||
filter := bson.M{"nameid": params["groupname"]}
|
filter := bson.M{"nameid": params["groupname"]}
|
||||||
|
|
||||||
@@ -406,7 +406,7 @@ func createGroup(w http.ResponseWriter, r *http.Request) {
|
|||||||
group.SetGroupLastModified()
|
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)
|
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)
|
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)
|
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 group models.Group
|
||||||
var keys []models.DisplayKey
|
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)
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ func authenticate(response http.ResponseWriter, request *http.Request) {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
//Search DB for node with Mac Address. Ignore pending nodes (they should not be able to authenticate with API untill approved).
|
//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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
var err = collection.FindOne(ctx, bson.M{ "macaddress": authRequest.MacAddress, "ispending": false }).Decode(&result)
|
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)
|
var params = mux.Vars(r)
|
||||||
|
|
||||||
//Connection mongoDB with mongoconn class
|
//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)
|
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 nodes []models.ReturnNode
|
||||||
var params = mux.Vars(r)
|
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)
|
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
|
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)
|
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.
|
//Retrieves node with DB Call which is inefficient. Let's just get the time and set it.
|
||||||
//node = functions.GetNodeByMacAddress(params["group"], params["macaddress"])
|
//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)
|
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 group models.Group
|
||||||
var params = mux.Vars(r)
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
@@ -565,7 +565,7 @@ func uncordonNode(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
collection := mongoconn.Client.Database("wirecat").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)
|
||||||
|
|
||||||
|
@@ -60,7 +60,7 @@ func authenticateUser(response http.ResponseWriter, request *http.Request) {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
//Search DB for node with Mac Address. Ignore pending nodes (they should not be able to authenticate with API untill approved).
|
//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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
var err = collection.FindOne(ctx, bson.M{ "username": authRequest.UserName }).Decode(&result)
|
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){
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ func GetUser(username string) (models.User, error) {
|
|||||||
|
|
||||||
var user models.User
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ func CreateUser(user models.User) (models.User, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// connect db
|
// 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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
// insert our node to the node db.
|
// 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
|
user.Password = userchange.Password
|
||||||
}
|
}
|
||||||
//collection := mongoconn.ConnectDB()
|
//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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
@@ -416,7 +416,7 @@ func DeleteUser(user string) (bool, error) {
|
|||||||
|
|
||||||
deleted := false
|
deleted := false
|
||||||
|
|
||||||
collection := mongoconn.Client.Database("wirecat").Collection("users")
|
collection := mongoconn.Client.Database("netmaker").Collection("users")
|
||||||
|
|
||||||
filter := bson.M{"username": user}
|
filter := bson.M{"username": user}
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
**Authenticate User:** "/users/authenticate", "POST"
|
**Authenticate User:** "/users/authenticate", "POST"
|
||||||
|
|
||||||
*note: users API does not use /api/ because of a weird bug. Will fix in future release.
|
*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
|
### Files
|
||||||
**Get File:** "/meshclient/files/{filename}", "GET"
|
**Get File:** "/meshclient/files/{filename}", "GET"
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
### Server Setup
|
### Server Setup
|
||||||
1. Get yourself a linux server and make sure it has a public IP.
|
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 `
|
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`
|
3. Pull this repo: `git clone https://github.com/gravitl/netmaker.git`
|
||||||
4. Switch to the directory and source the default env vars `cd WireCat && source defaultvars.sh`
|
4. Switch to the directory and source the default env vars `cd netmaker && source defaultvars.sh`
|
||||||
5. Run the server: `go run ./`
|
5. Run the server: `go run ./`
|
||||||
### Optional (For Testing): Create Groups and Nodes
|
### Optional (For Testing): Create Groups and Nodes
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
4. Create Nodes: `./test/nodescreate.sh`
|
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`
|
5. Check to see if nodes were created: `curl -H "authorization: Bearer secretkey" localhost:8081/api/skynet/nodes | jq`
|
||||||
### UI Setup
|
### 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
|
### Agent Setup
|
||||||
|
|
||||||
|
@@ -71,7 +71,7 @@
|
|||||||
- [ ] "Read Only" mode for nodes (can't update their settings centrally, only read)
|
- [ ] "Read Only" mode for nodes (can't update their settings centrally, only read)
|
||||||
|
|
||||||
**Agent:**
|
**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
|
- [ ] Add a prompt for easy setup
|
||||||
- [ ] Make it work as a sidecar container!!!
|
- [ ] Make it work as a sidecar container!!!
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ func IsFieldUnique(group string, field string, value string) bool {
|
|||||||
var node models.Node
|
var node models.Node
|
||||||
isunique := true
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
filter := bson.M{field: value, "group": group}
|
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) {
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ func GroupExists(name string) (bool, error) {
|
|||||||
func UpdateGroupNodeAddresses(groupName string) error {
|
func UpdateGroupNodeAddresses(groupName string) error {
|
||||||
|
|
||||||
//Connection mongoDB with mongoconn class
|
//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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ func IsGroupDisplayNameUnique(name string) bool {
|
|||||||
func ListGroups() []models.Group{
|
func ListGroups() []models.Group{
|
||||||
var groups []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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ func GetParentGroup(groupname string) (models.Group, error) {
|
|||||||
|
|
||||||
var group models.Group
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ func GetNodeObj(id primitive.ObjectID) models.Node {
|
|||||||
|
|
||||||
var node 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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
filter := bson.M{"_id": id}
|
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}
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
@@ -420,7 +420,7 @@ func IsIPUnique(group string, ip string) bool {
|
|||||||
|
|
||||||
isunique := true
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
filter := bson.M{"address": ip, "group": group}
|
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)
|
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 = append(group.AccessKeys[:i],
|
||||||
group.AccessKeys[i+1:]...)
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
|
@@ -41,10 +41,10 @@ func(group *Group) SetDefaults(){
|
|||||||
group.DisplayName = group.NameID
|
group.DisplayName = group.NameID
|
||||||
}
|
}
|
||||||
if group.DefaultInterface == "" {
|
if group.DefaultInterface == "" {
|
||||||
group.DefaultInterface = "wc-" + group.NameID
|
group.DefaultInterface = "nm-" + group.NameID
|
||||||
}
|
}
|
||||||
if group.DefaultListenPort == 0 {
|
if group.DefaultListenPort == 0 {
|
||||||
group.DefaultListenPort = 5555
|
group.DefaultListenPort = 51820
|
||||||
}
|
}
|
||||||
if group.DefaultPreUp == "" {
|
if group.DefaultPreUp == "" {
|
||||||
|
|
||||||
@@ -57,12 +57,10 @@ func(group *Group) SetDefaults(){
|
|||||||
group.DefaultKeepalive = 20
|
group.DefaultKeepalive = 20
|
||||||
}
|
}
|
||||||
if group.DefaultPostUp == "" {
|
if group.DefaultPostUp == "" {
|
||||||
postup := "sudo wg addconf " + group.DefaultInterface + " /etc/wireguard/peers.conf"
|
|
||||||
group.DefaultPostUp = postup
|
|
||||||
}
|
}
|
||||||
//Check-In Interval for Nodes, In Seconds
|
//Check-In Interval for Nodes, In Seconds
|
||||||
if group.DefaultCheckInInterval == 0 {
|
if group.DefaultCheckInInterval == 0 {
|
||||||
group.DefaultCheckInInterval = 120
|
group.DefaultCheckInInterval = 30
|
||||||
}
|
}
|
||||||
if group.AllowManualSignUp == nil {
|
if group.AllowManualSignUp == nil {
|
||||||
signup := false
|
signup := false
|
||||||
|
@@ -49,7 +49,7 @@ func(node *Node) GetGroup() (Group, error){
|
|||||||
var group Group
|
var group Group
|
||||||
|
|
||||||
collection := mongoconn.GroupDB
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
|
@@ -93,8 +93,8 @@ func ConnectDatabase() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeDB = Client.Database("wirecat").Collection("nodes")
|
NodeDB = Client.Database("netmaker").Collection("nodes")
|
||||||
GroupDB = Client.Database("wirecat").Collection("groups")
|
GroupDB = Client.Database("netmaker").Collection("groups")
|
||||||
|
|
||||||
log.Println("Database Connected.")
|
log.Println("Database Connected.")
|
||||||
}
|
}
|
||||||
|
@@ -15,8 +15,8 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// name of the service
|
// name of the service
|
||||||
name = "wcdaemon"
|
name = "netclient"
|
||||||
description = "Wirecat Daemon Service"
|
description = "Netmaker Daemon Service"
|
||||||
)
|
)
|
||||||
|
|
||||||
var password string
|
var password string
|
||||||
|
Reference in New Issue
Block a user