You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.9 KiB
65 lines
1.9 KiB
9 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
"time"
|
||
|
|
||
|
"github.com/btcsuite/btcd/wire"
|
||
|
)
|
||
|
|
||
9 years ago
|
// Node struct contains details on one client
|
||
|
type node struct {
|
||
9 years ago
|
na *wire.NetAddress // holds ip address & port details
|
||
|
lastConnect time.Time // last time we sucessfully connected to this client
|
||
|
lastTry time.Time // last time we tried to connect to this client
|
||
|
crawlStart time.Time // time when we started the last crawl
|
||
|
statusTime time.Time // time the status was last updated
|
||
|
crawlActive bool // are we currently crawling this client
|
||
|
connectFails uint32 // number of times we have failed to connect to this client
|
||
9 years ago
|
statusStr string // string with last error or OK details
|
||
|
version int32 // remote client protocol version
|
||
|
strVersion string // remote client user agent
|
||
|
services wire.ServiceFlag // remote client supported services
|
||
9 years ago
|
lastBlock int32 // remote client last block
|
||
|
status uint32 // rg,cg,wg,ng
|
||
|
rating uint32 // if it reaches 100 then we mark them statusNG
|
||
|
nonstdIP net.IP // if not using the default port then this is the encoded ip containing the actual port
|
||
|
dnsType uint32 // what dns type this client is
|
||
9 years ago
|
}
|
||
9 years ago
|
|
||
|
// status2str will return the string description of the status
|
||
9 years ago
|
func (nd node) status2str() string {
|
||
|
switch nd.status {
|
||
9 years ago
|
case statusRG:
|
||
|
return "statusRG"
|
||
|
case statusCG:
|
||
|
return "statusCG"
|
||
|
case statusWG:
|
||
|
return "statusWG"
|
||
|
case statusNG:
|
||
|
return "statusNG"
|
||
|
default:
|
||
|
return "Unknown"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// dns2str will return the string description of the dns type
|
||
9 years ago
|
func (nd node) dns2str() string {
|
||
|
switch nd.dnsType {
|
||
9 years ago
|
case dnsV4Std:
|
||
9 years ago
|
return "v4 standard port"
|
||
9 years ago
|
case dnsV4Non:
|
||
9 years ago
|
return "v4 non-standard port"
|
||
9 years ago
|
case dnsV6Std:
|
||
9 years ago
|
return "v6 standard port"
|
||
9 years ago
|
case dnsV6Non:
|
||
9 years ago
|
return "v6 non-standard port"
|
||
|
default:
|
||
|
return "Unknown DNS Type"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
|
||
|
*/
|