Browse Source

Merge pull request #754 from gravitl/develop

Develop
dcarns 3 years ago
parent
commit
b710802620

+ 3 - 0
.github/workflows/publish-docker.yml

@@ -47,6 +47,7 @@ jobs:
           load: true
           load: true
           platforms: linux/amd64
           platforms: linux/amd64
           tags: ${{ env.TAG }}
           tags: ${{ env.TAG }}
+          build-args: version=${{ env.TAG }}
       -
       -
         name: Test x86
         name: Test x86
         run: |
         run: |
@@ -61,6 +62,7 @@ jobs:
           load: true
           load: true
           platforms: linux/arm64
           platforms: linux/arm64
           tags: ${{ env.TAG }}
           tags: ${{ env.TAG }}
+          build-args: version=${{ env.TAG }}
       -
       -
         name: Test arm
         name: Test arm
         run: |
         run: |
@@ -75,3 +77,4 @@ jobs:
           platforms: linux/amd64, linux/arm64
           platforms: linux/amd64, linux/arm64
           push: true
           push: true
           tags: ${{ github.repository }}:${{ env.TAG }}
           tags: ${{ github.repository }}:${{ env.TAG }}
+          build-args: version=${{ env.TAG }}

+ 5 - 2
.github/workflows/publish-netclient-docker.yml

@@ -46,8 +46,9 @@ jobs:
           context: .
           context: .
           load: true
           load: true
           platforms: linux/amd64
           platforms: linux/amd64
-          file: docker/Dockerfile-netclient-multiarch
+          file: ./docker/Dockerfile-netclient-multiarch
           tags: ${{ env.TAG }}
           tags: ${{ env.TAG }}
+          build-args: version=${{ env.TAG }}  
       -
       -
         name: Test x86
         name: Test x86
         run: |
         run: |
@@ -61,8 +62,9 @@ jobs:
           context: .
           context: .
           load: true
           load: true
           platforms: linux/arm64
           platforms: linux/arm64
-          file: docker/Dockerfile-netclient-multiarch
+          file: ./docker/Dockerfile-netclient-multiarch
           tags: ${{ env.TAG }}
           tags: ${{ env.TAG }}
+          build-args: version=${{ env.TAG }}  
       -
       -
         name: Test arm
         name: Test arm
         run: |
         run: |
@@ -77,3 +79,4 @@ jobs:
           platforms: linux/amd64, linux/arm64
           platforms: linux/amd64, linux/arm64
           push: true
           push: true
           tags: gravitl/netclient:${{ env.TAG }}
           tags: gravitl/netclient:${{ env.TAG }}
+          build-args: version=${{ env.TAG }}  

+ 2 - 3
Dockerfile

@@ -1,13 +1,12 @@
 #first stage - builder
 #first stage - builder
 FROM golang:1.17-alpine as builder
 FROM golang:1.17-alpine as builder
-ARG version
+ARG version 
 RUN apk add build-base
 RUN apk add build-base
 WORKDIR /app
 WORKDIR /app
 COPY . .
 COPY . .
 ENV GO111MODULE=auto
 ENV GO111MODULE=auto
 
 
-# RUN GOOS=linux CGO_ENABLED=1 go build -tags debug -ldflags="-s -X 'main.version=$version'" -o netmaker main.go
-RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$VERSION'" -o netmaker main.go
+RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=${version}'" -o netmaker main.go
 FROM alpine:3.14.3
 FROM alpine:3.14.3
 
 
 # add a c lib
 # add a c lib

+ 12 - 0
SECURITY.md

@@ -0,0 +1,12 @@
+# Security Policy
+
+Netmaker is reliant on secure networking. If you find a vulnerability or bug please report it.
+Depending on complexity or severity, the Gravitl team may compensate (aka. bug bounty) the reporter. 
+However, there is no official bug bounty program up yet for the Netmaker project.
+
+## Supported Versions
+- We currently are only able to support work on the latest version(s)
+
+## Reporting a Vulnerability
+
+Please report security issues to `[email protected]`

+ 29 - 28
netclient/functions/daemon.go

@@ -181,35 +181,8 @@ func MessageQueue(ctx context.Context, network string) {
 	ncutils.Log("netclient go routine started for " + network)
 	ncutils.Log("netclient go routine started for " + network)
 	var cfg config.ClientConfig
 	var cfg config.ClientConfig
 	cfg.Network = network
 	cfg.Network = network
-	/*
-			var configPath = fmt.Sprintf("%snetconfig-%s", ncutils.GetNetclientPathSpecific(), network)
-			fileInfo, err := os.Stat(configPath)
-			if err != nil {
-				ncutils.Log("could not stat config file: " + configPath)
-			}
-			// speed up UDP rest
-				if time.Now().After(fileInfo.ModTime().Add(time.Minute)) {
-					sleepTime := 2
-					ncutils.Log("pulling latest config for " + cfg.Network)
-					for {
-						_, err := Pull(network, true)
-						if err == nil {
-							break
-						} else {
-							ncutils.PrintLog("error pulling config for "+network+": "+err.Error(), 1)
-						}
-						if sleepTime > 3600 {
-							sleepTime = 3600
-						}
-						ncutils.Log("failed to pull for network " + network)
-						ncutils.Log(fmt.Sprintf("waiting %d seconds to retry...", sleepTime))
-						time.Sleep(time.Second * time.Duration(sleepTime))
-						sleepTime = sleepTime * 2
-					}
-				}
+	initialPull(cfg.Network)
 
 
-		time.Sleep(time.Second << 1)
-	*/
 	cfg.ReadConfig()
 	cfg.ReadConfig()
 	ncutils.Log("daemon started for network: " + network)
 	ncutils.Log("daemon started for network: " + network)
 	client := SetupMQTT(&cfg, false)
 	client := SetupMQTT(&cfg, false)
@@ -538,6 +511,34 @@ func Hello(cfg *config.ClientConfig, network string) {
 
 
 // == Private ==
 // == Private ==
 
 
+func initialPull(network string) {
+	ncutils.Log("pulling latest config for " + network)
+	var configPath = fmt.Sprintf("%snetconfig-%s", ncutils.GetNetclientPathSpecific(), network)
+	fileInfo, err := os.Stat(configPath)
+	if err != nil {
+		ncutils.Log("could not stat config file: " + configPath)
+		return
+	}
+	// speed up UDP rest
+	if !fileInfo.ModTime().IsZero() && time.Now().After(fileInfo.ModTime().Add(time.Minute)) {
+		sleepTime := 2
+		for {
+			_, err := Pull(network, true)
+			if err == nil {
+				break
+			}
+			if sleepTime > 3600 {
+				sleepTime = 3600
+			}
+			ncutils.Log("failed to pull for network " + network)
+			ncutils.Log(fmt.Sprintf("waiting %d seconds to retry...", sleepTime))
+			time.Sleep(time.Second * time.Duration(sleepTime))
+			sleepTime = sleepTime * 2
+		}
+		time.Sleep(time.Second << 1)
+	}
+}
+
 func publish(cfg *config.ClientConfig, dest string, msg []byte) error {
 func publish(cfg *config.ClientConfig, dest string, msg []byte) error {
 	// setup the keys
 	// setup the keys
 	trafficPrivKey, err := auth.RetrieveTrafficKey(cfg.Node.Network)
 	trafficPrivKey, err := auth.RetrieveTrafficKey(cfg.Node.Network)