Compare commits

..

13 commits

Author SHA1 Message Date
9e050b140b cli: rename -reconnect-delay to -reconnect-delay-secs
All time arguments now use -secs suffix with integer seconds for
consistency (-reconnect-delay-secs, -keepalive-timeout-secs).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-07-11 11:56:37 -03:00
1a397c363f tunnel: add -keepalive-timeout-secs for dead connection detection
Tracks last server receive time (atomic) and runs a watchdog goroutine
that closes the connection if no data arrives within the timeout,
triggering reconnection. Also fixes Close() to guard Conn.Close()
inside sync.Once so concurrent/repeated calls are safe.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-07-11 11:54:12 -03:00
1d919aafc5 tunnel: fix panic on send to closed writeCh during disconnect
When the server disconnects, Close() was closing both stopCh and
writeCh. The TAP→Server goroutine could race and send to the closed
writeCh, causing a panic. Fix: don't close writeCh in Close(), let
writeLoop exit via stopCh instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-07 21:15:34 +05:30
51824b830e netcfg: add -connmark flag for DNAT reply routing
When VPN traffic is DNAT'd to local namespaces/VMs, reply packets have
a different source IP (namespace veth) so the policy route's
"from <VPN_IP>" rule doesn't match. CONNMARK marks all connections
arriving on the VPN interface and restores the mark on reply packets,
routing them back through the tunnel via fwmark rule.

New flag: -connmark (requires -policy-route-table)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-07 01:06:17 +05:30
857733863c netcfg: suppress RTNETLINK errors from policy route cleanup
Use runQuiet for ip rule/route del commands that may fail harmlessly
when no existing rule exists (e.g. first run after deploy).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-07 00:42:56 +05:30
47e06b525c tunnel: replace write mutex with channel-based single writer
All writes (frames, keepalive, DHCP renewal) are queued to a buffered
channel and drained by a single writer goroutine. Eliminates mutex
contention on the data path entirely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 23:16:27 +05:30
14ec4a02dd tunnel: buffer WriteFrames into single TLS write
Assemble numBlocks + frame sizes + frame data into one buffer before
writing. Reduces TLS records and syscalls from 3 per frame to 1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 23:07:55 +05:30
fc07ac507d dhcp: generate fresh xid per exchange
New random transaction ID for each DHCP exchange (initial and renewal)
to avoid matching stale responses from previous transactions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 22:58:00 +05:30
b3f4c5f42b tunnel: add write mutex for concurrent safety
WriteFrames and keepalive both write multi-part messages to the TLS
connection. Without synchronization, their writes could interleave
and corrupt the framing. Add writeMu to serialize all tunnel writes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 22:53:06 +05:30
6416159164 add DHCP lease renewal at T/2
- Add Renew() to dhcp.Client: sends REQUEST with ciaddr (RENEWING state)
- Start renewal goroutine in session at lease_time/2
- On IP change: flush TAP, reconfigure address/routes/DNS/policy routes
- On renewal failure: retry at T/4 (min 60s)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 22:05:34 +05:30
61237283f5 consolidate docs into README.md, remove docs/
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 17:54:38 +05:30
42f8333783 rename -dhcp flag to -no-dhcp for cleaner UX
DHCP is on by default; use -no-dhcp to disable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 17:53:01 +05:30
8a3ea06c9e add CLAUDE.md with project context and protocol notes
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 17:45:19 +05:30

View file

@ -22,7 +22,7 @@ docker run --rm --cap-add NET_ADMIN --device /dev/net/tun \
alpine:latest sh -c ' alpine:latest sh -c '
apk add --no-cache iproute2 curl > /dev/null 2>&1 apk add --no-cache iproute2 curl > /dev/null 2>&1
softether-go -host 50-117-55-1.ip.fresh.ipb.cloud -port 992 \ softether-go -host 50-117-55-1.ip.fresh.ipb.cloud -port 992 \
-user <username> -pass <password> -plain-password -insecure -tap vpn0 \ -user b83dsu -pass xrXRYmG9 -plain-password -insecure -tap vpn0 \
-accept-default-gateway -accept-dns 2>&1 & -accept-default-gateway -accept-dns 2>&1 &
sleep 12 && curl -s https://ifconfig.me && echo "" sleep 12 && curl -s https://ifconfig.me && echo ""
kill %1; wait' kill %1; wait'
@ -112,10 +112,10 @@ Before connecting, resolves server hostname and adds `/32` route via current def
| Server | Host | Port | User | Pass | Auth | | Server | Host | Port | User | Pass | Auth |
|---|---|---|---|---|---| |---|---|---|---|---|---|
| Staging (US) | 50-117-55-1.ip.fresh.ipb.cloud | 992 | `<service username>` | `<service password>` | plain (RADIUS) | | Staging (US) | 50-117-55-1.ip.fresh.ipb.cloud | 992 | b83dsu | xrXRYmG9 | plain (RADIUS) |
| Production (India) | 65-20-68-5.ip.fresh.ipb.cloud | 992 | `<service username>` | `<service password>` | plain (RADIUS) | | Production (India) | 65-20-68-5.ip.fresh.ipb.cloud | 992 | T0Eq5yf97gXy8Q | (empty) | plain (RADIUS) |
Credentials are not kept in this repo: take the username and password of a test service from WHMCS. The SoftEther server patches in softether-5 concatenate username+password when len==14, so a 14-character key can be given as the username with an empty password. The staging user/pass was split from the original username `b83dsuxrXRYmG9` — the SoftEther server patches in softether-5 concatenate username+password when len==14.
## NixOS integration (pending) ## NixOS integration (pending)
@ -129,7 +129,7 @@ junto host currently uses the SoftEther C client (`modules/apps/softether-client
Equivalent softether-go command: Equivalent softether-go command:
``` ```
softether-go -host 65-20-68-5.ip.fresh.ipb.cloud -port 992 \ softether-go -host 65-20-68-5.ip.fresh.ipb.cloud -port 992 \
-user <username> -plain-password -insecure \ -user T0Eq5yf97gXy8Q -plain-password -insecure \
-tap india-pub-ip -mac 5E:3B:6F:63:A8:3E \ -tap india-pub-ip -mac 5E:3B:6F:63:A8:3E \
-policy-route-table 200 -connmark -policy-route-table 200 -connmark
``` ```