A tunneling client for Pangolin
Find a file
Owen Schwartz 3b166c465d
Merge pull request #29 from firecat53/flake
Flake update for newt 1.1.3
2025-04-07 21:37:53 -04:00
.github Setup qemu 2025-03-04 00:01:37 -05:00
logger Add LOGGER_TIMEZONE env to control the time zone 2025-03-30 10:52:07 -04:00
proxy Fix typo 2025-02-15 17:52:51 -05:00
public/screenshots Add new readme 2025-01-03 21:47:36 -05:00
websocket feat/mtls-support-cert: doc update, removing config.Endpoint loading duplicates, handling null-pointer case and some logging 2025-04-02 21:00:09 +02:00
.dockerignore Add license 2025-01-04 21:22:32 -05:00
.gitignore feat/mtls-support-cert-script 2025-03-31 00:52:48 +02:00
.go-version add arm/v7 to cicd 2025-03-03 21:29:11 -05:00
CONTRIBUTING.md update CONTRIBUTING.md 2025-01-06 22:28:20 -05:00
docker-compose.yml Add all arches and log level 2025-01-13 21:22:17 -05:00
Dockerfile Build riscv64 newt binary and use alpine in docker 2025-02-26 18:52:05 -05:00
entrypoint.sh Allow use of env vars 2025-01-07 20:51:33 -05:00
flake.lock Flake update for newt 1.1.3 2025-04-06 16:40:32 -07:00
flake.nix Flake update for newt 1.1.3 2025-04-06 16:40:32 -07:00
go.mod feat/mtls-support 2025-03-31 00:06:40 +02:00
go.sum feat/mtls-support 2025-03-31 00:06:40 +02:00
LICENSE Add license 2025-01-04 21:22:32 -05:00
main.go Merge pull request #26 from progressive-kiwi/feat-mtls-support 2025-04-02 21:23:17 -04:00
Makefile Merge branch 'main' of github.com:fosrl/newt 2025-03-03 22:34:52 -05:00
README.md Merge pull request #28 from fosrl/dev 2025-04-06 14:09:59 -04:00
SECURITY.md add security policy 2025-01-08 21:36:03 -05:00
self-signed-certs-for-mtls.sh feat/mtls-support-cert-script 2025-03-31 00:52:48 +02:00
updown.py Add updown script capabilities 2025-03-07 12:35:46 -05:00

Newt

Newt is a fully user space WireGuard tunnel client and TCP/UDP proxy, designed to securely expose private resources controlled by Pangolin. By using Newt, you don't need to manage complex WireGuard tunnels and NATing.

Installation and Documentation

Newt is used with Pangolin and Gerbil as part of the larger system. See documentation below:

Preview

Preview

Sample output of a Newt container connected to Pangolin and hosting various resource target proxies.

Key Functions

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.

Receives WireGuard Control Messages

When Newt receives WireGuard control messages, it will use the information encoded (endpoint, public key) to bring up a WireGuard tunnel using netstack fully in user space. It will ping over the tunnel to ensure the peer on the Gerbil side is brought up.

Receives Proxy Control Messages

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

  • endpoint: The endpoint where both Gerbil and Pangolin reside in order to connect to the websocket.

  • id: Newt ID generated by Pangolin to identify the client.

  • secret: A unique secret (not shared and kept private) used to authenticate the client ID with the websocket in order to receive commands.

  • dns: DNS server to use to resolve the endpoint

  • log-level (optional): The log level to use. Default: INFO

  • updown (optional): A script to be called when targets are added or removed.

  • tls-client-cert (optional): Client certificate (p12 or pfx) for mTLS. See mTLS

  • Example:

./newt \
--id 31frd0uzbjvp721 \
--secret h51mmlknrvrwv8s4r1i210azhumt6isgbpyavxodibx1k2d6 \
--endpoint https://example.com

You can also run it with Docker compose. For example, a service in your docker-compose.yml might look like this using environment vars (recommended):

services:
  newt:
    image: fosrl/newt
    container_name: newt
    restart: unless-stopped
    environment:
      - PANGOLIN_ENDPOINT=https://example.com
      - NEWT_ID=2ix2t8xk22ubpfy 
      - NEWT_SECRET=nnisrfsdfc7prqsp9ewo1dvtvci50j5uiqotez00dgap0ii2 

You can also pass the CLI args to the container:

services:
  newt:
    image: fosrl/newt
    container_name: newt
    restart: unless-stopped
    command:
        - --id 31frd0uzbjvp721
        - --secret h51mmlknrvrwv8s4r1i210azhumt6isgbpyavxodibx1k2d6
        - --endpoint https://example.com

Finally a basic systemd service:

[Unit]
Description=Newt VPN Client
After=network.target

[Service]
ExecStart=/usr/local/bin/newt --id 31frd0uzbjvp721 --secret h51mmlknrvrwv8s4r1i210azhumt6isgbpyavxodibx1k2d6 --endpoint https://example.com
Restart=always
User=root

[Install]
WantedBy=multi-user.target

Make sure to mv ./newt /usr/local/bin/newt!

Updown

You can pass in a updown script for Newt to call when it is adding or removing a target:

--updown "python3 test.py"

It will get called with args when a target is added: python3 test.py add tcp localhost:8556 python3 test.py remove tcp localhost:8556

Returning a string from the script in the format of a target (ip:dst so 10.0.0.1:8080) it will override the target and use this value instead to proxy.

You can look at updown.py as a reference script to get started!

mTLS

Newt supports mutual TLS (mTLS) authentication, if the server has been configured to request a client certificate.

  • Only PKCS12 (.p12 or .pfx) file format is accepted
  • The PKCS12 file must contain:
    • Private key
    • Public certificate
    • CA certificate
  • Encrypted PKCS12 files are currently not supported

Examples:

./newt \
--id 31frd0uzbjvp721 \
--secret h51mmlknrvrwv8s4r1i210azhumt6isgbpyavxodibx1k2d6 \
--endpoint https://example.com \
--tls-client-cert ./client.p12
services:
  newt:
    image: fosrl/newt
    container_name: newt
    restart: unless-stopped
    environment:
      - PANGOLIN_ENDPOINT=https://example.com
      - NEWT_ID=2ix2t8xk22ubpfy 
      - NEWT_SECRET=nnisrfsdfc7prqsp9ewo1dvtvci50j5uiqotez00dgap0ii2 
      - TLS_CLIENT_CERT=./client.p12 

Build

Container

Ensure Docker is installed.

make

Binary

Make sure to have Go 1.23.1 installed.

make local

Nix Flake

nix build

Binary will be at ./result/bin/newt

Development shell available with nix develop

Licensing

Newt is dual licensed under the AGPLv3 and the Fossorial Commercial license. For inquiries about commercial licensing, please contact us.

Contributions

Please see CONTRIBUTIONS in the repository for guidelines and best practices.