pool: add ban and unban calls once again.
This commit is contained in:
parent
cc4dd23c83
commit
14f2851929
@ -545,7 +545,7 @@ RPC.prototype.ping = co(function* ping(args) {
|
||||
});
|
||||
|
||||
RPC.prototype.setban = co(function* setban(args) {
|
||||
var addr, peer;
|
||||
var addr;
|
||||
|
||||
if (args.help
|
||||
|| args.length < 2
|
||||
@ -555,20 +555,14 @@ RPC.prototype.setban = co(function* setban(args) {
|
||||
}
|
||||
|
||||
addr = toString(args[0]);
|
||||
addr = IP.parseHost(addr, this.network);
|
||||
addr = NetAddress.fromHostname(addr, this.network);
|
||||
|
||||
switch (args[1]) {
|
||||
case 'add':
|
||||
peer = this.pool.peers.get(addr.hostname);
|
||||
if (peer) {
|
||||
peer.ban();
|
||||
break;
|
||||
}
|
||||
this.pool.hosts.ban(addr.host);
|
||||
this.pool.hosts.remove(addr.hostname);
|
||||
this.pool.ban(addr);
|
||||
break;
|
||||
case 'remove':
|
||||
this.pool.hosts.unban(addr.host);
|
||||
this.pool.unban(addr);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ var VerifyResult = errors.VerifyResult;
|
||||
* @exports Peer
|
||||
* @constructor
|
||||
* @param {Pool} pool
|
||||
* @param {NetAddress} addr
|
||||
* @param {NetAddress} address
|
||||
* @param {net.Socket?} socket
|
||||
* @property {Pool} pool
|
||||
* @property {net.Socket?} socket
|
||||
@ -2685,10 +2685,7 @@ Peer.prototype.increaseBan = function increaseBan(score) {
|
||||
*/
|
||||
|
||||
Peer.prototype.ban = function ban() {
|
||||
this.logger.debug('Banning peer (%s).', this.hostname);
|
||||
this.pool.hosts.ban(this.host);
|
||||
this.pool.hosts.remove(this.hostname);
|
||||
this.destroy();
|
||||
this.pool.ban(this.address);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -1668,6 +1668,32 @@ Pool.prototype.removePeer = function removePeer(peer) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Ban peer.
|
||||
* @param {NetAddress} addr
|
||||
*/
|
||||
|
||||
Pool.prototype.ban = function ban(addr) {
|
||||
var peer = this.peers.get(addr.hostname);
|
||||
|
||||
this.logger.debug('Banning peer (%s).', addr.hostname);
|
||||
|
||||
this.hosts.ban(addr.host);
|
||||
this.hosts.remove(addr.hostname);
|
||||
|
||||
if (peer)
|
||||
peer.destroy();
|
||||
};
|
||||
|
||||
/**
|
||||
* Unban peer.
|
||||
* @param {NetAddress} addr
|
||||
*/
|
||||
|
||||
Pool.prototype.unban = function unban(addr) {
|
||||
this.hosts.unban(addr.host);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the spv filter.
|
||||
* @param {Bloom} filter
|
||||
|
||||
Loading…
Reference in New Issue
Block a user