Commit graph

18 commits

Author SHA1 Message Date
94716ac989 client: pin the server certificate by SHA-256, not by file
-server-cert-sha256 <hex> replaces -server-cert <file>: the connection is
accepted only if the SHA-256 of the server's certificate (DER) matches,
colons optional, case-insensitive. No certificate or key file to handle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 15:36:01 -03:00
bb92a9b954 client: -server-cert pins the server certificate
Accept the server only if it presents exactly the given certificate (PEM
or DER file), with no CA or hostname check, like the SoftEther client's
CheckServerCert + ServerCert. Lets a self-signed server certificate that
names no host be verified instead of turning verification off with
-insecure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 15:27:36 -03:00
20f41353e7 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
c248661eaf 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
629e2cce8d 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
42ae25b281 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
1fceb30873 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
47d4b77bf0 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
e84afd7c3e 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
ca050d46f2 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
a62ed3287f 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
bbeeb8c41b tunnel: document TAP goroutine lifecycle on disconnect
The TAP→Server goroutine can't be interrupted (TAP fd doesn't support
deadlines). It exits on next TAP frame when WriteFrames fails on the
closed connection. Document this rather than add complexity.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 17:29:47 +05:30
b2ef8bc1bf tunnel: reduce per-frame allocations in hot path
- TAP→server: write buf[:n] directly instead of copy to new slice
- Keepalive: reuse fixed buffer instead of allocating every 3s

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 17:20:24 +05:30
3feb93e679 client: fix version display and rename client string
- Rename client to "Softether Go Client"
- Fix node info int fields to use LittleEndian32 encoding matching
  the C client's OutRpcNodeInfo (Admin.c:14693)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 17:15:35 +05:30
ed672e7311 client: rename client string to Softether Go Client
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 17:11:32 +05:30
995504d761 netcfg: add verbose logging for TAP configuration
Log each step: address assignment, static routes, default route,
DNS changes, and cleanup flush.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 17:08:28 +05:30
17c1063e1f refactor: extract session/netcfg/tunnel, add mac/dhcp/policy-route flags
- Split cmd/softether-go into main.go (flags, reconnect loop) and
  session.go (session lifecycle, DHCP orchestration)
- Extract network config to pkg/netcfg (TAP config, routing, DNS, policy routes)
- Move frame bridging to pkg/client/tunnel.go as Bridge() method
- Add -mac, -dhcp, -policy-route-table CLI flags
- Add SetMAC() to pkg/tap for deterministic DHCP assignments
- Update all docs to reflect new structure and flags

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 16:43:12 +05:30
829ca73b1b initial commit: standalone SoftEther VPN client in Go
Built-in DHCP (raw Ethernet frames through tunnel), automatic reconnection,
host route management, classless static routes (option 121/249), DNS config.
Single static binary, Linux only.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 16:13:51 +05:30