From 10982b47a5daa80b4529f540e62ebe3bd392fc83 Mon Sep 17 00:00:00 2001 From: Milo Schwartz Date: Thu, 9 Jan 2025 16:44:25 -0500 Subject: [PATCH 1/4] fix typos in readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1bfc666..114fb15 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ _Sample output of a Newt container connected to Pangolin and hosting various res ### Registers with Pangolin -Using the Newt ID and a secret the client will make HTTP requests to Pangolin to receive a session token. Using that token it will connect to a websocket and maintain that connection. Control messages will be sent over the websocket. +Using the Newt ID and a secret, the client will make HTTP requests to Pangolin to receive a session token. Using that token, it will connect to a websocket and maintain that connection. Control messages will be sent over the websocket. ### Receives WireGuard Control Messages @@ -27,7 +27,7 @@ When Newt receives WireGuard control messages, it will use the information encod ### Receives Proxy Control Messages -When Newt receives WireGuard control messages, it will use the information encoded to crate local low level TCP and UDP proxies attached to the virtual tunnel in order to relay traffic to programmed targets. +When Newt receives WireGuard control messages, it will use the information encoded to create a local low level TCP and UDP proxies attached to the virtual tunnel in order to relay traffic to programmed targets. ## CLI Args @@ -98,4 +98,4 @@ Newt is dual licensed under the AGPLv3 and the Fossorial Commercial license. For ## Contributions -Please see [CONTRIBUTIONS](./CONTRIBUTING.md) in the repository for guidelines and best practices. \ No newline at end of file +Please see [CONTRIBUTIONS](./CONTRIBUTING.md) in the repository for guidelines and best practices. From a46fb23cddbdfb6279ea07452f71ee433c8525a4 Mon Sep 17 00:00:00 2001 From: Owen Schwartz Date: Mon, 13 Jan 2025 21:21:59 -0500 Subject: [PATCH 2/4] Add all arches and log level --- Makefile | 11 ++++++++++- docker-compose.yml | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 015c5b8..0f0aa39 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,16 @@ test: docker run fosrl/newt:latest local: - CGO_ENABLED=0 go build -o newt + CGO_ENABLED=0 go build -o newt + +all_arches: + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o newt_linux_arm64 + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o newt_linux_amd64 + CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o newt_darwin_arm64 + CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o newt_darwin_amd64 + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o newt_windows_amd64.exe + CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -o newt_freebsd_amd64 + CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -o newt_freebsd_arm64 clean: rm newt diff --git a/docker-compose.yml b/docker-compose.yml index b67c69a..86f4ca1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,4 +6,5 @@ services: environment: - PANGOLIN_ENDPOINT=https://example.com - NEWT_ID=2ix2t8xk22ubpfy - - NEWT_SECRET=nnisrfsdfc7prqsp9ewo1dvtvci50j5uiqotez00dgap0ii2 \ No newline at end of file + - NEWT_SECRET=nnisrfsdfc7prqsp9ewo1dvtvci50j5uiqotez00dgap0ii2 + - LOG_LEVEL=DEBUG \ No newline at end of file From e90e55d9822842ab0c9e55acccc7e9cba0a6f93d Mon Sep 17 00:00:00 2001 From: Owen Schwartz Date: Mon, 13 Jan 2025 22:51:36 -0500 Subject: [PATCH 3/4] Allow chaning mtu; set default low --- main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 7fe9026..aa9ff74 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "net/netip" "os" "os/signal" + "strconv" "strings" "syscall" "time" @@ -247,6 +248,8 @@ func main() { endpoint string id string secret string + mtu string + mtuInt int dns string privateKey wgtypes.Key err error @@ -257,6 +260,7 @@ func main() { endpoint = os.Getenv("PANGOLIN_ENDPOINT") id = os.Getenv("NEWT_ID") secret = os.Getenv("NEWT_SECRET") + mtu = os.Getenv("MTU") dns = os.Getenv("DNS") logLevel = os.Getenv("LOG_LEVEL") @@ -269,6 +273,9 @@ func main() { if secret == "" { flag.StringVar(&secret, "secret", "", "Newt secret") } + if mtu == "" { + flag.StringVar(&mtu, "mtu", "1280", "MTU to use") + } if dns == "" { flag.StringVar(&dns, "dns", "8.8.8.8", "DNS server to use") } @@ -286,6 +293,12 @@ func main() { logger.Fatal("endpoint, id, and secret are required either via CLI flags or environment variables") } + // parse the mtu string into an int + mtuInt, err = strconv.Atoi(mtu) + if err != nil { + logger.Fatal("Failed to parse MTU: %v", err) + } + privateKey, err = wgtypes.GeneratePrivateKey() if err != nil { logger.Fatal("Failed to generate private key: %v", err) @@ -353,7 +366,7 @@ func main() { tun, tnet, err = netstack.CreateNetTUN( []netip.Addr{netip.MustParseAddr(wgData.TunnelIP)}, []netip.Addr{netip.MustParseAddr(dns)}, - 1420) + mtuInt) if err != nil { logger.Error("Failed to create TUN device: %v", err) } From 7b663027ac5b5463e87ed601470393c643d4431f Mon Sep 17 00:00:00 2001 From: Owen Schwartz Date: Wed, 15 Jan 2025 21:57:14 -0500 Subject: [PATCH 4/4] Add tip --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index aa9ff74..515077c 100644 --- a/main.go +++ b/main.go @@ -124,6 +124,7 @@ func startPingCheck(tnet *netstack.Net, serverIP string, stopChan chan struct{}) err := ping(tnet, serverIP) if err != nil { logger.Warn("Periodic ping failed: %v", err) + logger.Warn("HINT: Do you have UDP port 51280 (or the port in config.yml) open on your Pangolin server?") } case <-stopChan: logger.Info("Stopping ping check") @@ -346,7 +347,8 @@ func main() { err = pingWithRetry(tnet, wgData.ServerIP) if err != nil { // Handle complete failure after all retries - logger.Error("Failed to ping %s: %v", wgData.ServerIP, err) + logger.Warn("Failed to ping %s: %v", wgData.ServerIP, err) + logger.Warn("HINT: Do you have UDP port 51280 (or the port in config.yml) open on your Pangolin server?") } return }