profile
viewpoint
dcarns 0xdcarns Gravitl, inc. Asheville, NC https://gravitl.com CTO & Co-Founder at Gravitl, inc.

gravitl/netmaker 2591

Netmaker makes networks with WireGuard. Netmaker automates fast, secure, and distributed virtual networks.

mattkasun/netmaker 0

Netmaker makes networks with WireGuard. Netmaker automates fast, secure, and distributed virtual networks.

push eventgravitl/netmaker

0xdcarns

commit sha 424c801c6c9b762412946994c0b9f8b8ff072f33

server update

view details

push time in 2 hours

create barnchgravitl/netmaker

branch : feature_v0.10.0_server_response

created branch time in 3 hours

push eventgravitl/netmaker

Matthew R Kasun

commit sha 815ce3cf24a77f60b5ee66139f03fe928d4e1211

update compose file and scripts to use mosquitto broker. Includes insecure config file for mosquitto

view details

Matthew R Kasun

commit sha 533965b77b79851e637c8754741dc88e8c9c6145

fix typo

view details

Matthew R Kasun

commit sha 07bf9252827220eb3c568b8e002f5979b6bcd073

update mosquitto broker conf and volume info

view details

Matthew R Kasun

commit sha 3e1a85b4b9edbef17f2230b620ee3343b2356c5b

update compose file and scripts to use mosquitto broker. Includes insecure config file for mosquitto

view details

Matthew R Kasun

commit sha e337d877281d46095320995dc1dce3ea135aa70f

fix typo

view details

Matthew R Kasun

commit sha bc974859ad611a284270900df5f4fe0c47ba2eaf

update mosquitto broker conf and volume info

view details

Matthew R Kasun

commit sha dc461c91a80fb90ccb04c904e0d2a419105f411c

Merge branch 'feature-messageQueue' of github.com:mattkasun/netmaker into feature-messageQueue

view details

Matthew R Kasun

commit sha d11bb575be85f55074b71ca4ab3a34b143188c9c

work in progress for message queue

view details

Matthew R Kasun

commit sha 5cd57400ce87a8b84ae42ac50d9c11c7f6f1949a

Replaced ### with - in Node.ID (local copy) to fix mqtt publishing errors added context to all go routines removed connectivity function

view details

Matthew R Kasun

commit sha 7bc99d3076a17f66b0956cf78e012d5309bf1c1c

move context up a level

view details

Matthew R Kasun

commit sha f5aa383541c2892a1a9fdfd86a41982527a5c6a2

go routines now run forever like they are supposed to

view details

0xdcarns

commit sha 5e5d97627d1edab44364e3edbb51d0a155f19801

linting fixes

view details

Matthew R Kasun

commit sha b4deb65cfb041997d7ba2fae3c11122768154bc7

Rebase to develop (#4) * add nameserver in call to CreateUserSpaceConf * fixed user deletion * changed log * go mod tidy and conver azure tenant to env/conf var * added egress relayed addrs to relayed nodes * added post commands for wg quick * refactored ncutils x-platform * log fix * adding egress to relay * fixing egress on relay Co-authored-by: dcarns <75687250+0xdcarns@users.noreply.github.com> Co-authored-by: 0xdcarns <dillon.carns@gmail.com> Co-authored-by: afeiszli <alex.feiszli@gmail.com>

view details

Matthew R Kasun

commit sha d9ff00d4b155f9f0762d2bb4ac7c536cb1e24229

subscribed message handlers implemented

view details

0xdcarns

commit sha 81b75c78bd1cf53db5a7da727a3835c69bddc631

constants

view details

Matthew R Kasun

commit sha 2531af49f24c36ccae090efce7fd55361221b35f

add error handling on failed key generation

view details

Matthew R Kasun

commit sha 55109d869f581749a6b22265971e428ef24a65b6

Merge branch 'feature-messageQueue' into feature-messageQueue

view details

Matthew R Kasun

commit sha 105e83f9872e6c65b70ce405743a8cfde5efc88d

Merge pull request #594 from mattkasun/feature-messageQueue Feature message queue

view details

Matthew R Kasun

commit sha f8a01dfac006f44c5fd6a84bc9177d16cebd51a7

refactor NodeUpdate message queue handler

view details

Matthew R Kasun

commit sha 206c542c7066b54cc8371a8ca3d9ff7830839289

WIP commit

view details

push time in 6 hours

PR merged gravitl/netmaker

Reviewers
Feature message queue enhancement v0.10.0 architecture

closing #621 closing #514

+1037 -246

0 comment

34 changed files

mattkasun

pr closed time in 6 hours

PullRequestReviewEvent

Pull request review commentgravitl/netmaker

Feature message queue

+package functions++import (+	"context"+	"encoding/json"+	"log"+	"os"+	"os/signal"+	"runtime"+	"syscall"+	"time"++	mqtt "github.com/eclipse/paho.mqtt.golang"+	"github.com/gravitl/netmaker/models"+	"github.com/gravitl/netmaker/netclient/config"+	"github.com/gravitl/netmaker/netclient/local"+	"github.com/gravitl/netmaker/netclient/ncutils"+	"github.com/gravitl/netmaker/netclient/wireguard"+	"golang.zx2c4.com/wireguard/wgctrl/wgtypes"+)++// Daemon runs netclient daemon from command line+func Daemon() error {+	ctx, cancel := context.WithCancel(context.Background())+	networks, err := ncutils.GetSystemNetworks()+	if err != nil {+		cancel()+		return err+	}+	for _, network := range networks {+		go MessageQueue(ctx, network)+	}+	quit := make(chan os.Signal, 1)+	signal.Notify(quit, syscall.SIGTERM, os.Interrupt)+	<-quit+	cancel()+	ncutils.Log("all done")+	return nil+}++// SetupMQTT creates a connection to broker and return client+func SetupMQTT(cfg *config.ClientConfig) mqtt.Client {+	opts := mqtt.NewClientOptions()+	ncutils.Log("setting broker to " + cfg.Server.CoreDNSAddr + ":1883")+	opts.AddBroker(cfg.Server.CoreDNSAddr + ":1883")+	opts.SetDefaultPublishHandler(All)+	client := mqtt.NewClient(opts)+	if token := client.Connect(); token.Wait() && token.Error() != nil {+		log.Fatal(token.Error())+	}+	return client+}++// MessageQueue sets up Message Queue and subsribes/publishes updates to/from server+func MessageQueue(ctx context.Context, network string) {+	ncutils.Log("netclient go routine started for " + network)+	var cfg config.ClientConfig+	cfg.Network = network+	cfg.ReadConfig()+	ncutils.Log("daemon started for network:" + network)+	client := SetupMQTT(&cfg)+	if cfg.DebugOn {+		if token := client.Subscribe("#", 0, nil); token.Wait() && token.Error() != nil {+			log.Fatal(token.Error())+		}+		ncutils.Log("subscribed to all topics for debugging purposes")+	}+	if token := client.Subscribe("update/"+cfg.Node.ID, 0, NodeUpdate); token.Wait() && token.Error() != nil {+		log.Fatal(token.Error())+	}+	if cfg.DebugOn {+		ncutils.Log("subscribed to node updates for node " + cfg.Node.Name + " update/" + cfg.Node.ID)+	}+	if token := client.Subscribe("update/peers/"+cfg.Node.ID, 0, UpdatePeers); token.Wait() && token.Error() != nil {+		log.Fatal(token.Error())+	}+	if cfg.DebugOn {+		ncutils.Log("subscribed to node updates for node " + cfg.Node.Name + " update/peers/" + cfg.Node.ID)+	}+	defer client.Disconnect(250)+	go Checkin(ctx, &cfg, network)+	<-ctx.Done()+	ncutils.Log("shutting down daemon")+}++// All -- mqtt message hander for all ('#') topics+var All mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {+	ncutils.Log("default message handler -- received message but not handling")+	ncutils.Log("Topic: " + string(msg.Topic()))+	//ncutils.Log("Message: " + string(msg.Payload()))+}++// NodeUpdate -- mqtt message handler for /update/<NodeID> topic+var NodeUpdate mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {+	ncutils.Log("received message to update node " + string(msg.Payload()))+	//potentiall blocking i/o so do this in a go routine+	go func() {+		var newNode models.Node+		var cfg config.ClientConfig+		err := json.Unmarshal(msg.Payload(), &newNode)+		if err != nil {+			ncutils.Log("error unmarshalling node update data" + err.Error())+			return+		}+		cfg.Network = newNode.Network+		cfg.ReadConfig()+		//check if interface name has changed if so delete.+		if cfg.Node.Interface != newNode.Interface {+			if err = wireguard.RemoveConf(cfg.Node.Interface, true); err != nil {+				ncutils.PrintLog("could not delete old interface "+cfg.Node.Interface+": "+err.Error(), 1)+			}+		}+		newNode.PullChanges = "no"+		//ensure that OS never changes+		newNode.OS = runtime.GOOS+		cfg.Node = newNode+		switch newNode.Action {+		case models.NODE_DELETE:+			if err := RemoveLocalInstance(&cfg, cfg.Network); err != nil {+				ncutils.PrintLog("error deleting local instance: "+err.Error(), 1)+				return+			}+			if token := client.Unsubscribe("update/"+newNode.ID, "update/peers/"+newNode.ID); token.Wait() && token.Error() != nil {+				ncutils.PrintLog("error unsubscribing during node deletion", 1)+			}+			return+		case models.NODE_UPDATE_KEY:+			if err := UpdateKeys(&cfg, client); err != nil {+				ncutils.PrintLog("err updating wireguard keys: "+err.Error(), 1)+			}+		case models.NODE_NOOP:+		default:+		}+		//Save new config+		if err := config.Write(&cfg, cfg.Network); err != nil {+			ncutils.PrintLog("error updating node configuration: "+err.Error(), 1)+		}+		nameserver := cfg.Server.CoreDNSAddr+		privateKey, err := wireguard.RetrievePrivKey(newNode.Network)+		if err != nil {+			ncutils.Log("error reading PrivateKey " + err.Error())+			return+		}+		file := ncutils.GetNetclientPathSpecific() + cfg.Node.Interface + ".conf"+		if err := wireguard.UpdateWgInterface(file, privateKey, nameserver, newNode); err != nil {+			ncutils.Log("error updating wireguard config " + err.Error())+			return+		}+		ncutils.Log("applyWGQuickConf to " + file)+		err = wireguard.ApplyWGQuickConf(file)+		if err != nil {+			ncutils.Log("error restarting wg after node update " + err.Error())+			return+		}+		//deal with DNS+		if newNode.DNSOn == "yes" {+			ncutils.Log("setting up DNS")+			if err = local.UpdateDNS(cfg.Node.Interface, cfg.Network, cfg.Server.CoreDNSAddr); err != nil {+				ncutils.Log("error applying dns" + err.Error())+			}+		} else {+			ncutils.Log("settng DNS off")+			_, err := ncutils.RunCmd("/usr/bin/resolvectl revert "+cfg.Node.Interface, true)+			if err != nil {+				ncutils.Log("error applying dns" + err.Error())+			}+		}+	}()+}++// UpdatePeers -- mqtt message handler for /update/peers/<NodeID> topic+var UpdatePeers mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {

I think almost all of these Update.. funcs can be private

mattkasun

comment created time in 10 hours

Pull request review commentgravitl/netmaker

Feature message queue

 WantedBy=timers.target 			return err 		} 	}--	if !ncutils.FileExists("/etc/systemd/system/netclient.timer") {-		err = os.WriteFile("/etc/systemd/system/netclient.timer", timerbytes, 0644)-		if err != nil {-			log.Println(err)-			return err-		}-	}- 	_, _ = ncutils.RunCmd("systemctl enable netclient.service", true) 	_, _ = ncutils.RunCmd("systemctl daemon-reload", true)-	_, _ = ncutils.RunCmd("systemctl enable netclient.timer", true)-	_, _ = ncutils.RunCmd("systemctl start netclient.timer", true)+	_, _ = ncutils.RunCmd("systemctl start netclient.server", true)

