Documentation ¶
Index ¶
- Constants
- type Address
- func AsAddress(addr net.Addr) Address
- func ExpandAddresses(ctx context.Context, skipError bool, ...) (result []Address, resolved int, err error)
- func ExpandHostAddresses(ctx context.Context, skipError bool, resolver *net.Resolver, a ...Address) ([]Address, int, error)
- func FromTCPAddr(a *net.TCPAddr) Address
- func FromUDPAddr(a *net.UDPAddr) Address
- func Join(addresses ...[]Address) []Address
- func NewHost(host string) Address
- func NewHostAndPort(host string, port int) Address
- func NewHostID(id HostID) Address
- func NewHostPK(pk longbits.FixedReader) Address
- func NewHostPort(hostport string, allowZero bool) Address
- func NewIP(ip net.IPAddr) Address
- func NewIPAndPort(ip net.IPAddr, port int) Address
- func NewLocalUID(uid uint64, id HostID) Address
- func ResolveAddresses(ctx context.Context, skipError bool, ...) (result []Address, err error)
- func ResolveHostAddresses(ctx context.Context, skipError bool, resolver *net.Resolver, a ...Address) ([]Address, error)
- func (a Address) AsHostID() HostID
- func (a *Address) AsIPAddr() net.IPAddr
- func (a Address) AsLocalUID() LocalUniqueID
- func (a *Address) AsTCPAddr() net.TCPAddr
- func (a *Address) AsUDPAddr() net.UDPAddr
- func (a Address) CanConnect() bool
- func (a Address) Data() longbits.ByteString
- func (a Address) DataLen() int
- func (a Address) EqualHostIdentity(o Address) bool
- func (a Address) HasName() bool
- func (a Address) HasPort() bool
- func (a Address) HostIdentity() Address
- func (a Address) HostString() string
- func (a Address) IdentityType() nwaddr.Identity
- func (a Address) IsLoopback() bool
- func (a Address) IsNetCompatible() bool
- func (a Address) IsResolved() bool
- func (a Address) IsZero() bool
- func (a Address) Name() string
- func (a Address) Network() string
- func (a Address) Port() int
- func (a Address) Resolve(ctx context.Context, resolver BasicAddressResolver, preference Preference) (Address, error)
- func (a Address) ResolveAll(ctx context.Context, resolver BasicAddressResolver) ([]Address, error)
- func (a Address) String() string
- func (a Address) WithPort(port uint16) Address
- func (a Address) WithoutName() Address
- func (a Address) WithoutPort() Address
- type AddressResolver
- type BasicAddressResolver
- type DeserializationContext
- type DeserializationFactory
- type Deserializer
- type HostID
- type LocalUniqueID
- type PayloadCompleteness
- type Preference
- type Serializable
- type SerializationContext
- type Serializer
- type ShortNodeID
- type SizeAwareDeserializer
- type SizeAwareSerializer
Constants ¶
const ( HostIDByteSize = 8 LocalUIDByteSize = 8 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
func ExpandAddresses ¶
func ExpandHostAddresses ¶
func FromTCPAddr ¶
func FromUDPAddr ¶
func NewHost ¶
NewHost checks if the string can be parsed into IP address, then returns either IP or DNS values accordingly.
func NewHostAndPort ¶
NewHostAndPort checks if the string can be parsed into IP address, then returns either IP or DNS values accordingly. Port must be valid.
func NewHostPK ¶
func NewHostPK(pk longbits.FixedReader) Address
NewHostID returns a PK based address
func NewHostPort ¶
NewHostPort checks if the string can be parsed into IP address, then returns either IP or DNS values accordingly. Port must be present.
func NewIPAndPort ¶
NewIPAndPort returns a host and port address. Panics on invalid (port).
func NewLocalUID ¶
NewLocalUID returns uid-based address. Value of (id) is for convenience only.
func ResolveAddresses ¶
func ResolveHostAddresses ¶
func (Address) AsLocalUID ¶
func (a Address) AsLocalUID() LocalUniqueID
AsLocalUID returns LocalUniqueID or panics
func (Address) CanConnect ¶
IsResolved indicates that this address can be connected
func (Address) Data ¶
func (a Address) Data() longbits.ByteString
Data provides a binary form of this address, only host part, excludes port
func (Address) EqualHostIdentity ¶
EqualHostIdentity is a convenience method to compare HostIdentity of both addresses
func (Address) HostIdentity ¶
HostIdentity strips out all extra data, like port or a name of a resolved address
func (Address) HostString ¶
HostString provides a readable string that describes the address/host. This string doesn't include port.
func (Address) IdentityType ¶
func (Address) IsLoopback ¶
IsLoopback returns true when address is IP and it is a loopback
func (Address) IsNetCompatible ¶
IsResolved indicates that this address can be used for net.Addr
func (Address) IsResolved ¶
IsResolved indicates that this address doesn't require a resolver
func (Address) Network ¶
Network enables use of Address as net.Addr, but will only be valid for IP/DNS identity
func (Address) Resolve ¶
func (a Address) Resolve(ctx context.Context, resolver BasicAddressResolver, preference Preference) (Address, error)
Resolve applies the given (resolver) to this address only when this address is unresolved. One address is picked by the (preference).
func (Address) ResolveAll ¶
ResolveAll applies the given (resolver) to this address only when this address is unresolved.
func (Address) String ¶
String provides value compatible with net.Addr, but will only be valid for IP/DNS identity
func (Address) WithoutName ¶
WithoutName returns address without a symbolic name. This does not change DNS (unresolved) address.
func (Address) WithoutPort ¶
WithoutPort returns address without a port.
type AddressResolver ¶
type BasicAddressResolver ¶
type DeserializationContext ¶
type DeserializationContext interface { // GetPayloadVerifier() cryptkit.DataSignatureVerifier // GetPayloadDecrypter() cryptkit.Decrypter GetPayloadFactory() DeserializationFactory }
type DeserializationFactory ¶
type DeserializationFactory interface {
DeserializePayloadFrom(DeserializationContext, PayloadCompleteness, *iokit.LimitedReader) (Serializable, error)
}
type Deserializer ¶
type Deserializer interface {
DeserializeFrom(DeserializationContext, io.Reader) error
}
type HostID ¶
type HostID uint64
HostID is a protocol-depended numerical id of a peer
func (HostID) AsNodeID ¶
func (v HostID) AsNodeID() ShortNodeID
type LocalUniqueID ¶
type LocalUniqueID uint64
LocalUniqueID is a protocol-independent locally unique id of a peer. This id wll change after de-registration of a peer.
func (LocalUniqueID) IsAbsent ¶
func (v LocalUniqueID) IsAbsent() bool
func (LocalUniqueID) String ¶
func (v LocalUniqueID) String() string
type PayloadCompleteness ¶
type PayloadCompleteness bool
const ( CompletePayload PayloadCompleteness = true PartialPayload PayloadCompleteness = false HeadOnlyPayload = CompletePayload )
type Preference ¶
type Preference uint8
const ( PreferV4 Preference PreferV6 )
func (Preference) ChooseOne ¶
func (v Preference) ChooseOne(a []Address) Address
func (Preference) Default ¶
func (v Preference) Default(name string) string
func (Preference) Override ¶
func (v Preference) Override(name string) string
func (Preference) String ¶
func (v Preference) String() string
type Serializable ¶
type Serializable interface { SizeAwareSerializer SizeAwareDeserializer }
type SerializationContext ¶
type SerializationContext interface {
SerializationContext()
}
type Serializer ¶
type Serializer interface {
SerializeTo(SerializationContext, io.Writer) error
}
type ShortNodeID ¶
type ShortNodeID uint32
ShortNodeID is the shortened ID of a peer that belongs to a member of a globula.
const ( AbsentShortNodeID ShortNodeID = 0 ShortNodeIDByteSize = 4 )
func (ShortNodeID) Equal ¶
func (v ShortNodeID) Equal(other ShortNodeID) bool
deprecated - do not use
func (ShortNodeID) IsAbsent ¶
func (v ShortNodeID) IsAbsent() bool
func (ShortNodeID) String ¶
func (v ShortNodeID) String() string
type SizeAwareDeserializer ¶
type SizeAwareDeserializer interface {
DeserializeFrom(DeserializationContext, *iokit.LimitedReader) error
}
type SizeAwareSerializer ¶
type SizeAwareSerializer interface { ByteSize() uint SerializeTo(SerializationContext, *iokit.LimitedWriter) error }