golint -min_confidence=0.3 .
This commits removes a number of golint warnings. There is a class of warnings which I can't fix due to unsufficient knowledge of the domain at this point. These are listed here: addrmanager.go:907:1: comment on exported method AddrManager.Attempt should be of the form "Attempt ..." addrmanager.go:1048:1: exported function RFC1918 should have comment or be unexported addrmanager.go:1058:1: exported function RFC3849 should have comment or be unexported addrmanager.go:1065:1: exported function RFC3927 should have comment or be unexported addrmanager.go:1073:1: exported function RFC3964 should have comment or be unexported addrmanager.go:1081:1: exported function RFC4193 should have comment or be unexported addrmanager.go:1089:1: exported function RFC4380 should have comment or be unexported addrmanager.go:1097:1: exported function RFC4843 should have comment or be unexported addrmanager.go:1105:1: exported function RFC4862 should have comment or be unexported addrmanager.go:1113:1: exported function RFC6052 should have comment or be unexported addrmanager.go:1121:1: exported function RFC6145 should have comment or be unexported addrmanager.go:1128:1: exported function Tor should have comment or be unexported addrmanager.go:1143:1: exported function Local should have comment or be unexported addrmanager.go:1228:2: exported const InterfacePrio should have comment (or a comment on this block) or be unexported discovery.go:26:2: exported var ErrTorInvalidAddressResponse should have comment or be unexported limits/limits_unix.go:19:1: exported function SetLimits should have comment or be unexported limits/limits_windows.go:7:1: exported function SetLimits should have comment or be unexported util/dropafter/dropafter.go:22:6: exported type ShaHash should have comment or be unexported util/dropafter/dropafter.go:38:2: exported const ArgSha should have comment (or a comment on this block) or be unexported util/dropafter/dropafter.go:128:5: exported var ErrBadShaPrefix should have comment or be unexported util/dropafter/dropafter.go:129:5: exported var ErrBadShaLen should have comment or be unexported util/dropafter/dropafter.go:130:5: exported var ErrBadShaChar should have comment or be unexported util/showblock/showblock.go:24:6: exported type ShaHash should have comment or be unexported util/showblock/showblock.go:46:2: exported const ArgSha should have comment (or a comment on this block) or be unexported util/showblock/showblock.go:163:1: exported function DumpBlock should have comment or be unexported util/showblock/showblock.go:211:5: exported var ErrBadShaPrefix should have comment or be unexported util/showblock/showblock.go:212:5: exported var ErrBadShaLen should have comment or be unexported util/showblock/showblock.go:213:5: exported var ErrBadShaChar should have comment or be unexported
This commit is contained in:
parent
84fa553b65
commit
a0f20007c5
10 changed files with 106 additions and 85 deletions
|
@ -754,7 +754,7 @@ func (a *AddrManager) reset() {
|
|||
}
|
||||
}
|
||||
|
||||
// New returns a new bitcoin address manager.
|
||||
// NewAddrManager returns a new bitcoin address manager.
|
||||
// Use Start to begin processing asynchronous address updates.
|
||||
func NewAddrManager() *AddrManager {
|
||||
am := AddrManager{
|
||||
|
@ -789,7 +789,7 @@ func hostToNetAddress(host string, port uint16, services btcwire.ServiceFlag) (*
|
|||
return nil, err
|
||||
}
|
||||
if len(ips) == 0 {
|
||||
return nil, fmt.Errorf("No addresses found for %s", host)
|
||||
return nil, fmt.Errorf("no addresses found for %s", host)
|
||||
}
|
||||
ip = ips[0]
|
||||
}
|
||||
|
@ -805,9 +805,8 @@ func ipString(na *btcwire.NetAddress) string {
|
|||
// We know now that na.IP is long enogh.
|
||||
base32 := base32.StdEncoding.EncodeToString(na.IP[6:])
|
||||
return strings.ToLower(base32) + ".onion"
|
||||
} else {
|
||||
return na.IP.String()
|
||||
}
|
||||
return na.IP.String()
|
||||
}
|
||||
|
||||
// NetAddressKey returns a string key in the form of ip:port for IPv4 addresses
|
||||
|
@ -1229,7 +1228,7 @@ const (
|
|||
InterfacePrio addressPrio = iota // address of local interface.
|
||||
BoundPrio // Address explicitly bound to.
|
||||
UpnpPrio // External IP discovered from UPnP
|
||||
HttpPrio // Obtained from internet service.
|
||||
HTTPPrio // Obtained from internet service.
|
||||
ManualPrio // provided by --externalip.
|
||||
)
|
||||
|
||||
|
@ -1274,54 +1273,76 @@ func getReachabilityFrom(na, fromna *btcwire.NetAddress) int {
|
|||
Unreachable = 0
|
||||
Default = iota
|
||||
Teredo
|
||||
Ipv6_weak
|
||||
Ipv6Weak
|
||||
Ipv4
|
||||
Ipv6_strong
|
||||
Ipv6Strong
|
||||
Private
|
||||
)
|
||||
|
||||
if !Routable(fromna) {
|
||||
return Unreachable
|
||||
} else if Tor(fromna) {
|
||||
}
|
||||
|
||||
if Tor(fromna) {
|
||||
if Tor(na) {
|
||||
return Private
|
||||
} else if Routable(na) && na.IP.To4() != nil {
|
||||
return Ipv4
|
||||
} else {
|
||||
return Default
|
||||
}
|
||||
} else if RFC4380(fromna) {
|
||||
|
||||
if Routable(na) && na.IP.To4() != nil {
|
||||
return Ipv4
|
||||
}
|
||||
|
||||
return Default
|
||||
}
|
||||
|
||||
if RFC4380(fromna) {
|
||||
if !Routable(na) {
|
||||
return Default
|
||||
} else if RFC4380(na) {
|
||||
return Teredo
|
||||
} else if na.IP.To4() != nil {
|
||||
return Ipv4
|
||||
} else { // ipv6
|
||||
return Ipv6_weak
|
||||
}
|
||||
} else if fromna.IP.To4() != nil {
|
||||
|
||||
if RFC4380(na) {
|
||||
return Teredo
|
||||
}
|
||||
|
||||
if na.IP.To4() != nil {
|
||||
return Ipv4
|
||||
}
|
||||
|
||||
return Ipv6Weak
|
||||
}
|
||||
|
||||
if fromna.IP.To4() != nil {
|
||||
if Routable(na) && na.IP.To4() != nil {
|
||||
return Ipv4
|
||||
}
|
||||
return Default
|
||||
} else /* ipv6 */ {
|
||||
var tunnelled bool
|
||||
// Is our v6 is tunnelled?
|
||||
if RFC3964(na) || RFC6052(na) || RFC6145(na) {
|
||||
tunnelled = true
|
||||
}
|
||||
if !Routable(na) {
|
||||
return Default
|
||||
} else if RFC4380(na) {
|
||||
return Teredo
|
||||
} else if na.IP.To4() != nil {
|
||||
return Ipv4
|
||||
} else if tunnelled {
|
||||
// only prioritise ipv6 if we aren't tunnelling it.
|
||||
return Ipv6_weak
|
||||
}
|
||||
return Ipv6_strong
|
||||
}
|
||||
|
||||
/* ipv6 */
|
||||
var tunnelled bool
|
||||
// Is our v6 is tunnelled?
|
||||
if RFC3964(na) || RFC6052(na) || RFC6145(na) {
|
||||
tunnelled = true
|
||||
}
|
||||
|
||||
if !Routable(na) {
|
||||
return Default
|
||||
}
|
||||
|
||||
if RFC4380(na) {
|
||||
return Teredo
|
||||
}
|
||||
|
||||
if na.IP.To4() != nil {
|
||||
return Ipv4
|
||||
}
|
||||
|
||||
if tunnelled {
|
||||
// only prioritise ipv6 if we aren't tunnelling it.
|
||||
return Ipv6Weak
|
||||
}
|
||||
|
||||
return Ipv6Strong
|
||||
}
|
||||
|
||||
// getBestLocalAddress returns the most appropriate local address that we know
|
||||
|
|
|
@ -41,7 +41,7 @@ type ipTest struct {
|
|||
var naTests = make([]naTest, 0)
|
||||
var ipTests = make([]ipTest, 0)
|
||||
|
||||
func addIpTest(ip string, rfc1918, rfc3849, rfc3927, rfc3964, rfc4193, rfc4380,
|
||||
func addIPTest(ip string, rfc1918, rfc3849, rfc3927, rfc3964, rfc4193, rfc4380,
|
||||
rfc4843, rfc4862, rfc6052, rfc6145, local, valid, routable bool) {
|
||||
nip := net.ParseIP(ip)
|
||||
na := btcwire.NetAddress{
|
||||
|
@ -55,38 +55,38 @@ func addIpTest(ip string, rfc1918, rfc3849, rfc3927, rfc3964, rfc4193, rfc4380,
|
|||
ipTests = append(ipTests, test)
|
||||
}
|
||||
|
||||
func addIpTests() {
|
||||
addIpTest("10.255.255.255", true, false, false, false, false, false,
|
||||
func addIPTests() {
|
||||
addIPTest("10.255.255.255", true, false, false, false, false, false,
|
||||
false, false, false, false, false, true, false)
|
||||
addIpTest("192.168.0.1", true, false, false, false, false, false,
|
||||
addIPTest("192.168.0.1", true, false, false, false, false, false,
|
||||
false, false, false, false, false, true, false)
|
||||
addIpTest("172.31.255.1", true, false, false, false, false, false,
|
||||
addIPTest("172.31.255.1", true, false, false, false, false, false,
|
||||
false, false, false, false, false, true, false)
|
||||
addIpTest("172.32.1.1", false, false, false, false, false, false,
|
||||
addIPTest("172.32.1.1", false, false, false, false, false, false,
|
||||
false, false, false, false, false, true, true)
|
||||
addIpTest("169.254.250.120", false, false, true, false, false, false,
|
||||
addIPTest("169.254.250.120", false, false, true, false, false, false,
|
||||
false, false, false, false, false, true, false)
|
||||
addIpTest("0.0.0.0", false, false, false, false, false, false,
|
||||
addIPTest("0.0.0.0", false, false, false, false, false, false,
|
||||
false, false, false, false, true, false, false)
|
||||
addIpTest("255.255.255.255", false, false, false, false, false, false,
|
||||
addIPTest("255.255.255.255", false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false)
|
||||
addIpTest("127.0.0.1", false, false, false, false, false, false,
|
||||
addIPTest("127.0.0.1", false, false, false, false, false, false,
|
||||
false, false, false, false, true, true, false)
|
||||
addIpTest("fd00:dead::1", false, false, false, false, true, false,
|
||||
addIPTest("fd00:dead::1", false, false, false, false, true, false,
|
||||
false, false, false, false, false, true, false)
|
||||
addIpTest("2001::1", false, false, false, false, false, true,
|
||||
addIPTest("2001::1", false, false, false, false, false, true,
|
||||
false, false, false, false, false, true, true)
|
||||
addIpTest("2001:10:abcd::1:1", false, false, false, false, false, false,
|
||||
addIPTest("2001:10:abcd::1:1", false, false, false, false, false, false,
|
||||
true, false, false, false, false, true, false)
|
||||
addIpTest("fe80::1", false, false, false, false, false, false,
|
||||
addIPTest("fe80::1", false, false, false, false, false, false,
|
||||
false, true, false, false, false, true, false)
|
||||
addIpTest("fe80:1::1", false, false, false, false, false, false,
|
||||
addIPTest("fe80:1::1", false, false, false, false, false, false,
|
||||
false, false, false, false, false, true, true)
|
||||
addIpTest("64:ff9b::1", false, false, false, false, false, false,
|
||||
addIPTest("64:ff9b::1", false, false, false, false, false, false,
|
||||
false, false, true, false, false, true, true)
|
||||
addIpTest("::ffff:abcd:ef12:1", false, false, false, false, false, false,
|
||||
addIPTest("::ffff:abcd:ef12:1", false, false, false, false, false, false,
|
||||
false, false, false, false, false, true, true)
|
||||
addIpTest("::1", false, false, false, false, false, false,
|
||||
addIPTest("::1", false, false, false, false, false, false,
|
||||
false, false, false, false, true, true, false)
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,8 @@ func TestGetAddress(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestIpTypes(t *testing.T) {
|
||||
addIpTests()
|
||||
func TestIPTypes(t *testing.T) {
|
||||
addIPTests()
|
||||
|
||||
t.Logf("Running %d tests", len(ipTests))
|
||||
for _, test := range ipTests {
|
||||
|
|
4
btcd.go
4
btcd.go
|
@ -56,8 +56,8 @@ func btcdMain(serverChan chan<- *server) error {
|
|||
}
|
||||
|
||||
// Write cpu profile if requested.
|
||||
if cfg.CpuProfile != "" {
|
||||
f, err := os.Create(cfg.CpuProfile)
|
||||
if cfg.CPUProfile != "" {
|
||||
f, err := os.Create(cfg.CPUProfile)
|
||||
if err != nil {
|
||||
btcdLog.Errorf("Unable to create cpu profile: %v", err)
|
||||
return err
|
||||
|
|
|
@ -97,7 +97,7 @@ type config struct {
|
|||
DisableCheckpoints bool `long:"nocheckpoints" description:"Disable built-in checkpoints. Don't do this unless you know what you're doing."`
|
||||
DbType string `long:"dbtype" description:"Database backend to use for the Block Chain"`
|
||||
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"`
|
||||
CpuProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"`
|
||||
CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"`
|
||||
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
|
||||
Upnp bool `long:"upnp" description:"Use UPnP to map our listening port outside of NAT"`
|
||||
FreeTxRelayLimit float64 `long:"limitfreerelay" description:"Limit relay of transactions with no transaction fee to the given amount in thousands of bytes per minute"`
|
||||
|
@ -232,7 +232,7 @@ func validDbType(dbType string) bool {
|
|||
// removeDuplicateAddresses returns a new slice with all duplicate entries in
|
||||
// addrs removed.
|
||||
func removeDuplicateAddresses(addrs []string) []string {
|
||||
result := make([]string, 0)
|
||||
var result []string
|
||||
seen := map[string]bool{}
|
||||
for _, val := range addrs {
|
||||
if _, ok := seen[val]; !ok {
|
||||
|
|
26
discovery.go
26
discovery.go
|
@ -17,26 +17,26 @@ const (
|
|||
torNetUnreachable = 0x03
|
||||
torHostUnreachable = 0x04
|
||||
torConnectionRefused = 0x05
|
||||
torTtlExpired = 0x06
|
||||
torTTLExpired = 0x06
|
||||
torCmdNotSupported = 0x07
|
||||
torAddrNotSupported = 0x08
|
||||
)
|
||||
|
||||
var (
|
||||
ErrTorInvalidAddressResponse = errors.New("Invalid address response")
|
||||
ErrTorInvalidProxyResponse = errors.New("Invalid proxy response")
|
||||
ErrTorUnrecognizedAuthMethod = errors.New("Invalid proxy authentication method")
|
||||
ErrTorInvalidAddressResponse = errors.New("invalid address response")
|
||||
ErrTorInvalidProxyResponse = errors.New("invalid proxy response")
|
||||
ErrTorUnrecognizedAuthMethod = errors.New("invalid proxy authentication method")
|
||||
|
||||
torStatusErrors = map[byte]error{
|
||||
torSucceeded: errors.New("Tor succeeded"),
|
||||
torGeneralError: errors.New("Tor general error"),
|
||||
torNotAllowed: errors.New("Tor not allowed"),
|
||||
torNetUnreachable: errors.New("Tor network is unreachable"),
|
||||
torHostUnreachable: errors.New("Tor host is unreachable"),
|
||||
torConnectionRefused: errors.New("Tor connection refused"),
|
||||
torTtlExpired: errors.New("Tor ttl expired"),
|
||||
torCmdNotSupported: errors.New("Tor command not supported"),
|
||||
torAddrNotSupported: errors.New("Tor address type not supported"),
|
||||
torSucceeded: errors.New("tor succeeded"),
|
||||
torGeneralError: errors.New("tor general error"),
|
||||
torNotAllowed: errors.New("tor not allowed"),
|
||||
torNetUnreachable: errors.New("tor network is unreachable"),
|
||||
torHostUnreachable: errors.New("tor host is unreachable"),
|
||||
torConnectionRefused: errors.New("tor connection refused"),
|
||||
torTTLExpired: errors.New("tor TTL expired"),
|
||||
torCmdNotSupported: errors.New("tor command not supported"),
|
||||
torAddrNotSupported: errors.New("tor address type not supported"),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
package limits
|
||||
|
||||
// Plan 9 has no process accounting. no-op here
|
||||
// SetLimits is a no-op on Plan 9 due to the lack of process accounting.
|
||||
func SetLimits() error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -642,7 +642,7 @@ func handleAddNode(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}) (in
|
|||
case "onetry":
|
||||
err = s.server.AddAddr(addr, false)
|
||||
default:
|
||||
err = errors.New("Invalid subcommand for addnode")
|
||||
err = errors.New("invalid subcommand for addnode")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -1160,7 +1160,7 @@ func newServer(listenAddrs []string, db btcdb.Db, netParams *btcnet.Params) (*se
|
|||
}
|
||||
|
||||
if len(listeners) == 0 {
|
||||
return nil, errors.New("No valid listen address")
|
||||
return nil, errors.New("no valid listen address")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ type handlerData struct {
|
|||
|
||||
// Errors used in the various handlers.
|
||||
var (
|
||||
ErrNoDisplayHandler = errors.New("No display handler specified.")
|
||||
ErrNoDisplayHandler = errors.New("no display handler specified")
|
||||
ErrUsage = errors.New("btcctl usage") // Real usage is shown.
|
||||
)
|
||||
|
||||
|
@ -815,7 +815,7 @@ func makeWalletPassphraseChange(args []interface{}) (btcjson.Cmd, error) {
|
|||
func send(cfg *config, msg []byte) (interface{}, error) {
|
||||
var reply btcjson.Reply
|
||||
var err error
|
||||
if cfg.NoTls || (cfg.RPCCert == "" && !cfg.TlsSkipVerify) {
|
||||
if cfg.NoTLS || (cfg.RPCCert == "" && !cfg.TLSSkipVerify) {
|
||||
reply, err = btcjson.RpcCommand(cfg.RPCUser, cfg.RPCPassword,
|
||||
cfg.RPCServer, msg)
|
||||
} else {
|
||||
|
@ -828,7 +828,7 @@ func send(cfg *config, msg []byte) (interface{}, error) {
|
|||
}
|
||||
reply, err = btcjson.TlsRpcCommand(cfg.RPCUser,
|
||||
cfg.RPCPassword, cfg.RPCServer, msg, pem,
|
||||
cfg.TlsSkipVerify)
|
||||
cfg.TLSSkipVerify)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -847,12 +847,12 @@ func send(cfg *config, msg []byte) (interface{}, error) {
|
|||
func sendCommand(cfg *config, command btcjson.Cmd) (interface{}, error) {
|
||||
msg, err := json.Marshal(command)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("CreateMessage: %v", err.Error())
|
||||
return nil, fmt.Errorf("createMessage: %v", err.Error())
|
||||
}
|
||||
|
||||
reply, err := send(cfg, msg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("RpcCommand: %v", err.Error())
|
||||
return nil, fmt.Errorf("rpcCommand: %v", err.Error())
|
||||
}
|
||||
|
||||
return reply, nil
|
||||
|
@ -878,7 +878,7 @@ func commandHandler(cfg *config, command string, data *handlerData, args []strin
|
|||
// specified.
|
||||
convHandlers := data.conversionHandlers
|
||||
if convHandlers != nil && len(convHandlers) < len(args) {
|
||||
return fmt.Errorf("The number of conversion handlers is invalid.")
|
||||
return fmt.Errorf("the number of conversion handlers is invalid")
|
||||
}
|
||||
|
||||
// Convert input parameters per the conversion handlers.
|
||||
|
|
|
@ -31,10 +31,10 @@ type config struct {
|
|||
RPCPassword string `short:"P" long:"rpcpass" default-mask:"-" description:"RPC password"`
|
||||
RPCServer string `short:"s" long:"rpcserver" description:"RPC server to connect to"`
|
||||
RPCCert string `short:"c" long:"rpccert" description:"RPC server certificate chain for validation"`
|
||||
NoTls bool `long:"notls" description:"Disable TLS"`
|
||||
NoTLS bool `long:"notls" description:"Disable TLS"`
|
||||
TestNet3 bool `long:"testnet" description:"Connect to testnet"`
|
||||
SimNet bool `long:"simnet" description:"Connect to the simulation test network"`
|
||||
TlsSkipVerify bool `long:"skipverify" description:"Do not verify tls certificates (not recommended!)"`
|
||||
TLSSkipVerify bool `long:"skipverify" description:"Do not verify tls certificates (not recommended!)"`
|
||||
Wallet bool `long:"wallet" description:"Connect to wallet"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue