From 7b4a5b26a5e2959b9027712cdac3a596ca9adc3d Mon Sep 17 00:00:00 2001 From: Randy Sommerfeld <cyan@synchro.net> Date: Tue, 14 Nov 2023 08:43:47 +0700 Subject: [PATCH] Add GoodResponses= and BadResponses= in [RBL] .ini section --- exec/load/ircd/config.js | 8 +++++++- exec/load/ircd/core.js | 27 ++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/exec/load/ircd/config.js b/exec/load/ircd/config.js index 02a92f9d9f..22692429a5 100644 --- a/exec/load/ircd/config.js +++ b/exec/load/ircd/config.js @@ -548,7 +548,7 @@ function ini_RBL(arg, ini) { )); return; } - RBL.push(ini.Hostname); + RBL.push(new RBL_Config_Object(ini.Hostname, ini.GoodResponses, ini.BadResponses)); } function load_config_defaults() { @@ -865,3 +865,9 @@ function ZLine(ipmask,reason) { this.ipmask = ipmask; this.reason = reason; } + +function RBL_Config_Object(hostname, good, bad) { + this.hostname = hostname; + this.good = this.good ? good.split(",") : ""; + this.bad = this.bad ? bad.split(",") : ""; +} diff --git a/exec/load/ircd/core.js b/exec/load/ircd/core.js index 783b2fb030..81c5cf6754 100644 --- a/exec/load/ircd/core.js +++ b/exec/load/ircd/core.js @@ -2803,6 +2803,27 @@ function IRCClient_finalize_server_connect(states) { this.synchronize(); } +function RBL_Listed_According_to_Config(rbl_object, dns_reply) { + var i; + + if (rbl_object.good) { + for (i in rbl_object.good) { + if (dns_reply == rbl_object.good[i]) + return false; + } + } else if (rbl_object.bad) { + for (i in rbl_object.bad) { + if (dns_reply == rbl_object.bad[i]) + return true; + } + } else if (dns_reply) { + return true; + } + + /* not listed by default */ + return false; +} + function accept_new_socket() { var unreg_obj, id, sock, num_rbls, count, i, dnsbl_result; @@ -2860,8 +2881,8 @@ function accept_new_socket() { count, num_rbls )); - dnsbl_result = check_dnsbl(sock.remote_ip_address, RBL[i]); - if (dnsbl_result) { + dnsbl_result = check_dnsbl(sock.remote_ip_address, RBL[i].hostname); + if (RBL_Listed_According_to_Config(RBL[i], dnsbl_result)) { sock.send(format( ":%s 463 * :Your IP address is on an RBL. Connection denied.\r\n", ServerName @@ -2870,7 +2891,7 @@ function accept_new_socket() { "DNS-Blocked IP address %s resolves to %s from RBL %s", sock.remote_ip_address, dnsbl_result, - RBL[i] + RBL[i].hostname )); sock.close(); return false; -- GitLab