Documentation ¶
Index ¶
- func AskYesNo() bool
- func CrawlReportToFile(report *CrawlOutput, onlineOnly bool, path string)
- func CreateDirIfNotExists(path string) error
- func IsIPAddressLocal(addr net.IP) bool
- func IsNullSlice(arr [20]byte) bool
- func MonitorReportToFile(report *Output, path string)
- func NodeInfoToID(addrs []*krpc.NodeInfo) []krpc.ID
- func NodeinfoToUdpAddr(nodeInfo *krpc.NodeInfo) net.UDPAddr
- func ParseAddrString(text string) (*krpc.NodeInfo, error)
- func ReadBootstrapListFromFile(path string) ([]*krpc.NodeInfo, error)
- func TargetIsInZone(sourceID [20]byte, targetID [20]byte, zone int) bool
- func UDPToNodeAddr(udp net.UDPAddr) krpc.NodeAddr
- type CrawlOutput
- type CrawlOutputJSON
- type CrawlResult
- type CrawledNode
- type CrawledNodeJSON
- type IPVersion
- type InfoHash
- type KRPCNilResponseError
- type MonitorOutputJSON
- type MonitoredNodeJSON
- type NodeKnows
- type ObservedNode
- type Output
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AskYesNo ¶
func AskYesNo() bool
AskYesNo asks the user to enter "y" or "n". Also recognizes "yes" and "no" in all capitalizations. Anything unrecognized will is equivalent to "n".
func CrawlReportToFile ¶
func CrawlReportToFile(report *CrawlOutput, onlineOnly bool, path string)
func CreateDirIfNotExists ¶
CreateDirIfNotExists creates the directory described in path if it does not exist yet.
func IsIPAddressLocal ¶
IsIPAddressLocal determines whether an IP address is local. Local addresses should(?) not be routed on the open internet and are probably not connectable.
func IsNullSlice ¶
IsNullSlice checks if the bytes of given slice are all null
func MonitorReportToFile ¶
MonitorReportToFile writes the report to the file in path. report is a pointer to an output data structure, currently only generated by the monitor.
func NodeInfoToID ¶
NodeInfoToID extracts each ID from an arry of krpc.NodeInfo and returns the krpc.IDs
func NodeinfoToUdpAddr ¶
NodeinfoToUdpAddr converts a krpc.NodeInfo to a net.UDPAddr
func ParseAddrString ¶
ParseAddrString parses an IP:port address into anacrolix/dht krpc.NodeInfo. This is very useful when connecting to bootstrap nodes.
func ReadBootstrapListFromFile ¶
ReadBootstrapListFromFile parses a file containing bootstrap peers. It assumes a text file with an IP:Port address on each line. It will ignore lines starting with a comment "//"
func TargetIsInZone ¶
TargetIsInZone returns true is targetID has zone many bits in common with sourceID
Types ¶
type CrawlOutput ¶
type CrawlOutput struct { StartDate string EndDate string Nodes map[krpc.ID]*CrawledNode }
CrawlOutput summarises the crawl, i.e. timestamp + collection of nodes we learned
type CrawlOutputJSON ¶
type CrawlOutputJSON struct { StartDate string `json:"start_timestamp"` EndDate string `json:"end_timestamp"` Nodes []*CrawledNodeJSON `json:"found_nodes"` }
CrawledOutputJSON is a collection of CrawledNodeJSON along with a timestamp
type CrawlResult ¶
CrawlResult is a container struct for crawl results... because of go...
type CrawledNode ¶
type CrawledNode struct { NID krpc.ID UDPAddrs net.UDPAddr Reachable bool IPVersion IPVersion Neighbours []krpc.ID Timestamp string }
CrawledNode stores everything we know about a node we have contacted
type CrawledNodeJSON ¶
type CrawledNodeJSON struct { NID krpc.ID `json:"NodeID"` UDPAddrs net.UDPAddr `json:"udpaddrs"` Reachable bool `json:"reachable"` IPVersion string `json:"ip_version"` }
CrawledNodeJSON encodes a node found by the crawler as a JSON string
type IPVersion ¶
type IPVersion uint
IPVersion is the version of an IP address, or unknown for invalid addresses.
func DetermineIPVersion ¶
DetermineIPVersion determines whether the given address is v4, v6, or invalid. This essentially duplicates the logic in (net.IP).To4() and (net.IP).To16() without the special-casing of IPv4-in-IPv6 addresses.
type KRPCNilResponseError ¶
KRPCNilResponseError signals that the KRPC Query returned an error. These could be: 1. A nil pointer in the message 2. Maybe a anacrolix/dht's rate limit error (TBD)
func (*KRPCNilResponseError) Error ¶
func (e *KRPCNilResponseError) Error() string
type MonitorOutputJSON ¶
type MonitorOutputJSON struct { StartDate string `json:"start_timestamp"` EndDate string `json:"end_timestamp"` Nodes []*MonitoredNodeJSON `json:"found_nodes"` }
MonitoredNodeJSON is a collection of MonitoredNodeJSON
type MonitoredNodeJSON ¶
type MonitoredNodeJSON struct { UDPAddrs net.UDPAddr `json:"udpaddrs"` Reachable bool `json:"reachable"` IPVersion string `json:"ip_version"` }
MonitoredNodeJSON holds a DHT Node described by its UDP address, its connectivity status and IP Version encoded as JSON strings
type ObservedNode ¶
ObservedNode contains all the information about a single node during observation