Documentation
¶
Overview ¶
internal/pkg/netaddr/master_target.go
Index ¶
- func AgentRelayTarget(raw string) (string, error)
- func AgentRelayURIFromMasterURL(masterURL string) (string, bool)
- func Listen(addr string) (net.Listener, error)
- func MasterHTTPTarget(masterURL, path string) (*http.Client, string, error)
- func Parse(addr string) (network, address string)
- func SelfClient(addr string) (*http.Client, string)
- func UnixHTTPClient(addr string) *http.Client
- func WSDial(ctx context.Context, masterURL string, logger *zap.Logger, ...) (*ws.Client, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AgentRelayTarget ¶ added in v0.0.13
AgentRelayTarget validates and canonicalizes the dedicated relay websocket URI. Path and query are intentionally preserved because deployments may route the tunnel through a non-default ingress path or signed query parameters.
func AgentRelayURIFromMasterURL ¶ added in v0.0.13
AgentRelayURIFromMasterURL derives the dedicated relay endpoint beside the control endpoint while preserving deployment-specific path prefixes and query.
func Listen ¶
Listen 按 Parse 结果监听。文件型 unix 在监听前清理陈旧 socket 文件 (仅当残留文件确实是一个 socket 时才删,避免误删普通文件)。 抽象型 unix(前导 @)与 tcp 直接监听。
func MasterHTTPTarget ¶ added in v0.0.13
MasterHTTPTarget 把 agent 配置的 master_url("http://host:port" | "ws://..." | "unix:/path") 解析成可用的 HTTP client + 完整目标 URL。enrollment 与 usage 上传共用。
func Parse ¶
Parse 把配置字符串解析为 net 包用的 (network, address)。 "unix:/x" → ("unix","/x");"unix:@x" → ("unix","@x");其余 → ("tcp", addr)。
func SelfClient ¶
SelfClient 返回回拨「自己 listen 地址」用的 http.Client 与 base URL。
unix → client 的 DialContext 固定拨该 socket,base = "http://unix" tcp → 普通 client,base = "http://127.0.0.1:<port>"
func UnixHTTPClient ¶
UnixHTTPClient returns an http.Client whose every request is routed to the unix socket named by a "unix:" address (e.g. "unix:/run/gw.sock" or "unix:@name"). Pair it with base URL "http://unix" — the host is ignored.
Types ¶
This section is empty.