-
Notifications
You must be signed in to change notification settings - Fork 1
Examples #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Examples #5
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,241 @@ | ||||||||||||||||||||||
| # Configuration Guide | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| `wstunnel-go` supports CLI flags and YAML config files. This guide focuses on the YAML format used by `--config`. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## File structure | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Configuration files use a top-level wrapper with `mode`, plus either a `client` or `server` section: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```yaml | ||||||||||||||||||||||
| mode: client | ||||||||||||||||||||||
| log_lvl: INFO | ||||||||||||||||||||||
| no_color: false | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| client: | ||||||||||||||||||||||
| remote_addr: wss://tunnel.example.com | ||||||||||||||||||||||
| local_to_remote: | ||||||||||||||||||||||
| - "tcp://127.0.0.1:8443:internal.service:443" | ||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Top-level fields: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - `mode`: `client` or `server`. Must match the populated section. | ||||||||||||||||||||||
| - `log_lvl`: `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, or `OFF`. | ||||||||||||||||||||||
| - `no_color`: disables colored log output. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Notes: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Duration values use Go duration syntax such as `10s`, `5m`, or `1h`. | ||||||||||||||||||||||
| - Tunnel definitions in `local_to_remote` and `remote_to_local` use the same syntax as the CLI `-L` and `-R` flags. | ||||||||||||||||||||||
| - The config loader maps directly onto the current Go structs. Unknown keys are ignored by YAML parsing, so typos can silently do nothing. | ||||||||||||||||||||||
| - `mode` is used when invoking the binary with only `--config`. The current runtime does not yet apply `log_lvl` or `no_color` from YAML automatically; use CLI flags for those. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## Client configuration | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Example client config with common options: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```yaml | ||||||||||||||||||||||
| mode: client | ||||||||||||||||||||||
| log_lvl: INFO | ||||||||||||||||||||||
| no_color: false | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| client: | ||||||||||||||||||||||
| remote_addr: wss://tunnel.example.com | ||||||||||||||||||||||
| http_upgrade_path_prefix: v1 | ||||||||||||||||||||||
| mode: rust | ||||||||||||||||||||||
| jwt_secret: "" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| http_headers: | ||||||||||||||||||||||
| X-Env: production | ||||||||||||||||||||||
| X-Cluster: edge-a | ||||||||||||||||||||||
| http_headers_file: /etc/wstunnel-go/client-headers.txt | ||||||||||||||||||||||
| http_upgrade_credentials: "Basic dXNlcjpwYXNzd29yZA==" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| websocket_ping_frequency: 30s | ||||||||||||||||||||||
| websocket_mask_frame: false | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| tls_verify_certificate: true | ||||||||||||||||||||||
| tls_certificate: /etc/wstunnel-go/client.crt | ||||||||||||||||||||||
| tls_private_key: /etc/wstunnel-go/client.key | ||||||||||||||||||||||
| tls_sni_override: tunnel.example.com | ||||||||||||||||||||||
| tls_sni_disable: false | ||||||||||||||||||||||
| tls_ech_enable: false | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| socket_so_mark: 0 | ||||||||||||||||||||||
| connection_min_idle: 2 | ||||||||||||||||||||||
| connection_retry_max_backoff: 5m | ||||||||||||||||||||||
| reverse_tunnel_connection_retry_max_backoff: 1m | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| http_proxy: http://proxy.example.net:3128 | ||||||||||||||||||||||
| http_proxy_login: "" | ||||||||||||||||||||||
| http_proxy_password: "" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| dns_resolver: | ||||||||||||||||||||||
| - dns://1.1.1.1 | ||||||||||||||||||||||
| - dns://8.8.8.8 | ||||||||||||||||||||||
| dns_resolver_prefer_ipv4: false | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| local_to_remote: | ||||||||||||||||||||||
| - "tcp://127.0.0.1:8443:internal.service:443" | ||||||||||||||||||||||
| - "udp://127.0.0.1:1053:1.1.1.1:53?timeout_sec=10" | ||||||||||||||||||||||
| - "socks5://127.0.0.1:1080?login=admin&password=secret" | ||||||||||||||||||||||
| - "http://127.0.0.1:8080?login=proxy&password=secret" | ||||||||||||||||||||||
| - "unix:///tmp/wstunnel.sock:/var/run/docker.sock" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| remote_to_local: | ||||||||||||||||||||||
| - "tcp://0.0.0.0:2222:127.0.0.1:22" | ||||||||||||||||||||||
| - "unix://wstunnel.sock:/var/run/app.sock" | ||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ### Client options | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - `remote_addr`: server URL. Use `ws://` / `wss://` for websocket transport and `http://` / `https://` for HTTP/2. | ||||||||||||||||||||||
| - `http_upgrade_path_prefix`: path prefix used for websocket upgrade / HTTP tunnel endpoints. Default is usually `v1`. | ||||||||||||||||||||||
| - `mode`: transport framing mode. Use `rust` for compatibility with the original Rust implementation, or `ws` for strict RFC 6455 websocket mode. | ||||||||||||||||||||||
| - `jwt_secret`: optional shared secret used to sign client tunnel JWTs. If unset, the client preserves legacy Rust-compatible behavior. | ||||||||||||||||||||||
| - `http_headers`: map of extra request headers added to the server request. | ||||||||||||||||||||||
| - `http_headers_file`: file with `Header: value` lines. If set, values from the file override duplicate keys in `http_headers`. | ||||||||||||||||||||||
| - `http_upgrade_credentials`: raw `Authorization` header value sent to the server. For HTTP Basic auth, provide the full header payload such as `Basic dXNlcjpwYXNzd29yZA==`. | ||||||||||||||||||||||
| - `websocket_ping_frequency`: websocket ping interval. | ||||||||||||||||||||||
| - `websocket_mask_frame`: enable masking on websocket frames. | ||||||||||||||||||||||
|
||||||||||||||||||||||
| - `websocket_mask_frame`: enable masking on websocket frames. | |
| - `websocket_mask_frame`: currently ignored/no-op; kept for forward compatibility and may be used by future versions. |
Copilot
AI
Mar 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tls_sni_disable and tls_ech_enable are described as working options here, but the client TLS config code only applies tls_sni_override and does not reference these fields. Please either implement these behaviors or mark them as currently unsupported/no-op in the YAML guide.
| - `tls_sni_disable`: disable SNI. | |
| - `tls_ech_enable`: enable ECH if supported by the runtime/server path. | |
| - `tls_sni_disable`: currently a no-op; SNI is always enabled. Reserved for future use. | |
| - `tls_ech_enable`: currently a no-op; ECH is not yet implemented in the client TLS stack. |
Copilot
AI
Mar 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http_proxy / http_proxy_login / http_proxy_password and dns_resolver / dns_resolver_prefer_ipv4 are documented as functional, but there’s no code that uses these config fields to affect dialing or name resolution (they’re only parsed into the config struct). Consider marking them as not implemented yet, or add the missing plumbing so these keys actually take effect.
| - `http_proxy`: upstream HTTP proxy URL used to reach the wstunnel server. | |
| - `http_proxy_login`: optional proxy username override. | |
| - `http_proxy_password`: optional proxy password override. | |
| - `dns_resolver`: explicit resolvers to use. | |
| - `dns_resolver_prefer_ipv4`: prefer IPv4 answers when both families are available. | |
| - `http_proxy`: (not yet implemented) reserved for configuring an upstream HTTP proxy URL used to reach the wstunnel server. | |
| - `http_proxy_login`: (not yet implemented) optional proxy username override. | |
| - `http_proxy_password`: (not yet implemented) optional proxy password override. | |
| - `dns_resolver`: (not yet implemented) reserved for configuring explicit DNS resolvers to use. | |
| - `dns_resolver_prefer_ipv4`: (not yet implemented) reserved for preferring IPv4 answers when both families are available. |
Copilot
AI
Mar 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Server websocket_mask_frame is documented as configurable, but server.Config.WebsocketMaskFrame is not referenced anywhere in the server implementation (only defined/parsed). Update the guide to note it’s currently a no-op, or wire it into the websocket handling if it’s intended to be supported.
| - `websocket_mask_frame`: enable websocket frame masking. | |
| - `websocket_mask_frame`: reserved for future use; currently a no-op and does not affect websocket frame masking. |
Copilot
AI
Mar 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the restrictions example, protocol: [reverse_tcp] won’t match what the server actually compares against (it uses getProtoName() which yields ReverseTcp / ReverseUnix / ReverseHttp, etc., and only does case-insensitive matching). Update the docs example to use ReverseTcp/reverseTcp (no underscore) or adjust the implementation to accept reverse_tcp aliases.
Copilot
AI
Mar 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list says http_proxy is a valid !Tunnel protocol, but restriction matching uses getProtoName() which returns Http for HTTP proxy tunnels, so http_proxy will never match (even with EqualFold). The doc should list http (or Http) here to reflect actual accepted values.
| - `!Tunnel` for regular forward tunnels (`tcp`, `udp`, `socks5`, `http_proxy`, `unix`) | |
| - `!Tunnel` for regular forward tunnels (`tcp`, `udp`, `socks5`, `http`, `unix`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README describes
--http-upgrade-credentialsas a rawAuthorizationheader value, but the CLI flag help text still says “Basic auth credentials for upgrade request” (cmd/wstunnel-go/main.go). Please update the CLI help string or adjust the README line so the docs don’t contradict the actual--helpoutput.