Documentation
¶
Index ¶
- func GroupKey(na net.IP) string
- func IsDNSAddress(rawAddr string) bool
- func IsIPv4(na net.IP) bool
- func IsLocal(na net.IP) bool
- func IsOnionCatTor(na net.IP) bool
- func IsRFC1918(na net.IP) bool
- func IsRFC2544(na net.IP) bool
- func IsRFC3849(na net.IP) bool
- func IsRFC3927(na net.IP) bool
- func IsRFC3964(na net.IP) bool
- func IsRFC4193(na net.IP) bool
- func IsRFC4380(na net.IP) bool
- func IsRFC4843(na net.IP) bool
- func IsRFC4862(na net.IP) bool
- func IsRFC5737(na net.IP) bool
- func IsRFC6052(na net.IP) bool
- func IsRFC6145(na net.IP) bool
- func IsRFC6598(na net.IP) bool
- func IsRoutable(na net.IP) bool
- func IsValid(na net.IP) bool
- type AddrBook
- func (a *AddrBook) AddAddress(addr, src *AddrInfo)
- func (a *AddrBook) AddAddresses(addrs []*AddrInfo, src *AddrInfo)
- func (a *AddrBook) AddressCache() []*AddrInfo
- func (a *AddrBook) Attempt(pid peer.ID)
- func (a *AddrBook) BootstrapAddressCache() (addresses []*AddrInfo)
- func (a *AddrBook) Connected(peerID peer.ID)
- func (a *AddrBook) GetAddresses() []*AddrInfo
- func (a *AddrBook) GetAddressesNotConnectedSince(date time.Time) []*AddrInfo
- func (a *AddrBook) GetKnownAddressesCache() []knownAddress
- func (a *AddrBook) Good(pid peer.ID)
- func (a *AddrBook) Lookup(addr peer.ID) *AddrInfo
- func (a *AddrBook) NumAddresses() int
- func (a *AddrBook) Persist(ctx context.Context)
- func (a *AddrBook) RemoveAddress(pid peer.ID)
- func (a *AddrBook) WasRecentlyRemoved(id peer.ID) (removedAt *time.Time, wasRemoved bool)
- type AddrInfo
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GroupKey ¶
GroupKey returns a string representing the network group an address is part of. This is the /16 for IPv4, the /32 (/36 for he.net) for IPv6, the string "localNode" for a localNode address, the string "tor:key" where key is the /4 of the onion address for Tor address, and the string "unroutable" for an unroutable address.
func IsDNSAddress ¶
IsDNSAddress returns whether or not the passed address is an intended DNS.
func IsOnionCatTor ¶
IsOnionCatTor returns whether or not the passed address is in the IPv6 range used by bitcoin to support Tor (fd87:d87e:eb43::/48). Note that this range is the same range used by OnionCat, which is part of the RFC4193 unique localNode IPv6 range.
func IsRFC1918 ¶
IsRFC1918 returns whether or not the passed address is part of the IPv4 private network address space as defined by RFC1918 (10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16).
func IsRFC2544 ¶
IsRFC2544 returns whether or not the passed address is part of the IPv4 address space as defined by RFC2544 (198.18.0.0/15).
func IsRFC3849 ¶
IsRFC3849 returns whether or not the passed address is part of the IPv6 documentation range as defined by RFC3849 (2001:DB8::/32).
func IsRFC3927 ¶
IsRFC3927 returns whether or not the passed address is part of the IPv4 autoconfiguration range as defined by RFC3927 (169.254.0.0/16).
func IsRFC3964 ¶
IsRFC3964 returns whether or not the passed address is part of the IPv6 to IPv4 encapsulation range as defined by RFC3964 (2002::/16).
func IsRFC4193 ¶
IsRFC4193 returns whether or not the passed address is part of the IPv6 unique localNode range as defined by RFC4193 (FC00::/7).
func IsRFC4380 ¶
IsRFC4380 returns whether or not the passed address is part of the IPv6 teredo tunneling over UDP range as defined by RFC4380 (2001::/32).
func IsRFC4843 ¶
IsRFC4843 returns whether or not the passed address is part of the IPv6 ORCHID range as defined by RFC4843 (2001:10::/28).
func IsRFC4862 ¶
IsRFC4862 returns whether or not the passed address is part of the IPv6 stateless address autoconfiguration range as defined by RFC4862 (FE80::/64).
func IsRFC5737 ¶
IsRFC5737 returns whether or not the passed address is part of the IPv4 documentation address space as defined by RFC5737 (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24).
func IsRFC6052 ¶
IsRFC6052 returns whether or not the passed address is part of the IPv6 well-known prefix range as defined by RFC6052 (64:FF9B::/96).
func IsRFC6145 ¶
IsRFC6145 returns whether or not the passed address is part of the IPv6 to IPv4 translated address range as defined by RFC6145 (::FFFF:0:0:0/96).
func IsRFC6598 ¶
IsRFC6598 returns whether or not the passed address is part of the IPv4 shared address space specified by RFC6598 (100.64.0.0/10).
func IsRoutable ¶
IsRoutable returns whether or not the passed address is routable over the public internet. This is true as long as the address is valid and is not in any reserved ranges.
Types ¶
type AddrBook ¶
type AddrBook struct {
// contains filtered or unexported fields
}
AddrBook provides a concurrency safe address manager for caching potential peers on the network. based on bitcoin's AddrBook.
func NewAddrBook ¶
NewAddrBook returns a new address manager. Use Start to begin processing asynchronous address updates.
func (*AddrBook) AddAddress ¶
AddAddress adds a new address to the address manager. It enforces a max number of addresses and silently ignores duplicate addresses. It is safe for concurrent access.
func (*AddrBook) AddAddresses ¶
AddAddresses adds new addresses to the address manager. It enforces a max number of addresses and silently ignores duplicate addresses. It is safe for concurrent access.
func (*AddrBook) AddressCache ¶
AddressCache returns the current address cache. It must be treated as read-only (but since it is a copy now, this is not as dangerous).
func (*AddrBook) Attempt ¶
Attempt increases the given address' attempt counter and updates the last attempt time.
func (*AddrBook) BootstrapAddressCache ¶
BootstrapAddressCache run AddressCache and add Config.AnchorPeersCount addresses from anchor peers.
func (*AddrBook) Connected ¶
Connected adds the given address to anchor list. Will take some addresses this when node will start.
func (*AddrBook) GetAddresses ¶
GetAddresses returns all the addresses currently found within the manager's address cache.
func (*AddrBook) GetAddressesNotConnectedSince ¶
GetAddressesNotConnectedSince returns all the addresses which have not been successfully connected to since `date`.
func (*AddrBook) GetKnownAddressesCache ¶
func (a *AddrBook) GetKnownAddressesCache() []knownAddress
func (*AddrBook) Good ¶
Good marks the given address as good. To be called after a successful connection and version exchange. If the address is unknown to the address manager it will be ignored.
func (*AddrBook) NumAddresses ¶
NumAddresses returns the number of addresses known to the address manager.
func (*AddrBook) Persist ¶
Persist runs a loop that periodically persists address book on disk. If started with canceled context it will persist exactly once.
func (*AddrBook) RemoveAddress ¶
RemoveAddress removes the address from the manager.
func (*AddrBook) WasRecentlyRemoved ¶
WasRecentlyRemoved checks if peer ID was recently removed. If peer is in the cache, then it returns the time when peer was removed. If the peer was not in the cache, returns (nil, false).
type AddrInfo ¶
type AddrInfo struct { IP net.IP ID peer.ID RawAddr string // contains filtered or unexported fields }
AddrInfo stores relevant information for discovery.
func ParseAddrInfo ¶
ParseAddrInfo parses required info from string in multiaddr format.
type Config ¶
type Config struct { // DataDir path to directory where store files DataDir string // NeedAddressThreshold is the number of addresses under which the // address manager will claim to need more addresses. NeedAddressThreshold int // TriedBucketSize is the maximum number of addresses in each tried address bucket. TriedBucketSize int // TriedBucketCount is the number of buckets we split tried addresses over. TriedBucketCount uint64 // NewBucketSize is the maximum number of addresses in each new address bucket. NewBucketSize int // NewBucketCount is the number of buckets that we spread new addresses over. NewBucketCount uint64 // TriedBucketsPerGroup is the number of tried buckets over which an address group will be spread. TriedBucketsPerGroup uint64 // NewBucketsPerGroup is the number of new buckets over which an source address group will be spread. NewBucketsPerGroup uint64 // NewBucketsPerAddress is the number of buckets a frequently seen new address may end up in. NewBucketsPerAddress int // NumMissingDays is the number of days before which we assume an // address has vanished if we have not seen it announced in that long. NumMissingDays time.Duration // NumRetries is the number of tried without a single success before // we assume an address is bad. NumRetries int // MaxFailures is the maximum number of failures we will accept without // a success before considering an address bad. MaxFailures int // MinBadDays is the number of days since the last success before we // will consider evicting an address. MinBadDays time.Duration // GetAddrMax is the most addresses that we will send in response // to a getAddr (in practice the most addresses we will return from a // call to AddressCache()). GetAddrMax int // GetAddrPercent is the percentage of total addresses known that we // will share with a call to AddressCache. GetAddrPercent int // AnchorPeersCount is the number of anchor peers to use when node starting. AnchorPeersCount int // Size of the evicted peers cache. Controls how many evicted peers are remembered. RemovedPeersCacheSize int }
Config is the configuration for the address book.
func DefaultAddressBookConfigWithDataDir ¶
DefaultAddressBookConfigWithDataDir returns a default configuration for the address book.