ips

package
v1.11.12 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: BSD-3-Clause Imports: 7 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddrFromSlice added in v1.11.8

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.

func IsPublic added in v1.11.8

func IsPublic(addr netip.Addr) bool

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

func Lookup added in v1.9.9

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.

func ParseAddr added in v1.11.8

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.

func ParseAddrPort added in v1.11.8

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

type ClaimedIPPort

type ClaimedIPPort struct {
	// The peer's certificate.
	Cert *staking.Certificate
	// The peer's claimed IP and port.
	AddrPort netip.AddrPort
	// The time the peer claimed to own this IP and port.
	Timestamp uint64
	// [Cert]'s signature over the IPPort and timestamp.
	// This is used in the networking library to ensure that this IPPort was
	// actually claimed by the peer in question, and not by a malicious peer
	// trying to get us to dial bogus IPPorts.
	Signature []byte
	// NodeID derived from the peer certificate.
	NodeID ids.NodeID
	// GossipID derived from the nodeID and timestamp.
	GossipID ids.ID
}

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

func NewClaimedIPPort added in v1.10.18

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

func (*ClaimedIPPort) Size added in v1.10.18

func (i *ClaimedIPPort) Size() int

Returns the approximate size of the binary representation of this ClaimedIPPort.

Jump to

Keyboard shortcuts

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