Documentation
¶
Overview ¶
Package netaddr parses listen and backend addresses and opens or dials them.
Index ¶
- type Endpoint
- func (e *Endpoint) Address() string
- func (e *Endpoint) DialContext(ctx context.Context, _ string, _ string) (net.Conn, error)
- func (e *Endpoint) IsH2C() bool
- func (e *Endpoint) IsLoopback() bool
- func (e *Endpoint) IsUnix() bool
- func (e *Endpoint) Listen(ctx context.Context) (net.Listener, error)
- func (e *Endpoint) Network() string
- func (e *Endpoint) Port() uint16
- func (e *Endpoint) SameDestination(other *Endpoint) bool
- func (e *Endpoint) Socket() string
- func (e *Endpoint) TargetsListener(listener *Endpoint) bool
- func (e *Endpoint) URL() Option[*url.URL]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint is a parsed listen or backend address. Backend endpoints also carry a target URL, an h2c flag, and a resolved port.
func ParseBackend ¶
ParseBackend parses a backend URL: http, https, or h2c over TCP, or "http+unix:"/"h2c+unix:" over a unix socket (absolute path or "@" name).
func ParseListen ¶
ParseListen parses a listener address. A "unix:" prefix selects a unix socket (absolute path or "@" abstract name); anything else is a TCP host:port.
func (*Endpoint) Address ¶
Address reports the listener or dial address: a unix socket or a TCP host:port.
func (*Endpoint) DialContext ¶
DialContext dials the endpoint's unix socket, ignoring the requested network and address so a transport reaches this backend regardless of the URL host.
func (*Endpoint) IsLoopback ¶
IsLoopback reports whether the backend or TCP listener host is a loopback IP address.
func (*Endpoint) Listen ¶
Listen binds a stream listener for the endpoint, clearing a stale unix socket so a restart can rebind it.
func (*Endpoint) SameDestination ¶ added in v0.14.0
SameDestination reports whether two backends reach the same unix socket or TCP scheme, canonical host, and port. A listener reaches no destination.
func (*Endpoint) Socket ¶
Socket returns the unix socket path, or an empty string for a TCP endpoint.
func (*Endpoint) TargetsListener ¶ added in v0.14.0
TargetsListener reports whether the backend would loop traffic back to the listener, matching unix sockets exactly and TCP by host and port. A listener targets nothing.