netaddr

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(addr string) (net.Listener, error)

Listen 按 Parse 结果监听。文件型 unix 在监听前清理陈旧 socket 文件 (仅当残留文件确实是一个 socket 时才删,避免误删普通文件)。 抽象型 unix(前导 @)与 tcp 直接监听。

func Parse

func Parse(addr string) (network, address string)

Parse 把配置字符串解析为 net 包用的 (network, address)。 "unix:/x" → ("unix","/x");"unix:@x" → ("unix","@x");其余 → ("tcp", addr)。

func SelfClient

func SelfClient(addr string) (*http.Client, string)

SelfClient 返回回拨「自己 listen 地址」用的 http.Client 与 base URL。

unix → client 的 DialContext 固定拨该 socket,base = "http://unix"
tcp  → 普通 client,base = "http://127.0.0.1:<port>"

func UnixHTTPClient

func UnixHTTPClient(addr string) *http.Client

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.

func WSDial

func WSDial(ctx context.Context, masterURL string, logger *zap.Logger, headers ...http.Header) (*ws.Client, error)

WSDial 拨 master 的 ws RPC 端点 /ws/agent。

masterURL 以 unix: 开头 → 占位 ws://unix/ws/agent + NetDialContext 拨该 socket
http(s)/ws(s)          → 转成 ws(s):// 并补 /ws/agent 后用默认 dialer

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL