Documentation
¶
Overview ¶
Package router_address implements the I2P RouterAddress common data structure
Package router_address implements the I2P RouterAddress common data structure
Package router_address implements the I2P RouterAddress common data structure
Package router_address implements the I2P RouterAddress common data structure
Package router_address implements the I2P RouterAddress common data structure
Index ¶
- Constants
- type RouterAddress
- func (router_address RouterAddress) Bytes() []byte
- func (router_address RouterAddress) CapsString() data.I2PString
- func (router_address RouterAddress) CheckOption(key string) bool
- func (router_address RouterAddress) Cost() int
- func (router_address RouterAddress) Expiration() data.Date
- func (router_address RouterAddress) GetOption(key data.I2PString) data.I2PString
- func (router_address RouterAddress) HasOption(key data.I2PString) bool
- func (router_address RouterAddress) HasValidHost() bool
- func (router_address RouterAddress) HasValidPort() bool
- func (router_address RouterAddress) Host() (net.Addr, error)
- func (router_address RouterAddress) HostString() data.I2PString
- func (router_address *RouterAddress) IPVersion() string
- func (router_address RouterAddress) InitializationVector() ([16]byte, error)
- func (router_address RouterAddress) InitializationVectorString() data.I2PString
- func (router_address RouterAddress) IntroducerExpirationString(num int) data.I2PString
- func (router_address RouterAddress) IntroducerHashString(num int) data.I2PString
- func (router_address RouterAddress) IntroducerTagString(num int) data.I2PString
- func (ra *RouterAddress) IsValid() bool
- func (router_address *RouterAddress) Network() string
- func (routerAddress RouterAddress) Options() data.Mapping
- func (router_address RouterAddress) Port() (string, error)
- func (router_address RouterAddress) PortString() data.I2PString
- func (router_address RouterAddress) ProtocolVersion() (string, error)
- func (router_address RouterAddress) ProtocolVersionString() data.I2PString
- func (routerAddress RouterAddress) StaticKey() ([32]byte, error)
- func (router_address RouterAddress) StaticKeyString() data.I2PString
- func (router_address *RouterAddress) String() string
- func (router_address RouterAddress) TransportStyle() data.I2PString
- func (router_address *RouterAddress) UDP() bool
- func (ra *RouterAddress) Validate() error
Constants ¶
const CAPS_OPTION_KEY = "caps"
CAPS_OPTION_KEY is the mapping key for the capabilities option
const DEFAULT_INTRODUCER_NUMBER = 0
DEFAULT_INTRODUCER_NUMBER is the default introducer number when out of range
const HOST_OPTION_KEY = "host"
HOST_OPTION_KEY is the mapping key for the host address option
const INITIALIZATION_VECTOR_OPTION_KEY = "i"
INITIALIZATION_VECTOR_OPTION_KEY is the mapping key for the initialization vector option
const INITIALIZATION_VECTOR_SIZE = 16
INITIALIZATION_VECTOR_SIZE is the size in bytes of an initialization vector
const INTRODUCER_EXPIRATION_PREFIX = "iexp"
INTRODUCER_EXPIRATION_PREFIX is the prefix for introducer expiration option keys
const INTRODUCER_HASH_PREFIX = "ih"
INTRODUCER_HASH_PREFIX is the prefix for introducer hash option keys
const INTRODUCER_TAG_PREFIX = "itag"
INTRODUCER_TAG_PREFIX is the prefix for introducer tag option keys
const IPV4_VERSION_STRING = "4"
IPV4_VERSION_STRING is the string representation for IPv4 addresses
const IPV6_SUFFIX = "6"
IPV6_SUFFIX is the suffix used to identify IPv6 addresses in capabilities
const IPV6_VERSION_STRING = "6"
IPV6_VERSION_STRING is the string representation for IPv6 addresses
const MAX_INTRODUCER_NUMBER = 2
MAX_INTRODUCER_NUMBER is the maximum valid introducer number
const MIN_INTRODUCER_NUMBER = 0
MIN_INTRODUCER_NUMBER is the minimum valid introducer number
const PORT_OPTION_KEY = "port"
PORT_OPTION_KEY is the mapping key for the port number option
const PROTOCOL_VERSION_OPTION_KEY = "v"
PROTOCOL_VERSION_OPTION_KEY is the mapping key for the protocol version option
const (
ROUTER_ADDRESS_MIN_SIZE = 9
)
ROUTER_ADDRESS_MIN_SIZE defines the minimum number of bytes in a valid RouterAddress
const SSU_TRANSPORT_PREFIX = "ssu"
SSU_TRANSPORT_PREFIX is the prefix used to identify SSU (UDP-based) transports
const STATIC_KEY_OPTION_KEY = "s"
STATIC_KEY_OPTION_KEY is the mapping key for the static key option
const STATIC_KEY_SIZE = 32
STATIC_KEY_SIZE is the size in bytes of a static key used in router addresses
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RouterAddress ¶
type RouterAddress struct {
TransportCost *data.Integer
ExpirationDate *data.Date
TransportType data.I2PString
TransportOptions *data.Mapping
}
RouterAddress is the represenation of an I2P RouterAddress.
https://geti2p.net/spec/common-structures#routeraddress
Use NewRouterAddress() in router_address.go to create instances.
func NewRouterAddress ¶
func NewRouterAddress(cost uint8, expiration time.Time, transportType string, options map[string]string) (*RouterAddress, error)
NewRouterAddress creates a new RouterAddress with the provided parameters. Validates that the transport type is not empty and that required options are provided. Returns a pointer to RouterAddress.
func ReadRouterAddress ¶
func ReadRouterAddress(routerAddressData []byte) (router_address RouterAddress, remainder []byte, err error)
ReadRouterAddress returns RouterAddress from a []byte. The remaining bytes after the specified length are also returned. Returns a list of errors that occurred during parsing.
func (RouterAddress) Bytes ¶
func (router_address RouterAddress) Bytes() []byte
Bytes returns the router address as a []byte.
func (RouterAddress) CapsString ¶
func (router_address RouterAddress) CapsString() data.I2PString
CapsString returns the caps option as an I2PString
func (RouterAddress) CheckOption ¶
func (router_address RouterAddress) CheckOption(key string) bool
CheckOption checks if an option exists using a string key
func (RouterAddress) Cost ¶
func (router_address RouterAddress) Cost() int
Cost returns the cost for this RouterAddress as a Go integer.
func (RouterAddress) Expiration ¶
func (router_address RouterAddress) Expiration() data.Date
Expiration returns the expiration for this RouterAddress as an I2P Date.
func (RouterAddress) GetOption ¶
func (router_address RouterAddress) GetOption(key data.I2PString) data.I2PString
GetOption returns the value of the option specified by the key
func (RouterAddress) HasOption ¶
func (router_address RouterAddress) HasOption(key data.I2PString) bool
HasOption checks if a given option key exists
func (RouterAddress) HasValidHost ¶ added in v0.1.0
func (router_address RouterAddress) HasValidHost() bool
HasValidHost checks if the RouterAddress has a valid and usable host option. This is useful for defensive programming to skip invalid addresses gracefully. Returns true if the host option exists, is non-empty, and contains a valid IP address.
func (RouterAddress) HasValidPort ¶ added in v0.1.0
func (router_address RouterAddress) HasValidPort() bool
HasValidPort checks if the RouterAddress has a valid and usable port option. This is useful for defensive programming to skip invalid addresses gracefully. Returns true if the port option exists, is non-empty, is a valid number, and is in range 1-65535.
func (RouterAddress) Host ¶
func (router_address RouterAddress) Host() (net.Addr, error)
Host returns the host address as a net.Addr
func (RouterAddress) HostString ¶
func (router_address RouterAddress) HostString() data.I2PString
HostString returns the host option as an I2PString
func (*RouterAddress) IPVersion ¶
func (router_address *RouterAddress) IPVersion() string
IPVersion returns a string "4" for IPv4 or 6 for IPv6
func (RouterAddress) InitializationVector ¶
func (router_address RouterAddress) InitializationVector() ([16]byte, error)
InitializationVector returns the initialization vector as a 16-byte array
func (RouterAddress) InitializationVectorString ¶
func (router_address RouterAddress) InitializationVectorString() data.I2PString
InitializationVectorString returns the initialization vector option as an I2PString
func (RouterAddress) IntroducerExpirationString ¶
func (router_address RouterAddress) IntroducerExpirationString(num int) data.I2PString
IntroducerExpirationString returns the introducer expiration option for the specified number
func (RouterAddress) IntroducerHashString ¶
func (router_address RouterAddress) IntroducerHashString(num int) data.I2PString
IntroducerHashString returns the introducer hash option for the specified number
func (RouterAddress) IntroducerTagString ¶
func (router_address RouterAddress) IntroducerTagString(num int) data.I2PString
IntroducerTagString returns the introducer tag option for the specified number
func (*RouterAddress) IsValid ¶ added in v0.1.0
func (ra *RouterAddress) IsValid() bool
IsValid returns true if the RouterAddress is properly initialized.
func (*RouterAddress) Network ¶
func (router_address *RouterAddress) Network() string
Network implements net.Addr. It returns the transport type plus 4 or 6
func (RouterAddress) Options ¶
func (routerAddress RouterAddress) Options() data.Mapping
Options returns the options for this RouterAddress as an I2P Mapping.
func (RouterAddress) Port ¶
func (router_address RouterAddress) Port() (string, error)
Port returns the port number as a string
func (RouterAddress) PortString ¶
func (router_address RouterAddress) PortString() data.I2PString
PortString returns the port option as an I2PString
func (RouterAddress) ProtocolVersion ¶
func (router_address RouterAddress) ProtocolVersion() (string, error)
ProtocolVersion returns the protocol version as a string
func (RouterAddress) ProtocolVersionString ¶
func (router_address RouterAddress) ProtocolVersionString() data.I2PString
ProtocolVersionString returns the protocol version option as an I2PString
func (RouterAddress) StaticKey ¶
func (routerAddress RouterAddress) StaticKey() ([32]byte, error)
StaticKey returns the static key as a 32-byte array
func (RouterAddress) StaticKeyString ¶
func (router_address RouterAddress) StaticKeyString() data.I2PString
StaticKeyString returns the static key option as an I2PString
func (*RouterAddress) String ¶
func (router_address *RouterAddress) String() string
String implements net.Addr. It returns the IP address, followed by the options
func (RouterAddress) TransportStyle ¶
func (router_address RouterAddress) TransportStyle() data.I2PString
TransportStyle returns the transport style for this RouterAddress as an I2PString.
func (*RouterAddress) UDP ¶
func (router_address *RouterAddress) UDP() bool
UDP checks if the RouterAddress is UDP-based
func (*RouterAddress) Validate ¶ added in v0.1.0
func (ra *RouterAddress) Validate() error
Validate checks if the RouterAddress is properly initialized.