host

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: Apache-2.0 Imports: 4 Imported by: 10

Documentation

Overview

Package host is a fundamental part of networking system. Each host has:

  • one real network address (IP or any other transport protocol address)
  • multiple abstract network IDs (either host's own or ones belonging to relayed hosts)

Contains structures to describe network entities in code.

Usage:

 	originAddress, err := host.NewAddress(address)
	if err != nil {
		...
	}

	origin, err := host.NewOrigin(nil, originAddress)
	if err != nil {
		...
	}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	net.UDPAddr
}

Address is host's real network address.

func NewAddress

func NewAddress(address string) (*Address, error)

NewAddress is constructor.

func (Address) Equal

func (address Address) Equal(other Address) bool

Equal checks if address is equal to another.

type Host

type Host struct {
	// ID is a 20 byte unique identifier.
	ID id.ID
	// Address is IP and port.
	Address *Address
}

Host is the over-the-wire representation of a host.

func NewHost

func NewHost(address *Address) *Host

NewHost creates a new Host for bootstrapping.

func (Host) Equal

func (host Host) Equal(other Host) bool

Equal checks if host equals to other host (e.g. hosts' IDs and network addresses match).

func (Host) String

func (host Host) String() string

String representation of Host.

type Origin

type Origin struct {
	IDs     []id.ID
	Address *Address
}

Origin is “self” variant of Host. Unlike ordinary host it can have multiple IDs.

func NewOrigin

func NewOrigin(ids []id.ID, address *Address) (*Origin, error)

NewOrigin creates origin host from list of ids and network address.

func (*Origin) Contains

func (s *Origin) Contains(host *Host) bool

Contains checks if origin host “contains” network host. It checks if host's and origin's addresses match and host's id is in origin's ids list.

Jump to

Keyboard shortcuts

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