parent
d2d899d157
commit
8968f7dd74
2 changed files with 62 additions and 32 deletions
56
config.go
56
config.go
|
@ -51,33 +51,35 @@ var runServiceCommand func(string) error
|
|||
//
|
||||
// See loadConfig for details on the configuration load process.
|
||||
type config struct {
|
||||
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
|
||||
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
|
||||
DataDir string `short:"b" long:"datadir" description:"Directory to store data"`
|
||||
AddPeers []string `short:"a" long:"addpeer" description:"Add a peer to connect with at startup"`
|
||||
ConnectPeers []string `long:"connect" description:"Connect only to the specified peers at startup"`
|
||||
DisableListen bool `long:"nolisten" description:"Disable listening for incoming connections -- NOTE: Listening is automatically disabled if the --connect or --proxy options are used without also specifying listen interfaces via --listen"`
|
||||
Listeners []string `long:"listen" description:"Add an interface/port to listen for connections (default all interfaces port: 8333, testnet: 18333)"`
|
||||
MaxPeers int `long:"maxpeers" description:"Max number of inbound and outbound peers"`
|
||||
BanDuration time.Duration `long:"banduration" description:"How long to ban misbehaving peers. Valid time units are {s, m, h}. Minimum 1 second"`
|
||||
RPCUser string `short:"u" long:"rpcuser" description:"Username for RPC connections"`
|
||||
RPCPass string `short:"P" long:"rpcpass" default-mask:"-" description:"Password for RPC connections"`
|
||||
RPCListeners []string `long:"rpclisten" description:"Add an interface/port to listen for RPC connections (default port: 8334, testnet: 18334)"`
|
||||
RPCCert string `long:"rpccert" description:"File containing the certificate file"`
|
||||
RPCKey string `long:"rpckey" description:"File containing the certificate key"`
|
||||
DisableRPC bool `long:"norpc" description:"Disable built-in RPC server -- NOTE: The RPC server is disabled by default if no rpcuser/rpcpass is specified"`
|
||||
DisableDNSSeed bool `long:"nodnsseed" description:"Disable DNS seeding for peers"`
|
||||
Proxy string `long:"proxy" description:"Connect via SOCKS5 proxy (eg. 127.0.0.1:9050)"`
|
||||
ProxyUser string `long:"proxyuser" description:"Username for proxy server"`
|
||||
ProxyPass string `long:"proxypass" default-mask:"-" description:"Password for proxy server"`
|
||||
UseTor bool `long:"tor" description:"Specifies the proxy server used is a Tor node"`
|
||||
TestNet3 bool `long:"testnet" description:"Use the test network"`
|
||||
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
|
||||
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"`
|
||||
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"`
|
||||
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
|
||||
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
|
||||
DataDir string `short:"b" long:"datadir" description:"Directory to store data"`
|
||||
AddPeers []string `short:"a" long:"addpeer" description:"Add a peer to connect with at startup"`
|
||||
ConnectPeers []string `long:"connect" description:"Connect only to the specified peers at startup"`
|
||||
DisableListen bool `long:"nolisten" description:"Disable listening for incoming connections -- NOTE: Listening is automatically disabled if the --connect or --proxy options are used without also specifying listen interfaces via --listen"`
|
||||
Listeners []string `long:"listen" description:"Add an interface/port to listen for connections (default all interfaces port: 8333, testnet: 18333)"`
|
||||
MaxPeers int `long:"maxpeers" description:"Max number of inbound and outbound peers"`
|
||||
BanDuration time.Duration `long:"banduration" description:"How long to ban misbehaving peers. Valid time units are {s, m, h}. Minimum 1 second"`
|
||||
RPCUser string `short:"u" long:"rpcuser" description:"Username for RPC connections"`
|
||||
RPCPass string `short:"P" long:"rpcpass" default-mask:"-" description:"Password for RPC connections"`
|
||||
RPCListeners []string `long:"rpclisten" description:"Add an interface/port to listen for RPC connections (default port: 8334, testnet: 18334)"`
|
||||
RPCCert string `long:"rpccert" description:"File containing the certificate file"`
|
||||
RPCKey string `long:"rpckey" description:"File containing the certificate key"`
|
||||
DisableRPC bool `long:"norpc" description:"Disable built-in RPC server -- NOTE: The RPC server is disabled by default if no rpcuser/rpcpass is specified"`
|
||||
DisableDNSSeed bool `long:"nodnsseed" description:"Disable DNS seeding for peers"`
|
||||
ExternalIPs []string `long:"externalip" description:"Add an ip
|
||||
to the list of local addresses we claim to listen on to peers"`
|
||||
Proxy string `long:"proxy" description:"Connect via SOCKS5 proxy (eg. 127.0.0.1:9050)"`
|
||||
ProxyUser string `long:"proxyuser" description:"Username for proxy server"`
|
||||
ProxyPass string `long:"proxypass" default-mask:"-" description:"Password for proxy server"`
|
||||
UseTor bool `long:"tor" description:"Specifies the proxy server used is a Tor node"`
|
||||
TestNet3 bool `long:"testnet" description:"Use the test network"`
|
||||
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
// serviceOptions defines the configuration options for btcd as a service on
|
||||
|
|
38
server.go
38
server.go
|
@ -828,6 +828,28 @@ func newServer(listenAddrs []string, db btcdb.Db, btcnet btcwire.BitcoinNet) (*s
|
|||
return nil, err
|
||||
}
|
||||
listeners = make([]net.Listener, 0, len(ipv4Addrs)+len(ipv6Addrs))
|
||||
discover := true
|
||||
if len(cfg.ExternalIPs) != 0 {
|
||||
discover = false
|
||||
port, err :=
|
||||
strconv.ParseUint(activeNetParams.listenPort,
|
||||
10, 16)
|
||||
if err != nil {
|
||||
srvrLog.Warnf("doubleewteeeff?")
|
||||
}
|
||||
|
||||
for _, sip := range cfg.ExternalIPs {
|
||||
na, err := hostToNetAddress(sip, uint16(port),
|
||||
btcwire.SFNodeNetwork)
|
||||
if err != nil {
|
||||
srvrLog.Warnf("Not adding %s as ip: %v",
|
||||
sip, err)
|
||||
continue
|
||||
}
|
||||
|
||||
amgr.addLocalAddress(na, ManualPrio)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(oga) nonstandard port...
|
||||
if wildcard {
|
||||
|
@ -846,7 +868,9 @@ func newServer(listenAddrs []string, db btcdb.Db, btcnet btcwire.BitcoinNet) (*s
|
|||
}
|
||||
na := btcwire.NewNetAddressIPPort(ip,
|
||||
uint16(port), btcwire.SFNodeNetwork)
|
||||
amgr.addLocalAddress(na, InterfacePrio)
|
||||
if discover {
|
||||
amgr.addLocalAddress(na, InterfacePrio)
|
||||
}
|
||||
}
|
||||
}
|
||||
nowc:
|
||||
|
@ -860,8 +884,10 @@ func newServer(listenAddrs []string, db btcdb.Db, btcnet btcwire.BitcoinNet) (*s
|
|||
}
|
||||
listeners = append(listeners, listener)
|
||||
|
||||
if na, err := deserialiseNetAddress(addr); err == nil {
|
||||
amgr.addLocalAddress(na, BoundPrio)
|
||||
if discover {
|
||||
if na, err := deserialiseNetAddress(addr); err == nil {
|
||||
amgr.addLocalAddress(na, BoundPrio)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -873,8 +899,10 @@ func newServer(listenAddrs []string, db btcdb.Db, btcnet btcwire.BitcoinNet) (*s
|
|||
continue
|
||||
}
|
||||
listeners = append(listeners, listener)
|
||||
if na, err := deserialiseNetAddress(addr); err == nil {
|
||||
amgr.addLocalAddress(na, BoundPrio)
|
||||
if discover {
|
||||
if na, err := deserialiseNetAddress(addr); err == nil {
|
||||
amgr.addLocalAddress(na, BoundPrio)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue