Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

...
 
Commits (2)
This diff is collapsed.
// $Id: ircd_channel.js,v 1.34 2019/08/06 20:44:39 deuce Exp $
//
// ircd_channel.js
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details:
// http://www.gnu.org/licenses/gpl.txt
//
// Synchronet IRC Daemon as per RFC 1459, link compatible with Bahamut 1.4
//
// Copyright 2003-2009 Randolph Erwin Sommerfeld <sysop@rrx.ca>
//
// ** Everything related to channels and their operation.
//
////////// Constants / Defines //////////
const CHANNEL_REVISION = "$Revision: 1.34 $".split(' ')[1];
/*
ircd/channel.js
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details:
https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
Everything related to channels in the IRCd and their operation.
Copyright 2003-2021 Randy Sommerfeld <cyan@synchro.net>
*/
const CHANMODE_NONE =(1<<0); // NONE
const CHANMODE_BAN =(1<<1); // b
......@@ -87,8 +83,11 @@ function Channel(nam) {
////////// Functions //////////
function ChanMode_tweaktmpmode(tmp_bit,add) {
if (!this.chan.modelist[CHANMODE_OP][this.user.id] &&
!this.user.server && !this.user.uline && !(this.mode&USERMODE_ADMIN)) {
if ( !this.chan.modelist[CHANMODE_OP][this.user.id]
&& !this.user.server
&& !this.user.uline
&& !(this.mode&USERMODE_ADMIN)
) {
this.user.numeric482(this.chan.nam);
return 0;
}
......@@ -102,15 +101,17 @@ function ChanMode_tweaktmpmode(tmp_bit,add) {
}
function ChanMode_tweaktmpmodelist(tmp_bit,add,arg) {
if (!this.chan.modelist[CHANMODE_OP][this.user.id] &&
!this.user.server && !this.user.uline && !(this.mode&USERMODE_ADMIN)) {
if ( !this.chan.modelist[CHANMODE_OP][this.user.id]
&& !this.user.server
&& !this.user.uline
&& !(this.mode&USERMODE_ADMIN)
) {
this.user.numeric482(this.chan.nam);
return 0;
}
for (lstitem in this.tmplist[tmp_bit][add]) {
// Is this argument in our list for this mode already?
if (this.tmplist[tmp_bit][add][lstitem].toUpperCase() ==
arg.toUpperCase())
if (this.tmplist[tmp_bit][add][lstitem].toUpperCase() == arg.toUpperCase())
return 0;
}
// It doesn't exist on our mode, push it in.
......@@ -122,8 +123,7 @@ function ChanMode_tweaktmpmodelist(tmp_bit,add,arg) {
else
oadd = true;
for (x in this.tmplist[tmp_bit][oadd]) {
if (this.tmplist[tmp_bit][oadd][x].toUpperCase() ==
arg.toUpperCase()) {
if (this.tmplist[tmp_bit][oadd][x].toUpperCase() == arg.toUpperCase()) {
delete this.tmplist[tmp_bit][oadd][x];
return 0;
}
......@@ -137,13 +137,14 @@ function ChanMode_affect_mode_list(list_bit) {
tmp_nick = Users[this.tmplist[list_bit][add][z].toUpperCase()];
if (!tmp_nick)
tmp_nick = search_nickbuf(this.tmplist[list_bit][add][z]);
if (tmp_nick && (add=="true") &&
!this.chan.modelist[list_bit][tmp_nick.id]) {
if (tmp_nick && (add=="true") && !this.chan.modelist[list_bit][tmp_nick.id]) {
this.addmodes += MODE[list_bit].modechar;
this.addmodeargs += " " + tmp_nick.nick;
this.chan.modelist[list_bit][tmp_nick.id] = tmp_nick;
} else if (tmp_nick && (add=="false") &&
this.chan.modelist[list_bit][tmp_nick.id]) {
} else if (tmp_nick
&& (add=="false")
&& this.chan.modelist[list_bit][tmp_nick.id]
) {
this.delmodes += MODE[list_bit].modechar;
this.delmodeargs += " " + tmp_nick.nick;
delete this.chan.modelist[list_bit][tmp_nick.id];
......@@ -382,14 +383,24 @@ function IRCClient_set_chanmode(chan,modeline,bounce_modes) {
// later display. We also play with the channel bit switches here.
for (cm in MODE) {
if (MODE[cm].state) {
if ((cm&CHANMODE_KEY) && (cmode.addbits&CHANMODE_KEY)&&
cmode.state_arg[cm] && chan.arg[cm] &&
!this.server && !this.parent && !bounce_modes) {
this.numeric(467, chan.nam +
" :Channel key already set.");
} else if ((cmode.addbits&cm) && (!(chan.mode&cm) ||
((cm==CHANMODE_LIMIT)&&(chan.arg[CHANMODE_LIMIT]!=
cmode.state_arg[CHANMODE_LIMIT])) ) ) {
if ( (cm&CHANMODE_KEY)
&& (cmode.addbits&CHANMODE_KEY)
&& cmode.state_arg[cm]
&& chan.arg[cm]
&& !this.server
&& !this.parent
&& !bounce_modes
) {
this.numeric(467, format("%s :Channel key already set.", chan.nam));
} else if ( (cmode.addbits&cm)
&& (
!(chan.mode&cm)
|| (
(cm==CHANMODE_LIMIT)
&&(chan.arg[CHANMODE_LIMIT]!=cmode.state_arg[CHANMODE_LIMIT])
)
)
) {
cmode.addmodes += MODE[cm].modechar;
chan.mode |= cm;
if (MODE[cm].args && MODE[cm].state) {
......@@ -413,7 +424,13 @@ function IRCClient_set_chanmode(chan,modeline,bounce_modes) {
// we simply display a list of bans on the channel.
if (cmode.addbits&CHANMODE_BAN) {
for (the_ban in chan.modelist[CHANMODE_BAN]) {
this.numeric(367, chan.nam + " " + chan.modelist[CHANMODE_BAN][the_ban] + " " + chan.bancreator[the_ban] + " " + chan.bantime[the_ban]);
this.numeric(367, format(
"%s %s %s %s",
chan.nam,
chan.modelist[CHANMODE_BAN][the_ban],
chan.bancreator[the_ban],
chan.bantime[the_ban]
));
}
this.numeric(368, chan.nam + " :End of Channel Ban List.");
}
......@@ -422,8 +439,10 @@ function IRCClient_set_chanmode(chan,modeline,bounce_modes) {
for (z in cmode.tmplist[CHANMODE_BAN][true]) { // +b
var set_ban = create_ban_mask(
cmode.tmplist[CHANMODE_BAN][add][z]);
if ((chan.count_modelist(CHANMODE_BAN) >= max_bans) &&
!this.server && !this.parent) {
if ( (chan.count_modelist(CHANMODE_BAN) >= max_bans)
&& !this.server
&& !this.parent
) {
this.numeric(478, chan.nam + " " + set_ban + " :" +
"Cannot add ban, channel's ban list is full.");
} else if (set_ban && !chan.isbanned(set_ban)) {
......@@ -437,8 +456,9 @@ function IRCClient_set_chanmode(chan,modeline,bounce_modes) {
for (z in cmode.tmplist[CHANMODE_BAN][false]) { // -b
for (ban in chan.modelist[CHANMODE_BAN]) {
if (cmode.tmplist[CHANMODE_BAN][false][z].toUpperCase()
== chan.modelist[CHANMODE_BAN][ban].toUpperCase()) {
if ( cmode.tmplist[CHANMODE_BAN][false][z].toUpperCase()
== chan.modelist[CHANMODE_BAN][ban].toUpperCase()
) {
cmode.delmodes += "b";
cmode.delmodeargs += " " +
cmode.tmplist[CHANMODE_BAN][false][z];
......@@ -559,8 +579,9 @@ function IRCClient_do_join(chan_name,join_key) {
+ " :Cannot join channel (+i: invite only)");
return 0;
}
if ((chan.mode&CHANMODE_LIMIT) && (true_array_len(chan.users)
>= chan.arg[CHANMODE_LIMIT]) ) {
if ( (chan.mode&CHANMODE_LIMIT)
&& (true_array_len(chan.users) >= chan.arg[CHANMODE_LIMIT])
) {
this.numeric("471", chan.nam
+ " :Cannot join channel (+l: channel is full)");
return 0;
......@@ -592,10 +613,13 @@ function IRCClient_do_join(chan_name,join_key) {
}
}
if (chan_name[0] != "&") {
this.bcast_to_servers_raw(":" + this.nick + " SJOIN "
+ chan.created + " " + chan.nam,BAHAMUT);
this.bcast_to_servers_raw(":" + this.nick + " JOIN "
+ chan.nam + " " + chan.created,DREAMFORGE);
this.bcast_to_servers_raw(
format(":%s SJOIN %s %s",
this.nick,
chan.created,
chan.nam
)
);
}
} else {
// create a new channel
......@@ -610,16 +634,16 @@ function IRCClient_do_join(chan_name,join_key) {
chan.modelist[CHANMODE_OP][this.id] = this;
}
if (chan_name[0] != "&") {
this.bcast_to_servers_raw(":" + servername + " SJOIN "
+ chan.created + " " + chan.nam + " "
+ chan.chanmode() + " :" + create_op + this.nick,BAHAMUT);
this.bcast_to_servers_raw(":" + this.nick + " JOIN "
+ chan.nam,DREAMFORGE);
if (create_op) {
server_bcast_to_servers(":" + servername + " MODE "
+ chan.nam + " +o " + this.nick + " "
+ chan.created,DREAMFORGE);
}
this.bcast_to_servers_raw(
format(":%s SJOIN %s %s %s :%s%s",
servername,
chan.created,
chan.nam,
chan.chanmode(),
create_op,
this.nick
)
);
}
}
if (this.invited.toUpperCase() == chan.nam.toUpperCase())
......
/*
ircd/config.js
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details:
https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
Anything that handles manipulating the IRCd configuration.
Copyright 2003-2021 Randy Sommerfeld <cyan@synchro.net>
*/
function parse_nline_flags(flags) {
var nline_flags = 0;
for(thisflag in flags) {
switch(flags[thisflag]) {
case "q":
nline_flags |= NLINE_CHECK_QWKPASSWD;
break;
case "w":
nline_flags |= NLINE_IS_QWKMASTER;
break;
case "k":
nline_flags |= NLINE_CHECK_WITH_QWKMASTER;
break;
default:
log(LOG_WARNING,"!WARNING Unknown N:Line flag '"
+ flags[thisflag] + "' in config.");
break;
}
}
return nline_flags;
}
function parse_oline_flags(flags) {
var oline_flags = 0;
for(thisflag in flags) {
switch(flags[thisflag]) {
case "r":
oline_flags |= OLINE_CAN_REHASH;
break;
case "R":
oline_flags |= OLINE_CAN_RESTART;
break;
case "D":
oline_flags |= OLINE_CAN_DIE;
break;
case "g":
oline_flags |= OLINE_CAN_GLOBOPS;
break;
case "w":
oline_flags |= OLINE_CAN_WALLOPS;
break;
case "l":
oline_flags |= OLINE_CAN_LOCOPS;
break;
case "c":
oline_flags |= OLINE_CAN_LSQUITCON;
break;
case "C":
oline_flags |= OLINE_CAN_GSQUITCON;
break;
case "k":
oline_flags |= OLINE_CAN_LKILL;
break;
case "K":
oline_flags |= OLINE_CAN_GKILL;
break;
case "b":
oline_flags |= OLINE_CAN_KLINE;
break;
case "B":
oline_flags |= OLINE_CAN_UNKLINE;
break;
case "n":
oline_flags |= OLINE_CAN_LGNOTICE;
break;
case "N":
oline_flags |= OLINE_CAN_GGNOTICE;
break;
case "u":
oline_flags |= OLINE_CAN_UMODEC;
break;
case "A":
oline_flags |= OLINE_IS_ADMIN;
break;
case "a":
case "f":
case "F":
break; // All reserved for future use.
case "s":
oline_flags |= OLINE_CAN_CHATOPS;
break;
case "S":
oline_flags |= OLINE_CHECK_SYSPASSWD;
break;
case "x":
case "X":
oline_flags |= OLINE_CAN_DEBUG;
break;
case "O":
oline_flags |= OLINE_IS_GOPER;
oline_flags |= OLINE_CAN_GSQUITCON;
oline_flags |= OLINE_CAN_GKILL;
oline_flags |= OLINE_CAN_GGNOTICE;
oline_flags |= OLINE_CAN_CHATOPS;
case "o":
oline_flags |= OLINE_CAN_REHASH;
oline_flags |= OLINE_CAN_GLOBOPS;
oline_flags |= OLINE_CAN_WALLOPS;
oline_flags |= OLINE_CAN_LOCOPS;
oline_flags |= OLINE_CAN_LSQUITCON;
oline_flags |= OLINE_CAN_LKILL;
oline_flags |= OLINE_CAN_KLINE;
oline_flags |= OLINE_CAN_UNKLINE;
oline_flags |= OLINE_CAN_LGNOTICE;
oline_flags |= OLINE_CAN_UMODEC;
break;
default:
log(LOG_WARNING,"!WARNING Unknown O:Line flag '"
+ flags[thisflag] + "' in config.");
break;
}
}
return oline_flags;
}
function read_config_file() {
/* All of these variables are global. */
Admin1 = "";
Admin2 = "";
Admin3 = "";
CLines = new Array;
HLines = new Array;
ILines = new Array;
KLines = new Array;
NLines = new Array;
OLines = new Array;
PLines = new Array;
QLines = new Array;
ULines = new Array;
diepass = "";
restartpass = "";
YLines = new Array;
ZLines = new Array;
/* End of global variables */
var fname="";
if (config_filename && config_filename.length) {
if(config_filename.indexOf('/')>=0 || config_filename.indexOf('\\')>=0)
fname=config_filename;
else
fname=system.ctrl_dir + config_filename;
} else {
fname=system.ctrl_dir + "ircd." + system.local_host_name + ".conf";
if(!file_exists(fname))
fname=system.ctrl_dir + "ircd." + system.host_name + ".conf";
if(!file_exists(fname))
fname=system.ctrl_dir + "ircd.conf";
}
log(LOG_INFO,"Trying to read configuration from: " + fname);
var file_handle = new File(fname);
if (file_handle.open("r")) {
if (fname.substr(fname.length-3,3) == "ini")
read_ini_config(file_handle);
else
read_conf_config(file_handle);
file_handle.close();
} else {
log("Couldn't open configuration file! Proceeding with defaults.");
}
time_config_read = time();
scan_for_klined_clients();
YLines[0] = new YLine(120,600,1,5050000); // default irc class
}
function ini_sections() {
this.IRCdInfo = ini_IRCdInfo;
this.Port = ini_Port;
this.ConnectClass = ini_ConnectClass;
this.Allow = ini_Allow;
this.Operator = ini_Operator;
this.Services = ini_Services;
this.Ban = ini_Ban;
this.Restrict = ini_Restrict;
this.Hub = ini_Hub;
}
function ini_IRCdInfo(arg, ini) {
log("ircdinfo " + ini.Hostname);
servername=ini.Hostname;
serverdesc=ini.Info;
Admin1=ini.Admin1;
Admin2=ini.Admin2;
Admin3=ini.Admin3;
}
/* Former M:Line */
function ini_Port(arg, ini) {
mline_port = arg;
}
/* Former Y:Line */
function ini_ConnectClass(arg, ini) {
YLines[arg] = new YLine(
parseInt(ini.PingFrequency),
parseInt(ini.ConnectFrequency),
parseInt(ini.Maximum),
parseInt(ini.SendQ)
);
}
/* Former I:Line */
function ini_Allow(arg, ini) {
ILines[arg] = new ILine(
ini.Mask,
null, /* password */
ini.Mask, /* hostmask */
null, /* port */
0 /* irc class */
);
}
/* Former O:Line */
function ini_Operator(arg, ini) {
}
/* Former U:Line */
function ini_Services(arg, ini) {
}
/* Former K:Line & Z:Line */
function ini_Ban(arg, ini) {
}
function ini_Restrict(arg, ini) {
}
/* Former H:Line */
function ini_Hub(arg, ini) {
HLines.push(new HLine(
"*", /* servermask permitted */
arg /* servername */
));
}
function read_ini_config(conf) {
var ini = conf.iniGetAllObjects();
var split;
var section_name;
var section_arg;
var Sections = new ini_sections();
for each(var i in ini) {
split = i.name.split(":");
section_name = split[0];
section_arg = split[1];
if (typeof Sections[section_name] === 'function')
Sections[section_name](section_arg, i);
}
}
function read_conf_config(conf) {
function fancy_split(line) {
var ret = [];
var i;
var s = 0;
var inb = false;
var str;
for (i = 0; i < line.length; i++) {
if (line[i] == ':') {
if (inb)
continue;
if (i > 0 && line[i-1] == ']')
str = line.slice(s, i-1);
else
str = line.slice(s, i);
ret.push(str);
s = i + 1;
}
else if (!inb && line[i] == '[' && s == i) {
inb = true;
s = i + 1;
}
else if (line[i] == ']' && (i+1 == line.length || line[i+1] == ':')) {
inb = false;
}
}
if (s < line.length) {
if (i > 0 && line[i-1] == ']')
str = line.slice(s, i-1);
else
str = line.slice(s, i);
ret.push(str);
}
return ret;
}
while (!conf.eof) {
var conf_line = conf.readln();
if ((conf_line != null) && conf_line.match("[:]")) {
var arg = fancy_split(conf_line);
for(argument in arg) {
arg[argument]=arg[argument].replace(
/SYSTEM_HOST_NAME/g,system.host_name);
arg[argument]=arg[argument].replace(
/SYSTEM_NAME/g,system.name);
if (typeof system.qwk_id !== "undefined") {
arg[argument]=arg[argument].replace(
/SYSTEM_QWKID/g,system.qwk_id.toLowerCase()
);
}
arg[argument]=arg[argument].replace(
/VERSION_NOTICE/g,system.version_notice);
}
switch (conf_line[0].toUpperCase()) {
case "A":
if (!arg[3])
break;
Admin1 = arg[1];
Admin2 = arg[2];
Admin3 = arg[3];
break;
case "C":
if (!arg[5])
break;
CLines.push(new CLine(arg[1],arg[2],arg[3],arg[4],
parseInt(arg[5]) ));
break;
case "H":
if (!arg[3])
break;
HLines.push(new HLine(arg[1],arg[3]));
break;
case "I":
if (!arg[5])
break;
ILines.push(new ILine(arg[1],arg[2],arg[3],arg[4],
arg[5]));
break;
case "K":
if (!arg[2])
break;
var kline_mask = create_ban_mask(arg[1],true);
if (!kline_mask) {
log(LOG_WARNING,"!WARNING Invalid K:Line ("
+ arg[1] + ")");
break;
}
KLines.push(new KLine(kline_mask,arg[2],"K"));
break;
case "M":
if (!arg[3])
break;
servername = arg[1];
serverdesc = arg[3];
mline_port = parseInt(arg[4]);
break;
case "N":
if (!arg[5])
break;
NLines.push(new NLine(arg[1],arg[2],arg[3],
parse_nline_flags(arg[4]),arg[5]) );
break;
case "O":
if (!arg[5])
break;
OLines.push(new OLine(arg[1],arg[2],arg[3],
parse_oline_flags(arg[4]),parseInt(arg[5]) ));
break;
case "P":
PLines.push(parseInt(arg[4]));
break;
case "Q":
if (!arg[3])
break;
QLines.push(new QLine(arg[3],arg[2]));
break;
case "U":
if (!arg[1])
break;
ULines.push(arg[1]);
break;
case "X":
diepass = arg[1];
restartpass = arg[2];
break;
case "Y":
if (!arg[5])
break;
YLines[parseInt(arg[1])] = new YLine(parseInt(arg[2]),
parseInt(arg[3]),parseInt(arg[4]),parseInt(arg[5]));
break;
case "Z":
if (!arg[2])
break;
ZLines.push(new ZLine(arg[1],arg[2]));
break;
case "#":
case ";":
default:
break;
}
}
}
}
This diff is collapsed.
// $Id: ircd_unreg.js,v 1.53 2020/04/04 03:34:03 deuce Exp $
//
// ircd_unreg.js
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details:
// http://www.gnu.org/licenses/gpl.txt
//
// Synchronet IRC Daemon as per RFC 1459, link compatible with Bahamut 1.4
//
// Copyright 2003-2010 Randolph Erwin Sommerfeld <sysop@rrx.ca>
//
// ** Handle unregistered clients.
//
/*
const UNREG_REVISION = "$Revision: 1.53 $".split(' ')[1];
ircd/unregistered.js
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details:
https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
How unregistered clients are handled in the IRCd.
Copyright 2003-2021 Randy Sommerfeld <cyan@synchro.net>
*/
////////// Objects //////////
function Unregistered_Client(id,socket) {
////////// VARIABLES
// Bools/Flags that change depending on connection state.
this.pinged = false; // Sent PING?
this.local = true; // FIXME: this is redundant.
this.criteria_met = false; // Have we met registration criteria?
this.pinged = false; // Sent PING?
this.local = true; // FIXME: this is redundant.
this.criteria_met = false; // Have we met registration criteria?
// Variables containing user/server information as we receive it.
this.id = id;
this.nick = "*";
......@@ -48,7 +45,6 @@ function Unregistered_Client(id,socket) {
////////// FUNCTIONS
// Functions we use to control clients (specific)
this.work = Unregistered_Commands;
// this.JSON_Unregistered_Commands = JSON_Unregistered_Commands;
this.IRC_Unregistered_Commands = IRC_Unregistered_Commands;
this.quit = Unregistered_Quit;
this.check_timeout = IRCClient_check_timeout;
......@@ -73,13 +69,17 @@ function Unregistered_Client(id,socket) {
Local_Sockets[id] = socket.descriptor;
Local_Sockets_Map[id] = this;
rebuild_socksel_array = true;
log(format("%04u",socket.descriptor)
+ " Accepted new connection: " + this.ip
+ " port " + socket.remote_port);
if ((this.ip.slice(0,4) == "127.") ||
(this.ip.slice(0,3) == "10.") ||
(this.ip.slice(0,8) == "192.168.") ||
(this.ip.slice(0,7) == "172.16." )) {
log(format("%04u Accepted new connection: %s port %s",
socket.descriptor,
this.ip,
socket.remote_port
));
if ( (this.ip.slice(0,4) == "127.")
|| (this.ip.slice(0,3) == "10.")
|| (this.ip.slice(0,8) == "192.168.")
|| (this.ip.slice(0,7) == "100.64.")
|| (this.ip.slice(0,7) == "172.16." )
) {
this.hostname = servername;
this.pending_resolve_time = false;
} else {
......@@ -99,7 +99,7 @@ function Unregistered_Commands(cmdline) {
cmdline = cmdline.slice(1);
if (debug)
log(LOG_DEBUG,"[UNREG]: " + cmdline);
log("[UNREG]: " + cmdline);
this.IRC_Unregistered_Commands(cmdline);
}
......@@ -128,7 +128,7 @@ function IRC_Unregistered_Commands(cmdline) {
return 0;
var legal_command = true; /* For tracking STATS M */
switch(command) {
case "PING":
if (!cmd[1]) {
......@@ -137,6 +137,7 @@ function IRC_Unregistered_Commands(cmdline) {
}
this.rawout("PONG " + servername + " :" + IRC_string(cmdline,1));
break;
case "CAP":
case "CAPAB":
break; // Silently ignore, for now.
case "NICK":
......@@ -166,23 +167,25 @@ function IRC_Unregistered_Commands(cmdline) {
break;
}
if (Servers[cmd[1].toLowerCase()]) {
if (parseInt(cmd[2]) < 2)
if (parseInt(cmd[2]) < 2)
this.quit("Server already exists.");
return 0;
}
var this_nline = 0;
var qwk_slave = false;
var qwkid = cmd[1].slice(0,cmd[1].indexOf(".")).toUpperCase();
if (parseInt(cmd[2]) < 2) {
if (parseInt(cmd[2]) < 2) {
for (nl in NLines) {
if ((NLines[nl].flags&NLINE_CHECK_QWKPASSWD) &&
wildmatch(cmd[1],NLines[nl].servername)) {
if ( (NLines[nl].flags&NLINE_CHECK_QWKPASSWD)
&& wildmatch(cmd[1],NLines[nl].servername)
) {
if (check_qwk_passwd(qwkid,this.password)) {
this_nline = NLines[nl];
break;
}
} else if ((NLines[nl].flags&NLINE_CHECK_WITH_QWKMASTER) &&
wildmatch(cmd[1],NLines[nl].servername)) {
} else if ( (NLines[nl].flags&NLINE_CHECK_WITH_QWKMASTER)
&& wildmatch(cmd[1],NLines[nl].servername)
) {
for (qwkm_nl in NLines) {
if (NLines[qwkm_nl].flags&NLINE_IS_QWKMASTER) {
var qwk_master = searchbyserver(NLines[qwkm_nl].servername);
......@@ -190,24 +193,33 @@ function IRC_Unregistered_Commands(cmdline) {
this.quit("No QWK master available for authorization.");
return 0;
} else {
qwk_master.rawout(":" + servername + " PASS " + this.password + " :" + qwkid + " QWK");
qwk_master.rawout(format(
":%s PASS %s :%s QWK",
servername,
this.password,
qwkid
));
qwk_slave = true;
}
}
}
} else if ((NLines[nl].password == this.password) &&
(wildmatch(cmd[1],NLines[nl].servername))
) {
this_nline = NLines[nl];
break;
} else if ( (NLines[nl].password == this.password)
&& (wildmatch(cmd[1],NLines[nl].servername))
) {
this_nline = NLines[nl];
break;
}
}
}
if ( (!this_nline ||
( (this_nline.password == "*") && !this.outgoing
&& !(this_nline.flags&NLINE_CHECK_QWKPASSWD) )
) && !qwk_slave) {
if (parseInt(cmd[2]) < 2)
if ( !qwk_slave
&& ( !this_nline
|| ( (this_nline.password == "*")
&& !this.outgoing
&& !(this_nline.flags&NLINE_CHECK_QWKPASSWD)
)
)
) {
if (parseInt(cmd[2]) < 2)
this.quit("UR Server not configured.");
return 0;
}
......@@ -247,8 +259,6 @@ function IRC_Unregistered_Commands(cmdline) {
}
}
}
if (this_nline.flags&NLINE_IS_DREAMFORGE)
new_server.type = DREAMFORGE;
new_server.finalize_server_connect("TS",this.sendps);
this.replaced_with = new_server;
break;
......@@ -357,13 +367,9 @@ function Unregistered_Welcome() {
var my_iline;
// FIXME: We don't compare connecting port.
for(thisILine in ILines) {
if ((wildmatch(this.uprefix + "@" +
this.ip,
ILines[thisILine].ipmask)) &&
(wildmatch(this.uprefix + "@" +
this.hostname,
ILines[thisILine].hostmask))
) {
if ( (wildmatch(this.uprefix + "@" + this.ip, ILines[thisILine].ipmask))
&& (wildmatch(this.uprefix + "@" + this.hostname, ILines[thisILine].hostmask))
) {
my_iline = ILines[thisILine];
break;
}
......@@ -425,9 +431,18 @@ function Unregistered_Welcome() {
if (server.client_update != undefined)
server.client_update(this.socket, this.nick, this.hostname);
var nickstr = "NICK " + this.nick + " 1 " + new_user.created + " ";
server_bcast_to_servers(nickstr + "+ " + this.uprefix + " " + this.hostname + " " + servername + " 0 " + ip_to_int(new_user.ip) + " :" + this.realname,BAHAMUT);
server_bcast_to_servers(nickstr + this.uprefix + " " + this.hostname + " " + servername + " 0 " + " :" + this.realname,DREAMFORGE);
// we're no longer unregistered.
server_bcast_to_servers(
format("NICK %s 1 %s + %s %s %s 0 %s :%s",
this.nick,
new_user.created,
this.uprefix,
this.hostname,
servername,
ip_to_int(new_user.ip),
this.realname
)
);
/* we're no longer unregistered. */
this.replaced_with = new_user;
delete Unregistered[this.id];
delete this;
......
// $Id: ircd_user.js,v 1.53 2020/04/03 23:27:54 deuce Exp $
//
// ircd_unreg.js
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details:
// http://www.gnu.org/licenses/gpl.txt
//
// Synchronet IRC Daemon as per RFC 1459, link compatible with Bahamut 1.4
//
// Copyright 2003-2009 Randolph Erwin Sommerfeld <sysop@rrx.ca>
//
// ** Handle registered clients.
//
/*
////////// Constants / Defines //////////
const USER_REVISION = "$Revision: 1.53 $".split(' ')[1];
ircd/user.js
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details:
https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
Handling of regular user-to-server communication in the IRCd.
Copyright 2003-2021 Randy Sommerfeld <cyan@synchro.net>
*/
const USERMODE_NONE =(1<<0); // NONE
const USERMODE_OPER =(1<<1); // o
......@@ -34,7 +30,7 @@ const USERMODE_CLIENT =(1<<7); // c
const USERMODE_REJECTED =(1<<8); // r
const USERMODE_KILL =(1<<9); // k
const USERMODE_FLOOD =(1<<10); // f
const USERMODE_SPY =(1<<11); // y
const USERMODE_STATS_LINKS =(1<<11); // y
const USERMODE_DEBUG =(1<<12); // d
const USERMODE_ROUTING =(1<<13); // n
const USERMODE_HELP =(1<<14); // h
......@@ -52,7 +48,7 @@ USERMODE_CHAR["c"] = USERMODE_CLIENT;
USERMODE_CHAR["r"] = USERMODE_REJECTED;
USERMODE_CHAR["k"] = USERMODE_KILL;
USERMODE_CHAR["f"] = USERMODE_FLOOD;
USERMODE_CHAR["y"] = USERMODE_SPY;
USERMODE_CHAR["y"] = USERMODE_STATS_LINKS;
USERMODE_CHAR["d"] = USERMODE_DEBUG;
USERMODE_CHAR["n"] = USERMODE_ROUTING;
USERMODE_CHAR["h"] = USERMODE_HELP;
......@@ -67,7 +63,7 @@ USERMODE_BCAST["h"] = true;
USERMODE_BCAST["A"] = true;
// FIXME: Services modes are broadcast but not displayed to the user.
USERMODE_SERVICES = new Object;
USERMODE_SERVICES = {};
// Various permissions that can be set on an O:Line
const OLINE_CAN_REHASH =(1<<0); // r
......@@ -311,7 +307,7 @@ function User_Work(cmdline) {
this.numeric(409,":No origin specified.");
break;
}
if (cmd[1][0] == ":") cmd[1] = cmd[1].slice(1);
if (cmd[1][0] == ":") cmd[1] = cmd[1].slice(1);
if (cmd[2]) {
if (cmd[2][0] == ":")
cmd[2] = cmd[2].slice(1);
......@@ -606,8 +602,7 @@ function User_Work(cmdline) {
this.do_connect(cmd[1],cmd[2]);
break;
case "DEBUG":
if (!((this.mode&USERMODE_OPER) &&
(this.flags&OLINE_CAN_DEBUG))) {
if (!((this.mode&USERMODE_OPER) && (this.flags&OLINE_CAN_DEBUG))) {
this.numeric481();
break;
}
......@@ -669,8 +664,7 @@ function User_Work(cmdline) {
}
break;
case "DIE":
if (!((this.mode&USERMODE_OPER) &&
(this.flags&OLINE_CAN_DIE))) {
if (!((this.mode&USERMODE_OPER) && (this.flags&OLINE_CAN_DIE))) {
this.numeric481();
break;
}
......@@ -687,8 +681,7 @@ function User_Work(cmdline) {
case "ERROR":
break; // silently ignore
case "GLOBOPS":
if (!((this.mode&USERMODE_OPER) &&
(this.flags&OLINE_CAN_GLOBOPS))) {
if (!((this.mode&USERMODE_OPER) && (this.flags&OLINE_CAN_GLOBOPS))) {
this.numeric481();
break;
}
......@@ -762,8 +755,7 @@ function User_Work(cmdline) {
this.numeric("303", isonstr);
break;
case "KILL":
if (!(this.mode&USERMODE_OPER) ||
!(this.flags&OLINE_CAN_LKILL)) {
if (!(this.mode&USERMODE_OPER) || !(this.flags&OLINE_CAN_LKILL)) {
this.numeric481();
break;
}
......@@ -936,8 +928,7 @@ function User_Work(cmdline) {
this.numeric(272, ":End of SILENCE List.");
break;
case "LOCOPS":
if (!((this.mode&USERMODE_OPER) &&
(this.flags&OLINE_CAN_LOCOPS))) {
if (!((this.mode&USERMODE_OPER) && (this.flags&OLINE_CAN_LOCOPS))) {
this.numeric481();
break;
}
......@@ -962,9 +953,13 @@ function User_Work(cmdline) {
break;
}
}
umode_notice(USERMODE_SPY,"Spy","MOTD requested by " +
this.nick + " (" + this.uprefix + "@" +
this.hostname + ") [" + this.servername + "]");
umode_notice(USERMODE_STATS_LINKS,"StatsLinks",format(
"MOTD requested by %s (%s@%s) [%s]",
this.nick,
this.uprefix,
this.hostname,
this.servername
));
this.motd();
break;
case "NAMES":
......@@ -1067,19 +1062,18 @@ function User_Work(cmdline) {
}
var oper_success = false;
for (ol in OLines) {
if( (cmd[1].toUpperCase() ==
OLines[ol].nick.toUpperCase())
&&
(wildmatch(this.uprefix + "@" +
this.hostname,OLines[ol].hostmask)
)
&&
(((cmd[2] == OLines[ol].password) &&
!(OLines[ol].flags&OLINE_CHECK_SYSPASSWD)
) || (
(OLines[ol].flags&OLINE_CHECK_SYSPASSWD)
&& system.check_syspass(cmd[2])
) ) ) {
if ( (cmd[1].toUpperCase() == OLines[ol].nick.toUpperCase())
&& (wildmatch(this.uprefix + "@" + this.hostname,OLines[ol].hostmask))
&& (
( (cmd[2] == OLines[ol].password)
&& !(OLines[ol].flags&OLINE_CHECK_SYSPASSWD)
)
|| (
(OLines[ol].flags&OLINE_CHECK_SYSPASSWD)
&& system.check_syspass(cmd[2])
)
)
) {
oper_success=true;
this.ircclass = OLines[ol].ircclass;
this.flags = OLines[ol].flags;
......@@ -1126,8 +1120,7 @@ function User_Work(cmdline) {
this.quit(IRC_string(cmdline,1));
break;
case "REHASH":
if (!((this.mode&USERMODE_OPER) &&
(this.flags&OLINE_CAN_REHASH))) {
if (!((this.mode&USERMODE_OPER) && (this.flags&OLINE_CAN_REHASH))) {
this.numeric481();
break;
}
......@@ -1138,10 +1131,10 @@ function User_Work(cmdline) {
umode_notice(USERMODE_SERVER,"Notice",this.nick
+ " is clearing temp klines while whistling innocently");
for (kl in KLines) {
if(KLines[kl].type ==
"k")
delete KLines[kl];
if(KLines[kl].type == "k") {
delete KLines[kl];
}
}
break;
case "GC":
if (js.gc!=undefined) {
......@@ -1172,8 +1165,7 @@ function User_Work(cmdline) {
}
break;
case "RESTART":
if (!((this.mode&USERMODE_OPER) &&
(this.flags&OLINE_CAN_RESTART))) {
if (!((this.mode&USERMODE_OPER) && (this.flags&OLINE_CAN_RESTART))) {
this.numeric481();
break;
}
......@@ -1189,8 +1181,7 @@ function User_Work(cmdline) {
terminate_everything(rs_str);
break;
case "SQUIT":
if (!((this.mode&USERMODE_OPER) &&
(this.flags&OLINE_CAN_LSQUITCON))) {
if (!((this.mode&USERMODE_OPER) && (this.flags&OLINE_CAN_LSQUITCON))) {
this.numeric481();
break;
}
......@@ -1358,16 +1349,14 @@ function User_Work(cmdline) {
break;
}
if (dest_server != -1) {
dest_server.rawout(":" + this.nick + " VERSION :"
+ dest_server.nick);
dest_server.rawout(":" + this.nick + " VERSION :" + dest_server.nick);
break;
}
}
this.numeric351();
break;
case "WALLOPS":
if (!((this.mode&USERMODE_OPER) &&
(this.flags&OLINE_CAN_WALLOPS))) {
if (!((this.mode&USERMODE_OPER) && (this.flags&OLINE_CAN_WALLOPS))) {
this.numeric481();
break;
}
......@@ -1538,8 +1527,6 @@ function User_Quit(str,suppress_bcast,is_netsplit,origin) {
if (!suppress_bcast)
this.bcast_to_servers(tmp);
else if (is_netsplit)
this.bcast_to_servers(tmp,DREAMFORGE); /* DF doesn't have NOQUIT */
if (this.local) {
if(server.client_remove!=undefined)
......