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