changed wirecat --> netmaker. Changed defaults to be more sensible

This commit is contained in:
afeiszli
2021-04-01 14:50:18 -04:00
parent 38c07f6c68
commit aeb13da21b
13 changed files with 52 additions and 54 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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}

View File

@@ -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"

View File

@@ -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

View File

@@ -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!!!

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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.")
}

View File

@@ -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