Laurence 1cf75b00ff perf: optimize reverse NAT lookup with O(1) map instead of O(n) iteration
Replace O(n) linear search through NAT table with O(1) reverse lookup map
for reply packet NAT translation.

Changes:
- Add reverseConnKey type for reverse NAT lookups
- Add reverseNatTable map to ProxyHandler for O(1) lookups
- Populate both forward and reverse maps when creating NAT entries
- Replace iteration-based reverse lookup with direct map access

Performance:
- O(n) → O(1) complexity for reverse NAT lookups
- Eliminates lock-held iteration on every reply packet
- Removes string comparisons from hot path
- Expected 10-50x improvement for reverse NAT lookups

This addresses Critical #1 from performance analysis where reply path
was walking the entire NAT table to find original mapping.
2025-12-16 08:16:37 +00:00
2025-12-08 14:18:40 -05:00
2025-12-11 16:01:59 -05:00
2025-12-08 12:17:11 -05:00
2025-11-17 13:49:43 -05:00
2025-12-03 20:49:46 -05:00
2025-11-05 21:46:29 -08:00
2025-07-28 12:02:10 -07:00
2025-06-22 12:10:00 -04:00
2025-12-09 17:10:38 -05:00
2025-11-30 19:45:25 -05:00
2025-01-04 21:22:32 -05:00
2025-12-10 16:24:22 -05:00
2025-08-28 17:32:27 +02:00
2025-10-19 15:12:15 -07:00
2025-12-10 14:07:53 -05:00
2025-12-03 20:49:46 -05:00
2025-10-19 15:12:15 -07:00
2025-01-07 20:51:33 -05:00
2025-12-11 17:53:07 -08:00
2025-07-10 17:26:58 -07:00
2025-12-06 21:09:48 -05:00
2025-12-06 21:09:48 -05:00
2025-01-04 21:22:32 -05:00
2025-12-10 15:32:49 -05:00
2025-12-11 12:29:49 -05:00
2025-12-10 16:24:22 -05:00
2025-10-19 15:12:15 -07:00
2025-12-10 15:32:49 -05:00
2025-12-11 12:21:54 -05:00
2025-11-26 17:57:27 -05:00
2025-03-07 12:35:46 -05:00

Newt

PkgGoDev GitHub License Go Report Card

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:

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.

Build

Binary

Make sure to have Go 1.25 installed.

make

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.

Languages
Go 94.8%
Shell 2%
Inno Setup 1.1%
Python 1%
Nix 0.5%
Other 0.6%