Skip to content

Commit 12862f2

Browse files
authored
Merge pull request #105 from gravitl/develop
Latest Develop
2 parents ddbeb88 + e4ed11d commit 12862f2

File tree

5 files changed

+84
-9
lines changed

5 files changed

+84
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ Netmaker's source code and all artifacts in this repository are freely available
7474

7575
#### CONTACT
7676

77-
Email: alex@gravitl.com
77+
Email: info@gravitl.com
7878
Discord: https://discord.gg/zRb9Vfhk8A
7979

docs/USAGE.md

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,72 @@
1-
# Getting Started
1+
# Usage
22

3-
This guide covers the fundamentals of using Netmaker.
3+
This guide covers advanced usage of Netmaker. If you are just looking to get started quickly, check out the Quick Start in the [README](../README.md).
44

5-
## Quick Start
5+
## Index
66

7+
- Config
8+
- Server Config
9+
- Agent Config
10+
- UI Config
11+
- Creating Your Network
12+
- Creating Networks
13+
- Creating Keys
14+
- Creating Nodes
15+
- Managing Your Network
16+
- Cleaning up
17+
- Non-Docker Installation
18+
- Building
19+
- Testing
720

8-
## Non-Docker Setup
21+
## Server Config
22+
Netmaker settings can be set via Environment Variables or Config file. There are also a couple of runtime arguments that can optionally be set.
23+
24+
### Environment Variables
25+
**APP_ENV**: default=dev. Determines which environment file to use. Will look under config/environments/APP_ENV.yaml. For instance, you can have different environments for dev, test, and prod, and store different settinggs accordingly.
26+
**GRPC_PORT**: default=50051. The port for GRPC (node/client) communications
27+
**API_PORT**: default=8081. The port for API and UI communications
28+
**MASTER_KEY**: default=secretkey. The skeleton key used for authenticating with server as administrator.
29+
30+
MongoDB Connection Env Vars:
31+
**MONGO_USER**:default=admin
32+
**MONGO_HOST**:default=password
33+
**MONGO_PASS**:default=localhost
34+
**MONGO_PORTS**:default=27017
35+
**MONGO_OPTS**:default=/?authSource=admin
36+
37+
**BACKEND_URL**: default=nil. The address of the server. Used for setting token values for client/nodes. If not set, will run a command to retrieve the server URL.
38+
39+
### Config File
40+
Stored as config/environments/*.yaml. Default used is dev.yaml
41+
42+
**server**:
43+
- **host:** "localhost" (reachable address of this server, overriden by BACKEND_URL)
44+
- **apiport:** "8081" (api port, overriden by API_PORT)
45+
- **grpcport**: "50051" (grpc port, overridden by GRPC_PORT)
46+
- **masterkey**: "secretkey" (administrator server API key, overridden by MASTER_KEY)
47+
- **allowedorigin**: "*" (CORS policy for requests)
48+
- **restbackend**: true (Runs the REST server)
49+
- **agentbackend**: true (Runs the GRPC server)
50+
- **defaultnetname**: "default" (name for the default network)
51+
- **defaultnetrange**: "10.10.10.0/24" (range for the default network)
52+
- **createdefault**: true (Flag for creating the default network)
53+
54+
**mongoconn**: (see ENV values above for explanation. ENV values override.)
55+
- **user**: "mongoadmin"
56+
- **pass**: "mongopass"
57+
- **host**: "localhost"
58+
- **port**: "27017"
59+
- **opts**: '/?authSource=admin'
60+
61+
### Runtime Args
62+
63+
**clientmode**: (default=on) E.x.: `sudo netmaker --clientmode=off` Run the Server as a client (node) as well.
64+
**defaultnet**: (default=on) E.x.: `sudo netmaker --defaultnet=off` Create a default network on startup.
65+
66+
### Running the Backend Components on Different Machines
67+
HTTP, GRPC, MongoDB
68+
69+
### Non-Docker Installation
970

1071
### Server Setup
1172
1. Get yourself a linux server and make sure it has a public IP.
@@ -37,9 +98,25 @@ On each machine you would like to add to the network, do the following:
3798
This will install netclient.service and netclient.timer in systemd, which will run periodically to call the netclient binary, which will check to see if there are any updates that it needs and update WireGuard appropriately.
3899

39100
## BUILDING
101+
**Back End Compilation**
102+
The backend can be compiled by running "go build" from the root of the repository, which will create an executable named "netmaker."
103+
104+
**Client Compilation**
105+
Similarly, "go build" can be run from the netclient directory to produce a netclient executable.
106+
40107
**Protoc command for GRPC Compilation:**
108+
Whenever making changes to grpc/node.proto, you will need to recompile the grpc. This can be achieved by running the following command from the root of the repository.
41109

42110
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative grpc/node.proto
43111

44112
**Build binary:** `go build ./`
45113

114+
115+
## TESTING
116+
117+
**Unit Testing**
118+
When making changes to Netmaker, you may wish to create nodes, networks, or keys for testing. Bash scripts have been created under the "test" directory (*.sh) which run curl commands that generate sample nodes, networks, and keys that can be used for testing purposes.
119+
120+
**Integration Testing**
121+
Similarly, several go scripts have been created under the test directory (*.go) to test out changes to the code base. These will be run automatically when PR's are submitted but can also be run manually using "go test."
122+

functions/jwt.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func CreateUserJWT(username string, isadmin bool) (response string, err error) {
5050
func VerifyUserToken(tokenString string) (username string, isadmin bool, err error) {
5151
claims := &models.UserClaims{}
5252

53-
if tokenString == config.Config.Server.MasterKey {
53+
if tokenString == config.Config.Server.MasterKey || os.Getenv("MASTER_KEY") {
5454
return "masteradministrator", true, nil
5555
}
5656

@@ -70,7 +70,7 @@ func VerifyToken(tokenString string) (macaddress string, network string, err err
7070

7171
//this may be a stupid way of serving up a master key
7272
//TODO: look into a different method. Encryption?
73-
if tokenString == config.Config.Server.MasterKey {
73+
if tokenString == config.Config.Server.MasterKey || os.Getenv("MASTER_KEY") {
7474
return "mastermac", "", nil
7575
}
7676

privatekey

Lines changed: 0 additions & 1 deletion
This file was deleted.

publickey

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)