Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · netip

Docs

std/netip

On this page

Index

Types

Addr

struct Addr {
  bits: Int
  hi: Int
  lo: Int
  zone: Str
} derive Ord

An IP address: bits is 32 for IPv4, 128 for IPv6, 0 for the zero value; hi and lo its 16 bytes as two words (an IPv4 address as ::ffff:a.b.c.d); zone an IPv6 zone. The order is Go’s Addr.Compare.

Source: std/netip.xo:8

Addr.is_4

fn (a: Addr) is_4() -> Bool

Source: std/netip.xo:40

Addr.is_6

fn (a: Addr) is_6() -> Bool

Source: std/netip.xo:41

Addr.is_4in6

fn (a: Addr) is_4in6() -> Bool

Source: std/netip.xo:42

Addr.unmap

fn (a: Addr) unmap() -> Addr

An IPv4 in IPv6 address as IPv4 (its zone dropped), others as they are.

Source: std/netip.xo:44

Addr.is_loopback

fn (a: Addr) is_loopback() -> Bool

Source: std/netip.xo:45

Addr.is_private

fn (a: Addr) is_private() -> Bool

Source: std/netip.xo:46

Addr.is_unspecified

fn (a: Addr) is_unspecified() -> Bool

Source: std/netip.xo:47

fn (a: Addr) is_link_local_unicast() -> Bool

Source: std/netip.xo:48

Addr.is_multicast

fn (a: Addr) is_multicast() -> Bool

Source: std/netip.xo:49

Addr.bytes

fn (a: Addr) bytes() -> Bytes

4 bytes for IPv4, 16 for IPv6 (Go’s AsSlice).

Source: std/netip.xo:51

Addr.display

fn (a: Addr) display() -> Str

Go’s String: 1.2.3.4, 2001:db8::1, ::ffff:1.2.3.4, fe80::1%eth0.

Source: std/netip.xo:53

Prefix

struct Prefix {
  addr: Addr
  len: Int
}

An address and a prefix length.

Source: std/netip.xo:19

Prefix.contains

fn (p: Prefix) contains(a: Addr) -> Bool

Source: std/netip.xo:54

Prefix.masked

fn (p: Prefix) masked() -> Prefix

Source: std/netip.xo:55

Prefix.display

fn (p: Prefix) display() -> Str

Source: std/netip.xo:56

ParseErr

struct ParseErr {
  msg: Str
}

Go’s texts: ParseAddr("1.2.3"): IPv4 address too short.

Source: std/netip.xo:25

ParseErr.display

fn (e: ParseErr) display() -> Str

Source: std/netip.xo:29

Functions

parse_addr

fn parse_addr(s: Str) -> Addr ! ParseErr

Go’s ParseAddr: IPv4 (no leading zeros), IPv6, IPv4 in IPv6, zones.

Source: std/netip.xo:32

lookup

fn lookup(n: Net, host: Str) -> List[Addr] ! NetErr uses net.dial

The addresses of host, in the order Net.dial tries them (Go’s net.LookupIP through Net.lookup_host; decision 0406).

Source: std/netip.xo:35

parse_prefix

fn parse_prefix(s: Str) -> Prefix ! ParseErr

Go’s ParsePrefix: 10.0.0.0/8, 2001:db8::/32.

Source: std/netip.xo:37

addr_from_bytes

fn addr_from_bytes(b: Bytes) -> Addr?

The address of 4 or 16 bytes (AddrFrom4, AddrFrom16); None for another length.

Source: std/netip.xo:39

↑ index