From 395d17768cf354a6fbf7a5229cc3b56caf0eabbd Mon Sep 17 00:00:00 2001 From: afeiszli Date: Mon, 19 Apr 2021 21:25:09 -0400 Subject: [PATCH 1/2] updating readme and docs --- .main.go.swp | Bin 0 -> 16384 bytes README.md | 2 +- config/.config.go.swp | Bin 0 -> 12288 bytes docs/USAGE.md | 85 ++++++++++++++++++++++++++++++++++++++++-- functions/jwt.go | 4 +- privatekey | 1 - publickey | 1 - 7 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 .main.go.swp create mode 100644 config/.config.go.swp delete mode 100644 privatekey delete mode 100644 publickey diff --git a/.main.go.swp b/.main.go.swp new file mode 100644 index 0000000000000000000000000000000000000000..1f73a895c565563f71bef03dd851d643e781b2d0 GIT binary patch literal 16384 zcmeI3TZ|-C8Gs8xVH6ZKF+ON=w$Y&ncdK_XC=O0wc4l|k?C#7sGrMcTWv%W$-Ba1> zs-~)XF0hMegdj2cq)~#27%?HnpeFF(9V9WniGU^=FzA!l7sUsS;P;vAst`Op8KbN;`3n|n_jKBlg9_c{Ds?l^Znc=lr_Yq4{3>2k*l^twDg-``pk zpH5OQ^`mgdqIXJzjc(LP;#MQnY0o>Y<3`W(L$@34ShIRrX`s@;YuCVK&ik+4w^!P^ zqP9!D{cXozdy`cQl?EyeR2rx>P-&pjK&6371C<6U4gB9|Anjl1d>mM1@P>f9p_;<3(K$vu7G#K82sxp z$N4Kf56{9+;Ro;tJP2Qad*D{6!#^)|oaf*-@N0Myz6FoKDy%>k7T`nhhc`LS1MpcG zKnh1-9Nr6;!k^#hI4{71a4)RDEpRg&f^UpD&R5{e@BnPU&2SUUz&QN-632N4o`6ro z-EayH!3^90Q}Awh7ySKV$N4Qh3g3Zm!+kJ-Lof^fcmrdDZ^D=04BQSIunyC316&U- z?15jso_63kEWdUn)x;I8i zDy7ScLzQ-`Q*_tW>B68H_^rbWb^4GA+qNk+h0<#x0HwB*Gb<#e@;Q)h;(n`-;vALz z$q4d?ysu4)CWqP-Ri9dzUtD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$iDQurad z{62_IzbksJ{wfVr8mKf-Y2d%Af$~HjYZJ-HQO)JNti9f0j!1D!_tPk@mpiySJxEvV zQSqE&6ZVYiZC`?;tL?$0GUoeo+Tbut^gG=D@z9Gm&fEQHsdIWCEwD}Jl1Iq{k4y?u z7yXFrrioIDmu0cMxWvp;Nv8pjftdB)WK*Fnw&{qEep^HTJrR7 z)?blI%uAjfiU6}`=SqBPdsn;n=b~ znm>Y-jdUoX7w5a8S$8IgOwc%5ZhIwcJNWYrS~@MpY2+lkUHAL;RK0nCasWL=S}J=f zadAu>rgh*os@B5t%3Brb+^DOK{t^`T_8WwBvnVT}`D$6mLAxCkZy(B%8Ih>yi=bLPT zu6TyU+DzDHzcE?EVw83=TVB}G!B8dv#aSn9Nn+7NH}2sOHK+4rUt8(=Zbif<8PZbe zq>stOQN-k|v)4Q#-7E2X{(wAGK#Ho6z%*tBFbOjoV!9^@b(V<&2}#T{O4#X2;HRs~r^lJggvwF%K=crdem(ht0i?EARPlV+?#*`3qPsv(V(D)o?U8;i!j zNxE+J^;KEd6e}y!+TmGLc%E9ON1J8J)SrLHmnlcGrsa2I+j!{aFA)h*7%8G?N?3Wip){{Z6V!$$xB literal 0 HcmV?d00001 diff --git a/README.md b/README.md index 6a2e7b608..22e58de50 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config/.config.go.swp b/config/.config.go.swp new file mode 100644 index 0000000000000000000000000000000000000000..5bc21c5ff5cbad352a1f6489869c6fc8dd589cfd GIT binary patch literal 12288 zcmeI2L1-jJ6oxBaba!11yLWxti!vk2bT&bhz$jx9SCM2wVgjC$n(69Jlb)`os%El- zt{%O(E?yKbf`TY`5){uW;?;v79=s_YB6?Uo>|w>fs(Z3YCPoNe7HZ(5r|Z3{diB4m zmxNSjYW?{|da`ku;WNot`;6Rtd)uWNfV~6lYuYgzJ#0s2cGt-x+Z1;=71v-Cj?ZhMbj$Q$;fLFjP z;1%!+cm=!yUIDMb-KT&lCfI8T`<^QFmFhWh=vlq`hgZNW;1%!+cm=!yUIDLwSHLUa z74Qmp1-t@xp#nT&Y~x7i<|wGX%=xY9yC zNR`ZcA~$8oHoi#2LQ&k9%cK@q!^vZeFS#%g1=iOtL|%*2OxO|a(?%EfOk=fBX>Q_L zP~F26cY@O4Bf4Q%5L}`}7=&A^SEBBhnI0Qk2s8>q>yzdQ5^|aHPr+`v=p)%LOrhDE2lHA{n16GFoUYHTd2L_}OulF1IwY?(=UCllo|tGb6%Xsb+F z_o}ua5`zGZD03OA1YGLWY|@n7?kIIQw`C2vA`D(?L2G$=V_|7MsI#)dj%vebZ`;GK zg)#PEV`%COZB?@;f-zfufOf0x|0oQi(|gjkin&P!rZ9g_~~Qs#8-153f=E+ z*#x;o*)Ux=QOC}m3+D`_3{NwS_~!ab;Q(W78=lPF7gtaXMN()=H9=-)EzcU+3WwYH W5qdA&Sw|VY6$qJfSs85&&He$PfVV*a literal 0 HcmV?d00001 diff --git a/docs/USAGE.md b/docs/USAGE.md index f29ad1f06..a17704800 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -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." + diff --git a/functions/jwt.go b/functions/jwt.go index c2e880ae7..6570af5d8 100644 --- a/functions/jwt.go +++ b/functions/jwt.go @@ -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 } diff --git a/privatekey b/privatekey deleted file mode 100644 index 1ac528849..000000000 --- a/privatekey +++ /dev/null @@ -1 +0,0 @@ -wMb6dxHPNJqQd8GbwfLN8HPLiJYEl1uJtEls5hRoD10= diff --git a/publickey b/publickey deleted file mode 100644 index 93109eb47..000000000 --- a/publickey +++ /dev/null @@ -1 +0,0 @@ -/FdO9q+Bs3ee/NVbtKwMhSmFj4AyyjmlOrujzaBoenE= From 4f8c0d38ba3d20ca04f9f9fa5dd493493348b213 Mon Sep 17 00:00:00 2001 From: afeiszli Date: Mon, 19 Apr 2021 21:25:48 -0400 Subject: [PATCH 2/2] updating readme and docs --- .main.go.swp | Bin 16384 -> 0 bytes config/.config.go.swp | Bin 12288 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .main.go.swp delete mode 100644 config/.config.go.swp diff --git a/.main.go.swp b/.main.go.swp deleted file mode 100644 index 1f73a895c565563f71bef03dd851d643e781b2d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3TZ|-C8Gs8xVH6ZKF+ON=w$Y&ncdK_XC=O0wc4l|k?C#7sGrMcTWv%W$-Ba1> zs-~)XF0hMegdj2cq)~#27%?HnpeFF(9V9WniGU^=FzA!l7sUsS;P;vAst`Op8KbN;`3n|n_jKBlg9_c{Ds?l^Znc=lr_Yq4{3>2k*l^twDg-``pk zpH5OQ^`mgdqIXJzjc(LP;#MQnY0o>Y<3`W(L$@34ShIRrX`s@;YuCVK&ik+4w^!P^ zqP9!D{cXozdy`cQl?EyeR2rx>P-&pjK&6371C<6U4gB9|Anjl1d>mM1@P>f9p_;<3(K$vu7G#K82sxp z$N4Kf56{9+;Ro;tJP2Qad*D{6!#^)|oaf*-@N0Myz6FoKDy%>k7T`nhhc`LS1MpcG zKnh1-9Nr6;!k^#hI4{71a4)RDEpRg&f^UpD&R5{e@BnPU&2SUUz&QN-632N4o`6ro z-EayH!3^90Q}Awh7ySKV$N4Qh3g3Zm!+kJ-Lof^fcmrdDZ^D=04BQSIunyC316&U- z?15jso_63kEWdUn)x;I8i zDy7ScLzQ-`Q*_tW>B68H_^rbWb^4GA+qNk+h0<#x0HwB*Gb<#e@;Q)h;(n`-;vALz z$q4d?ysu4)CWqP-Ri9dzUtDJ7d7aI@4wVr5vVv{d?3M#MghV2s8O)9)%GL{kG11!O zHGB77v#(Z2*J!Av)WbHSL97BlVGeb?TbWYIPgJ_1Ra8m-oinzNoP^0bk{Xq9Q0Bz zz?T^;FV?#5EK*@yj?)>0Efo(!nY#K~S6!8Cge~`^=ck9_XwcuS{E**<1z5Q_t7=A3 zFo7YlV~n`gfptIi!>$UWHCJ3?jV4$Pe zNQXpKo9EVuBGL$Bo9B5-rSU-XTt*dZ4Akhe75J!5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cJNWYrS~@MpY2+lkUHAL;RK0nCasWL=S}J=f zadAu>rgh*os@B5t%3Brb+^DOK{t^`T_8WwBvnVT}`D$6mLAxCkZy(B%8Ih>yi=bLPT zu6TyU+DzDHzcE?EVw83=TVB}G!B8dv#aSn9Nn+7NH}2sOHK+4rUt8(=Zbif<8PZbe zq>stOQN-k|v)4Q#-7E2X{(wAGK#Ho6z%*tBFbOjoV!9^@b(V<&2}#T{O4#X2;HRs~r^lJggvwF%K=crdem(ht0i?EARPlV+?#*`3qPsv(V(D)o?U8;i!j zNxE+J^;KEd6e}y!+TmGLc%E9ON1J8J)SrLHmnlcGrsa2I+j!{aFA)h*7%8G?N?3Wip){{Z6V!$$xB diff --git a/config/.config.go.swp b/config/.config.go.swp deleted file mode 100644 index 5bc21c5ff5cbad352a1f6489869c6fc8dd589cfd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2L1-jJ6oxBaba!11yLWxti!vk2bT&bhz$jx9SCM2wVgjC$n(69Jlb)`os%El- zt{%O(E?yKbf`TY`5){uW;?;v79=s_YB6?Uo>|w>fs(Z3YCPoNe7HZ(5r|Z3{diB4m zmxNSjYW?{|da`ku;WNot`;6Rtd)uWNfV~6lYuYgzJ#0s2cGt-x+Z1;=71v-Cj?ZhMbj$Q$;fLFjP z;1%!+cm=!yUIDMb-KT&lCfI8T`<^QFmFhWh=vlq`hgZNW;1%!+cm=!yUIDLwSHLUa z74Qmp1-t@xp#nT&Y~x7i<|wGX%=xY9yC zNR`ZcA~$8oHoi#2LQ&k9%cK@q!^vZeFS#%g1=iOtL|%*2OxO|a(?%EfOk=fBX>Q_L zP~F26cY@O4Bf4Q%5L}`}7=&A^SEBBhnI0Qk2s8>q>yzdQ5^|aHPr+`v=p)%LOrhDE2lHA{n16GFoUYHTd2L_}OulF1IwY?(=UCllo|tGb6%Xsb+F z_o}ua5`zGZD03OA1YGLWY|@n7?kIIQw`C2vA`D(?L2G$=V_|7MsI#)dj%vebZ`;GK zg)#PEV`%COZB?@;f-zfufOf0x|0oQi(|gjkin&P!rZ9g_~~Qs#8-153f=E+ z*#x;o*)Ux=QOC}m3+D`_3{NwS_~!ab;Q(W78=lPF7gtaXMN()=H9=-)EzcU+3WwYH W5qdA&Sw|VY6$qJfSs85&&He$PfVV*a