From 3b54fc1af070a72c760370adb20ad9dd6dd682d9 Mon Sep 17 00:00:00 2001 From: Grid Cat Date: Tue, 6 Jul 2021 10:12:12 +0200 Subject: [PATCH] feat: add setban --- src/RPC/Network.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/RPC/Network.ts b/src/RPC/Network.ts index 07fbf14..3429c8b 100644 --- a/src/RPC/Network.ts +++ b/src/RPC/Network.ts @@ -281,4 +281,24 @@ export class Network extends RPCBase { public async ping(): Promise { return this.call('ping'); } + + /** + * add or remove an IP/Subnet from the banned list. + * + * @param {string} subnet - The IP/Subnet (see getpeerinfo for nodes IP) with an optional netmask (default is /32 = single IP) + * @param {('add' | 'remove')} command - 'add' to add an IP/Subnet to the list, 'remove' to remove an IP/Subnet from the list + * @param {number} [banTime] - time in seconds how long (or until when if [absolute] is set) the IP is banned + * (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument) + * @param {number | false} [absolute] - Defaults to false. If set, the bantime must be an absolute timestamp in seconds since epoch (Jan 1 1970 GMT). + * @returns {Promise} + * @memberof Network + */ + public async setBan( + subnet: string, + command: 'add' | 'remove', + banTime?: number, + absolute?: number | false, + ): Promise { + return this.call('setban', subnet, command, banTime, absolute); + } }