package netaddr

Import Path
	github.com/tmc/go-iroh/netaddr (on go.dev)

Dependency Relation
	imports 12 packages, and imported by 7 packages

Involved Source Files Package netaddr provides endpoint and transport addresses for go-iroh. An [EndpointAddr] combines a key.EndpointID with the network-level [TransportAddr] values at which the endpoint may be reached. A transport address is a [RelayAddr], [IPAddr], or [CustomAddr]. A [RelayURL] identifies an iroh relay server. The Go API is not stable before v1 and may change in any v0 release. endpointaddr.go relayurl.go
Package-Level Type Names (total 6)
/* sort by: | */
CustomAddr is a custom transport address: a freely-chosen u64 transport id plus opaque, unvalidated address data. A registry of well-known transport ids is at https://github.com/n0-computer/iroh/blob/main/TRANSPORTS.md. CustomAddr mirrors upstream iroh's experimental custom-transport address surface, which upstream excludes from its stability guarantees. The Go API below follows this module's normal compatibility policy, but the endpoint-ticket wire encoding of a CustomAddr may change to track upstream without a major go-iroh version bump. String encoding ([CustomAddr.String], [ParseCustomAddr]): "<id>_<data>" where <id> is the transport ID as lowercase hex (no "0x", no leading zeros) and <data> is the address bytes as lowercase hex. Binary encoding ([CustomAddr.MarshalBinary], [CustomAddr.UnmarshalBinary]): 8-byte little-endian u64 ID followed by the raw data bytes (minimum 8 bytes). CustomAddr mirrors upstream iroh's experimental custom-transport address surface, which upstream excludes from its stability guarantees. The Go API below follows this module's normal compatibility policy, but the endpoint-ticket wire encoding of a CustomAddr may change to track upstream without a major go-iroh version bump. Compare orders custom addresses by numeric transport id, then by data bytes. Data returns the opaque address data. ID returns the transport ID. MarshalBinary implements encoding.BinaryMarshaler using the binary encoding described on [CustomAddr]. MarshalText implements encoding.TextMarshaler using the string encoding described on [CustomAddr]. ( CustomAddr) Network() string ( CustomAddr) String() string UnmarshalBinary implements encoding.BinaryUnmarshaler using the binary encoding described on [CustomAddr]. UnmarshalText implements encoding.TextUnmarshaler using the string encoding described on [CustomAddr]. CustomAddr : TransportAddr CustomAddr : encoding.BinaryMarshaler *CustomAddr : encoding.BinaryUnmarshaler CustomAddr : encoding.TextMarshaler *CustomAddr : encoding.TextUnmarshaler CustomAddr : expvar.Var CustomAddr : fmt.Stringer CustomAddr : net.Addr func NewCustomAddr(id uint64, data []byte) CustomAddr func ParseCustomAddr(s string) (CustomAddr, error) func github.com/tmc/go-iroh/internal/socket.Addr.Custom() (CustomAddr, bool) func github.com/tmc/go-iroh/internal/socket.(*Socket).LookupCustom(m socket.CustomMappedAddr) (CustomAddr, bool) func github.com/tmc/go-iroh/iroh.AdvertisingCustomTransport.LocalCustomAddrs(context.Context) ([]CustomAddr, error) func github.com/tmc/go-iroh/internal/socket.CustomAddr(c CustomAddr) socket.Addr func github.com/tmc/go-iroh/internal/socket.CustomTransport.Send(remote CustomAddr, local *CustomAddr, p []byte) bool func github.com/tmc/go-iroh/internal/socket.CustomTransport.Send(remote CustomAddr, local *CustomAddr, p []byte) bool func github.com/tmc/go-iroh/internal/socket.PacketTransport.Send(remote CustomAddr, local *CustomAddr, p []byte) bool func github.com/tmc/go-iroh/internal/socket.PacketTransport.Send(remote CustomAddr, local *CustomAddr, p []byte) bool func github.com/tmc/go-iroh/internal/socket.PacketTransport.SendPacket(remote CustomAddr, local *CustomAddr, p []byte) bool func github.com/tmc/go-iroh/internal/socket.PacketTransport.SendPacket(remote CustomAddr, local *CustomAddr, p []byte) bool func github.com/tmc/go-iroh/internal/socket.(*Socket).CustomMappedAddrFor(c CustomAddr) socket.CustomMappedAddr func github.com/tmc/go-iroh/iroh.AdvertisingCustomTransport.Send(remote CustomAddr, local *CustomAddr, p []byte) bool func github.com/tmc/go-iroh/iroh.AdvertisingCustomTransport.Send(remote CustomAddr, local *CustomAddr, p []byte) bool func github.com/tmc/go-iroh/iroh.CustomTransport.Send(remote CustomAddr, local *CustomAddr, p []byte) bool func github.com/tmc/go-iroh/iroh.CustomTransport.Send(remote CustomAddr, local *CustomAddr, p []byte) bool
EndpointAddr combines an endpoint's [key.EndpointID] with the network-level addresses at which it may be reached. To establish a connection both the key.EndpointID and at least one path (a relay URL or a direct IP address) are needed; an EndpointAddr with no addresses is still usable together with an address-lookup service. ID is the endpoint's identifier. Addrs returns the sorted, deduplicated transport addresses. IPAddrs returns the IP socket addresses of this endpoint. IsEmpty reports whether only the key.EndpointID is present. RelayURLs returns the relay URLs of this endpoint. In practice this is expected to be zero or one home relay. String returns a diagnostic string for a. WithAddrs returns a copy of a with the given addresses added. The result's address set is sorted and deduplicated. WithIP returns a copy of a with the given IP address added. WithRelayURL returns a copy of a with the given relay URL added. EndpointAddr : expvar.Var EndpointAddr : fmt.Stringer func NewEndpointAddr(id key.EndpointID, addrs ...TransportAddr) EndpointAddr func EndpointAddr.WithAddrs(addrs ...TransportAddr) EndpointAddr func EndpointAddr.WithIP(ap netip.AddrPort) EndpointAddr func EndpointAddr.WithRelayURL(u RelayURL) EndpointAddr func github.com/tmc/go-iroh/dns.EndpointInfo.Addr() EndpointAddr func github.com/tmc/go-iroh/endpointticket.Decode(s string) (EndpointAddr, error) func github.com/tmc/go-iroh/endpointticket.ShortAddr(addr EndpointAddr) EndpointAddr func github.com/tmc/go-iroh/endpointticket.Ticket.Addr() EndpointAddr func github.com/tmc/go-iroh/iroh.(*Endpoint).Addr() EndpointAddr func github.com/tmc/go-iroh/iroh.Item.Addr() EndpointAddr func github.com/tmc/go-iroh/dns.EndpointDataFromAddr(addr EndpointAddr) dns.EndpointData func github.com/tmc/go-iroh/dns.EndpointInfoFromAddr(addr EndpointAddr) dns.EndpointInfo func github.com/tmc/go-iroh/endpointticket.Encode(addr EndpointAddr) string func github.com/tmc/go-iroh/endpointticket.New(addr EndpointAddr) endpointticket.Ticket func github.com/tmc/go-iroh/endpointticket.Short(addr EndpointAddr) endpointticket.Ticket func github.com/tmc/go-iroh/endpointticket.ShortAddr(addr EndpointAddr) EndpointAddr func github.com/tmc/go-iroh/internal/socket.(*RemoteMap).ResolveRemote(addr EndpointAddr) error func github.com/tmc/go-iroh/internal/socket.(*RemoteStateActor).ResolveRemote(addr EndpointAddr) error func github.com/tmc/go-iroh/iroh.StaticLookupFromAddrs(addrs ...EndpointAddr) *iroh.StaticLookup func github.com/tmc/go-iroh/iroh.(*Endpoint).Connect(ctx context.Context, addr EndpointAddr, alpn string) (*iroh.Conn, error) func github.com/tmc/go-iroh/iroh.(*Endpoint).ConnectEarly(ctx context.Context, addr EndpointAddr, alpn string) (*iroh.Connecting, error) func github.com/tmc/go-iroh/iroh.(*Endpoint).Dial(ctx context.Context, addr EndpointAddr, alpn string) (net.Conn, error) func github.com/tmc/go-iroh/iroh.EndpointHooks.BeforeConnect(ctx context.Context, addr EndpointAddr, alpn string) error func github.com/tmc/go-iroh/iroh.(*MemoryLookup).AddEndpointAddr(addr EndpointAddr)
IPAddr is a [TransportAddr] reachable at an IP socket address. Addr netip.AddrPort Compare orders IP addresses numerically (by [netip.AddrPort.Compare]). MarshalText implements encoding.TextMarshaler using the string encoding described on [TransportAddr]. ( IPAddr) Network() string ( IPAddr) String() string UnmarshalText implements encoding.TextUnmarshaler using the string encoding described on [TransportAddr]. IPAddr : TransportAddr IPAddr : encoding.TextMarshaler *IPAddr : encoding.TextUnmarshaler IPAddr : expvar.Var IPAddr : fmt.Stringer IPAddr : net.Addr
RelayAddr is a [TransportAddr] reachable via a relay server. URL RelayURL Compare orders relay addresses by their normalized URL string. MarshalText implements encoding.TextMarshaler using the string encoding described on [TransportAddr]. ( RelayAddr) Network() string ( RelayAddr) String() string UnmarshalText implements encoding.TextUnmarshaler using the string encoding described on [TransportAddr]. RelayAddr : TransportAddr RelayAddr : encoding.TextMarshaler *RelayAddr : encoding.TextUnmarshaler RelayAddr : expvar.Var RelayAddr : fmt.Stringer RelayAddr : net.Addr
RelayURL is a URL identifying a relay server. It wraps a parsed URL and is cheap to copy. It is encouraged to use a fully-qualified DNS domain name (one ending in a ".", e.g. "relay.example.com.") so that local DNS search domains do not interfere with resolution. The zero value is not usable; construct a RelayURL with [ParseRelayURL] or [RelayURLFromURL]. Compare returns -1, 0, or +1 comparing r and other by their normalized string form, giving RelayURL a total order. Equal reports whether r and other are the same relay URL. Host returns the host (without port) of the relay URL. IsZero reports whether r is the unusable zero value. MarshalText implements encoding.TextMarshaler. String returns the normalized string form of the URL. An empty path is rendered as "/", matching the WHATWG URL serialization used by the Rust reference implementation (e.g. "https://example.com" -> "https://example.com/"). URL returns a copy of the underlying parsed URL. UnmarshalText implements encoding.TextUnmarshaler. RelayURL : encoding.TextMarshaler *RelayURL : encoding.TextUnmarshaler RelayURL : expvar.Var RelayURL : fmt.Stringer RelayURL : gopkg.in/yaml.v3.IsZeroer func ParseRelayURL(s string) (RelayURL, error) func RelayURLFromURL(u *url.URL) RelayURL func EndpointAddr.RelayURLs() []RelayURL func github.com/tmc/go-iroh/dns.EndpointData.RelayURLs() []RelayURL func github.com/tmc/go-iroh/internal/netreport.(*RelayLatencies).Snapshot() map[RelayURL]time.Duration func github.com/tmc/go-iroh/internal/socket.Addr.Relay() (RelayURL, key.EndpointID, bool) func github.com/tmc/go-iroh/relay.(*Map).Nearest(ctx context.Context, prober relay.Prober) (RelayURL, error) func github.com/tmc/go-iroh/relay.(*Map).URLs() []RelayURL func EndpointAddr.WithRelayURL(u RelayURL) EndpointAddr func RelayURL.Compare(other RelayURL) int func RelayURL.Equal(other RelayURL) bool func github.com/tmc/go-iroh/dns.(*EndpointData).AddRelayURL(u RelayURL) func github.com/tmc/go-iroh/dns.EndpointData.WithRelayURL(u RelayURL) dns.EndpointData func github.com/tmc/go-iroh/internal/relayclient.Connect(ctx context.Context, u RelayURL, opts relayclient.Options) (*relayclient.Client, error) func github.com/tmc/go-iroh/internal/socket.RelayAddr(url RelayURL, eid key.EndpointID) socket.Addr func github.com/tmc/go-iroh/internal/socket.(*RelayActor).InsertRelay(url RelayURL, cfg relay.Config) (relay.Config, bool) func github.com/tmc/go-iroh/internal/socket.(*RelayActor).RemoveRelay(url RelayURL) (relay.Config, bool) func github.com/tmc/go-iroh/internal/socket.(*RelayActor).SetHomeRelay(url RelayURL) func github.com/tmc/go-iroh/internal/socket.(*RelayTransport).InsertRelay(url RelayURL, cfg relay.Config) (relay.Config, bool) func github.com/tmc/go-iroh/internal/socket.(*RelayTransport).RemoveRelay(url RelayURL) (relay.Config, bool) func github.com/tmc/go-iroh/internal/socket.(*RelayTransport).SetHomeRelay(url RelayURL) func github.com/tmc/go-iroh/internal/socket.(*Socket).RelayMappedAddrFor(url RelayURL, eid key.EndpointID) socket.RelayMappedAddr func github.com/tmc/go-iroh/iroh.(*Endpoint).InsertRelay(url RelayURL, cfg *iroh.RelayConfig) (*iroh.RelayConfig, error) func github.com/tmc/go-iroh/iroh.(*Endpoint).RemoveRelay(url RelayURL) *iroh.RelayConfig func github.com/tmc/go-iroh/relay.MapFromURLs(urls ...RelayURL) *relay.Map func github.com/tmc/go-iroh/relay.ModeCustomURLs(urls ...RelayURL) relay.Mode func github.com/tmc/go-iroh/relay.NewConfig(url RelayURL, quic *relay.QUICConfig) relay.Config func github.com/tmc/go-iroh/relay.(*Map).Contains(url RelayURL) bool func github.com/tmc/go-iroh/relay.(*Map).Get(url RelayURL) (relay.Config, bool) func github.com/tmc/go-iroh/relay.(*Map).Remove(url RelayURL) (relay.Config, bool)
TransportAddr is a network-level address at which an endpoint may be reached. It is one of [RelayAddr], [IPAddr], or [CustomAddr]. The interface is closed: only the implementations in this package satisfy it. Compare returns -1, 0, or +1 ordering this address against other. The order matches the Rust reference's derived Ord on the TransportAddr enum: by kind first (relay < ip < custom), then by value (relay URLs by their normalized string, IP addresses numerically, custom by id then data). Network returns the transport kind: "relay", "ip", or "custom". String renders the address in its "kind:value" form, e.g. "ip:127.0.0.1:9". CustomAddr IPAddr RelayAddr TransportAddr : expvar.Var TransportAddr : fmt.Stringer TransportAddr : net.Addr func ParseTransportAddr(s string) (TransportAddr, error) func EndpointAddr.Addrs() []TransportAddr func github.com/tmc/go-iroh/dns.EndpointData.Addrs() []TransportAddr func github.com/tmc/go-iroh/iroh.IPOnlyFilter(addrs []TransportAddr) []TransportAddr func github.com/tmc/go-iroh/iroh.RelayOnlyFilter(addrs []TransportAddr) []TransportAddr func github.com/tmc/go-iroh/iroh.BiasedRttPathSelector.Select(current TransportAddr, candidates []iroh.PathCandidate) (TransportAddr, bool) func github.com/tmc/go-iroh/iroh.PathSelector.Select(current TransportAddr, candidates []iroh.PathCandidate) (selected TransportAddr, ok bool) func NewEndpointAddr(id key.EndpointID, addrs ...TransportAddr) EndpointAddr func CustomAddr.Compare(other TransportAddr) int func EndpointAddr.WithAddrs(addrs ...TransportAddr) EndpointAddr func IPAddr.Compare(other TransportAddr) int func RelayAddr.Compare(other TransportAddr) int func TransportAddr.Compare(other TransportAddr) int func github.com/tmc/go-iroh/dns.NewEndpointData(addrs ...TransportAddr) dns.EndpointData func github.com/tmc/go-iroh/dns.(*EndpointData).AddAddrs(addrs ...TransportAddr) func github.com/tmc/go-iroh/dns.EndpointData.WithAddrs(addrs ...TransportAddr) dns.EndpointData func github.com/tmc/go-iroh/iroh.IPOnlyFilter(addrs []TransportAddr) []TransportAddr func github.com/tmc/go-iroh/iroh.RelayOnlyFilter(addrs []TransportAddr) []TransportAddr func github.com/tmc/go-iroh/iroh.BiasedRttPathSelector.Select(current TransportAddr, candidates []iroh.PathCandidate) (TransportAddr, bool) func github.com/tmc/go-iroh/iroh.PathSelector.Select(current TransportAddr, candidates []iroh.PathCandidate) (selected TransportAddr, ok bool)
Package-Level Functions (total 6)
NewCustomAddr creates a CustomAddr from a transport ID and raw address data. The data is copied.
NewEndpointAddr creates an EndpointAddr with the given id and transport addresses. Addresses are deduplicated and sorted.
ParseCustomAddr parses a CustomAddr from its "<id>_<data>" string form. It also accepts the "custom:" prefix used by [ParseTransportAddr].
ParseRelayURL parses s into a RelayURL. It returns an error wrapping [ErrParseRelayURL] if s is not a valid URL.
ParseTransportAddr parses a TransportAddr from its "kind:value" string form.
RelayURLFromURL wraps an already-parsed URL as a RelayURL, normalizing it so that equivalent URLs compare equal (see [RelayURL.String]).
Package-Level Variables (total 5)
CustomAddr parse/encode errors.
CustomAddr parse/encode errors.
CustomAddr parse/encode errors.
CustomAddr parse/encode errors.
ErrParseRelayURL is returned (wrapped) when a relay URL cannot be parsed.