ginuerzh
|
31878a72ec
|
docs(handler/tunnel): add architecture documentation and fix observeStats event loss
- Add package-level architecture doc in handler.go covering:
- NAT traversal reverse proxy architecture
- CmdBind/CmdConnect roles and data flow
- Connector lifecycle and waitClose semantics
- Entrypoint protocol dispatch (first-byte sniffing)
- SD fallback behavior
- Add data-flow-oriented doc comments to all business files:
- entrypoint.go: protocol dispatch, dial flow
- connector.go: Connector/ConnectorPool semantics
- dialer.go: two-phase dial strategy
- tunnel.go: MaxWeight semantics, selection algorithm
- bind.go: 6-step CmdBind flow
- connect.go: CmdConnect flow with relay framing
- ephttp.go, eptls.go, eprelay.go: per-protocol entrypoint flow
- Fix observeStats: after successful error retry, also flush new events
instead of skipping the current tick (handler.go:261-271)
- Add test for observeStats retry-then-flush (handler_test.go)
|
2026-06-02 18:36:52 +08:00 |
|
ginuerzh
|
e791ba47e2
|
refactor(handler/tunnel): split 794-line entrypoint.go into 6 files, fix 3 bugs, add 48 tests
Breaking Change: moves Connector, ConnectorPool, parseTunnelID from
tunnel.go into dedicated connector.go and id.go.
Bug Fixes:
- dialer.go: clear stale retry err so SD fallback is not masked (nil err
from pool.Get() left previous iteration's error live)
- connect.go: check WriteTo errors in both mux and non-mux paths
- eprelay.go: use fresh relay.Response for features sent over mux
(previously reused same resp struct after resp.WriteTo(muxConn))
Refactor:
- entrypoint.go: split ~790 lines into 6 files (ephttp, eptls, eprelay,
epwebsocket, eplistener, entrypointsvc), moved to dedicated package
- handler.go: moved initEntrypoints/createEntrypointService to
entrypointsvc.go
- tunnel.go: moved Connector/ConnectorPool/parseTunnelID to
connector.go and id.go
- connect.go: moved entrypoint-originated handleConnect to eprelay.go
(handler-side handleConnect kept in connect.go)
Tests (48 new, 88 total):
- id_test.go: parseTunnelID variants (empty, UUID, private '$', invalid)
- tunnel_test.go: Tunnel lifecycle (AddConnector, GetConnector
weighted/closed filtering, CloseOnIdle, clean),
Connector (NewConnector nil-opts, GetConn nil/closed session, Close,
IsClosed), ConnectorPool (Add/Get/Close, idle cleanup, concurrency)
- dialer_test.go: SD error paths (sd.Get error, empty address)
- handler_test.go: observeStats (nil observer, cancelled context loop),
initEntrypoints (no entrypoints configured)
- helpers_test.go: testLogger, fakeConn for handler tests
- eprelay_test.go: handleConnect ingress/dial/SD round-trip
|
2026-06-01 22:20:43 +08:00 |
|
ginuerzh
|
1c1f092a14
|
fix metrics wrapper
|
2025-10-11 21:54:16 +08:00 |
|
ginuerzh
|
a69a759e17
|
tunnel: add multiple entrypoints
|
2025-10-09 22:32:03 +08:00 |
|
ginuerzh
|
c7d16962ec
|
add service option for plugin
|
2025-08-29 23:36:31 +08:00 |
|
ginuerzh
|
b597467858
|
add context for conn
|
2025-08-04 19:29:38 +08:00 |
|
ginuerzh
|
afcf4a5252
|
parse real client IP
|
2025-07-15 19:59:10 +08:00 |
|
ginuerzh
|
fc12e33786
|
router handler: add cache for sd service
|
2025-02-09 16:16:44 +08:00 |
|
ginuerzh
|
379d9a73ad
|
service: add limiter.scope option
|
2025-01-20 23:22:58 +08:00 |
|
ginuerzh
|
06d993023f
|
add traffic reset for stats
|
2024-12-24 20:11:22 +08:00 |
|
ginuerzh
|
be8e0555e5
|
handle tls for tunnel entrypoint
|
2024-12-23 21:05:55 +08:00 |
|
ginuerzh
|
79b6b9138e
|
add limiterRefreshInterval option for limiter
|
2024-11-14 20:16:09 +08:00 |
|
ginuerzh
|
a12870e766
|
add compression flag option for http request
|
2024-11-02 20:41:23 +08:00 |
|
ginuerzh
|
f4d9a5f79b
|
tunnel: checking closed connector
|
2024-11-01 15:25:45 +08:00 |
|
ginuerzh
|
6b932e35bf
|
sniffing websocket frame
|
2024-10-19 19:36:06 +08:00 |
|
ginuerzh
|
51ca9f620a
|
add transport for tunnel entrypoint
|
2024-10-15 18:47:36 +08:00 |
|
ginuerzh
|
5bba004324
|
add keepalive option for tunnel entrypoint
|
2024-10-14 23:09:07 +08:00 |
|
ginuerzh
|
69455ace9d
|
add handler recorder
|
2024-09-14 23:21:25 +08:00 |
|
ginuerzh
|
31c482c649
|
add scope param for traffic limiter
|
2024-08-31 09:30:04 +08:00 |
|
ginuerzh
|
ff20711c25
|
add stats support for tunnel handler
|
2024-08-28 13:34:05 +08:00 |
|
ginuerzh
|
1a776dc759
|
fix connection state in tunnel entrypoint
|
2024-08-01 20:52:08 +08:00 |
|
ginuerzh
|
3d2a7b7d3b
|
move x/internal/ctx to x/ctx
|
2024-01-30 18:19:39 +08:00 |
|
ginuerzh
|
3616a0d8a4
|
fix tunnel weight
|
2024-01-28 18:33:54 +08:00 |
|
ginuerzh
|
88cc6ff4d5
|
add traffic limiter for proxy handler
|
2023-11-18 18:28:09 +08:00 |
|
ginuerzh
|
a7166b8206
|
add sd for tunnel
|
2023-10-31 22:59:14 +08:00 |
|
ginuerzh
|
0bef7c0cdf
|
improve tunnel handler
|
2023-10-27 22:11:11 +08:00 |
|
ginuerzh
|
bcc75c5ba4
|
update tunnel handler
|
2023-10-27 08:48:16 +08:00 |
|
ginuerzh
|
28824885ab
|
add entrypoint for tunnel handler
|
2023-10-20 19:12:09 +08:00 |
|
ginuerzh
|
5dfbb59f8a
|
update forward handler
|
2023-10-16 23:16:47 +08:00 |
|
ginuerzh
|
497915f465
|
add tunnel handler and connector
|
2023-10-15 15:39:25 +08:00 |
|