netaddr

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package netaddr parses listen and backend addresses and opens or dials them.

Index

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

func ParseBackend(value string) (*Endpoint, error)

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

func ParseListen(value string) *Endpoint

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

func (e *Endpoint) Address() string

Address reports the listener or dial address: a unix socket or a TCP host:port.

func (*Endpoint) DialContext

func (e *Endpoint) DialContext(ctx context.Context, _ string, _ string) (net.Conn, error)

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) IsH2C

func (e *Endpoint) IsH2C() bool

IsH2C reports whether the backend speaks unencrypted HTTP/2.

func (*Endpoint) IsLoopback

func (e *Endpoint) IsLoopback() bool

IsLoopback reports whether the backend host is a loopback IP address.

func (*Endpoint) IsUnix

func (e *Endpoint) IsUnix() bool

IsUnix reports whether the endpoint is reached over a unix domain socket.

func (*Endpoint) Listen

func (e *Endpoint) Listen(ctx context.Context) (net.Listener, error)

Listen binds a stream listener for the endpoint, clearing a stale unix socket so a restart can rebind it.

func (*Endpoint) Network

func (e *Endpoint) Network() string

Network reports the listener network, "tcp" or "unix".

func (*Endpoint) Port

func (e *Endpoint) Port() uint16

Port returns the resolved backend TCP port.

func (*Endpoint) Socket

func (e *Endpoint) Socket() string

Socket returns the unix socket path, or an empty string for a TCP endpoint.

func (*Endpoint) URL

func (e *Endpoint) URL() *url.URL

URL returns the backend target URL, or nil for a listener endpoint.

Jump to

Keyboard shortcuts

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