Run NodesReferenceutils

ips

Package ips

import "github.com/luxfi/node/utils/ips"

Functions

AddrFromSlice

func AddrFromSlice(b []byte) (netip.Addr, bool)

AddrFromSlice returns the IP address from the provided byte slice. If the byte slice represents an IPv4 address in an IPv6 address, the IPv4 address is returned.

IsPublic

func IsPublic(addr netip.Addr) bool

IsPublic returns true if the provided address is considered to be a public IP.

Lookup

func Lookup(hostname string) (netip.Addr, error)

Lookup attempts to resolve a hostname to a single IP. If multiple IPs are found, then lookup will attempt to return an IPv4 address, otherwise it will pick any of the IPs.

Note: IPv4 is preferred because net.Listen prefers IPv4.

PackIP

func PackIP(p *wrappers.Packer, ip IPPort)

PackIP packs an ip port pair to the byte array

ParseAddr

func ParseAddr(s string) (netip.Addr, error)

ParseAddr returns the IP address from the provided string. If the string represents an IPv4 address in an IPv6 address, the IPv4 address is returned.

ParseAddrPort

func ParseAddrPort(s string) (netip.AddrPort, error)

ParseAddrPort returns the IP:port address from the provided string. If the string represents an IPv4 address in an IPv6 address, the IPv4 address is returned.

Types

ClaimedIPPort

A self contained proof that a peer is claiming ownership of an IPPort at a given time.

func NewClaimedIPPort(
	cert *staking.Certificate,
	ipPort netip.AddrPort,
	timestamp uint64,
	signature []byte,
) *ClaimedIPPort
func (i *ClaimedIPPort) Size() int

DynamicIPPort

An IPPort that can change. Safe for use by multiple goroutines.

func NewDynamicIPPort(ip net.IP, port uint16) DynamicIPPort

IPDesc

func (ipDesc IPDesc) MarshalJSON() ([]byte, error)
func (ipDesc IPDesc) String() string
func (ipDesc *IPDesc) UnmarshalJSON(b []byte) error

IPPort

An IP and a port.

func ToIPPort(str string) (IPPort, error)
func (ipPort IPPort) Equal(other IPPort) bool
func (ipPort IPPort) IsZero() bool
func (ipPort IPPort) String() string