btcd: pass user agent black and white lists to server

This commit is contained in:
Conner Fromknecht 2018-01-09 19:13:25 -08:00 committed by Conner Fromknecht
parent 0e073b8058
commit 39592eba78
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
2 changed files with 15 additions and 3 deletions

View File

@ -145,8 +145,8 @@ func btcdMain(serverChan chan<- *server) error {
}
// Create server and start it.
server, err := newServer(cfg.Listeners, db, activeNetParams.Params,
interrupt)
server, err := newServer(cfg.Listeners, cfg.AgentBlacklist,
cfg.AgentWhitelist, db, activeNetParams.Params, interrupt)
if err != nil {
// TODO: this logging could do with some beautifying.
btcdLog.Errorf("Unable to start server on %v: %v",

View File

@ -2552,7 +2552,10 @@ func setupRPCListeners() ([]net.Listener, error) {
// newServer returns a new btcd server configured to listen on addr for the
// bitcoin network type specified by chainParams. Use start to begin accepting
// connections from peers.
func newServer(listenAddrs []string, db database.DB, chainParams *chaincfg.Params, interrupt <-chan struct{}) (*server, error) {
func newServer(listenAddrs, agentBlacklist, agentWhitelist []string,
db database.DB, chainParams *chaincfg.Params,
interrupt <-chan struct{}) (*server, error) {
services := defaultServices
if cfg.NoPeerBloomFilters {
services &^= wire.SFNodeBloom
@ -2576,6 +2579,13 @@ func newServer(listenAddrs []string, db database.DB, chainParams *chaincfg.Param
}
}
if len(agentBlacklist) > 0 {
srvrLog.Infof("User-agent blacklist %s", agentBlacklist)
}
if len(agentWhitelist) > 0 {
srvrLog.Infof("User-agent whitelist %s", agentWhitelist)
}
s := server{
chainParams: chainParams,
addrManager: amgr,
@ -2595,6 +2605,8 @@ func newServer(listenAddrs []string, db database.DB, chainParams *chaincfg.Param
sigCache: txscript.NewSigCache(cfg.SigCacheMaxSize),
hashCache: txscript.NewHashCache(cfg.SigCacheMaxSize),
cfCheckptCaches: make(map[wire.FilterType][]cfHeaderKV),
agentBlacklist: agentBlacklist,
agentWhitelist: agentWhitelist,
}
// Create the transaction and address indexes if needed.