updating readme and docs

This commit is contained in:
afeiszli 2021-04-19 21:25:09 -04:00
parent a0b8e2591b
commit 395d17768c
7 changed files with 84 additions and 9 deletions

BIN
.main.go.swp Normal file

Binary file not shown.

View file

@ -74,6 +74,6 @@ Netmaker's source code and all artifacts in this repository are freely available
#### CONTACT
Email: alex@gravitl.com
Email: info@gravitl.com
Discord: https://discord.gg/zRb9Vfhk8A

BIN
config/.config.go.swp Normal file

Binary file not shown.

View file

@ -1,11 +1,72 @@
# Getting Started
# Usage
This guide covers the fundamentals of using Netmaker.
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).
## Quick Start
## Index
- Config
- Server Config
- Agent Config
- UI Config
- Creating Your Network
- Creating Networks
- Creating Keys
- Creating Nodes
- Managing Your Network
- Cleaning up
- Non-Docker Installation
- Building
- Testing
## Non-Docker Setup
## Server Config
Netmaker settings can be set via Environment Variables or Config file. There are also a couple of runtime arguments that can optionally be set.
### Environment Variables
**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.
**GRPC_PORT**: default=50051. The port for GRPC (node/client) communications
**API_PORT**: default=8081. The port for API and UI communications
**MASTER_KEY**: default=secretkey. The skeleton key used for authenticating with server as administrator.
MongoDB Connection Env Vars:
**MONGO_USER**:default=admin
**MONGO_HOST**:default=password
**MONGO_PASS**:default=localhost
**MONGO_PORTS**:default=27017
**MONGO_OPTS**:default=/?authSource=admin
**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.
### Config File
Stored as config/environments/*.yaml. Default used is dev.yaml
**server**:
- **host:** "localhost" (reachable address of this server, overriden by BACKEND_URL)
- **apiport:** "8081" (api port, overriden by API_PORT)
- **grpcport**: "50051" (grpc port, overridden by GRPC_PORT)
- **masterkey**: "secretkey" (administrator server API key, overridden by MASTER_KEY)
- **allowedorigin**: "*" (CORS policy for requests)
- **restbackend**: true (Runs the REST server)
- **agentbackend**: true (Runs the GRPC server)
- **defaultnetname**: "default" (name for the default network)
- **defaultnetrange**: "10.10.10.0/24" (range for the default network)
- **createdefault**: true (Flag for creating the default network)
**mongoconn**: (see ENV values above for explanation. ENV values override.)
- **user**: "mongoadmin"
- **pass**: "mongopass"
- **host**: "localhost"
- **port**: "27017"
- **opts**: '/?authSource=admin'
### Runtime Args
**clientmode**: (default=on) E.x.: `sudo netmaker --clientmode=off` Run the Server as a client (node) as well.
**defaultnet**: (default=on) E.x.: `sudo netmaker --defaultnet=off` Create a default network on startup.
### Running the Backend Components on Different Machines
HTTP, GRPC, MongoDB
### Non-Docker Installation
### Server Setup
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:
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.
## BUILDING
**Back End Compilation**
The backend can be compiled by running "go build" from the root of the repository, which will create an executable named "netmaker."
**Client Compilation**
Similarly, "go build" can be run from the netclient directory to produce a netclient executable.
**Protoc command for GRPC Compilation:**
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.
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative grpc/node.proto
**Build binary:** `go build ./`
## TESTING
**Unit Testing**
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.
**Integration Testing**
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."

View file

@ -50,7 +50,7 @@ func CreateUserJWT(username string, isadmin bool) (response string, err error) {
func VerifyUserToken(tokenString string) (username string, isadmin bool, err error) {
claims := &models.UserClaims{}
if tokenString == config.Config.Server.MasterKey {
if tokenString == config.Config.Server.MasterKey || os.Getenv("MASTER_KEY") {
return "masteradministrator", true, nil
}
@ -70,7 +70,7 @@ func VerifyToken(tokenString string) (macaddress string, network string, err err
//this may be a stupid way of serving up a master key
//TODO: look into a different method. Encryption?
if tokenString == config.Config.Server.MasterKey {
if tokenString == config.Config.Server.MasterKey || os.Getenv("MASTER_KEY") {
return "mastermac", "", nil
}

View file

@ -1 +0,0 @@
wMb6dxHPNJqQd8GbwfLN8HPLiJYEl1uJtEls5hRoD10=

View file

@ -1 +0,0 @@
/FdO9q+Bs3ee/NVbtKwMhSmFj4AyyjmlOrujzaBoenE=