I think this should be netclient.service?

mattkasun

comment created time in 10 hours

PullRequestReviewEvent

Pull request review commentgravitl/netmaker

Feature message queue

 func SetupSystemDDaemon(interval string) error { 		log.Println("couldnt find or create /etc/netclient") 		return err 	}--	if !ncutils.FileExists("/usr/local/bin/netclient") {-		os.Symlink("/etc/netclient/netclient", "/usr/local/bin/netclient")-	}-	if !ncutils.FileExists("/etc/netclient/netclient") {-		err = ncutils.Copy(binarypath, "/etc/netclient/netclient")+	//install binary+	//should check if the existing binary is the corect version -- for now only copy if file doesn't exist+	if !ncutils.FileExists("/usr/sbin/netclient") {

"/usr/sbin/" should probably be a constant

mattkasun

comment created time in 10 hours

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentgravitl/netmaker

Feature message queue

+package mq++import (+	"encoding/json"+	"errors"+	"log"+	"strings"++	mqtt "github.com/eclipse/paho.mqtt.golang"+	"github.com/gravitl/netmaker/database"+	"github.com/gravitl/netmaker/logger"+	"github.com/gravitl/netmaker/logic"+	"github.com/gravitl/netmaker/models"+	"github.com/gravitl/netmaker/servercfg"+)++// default message handler - only called in GetDebug == true

malformed comment

mattkasun

comment created time in 12 hours

Pull request review commentgravitl/netmaker

Feature message queue

+package models++import "golang.zx2c4.com/wireguard/wgctrl/wgtypes"++type PeerUpdate struct {

comments required for public types, funcs and variables

mattkasun

comment created time in 12 hours

PullRequestReviewEvent

Pull request review commentgravitl/netmaker

Feature message queue

+package logic++import (+	"log"+	"net"+	"strconv"+	"strings"+	"time"++	"github.com/gravitl/netmaker/models"+	"github.com/gravitl/netmaker/netclient/ncutils"+	"golang.zx2c4.com/wireguard/wgctrl/wgtypes"+)++func GetPeerUpdate(node *models.Node) (models.PeerUpdate, error) {

Add comment for public function

mattkasun

comment created time in 12 hours

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentgravitl/netmaker

Feature message queue

 func deleteNode(w http.ResponseWriter, r *http.Request) { 		returnErrorResponse(w, r, formatError(err, "internal")) 		return 	}-+	node.Action = models.NODE_DELETE+	go func() {+		if err := mq.NodeUpdate(&node); err != nil {+			logger.Log(1, "error publishing node delete "+err.Error())

no need to concatenate strings, just do "error publishing node delete", err.Error(). The logger will join with spaces.

mattkasun

comment created time in 12 hours

Pull request review commentgravitl/netmaker

Feature message queue

 func uncordonNode(w http.ResponseWriter, r *http.Request) { 	if err = runServerPeerUpdate(node.Network, false); err != nil { 		logger.Log(1, "internal error when approving node:", nodeid) 	}+	go func() {+		if err := mq.NodeUpdate(&node); err != nil {+			logger.Log(1, "error publishing node update"+err.Error())+		}+		if err := mq.UpdatePeers(&node); err != nil {+			logger.Log(1, "error publishing peer update "+err.Error())+			return

empty return?

mattkasun

comment created time in 12 hours

PullRequestReviewEvent

push eventgravitl/netmaker

0xdcarns

commit sha 0874ad1cd824bcad3b9b180f7117336f6da3793a

updated to log errors

view details

push time in 12 hours

PR opened gravitl/netmaker

added timer hooks
+83 -112

0 comment

9 changed files

pr created time in 14 hours

create barnchgravitl/netmaker

branch : feature_v0.10.0_dumps

created branch time in 14 hours

push eventgravitl/netmaker

Matthew R Kasun

commit sha d44df2c1c71db55fc8c34c32d6d48df7745ff416

workflow fix to tag with latest

view details

Matthew R Kasun

commit sha 1a8b1513c06420aa78f375474e69d002bed1eae9

Merge branch 'master' of github.com:gravitl/netmaker

view details

Matthew R Kasun

commit sha a3678f36f3c9e3b86b032a0faec746d1a61fa232

Merge branch 'master' of github.com:gravitl/netmaker

view details

Matthew R Kasun

commit sha 4b65bb5f67d027ee2988b76cc0adb510cf0f35ac

Merge branch 'master' of github.com:gravitl/netmaker

view details

Matthew R Kasun

commit sha 43b680d59b360b2eda85e39c2ff3ca5898b9f7a7

add netmaker binary to release

view details

Matthew R Kasun

commit sha 26058ea39563b113b30ba2d21e984bd39b69f9c0

netmaker added to release

view details

Matthew R Kasun

commit sha d9200713056c726cb04d09be77122d756152c0bd

update test workflow to include step to build netmaker(linux) and netclient(linux/freebsd/darwin/windows)

view details

Matthew R Kasun

commit sha 8ef30fb0e474184bf7b9e32892e03f58311b5aee

new worflow to publish amd64/arm64 netclient docker images

view details

dcarns

commit sha b0db450a79a385e78d7661fb9c745e2c6f9a7f03

Merge pull request #633 from gravitl/update_workflow Update workflow to add netmaker binary to release assets

view details

push time in a day

PR merged gravitl/netmaker

Update workflow to add netmaker binary to release assets
  • adds netmaker binary to release assets
  • added build check to test workflow to ensure netclient builds on supported OSes. (linux, freebsd, darwin, and windows)
  • new workflow to publish amd64/arm64 netclient docker images
+146 -0

0 comment

4 changed files

mattkasun

pr closed time in a day

push eventgravitl/netmaker

0xdcarns

commit sha 0e83ba932c2382245f3c1150d1fa7c37116dab7c

bug fixed

view details

dcarns

commit sha 59b851a8aca57fecd156b6e242274cb94740c5f3

Merge pull request #642 from gravitl/bugfix_v0.10.0_relay_log bug fixed

view details

push time in a day

PR merged gravitl/netmaker

bug fixed
  • Changed wrong log
+1 -1

0 comment

1 changed file

0xdcarns

pr closed time in a day

PR opened gravitl/netmaker

bug fixed
  • Changed wrong log
+1 -1

0 comment

1 changed file

pr created time in a day

create barnchgravitl/netmaker

branch : bugfix_v0.10.0_relay_log

created branch time in a day

push eventgravitl/netmaker-ui

0xdcarns

commit sha 640bd5dffcb0300054c5c781573b11ce907d0966

good first commit

view details

0xdcarns

commit sha 24d8f8fed7110091411594e7b9f7d7f8f5e0a788

better second commit

view details

0xdcarns

commit sha 330438ac593d0547cfd78e5d7f0fa5dc2710b136

fixed breadcrumb

view details

dcarns

commit sha a377c5bbed566ec9d93ac133b7ab0ba391534b59

Merge pull request #66 from gravitl/feature_v0.10.0_remember_rows Feature v0.10.0 remember rows

view details

push time in 2 days

more