Skip to content
Snippets Groups Projects
Commit 277da6d7 authored by Randy Sommerfeld's avatar Randy Sommerfeld
Browse files

More .ini stuff

parent 5a00606b
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -236,19 +236,21 @@ function Read_Config_File() { ...@@ -236,19 +236,21 @@ function Read_Config_File() {
function ini_sections() { function ini_sections() {
this.Info = ini_Info; this.Info = ini_Info;
this.Port = ini_Port; this.Port = ini_Port;
this.ConnectClass = ini_ConnectClass; this.Class = ini_Class;
this.Allow = ini_Allow; this.Allow = ini_Allow;
this.Operator = ini_Operator; this.Operator = ini_Operator;
this.Services = ini_Services; this.Services = ini_Services;
this.Ban = ini_Ban; this.Ban = ini_Ban;
this.Restrict = ini_Restrict; this.Restrict = ini_Restrict;
this.RBL = ini_RBL;
this.Server = ini_Server;
this.Hub = ini_Hub; this.Hub = ini_Hub;
} }
function ini_Info(arg, ini) { function ini_Info(arg, ini) {
ServerName = format("%s.synchro.net", system.qwk_id.toLowerCase()); ServerName = format("%s.synchro.net", system.qwk_id.toLowerCase());
if (ini.Hostname) if (ini.ServerName)
ServerName = ini.Hostname; ServerName = ini.ServerName;
ServerDesc = system.name; ServerDesc = system.name;
if (ini.Description) if (ini.Description)
ServerDesc = ini.Description; ServerDesc = ini.Description;
...@@ -413,7 +415,71 @@ function ini_Ban(arg, ini) { ...@@ -413,7 +415,71 @@ function ini_Ban(arg, ini) {
function ini_Hub(arg, ini) { function ini_Hub(arg, ini) {
HLines.push(new HLine( HLines.push(new HLine(
"*", /* servermask permitted */ "*", /* servermask permitted */
ini.Server /* servername */ ini.Servername /* servername */
));
}
/* Former C:Line and N:Line */
function ini_Server(arg, ini) {
var ircclass, port;
if (!ini.Servername || !ini.Hostname || !ini.Port || !ini.Password || !ini.Class) {
log(LOG_WARNING,format(
"!WARNING Missing information from Server:%s. Section ignored.",
arg
));
return;
}
port = parseInt(ini.Port);
if (port != ini.Port) {
log(LOG_WARNING,format(
"!WARNING Malformed port in Server:%s. Using 6667.",
arg
));
port = 6667;
}
ircclass = parseInt(ini.Class);
if (ircclass != ini.Class) {
log(LOG_WARNING,format(
"!WARNING Malformed IRC Class in Server:%s. Using default class of 0.",
arg
));
ircclass = 0;
}
if (ini_false_true(ini.Hub))
HLines.push(new HLine("*", ini.Servername));
CLines.push(new CLine(
ini.Hostname,
ini.Password,
ini.Servername,
port,
ircclass
));
NLines.push(new NLine(
ini.Hostname,
ini.Password,
ini.Servername,
parse_nline_flags(ini.Flags),
ircclass
));
}
/* Former Q:Lines */
function ini_Restrict(arg, ini) {
if (!ini.Mask) {
log(LOG_WARNING,format(
"!WARNING Missing Mask from Restrict:%s. Section ignored.",
arg
));
return;
}
QLines.push(new QLine(
ini.Mask,
ini.Reason ? ini.Reason : "No reason provided."
)); ));
} }
...@@ -483,9 +549,9 @@ function read_ini_config(conf) { ...@@ -483,9 +549,9 @@ function read_ini_config(conf) {
continue; continue;
if (!ini_true_false(i.enabled) || !ini_true_false(i.Enabled)) if (!ini_true_false(i.enabled) || !ini_true_false(i.Enabled))
continue; continue;
s = i.name.split(":"); s = ini[i].name.split(":");
if (typeof Sections[s[0]] === 'function') if (typeof Sections[s[0]] === 'function')
Sections[s[0]](s[1], i); Sections[s[0]](s[1], ini[i]);
} }
} }
...@@ -522,6 +588,8 @@ function ini_int_min_max(str, min, max, def, desc) { ...@@ -522,6 +588,8 @@ function ini_int_min_max(str, min, max, def, desc) {
} }
function ini_false_true(str) { function ini_false_true(str) {
if (typeof str === "boolean")
return str;
if (typeof str !== "string") if (typeof str !== "string")
return false; return false;
str = str.toUpperCase(); str = str.toUpperCase();
...@@ -536,6 +604,8 @@ function ini_false_true(str) { ...@@ -536,6 +604,8 @@ function ini_false_true(str) {
} }
function ini_true_false(str) { function ini_true_false(str) {
if (typeof str === "boolean")
return str;
if (typeof str !== "string") if (typeof str !== "string")
return true; return true;
str = str.toUpperCase(); str = str.toUpperCase();
......
...@@ -2817,7 +2817,7 @@ function accept_new_socket() { ...@@ -2817,7 +2817,7 @@ function accept_new_socket() {
count = 0; count = 0;
for (i in RBL) { for (i in RBL) {
count++; count++;
sock.send(format(":%s NOTICE * :Performing RBL check %u of %u. Please stand by.", sock.send(format(":%s NOTICE * :Performing RBL check %u of %u. Please stand by.\r\n",
ServerName, ServerName,
count, count,
num_rbls num_rbls
...@@ -2825,7 +2825,7 @@ function accept_new_socket() { ...@@ -2825,7 +2825,7 @@ function accept_new_socket() {
dnsbl_result = check_dnsbl(sock.remote_ip_address, RBL[i]); dnsbl_result = check_dnsbl(sock.remote_ip_address, RBL[i]);
if (dnsbl_result) { if (dnsbl_result) {
sock.send(format( sock.send(format(
":%s 463 * :Your IP address is on an RBL. Connection denied.", ":%s 463 * :Your IP address is on an RBL. Connection denied.\r\n",
ServerName ServerName
)); ));
log(LOG_NOTICE, format( log(LOG_NOTICE, format(
......
...@@ -1277,11 +1277,22 @@ function Reset_Autoconnect(cline, freq) { ...@@ -1277,11 +1277,22 @@ function Reset_Autoconnect(cline, freq) {
if (typeof cline !== 'object') if (typeof cline !== 'object')
throw "Reset_Autoconnect() called without cline object."; throw "Reset_Autoconnect() called without cline object.";
log(LOG_DEBUG,format(
"Reset_Autoconnect() for %s on port %u.",
cline.servername,
cline.port
));
if (cline.next_connect) if (cline.next_connect)
js.clearTimeout(cline.next_connect); js.clearTimeout(cline.next_connect);
if (!cline.port || Servers[cline.servername.toLowerCase()]) if (!cline.port || Servers[cline.servername.toLowerCase()]) {
log(LOG_DEBUG,format(
"Reset_Autoconnect() cancelled for %s because no port or server exists.",
cline.servername
));
return false; return false;
}
cline.next_connect = js.setTimeout( cline.next_connect = js.setTimeout(
Automatic_Server_Connect, Automatic_Server_Connect,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment