Change all code to a consistent style

We use the Linux Kernel format now.
This commit is contained in:
Sam Dodrill 2014-08-03 10:38:55 -07:00
parent 027b2310ca
commit 9890a48cd9
254 changed files with 44148 additions and 48443 deletions

View File

@ -40,21 +40,20 @@
#define COMMIT_INTERVAL 3 /* seconds */ #define COMMIT_INTERVAL 3 /* seconds */
typedef enum typedef enum {
{ BANDB_KLINE,
BANDB_KLINE, BANDB_DLINE,
BANDB_DLINE, BANDB_XLINE,
BANDB_XLINE, BANDB_RESV,
BANDB_RESV, LAST_BANDB_TYPE
LAST_BANDB_TYPE
} bandb_type; } bandb_type;
static char bandb_letter[LAST_BANDB_TYPE] = { static char bandb_letter[LAST_BANDB_TYPE] = {
'K', 'D', 'X', 'R' 'K', 'D', 'X', 'R'
}; };
static const char *bandb_table[LAST_BANDB_TYPE] = { static const char *bandb_table[LAST_BANDB_TYPE] = {
"kline", "dline", "xline", "resv" "kline", "dline", "xline", "resv"
}; };
@ -66,191 +65,181 @@ static void check_schema(void);
static void static void
bandb_commit(void *unused) bandb_commit(void *unused)
{ {
rsdb_transaction(RSDB_TRANS_END); rsdb_transaction(RSDB_TRANS_END);
in_transaction = 0; in_transaction = 0;
} }
static void static void
parse_ban(bandb_type type, char *parv[], int parc) parse_ban(bandb_type type, char *parv[], int parc)
{ {
const char *mask1 = NULL; const char *mask1 = NULL;
const char *mask2 = NULL; const char *mask2 = NULL;
const char *oper = NULL; const char *oper = NULL;
const char *curtime = NULL; const char *curtime = NULL;
const char *reason = NULL; const char *reason = NULL;
const char *perm = NULL; const char *perm = NULL;
int para = 1; int para = 1;
if(type == BANDB_KLINE) if(type == BANDB_KLINE) {
{ if(parc != 7)
if(parc != 7) return;
return; } else if(parc != 6)
} return;
else if(parc != 6)
return;
mask1 = parv[para++]; mask1 = parv[para++];
if(type == BANDB_KLINE) if(type == BANDB_KLINE)
mask2 = parv[para++]; mask2 = parv[para++];
oper = parv[para++]; oper = parv[para++];
curtime = parv[para++]; curtime = parv[para++];
perm = parv[para++]; perm = parv[para++];
reason = parv[para++]; reason = parv[para++];
if(!in_transaction) if(!in_transaction) {
{ rsdb_transaction(RSDB_TRANS_START);
rsdb_transaction(RSDB_TRANS_START); in_transaction = 1;
in_transaction = 1; rb_event_addonce("bandb_commit", bandb_commit, NULL,
rb_event_addonce("bandb_commit", bandb_commit, NULL, COMMIT_INTERVAL);
COMMIT_INTERVAL); }
}
rsdb_exec(NULL, rsdb_exec(NULL,
"INSERT INTO %s (mask1, mask2, oper, time, perm, reason) VALUES('%Q', '%Q', '%Q', %s, %s, '%Q')", "INSERT INTO %s (mask1, mask2, oper, time, perm, reason) VALUES('%Q', '%Q', '%Q', %s, %s, '%Q')",
bandb_table[type], mask1, mask2 ? mask2 : "", oper, curtime, perm, reason); bandb_table[type], mask1, mask2 ? mask2 : "", oper, curtime, perm, reason);
} }
static void static void
parse_unban(bandb_type type, char *parv[], int parc) parse_unban(bandb_type type, char *parv[], int parc)
{ {
const char *mask1 = NULL; const char *mask1 = NULL;
const char *mask2 = NULL; const char *mask2 = NULL;
if(type == BANDB_KLINE) if(type == BANDB_KLINE) {
{ if(parc != 3)
if(parc != 3) return;
return; } else if(parc != 2)
} return;
else if(parc != 2)
return;
mask1 = parv[1]; mask1 = parv[1];
if(type == BANDB_KLINE) if(type == BANDB_KLINE)
mask2 = parv[2]; mask2 = parv[2];
if(!in_transaction) if(!in_transaction) {
{ rsdb_transaction(RSDB_TRANS_START);
rsdb_transaction(RSDB_TRANS_START); in_transaction = 1;
in_transaction = 1; rb_event_addonce("bandb_commit", bandb_commit, NULL,
rb_event_addonce("bandb_commit", bandb_commit, NULL, COMMIT_INTERVAL);
COMMIT_INTERVAL); }
}
rsdb_exec(NULL, "DELETE FROM %s WHERE mask1='%Q' AND mask2='%Q'", rsdb_exec(NULL, "DELETE FROM %s WHERE mask1='%Q' AND mask2='%Q'",
bandb_table[type], mask1, mask2 ? mask2 : ""); bandb_table[type], mask1, mask2 ? mask2 : "");
} }
static void static void
list_bans(void) list_bans(void)
{ {
static char buf[512]; static char buf[512];
struct rsdb_table table; struct rsdb_table table;
int i, j; int i, j;
/* schedule a clear of anything already pending */ /* schedule a clear of anything already pending */
rb_helper_write_queue(bandb_helper, "C"); rb_helper_write_queue(bandb_helper, "C");
for(i = 0; i < LAST_BANDB_TYPE; i++) for(i = 0; i < LAST_BANDB_TYPE; i++) {
{ rsdb_exec_fetch(&table, "SELECT mask1,mask2,oper,reason FROM %s WHERE 1",
rsdb_exec_fetch(&table, "SELECT mask1,mask2,oper,reason FROM %s WHERE 1", bandb_table[i]);
bandb_table[i]);
for(j = 0; j < table.row_count; j++) for(j = 0; j < table.row_count; j++) {
{ if(i == BANDB_KLINE)
if(i == BANDB_KLINE) rb_snprintf(buf, sizeof(buf), "%c %s %s %s :%s",
rb_snprintf(buf, sizeof(buf), "%c %s %s %s :%s", bandb_letter[i], table.row[j][0],
bandb_letter[i], table.row[j][0], table.row[j][1], table.row[j][2], table.row[j][3]);
table.row[j][1], table.row[j][2], table.row[j][3]); else
else rb_snprintf(buf, sizeof(buf), "%c %s %s :%s",
rb_snprintf(buf, sizeof(buf), "%c %s %s :%s", bandb_letter[i], table.row[j][0],
bandb_letter[i], table.row[j][0], table.row[j][2], table.row[j][3]);
table.row[j][2], table.row[j][3]);
rb_helper_write_queue(bandb_helper, "%s", buf); rb_helper_write_queue(bandb_helper, "%s", buf);
} }
rsdb_exec_fetch_end(&table); rsdb_exec_fetch_end(&table);
} }
rb_helper_write(bandb_helper, "F"); rb_helper_write(bandb_helper, "F");
} }
static void static void
parse_request(rb_helper *helper) parse_request(rb_helper *helper)
{ {
static char *parv[MAXPARA + 1]; static char *parv[MAXPARA + 1];
static char readbuf[READBUF_SIZE]; static char readbuf[READBUF_SIZE];
int parc; int parc;
int len; int len;
while((len = rb_helper_read(helper, readbuf, sizeof(readbuf))) > 0) while((len = rb_helper_read(helper, readbuf, sizeof(readbuf))) > 0) {
{ parc = rb_string_to_array(readbuf, parv, MAXPARA);
parc = rb_string_to_array(readbuf, parv, MAXPARA);
if(parc < 1) if(parc < 1)
continue; continue;
switch (parv[0][0]) switch (parv[0][0]) {
{ case 'K':
case 'K': parse_ban(BANDB_KLINE, parv, parc);
parse_ban(BANDB_KLINE, parv, parc); break;
break;
case 'D': case 'D':
parse_ban(BANDB_DLINE, parv, parc); parse_ban(BANDB_DLINE, parv, parc);
break; break;
case 'X': case 'X':
parse_ban(BANDB_XLINE, parv, parc); parse_ban(BANDB_XLINE, parv, parc);
break; break;
case 'R': case 'R':
parse_ban(BANDB_RESV, parv, parc); parse_ban(BANDB_RESV, parv, parc);
break; break;
case 'k': case 'k':
parse_unban(BANDB_KLINE, parv, parc); parse_unban(BANDB_KLINE, parv, parc);
break; break;
case 'd': case 'd':
parse_unban(BANDB_DLINE, parv, parc); parse_unban(BANDB_DLINE, parv, parc);
break; break;
case 'x': case 'x':
parse_unban(BANDB_XLINE, parv, parc); parse_unban(BANDB_XLINE, parv, parc);
break; break;
case 'r': case 'r':
parse_unban(BANDB_RESV, parv, parc); parse_unban(BANDB_RESV, parv, parc);
break; break;
case 'L': case 'L':
list_bans(); list_bans();
break; break;
default: default:
break; break;
} }
} }
} }
static void static void
error_cb(rb_helper *helper) error_cb(rb_helper *helper)
{ {
if(in_transaction) if(in_transaction)
rsdb_transaction(RSDB_TRANS_END); rsdb_transaction(RSDB_TRANS_END);
exit(1); exit(1);
} }
#ifndef WINDOWS #ifndef WINDOWS
static void static void
dummy_handler(int sig) dummy_handler(int sig)
{ {
return; return;
} }
#endif #endif
@ -258,28 +247,28 @@ static void
setup_signals() setup_signals()
{ {
#ifndef WINDOWS #ifndef WINDOWS
struct sigaction act; struct sigaction act;
act.sa_flags = 0; act.sa_flags = 0;
act.sa_handler = SIG_IGN; act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask); sigemptyset(&act.sa_mask);
sigaddset(&act.sa_mask, SIGPIPE); sigaddset(&act.sa_mask, SIGPIPE);
sigaddset(&act.sa_mask, SIGALRM); sigaddset(&act.sa_mask, SIGALRM);
#ifdef SIGTRAP #ifdef SIGTRAP
sigaddset(&act.sa_mask, SIGTRAP); sigaddset(&act.sa_mask, SIGTRAP);
#endif #endif
#ifdef SIGWINCH #ifdef SIGWINCH
sigaddset(&act.sa_mask, SIGWINCH); sigaddset(&act.sa_mask, SIGWINCH);
sigaction(SIGWINCH, &act, 0); sigaction(SIGWINCH, &act, 0);
#endif #endif
sigaction(SIGPIPE, &act, 0); sigaction(SIGPIPE, &act, 0);
#ifdef SIGTRAP #ifdef SIGTRAP
sigaction(SIGTRAP, &act, 0); sigaction(SIGTRAP, &act, 0);
#endif #endif
act.sa_handler = dummy_handler; act.sa_handler = dummy_handler;
sigaction(SIGALRM, &act, 0); sigaction(SIGALRM, &act, 0);
#endif #endif
} }
@ -287,51 +276,49 @@ setup_signals()
static void static void
db_error_cb(const char *errstr) db_error_cb(const char *errstr)
{ {
char buf[256]; char buf[256];
rb_snprintf(buf, sizeof(buf), "! :%s", errstr); rb_snprintf(buf, sizeof(buf), "! :%s", errstr);
rb_helper_write(bandb_helper, buf); rb_helper_write(bandb_helper, buf);
rb_sleep(2 << 30, 0); rb_sleep(2 << 30, 0);
exit(1); exit(1);
} }
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
setup_signals(); setup_signals();
bandb_helper = rb_helper_child(parse_request, error_cb, NULL, NULL, NULL, 256, 256, 256, 256); /* XXX fix me */ bandb_helper = rb_helper_child(parse_request, error_cb, NULL, NULL, NULL, 256, 256, 256, 256); /* XXX fix me */
if(bandb_helper == NULL) if(bandb_helper == NULL) {
{ fprintf(stderr,
fprintf(stderr, "This is ircd-ratbox bandb. You aren't supposed to run me directly. Maybe you want bantool?\n");
"This is ircd-ratbox bandb. You aren't supposed to run me directly. Maybe you want bantool?\n"); fprintf(stderr,
fprintf(stderr, "However I will print my Id tag $Id: bandb.c 26094 2008-09-19 15:33:46Z androsyn $\n");
"However I will print my Id tag $Id: bandb.c 26094 2008-09-19 15:33:46Z androsyn $\n"); fprintf(stderr, "Have a nice day\n");
fprintf(stderr, "Have a nice day\n"); exit(1);
exit(1); }
} rsdb_init(db_error_cb);
rsdb_init(db_error_cb); check_schema();
check_schema(); rb_helper_loop(bandb_helper, 0);
rb_helper_loop(bandb_helper, 0);
return 0; return 0;
} }
static void static void
check_schema(void) check_schema(void)
{ {
struct rsdb_table table; struct rsdb_table table;
int i; int i;
for(i = 0; i < LAST_BANDB_TYPE; i++) for(i = 0; i < LAST_BANDB_TYPE; i++) {
{ rsdb_exec_fetch(&table,
rsdb_exec_fetch(&table, "SELECT name FROM sqlite_master WHERE type='table' AND name='%s'",
"SELECT name FROM sqlite_master WHERE type='table' AND name='%s'", bandb_table[i]);
bandb_table[i]);
rsdb_exec_fetch_end(&table); rsdb_exec_fetch_end(&table);
if(!table.row_count) if(!table.row_count)
rsdb_exec(NULL, rsdb_exec(NULL,
"CREATE TABLE %s (mask1 TEXT, mask2 TEXT, oper TEXT, time INTEGER, perm INTEGER, reason TEXT)", "CREATE TABLE %s (mask1 TEXT, mask2 TEXT, oper TEXT, time INTEGER, perm INTEGER, reason TEXT)",
bandb_table[i]); bandb_table[i]);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -6,19 +6,17 @@ typedef void rsdb_error_cb(const char *);
typedef int (*rsdb_callback) (int, const char **); typedef int (*rsdb_callback) (int, const char **);
typedef enum rsdb_transtype typedef enum rsdb_transtype {
{ RSDB_TRANS_START,
RSDB_TRANS_START, RSDB_TRANS_END
RSDB_TRANS_END
} }
rsdb_transtype; rsdb_transtype;
struct rsdb_table struct rsdb_table {
{ char ***row;
char ***row; int row_count;
int row_count; int col_count;
int col_count; void *arg;
void *arg;
}; };
int rsdb_init(rsdb_error_cb *); int rsdb_init(rsdb_error_cb *);

View File

@ -39,206 +39,206 @@
#define TABLE_MAX 1000 #define TABLE_MAX 1000
static const char *IntTable[] = { static const char *IntTable[] = {
"000", "100", "200", "300", "400", "000", "100", "200", "300", "400",
"500", "600", "700", "800", "900", "500", "600", "700", "800", "900",
"010", "110", "210", "310", "410", "010", "110", "210", "310", "410",
"510", "610", "710", "810", "910", "510", "610", "710", "810", "910",
"020", "120", "220", "320", "420", "020", "120", "220", "320", "420",
"520", "620", "720", "820", "920", "520", "620", "720", "820", "920",
"030", "130", "230", "330", "430", "030", "130", "230", "330", "430",
"530", "630", "730", "830", "930", "530", "630", "730", "830", "930",
"040", "140", "240", "340", "440", "040", "140", "240", "340", "440",
"540", "640", "740", "840", "940", "540", "640", "740", "840", "940",
"050", "150", "250", "350", "450", "050", "150", "250", "350", "450",
"550", "650", "750", "850", "950", "550", "650", "750", "850", "950",
"060", "160", "260", "360", "460", "060", "160", "260", "360", "460",
"560", "660", "760", "860", "960", "560", "660", "760", "860", "960",
"070", "170", "270", "370", "470", "070", "170", "270", "370", "470",
"570", "670", "770", "870", "970", "570", "670", "770", "870", "970",
"080", "180", "280", "380", "480", "080", "180", "280", "380", "480",
"580", "680", "780", "880", "980", "580", "680", "780", "880", "980",
"090", "190", "290", "390", "490", "090", "190", "290", "390", "490",
"590", "690", "790", "890", "990", "590", "690", "790", "890", "990",
"001", "101", "201", "301", "401", "001", "101", "201", "301", "401",
"501", "601", "701", "801", "901", "501", "601", "701", "801", "901",
"011", "111", "211", "311", "411", "011", "111", "211", "311", "411",
"511", "611", "711", "811", "911", "511", "611", "711", "811", "911",
"021", "121", "221", "321", "421", "021", "121", "221", "321", "421",
"521", "621", "721", "821", "921", "521", "621", "721", "821", "921",
"031", "131", "231", "331", "431", "031", "131", "231", "331", "431",
"531", "631", "731", "831", "931", "531", "631", "731", "831", "931",
"041", "141", "241", "341", "441", "041", "141", "241", "341", "441",
"541", "641", "741", "841", "941", "541", "641", "741", "841", "941",
"051", "151", "251", "351", "451", "051", "151", "251", "351", "451",
"551", "651", "751", "851", "951", "551", "651", "751", "851", "951",
"061", "161", "261", "361", "461", "061", "161", "261", "361", "461",
"561", "661", "761", "861", "961", "561", "661", "761", "861", "961",
"071", "171", "271", "371", "471", "071", "171", "271", "371", "471",
"571", "671", "771", "871", "971", "571", "671", "771", "871", "971",
"081", "181", "281", "381", "481", "081", "181", "281", "381", "481",
"581", "681", "781", "881", "981", "581", "681", "781", "881", "981",
"091", "191", "291", "391", "491", "091", "191", "291", "391", "491",
"591", "691", "791", "891", "991", "591", "691", "791", "891", "991",
"002", "102", "202", "302", "402", "002", "102", "202", "302", "402",
"502", "602", "702", "802", "902", "502", "602", "702", "802", "902",
"012", "112", "212", "312", "412", "012", "112", "212", "312", "412",
"512", "612", "712", "812", "912", "512", "612", "712", "812", "912",
"022", "122", "222", "322", "422", "022", "122", "222", "322", "422",
"522", "622", "722", "822", "922", "522", "622", "722", "822", "922",
"032", "132", "232", "332", "432", "032", "132", "232", "332", "432",
"532", "632", "732", "832", "932", "532", "632", "732", "832", "932",
"042", "142", "242", "342", "442", "042", "142", "242", "342", "442",
"542", "642", "742", "842", "942", "542", "642", "742", "842", "942",
"052", "152", "252", "352", "452", "052", "152", "252", "352", "452",
"552", "652", "752", "852", "952", "552", "652", "752", "852", "952",
"062", "162", "262", "362", "462", "062", "162", "262", "362", "462",
"562", "662", "762", "862", "962", "562", "662", "762", "862", "962",
"072", "172", "272", "372", "472", "072", "172", "272", "372", "472",
"572", "672", "772", "872", "972", "572", "672", "772", "872", "972",
"082", "182", "282", "382", "482", "082", "182", "282", "382", "482",
"582", "682", "782", "882", "982", "582", "682", "782", "882", "982",
"092", "192", "292", "392", "492", "092", "192", "292", "392", "492",
"592", "692", "792", "892", "992", "592", "692", "792", "892", "992",
"003", "103", "203", "303", "403", "003", "103", "203", "303", "403",
"503", "603", "703", "803", "903", "503", "603", "703", "803", "903",
"013", "113", "213", "313", "413", "013", "113", "213", "313", "413",
"513", "613", "713", "813", "913", "513", "613", "713", "813", "913",
"023", "123", "223", "323", "423", "023", "123", "223", "323", "423",
"523", "623", "723", "823", "923", "523", "623", "723", "823", "923",
"033", "133", "233", "333", "433", "033", "133", "233", "333", "433",
"533", "633", "733", "833", "933", "533", "633", "733", "833", "933",
"043", "143", "243", "343", "443", "043", "143", "243", "343", "443",
"543", "643", "743", "843", "943", "543", "643", "743", "843", "943",
"053", "153", "253", "353", "453", "053", "153", "253", "353", "453",
"553", "653", "753", "853", "953", "553", "653", "753", "853", "953",
"063", "163", "263", "363", "463", "063", "163", "263", "363", "463",
"563", "663", "763", "863", "963", "563", "663", "763", "863", "963",
"073", "173", "273", "373", "473", "073", "173", "273", "373", "473",
"573", "673", "773", "873", "973", "573", "673", "773", "873", "973",
"083", "183", "283", "383", "483", "083", "183", "283", "383", "483",
"583", "683", "783", "883", "983", "583", "683", "783", "883", "983",
"093", "193", "293", "393", "493", "093", "193", "293", "393", "493",
"593", "693", "793", "893", "993", "593", "693", "793", "893", "993",
"004", "104", "204", "304", "404", "004", "104", "204", "304", "404",
"504", "604", "704", "804", "904", "504", "604", "704", "804", "904",
"014", "114", "214", "314", "414", "014", "114", "214", "314", "414",
"514", "614", "714", "814", "914", "514", "614", "714", "814", "914",
"024", "124", "224", "324", "424", "024", "124", "224", "324", "424",
"524", "624", "724", "824", "924", "524", "624", "724", "824", "924",
"034", "134", "234", "334", "434", "034", "134", "234", "334", "434",
"534", "634", "734", "834", "934", "534", "634", "734", "834", "934",
"044", "144", "244", "344", "444", "044", "144", "244", "344", "444",
"544", "644", "744", "844", "944", "544", "644", "744", "844", "944",
"054", "154", "254", "354", "454", "054", "154", "254", "354", "454",
"554", "654", "754", "854", "954", "554", "654", "754", "854", "954",
"064", "164", "264", "364", "464", "064", "164", "264", "364", "464",
"564", "664", "764", "864", "964", "564", "664", "764", "864", "964",
"074", "174", "274", "374", "474", "074", "174", "274", "374", "474",
"574", "674", "774", "874", "974", "574", "674", "774", "874", "974",
"084", "184", "284", "384", "484", "084", "184", "284", "384", "484",
"584", "684", "784", "884", "984", "584", "684", "784", "884", "984",
"094", "194", "294", "394", "494", "094", "194", "294", "394", "494",
"594", "694", "794", "894", "994", "594", "694", "794", "894", "994",
"005", "105", "205", "305", "405", "005", "105", "205", "305", "405",
"505", "605", "705", "805", "905", "505", "605", "705", "805", "905",
"015", "115", "215", "315", "415", "015", "115", "215", "315", "415",
"515", "615", "715", "815", "915", "515", "615", "715", "815", "915",
"025", "125", "225", "325", "425", "025", "125", "225", "325", "425",
"525", "625", "725", "825", "925", "525", "625", "725", "825", "925",
"035", "135", "235", "335", "435", "035", "135", "235", "335", "435",
"535", "635", "735", "835", "935", "535", "635", "735", "835", "935",
"045", "145", "245", "345", "445", "045", "145", "245", "345", "445",
"545", "645", "745", "845", "945", "545", "645", "745", "845", "945",
"055", "155", "255", "355", "455", "055", "155", "255", "355", "455",
"555", "655", "755", "855", "955", "555", "655", "755", "855", "955",
"065", "165", "265", "365", "465", "065", "165", "265", "365", "465",
"565", "665", "765", "865", "965", "565", "665", "765", "865", "965",
"075", "175", "275", "375", "475", "075", "175", "275", "375", "475",
"575", "675", "775", "875", "975", "575", "675", "775", "875", "975",
"085", "185", "285", "385", "485", "085", "185", "285", "385", "485",
"585", "685", "785", "885", "985", "585", "685", "785", "885", "985",
"095", "195", "295", "395", "495", "095", "195", "295", "395", "495",
"595", "695", "795", "895", "995", "595", "695", "795", "895", "995",
"006", "106", "206", "306", "406", "006", "106", "206", "306", "406",
"506", "606", "706", "806", "906", "506", "606", "706", "806", "906",
"016", "116", "216", "316", "416", "016", "116", "216", "316", "416",
"516", "616", "716", "816", "916", "516", "616", "716", "816", "916",
"026", "126", "226", "326", "426", "026", "126", "226", "326", "426",
"526", "626", "726", "826", "926", "526", "626", "726", "826", "926",
"036", "136", "236", "336", "436", "036", "136", "236", "336", "436",
"536", "636", "736", "836", "936", "536", "636", "736", "836", "936",
"046", "146", "246", "346", "446", "046", "146", "246", "346", "446",
"546", "646", "746", "846", "946", "546", "646", "746", "846", "946",
"056", "156", "256", "356", "456", "056", "156", "256", "356", "456",
"556", "656", "756", "856", "956", "556", "656", "756", "856", "956",
"066", "166", "266", "366", "466", "066", "166", "266", "366", "466",
"566", "666", "766", "866", "966", "566", "666", "766", "866", "966",
"076", "176", "276", "376", "476", "076", "176", "276", "376", "476",
"576", "676", "776", "876", "976", "576", "676", "776", "876", "976",
"086", "186", "286", "386", "486", "086", "186", "286", "386", "486",
"586", "686", "786", "886", "986", "586", "686", "786", "886", "986",
"096", "196", "296", "396", "496", "096", "196", "296", "396", "496",
"596", "696", "796", "896", "996", "596", "696", "796", "896", "996",
"007", "107", "207", "307", "407", "007", "107", "207", "307", "407",
"507", "607", "707", "807", "907", "507", "607", "707", "807", "907",
"017", "117", "217", "317", "417", "017", "117", "217", "317", "417",
"517", "617", "717", "817", "917", "517", "617", "717", "817", "917",
"027", "127", "227", "327", "427", "027", "127", "227", "327", "427",
"527", "627", "727", "827", "927", "527", "627", "727", "827", "927",
"037", "137", "237", "337", "437", "037", "137", "237", "337", "437",
"537", "637", "737", "837", "937", "537", "637", "737", "837", "937",
"047", "147", "247", "347", "447", "047", "147", "247", "347", "447",
"547", "647", "747", "847", "947", "547", "647", "747", "847", "947",
"057", "157", "257", "357", "457", "057", "157", "257", "357", "457",
"557", "657", "757", "857", "957", "557", "657", "757", "857", "957",
"067", "167", "267", "367", "467", "067", "167", "267", "367", "467",
"567", "667", "767", "867", "967", "567", "667", "767", "867", "967",
"077", "177", "277", "377", "477", "077", "177", "277", "377", "477",
"577", "677", "777", "877", "977", "577", "677", "777", "877", "977",
"087", "187", "287", "387", "487", "087", "187", "287", "387", "487",
"587", "687", "787", "887", "987", "587", "687", "787", "887", "987",
"097", "197", "297", "397", "497", "097", "197", "297", "397", "497",
"597", "697", "797", "897", "997", "597", "697", "797", "897", "997",
"008", "108", "208", "308", "408", "008", "108", "208", "308", "408",
"508", "608", "708", "808", "908", "508", "608", "708", "808", "908",
"018", "118", "218", "318", "418", "018", "118", "218", "318", "418",
"518", "618", "718", "818", "918", "518", "618", "718", "818", "918",
"028", "128", "228", "328", "428", "028", "128", "228", "328", "428",
"528", "628", "728", "828", "928", "528", "628", "728", "828", "928",
"038", "138", "238", "338", "438", "038", "138", "238", "338", "438",
"538", "638", "738", "838", "938", "538", "638", "738", "838", "938",
"048", "148", "248", "348", "448", "048", "148", "248", "348", "448",
"548", "648", "748", "848", "948", "548", "648", "748", "848", "948",
"058", "158", "258", "358", "458", "058", "158", "258", "358", "458",
"558", "658", "758", "858", "958", "558", "658", "758", "858", "958",
"068", "168", "268", "368", "468", "068", "168", "268", "368", "468",
"568", "668", "768", "868", "968", "568", "668", "768", "868", "968",
"078", "178", "278", "378", "478", "078", "178", "278", "378", "478",
"578", "678", "778", "878", "978", "578", "678", "778", "878", "978",
"088", "188", "288", "388", "488", "088", "188", "288", "388", "488",
"588", "688", "788", "888", "988", "588", "688", "788", "888", "988",
"098", "198", "298", "398", "498", "098", "198", "298", "398", "498",
"598", "698", "798", "898", "998", "598", "698", "798", "898", "998",
"009", "109", "209", "309", "409", "009", "109", "209", "309", "409",
"509", "609", "709", "809", "909", "509", "609", "709", "809", "909",
"019", "119", "219", "319", "419", "019", "119", "219", "319", "419",
"519", "619", "719", "819", "919", "519", "619", "719", "819", "919",
"029", "129", "229", "329", "429", "029", "129", "229", "329", "429",
"529", "629", "729", "829", "929", "529", "629", "729", "829", "929",
"039", "139", "239", "339", "439", "039", "139", "239", "339", "439",
"539", "639", "739", "839", "939", "539", "639", "739", "839", "939",
"049", "149", "249", "349", "449", "049", "149", "249", "349", "449",
"549", "649", "749", "849", "949", "549", "649", "749", "849", "949",
"059", "159", "259", "359", "459", "059", "159", "259", "359", "459",
"559", "659", "759", "859", "959", "559", "659", "759", "859", "959",
"069", "169", "269", "369", "469", "069", "169", "269", "369", "469",
"569", "669", "769", "869", "969", "569", "669", "769", "869", "969",
"079", "179", "279", "379", "479", "079", "179", "279", "379", "479",
"579", "679", "779", "879", "979", "579", "679", "779", "879", "979",
"089", "189", "289", "389", "489", "089", "189", "289", "389", "489",
"589", "689", "789", "889", "989", "589", "689", "789", "889", "989",
"099", "199", "299", "399", "499", "099", "199", "299", "399", "499",
"599", "699", "799", "899", "999" "599", "699", "799", "899", "999"
}; };
/* /*
@ -274,328 +274,290 @@ NOTE: This function handles the following flags only:
int int
rs_vsnprintf(char *dest, const size_t bytes, const char *format, va_list args) rs_vsnprintf(char *dest, const size_t bytes, const char *format, va_list args)
{ {
char ch; char ch;
int written = 0; /* bytes written so far */ int written = 0; /* bytes written so far */
int maxbytes = bytes - 1; int maxbytes = bytes - 1;
while((ch = *format++) && (written < maxbytes)) while((ch = *format++) && (written < maxbytes)) {
{ if(ch == '%') {
if(ch == '%') /*
{ * Advance past the %
/* */
* Advance past the % ch = *format++;
*/
ch = *format++;
/* /*
* Put the most common cases first - %s %d etc * Put the most common cases first - %s %d etc
*/ */
if(ch == 's') if(ch == 's') {
{ const char *str = va_arg(args, const char *);
const char *str = va_arg(args, const char *);
while((*dest = *str)) while((*dest = *str)) {
{ ++dest;
++dest; ++str;
++str;
if(++written >= maxbytes) if(++written >= maxbytes)
break; break;
} }
continue; continue;
} }
if(ch == 'd') if(ch == 'd') {
{ int num = va_arg(args, int);
int num = va_arg(args, int); int quotient;
int quotient; const char *str;
const char *str; char *digitptr = TempBuffer;
char *digitptr = TempBuffer;
/* /*
* We have to special-case "0" unfortunately * We have to special-case "0" unfortunately
*/ */
if(num == 0) if(num == 0) {
{ *dest++ = '0';
*dest++ = '0'; ++written;
++written; continue;
continue; }
}
if(num < 0) if(num < 0) {
{ *dest++ = '-';
*dest++ = '-'; if(++written >= maxbytes)
if(++written >= maxbytes) continue;
continue;
num = -num; num = -num;
} }
do do {
{ quotient = num / TABLE_MAX;
quotient = num / TABLE_MAX;
/* /*
* We'll start with the right-most digits of 'num'. * We'll start with the right-most digits of 'num'.
* Dividing by TABLE_MAX cuts off all but the X * Dividing by TABLE_MAX cuts off all but the X
* right-most digits, where X is such that: * right-most digits, where X is such that:
* *
* 10^X = TABLE_MAX * 10^X = TABLE_MAX
* *
* For example, if num = 1200, and TABLE_MAX = 1000, * For example, if num = 1200, and TABLE_MAX = 1000,
* quotient will be 1. Multiplying this by 1000 and * quotient will be 1. Multiplying this by 1000 and
* subtracting from 1200 gives: 1200 - (1 * 1000) = 200. * subtracting from 1200 gives: 1200 - (1 * 1000) = 200.
* We then go right to slot 200 in our array and behold! * We then go right to slot 200 in our array and behold!
* The string "002" (200 backwards) is conveniently * The string "002" (200 backwards) is conveniently
* waiting for us. Then repeat the process with the * waiting for us. Then repeat the process with the
* digits left. * digits left.
* *
* The reason we need to have the integers written * The reason we need to have the integers written
* backwards, is because we don't know how many digits * backwards, is because we don't know how many digits
* there are. If we want to express the number 12130 * there are. If we want to express the number 12130
* for example, our first pass would leave us with 130, * for example, our first pass would leave us with 130,
* whose slot in the array yields "031", which we * whose slot in the array yields "031", which we
* plug into our TempBuffer[]. The next pass gives us * plug into our TempBuffer[]. The next pass gives us
* 12, whose slot yields "21" which we append to * 12, whose slot yields "21" which we append to
* TempBuffer[], leaving us with "03121". This is the * TempBuffer[], leaving us with "03121". This is the
* exact number we want, only backwards, so it is * exact number we want, only backwards, so it is
* a simple matter to reverse the string. If we used * a simple matter to reverse the string. If we used
* straightfoward numbers, we would have a TempBuffer * straightfoward numbers, we would have a TempBuffer
* looking like this: "13012" which would be a nightmare * looking like this: "13012" which would be a nightmare
* to deal with. * to deal with.
*/ */
str = IntTable[num - (quotient * TABLE_MAX)]; str = IntTable[num - (quotient * TABLE_MAX)];
while((*digitptr = *str)) while((*digitptr = *str)) {
{ ++digitptr;
++digitptr; ++str;
++str; }
} } while((num = quotient) != 0);
}
while((num = quotient) != 0);
/* /*
* If the last quotient was a 1 or 2 digit number, there * If the last quotient was a 1 or 2 digit number, there
* will be one or more leading zeroes in TempBuffer[] - * will be one or more leading zeroes in TempBuffer[] -
* get rid of them. * get rid of them.
*/ */
while(*(digitptr - 1) == '0') while(*(digitptr - 1) == '0')
--digitptr; --digitptr;
while(digitptr != TempBuffer) while(digitptr != TempBuffer) {
{ *dest++ = *--digitptr;
*dest++ = *--digitptr; if(++written >= maxbytes)
if(++written >= maxbytes) break;
break; }
}
continue; continue;
} /* if (ch == 'd') */ } /* if (ch == 'd') */
if(ch == 'c') if(ch == 'c') {
{ *dest++ = va_arg(args, int);
*dest++ = va_arg(args, int);
++written; ++written;
continue; continue;
} /* if (ch == 'c') */ } /* if (ch == 'c') */
if(ch == 'u') if(ch == 'u') {
{ unsigned int num = va_arg(args, unsigned int);
unsigned int num = va_arg(args, unsigned int); unsigned int quotient;
unsigned int quotient; const char *str;
const char *str; char *digitptr = TempBuffer;
char *digitptr = TempBuffer;
if(num == 0) if(num == 0) {
{ *dest++ = '0';
*dest++ = '0'; ++written;
++written; continue;
continue; }
}
do do {
{ quotient = num / TABLE_MAX;
quotient = num / TABLE_MAX;
/* /*
* Very similar to case 'd' * Very similar to case 'd'
*/ */
str = IntTable[num - (quotient * TABLE_MAX)]; str = IntTable[num - (quotient * TABLE_MAX)];
while((*digitptr = *str)) while((*digitptr = *str)) {
{ ++digitptr;
++digitptr; ++str;
++str; }
} } while((num = quotient) != 0);
}
while((num = quotient) != 0);
while(*(digitptr - 1) == '0') while(*(digitptr - 1) == '0')
--digitptr; --digitptr;
while(digitptr != TempBuffer) while(digitptr != TempBuffer) {
{ *dest++ = *--digitptr;
*dest++ = *--digitptr; if(++written >= maxbytes)
if(++written >= maxbytes) break;
break; }
}
continue; continue;
} /* if (ch == 'u') */ } /* if (ch == 'u') */
if(ch == 'Q') if(ch == 'Q') {
{ const char *arg = va_arg(args, const char *);
const char *arg = va_arg(args, const char *);
if(arg == NULL) if(arg == NULL)
continue; continue;
const char *str = rsdb_quote(arg); const char *str = rsdb_quote(arg);
while((*dest = *str)) while((*dest = *str)) {
{ ++dest;
++dest; ++str;
++str;
if(++written >= maxbytes) if(++written >= maxbytes)
break; break;
} }
continue; continue;
} }
if(ch == 'l') if(ch == 'l') {
{ if(*format == 'u') {
if(*format == 'u') unsigned long num = va_arg(args, unsigned long);
{ unsigned long quotient;
unsigned long num = va_arg(args, unsigned long); const char *str;
unsigned long quotient; char *digitptr = TempBuffer;
const char *str;
char *digitptr = TempBuffer;
++format; ++format;
if(num == 0) if(num == 0) {
{ *dest++ = '0';
*dest++ = '0'; ++written;
++written; continue;
continue; }
}
do do {
{ quotient = num / TABLE_MAX;
quotient = num / TABLE_MAX;
/* /*
* Very similar to case 'u' * Very similar to case 'u'
*/ */
str = IntTable[num - (quotient * TABLE_MAX)]; str = IntTable[num - (quotient * TABLE_MAX)];
while((*digitptr = *str)) while((*digitptr = *str)) {
{ ++digitptr;
++digitptr; ++str;
++str; }
} } while((num = quotient) != 0);
}
while((num = quotient) != 0);
while(*(digitptr - 1) == '0') while(*(digitptr - 1) == '0')
--digitptr; --digitptr;
while(digitptr != TempBuffer) while(digitptr != TempBuffer) {
{ *dest++ = *--digitptr;
*dest++ = *--digitptr; if(++written >= maxbytes)
if(++written >= maxbytes) break;
break; }
}
continue; continue;
} } else
else /* if (*format == 'u') */ if(*format == 'd') {
/* if (*format == 'u') */ if(*format == 'd') long num = va_arg(args, long);
{ long quotient;
long num = va_arg(args, long); const char *str;
long quotient; char *digitptr = TempBuffer;
const char *str;
char *digitptr = TempBuffer;
++format; ++format;
if(num == 0) if(num == 0) {
{ *dest++ = '0';
*dest++ = '0'; ++written;
++written; continue;
continue; }
}
if(num < 0) if(num < 0) {
{ *dest++ = '-';
*dest++ = '-'; if(++written >= maxbytes)
if(++written >= maxbytes) continue;
continue;
num = -num; num = -num;
} }
do do {
{ quotient = num / TABLE_MAX;
quotient = num / TABLE_MAX;
str = IntTable[num - (quotient * TABLE_MAX)]; str = IntTable[num - (quotient * TABLE_MAX)];
while((*digitptr = *str)) while((*digitptr = *str)) {
{ ++digitptr;
++digitptr; ++str;
++str; }
} } while((num = quotient) != 0);
}
while((num = quotient) != 0);
while(*(digitptr - 1) == '0') while(*(digitptr - 1) == '0')
--digitptr; --digitptr;
while(digitptr != TempBuffer) while(digitptr != TempBuffer) {
{ *dest++ = *--digitptr;
*dest++ = *--digitptr; if(++written >= maxbytes)
if(++written >= maxbytes) break;
break; }
}
continue; continue;
} } else { /* if (*format == 'd') */
else /* if (*format == 'd') */ /* XXX error */
{ exit(1);
/* XXX error */ }
exit(1);
}
} /* if (ch == 'l') */ } /* if (ch == 'l') */
if(ch != '%') if(ch != '%') {
{ /* XXX error */
/* XXX error */ exit(1);
exit(1); } /* if (ch != '%') */
} /* if (ch != '%') */ } /* if (ch == '%') */
} /* if (ch == '%') */
*dest++ = ch; *dest++ = ch;
++written; ++written;
} /* while ((ch = *format++) && (written < maxbytes)) */ } /* while ((ch = *format++) && (written < maxbytes)) */
/* /*
* Terminate the destination buffer with a \0 * Terminate the destination buffer with a \0
*/ */
*dest = '\0'; *dest = '\0';
return (written); return (written);
} /* vSnprintf() */ } /* vSnprintf() */
/* /*
@ -614,14 +576,14 @@ Return: number of characters copied, NOT including the terminating
int int
rs_snprintf(char *dest, const size_t bytes, const char *format, ...) rs_snprintf(char *dest, const size_t bytes, const char *format, ...)
{ {
va_list args; va_list args;
int count; int count;
va_start(args, format); va_start(args, format);
count = rs_vsnprintf(dest, bytes, format, args); count = rs_vsnprintf(dest, bytes, format, args);
va_end(args); va_end(args);
return (count); return (count);
} /* Snprintf() */ } /* Snprintf() */

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2003-2006 Lee Hardy <leeh@leeh.co.uk> * Copyright (C) 2003-2006 Lee Hardy <leeh@leeh.co.uk>
* Copyright (C) 2003-2006 ircd-ratbox development team * Copyright (C) 2003-2006 ircd-ratbox development team
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
* met: * met:
@ -27,7 +27,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
#include "stdinc.h" #include "stdinc.h"
#include "rsdb.h" #include "rsdb.h"
@ -41,224 +41,206 @@ rsdb_error_cb *error_cb;
static void static void
mlog(const char *errstr, ...) mlog(const char *errstr, ...)
{ {
if(error_cb != NULL) if(error_cb != NULL) {
{ char buf[256];
char buf[256]; va_list ap;
va_list ap; va_start(ap, errstr);
va_start(ap, errstr); rb_vsnprintf(buf, sizeof(buf), errstr, ap);
rb_vsnprintf(buf, sizeof(buf), errstr, ap); va_end(ap);
va_end(ap); error_cb(buf);
error_cb(buf); } else
} exit(1);
else
exit(1);
} }
int int
rsdb_init(rsdb_error_cb * ecb) rsdb_init(rsdb_error_cb * ecb)
{ {
const char *bandb_dbpath_env; const char *bandb_dbpath_env;
char dbpath[PATH_MAX]; char dbpath[PATH_MAX];
char errbuf[128]; char errbuf[128];
error_cb = ecb; error_cb = ecb;
/* try a path from the environment first, useful for basedir overrides */ /* try a path from the environment first, useful for basedir overrides */
bandb_dbpath_env = getenv("BANDB_DBPATH"); bandb_dbpath_env = getenv("BANDB_DBPATH");
if(bandb_dbpath_env != NULL) if(bandb_dbpath_env != NULL)
rb_strlcpy(dbpath, bandb_dbpath_env, sizeof(dbpath)); rb_strlcpy(dbpath, bandb_dbpath_env, sizeof(dbpath));
else else
rb_strlcpy(dbpath, DBPATH, sizeof(dbpath)); rb_strlcpy(dbpath, DBPATH, sizeof(dbpath));
if(sqlite3_open(dbpath, &rb_bandb) != SQLITE_OK) if(sqlite3_open(dbpath, &rb_bandb) != SQLITE_OK) {
{ rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s",
rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s", sqlite3_errmsg(rb_bandb));
sqlite3_errmsg(rb_bandb)); mlog(errbuf);
mlog(errbuf); return -1;
return -1; }
} if(access(dbpath, W_OK)) {
if(access(dbpath, W_OK)) rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database for write: %s", strerror(errno));
{ mlog(errbuf);
rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database for write: %s", strerror(errno)); return -1;
mlog(errbuf); }
return -1; return 0;
}
return 0;
} }
void void
rsdb_shutdown(void) rsdb_shutdown(void)
{ {
if(rb_bandb) if(rb_bandb)
sqlite3_close(rb_bandb); sqlite3_close(rb_bandb);
} }
const char * const char *
rsdb_quote(const char *src) rsdb_quote(const char *src)
{ {
static char buf[BUFSIZE * 4]; static char buf[BUFSIZE * 4];
char *p = buf; char *p = buf;
/* cheap and dirty length check.. */ /* cheap and dirty length check.. */
if(strlen(src) >= (sizeof(buf) / 2)) if(strlen(src) >= (sizeof(buf) / 2))
return NULL; return NULL;
while(*src) while(*src) {
{ if(*src == '\'')
if(*src == '\'') *p++ = '\'';
*p++ = '\'';
*p++ = *src++; *p++ = *src++;
} }
*p = '\0'; *p = '\0';
return buf; return buf;
} }
static int static int
rsdb_callback_func(void *cbfunc, int argc, char **argv, char **colnames) rsdb_callback_func(void *cbfunc, int argc, char **argv, char **colnames)
{ {
rsdb_callback cb = (rsdb_callback)((uintptr_t)cbfunc); rsdb_callback cb = (rsdb_callback)((uintptr_t)cbfunc);
(cb) (argc, (const char **)argv); (cb) (argc, (const char **)argv);
return 0; return 0;
} }
void void
rsdb_exec(rsdb_callback cb, const char *format, ...) rsdb_exec(rsdb_callback cb, const char *format, ...)
{ {
static char buf[BUFSIZE * 4]; static char buf[BUFSIZE * 4];
va_list args; va_list args;
char *errmsg; char *errmsg;
unsigned int i; unsigned int i;
int j; int j;
va_start(args, format); va_start(args, format);
i = rs_vsnprintf(buf, sizeof(buf), format, args); i = rs_vsnprintf(buf, sizeof(buf), format, args);
va_end(args); va_end(args);
if(i >= sizeof(buf)) if(i >= sizeof(buf)) {
{ mlog("fatal error: length problem with compiling sql");
mlog("fatal error: length problem with compiling sql"); }
}
if((i = sqlite3_exec(rb_bandb, buf, (cb ? rsdb_callback_func : NULL), (void *)((uintptr_t)cb), &errmsg))) if((i = sqlite3_exec(rb_bandb, buf, (cb ? rsdb_callback_func : NULL), (void *)((uintptr_t)cb), &errmsg))) {
{ switch (i) {
switch (i) case SQLITE_BUSY:
{ for(j = 0; j < 5; j++) {
case SQLITE_BUSY: rb_sleep(0, 500000);
for(j = 0; j < 5; j++) if(!sqlite3_exec
{ (rb_bandb, buf, (cb ? rsdb_callback_func : NULL), (void *)((uintptr_t)cb), &errmsg))
rb_sleep(0, 500000); return;
if(!sqlite3_exec }
(rb_bandb, buf, (cb ? rsdb_callback_func : NULL), (void *)((uintptr_t)cb), &errmsg))
return;
}
/* failed, fall through to default */ /* failed, fall through to default */
mlog("fatal error: problem with db file: %s", errmsg); mlog("fatal error: problem with db file: %s", errmsg);
break; break;
default: default:
mlog("fatal error: problem with db file: %s", errmsg); mlog("fatal error: problem with db file: %s", errmsg);
break; break;
} }
} }
} }
void void
rsdb_exec_fetch(struct rsdb_table *table, const char *format, ...) rsdb_exec_fetch(struct rsdb_table *table, const char *format, ...)
{ {
static char buf[BUFSIZE * 4]; static char buf[BUFSIZE * 4];
va_list args; va_list args;
char *errmsg; char *errmsg;
char **data; char **data;
int pos; int pos;
unsigned int retval; unsigned int retval;
int i, j; int i, j;
va_start(args, format); va_start(args, format);
retval = rs_vsnprintf(buf, sizeof(buf), format, args); retval = rs_vsnprintf(buf, sizeof(buf), format, args);
va_end(args); va_end(args);
if(retval >= sizeof(buf)) if(retval >= sizeof(buf)) {
{ mlog("fatal error: length problem with compiling sql");
mlog("fatal error: length problem with compiling sql"); }
}
if((retval = if((retval =
sqlite3_get_table(rb_bandb, buf, &data, &table->row_count, &table->col_count, &errmsg))) sqlite3_get_table(rb_bandb, buf, &data, &table->row_count, &table->col_count, &errmsg))) {
{ int success = 0;
int success = 0;
switch (retval) switch (retval) {
{ case SQLITE_BUSY:
case SQLITE_BUSY: for(i = 0; i < 5; i++) {
for(i = 0; i < 5; i++) rb_sleep(0, 500000);
{ if(!sqlite3_get_table
rb_sleep(0, 500000); (rb_bandb, buf, &data, &table->row_count, &table->col_count,
if(!sqlite3_get_table &errmsg)) {
(rb_bandb, buf, &data, &table->row_count, &table->col_count, success++;
&errmsg)) break;
{ }
success++; }
break;
}
}
if(success) if(success)
break; break;
mlog("fatal error: problem with db file: %s", errmsg); mlog("fatal error: problem with db file: %s", errmsg);
break; break;
default: default:
mlog("fatal error: problem with db file: %s", errmsg); mlog("fatal error: problem with db file: %s", errmsg);
break; break;
} }
} }
/* we need to be able to free data afterward */ /* we need to be able to free data afterward */
table->arg = data; table->arg = data;
if(table->row_count == 0) if(table->row_count == 0) {
{ table->row = NULL;
table->row = NULL; return;
return; }
}
/* sqlite puts the column names as the first row */ /* sqlite puts the column names as the first row */
pos = table->col_count; pos = table->col_count;
table->row = rb_malloc(sizeof(char **) * table->row_count); table->row = rb_malloc(sizeof(char **) * table->row_count);
for(i = 0; i < table->row_count; i++) for(i = 0; i < table->row_count; i++) {
{ table->row[i] = rb_malloc(sizeof(char *) * table->col_count);
table->row[i] = rb_malloc(sizeof(char *) * table->col_count);
for(j = 0; j < table->col_count; j++) for(j = 0; j < table->col_count; j++) {
{ table->row[i][j] = data[pos++];
table->row[i][j] = data[pos++]; }
} }
}
} }
void void
rsdb_exec_fetch_end(struct rsdb_table *table) rsdb_exec_fetch_end(struct rsdb_table *table)
{ {
int i; int i;
for(i = 0; i < table->row_count; i++) for(i = 0; i < table->row_count; i++) {
{ rb_free(table->row[i]);
rb_free(table->row[i]); }
} rb_free(table->row);
rb_free(table->row);
sqlite3_free_table((char **)table->arg); sqlite3_free_table((char **)table->arg);
} }
void void
rsdb_transaction(rsdb_transtype type) rsdb_transaction(rsdb_transtype type)
{ {
if(type == RSDB_TRANS_START) if(type == RSDB_TRANS_START)
rsdb_exec(NULL, "BEGIN TRANSACTION"); rsdb_exec(NULL, "BEGIN TRANSACTION");
else if(type == RSDB_TRANS_END) else if(type == RSDB_TRANS_END)
rsdb_exec(NULL, "COMMIT TRANSACTION"); rsdb_exec(NULL, "COMMIT TRANSACTION");
} }

View File

@ -13,8 +13,8 @@
static void h_can_join(hook_data_channel *); static void h_can_join(hook_data_channel *);
mapi_hfn_list_av1 adminonly_hfnlist[] = { mapi_hfn_list_av1 adminonly_hfnlist[] = {
{ "can_join", (hookfn) h_can_join }, { "can_join", (hookfn) h_can_join },
{ NULL, NULL } { NULL, NULL }
}; };
static unsigned int mymode; static unsigned int mymode;
@ -22,17 +22,17 @@ static unsigned int mymode;
static int static int
_modinit(void) _modinit(void)
{ {
mymode = cflag_add('A', chm_staff); mymode = cflag_add('A', chm_staff);
if (mymode == 0) if (mymode == 0)
return -1; return -1;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
cflag_orphan('A'); cflag_orphan('A');
} }
DECLARE_MODULE_AV1(chm_adminonly, _modinit, _moddeinit, NULL, NULL, adminonly_hfnlist, "$Revision$"); DECLARE_MODULE_AV1(chm_adminonly, _modinit, _moddeinit, NULL, NULL, adminonly_hfnlist, "$Revision$");
@ -40,12 +40,12 @@ DECLARE_MODULE_AV1(chm_adminonly, _modinit, _moddeinit, NULL, NULL, adminonly_hf
static void static void
h_can_join(hook_data_channel *data) h_can_join(hook_data_channel *data)
{ {
struct Client *source_p = data->client; struct Client *source_p = data->client;
struct Channel *chptr = data->chptr; struct Channel *chptr = data->chptr;
if((chptr->mode.mode & mymode) && !IsAdmin(source_p)) { if((chptr->mode.mode & mymode) && !IsAdmin(source_p)) {
sendto_one_numeric(source_p, 519, "%s :Cannot join channel (+A) - you are not an IRC server administrator", chptr->chname); sendto_one_numeric(source_p, 519, "%s :Cannot join channel (+A) - you are not an IRC server administrator", chptr->chname);
data->approved = ERR_CUSTOM; data->approved = ERR_CUSTOM;
} }
} }

View File

@ -13,8 +13,8 @@
static void h_can_join(hook_data_channel *); static void h_can_join(hook_data_channel *);
mapi_hfn_list_av1 operonly_hfnlist[] = { mapi_hfn_list_av1 operonly_hfnlist[] = {
{ "can_join", (hookfn) h_can_join }, { "can_join", (hookfn) h_can_join },
{ NULL, NULL } { NULL, NULL }
}; };
static unsigned int mymode; static unsigned int mymode;
@ -26,18 +26,18 @@ static unsigned int mymode;
static int static int
_modinit(void) _modinit(void)
{ {
mymode = cflag_add('O', chm_staff); mymode = cflag_add('O', chm_staff);
if (mymode == 0) if (mymode == 0)
return -1; return -1;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
cflag_orphan('O'); cflag_orphan('O');
} }
DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnlist, "$Revision$"); DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnlist, "$Revision$");
@ -45,12 +45,12 @@ DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnl
static void static void
h_can_join(hook_data_channel *data) h_can_join(hook_data_channel *data)
{ {
struct Client *source_p = data->client; struct Client *source_p = data->client;
struct Channel *chptr = data->chptr; struct Channel *chptr = data->chptr;
if((chptr->mode.mode & mymode) && !IsOper(source_p)) { if((chptr->mode.mode & mymode) && !IsOper(source_p)) {
sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+O) - you are not an IRC operator", chptr->chname); sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+O) - you are not an IRC operator", chptr->chname);
data->approved = ERR_CUSTOM; data->approved = ERR_CUSTOM;
} }
} }

View File

@ -12,41 +12,41 @@
static int _modinit(void); static int _modinit(void);
static void _moddeinit(void); static void _moddeinit(void);
static void chm_operonly(struct Client *source_p, struct Channel *chptr, static void chm_operonly(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
DECLARE_MODULE_AV1(chm_operonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$"); DECLARE_MODULE_AV1(chm_operonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
static int static int
_modinit(void) _modinit(void)
{ {
chmode_table['O'].set_func = chm_operonly; chmode_table['O'].set_func = chm_operonly;
chmode_table['O'].mode_type = 0; chmode_table['O'].mode_type = 0;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
chmode_table['O'].set_func = chm_nosuch; chmode_table['O'].set_func = chm_nosuch;
chmode_table['O'].mode_type = 0; chmode_table['O'].mode_type = 0;
} }
static void static void
chm_operonly(struct Client *source_p, struct Channel *chptr, chm_operonly(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type) const char **parv, int *errors, int dir, char c, long mode_type)
{ {
int newparn = 0; int newparn = 0;
const char *newparv[] = { "$o" }; const char *newparv[] = { "$o" };
if (MyClient(source_p)) { if (MyClient(source_p)) {
chm_simple(source_p, chptr, alevel, parc, parn, parv, chm_simple(source_p, chptr, alevel, parc, parn, parv,
errors, dir, 'i', MODE_INVITEONLY); errors, dir, 'i', MODE_INVITEONLY);
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv, chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
errors, dir, 'I', CHFL_INVEX); errors, dir, 'I', CHFL_INVEX);
} else } else
chm_nosuch(source_p, chptr, alevel, parc, parn, parv, chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
errors, dir, c, mode_type); errors, dir, c, mode_type);
} }

View File

@ -13,39 +13,39 @@
static int _modinit(void); static int _modinit(void);
static void _moddeinit(void); static void _moddeinit(void);
static void chm_quietunreg(struct Client *source_p, struct Channel *chptr, static void chm_quietunreg(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
DECLARE_MODULE_AV1(chm_quietunreg_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$"); DECLARE_MODULE_AV1(chm_quietunreg_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
static int static int
_modinit(void) _modinit(void)
{ {
chmode_table['R'].set_func = chm_quietunreg; chmode_table['R'].set_func = chm_quietunreg;
chmode_table['R'].mode_type = 0; chmode_table['R'].mode_type = 0;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
chmode_table['R'].set_func = chm_nosuch; chmode_table['R'].set_func = chm_nosuch;
chmode_table['R'].mode_type = 0; chmode_table['R'].mode_type = 0;
} }
static void static void
chm_quietunreg(struct Client *source_p, struct Channel *chptr, chm_quietunreg(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type) const char **parv, int *errors, int dir, char c, long mode_type)
{ {
int newparn = 0; int newparn = 0;
const char *newparv[] = { "$~a" }; const char *newparv[] = { "$~a" };
if (MyClient(source_p)) if (MyClient(source_p))
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv, chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
errors, dir, 'q', CHFL_QUIET); errors, dir, 'q', CHFL_QUIET);
else else
chm_nosuch(source_p, chptr, alevel, parc, parn, parv, chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
errors, dir, c, mode_type); errors, dir, c, mode_type);
} }

View File

@ -13,8 +13,8 @@
static void h_can_join(hook_data_channel *); static void h_can_join(hook_data_channel *);
mapi_hfn_list_av1 sslonly_hfnlist[] = { mapi_hfn_list_av1 sslonly_hfnlist[] = {
{ "can_join", (hookfn) h_can_join }, { "can_join", (hookfn) h_can_join },
{ NULL, NULL } { NULL, NULL }
}; };
static unsigned int mymode; static unsigned int mymode;
@ -22,18 +22,18 @@ static unsigned int mymode;
static int static int
_modinit(void) _modinit(void)
{ {
mymode = cflag_add('S', chm_simple); mymode = cflag_add('S', chm_simple);
if (mymode == 0) if (mymode == 0)
return -1; return -1;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
cflag_orphan('S'); cflag_orphan('S');
} }
DECLARE_MODULE_AV1(chm_sslonly, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlist, "$Revision$"); DECLARE_MODULE_AV1(chm_sslonly, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlist, "$Revision$");
@ -41,12 +41,12 @@ DECLARE_MODULE_AV1(chm_sslonly, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlis
static void static void
h_can_join(hook_data_channel *data) h_can_join(hook_data_channel *data)
{ {
struct Client *source_p = data->client; struct Client *source_p = data->client;
struct Channel *chptr = data->chptr; struct Channel *chptr = data->chptr;
if((chptr->mode.mode & mymode) && !IsSSLClient(source_p)) { if((chptr->mode.mode & mymode) && !IsSSLClient(source_p)) {
sendto_one_notice(source_p, ":Only users using SSL can join this channel!"); sendto_one_notice(source_p, ":Only users using SSL can join this channel!");
data->approved = ERR_CUSTOM; data->approved = ERR_CUSTOM;
} }
} }

View File

@ -12,39 +12,39 @@
static int _modinit(void); static int _modinit(void);
static void _moddeinit(void); static void _moddeinit(void);
static void chm_sslonly(struct Client *source_p, struct Channel *chptr, static void chm_sslonly(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
DECLARE_MODULE_AV1(chm_sslonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$"); DECLARE_MODULE_AV1(chm_sslonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
static int static int
_modinit(void) _modinit(void)
{ {
chmode_table['S'].set_func = chm_sslonly; chmode_table['S'].set_func = chm_sslonly;
chmode_table['S'].mode_type = 0; chmode_table['S'].mode_type = 0;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
chmode_table['S'].set_func = chm_nosuch; chmode_table['S'].set_func = chm_nosuch;
chmode_table['S'].mode_type = 0; chmode_table['S'].mode_type = 0;
} }
static void static void
chm_sslonly(struct Client *source_p, struct Channel *chptr, chm_sslonly(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type) const char **parv, int *errors, int dir, char c, long mode_type)
{ {
int newparn = 0; int newparn = 0;
const char *newparv[] = { "$~z" }; const char *newparv[] = { "$~z" };
if (MyClient(source_p)) if (MyClient(source_p))
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv, chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
errors, dir, 'b', CHFL_BAN); errors, dir, 'b', CHFL_BAN);
else else
chm_nosuch(source_p, chptr, alevel, parc, parn, parv, chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
errors, dir, c, mode_type); errors, dir, c, mode_type);
} }

View File

@ -20,8 +20,8 @@
static void h_can_create_channel_authenticated(hook_data_client_approval *); static void h_can_create_channel_authenticated(hook_data_client_approval *);
mapi_hfn_list_av1 restrict_hfnlist[] = { mapi_hfn_list_av1 restrict_hfnlist[] = {
{ "can_create_channel", (hookfn) h_can_create_channel_authenticated }, { "can_create_channel", (hookfn) h_can_create_channel_authenticated },
{ NULL, NULL } { NULL, NULL }
}; };
DECLARE_MODULE_AV1(createauthonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$Revision: 833 $"); DECLARE_MODULE_AV1(createauthonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$Revision: 833 $");
@ -29,8 +29,8 @@ DECLARE_MODULE_AV1(createauthonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$R
static void static void
h_can_create_channel_authenticated(hook_data_client_approval *data) h_can_create_channel_authenticated(hook_data_client_approval *data)
{ {
struct Client *source_p = data->client; struct Client *source_p = data->client;
if (*source_p->user->suser == '\0' && !IsOper(source_p)) if (*source_p->user->suser == '\0' && !IsOper(source_p))
data->approved = ERR_NEEDREGGEDNICK; data->approved = ERR_NEEDREGGEDNICK;
} }

View File

@ -20,8 +20,8 @@
static void h_can_create_channel_authenticated(hook_data_client_approval *); static void h_can_create_channel_authenticated(hook_data_client_approval *);
mapi_hfn_list_av1 restrict_hfnlist[] = { mapi_hfn_list_av1 restrict_hfnlist[] = {
{ "can_create_channel", (hookfn) h_can_create_channel_authenticated }, { "can_create_channel", (hookfn) h_can_create_channel_authenticated },
{ NULL, NULL } { NULL, NULL }
}; };
DECLARE_MODULE_AV1(createoperonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$Revision: 3476 $"); DECLARE_MODULE_AV1(createoperonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$Revision: 3476 $");
@ -29,11 +29,10 @@ DECLARE_MODULE_AV1(createoperonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$R
static void static void
h_can_create_channel_authenticated(hook_data_client_approval *data) h_can_create_channel_authenticated(hook_data_client_approval *data)
{ {
struct Client *source_p = data->client; struct Client *source_p = data->client;
if (!IsOper(source_p)) if (!IsOper(source_p)) {
{ sendto_one_notice(source_p, ":*** Channel creation is restricted to network staff only.");
sendto_one_notice(source_p, ":*** Channel creation is restricted to network staff only."); data->approved = ERR_NEEDREGGEDNICK;
data->approved = ERR_NEEDREGGEDNICK; }
}
} }

View File

@ -47,25 +47,25 @@ static int moper_test(struct Client *client_p, struct Client *source_p, int parc
*/ */
struct Message test_msgtab = { struct Message test_msgtab = {
"TEST", /* the /COMMAND you want */ "TEST", /* the /COMMAND you want */
0, /* SET TO ZERO -- number of times command used by clients */ 0, /* SET TO ZERO -- number of times command used by clients */
0, /* SET TO ZERO -- number of times command used by clients */ 0, /* SET TO ZERO -- number of times command used by clients */
0, /* SET TO ZERO -- number of times command used by clients */ 0, /* SET TO ZERO -- number of times command used by clients */
MFLG_SLOW, /* ALWAYS SET TO MFLG_SLOW */ MFLG_SLOW, /* ALWAYS SET TO MFLG_SLOW */
/* the functions to call for each handler. If not using the generic /* the functions to call for each handler. If not using the generic
* handlers, the first param is the function to call, the second is the * handlers, the first param is the function to call, the second is the
* required number of parameters. NOTE: If you specify a min para of 2, * required number of parameters. NOTE: If you specify a min para of 2,
* then parv[1] must *also* be non-empty. * then parv[1] must *also* be non-empty.
*/ */
{ {
{munreg_test, 0}, /* function call for unregistered clients, 0 parms required */ {munreg_test, 0}, /* function call for unregistered clients, 0 parms required */
{mclient_test, 0}, /* function call for local clients, 0 parms required */ {mclient_test, 0}, /* function call for local clients, 0 parms required */
{mrclient_test, 0}, /* function call for remote clients, 0 parms required */ {mrclient_test, 0}, /* function call for remote clients, 0 parms required */
{mserver_test, 0}, /* function call for servers, 0 parms required */ {mserver_test, 0}, /* function call for servers, 0 parms required */
mg_ignore, /* function call for ENCAP, unused in this test */ mg_ignore, /* function call for ENCAP, unused in this test */
{moper_test, 0} /* function call for operators, 0 parms required */ {moper_test, 0} /* function call for operators, 0 parms required */
} }
}; };
/* /*
* There are also some macros for the above function calls and parameter counts. * There are also some macros for the above function calls and parameter counts.
@ -93,9 +93,9 @@ mapi_clist_av1 test_clist[] = { &test_msgtab, NULL };
* terminated with NULLs. * terminated with NULLs.
*/ */
int doing_example_hook; int doing_example_hook;
mapi_hlist_av1 test_hlist[] = { mapi_hlist_av1 test_hlist[] = {
{ "doing_example_hook", &doing_example_hook, }, { "doing_example_hook", &doing_example_hook, },
{ NULL, NULL } { NULL, NULL }
}; };
/* The mapi_hfn_list_av1 declares the hook functions which other modules can /* The mapi_hfn_list_av1 declares the hook functions which other modules can
@ -106,44 +106,44 @@ mapi_hlist_av1 test_hlist[] = {
static void show_example_hook(void *unused); static void show_example_hook(void *unused);
mapi_hfn_list_av1 test_hfnlist[] = { mapi_hfn_list_av1 test_hfnlist[] = {
{ "doing_example_hook", (hookfn) show_example_hook }, { "doing_example_hook", (hookfn) show_example_hook },
{ NULL, NULL } { NULL, NULL }
}; };
/* Here we tell it what to do when the module is loaded */ /* Here we tell it what to do when the module is loaded */
static int static int
modinit(void) modinit(void)
{ {
/* Nothing to do for the example module. */ /* Nothing to do for the example module. */
/* The init function should return -1 on failure, /* The init function should return -1 on failure,
which will cause the module to be unloaded, which will cause the module to be unloaded,
otherwise 0 to indicate success. */ otherwise 0 to indicate success. */
return 0; return 0;
} }
/* here we tell it what to do when the module is unloaded */ /* here we tell it what to do when the module is unloaded */
static void static void
moddeinit(void) moddeinit(void)
{ {
/* Again, nothing to do. */ /* Again, nothing to do. */
} }
/* DECLARE_MODULE_AV1() actually declare the MAPI header. */ /* DECLARE_MODULE_AV1() actually declare the MAPI header. */
DECLARE_MODULE_AV1( DECLARE_MODULE_AV1(
/* The first argument is the name */ /* The first argument is the name */
example, example,
/* The second argument is the function to call on load */ /* The second argument is the function to call on load */
modinit, modinit,
/* And the function to call on unload */ /* And the function to call on unload */
moddeinit, moddeinit,
/* Then the MAPI command list */ /* Then the MAPI command list */
test_clist, test_clist,
/* Next the hook list, if we have one. */ /* Next the hook list, if we have one. */
test_hlist, test_hlist,
/* Then the hook function list, if we have one */ /* Then the hook function list, if we have one */
test_hfnlist, test_hfnlist,
/* And finally the version number of this module. */ /* And finally the version number of this module. */
"$Revision: 3161 $"); "$Revision: 3161 $");
/* Any of the above arguments can be NULL to indicate they aren't used. */ /* Any of the above arguments can be NULL to indicate they aren't used. */
@ -159,19 +159,16 @@ DECLARE_MODULE_AV1(
static int static int
munreg_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) munreg_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
if(parc < 2) if(parc < 2) {
{ sendto_one_notice(source_p, ":You are unregistered and sent no parameters");
sendto_one_notice(source_p, ":You are unregistered and sent no parameters"); } else {
} sendto_one_notice(source_p, ":You are unregistered and sent parameter: %s", parv[1]);
else }
{
sendto_one_notice(source_p, ":You are unregistered and sent parameter: %s", parv[1]);
}
/* illustration of how to call a hook function */ /* illustration of how to call a hook function */
call_hook(doing_example_hook, NULL); call_hook(doing_example_hook, NULL);
return 0; return 0;
} }
/* /*
@ -181,19 +178,16 @@ munreg_test(struct Client *client_p, struct Client *source_p, int parc, const ch
static int static int
mclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
if(parc < 2) if(parc < 2) {
{ sendto_one_notice(source_p, ":You are a normal user, and sent no parameters");
sendto_one_notice(source_p, ":You are a normal user, and sent no parameters"); } else {
} sendto_one_notice(source_p, ":You are a normal user, and send parameters: %s", parv[1]);
else }
{
sendto_one_notice(source_p, ":You are a normal user, and send parameters: %s", parv[1]);
}
/* illustration of how to call a hook function */ /* illustration of how to call a hook function */
call_hook(doing_example_hook, NULL); call_hook(doing_example_hook, NULL);
return 0; return 0;
} }
/* /*
@ -203,15 +197,12 @@ mclient_test(struct Client *client_p, struct Client *source_p, int parc, const c
static int static int
mrclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mrclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
if(parc < 2) if(parc < 2) {
{ sendto_one_notice(source_p, ":You are a remote client, and sent no parameters");
sendto_one_notice(source_p, ":You are a remote client, and sent no parameters"); } else {
} sendto_one_notice(source_p, ":You are a remote client, and sent parameters: %s", parv[1]);
else }
{ return 0;
sendto_one_notice(source_p, ":You are a remote client, and sent parameters: %s", parv[1]);
}
return 0;
} }
/* /*
@ -221,15 +212,12 @@ mrclient_test(struct Client *client_p, struct Client *source_p, int parc, const
static int static int
mserver_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mserver_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
if(parc < 2) if(parc < 2) {
{ sendto_one_notice(source_p, ":You are a server, and sent no parameters");
sendto_one_notice(source_p, ":You are a server, and sent no parameters"); } else {
} sendto_one_notice(source_p, ":You are a server, and sent parameters: %s", parv[1]);
else }
{ return 0;
sendto_one_notice(source_p, ":You are a server, and sent parameters: %s", parv[1]);
}
return 0;
} }
/* /*
@ -239,21 +227,18 @@ mserver_test(struct Client *client_p, struct Client *source_p, int parc, const c
static int static int
moper_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) moper_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
if(parc < 2) if(parc < 2) {
{ sendto_one_notice(source_p, ":You are an operator, and sent no parameters");
sendto_one_notice(source_p, ":You are an operator, and sent no parameters"); } else {
} sendto_one_notice(source_p, ":You are an operator, and sent parameters: %s", parv[1]);
else }
{ return 0;
sendto_one_notice(source_p, ":You are an operator, and sent parameters: %s", parv[1]);
}
return 0;
} }
static void static void
show_example_hook(void *unused) show_example_hook(void *unused)
{ {
sendto_realops_snomask(SNO_GENERAL, L_ALL, "Called example hook!"); sendto_realops_snomask(SNO_GENERAL, L_ALL, "Called example hook!");
} }
/* END OF EXAMPLE MODULE */ /* END OF EXAMPLE MODULE */

View File

@ -18,25 +18,25 @@ DECLARE_MODULE_AV1(extb_account, _modinit, _moddeinit, NULL, NULL, NULL, "$Revis
static int static int
_modinit(void) _modinit(void)
{ {
extban_table['a'] = eb_account; extban_table['a'] = eb_account;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
extban_table['a'] = NULL; extban_table['a'] = NULL;
} }
static int eb_account(const char *data, struct Client *client_p, static int eb_account(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type) struct Channel *chptr, long mode_type)
{ {
(void)chptr; (void)chptr;
/* $a alone matches any logged in user */ /* $a alone matches any logged in user */
if (data == NULL) if (data == NULL)
return EmptyString(client_p->user->suser) ? EXTBAN_NOMATCH : EXTBAN_MATCH; return EmptyString(client_p->user->suser) ? EXTBAN_NOMATCH : EXTBAN_MATCH;
/* $a:MASK matches users logged in under matching account */ /* $a:MASK matches users logged in under matching account */
return match(data, client_p->user->suser) ? EXTBAN_MATCH : EXTBAN_NOMATCH; return match(data, client_p->user->suser) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
} }

View File

@ -21,46 +21,46 @@ DECLARE_MODULE_AV1(extb_canjoin, _modinit, _moddeinit, NULL, NULL, NULL, "$Revis
static int static int
_modinit(void) _modinit(void)
{ {
extban_table['j'] = eb_canjoin; extban_table['j'] = eb_canjoin;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
extban_table['j'] = NULL; extban_table['j'] = NULL;
} }
static int eb_canjoin(const char *data, struct Client *client_p, static int eb_canjoin(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type) struct Channel *chptr, long mode_type)
{ {
struct Channel *chptr2; struct Channel *chptr2;
int ret; int ret;
static int recurse = 0; static int recurse = 0;
(void)mode_type; (void)mode_type;
/* don't process a $j in a $j'ed list */ /* don't process a $j in a $j'ed list */
if (recurse) if (recurse)
return EXTBAN_INVALID; return EXTBAN_INVALID;
if (data == NULL) if (data == NULL)
return EXTBAN_INVALID; return EXTBAN_INVALID;
chptr2 = find_channel(data); chptr2 = find_channel(data);
/* must exist, and no point doing this with the same channel */ /* must exist, and no point doing this with the same channel */
if (chptr2 == NULL || chptr2 == chptr) if (chptr2 == NULL || chptr2 == chptr)
return EXTBAN_INVALID; return EXTBAN_INVALID;
/* require consistent target */ /* require consistent target */
if (chptr->chname[0] == '#' && data[0] == '&') if (chptr->chname[0] == '#' && data[0] == '&')
return EXTBAN_INVALID; return EXTBAN_INVALID;
/* this allows getting some information about ban exceptions /* this allows getting some information about ban exceptions
* but +s/+p doesn't seem the right criterion */ * but +s/+p doesn't seem the right criterion */
#if 0 #if 0
/* privacy! don't allow +s/+p channels to influence another channel */ /* privacy! don't allow +s/+p channels to influence another channel */
if (!PubChannel(chptr2)) if (!PubChannel(chptr2))
return EXTBAN_INVALID; return EXTBAN_INVALID;
#endif #endif
recurse = 1; recurse = 1;
ret = is_banned(chptr2, client_p, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH; ret = is_banned(chptr2, client_p, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH;
recurse = 0; recurse = 0;
return ret; return ret;
} }

View File

@ -20,34 +20,34 @@ DECLARE_MODULE_AV1(extb_channel, _modinit, _moddeinit, NULL, NULL, NULL, "$Revis
static int static int
_modinit(void) _modinit(void)
{ {
extban_table['c'] = eb_channel; extban_table['c'] = eb_channel;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
extban_table['c'] = NULL; extban_table['c'] = NULL;
} }
static int eb_channel(const char *data, struct Client *client_p, static int eb_channel(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type) struct Channel *chptr, long mode_type)
{ {
struct Channel *chptr2; struct Channel *chptr2;
(void)chptr; (void)chptr;
(void)mode_type; (void)mode_type;
if (data == NULL) if (data == NULL)
return EXTBAN_INVALID; return EXTBAN_INVALID;
chptr2 = find_channel(data); chptr2 = find_channel(data);
if (chptr2 == NULL) if (chptr2 == NULL)
return EXTBAN_INVALID; return EXTBAN_INVALID;
/* require consistent target */ /* require consistent target */
if (chptr->chname[0] == '#' && data[0] == '&') if (chptr->chname[0] == '#' && data[0] == '&')
return EXTBAN_INVALID; return EXTBAN_INVALID;
/* privacy! don't allow +s/+p channels to influence another channel */ /* privacy! don't allow +s/+p channels to influence another channel */
if (!PubChannel(chptr2)) if (!PubChannel(chptr2))
return EXTBAN_INVALID; return EXTBAN_INVALID;
return IsMember(client_p, chptr2) ? EXTBAN_MATCH : EXTBAN_NOMATCH; return IsMember(client_p, chptr2) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
} }

View File

@ -19,40 +19,39 @@ DECLARE_MODULE_AV1(extb_extended, _modinit, _moddeinit, NULL, NULL, NULL, "$Revi
static int static int
_modinit(void) _modinit(void)
{ {
extban_table['x'] = eb_extended; extban_table['x'] = eb_extended;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
extban_table['x'] = NULL; extban_table['x'] = NULL;
} }
static int eb_extended(const char *data, struct Client *client_p, static int eb_extended(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type) struct Channel *chptr, long mode_type)
{ {
char buf[BUFSIZE]; char buf[BUFSIZE];
int ret; int ret;
(void)chptr; (void)chptr;
if (data == NULL) if (data == NULL)
return EXTBAN_INVALID; return EXTBAN_INVALID;
rb_snprintf(buf, BUFSIZE, "%s!%s@%s#%s", rb_snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
client_p->name, client_p->username, client_p->host, client_p->info); client_p->name, client_p->username, client_p->host, client_p->info);
ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH; ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
if (ret == EXTBAN_NOMATCH && IsDynSpoof(client_p)) if (ret == EXTBAN_NOMATCH && IsDynSpoof(client_p)) {
{ rb_snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
rb_snprintf(buf, BUFSIZE, "%s!%s@%s#%s", client_p->name, client_p->username, client_p->orighost, client_p->info);
client_p->name, client_p->username, client_p->orighost, client_p->info);
ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH; ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
} }
return ret; return ret;
} }

View File

@ -18,26 +18,26 @@ DECLARE_MODULE_AV1(extb_oper, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision
static int static int
_modinit(void) _modinit(void)
{ {
extban_table['o'] = eb_oper; extban_table['o'] = eb_oper;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
extban_table['o'] = NULL; extban_table['o'] = NULL;
} }
static int eb_oper(const char *data, struct Client *client_p, static int eb_oper(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type) struct Channel *chptr, long mode_type)
{ {
(void)chptr; (void)chptr;
(void)mode_type; (void)mode_type;
/* perhaps use data somehow? (opernick/flags?) */ /* perhaps use data somehow? (opernick/flags?) */
/* so deny any bans with data for now */ /* so deny any bans with data for now */
if (data != NULL) if (data != NULL)
return EXTBAN_INVALID; return EXTBAN_INVALID;
return IsOper(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH; return IsOper(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
} }

View File

@ -18,26 +18,26 @@ DECLARE_MODULE_AV1(extb_realname, _modinit, _moddeinit, NULL, NULL, NULL, "$Revi
static int static int
_modinit(void) _modinit(void)
{ {
extban_table['r'] = eb_realname; extban_table['r'] = eb_realname;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
extban_table['r'] = NULL; extban_table['r'] = NULL;
} }
static int eb_realname(const char *data, struct Client *client_p, static int eb_realname(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type) struct Channel *chptr, long mode_type)
{ {
(void)chptr; (void)chptr;
/* This type is not safe for exceptions */ /* This type is not safe for exceptions */
if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX) if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX)
return EXTBAN_INVALID; return EXTBAN_INVALID;
if (data == NULL) if (data == NULL)
return EXTBAN_INVALID; return EXTBAN_INVALID;
return match(data, client_p->info) ? EXTBAN_MATCH : EXTBAN_NOMATCH; return match(data, client_p->info) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
} }

View File

@ -18,26 +18,26 @@ DECLARE_MODULE_AV1(extb_server, _modinit, _moddeinit, NULL, NULL, NULL, "$Revisi
static int static int
_modinit(void) _modinit(void)
{ {
extban_table['s'] = eb_server; extban_table['s'] = eb_server;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
extban_table['s'] = NULL; extban_table['s'] = NULL;
} }
static int eb_server(const char *data, struct Client *client_p, static int eb_server(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type) struct Channel *chptr, long mode_type)
{ {
(void)chptr; (void)chptr;
/* This type is not safe for exceptions */ /* This type is not safe for exceptions */
if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX) if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX)
return EXTBAN_INVALID; return EXTBAN_INVALID;
if (data == NULL) if (data == NULL)
return EXTBAN_INVALID; return EXTBAN_INVALID;
return match(data, me.name) ? EXTBAN_MATCH : EXTBAN_NOMATCH; return match(data, me.name) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
} }

View File

@ -14,24 +14,24 @@ DECLARE_MODULE_AV1(extb_ssl, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$
static int static int
_modinit(void) _modinit(void)
{ {
extban_table['z'] = eb_ssl; extban_table['z'] = eb_ssl;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
extban_table['z'] = NULL; extban_table['z'] = NULL;
} }
static int eb_ssl(const char *data, struct Client *client_p, static int eb_ssl(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type) struct Channel *chptr, long mode_type)
{ {
(void)chptr; (void)chptr;
(void)mode_type; (void)mode_type;
if (data != NULL) if (data != NULL)
return EXTBAN_INVALID; return EXTBAN_INVALID;
return IsSSLClient(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH; return IsSSLClient(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
} }

View File

@ -18,8 +18,8 @@
static void h_noi_umode_changed(hook_data_umode_changed *); static void h_noi_umode_changed(hook_data_umode_changed *);
mapi_hfn_list_av1 noi_hfnlist[] = { mapi_hfn_list_av1 noi_hfnlist[] = {
{ "umode_changed", (hookfn) h_noi_umode_changed }, { "umode_changed", (hookfn) h_noi_umode_changed },
{ NULL, NULL } { NULL, NULL }
}; };
DECLARE_MODULE_AV1(force_user_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "1.0.0"); DECLARE_MODULE_AV1(force_user_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "1.0.0");
@ -27,9 +27,9 @@ DECLARE_MODULE_AV1(force_user_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "1.0.0
static void static void
h_noi_umode_changed(hook_data_umode_changed *hdata) h_noi_umode_changed(hook_data_umode_changed *hdata)
{ {
struct Client *source_p = hdata->client; struct Client *source_p = hdata->client;
if (MyClient(source_p) && !IsOper(source_p) && !IsInvisible(source_p)) { if (MyClient(source_p) && !IsOper(source_p) && !IsInvisible(source_p)) {
SetInvisible(source_p); SetInvisible(source_p);
} }
} }

View File

@ -23,25 +23,25 @@
#define HURT_EXIT_REASON "Hurt: Failed to identify to services" #define HURT_EXIT_REASON "Hurt: Failed to identify to services"
enum { enum {
HEAL_NICK = 0, HEAL_NICK = 0,
HEAL_IP HEAL_IP
}; };
typedef struct _hurt_state { typedef struct _hurt_state {
time_t start_time; time_t start_time;
uint32_t n_hurts; uint32_t n_hurts;
rb_dlink_list hurt_clients; rb_dlink_list hurt_clients;
uint16_t cutoff; uint16_t cutoff;
time_t default_expire; time_t default_expire;
const char *exit_reason; const char *exit_reason;
} hurt_state_t; } hurt_state_t;
typedef struct _hurt { typedef struct _hurt {
char *ip; char *ip;
struct sockaddr *saddr; struct sockaddr *saddr;
int saddr_bits; int saddr_bits;
char *reason; char *reason;
time_t expire; time_t expire;
} hurt_t; } hurt_t;
/* }}} */ /* }}} */
@ -82,45 +82,45 @@ rb_dlink_list hurt_confs = { NULL, NULL, 0 };
/* {{{ Messages */ /* {{{ Messages */
struct Message hurt_msgtab = { struct Message hurt_msgtab = {
"HURT", 0, 0, 0, MFLG_SLOW, { "HURT", 0, 0, 0, MFLG_SLOW, {
mg_ignore, mg_ignore, mg_ignore, mg_ignore, mg_ignore, mg_ignore,
mg_ignore, {me_hurt, 0}, {mo_hurt, 3} mg_ignore, {me_hurt, 0}, {mo_hurt, 3}
} }
}; };
struct Message heal_msgtab = { struct Message heal_msgtab = {
"HEAL", 0, 0, 0, MFLG_SLOW, { "HEAL", 0, 0, 0, MFLG_SLOW, {
mg_ignore, mg_ignore, mg_ignore, mg_ignore, mg_ignore, mg_ignore,
mg_ignore, {me_heal, 0}, {mo_heal, 2} mg_ignore, {me_heal, 0}, {mo_heal, 2}
} }
}; };
/* }}} */ /* }}} */
/* {{{ Misc module stuff */ /* {{{ Misc module stuff */
mapi_hfn_list_av1 hurt_hfnlist[] = { mapi_hfn_list_av1 hurt_hfnlist[] = {
{"client_exit", (hookfn) client_exit_hook}, {"client_exit", (hookfn) client_exit_hook},
{"new_local_user", (hookfn) new_local_user_hook}, {"new_local_user", (hookfn) new_local_user_hook},
{"doing_stats", (hookfn) doing_stats_hook}, {"doing_stats", (hookfn) doing_stats_hook},
{NULL, NULL}, {NULL, NULL},
}; };
mapi_clist_av1 hurt_clist[] = { &hurt_msgtab, &heal_msgtab, NULL }; mapi_clist_av1 hurt_clist[] = { &hurt_msgtab, &heal_msgtab, NULL };
DECLARE_MODULE_AV1( DECLARE_MODULE_AV1(
hurt, hurt,
modinit, modinit,
modfini, modfini,
hurt_clist, hurt_clist,
NULL, NULL,
hurt_hfnlist, hurt_hfnlist,
"$Revision: 3161 $" "$Revision: 3161 $"
); );
/* }}} */ /* }}} */
hurt_state_t hurt_state = { hurt_state_t hurt_state = {
.cutoff = HURT_CUTOFF, .cutoff = HURT_CUTOFF,
.default_expire = HURT_DEFAULT_EXPIRE, .default_expire = HURT_DEFAULT_EXPIRE,
.exit_reason = HURT_EXIT_REASON, .exit_reason = HURT_EXIT_REASON,
}; };
/* /*
@ -135,14 +135,14 @@ struct ev_entry *hurt_check_ev = NULL;
static int static int
modinit(void) modinit(void)
{ {
/* set-up hurt_state. */ /* set-up hurt_state. */
hurt_state.start_time = rb_current_time(); hurt_state.start_time = rb_current_time();
/* add our event handlers. */ /* add our event handlers. */
hurt_expire_ev = rb_event_add("hurt_expire", hurt_expire_event, NULL, 60); hurt_expire_ev = rb_event_add("hurt_expire", hurt_expire_event, NULL, 60);
hurt_check_ev = rb_event_add("hurt_check", hurt_check_event, NULL, 5); hurt_check_ev = rb_event_add("hurt_check", hurt_check_event, NULL, 5);
return 0; return 0;
} }
/* }}} */ /* }}} */
@ -150,16 +150,15 @@ modinit(void)
static void static void
modfini(void) modfini(void)
{ {
rb_dlink_node *ptr, *next_ptr; rb_dlink_node *ptr, *next_ptr;
/* and delete our events. */ /* and delete our events. */
rb_event_delete(hurt_expire_ev); rb_event_delete(hurt_expire_ev);
rb_event_delete(hurt_check_ev); rb_event_delete(hurt_check_ev);
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) {
{ rb_dlinkDestroy(ptr, &hurt_state.hurt_clients);
rb_dlinkDestroy(ptr, &hurt_state.hurt_clients); }
}
} }
/* }}} */ /* }}} */
@ -170,84 +169,79 @@ modfini(void)
/* {{{ static int mo_hurt() /* {{{ static int mo_hurt()
* *
* HURT [<expire>] <ip> <reason> * HURT [<expire>] <ip> <reason>
* *
* parv[1] - expire or ip * parv[1] - expire or ip
* parv[2] - ip or reason * parv[2] - ip or reason
* parv[3] - reason or NULL * parv[3] - reason or NULL
*/ */
static int static int
mo_hurt(struct Client *client_p, struct Client *source_p, mo_hurt(struct Client *client_p, struct Client *source_p,
int parc, const char **parv) int parc, const char **parv)
{ {
const char *ip, *expire, *reason; const char *ip, *expire, *reason;
int expire_time; int expire_time;
hurt_t *hurt; hurt_t *hurt;
struct Client *target_p; struct Client *target_p;
if (!IsOperK(source_p)) { if (!IsOperK(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, sendto_one(source_p, form_str(ERR_NOPRIVS), me.name,
source_p->name, "kline"); source_p->name, "kline");
return 0; return 0;
} }
if (parc == 3) if (parc == 3)
expire = NULL, ip = parv[1], reason = parv[2]; expire = NULL, ip = parv[1], reason = parv[2];
else else
expire = parv[1], ip = parv[2], reason = parv[3]; expire = parv[1], ip = parv[2], reason = parv[3];
if (!expire) if (!expire)
expire_time = HURT_DEFAULT_EXPIRE; expire_time = HURT_DEFAULT_EXPIRE;
if (expire && (expire_time = valid_temp_time(expire)) < 1) { if (expire && (expire_time = valid_temp_time(expire)) < 1) {
sendto_one_notice(source_p, ":Permanent HURTs are not supported"); sendto_one_notice(source_p, ":Permanent HURTs are not supported");
return 0; return 0;
} }
if (EmptyString(reason)) { if (EmptyString(reason)) {
sendto_one_notice(source_p, ":Empty HURT reasons are bad for business"); sendto_one_notice(source_p, ":Empty HURT reasons are bad for business");
return 0; return 0;
} }
/* Is this a client? */ /* Is this a client? */
if (strchr(ip, '.') == NULL && strchr(ip, ':') == NULL) if (strchr(ip, '.') == NULL && strchr(ip, ':') == NULL) {
{ target_p = find_named_person(ip);
target_p = find_named_person(ip); if (target_p == NULL) {
if (target_p == NULL) sendto_one_numeric(source_p, ERR_NOSUCHNICK,
{ form_str(ERR_NOSUCHNICK), ip);
sendto_one_numeric(source_p, ERR_NOSUCHNICK, return 0;
form_str(ERR_NOSUCHNICK), ip); }
return 0; ip = target_p->orighost;
} } else {
ip = target_p->orighost; if (!strncmp(ip, "*@", 2))
} ip += 2;
else if (strchr(ip, '!') || strchr(ip, '@')) {
{ sendto_one_notice(source_p, ":Invalid HURT mask [%s]",
if (!strncmp(ip, "*@", 2)) ip);
ip += 2; return 0;
if (strchr(ip, '!') || strchr(ip, '@')) }
{ }
sendto_one_notice(source_p, ":Invalid HURT mask [%s]",
ip);
return 0;
}
}
if (hurt_find(ip) != NULL) { if (hurt_find(ip) != NULL) {
sendto_one(source_p, ":[%s] already HURT", ip); sendto_one(source_p, ":[%s] already HURT", ip);
return 0; return 0;
} }
/* /*
* okay, we've got this far, now it's time to add the the HURT locally * okay, we've got this far, now it's time to add the the HURT locally
* and propagate it to other servers on the network. * and propagate it to other servers on the network.
*/ */
sendto_realops_snomask(SNO_GENERAL, L_ALL, sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s added HURT on [%s] for %ld minutes with reason [%s]", "%s added HURT on [%s] for %ld minutes with reason [%s]",
get_oper_name(source_p), ip, (long) expire_time / 60, reason); get_oper_name(source_p), ip, (long) expire_time / 60, reason);
hurt = hurt_new(expire_time, ip, reason); hurt = hurt_new(expire_time, ip, reason);
hurt_add(hurt); hurt_add(hurt);
hurt_propagate(NULL, source_p, hurt); hurt_propagate(NULL, source_p, hurt);
return 0; return 0;
} }
/* }}} */ /* }}} */
@ -261,32 +255,32 @@ mo_hurt(struct Client *client_p, struct Client *source_p,
*/ */
static int static int
me_hurt(struct Client *client_p, struct Client *source_p, me_hurt(struct Client *client_p, struct Client *source_p,
int parc, const char **parv) int parc, const char **parv)
{ {
time_t expire_time; time_t expire_time;
hurt_t *hurt; hurt_t *hurt;
/* /*
* right... if we don't get enough arguments, or if we get any invalid * right... if we don't get enough arguments, or if we get any invalid
* arguments, just ignore this request - shit happens, and it's not worth * arguments, just ignore this request - shit happens, and it's not worth
* dropping a server over. * dropping a server over.
*/ */
if (parc < 4 || !IsPerson(source_p)) if (parc < 4 || !IsPerson(source_p))
return 0; return 0;
if ((expire_time = atoi(parv[1])) < 1) if ((expire_time = atoi(parv[1])) < 1)
return 0; return 0;
if (hurt_find(parv[2]) != NULL) if (hurt_find(parv[2]) != NULL)
return 0; return 0;
if (EmptyString(parv[3])) if (EmptyString(parv[3]))
return 0; return 0;
sendto_realops_snomask(SNO_GENERAL, L_ALL, sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s added HURT on [%s] for %ld minutes with reason [%s]", "%s added HURT on [%s] for %ld minutes with reason [%s]",
get_oper_name(source_p), parv[2], (long) expire_time / 60, parv[3]); get_oper_name(source_p), parv[2], (long) expire_time / 60, parv[3]);
hurt = hurt_new(expire_time, parv[2], parv[3]); hurt = hurt_new(expire_time, parv[2], parv[3]);
hurt_add(hurt); hurt_add(hurt);
return 0; return 0;
} }
/* }}} */ /* }}} */
@ -298,88 +292,76 @@ me_hurt(struct Client *client_p, struct Client *source_p,
*/ */
static int static int
mo_heal(struct Client *client_p, struct Client *source_p, mo_heal(struct Client *client_p, struct Client *source_p,
int parc, const char **parv) int parc, const char **parv)
{ {
struct Client *target_p; struct Client *target_p;
if (!IsOperUnkline(source_p)) if (!IsOperUnkline(source_p)) {
{ sendto_one(source_p, form_str(ERR_NOPRIVS),
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "unkline");
me.name, source_p->name, "unkline"); return 0;
return 0; }
}
if (nick_is_valid(parv[1])) if (nick_is_valid(parv[1])) {
{ target_p = find_named_person(parv[1]);
target_p = find_named_person(parv[1]); if (target_p == NULL) {
if (target_p == NULL) sendto_one_numeric(source_p, ERR_NOSUCHNICK,
{ form_str(ERR_NOSUCHNICK), parv[1]);
sendto_one_numeric(source_p, ERR_NOSUCHNICK, return 0;
form_str(ERR_NOSUCHNICK), parv[1]); }
return 0; if (MyConnect(target_p))
} heal_nick(source_p, target_p);
if (MyConnect(target_p)) else
heal_nick(source_p, target_p); sendto_one(target_p, ":%s ENCAP %s HEAL %s",
else get_id(source_p, target_p),
sendto_one(target_p, ":%s ENCAP %s HEAL %s", target_p->servptr->name,
get_id(source_p, target_p), get_id(target_p, target_p));
target_p->servptr->name, } else if (strchr(parv[1], '.')) {
get_id(target_p, target_p)); if (hurt_find_exact(parv[1]) == NULL) {
} sendto_one_notice(source_p, ":Mask [%s] is not HURT", parv[1]);
else if (strchr(parv[1], '.')) return 0;
{ }
if (hurt_find_exact(parv[1]) == NULL) hurt_remove(parv[1]);
{ sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s",
sendto_one_notice(source_p, ":Mask [%s] is not HURT", parv[1]); get_oper_name(source_p), parv[1]);
return 0; sendto_server(NULL, NULL, NOCAPS, NOCAPS, ":%s ENCAP * HEAL %s",
} source_p->name, parv[1]);
hurt_remove(parv[1]); } else {
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s", sendto_one(source_p, ":[%s] is not a valid IP address/nick", parv[1]);
get_oper_name(source_p), parv[1]); return 0;
sendto_server(NULL, NULL, NOCAPS, NOCAPS, ":%s ENCAP * HEAL %s", }
source_p->name, parv[1]);
}
else
{
sendto_one(source_p, ":[%s] is not a valid IP address/nick", parv[1]);
return 0;
}
return 0; return 0;
} }
/* }}} */ /* }}} */
static int static int
me_heal(struct Client *client_p, struct Client *source_p, me_heal(struct Client *client_p, struct Client *source_p,
int parc, const char **parv) int parc, const char **parv)
{ {
struct Client *target_p; struct Client *target_p;
/* as noted in me_hurt(), if we don't get sufficient arguments... /* as noted in me_hurt(), if we don't get sufficient arguments...
* *poof*, it's dropped... * *poof*, it's dropped...
*/ */
if (parc < 2) if (parc < 2)
return 0; return 0;
if (nick_is_valid(parv[1])) if (nick_is_valid(parv[1])) {
{ target_p = find_person(parv[1]);
target_p = find_person(parv[1]); if (target_p != NULL && MyConnect(target_p))
if (target_p != NULL && MyConnect(target_p)) heal_nick(source_p, target_p);
heal_nick(source_p, target_p); } else if (strchr(parv[1], '.')) { /* host or mask to remove ban for */
} if (hurt_find_exact(parv[1]) == NULL)
else if (strchr(parv[1], '.')) /* host or mask to remove ban for */ return 0;
{
if (hurt_find_exact(parv[1]) == NULL)
return 0;
hurt_remove(parv[1]); hurt_remove(parv[1]);
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s", sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s",
get_oper_name(source_p), parv[1]); get_oper_name(source_p), parv[1]);
} } else
else return 0;
return 0;
return 0; return 0;
} }
/* /*
@ -390,20 +372,18 @@ me_heal(struct Client *client_p, struct Client *source_p,
static void static void
hurt_check_event(void *arg) hurt_check_event(void *arg)
{ {
rb_dlink_node *ptr, *next_ptr; rb_dlink_node *ptr, *next_ptr;
struct Client *client_p; struct Client *client_p;
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) { RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) {
client_p = ptr->data; client_p = ptr->data;
if (!EmptyString(client_p->user->suser)) if (!EmptyString(client_p->user->suser)) {
{ rb_dlinkDestroy(ptr, &hurt_state.hurt_clients);
rb_dlinkDestroy(ptr, &hurt_state.hurt_clients); sendto_one_notice(client_p, ":HURT restriction removed for this session");
sendto_one_notice(client_p, ":HURT restriction removed for this session"); client_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */
client_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */ } else if (client_p->localClient->receiveM > hurt_state.cutoff)
} exit_client(NULL, client_p, &me, hurt_state.exit_reason);
else if (client_p->localClient->receiveM > hurt_state.cutoff) }
exit_client(NULL, client_p, &me, hurt_state.exit_reason);
}
} }
/* }}} */ /* }}} */
@ -411,19 +391,17 @@ hurt_check_event(void *arg)
static void static void
hurt_expire_event(void *unused) hurt_expire_event(void *unused)
{ {
rb_dlink_node *ptr, *next_ptr; rb_dlink_node *ptr, *next_ptr;
hurt_t *hurt; hurt_t *hurt;
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_confs.head) RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_confs.head) {
{ hurt = (hurt_t *) ptr->data;
hurt = (hurt_t *) ptr->data;
if (hurt->expire <= rb_current_time()) if (hurt->expire <= rb_current_time()) {
{ rb_dlinkFindDestroy(hurt, &hurt_confs);
rb_dlinkFindDestroy(hurt, &hurt_confs); hurt_destroy(hurt);
hurt_destroy(hurt); }
} }
}
} }
/* }}} */ /* }}} */
@ -435,10 +413,10 @@ hurt_expire_event(void *unused)
static void static void
client_exit_hook(hook_data_client_exit *data) client_exit_hook(hook_data_client_exit *data)
{ {
s_assert(data != NULL); s_assert(data != NULL);
s_assert(data->target != NULL); s_assert(data->target != NULL);
rb_dlinkFindDestroy(data->target, &hurt_state.hurt_clients); rb_dlinkFindDestroy(data->target, &hurt_state.hurt_clients);
} }
/* }}} */ /* }}} */
@ -446,17 +424,16 @@ client_exit_hook(hook_data_client_exit *data)
static void static void
new_local_user_hook(struct Client *source_p) new_local_user_hook(struct Client *source_p)
{ {
if (IsAnyDead(source_p) || !EmptyString(source_p->user->suser) || if (IsAnyDead(source_p) || !EmptyString(source_p->user->suser) ||
IsExemptKline(source_p)) IsExemptKline(source_p))
return; return;
if (hurt_find(source_p->sockhost) || hurt_find(source_p->orighost)) if (hurt_find(source_p->sockhost) || hurt_find(source_p->orighost)) {
{ source_p->localClient->target_last = rb_current_time() + 600; /* don't ask --nenolod */
source_p->localClient->target_last = rb_current_time() + 600; /* don't ask --nenolod */ SetTGChange(source_p);
SetTGChange(source_p); rb_dlinkAddAlloc(source_p, &hurt_state.hurt_clients);
rb_dlinkAddAlloc(source_p, &hurt_state.hurt_clients); sendto_one_notice(source_p, ":You are hurt. Please identify to services immediately, or use /stats p for assistance.");
sendto_one_notice(source_p, ":You are hurt. Please identify to services immediately, or use /stats p for assistance."); }
}
} }
/* }}} */ /* }}} */
@ -464,47 +441,43 @@ new_local_user_hook(struct Client *source_p)
static void static void
doing_stats_hook(hook_data_int *hdata) doing_stats_hook(hook_data_int *hdata)
{ {
rb_dlink_node *ptr; rb_dlink_node *ptr;
hurt_t *hurt; hurt_t *hurt;
struct Client *source_p; struct Client *source_p;
s_assert(hdata); s_assert(hdata);
s_assert(hdata->client); s_assert(hdata->client);
source_p = hdata->client; source_p = hdata->client;
if(hdata->arg2 != (int) 's') if(hdata->arg2 != (int) 's')
return; return;
if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p)) if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
return; return;
if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p)) if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p)) {
{ hurt = hurt_find(source_p->sockhost);
hurt = hurt_find(source_p->sockhost); if (hurt != NULL) {
if (hurt != NULL) sendto_one_numeric(source_p, RPL_STATSKLINE,
{ form_str(RPL_STATSKLINE), 's',
sendto_one_numeric(source_p, RPL_STATSKLINE, "*", hurt->ip, hurt->reason, "", "");
form_str(RPL_STATSKLINE), 's', return;
"*", hurt->ip, hurt->reason, "", ""); }
return;
}
hurt = hurt_find(source_p->orighost); hurt = hurt_find(source_p->orighost);
if (hurt != NULL) if (hurt != NULL) {
{ sendto_one_numeric(source_p, RPL_STATSKLINE,
sendto_one_numeric(source_p, RPL_STATSKLINE, form_str(RPL_STATSKLINE), 's',
form_str(RPL_STATSKLINE), 's', "*", hurt->ip, hurt->reason, "", "");
"*", hurt->ip, hurt->reason, "", ""); return;
return; }
} return;
return; }
}
RB_DLINK_FOREACH(ptr, hurt_confs.head) RB_DLINK_FOREACH(ptr, hurt_confs.head) {
{ hurt = (hurt_t *) ptr->data;
hurt = (hurt_t *) ptr->data; sendto_one_numeric(source_p, RPL_STATSKLINE,
sendto_one_numeric(source_p, RPL_STATSKLINE, form_str(RPL_STATSKLINE), 's',
form_str(RPL_STATSKLINE), 's', "*", hurt->ip, hurt->reason, "", "");
"*", hurt->ip, hurt->reason, "", ""); }
}
} }
/* }}} */ /* }}} */
@ -518,18 +491,18 @@ doing_stats_hook(hook_data_int *hdata)
static void static void
hurt_propagate(struct Client *client_p, struct Client *source_p, hurt_t *hurt) hurt_propagate(struct Client *client_p, struct Client *source_p, hurt_t *hurt)
{ {
if (client_p) if (client_p)
sendto_one(client_p, sendto_one(client_p,
":%s ENCAP %s HURT %ld %s :%s", ":%s ENCAP %s HURT %ld %s :%s",
source_p->name, client_p->name, source_p->name, client_p->name,
(long)(hurt->expire - rb_current_time()), (long)(hurt->expire - rb_current_time()),
hurt->ip, hurt->reason); hurt->ip, hurt->reason);
else else
sendto_server(&me, NULL, NOCAPS, NOCAPS, sendto_server(&me, NULL, NOCAPS, NOCAPS,
":%s ENCAP * HURT %ld %s :%s", ":%s ENCAP * HURT %ld %s :%s",
source_p->name, source_p->name,
(long)(hurt->expire - rb_current_time()), (long)(hurt->expire - rb_current_time()),
hurt->ip, hurt->reason); hurt->ip, hurt->reason);
} }
/* }}} */ /* }}} */
@ -537,15 +510,15 @@ hurt_propagate(struct Client *client_p, struct Client *source_p, hurt_t *hurt)
static hurt_t * static hurt_t *
hurt_new(time_t expire, const char *ip, const char *reason) hurt_new(time_t expire, const char *ip, const char *reason)
{ {
hurt_t *hurt; hurt_t *hurt;
hurt = rb_malloc(sizeof(hurt_t)); hurt = rb_malloc(sizeof(hurt_t));
hurt->ip = rb_strdup(ip); hurt->ip = rb_strdup(ip);
hurt->reason = rb_strdup(reason); hurt->reason = rb_strdup(reason);
hurt->expire = rb_current_time() + expire; hurt->expire = rb_current_time() + expire;
return hurt; return hurt;
} }
/* }}} */ /* }}} */
@ -553,85 +526,80 @@ hurt_new(time_t expire, const char *ip, const char *reason)
static void static void
hurt_destroy(void *hurt) hurt_destroy(void *hurt)
{ {
hurt_t *h; hurt_t *h;
if (!hurt) if (!hurt)
return; return;
h = (hurt_t *) hurt; h = (hurt_t *) hurt;
rb_free(h->ip); rb_free(h->ip);
rb_free(h->reason); rb_free(h->reason);
rb_free(h); rb_free(h);
} }
/* }}} */ /* }}} */
static void static void
hurt_add(hurt_t *hurt) hurt_add(hurt_t *hurt)
{ {
rb_dlinkAddAlloc(hurt, &hurt_confs); rb_dlinkAddAlloc(hurt, &hurt_confs);
} }
static hurt_t * static hurt_t *
hurt_find_exact(const char *ip) hurt_find_exact(const char *ip)
{ {
rb_dlink_node *ptr; rb_dlink_node *ptr;
hurt_t *hurt; hurt_t *hurt;
RB_DLINK_FOREACH(ptr, hurt_confs.head) RB_DLINK_FOREACH(ptr, hurt_confs.head) {
{ hurt = (hurt_t *) ptr->data;
hurt = (hurt_t *) ptr->data;
if (!strcasecmp(ip, hurt->ip)) if (!strcasecmp(ip, hurt->ip))
return hurt; return hurt;
} }
return NULL; return NULL;
} }
static hurt_t * static hurt_t *
hurt_find(const char *ip) hurt_find(const char *ip)
{ {
rb_dlink_node *ptr; rb_dlink_node *ptr;
hurt_t *hurt; hurt_t *hurt;
RB_DLINK_FOREACH(ptr, hurt_confs.head) RB_DLINK_FOREACH(ptr, hurt_confs.head) {
{ hurt = (hurt_t *) ptr->data;
hurt = (hurt_t *) ptr->data;
if (match(hurt->ip, ip)) if (match(hurt->ip, ip))
return hurt; return hurt;
} }
return NULL; return NULL;
} }
static void static void
hurt_remove(const char *ip) hurt_remove(const char *ip)
{ {
hurt_t *hurt = hurt_find_exact(ip); hurt_t *hurt = hurt_find_exact(ip);
rb_dlinkFindDestroy(hurt, &hurt_confs); rb_dlinkFindDestroy(hurt, &hurt_confs);
hurt_destroy(hurt); hurt_destroy(hurt);
} }
/* {{{ static int heal_nick() */ /* {{{ static int heal_nick() */
static int static int
heal_nick(struct Client *source_p, struct Client *target_p) heal_nick(struct Client *source_p, struct Client *target_p)
{ {
if (rb_dlinkFindDestroy(target_p, &hurt_state.hurt_clients)) if (rb_dlinkFindDestroy(target_p, &hurt_state.hurt_clients)) {
{ sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s used HEAL on %s",
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s used HEAL on %s", get_oper_name(source_p), get_client_name(target_p, HIDE_IP));
get_oper_name(source_p), get_client_name(target_p, HIDE_IP)); sendto_one_notice(target_p, ":HURT restriction temporarily removed by operator");
sendto_one_notice(target_p, ":HURT restriction temporarily removed by operator"); sendto_one_notice(source_p, ":HURT restriction on %s temporarily removed", target_p->name);
sendto_one_notice(source_p, ":HURT restriction on %s temporarily removed", target_p->name); target_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */
target_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */ return 1;
return 1; } else {
} sendto_one_notice(source_p, ":%s was not hurt", target_p->name);
else return 0;
{ }
sendto_one_notice(source_p, ":%s was not hurt", target_p->name);
return 0;
}
} }
/* }}} */ /* }}} */
@ -643,14 +611,14 @@ heal_nick(struct Client *source_p, struct Client *target_p)
static int static int
nick_is_valid(const char *nick) nick_is_valid(const char *nick)
{ {
const char *s = nick; const char *s = nick;
for (; *s != '\0'; s++) { for (; *s != '\0'; s++) {
if (!IsNickChar(*s)) if (!IsNickChar(*s))
return 0; return 0;
} }
return 1; return 1;
} }
/* }}} */ /* }}} */

View File

@ -1,4 +1,4 @@
/* /*
* Charybdis: an advanced ircd * Charybdis: an advanced ircd
* ip_cloaking.c: provide user hostname cloaking * ip_cloaking.c: provide user hostname cloaking
* *
@ -25,145 +25,136 @@ char *secretsalt = "32qwnqoWI@DpMd&w";
static void static void
conf_set_secretsalt(void *data) conf_set_secretsalt(void *data)
{ {
secretsalt = rb_strdup(data); secretsalt = rb_strdup(data);
} }
static int static int
_modinit(void) _modinit(void)
{ {
/* add the usermode to the available slot */ /* add the usermode to the available slot */
user_modes['x'] = find_umode_slot(); user_modes['x'] = find_umode_slot();
construct_umodebuf(); construct_umodebuf();
add_top_conf("cloaking", NULL, NULL, NULL); add_top_conf("cloaking", NULL, NULL, NULL);
add_conf_item("cloaking", "secretsalt", CF_QSTRING, conf_set_secretsalt); add_conf_item("cloaking", "secretsalt", CF_QSTRING, conf_set_secretsalt);
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
/* disable the umode and remove it from the available list */ /* disable the umode and remove it from the available list */
user_modes['x'] = 0; user_modes['x'] = 0;
construct_umodebuf(); construct_umodebuf();
add_top_conf("cloaking", NULL, NULL, NULL); add_top_conf("cloaking", NULL, NULL, NULL);
add_conf_item("cloaking", "secretsalt", CF_QSTRING, conf_set_secretsalt); add_conf_item("cloaking", "secretsalt", CF_QSTRING, conf_set_secretsalt);
} }
static void check_umode_change(void *data); static void check_umode_change(void *data);
static void check_new_user(void *data); static void check_new_user(void *data);
mapi_hfn_list_av1 ip_cloaking_hfnlist[] = { mapi_hfn_list_av1 ip_cloaking_hfnlist[] = {
{ "umode_changed", (hookfn) check_umode_change }, { "umode_changed", (hookfn) check_umode_change },
{ "new_local_user", (hookfn) check_new_user }, { "new_local_user", (hookfn) check_new_user },
{ NULL, NULL } { NULL, NULL }
}; };
DECLARE_MODULE_AV1(ip_cloaking, _modinit, _moddeinit, NULL, NULL, DECLARE_MODULE_AV1(ip_cloaking, _modinit, _moddeinit, NULL, NULL,
ip_cloaking_hfnlist, "$Revision: 3526 $"); ip_cloaking_hfnlist, "$Revision: 3526 $");
static void static void
distribute_hostchange(struct Client *client_p, char *newhost) distribute_hostchange(struct Client *client_p, char *newhost)
{ {
if (newhost != client_p->orighost) if (newhost != client_p->orighost)
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :is now your hidden host", sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
newhost); newhost);
else else
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :hostname reset", sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :hostname reset",
newhost); newhost);
sendto_server(NULL, NULL, sendto_server(NULL, NULL,
CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGHOST %s :%s", CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGHOST %s :%s",
use_id(&me), use_id(client_p), newhost); use_id(&me), use_id(client_p), newhost);
sendto_server(NULL, NULL, sendto_server(NULL, NULL,
CAP_TS6, CAP_EUID, ":%s ENCAP * CHGHOST %s :%s", CAP_TS6, CAP_EUID, ":%s ENCAP * CHGHOST %s :%s",
use_id(&me), use_id(client_p), newhost); use_id(&me), use_id(client_p), newhost);
change_nick_user_host(client_p, client_p->name, client_p->username, newhost, 0, "Changing host"); change_nick_user_host(client_p, client_p->name, client_p->username, newhost, 0, "Changing host");
if (newhost != client_p->orighost) if (newhost != client_p->orighost)
SetDynSpoof(client_p); SetDynSpoof(client_p);
else else
ClearDynSpoof(client_p); ClearDynSpoof(client_p);
} }
static void static void
do_host_cloak(const char *inbuf, char *outbuf) do_host_cloak(const char *inbuf, char *outbuf)
{ {
unsigned char *hash; unsigned char *hash;
char buf[3]; char buf[3];
char output[HOSTLEN+1]; char output[HOSTLEN+1];
int i; int i;
hash = HMAC(EVP_sha256(), secretsalt, strlen(secretsalt), (unsigned char*)inbuf, strlen(inbuf), NULL, NULL); hash = HMAC(EVP_sha256(), secretsalt, strlen(secretsalt), (unsigned char*)inbuf, strlen(inbuf), NULL, NULL);
output[0]=0; output[0]=0;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
sprintf(buf, "%.2x", hash[i]); sprintf(buf, "%.2x", hash[i]);
strcat(output,buf); strcat(output,buf);
} }
rb_strlcpy(outbuf,output,HOSTLEN+1); rb_strlcpy(outbuf,output,HOSTLEN+1);
} }
static void static void
check_umode_change(void *vdata) check_umode_change(void *vdata)
{ {
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata; hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
struct Client *source_p = data->client; struct Client *source_p = data->client;
if (!MyClient(source_p)) if (!MyClient(source_p))
return; return;
/* didn't change +h umode, we don't need to do anything */ /* didn't change +h umode, we don't need to do anything */
if (!((data->oldumodes ^ source_p->umodes) & user_modes['x'])) if (!((data->oldumodes ^ source_p->umodes) & user_modes['x']))
return; return;
if (source_p->umodes & user_modes['h']) if (source_p->umodes & user_modes['h']) {
{ if (IsIPSpoof(source_p) || source_p->localClient->mangledhost == NULL || (IsDynSpoof(source_p) && strcmp(source_p->host, source_p->localClient->mangledhost))) {
if (IsIPSpoof(source_p) || source_p->localClient->mangledhost == NULL || (IsDynSpoof(source_p) && strcmp(source_p->host, source_p->localClient->mangledhost))) source_p->umodes &= ~user_modes['x'];
{ return;
source_p->umodes &= ~user_modes['x']; }
return; if (strcmp(source_p->host, source_p->localClient->mangledhost)) {
} distribute_hostchange(source_p, source_p->localClient->mangledhost);
if (strcmp(source_p->host, source_p->localClient->mangledhost)) } else /* not really nice, but we need to send this numeric here */
{ sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
distribute_hostchange(source_p, source_p->localClient->mangledhost); source_p->host);
} } else if (!(source_p->umodes & user_modes['x'])) {
else /* not really nice, but we need to send this numeric here */ if (source_p->localClient->mangledhost != NULL &&
sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host", !strcmp(source_p->host, source_p->localClient->mangledhost)) {
source_p->host); distribute_hostchange(source_p, source_p->orighost);
} }
else if (!(source_p->umodes & user_modes['x'])) }
{
if (source_p->localClient->mangledhost != NULL &&
!strcmp(source_p->host, source_p->localClient->mangledhost))
{
distribute_hostchange(source_p, source_p->orighost);
}
}
} }
static void static void
check_new_user(void *vdata) check_new_user(void *vdata)
{ {
struct Client *source_p = (void *)vdata; struct Client *source_p = (void *)vdata;
if (IsIPSpoof(source_p)) if (IsIPSpoof(source_p)) {
{ source_p->umodes &= ~user_modes['x'];
source_p->umodes &= ~user_modes['x']; return;
return; }
} source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1);
source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1); do_host_cloak(source_p->orighost, source_p->localClient->mangledhost);
do_host_cloak(source_p->orighost, source_p->localClient->mangledhost); if (IsDynSpoof(source_p))
if (IsDynSpoof(source_p)) source_p->umodes &= ~user_modes['x'];
source_p->umodes &= ~user_modes['x']; if (source_p->umodes & user_modes['x']) {
if (source_p->umodes & user_modes['x']) rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host));
{ if (irccmp(source_p->host, source_p->orighost))
rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host)); SetDynSpoof(source_p);
if (irccmp(source_p->host, source_p->orighost)) }
SetDynSpoof(source_p);
}
} }

View File

@ -1,4 +1,4 @@
/* /*
* Charybdis: an advanced ircd * Charybdis: an advanced ircd
* ip_cloaking.c: provide user hostname cloaking * ip_cloaking.c: provide user hostname cloaking
* *
@ -20,206 +20,191 @@
static int static int
_modinit(void) _modinit(void)
{ {
/* add the usermode to the available slot */ /* add the usermode to the available slot */
user_modes['x'] = find_umode_slot(); user_modes['x'] = find_umode_slot();
construct_umodebuf(); construct_umodebuf();
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
/* disable the umode and remove it from the available list */ /* disable the umode and remove it from the available list */
user_modes['x'] = 0; user_modes['x'] = 0;
construct_umodebuf(); construct_umodebuf();
} }
static void check_umode_change(void *data); static void check_umode_change(void *data);
static void check_new_user(void *data); static void check_new_user(void *data);
mapi_hfn_list_av1 ip_cloaking_hfnlist[] = { mapi_hfn_list_av1 ip_cloaking_hfnlist[] = {
{ "umode_changed", (hookfn) check_umode_change }, { "umode_changed", (hookfn) check_umode_change },
{ "new_local_user", (hookfn) check_new_user }, { "new_local_user", (hookfn) check_new_user },
{ NULL, NULL } { NULL, NULL }
}; };
DECLARE_MODULE_AV1(ip_cloaking, _modinit, _moddeinit, NULL, NULL, DECLARE_MODULE_AV1(ip_cloaking, _modinit, _moddeinit, NULL, NULL,
ip_cloaking_hfnlist, "$Revision: 3526 $"); ip_cloaking_hfnlist, "$Revision: 3526 $");
static void static void
distribute_hostchange(struct Client *client_p, char *newhost) distribute_hostchange(struct Client *client_p, char *newhost)
{ {
if (newhost != client_p->orighost) if (newhost != client_p->orighost)
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :is now your hidden host", sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
newhost); newhost);
else else
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :hostname reset", sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :hostname reset",
newhost); newhost);
sendto_server(NULL, NULL, sendto_server(NULL, NULL,
CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGHOST %s :%s", CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGHOST %s :%s",
use_id(&me), use_id(client_p), newhost); use_id(&me), use_id(client_p), newhost);
sendto_server(NULL, NULL, sendto_server(NULL, NULL,
CAP_TS6, CAP_EUID, ":%s ENCAP * CHGHOST %s :%s", CAP_TS6, CAP_EUID, ":%s ENCAP * CHGHOST %s :%s",
use_id(&me), use_id(client_p), newhost); use_id(&me), use_id(client_p), newhost);
change_nick_user_host(client_p, client_p->name, client_p->username, newhost, 0, "Changing host"); change_nick_user_host(client_p, client_p->name, client_p->username, newhost, 0, "Changing host");
if (newhost != client_p->orighost) if (newhost != client_p->orighost)
SetDynSpoof(client_p); SetDynSpoof(client_p);
else else
ClearDynSpoof(client_p); ClearDynSpoof(client_p);
} }
static void static void
do_host_cloak_ip(const char *inbuf, char *outbuf) do_host_cloak_ip(const char *inbuf, char *outbuf)
{ {
/* None of the characters in this table can be valid in an IP */ /* None of the characters in this table can be valid in an IP */
char chartable[] = "ghijklmnopqrstuvwxyz"; char chartable[] = "ghijklmnopqrstuvwxyz";
char *tptr; char *tptr;
uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32); uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32);
int sepcount = 0; int sepcount = 0;
int totalcount = 0; int totalcount = 0;
int ipv6 = 0; int ipv6 = 0;
rb_strlcpy(outbuf, inbuf, HOSTLEN + 1); rb_strlcpy(outbuf, inbuf, HOSTLEN + 1);
if (strchr(outbuf, ':')) if (strchr(outbuf, ':')) {
{ ipv6 = 1;
ipv6 = 1;
/* Damn you IPv6... /* Damn you IPv6...
* We count the number of colons so we can calculate how much * We count the number of colons so we can calculate how much
* of the host to cloak. This is because some hostmasks may not * of the host to cloak. This is because some hostmasks may not
* have as many octets as we'd like. * have as many octets as we'd like.
* *
* We have to do this ahead of time because doing this during * We have to do this ahead of time because doing this during
* the actual cloaking would get ugly * the actual cloaking would get ugly
*/ */
for (tptr = outbuf; *tptr != '\0'; tptr++) for (tptr = outbuf; *tptr != '\0'; tptr++)
if (*tptr == ':') if (*tptr == ':')
totalcount++; totalcount++;
} } else if (!strchr(outbuf, '.'))
else if (!strchr(outbuf, '.')) return;
return;
for (tptr = outbuf; *tptr != '\0'; tptr++) for (tptr = outbuf; *tptr != '\0'; tptr++) {
{ if (*tptr == ':' || *tptr == '.') {
if (*tptr == ':' || *tptr == '.') sepcount++;
{ continue;
sepcount++; }
continue;
}
if (ipv6 && sepcount < totalcount / 2) if (ipv6 && sepcount < totalcount / 2)
continue; continue;
if (!ipv6 && sepcount < 2) if (!ipv6 && sepcount < 2)
continue; continue;
*tptr = chartable[(*tptr + accum) % 20]; *tptr = chartable[(*tptr + accum) % 20];
accum = (accum << 1) | (accum >> 31); accum = (accum << 1) | (accum >> 31);
} }
} }
static void static void
do_host_cloak_host(const char *inbuf, char *outbuf) do_host_cloak_host(const char *inbuf, char *outbuf)
{ {
char b26_alphabet[] = "abcdefghijklmnopqrstuvwxyz"; char b26_alphabet[] = "abcdefghijklmnopqrstuvwxyz";
char *tptr; char *tptr;
uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32); uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32);
rb_strlcpy(outbuf, inbuf, HOSTLEN + 1); rb_strlcpy(outbuf, inbuf, HOSTLEN + 1);
/* pass 1: scramble first section of hostname using base26 /* pass 1: scramble first section of hostname using base26
* alphabet toasted against the FNV hash of the string. * alphabet toasted against the FNV hash of the string.
* *
* numbers are not changed at this time, only letters. * numbers are not changed at this time, only letters.
*/ */
for (tptr = outbuf; *tptr != '\0'; tptr++) for (tptr = outbuf; *tptr != '\0'; tptr++) {
{ if (*tptr == '.')
if (*tptr == '.') break;
break;
if (isdigit(*tptr) || *tptr == '-') if (isdigit(*tptr) || *tptr == '-')
continue; continue;
*tptr = b26_alphabet[(*tptr + accum) % 26]; *tptr = b26_alphabet[(*tptr + accum) % 26];
/* Rotate one bit to avoid all digits being turned odd or even */ /* Rotate one bit to avoid all digits being turned odd or even */
accum = (accum << 1) | (accum >> 31); accum = (accum << 1) | (accum >> 31);
} }
/* pass 2: scramble each number in the address */ /* pass 2: scramble each number in the address */
for (tptr = outbuf; *tptr != '\0'; tptr++) for (tptr = outbuf; *tptr != '\0'; tptr++) {
{ if (isdigit(*tptr))
if (isdigit(*tptr)) *tptr = '0' + (*tptr + accum) % 10;
*tptr = '0' + (*tptr + accum) % 10;
accum = (accum << 1) | (accum >> 31); accum = (accum << 1) | (accum >> 31);
} }
} }
static void static void
check_umode_change(void *vdata) check_umode_change(void *vdata)
{ {
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata; hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
struct Client *source_p = data->client; struct Client *source_p = data->client;
if (!MyClient(source_p)) if (!MyClient(source_p))
return; return;
/* didn't change +h umode, we don't need to do anything */ /* didn't change +h umode, we don't need to do anything */
if (!((data->oldumodes ^ source_p->umodes) & user_modes['x'])) if (!((data->oldumodes ^ source_p->umodes) & user_modes['x']))
return; return;
if (source_p->umodes & user_modes['x']) if (source_p->umodes & user_modes['x']) {
{ if (IsIPSpoof(source_p) || source_p->localClient->mangledhost == NULL || (IsDynSpoof(source_p) && strcmp(source_p->host, source_p->localClient->mangledhost))) {
if (IsIPSpoof(source_p) || source_p->localClient->mangledhost == NULL || (IsDynSpoof(source_p) && strcmp(source_p->host, source_p->localClient->mangledhost))) source_p->umodes &= ~user_modes['x'];
{ return;
source_p->umodes &= ~user_modes['x']; }
return; if (strcmp(source_p->host, source_p->localClient->mangledhost)) {
} distribute_hostchange(source_p, source_p->localClient->mangledhost);
if (strcmp(source_p->host, source_p->localClient->mangledhost)) } else /* not really nice, but we need to send this numeric here */
{ sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
distribute_hostchange(source_p, source_p->localClient->mangledhost); source_p->host);
} } else if (!(source_p->umodes & user_modes['x'])) {
else /* not really nice, but we need to send this numeric here */ if (source_p->localClient->mangledhost != NULL &&
sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host", !strcmp(source_p->host, source_p->localClient->mangledhost)) {
source_p->host); distribute_hostchange(source_p, source_p->orighost);
} }
else if (!(source_p->umodes & user_modes['x'])) }
{
if (source_p->localClient->mangledhost != NULL &&
!strcmp(source_p->host, source_p->localClient->mangledhost))
{
distribute_hostchange(source_p, source_p->orighost);
}
}
} }
static void static void
check_new_user(void *vdata) check_new_user(void *vdata)
{ {
struct Client *source_p = (void *)vdata; struct Client *source_p = (void *)vdata;
if (IsIPSpoof(source_p)) if (IsIPSpoof(source_p)) {
{ source_p->umodes &= ~user_modes['x'];
source_p->umodes &= ~user_modes['x']; return;
return; }
} source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1);
source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1); if (!irccmp(source_p->orighost, source_p->sockhost))
if (!irccmp(source_p->orighost, source_p->sockhost)) do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost);
do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost); else
else do_host_cloak_host(source_p->orighost, source_p->localClient->mangledhost);
do_host_cloak_host(source_p->orighost, source_p->localClient->mangledhost); if (IsDynSpoof(source_p))
if (IsDynSpoof(source_p)) source_p->umodes &= ~user_modes['x'];
source_p->umodes &= ~user_modes['x']; if (source_p->umodes & user_modes['x']) {
if (source_p->umodes & user_modes['x']) rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host));
{ if (irccmp(source_p->host, source_p->orighost))
rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host)); SetDynSpoof(source_p);
if (irccmp(source_p->host, source_p->orighost)) }
SetDynSpoof(source_p);
}
} }

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (C) infinity-infinity God <God@Heaven> * Copyright (C) infinity-infinity God <God@Heaven>
* *
* Bob was here * Bob was here
*/ */
#include "stdinc.h" #include "stdinc.h"
@ -13,9 +13,10 @@
static int mclient_42(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); static int mclient_42(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message hgtg_msgtab = { struct Message hgtg_msgtab = {
"42", 0, 0, 0, MFLG_SLOW, "42", 0, 0, 0, MFLG_SLOW,
{ mg_ignore, {mclient_42, 0}, mg_ignore, mg_ignore, mg_ignore, {mclient_42, 0} {
} mg_ignore, {mclient_42, 0}, mg_ignore, mg_ignore, mg_ignore, {mclient_42, 0}
}
}; };
mapi_clist_av1 hgtg_clist[] = { &hgtg_msgtab, NULL }; mapi_clist_av1 hgtg_clist[] = { &hgtg_msgtab, NULL };
@ -27,8 +28,8 @@ DECLARE_MODULE_AV1(42, NULL, NULL, hgtg_clist, NULL, NULL, "Revision 0.42");
static int static int
mclient_42(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mclient_42(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
sendto_one_notice(source_p, ":The Answer to Life, the Universe, and Everything."); sendto_one_notice(source_p, ":The Answer to Life, the Universe, and Everything.");
return 0; return 0;
} }

View File

@ -41,10 +41,10 @@ static int mo_adminwall(struct Client *, struct Client *, int, const char **);
static int me_adminwall(struct Client *, struct Client *, int, const char **); static int me_adminwall(struct Client *, struct Client *, int, const char **);
struct Message adminwall_msgtab = { struct Message adminwall_msgtab = {
"ADMINWALL", 0, 0, 0, MFLG_SLOW, "ADMINWALL", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_adminwall, 2}, {mo_adminwall, 2}} {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_adminwall, 2}, {mo_adminwall, 2}}
}; };
mapi_clist_av1 adminwall_clist[] = { &adminwall_msgtab, NULL }; mapi_clist_av1 adminwall_clist[] = { &adminwall_msgtab, NULL };
DECLARE_MODULE_AV1(adminwall, NULL, NULL, adminwall_clist, NULL, NULL, "$Revision: 20702 $"); DECLARE_MODULE_AV1(adminwall, NULL, NULL, adminwall_clist, NULL, NULL, "$Revision: 20702 $");
@ -56,22 +56,21 @@ DECLARE_MODULE_AV1(adminwall, NULL, NULL, adminwall_clist, NULL, NULL, "$Revisio
*/ */
static int static int
mo_adminwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mo_adminwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
if(!IsAdmin(source_p)) if(!IsAdmin(source_p)) {
{ sendto_one(source_p, form_str(ERR_NOPRIVS),
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "adminwall");
me.name, source_p->name, "adminwall");
return 0;
}
sendto_wallops_flags(UMODE_ADMIN, source_p, "ADMINWALL - %s", parv[1]);
sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ADMINWALL :%s", parv[1]);
return 0; return 0;
} }
sendto_wallops_flags(UMODE_ADMIN, source_p, "ADMINWALL - %s", parv[1]);
sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ADMINWALL :%s", parv[1]);
return 0;
}
static int static int
me_adminwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) me_adminwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
sendto_wallops_flags(UMODE_ADMIN, source_p, "ADMINWALL - %s", parv[1]); sendto_wallops_flags(UMODE_ADMIN, source_p, "ADMINWALL - %s", parv[1]);
return 0; return 0;
} }

View File

@ -25,8 +25,8 @@ extern struct module **modlist;
static int m_cycle(struct Client *, struct Client *, int, const char **); static int m_cycle(struct Client *, struct Client *, int, const char **);
struct Message cycle_msgtab = { struct Message cycle_msgtab = {
"CYCLE", 0, 0, 0, MFLG_SLOW, "CYCLE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_cycle, 2}, {m_cycle, 2}, mg_ignore, mg_ignore, {m_cycle, 2}} {mg_unreg, {m_cycle, 2}, {m_cycle, 2}, mg_ignore, mg_ignore, {m_cycle, 2}}
}; };
mapi_clist_av1 cycle_clist[] = { &cycle_msgtab, NULL }; mapi_clist_av1 cycle_clist[] = { &cycle_msgtab, NULL };
@ -35,64 +35,58 @@ DECLARE_MODULE_AV1(cycle, NULL, NULL, cycle_clist, NULL, NULL, "$Revision$");
static int static int
m_cycle(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) m_cycle(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
char *p, *name; char *p, *name;
char *s = LOCAL_COPY(parv[1]); char *s = LOCAL_COPY(parv[1]);
struct Channel *chptr; struct Channel *chptr;
struct membership *msptr; struct membership *msptr;
name = rb_strtok_r(s, ",", &p); name = rb_strtok_r(s, ",", &p);
/* Finish the flood grace period... */ /* Finish the flood grace period... */
if(MyClient(source_p) && !IsFloodDone(source_p)) if(MyClient(source_p) && !IsFloodDone(source_p))
flood_endgrace(source_p); flood_endgrace(source_p);
while(name) while(name) {
{ if((chptr = find_channel(name)) == NULL) {
if((chptr = find_channel(name)) == NULL) sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
{ return 0;
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name); }
return 0;
}
msptr = find_channel_membership(chptr, source_p); msptr = find_channel_membership(chptr, source_p);
if(msptr == NULL) if(msptr == NULL) {
{ sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name);
sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name); return 0;
return 0; }
}
if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p)) if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p))
check_spambot_warning(source_p, NULL); check_spambot_warning(source_p, NULL);
if((is_any_op(msptr) || !MyConnect(source_p) ||
((can_send(chptr, source_p, msptr) > 0 &&
(source_p->localClient->firsttime +
ConfigFileEntry.anti_spam_exit_message_time) < rb_current_time()))))
{
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s :Cycling", use_id(source_p), chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :Cycling",
source_p->name, source_p->username,
source_p->host, chptr->chname);
}
else
{
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s", use_id(source_p), chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s",
source_p->name, source_p->username,
source_p->host, chptr->chname);
}
remove_user_from_channel(msptr);
chptr = NULL;
msptr = NULL;
name = rb_strtok_r(NULL, ",", &p);
}
user_join(client_p, source_p, parv[1], parc > 2 ? parv[2] : NULL);
return 0; if((is_any_op(msptr) || !MyConnect(source_p) ||
((can_send(chptr, source_p, msptr) > 0 &&
(source_p->localClient->firsttime +
ConfigFileEntry.anti_spam_exit_message_time) < rb_current_time())))) {
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s :Cycling", use_id(source_p), chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :Cycling",
source_p->name, source_p->username,
source_p->host, chptr->chname);
} else {
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s", use_id(source_p), chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s",
source_p->name, source_p->username,
source_p->host, chptr->chname);
}
remove_user_from_channel(msptr);
chptr = NULL;
msptr = NULL;
name = rb_strtok_r(NULL, ",", &p);
}
user_join(client_p, source_p, parv[1], parc > 2 ? parv[2] : NULL);
return 0;
} }

View File

@ -35,11 +35,11 @@
#include "packet.h" #include "packet.h"
static int m_findforwards(struct Client *client_p, struct Client *source_p, static int m_findforwards(struct Client *client_p, struct Client *source_p,
int parc, const char *parv[]); int parc, const char *parv[]);
struct Message findforwards_msgtab = { struct Message findforwards_msgtab = {
"FINDFORWARDS", 0, 0, 0, MFLG_SLOW, "FINDFORWARDS", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_findforwards, 2}, mg_ignore, mg_ignore, mg_ignore, {m_findforwards, 2}} {mg_unreg, {m_findforwards, 2}, mg_ignore, mg_ignore, mg_ignore, {m_findforwards, 2}}
}; };
mapi_clist_av1 findforwards_clist[] = { &findforwards_msgtab, NULL }; mapi_clist_av1 findforwards_clist[] = { &findforwards_msgtab, NULL };
@ -53,62 +53,54 @@ DECLARE_MODULE_AV1(findforwards, NULL, NULL, findforwards_clist, NULL, NULL, "$R
static int static int
m_findforwards(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) m_findforwards(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
static time_t last_used = 0; static time_t last_used = 0;
struct Channel *chptr; struct Channel *chptr;
struct membership *msptr; struct membership *msptr;
rb_dlink_node *ptr; rb_dlink_node *ptr;
char buf[414]; char buf[414];
char *p = buf, *end = buf + sizeof buf - 1; char *p = buf, *end = buf + sizeof buf - 1;
*p = '\0'; *p = '\0';
/* Allow ircops to search for forwards to nonexistent channels */ /* Allow ircops to search for forwards to nonexistent channels */
if(!IsOper(source_p)) if(!IsOper(source_p)) {
{ if((chptr = find_channel(parv[1])) == NULL || (msptr = find_channel_membership(chptr, source_p)) == NULL) {
if((chptr = find_channel(parv[1])) == NULL || (msptr = find_channel_membership(chptr, source_p)) == NULL) sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
{ form_str(ERR_NOTONCHANNEL), parv[1]);
sendto_one_numeric(source_p, ERR_NOTONCHANNEL, return 0;
form_str(ERR_NOTONCHANNEL), parv[1]); }
return 0;
}
if(!is_any_op(msptr)) if(!is_any_op(msptr)) {
{ sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), me.name, source_p->name, parv[1]);
me.name, source_p->name, parv[1]); return 0;
return 0; }
}
if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) {
{ sendto_one(source_p, form_str(RPL_LOAD2HI),
sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name, "FINDFORWARDS");
me.name, source_p->name, "FINDFORWARDS"); return 0;
return 0; } else
} last_used = rb_current_time();
else }
last_used = rb_current_time();
}
RB_DLINK_FOREACH(ptr, global_channel_list.head)
{
chptr = ptr->data;
if(chptr->mode.forward && !irccmp(chptr->mode.forward, parv[1]))
{
if(p + strlen(chptr->chname) >= end - 13)
{
strcpy(p, "<truncated> ");
p += 12;
break;
}
strcpy(p, chptr->chname);
p += strlen(chptr->chname);
*p++ = ' ';
}
}
if(buf[0]) RB_DLINK_FOREACH(ptr, global_channel_list.head) {
*(--p) = '\0'; chptr = ptr->data;
if(chptr->mode.forward && !irccmp(chptr->mode.forward, parv[1])) {
if(p + strlen(chptr->chname) >= end - 13) {
strcpy(p, "<truncated> ");
p += 12;
break;
}
strcpy(p, chptr->chname);
p += strlen(chptr->chname);
*p++ = ' ';
}
}
sendto_one_notice(source_p, ":Forwards for %s: %s", parv[1], buf); if(buf[0])
*(--p) = '\0';
return 0; sendto_one_notice(source_p, ":Forwards for %s: %s", parv[1], buf);
return 0;
} }

View File

@ -48,11 +48,11 @@
#include "modules.h" #include "modules.h"
static int mo_forcejoin(struct Client *client_p, struct Client *source_p, static int mo_forcejoin(struct Client *client_p, struct Client *source_p,
int parc, const char *parv[]); int parc, const char *parv[]);
struct Message forcejoin_msgtab = { struct Message forcejoin_msgtab = {
"FORCEJOIN", 0, 0, 0, MFLG_SLOW, "FORCEJOIN", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_forcejoin, 3}} {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_forcejoin, 3}}
}; };
mapi_clist_av1 force_clist[] = { &forcejoin_msgtab, NULL }; mapi_clist_av1 force_clist[] = { &forcejoin_msgtab, NULL };
@ -67,152 +67,137 @@ DECLARE_MODULE_AV1(force, NULL, NULL, force_clist, NULL, NULL, "$Revision: 3297
static int static int
mo_forcejoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mo_forcejoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
struct Client *target_p; struct Client *target_p;
struct Channel *chptr; struct Channel *chptr;
int type; int type;
char mode; char mode;
char sjmode; char sjmode;
char *newch; char *newch;
if(!IsOperAdmin(source_p)) if(!IsOperAdmin(source_p)) {
{ sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin"); return 0;
return 0; }
}
if((hunt_server(client_p, source_p, ":%s FORCEJOIN %s %s", 1, parc, parv)) != HUNTED_ISME) if((hunt_server(client_p, source_p, ":%s FORCEJOIN %s %s", 1, parc, parv)) != HUNTED_ISME)
return 0; return 0;
/* if target_p is not existant, print message /* if target_p is not existant, print message
* to source_p and bail - scuzzy * to source_p and bail - scuzzy
*/ */
if((target_p = find_client(parv[1])) == NULL) if((target_p = find_client(parv[1])) == NULL) {
{ sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, parv[1]);
sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, parv[1]); return 0;
return 0; }
}
if(!IsPerson(target_p)) if(!IsPerson(target_p))
return 0; return 0;
sendto_wallops_flags(UMODE_WALLOP, &me, sendto_wallops_flags(UMODE_WALLOP, &me,
"FORCEJOIN called for %s %s by %s!%s@%s", "FORCEJOIN called for %s %s by %s!%s@%s",
parv[1], parv[2], source_p->name, source_p->username, source_p->host); parv[1], parv[2], source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "FORCEJOIN called for %s %s by %s!%s@%s", ilog(L_MAIN, "FORCEJOIN called for %s %s by %s!%s@%s",
parv[1], parv[2], source_p->name, source_p->username, source_p->host); parv[1], parv[2], source_p->name, source_p->username, source_p->host);
sendto_server(NULL, NULL, NOCAPS, NOCAPS, sendto_server(NULL, NULL, NOCAPS, NOCAPS,
":%s WALLOPS :FORCEJOIN called for %s %s by %s!%s@%s", ":%s WALLOPS :FORCEJOIN called for %s %s by %s!%s@%s",
me.name, parv[1], parv[2], me.name, parv[1], parv[2],
source_p->name, source_p->username, source_p->host); source_p->name, source_p->username, source_p->host);
/* select our modes from parv[2] if they exist... (chanop) */ /* select our modes from parv[2] if they exist... (chanop) */
if(*parv[2] == '@') if(*parv[2] == '@') {
{ type = CHFL_CHANOP;
type = CHFL_CHANOP; mode = 'o';
mode = 'o'; sjmode = '@';
sjmode = '@'; } else if(*parv[2] == '+') {
} type = CHFL_VOICE;
else if(*parv[2] == '+') mode = 'v';
{ sjmode = '+';
type = CHFL_VOICE; } else {
mode = 'v'; type = CHFL_PEON;
sjmode = '+'; mode = sjmode = '\0';
} }
else
{
type = CHFL_PEON;
mode = sjmode = '\0';
}
if(mode != '\0') if(mode != '\0')
parv[2]++; parv[2]++;
if((chptr = find_channel(parv[2])) != NULL) if((chptr = find_channel(parv[2])) != NULL) {
{ if(IsMember(target_p, chptr)) {
if(IsMember(target_p, chptr)) /* debugging is fun... */
{ sendto_one_notice(source_p, ":*** Notice -- %s is already in %s",
/* debugging is fun... */ target_p->name, chptr->chname);
sendto_one_notice(source_p, ":*** Notice -- %s is already in %s", return 0;
target_p->name, chptr->chname); }
return 0;
}
add_user_to_channel(chptr, target_p, type); add_user_to_channel(chptr, target_p, type);
sendto_server(target_p, chptr, NOCAPS, NOCAPS, sendto_server(target_p, chptr, NOCAPS, NOCAPS,
":%s SJOIN %ld %s + :%c%s", ":%s SJOIN %ld %s + :%c%s",
me.name, (long) chptr->channelts, me.name, (long) chptr->channelts,
chptr->chname, type ? sjmode : ' ', target_p->name); chptr->chname, type ? sjmode : ' ', target_p->name);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s", sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
target_p->name, target_p->username, target_p->name, target_p->username,
target_p->host, chptr->chname); target_p->host, chptr->chname);
if(type) if(type)
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +%c %s", sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +%c %s",
me.name, chptr->chname, mode, target_p->name); me.name, chptr->chname, mode, target_p->name);
if(chptr->topic != NULL) if(chptr->topic != NULL) {
{ sendto_one(target_p, form_str(RPL_TOPIC), me.name,
sendto_one(target_p, form_str(RPL_TOPIC), me.name, target_p->name, chptr->chname, chptr->topic);
target_p->name, chptr->chname, chptr->topic); sendto_one(target_p, form_str(RPL_TOPICWHOTIME),
sendto_one(target_p, form_str(RPL_TOPICWHOTIME), me.name, source_p->name, chptr->chname,
me.name, source_p->name, chptr->chname, chptr->topic_info, chptr->topic_time);
chptr->topic_info, chptr->topic_time); }
}
channel_member_names(chptr, target_p, 1); channel_member_names(chptr, target_p, 1);
} } else {
else newch = LOCAL_COPY(parv[2]);
{ if(!check_channel_name(newch)) {
newch = LOCAL_COPY(parv[2]); sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name,
if(!check_channel_name(newch)) source_p->name, (unsigned char *) newch);
{ return 0;
sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name, }
source_p->name, (unsigned char *) newch);
return 0;
}
/* channel name must begin with & or # */ /* channel name must begin with & or # */
if(!IsChannelName(newch)) if(!IsChannelName(newch)) {
{ sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name,
sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name, source_p->name, (unsigned char *) newch);
source_p->name, (unsigned char *) newch); return 0;
return 0; }
}
/* newch can't be longer than CHANNELLEN */ /* newch can't be longer than CHANNELLEN */
if(strlen(newch) > CHANNELLEN) if(strlen(newch) > CHANNELLEN) {
{ sendto_one_notice(source_p, ":Channel name is too long");
sendto_one_notice(source_p, ":Channel name is too long"); return 0;
return 0; }
}
chptr = get_or_create_channel(target_p, newch, NULL); chptr = get_or_create_channel(target_p, newch, NULL);
add_user_to_channel(chptr, target_p, CHFL_CHANOP); add_user_to_channel(chptr, target_p, CHFL_CHANOP);
/* send out a join, make target_p join chptr */ /* send out a join, make target_p join chptr */
sendto_server(target_p, chptr, NOCAPS, NOCAPS, sendto_server(target_p, chptr, NOCAPS, NOCAPS,
":%s SJOIN %ld %s +nt :@%s", me.name, ":%s SJOIN %ld %s +nt :@%s", me.name,
(long) chptr->channelts, chptr->chname, target_p->name); (long) chptr->channelts, chptr->chname, target_p->name);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s", sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
target_p->name, target_p->username, target_p->name, target_p->username,
target_p->host, chptr->chname); target_p->host, chptr->chname);
chptr->mode.mode |= MODE_TOPICLIMIT; chptr->mode.mode |= MODE_TOPICLIMIT;
chptr->mode.mode |= MODE_NOPRIVMSGS; chptr->mode.mode |= MODE_NOPRIVMSGS;
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +nt", me.name, chptr->chname); sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +nt", me.name, chptr->chname);
target_p->localClient->last_join_time = rb_current_time(); target_p->localClient->last_join_time = rb_current_time();
channel_member_names(chptr, target_p, 1); channel_member_names(chptr, target_p, 1);
/* we do this to let the oper know that a channel was created, this will be /* we do this to let the oper know that a channel was created, this will be
* seen from the server handling the command instead of the server that * seen from the server handling the command instead of the server that
* the oper is on. * the oper is on.
*/ */
sendto_one_notice(source_p, ":*** Notice -- Creating channel %s", chptr->chname); sendto_one_notice(source_p, ":*** Notice -- Creating channel %s", chptr->chname);
} }
return 0; return 0;
} }

View File

@ -52,49 +52,45 @@ char *reconstruct_parv(int parc, const char *parv[]);
static int m_identify(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); static int m_identify(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message identify_msgtab = { struct Message identify_msgtab = {
"IDENTIFY", 0, 0, 0, MFLG_SLOW, "IDENTIFY", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_identify, 0}, mg_ignore, mg_ignore, mg_ignore, {m_identify, 0}} {mg_unreg, {m_identify, 0}, mg_ignore, mg_ignore, mg_ignore, {m_identify, 0}}
}; };
mapi_clist_av1 identify_clist[] = { mapi_clist_av1 identify_clist[] = {
&identify_msgtab, &identify_msgtab,
NULL NULL
}; };
DECLARE_MODULE_AV1(identify, NULL, NULL, identify_clist, NULL, NULL, "$Revision: 2729 $"); DECLARE_MODULE_AV1(identify, NULL, NULL, identify_clist, NULL, NULL, "$Revision: 2729 $");
char *reconstruct_parv(int parc, const char *parv[]) char *reconstruct_parv(int parc, const char *parv[])
{ {
static char tmpbuf[BUFSIZE]; int i; static char tmpbuf[BUFSIZE];
int i;
rb_strlcpy(tmpbuf, parv[0], BUFSIZE); rb_strlcpy(tmpbuf, parv[0], BUFSIZE);
for (i = 1; i < parc; i++) for (i = 1; i < parc; i++) {
{ rb_strlcat(tmpbuf, " ", BUFSIZE);
rb_strlcat(tmpbuf, " ", BUFSIZE); rb_strlcat(tmpbuf, parv[i], BUFSIZE);
rb_strlcat(tmpbuf, parv[i], BUFSIZE); }
} return tmpbuf;
return tmpbuf;
} }
static int m_identify(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) static int m_identify(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
const char *nick; const char *nick;
struct Client *target_p; struct Client *target_p;
if (parc < 2 || EmptyString(parv[1])) if (parc < 2 || EmptyString(parv[1])) {
{ sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name);
sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name); return 0;
return 0; }
}
nick = parv[1][0] == '#' ? SVS_chanserv_NICK : SVS_nickserv_NICK; nick = parv[1][0] == '#' ? SVS_chanserv_NICK : SVS_nickserv_NICK;
if ((target_p = find_named_person(nick)) && IsService(target_p)) if ((target_p = find_named_person(nick)) && IsService(target_p)) {
{ sendto_one(target_p, ":%s PRIVMSG %s :IDENTIFY %s", get_id(source_p, target_p), get_id(target_p, target_p), reconstruct_parv(parc - 1, &parv[1]));
sendto_one(target_p, ":%s PRIVMSG %s :IDENTIFY %s", get_id(source_p, target_p), get_id(target_p, target_p), reconstruct_parv(parc - 1, &parv[1])); } else {
} sendto_one_numeric(source_p, ERR_SERVICESDOWN, form_str(ERR_SERVICESDOWN), nick);
else }
{ return 0;
sendto_one_numeric(source_p, ERR_SERVICESDOWN, form_str(ERR_SERVICESDOWN), nick);
}
return 0;
} }

View File

@ -15,9 +15,9 @@
#include <string.h> #include <string.h>
static int m_mkpasswd(struct Client *client_p, struct Client *source_p, static int m_mkpasswd(struct Client *client_p, struct Client *source_p,
int parc, const char *parv[]); int parc, const char *parv[]);
static int mo_mkpasswd(struct Client *client_p, struct Client *source_p, static int mo_mkpasswd(struct Client *client_p, struct Client *source_p,
int parc, const char *parv[]); int parc, const char *parv[]);
static char *make_md5_salt(int); static char *make_md5_salt(int);
static char *make_sha256_salt(int); static char *make_sha256_salt(int);
@ -26,11 +26,11 @@ static char *generate_random_salt(char *, int);
static char *generate_poor_salt(char *, int); static char *generate_poor_salt(char *, int);
static char saltChars[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; static char saltChars[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
/* 0 .. 63, ascii - 64 */ /* 0 .. 63, ascii - 64 */
struct Message mkpasswd_msgtab = { struct Message mkpasswd_msgtab = {
"MKPASSWD", 0, 0, 0, MFLG_SLOW, "MKPASSWD", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_mkpasswd, 2}, mg_ignore, mg_ignore, mg_ignore, {mo_mkpasswd, 2}} {mg_unreg, {m_mkpasswd, 2}, mg_ignore, mg_ignore, mg_ignore, {mo_mkpasswd, 2}}
}; };
mapi_clist_av1 mkpasswd_clist[] = { &mkpasswd_msgtab, NULL }; mapi_clist_av1 mkpasswd_clist[] = { &mkpasswd_msgtab, NULL };
@ -45,46 +45,42 @@ DECLARE_MODULE_AV1(mkpasswd, NULL, NULL, mkpasswd_clist, NULL, NULL, "$Revision$
static int static int
m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
static time_t last_used = 0; static time_t last_used = 0;
char *salt; char *salt;
const char *hashtype; const char *hashtype;
const char hashdefault[] = "SHA512"; const char hashdefault[] = "SHA512";
if(EmptyString(parv[1])) if(EmptyString(parv[1])) {
{ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD");
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD"); return 0;
return 0; }
}
if(parc < 3) if(parc < 3)
hashtype = hashdefault; hashtype = hashdefault;
else else
hashtype = parv[2]; hashtype = parv[2];
if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) {
{ /* safe enough to give this on a local connect only */
/* safe enough to give this on a local connect only */ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name, "MKPASSWD");
sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name, "MKPASSWD"); return 0;
return 0; } else
} last_used = rb_current_time();
else
last_used = rb_current_time();
if(!irccmp(hashtype, "SHA256")) if(!irccmp(hashtype, "SHA256"))
salt = make_sha256_salt(16); salt = make_sha256_salt(16);
else if(!irccmp(hashtype, "SHA512")) else if(!irccmp(hashtype, "SHA512"))
salt = make_sha512_salt(16); salt = make_sha512_salt(16);
else if(!irccmp(hashtype, "MD5")) else if(!irccmp(hashtype, "MD5"))
salt = make_md5_salt(8); salt = make_md5_salt(8);
else else {
{ sendto_one_notice(source_p,
sendto_one_notice(source_p, ":MKPASSWD syntax error: MKPASSWD pass [SHA256|SHA512|MD5]");
":MKPASSWD syntax error: MKPASSWD pass [SHA256|SHA512|MD5]"); return 0;
return 0; }
}
sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt)); sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt));
return 0; return 0;
} }
/* mo_mkpasswd - mkpasswd message handler /* mo_mkpasswd - mkpasswd message handler
@ -94,124 +90,115 @@ m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const cha
static int static int
mo_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mo_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
char *salt; char *salt;
const char *hashtype; const char *hashtype;
const char hashdefault[] = "SHA512"; const char hashdefault[] = "SHA512";
if(EmptyString(parv[1])) if(EmptyString(parv[1])) {
{ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD");
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD"); return 0;
return 0; }
}
if(parc < 3) if(parc < 3)
hashtype = hashdefault; hashtype = hashdefault;
else else
hashtype = parv[2]; hashtype = parv[2];
if(!irccmp(hashtype, "SHA256")) if(!irccmp(hashtype, "SHA256"))
salt = make_sha256_salt(16); salt = make_sha256_salt(16);
else if(!irccmp(hashtype, "SHA512")) else if(!irccmp(hashtype, "SHA512"))
salt = make_sha512_salt(16); salt = make_sha512_salt(16);
else if(!irccmp(hashtype, "MD5")) else if(!irccmp(hashtype, "MD5"))
salt = make_md5_salt(8); salt = make_md5_salt(8);
else else {
{ sendto_one_notice(source_p,
sendto_one_notice(source_p, ":MKPASSWD syntax error: MKPASSWD pass [SHA256|SHA512|MD5]");
":MKPASSWD syntax error: MKPASSWD pass [SHA256|SHA512|MD5]"); return 0;
return 0; }
}
sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt)); sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt));
return 0; return 0;
} }
char * char *
make_md5_salt(int length) make_md5_salt(int length)
{ {
static char salt[21]; static char salt[21];
if(length > 16) if(length > 16) {
{ printf("MD5 salt length too long\n");
printf("MD5 salt length too long\n"); exit(0);
exit(0); }
} salt[0] = '$';
salt[0] = '$'; salt[1] = '1';
salt[1] = '1'; salt[2] = '$';
salt[2] = '$'; generate_random_salt(&salt[3], length);
generate_random_salt(&salt[3], length); salt[length + 3] = '$';
salt[length + 3] = '$'; salt[length + 4] = '\0';
salt[length + 4] = '\0'; return salt;
return salt;
} }
char * char *
make_sha256_salt(int length) make_sha256_salt(int length)
{ {
static char salt[21]; static char salt[21];
if(length > 16) if(length > 16) {
{ printf("SHA256 salt length too long\n");
printf("SHA256 salt length too long\n"); exit(0);
exit(0); }
} salt[0] = '$';
salt[0] = '$'; salt[1] = '5';
salt[1] = '5'; salt[2] = '$';
salt[2] = '$'; generate_random_salt(&salt[3], length);
generate_random_salt(&salt[3], length); salt[length + 3] = '$';
salt[length + 3] = '$'; salt[length + 4] = '\0';
salt[length + 4] = '\0'; return salt;
return salt;
} }
char * char *
make_sha512_salt(int length) make_sha512_salt(int length)
{ {
static char salt[21]; static char salt[21];
if(length > 16) if(length > 16) {
{ printf("SHA512 salt length too long\n");
printf("SHA512 salt length too long\n"); exit(0);
exit(0); }
} salt[0] = '$';
salt[0] = '$'; salt[1] = '6';
salt[1] = '6'; salt[2] = '$';
salt[2] = '$'; generate_random_salt(&salt[3], length);
generate_random_salt(&salt[3], length); salt[length + 3] = '$';
salt[length + 3] = '$'; salt[length + 4] = '\0';
salt[length + 4] = '\0'; return salt;
return salt;
} }
char * char *
generate_poor_salt(char *salt, int length) generate_poor_salt(char *salt, int length)
{ {
int i; int i;
srand(time(NULL)); srand(time(NULL));
for(i = 0; i < length; i++) for(i = 0; i < length; i++) {
{ salt[i] = saltChars[rand() % 64];
salt[i] = saltChars[rand() % 64]; }
} return (salt);
return (salt);
} }
char * char *
generate_random_salt(char *salt, int length) generate_random_salt(char *salt, int length)
{ {
char *buf; char *buf;
int fd, i; int fd, i;
if((fd = open("/dev/random", O_RDONLY)) < 0) if((fd = open("/dev/random", O_RDONLY)) < 0) {
{ return (generate_poor_salt(salt, length));
return (generate_poor_salt(salt, length)); }
} buf = calloc(1, length);
buf = calloc(1, length); if(read(fd, buf, length) != length) {
if(read(fd, buf, length) != length) free(buf);
{ return (generate_poor_salt(salt, length));
free(buf); }
return (generate_poor_salt(salt, length));
}
for(i = 0; i < length; i++) for(i = 0; i < length; i++) {
{ salt[i] = saltChars[abs(buf[i]) % 64];
salt[i] = saltChars[abs(buf[i]) % 64]; }
} free(buf);
free(buf); return (salt);
return (salt);
} }

View File

@ -9,9 +9,9 @@
static int mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); static int mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message oaccept_msgtab = { struct Message oaccept_msgtab = {
"OACCEPT", 0, 0, 0, MFLG_SLOW, "OACCEPT", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_oaccept, 2}} {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_oaccept, 2}}
}; };
mapi_clist_av1 oaccept_clist[] = { &oaccept_msgtab, NULL }; mapi_clist_av1 oaccept_clist[] = { &oaccept_msgtab, NULL };
@ -20,46 +20,42 @@ DECLARE_MODULE_AV1(oaccept, NULL, NULL, oaccept_clist, NULL, NULL, "$Id $");
static int static int
mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
struct Metadata *md; struct Metadata *md;
struct DictionaryIter iter; struct DictionaryIter iter;
struct Client *target_p; struct Client *target_p;
char text[10]; char text[10];
if(!(target_p = find_client(parv[1]))) if(!(target_p = find_client(parv[1]))) {
{ sendto_one(source_p, form_str(ERR_NOSUCHNICK), parv[1]);
sendto_one(source_p, form_str(ERR_NOSUCHNICK), parv[1]); return 0;
return 0; }
}
/* If we don't check for this, and some idiot tries to OACCEPT a server... */ /* If we don't check for this, and some idiot tries to OACCEPT a server... */
if(!IsPerson(target_p)) if(!IsPerson(target_p)) {
{ sendto_one_notice(source_p, ":That is a server, not a user. What are you doing?");
sendto_one_notice(source_p, ":That is a server, not a user. What are you doing?"); return 0;
return 0; }
}
rb_snprintf(text, sizeof(text), "O%s", source_p->id); rb_snprintf(text, sizeof(text), "O%s", source_p->id);
/* Provide a nice error message if you try to OACCEPT someone /* Provide a nice error message if you try to OACCEPT someone
* who you've already OACCEPTed. */ * who you've already OACCEPTed. */
DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) {
{ if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text)) {
if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text)) sendto_one_notice(source_p, ":You're already on %s's OACCEPT list", target_p->name);
{ return 0;
sendto_one_notice(source_p, ":You're already on %s's OACCEPT list", target_p->name); }
return 0; }
}
}
user_metadata_add(target_p, text, "OACCEPT", 1); user_metadata_add(target_p, text, "OACCEPT", 1);
sendto_wallops_flags(UMODE_WALLOP, &me, sendto_wallops_flags(UMODE_WALLOP, &me,
"OACCEPT called for %s by %s!%s@%s", "OACCEPT called for %s by %s!%s@%s",
target_p->name, target_p->name,
source_p->name, source_p->username, source_p->host); source_p->name, source_p->username, source_p->host);
sendto_server(NULL, NULL, NOCAPS, NOCAPS, sendto_server(NULL, NULL, NOCAPS, NOCAPS,
":%s WALLOPS :OACCEPT called for %s by %s!%s@%s", ":%s WALLOPS :OACCEPT called for %s by %s!%s@%s",
me.name, target_p->name, source_p->name, source_p->username, me.name, target_p->name, source_p->name, source_p->username,
source_p->host); source_p->host);
return 0; return 0;
} }

View File

@ -20,17 +20,17 @@
#include "stdinc.h" #include "stdinc.h"
#include "channel.h" #include "channel.h"
#include "client.h" #include "client.h"
#include "ircd.h" #include "ircd.h"
#include "numeric.h" #include "numeric.h"
#include "logger.h" #include "logger.h"
#include "s_serv.h" #include "s_serv.h"
#include "s_conf.h" #include "s_conf.h"
#include "s_newconf.h" #include "s_newconf.h"
#include "send.h" #include "send.h"
#include "whowas.h" #include "whowas.h"
#include "match.h" #include "match.h"
#include "hash.h" #include "hash.h"
#include "msg.h" #include "msg.h"
#include "parse.h" #include "parse.h"
#include "modules.h" #include "modules.h"
@ -39,8 +39,8 @@ static int mo_ojoin(struct Client *client_p, struct Client *source_p, int parc,
struct Message ojoin_msgtab = { struct Message ojoin_msgtab = {
"OJOIN", 0, 0, 0, MFLG_SLOW, "OJOIN", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_ojoin, 2}} {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_ojoin, 2}}
}; };
mapi_clist_av1 ojoin_clist[] = { &ojoin_msgtab, NULL }; mapi_clist_av1 ojoin_clist[] = { &ojoin_msgtab, NULL };
@ -54,133 +54,117 @@ DECLARE_MODULE_AV1(ojoin, NULL, NULL, ojoin_clist, NULL, NULL, "$Revision: 3554
static int static int
mo_ojoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mo_ojoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
struct Channel *chptr; struct Channel *chptr;
int move_me = 0; int move_me = 0;
/* admins only */ /* admins only */
if(!IsOperAdmin(source_p)) if(!IsOperAdmin(source_p)) {
{ sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin"); return 0;
return 0; }
}
if(*parv[1] == '@' || *parv[1] == '%' || *parv[1] == '+' || *parv[1] == '!' || *parv[1] == '~') if(*parv[1] == '@' || *parv[1] == '%' || *parv[1] == '+' || *parv[1] == '!' || *parv[1] == '~') {
{ parv[1]++;
parv[1]++; move_me = 1;
move_me = 1; }
}
if((chptr = find_channel(parv[1])) == NULL) if((chptr = find_channel(parv[1])) == NULL) {
{ sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), parv[1]);
form_str(ERR_NOSUCHCHANNEL), parv[1]); return 0;
return 0; }
}
if(IsMember(source_p, chptr)) if(IsMember(source_p, chptr)) {
{ sendto_one_notice(source_p, ":Please part %s before using OJOIN", parv[1]);
sendto_one_notice(source_p, ":Please part %s before using OJOIN", parv[1]); return 0;
return 0; }
}
if(move_me == 1) if(move_me == 1)
parv[1]--; parv[1]--;
sendto_wallops_flags(UMODE_WALLOP, &me, sendto_wallops_flags(UMODE_WALLOP, &me,
"OJOIN called for %s by %s!%s@%s", "OJOIN called for %s by %s!%s@%s",
parv[1], source_p->name, source_p->username, source_p->host); parv[1], source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OJOIN called for %s by %s", ilog(L_MAIN, "OJOIN called for %s by %s",
parv[1], get_oper_name(source_p)); parv[1], get_oper_name(source_p));
/* only sends stuff for #channels remotely */ /* only sends stuff for #channels remotely */
sendto_server(NULL, chptr, NOCAPS, NOCAPS, sendto_server(NULL, chptr, NOCAPS, NOCAPS,
":%s WALLOPS :OJOIN called for %s by %s!%s@%s", ":%s WALLOPS :OJOIN called for %s by %s!%s@%s",
me.name, parv[1], me.name, parv[1],
source_p->name, source_p->username, source_p->host); source_p->name, source_p->username, source_p->host);
if(*parv[1] == '~' && ConfigChannel.use_owner) if(*parv[1] == '~' && ConfigChannel.use_owner) {
{ add_user_to_channel(chptr, source_p, CHFL_OWNER);
add_user_to_channel(chptr, source_p, CHFL_OWNER); sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
sendto_server(client_p, chptr, CAP_TS6, NOCAPS, ":%s SJOIN %ld %s + :~%s",
":%s SJOIN %ld %s + :~%s", me.id, (long) chptr->channelts, chptr->chname, source_p->id);
me.id, (long) chptr->channelts, chptr->chname, source_p->id); sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s", source_p->name,
source_p->name, source_p->username, source_p->host, chptr->chname);
source_p->username, source_p->host, chptr->chname); sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +y %s",
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +y %s", me.name, chptr->chname, source_p->name);
me.name, chptr->chname, source_p->name); } else if(*parv[1] == '!' && ConfigChannel.use_admin) {
} add_user_to_channel(chptr, source_p, CHFL_ADMIN);
else if(*parv[1] == '!' && ConfigChannel.use_admin) sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
{ ":%s SJOIN %ld %s + :!%s",
add_user_to_channel(chptr, source_p, CHFL_ADMIN); me.id, (long) chptr->channelts, chptr->chname, source_p->id);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS, sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
":%s SJOIN %ld %s + :!%s", source_p->name,
me.id, (long) chptr->channelts, chptr->chname, source_p->id); source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s", sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
source_p->name, me.name, chptr->chname, source_p->name);
source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
me.name, chptr->chname, source_p->name);
} } else if(*parv[1] == '@') {
else if(*parv[1] == '@') add_user_to_channel(chptr, source_p, CHFL_CHANOP);
{ sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
add_user_to_channel(chptr, source_p, CHFL_CHANOP); ":%s SJOIN %ld %s + :@%s",
sendto_server(client_p, chptr, CAP_TS6, NOCAPS, me.id, (long) chptr->channelts, chptr->chname, source_p->id);
":%s SJOIN %ld %s + :@%s", sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
me.id, (long) chptr->channelts, chptr->chname, source_p->id); source_p->name,
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s", source_p->username, source_p->host, chptr->chname);
source_p->name, sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
source_p->username, source_p->host, chptr->chname); me.name, chptr->chname, source_p->name);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
me.name, chptr->chname, source_p->name);
} } else if(*parv[1] == '%' && ConfigChannel.use_halfop) {
else if(*parv[1] == '%' && ConfigChannel.use_halfop) add_user_to_channel(chptr, source_p, CHFL_HALFOP);
{ sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
add_user_to_channel(chptr, source_p, CHFL_HALFOP); ":%s SJOIN %ld %s + :%s%s",
sendto_server(client_p, chptr, CAP_TS6, NOCAPS, me.id, (long) chptr->channelts, chptr->chname, "%", source_p->id);
":%s SJOIN %ld %s + :%s%s", sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
me.id, (long) chptr->channelts, chptr->chname, "%", source_p->id); source_p->name,
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s", source_p->username, source_p->host, chptr->chname);
source_p->name, sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s",
source_p->username, source_p->host, chptr->chname); me.name, chptr->chname, source_p->name);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s", } else if(*parv[1] == '+') {
me.name, chptr->chname, source_p->name); add_user_to_channel(chptr, source_p, CHFL_VOICE);
} sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
else if(*parv[1] == '+') ":%s SJOIN %ld %s + :+%s",
{ me.id, (long) chptr->channelts, chptr->chname, source_p->id);
add_user_to_channel(chptr, source_p, CHFL_VOICE); sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
sendto_server(client_p, chptr, CAP_TS6, NOCAPS, source_p->name,
":%s SJOIN %ld %s + :+%s", source_p->username, source_p->host, chptr->chname);
me.id, (long) chptr->channelts, chptr->chname, source_p->id); sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +v %s",
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s", me.name, chptr->chname, source_p->name);
source_p->name, } else {
source_p->username, source_p->host, chptr->chname); add_user_to_channel(chptr, source_p, CHFL_PEON);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +v %s", sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
me.name, chptr->chname, source_p->name); ":%s JOIN %ld %s +",
} source_p->id, (long) chptr->channelts, chptr->chname);
else sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
{ source_p->name,
add_user_to_channel(chptr, source_p, CHFL_PEON); source_p->username, source_p->host, chptr->chname);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS, }
":%s JOIN %ld %s +",
source_p->id, (long) chptr->channelts, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
}
/* send the topic... */ /* send the topic... */
if(chptr->topic != NULL) if(chptr->topic != NULL) {
{ sendto_one(source_p, form_str(RPL_TOPIC), me.name,
sendto_one(source_p, form_str(RPL_TOPIC), me.name, source_p->name, chptr->chname, chptr->topic);
source_p->name, chptr->chname, chptr->topic); sendto_one(source_p, form_str(RPL_TOPICWHOTIME), me.name,
sendto_one(source_p, form_str(RPL_TOPICWHOTIME), me.name, source_p->name, chptr->chname, chptr->topic_info, chptr->topic_time);
source_p->name, chptr->chname, chptr->topic_info, chptr->topic_time); }
}
source_p->localClient->last_join_time = rb_current_time(); source_p->localClient->last_join_time = rb_current_time();
channel_member_names(chptr, source_p, 1); channel_member_names(chptr, source_p, 1);
return 0; return 0;
} }

View File

@ -41,8 +41,8 @@ static int mo_okick(struct Client *client_p, struct Client *source_p, int parc,
struct Message okick_msgtab = { struct Message okick_msgtab = {
"OKICK", 0, 0, 0, MFLG_SLOW, "OKICK", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_okick, 4}} {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_okick, 4}}
}; };
mapi_clist_av1 okick_clist[] = { &okick_msgtab, NULL }; mapi_clist_av1 okick_clist[] = { &okick_msgtab, NULL };
@ -58,89 +58,84 @@ DECLARE_MODULE_AV1(okick, NULL, NULL, okick_clist, NULL, NULL, "$Revision: 3554
static int static int
mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
struct Client *who; struct Client *who;
struct Client *target_p; struct Client *target_p;
struct Channel *chptr; struct Channel *chptr;
struct membership *msptr; struct membership *msptr;
int chasing = 0; int chasing = 0;
char *comment; char *comment;
char *name; char *name;
char *p = NULL; char *p = NULL;
char *user; char *user;
char text[10]; char text[10];
static char buf[BUFSIZE]; static char buf[BUFSIZE];
if(*parv[2] == '\0') if(*parv[2] == '\0') {
{ sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "KICK");
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "KICK"); return 0;
return 0; }
}
if(MyClient(source_p) && !IsFloodDone(source_p)) if(MyClient(source_p) && !IsFloodDone(source_p))
flood_endgrace(source_p); flood_endgrace(source_p);
comment = (EmptyString(LOCAL_COPY(parv[3]))) ? LOCAL_COPY(parv[2]) : LOCAL_COPY(parv[3]); comment = (EmptyString(LOCAL_COPY(parv[3]))) ? LOCAL_COPY(parv[2]) : LOCAL_COPY(parv[3]);
if(strlen(comment) > (size_t) TOPICLEN) if(strlen(comment) > (size_t) TOPICLEN)
comment[TOPICLEN] = '\0'; comment[TOPICLEN] = '\0';
*buf = '\0'; *buf = '\0';
if((p = strchr(parv[1], ','))) if((p = strchr(parv[1], ',')))
*p = '\0'; *p = '\0';
name = LOCAL_COPY(parv[1]); name = LOCAL_COPY(parv[1]);
chptr = find_channel(name); chptr = find_channel(name);
if(!chptr) if(!chptr) {
{ sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name); return 0;
return 0; }
}
if((p = strchr(parv[2], ','))) if((p = strchr(parv[2], ',')))
*p = '\0'; *p = '\0';
user = LOCAL_COPY(parv[2]); // strtoken(&p2, parv[2], ","); user = LOCAL_COPY(parv[2]); // strtoken(&p2, parv[2], ",");
if(!(who = find_chasing(source_p, user, &chasing))) if(!(who = find_chasing(source_p, user, &chasing))) {
{ return 0;
return 0; }
}
if((target_p = find_client(user)) == NULL) if((target_p = find_client(user)) == NULL) {
{ sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, user);
sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, user); return 0;
return 0; }
}
if((msptr = find_channel_membership(chptr, target_p)) == NULL) if((msptr = find_channel_membership(chptr, target_p)) == NULL) {
{ sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL),
sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL), me.name, source_p->name, parv[1], parv[2]);
me.name, source_p->name, parv[1], parv[2]); return 0;
return 0; }
}
sendto_wallops_flags(UMODE_WALLOP, &me, sendto_wallops_flags(UMODE_WALLOP, &me,
"OKICK called for %s %s by %s!%s@%s", "OKICK called for %s %s by %s!%s@%s",
chptr->chname, target_p->name, chptr->chname, target_p->name,
source_p->name, source_p->username, source_p->host); source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OKICK called for %s %s by %s", ilog(L_MAIN, "OKICK called for %s %s by %s",
chptr->chname, target_p->name, chptr->chname, target_p->name,
get_oper_name(source_p)); get_oper_name(source_p));
/* only sends stuff for #channels remotely */ /* only sends stuff for #channels remotely */
sendto_server(NULL, chptr, NOCAPS, NOCAPS, sendto_server(NULL, chptr, NOCAPS, NOCAPS,
":%s WALLOPS :OKICK called for %s %s by %s!%s@%s", ":%s WALLOPS :OKICK called for %s %s by %s!%s@%s",
me.name, chptr->chname, target_p->name, me.name, chptr->chname, target_p->name,
source_p->name, source_p->username, source_p->host); source_p->name, source_p->username, source_p->host);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s KICK %s %s :%s", sendto_channel_local(ALL_MEMBERS, chptr, ":%s KICK %s %s :%s",
me.name, chptr->chname, who->name, comment); me.name, chptr->chname, who->name, comment);
sendto_server(&me, chptr, CAP_TS6, NOCAPS, sendto_server(&me, chptr, CAP_TS6, NOCAPS,
":%s KICK %s %s :%s", me.id, chptr->chname, who->id, comment); ":%s KICK %s %s :%s", me.id, chptr->chname, who->id, comment);
remove_user_from_channel(msptr); remove_user_from_channel(msptr);
rb_snprintf(text, sizeof(text), "K%s", who->id); rb_snprintf(text, sizeof(text), "K%s", who->id);
/* we don't need to track NOREJOIN stuff unless it's our client being kicked */ /* we don't need to track NOREJOIN stuff unless it's our client being kicked */
if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN) if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN)
channel_metadata_time_add(chptr, text, rb_current_time(), "KICKNOREJOIN"); channel_metadata_time_add(chptr, text, rb_current_time(), "KICKNOREJOIN");
return 0; return 0;
} }

View File

@ -46,8 +46,8 @@ static int mo_olist(struct Client *, struct Client *, int parc, const char *parv
#ifndef STATIC_MODULES #ifndef STATIC_MODULES
struct Message olist_msgtab = { struct Message olist_msgtab = {
"OLIST", 0, 0, 0, MFLG_SLOW, "OLIST", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_olist, 1}} {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_olist, 1}}
}; };
mapi_clist_av1 olist_clist[] = { &olist_msgtab, NULL }; mapi_clist_av1 olist_clist[] = { &olist_msgtab, NULL };
@ -66,23 +66,22 @@ static void list_named_channel(struct Client *source_p, const char *name);
static int static int
mo_olist(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mo_olist(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
if(!IsOperSpy(source_p)) if(!IsOperSpy(source_p)) {
{ sendto_one(source_p, form_str(ERR_NOPRIVS),
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "oper_spy");
me.name, source_p->name, "oper_spy"); sendto_one(source_p, form_str(RPL_LISTEND),
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
me.name, source_p->name); return 0;
return 0; }
}
/* If no arg, do all channels *whee*, else just one channel */ /* If no arg, do all channels *whee*, else just one channel */
if(parc < 2 || EmptyString(parv[1])) if(parc < 2 || EmptyString(parv[1]))
list_all_channels(source_p); list_all_channels(source_p);
else else
list_named_channel(source_p, parv[1]); list_named_channel(source_p, parv[1]);
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name); sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
return 0; return 0;
} }
@ -95,24 +94,23 @@ mo_olist(struct Client *client_p, struct Client *source_p, int parc, const char
static void static void
list_all_channels(struct Client *source_p) list_all_channels(struct Client *source_p)
{ {
struct Channel *chptr; struct Channel *chptr;
rb_dlink_node *ptr; rb_dlink_node *ptr;
report_operspy(source_p, "LIST", NULL); report_operspy(source_p, "LIST", NULL);
sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name); sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
RB_DLINK_FOREACH(ptr, global_channel_list.head) RB_DLINK_FOREACH(ptr, global_channel_list.head) {
{ chptr = ptr->data;
chptr = ptr->data;
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s", sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s",
me.name, source_p->name, chptr->chname, me.name, source_p->name, chptr->chname,
rb_dlink_list_length(&chptr->members), rb_dlink_list_length(&chptr->members),
channel_modes(chptr, &me), channel_modes(chptr, &me),
chptr->topic == NULL ? "" : chptr->topic); chptr->topic == NULL ? "" : chptr->topic);
} }
return; return;
} }
/* /*
@ -124,28 +122,28 @@ list_all_channels(struct Client *source_p)
static void static void
list_named_channel(struct Client *source_p, const char *name) list_named_channel(struct Client *source_p, const char *name)
{ {
struct Channel *chptr; struct Channel *chptr;
char *p; char *p;
char *n = LOCAL_COPY(name); char *n = LOCAL_COPY(name);
if((p = strchr(n, ','))) if((p = strchr(n, ',')))
*p = '\0'; *p = '\0';
/* Put operspy notice before any output, but only if channel exists */ /* Put operspy notice before any output, but only if channel exists */
chptr = EmptyString(n) ? NULL : find_channel(n); chptr = EmptyString(n) ? NULL : find_channel(n);
if(chptr != NULL) if(chptr != NULL)
report_operspy(source_p, "LIST", chptr->chname); report_operspy(source_p, "LIST", chptr->chname);
sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name); sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
if(EmptyString(n)) if(EmptyString(n))
return; return;
if(chptr == NULL) if(chptr == NULL)
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), n); form_str(ERR_NOSUCHCHANNEL), n);
else else
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s", me.name, source_p->name, sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s", me.name, source_p->name,
chptr->chname, rb_dlink_list_length(&chptr->members), chptr->chname, rb_dlink_list_length(&chptr->members),
channel_modes(chptr, &me), chptr->topic ? chptr->topic : ""); channel_modes(chptr, &me), chptr->topic ? chptr->topic : "");
} }

View File

@ -44,8 +44,8 @@
static int mo_omode(struct Client *, struct Client *, int, const char **); static int mo_omode(struct Client *, struct Client *, int, const char **);
struct Message omode_msgtab = { struct Message omode_msgtab = {
"OMODE", 0, 0, 0, MFLG_SLOW, "OMODE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_omode, 3}} {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_omode, 3}}
}; };
mapi_clist_av1 omode_clist[] = { &omode_msgtab, NULL }; mapi_clist_av1 omode_clist[] = { &omode_msgtab, NULL };
@ -59,199 +59,174 @@ DECLARE_MODULE_AV1(omode, NULL, NULL, omode_clist, NULL, NULL, "$Revision: 3121
static int static int
mo_omode(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mo_omode(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
struct Channel *chptr = NULL; struct Channel *chptr = NULL;
struct membership *msptr; struct membership *msptr;
char params[512]; char params[512];
int i; int i;
int wasonchannel; int wasonchannel;
/* admins only */ /* admins only */
if(!IsOperAdmin(source_p)) if(!IsOperAdmin(source_p)) {
{ sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin"); return 0;
return 0; }
}
/* Now, try to find the channel in question */ /* Now, try to find the channel in question */
if(!IsChanPrefix(parv[1][0]) || !check_channel_name(parv[1])) if(!IsChanPrefix(parv[1][0]) || !check_channel_name(parv[1])) {
{ sendto_one_numeric(source_p, ERR_BADCHANNAME,
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), parv[1]);
form_str(ERR_BADCHANNAME), parv[1]); return 0;
return 0; }
}
chptr = find_channel(parv[1]); chptr = find_channel(parv[1]);
if(chptr == NULL) if(chptr == NULL) {
{ sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), parv[1]);
form_str(ERR_NOSUCHCHANNEL), parv[1]); return 0;
return 0; }
}
/* Now know the channel exists */ /* Now know the channel exists */
msptr = find_channel_membership(chptr, source_p); msptr = find_channel_membership(chptr, source_p);
wasonchannel = msptr != NULL; wasonchannel = msptr != NULL;
if (is_any_op(msptr)) if (is_any_op(msptr)) {
{ sendto_one_notice(source_p, ":Use a normal MODE you idiot");
sendto_one_notice(source_p, ":Use a normal MODE you idiot"); return 0;
return 0; }
}
params[0] = '\0'; params[0] = '\0';
for (i = 2; i < parc; i++) for (i = 2; i < parc; i++) {
{ if (i != 2)
if (i != 2) rb_strlcat(params, " ", sizeof params);
rb_strlcat(params, " ", sizeof params); rb_strlcat(params, parv[i], sizeof params);
rb_strlcat(params, parv[i], sizeof params); }
}
sendto_wallops_flags(UMODE_WALLOP, &me, sendto_wallops_flags(UMODE_WALLOP, &me,
"OMODE called for [%s] [%s] by %s!%s@%s", "OMODE called for [%s] [%s] by %s!%s@%s",
parv[1], params, source_p->name, source_p->username, source_p->host); parv[1], params, source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OMODE called for [%s] [%s] by %s", ilog(L_MAIN, "OMODE called for [%s] [%s] by %s",
parv[1], params, get_oper_name(source_p)); parv[1], params, get_oper_name(source_p));
if(*chptr->chname != '&') if(*chptr->chname != '&')
sendto_server(NULL, NULL, NOCAPS, NOCAPS, sendto_server(NULL, NULL, NOCAPS, NOCAPS,
":%s WALLOPS :OMODE called for [%s] [%s] by %s!%s@%s", ":%s WALLOPS :OMODE called for [%s] [%s] by %s!%s@%s",
me.name, parv[1], params, source_p->name, source_p->username, me.name, parv[1], params, source_p->name, source_p->username,
source_p->host); source_p->host);
#if 0 #if 0
set_channel_mode(client_p, source_p->servptr, chptr, msptr, set_channel_mode(client_p, source_p->servptr, chptr, msptr,
parc - 2, parv + 2); parc - 2, parv + 2);
#else #else
if (parc == 4 && !strcmp(parv[2], "+y") && !irccmp(parv[3], source_p->name)) if (parc == 4 && !strcmp(parv[2], "+y") && !irccmp(parv[3], source_p->name)) {
{ /* Ownering themselves */
/* Ownering themselves */ if (!wasonchannel) {
if (!wasonchannel) sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
{ form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, return 0;
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
return 0;
}
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +y %s",
me.name, parv[1], source_p->name);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
":%s TMODE %ld %s +y %s",
me.id, (long) chptr->channelts, parv[1],
source_p->id);
msptr->flags |= CHFL_OWNER;
} }
else if (parc == 4 && !strcmp(parv[2], "+a") && !irccmp(parv[3], source_p->name)) sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +y %s",
{ me.name, parv[1], source_p->name);
/* Admining themselves */ sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
if (!wasonchannel) ":%s TMODE %ld %s +y %s",
{ me.id, (long) chptr->channelts, parv[1],
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, source_p->id);
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname); msptr->flags |= CHFL_OWNER;
return 0; } else if (parc == 4 && !strcmp(parv[2], "+a") && !irccmp(parv[3], source_p->name)) {
} /* Admining themselves */
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s", if (!wasonchannel) {
me.name, parv[1], source_p->name); sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
sendto_server(NULL, chptr, CAP_TS6, NOCAPS, form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
":%s TMODE %ld %s +a %s", return 0;
me.id, (long) chptr->channelts, parv[1], }
source_p->id); sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
msptr->flags |= CHFL_ADMIN; me.name, parv[1], source_p->name);
} sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
else if (parc == 4 && !strcmp(parv[2], "+o") && !irccmp(parv[3], source_p->name)) ":%s TMODE %ld %s +a %s",
{ me.id, (long) chptr->channelts, parv[1],
/* Opping themselves */ source_p->id);
if (!wasonchannel) msptr->flags |= CHFL_ADMIN;
{ } else if (parc == 4 && !strcmp(parv[2], "+o") && !irccmp(parv[3], source_p->name)) {
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, /* Opping themselves */
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname); if (!wasonchannel) {
return 0; sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
} form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s", return 0;
me.name, parv[1], source_p->name); }
sendto_server(NULL, chptr, CAP_TS6, NOCAPS, sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
":%s TMODE %ld %s +o %s", me.name, parv[1], source_p->name);
me.id, (long) chptr->channelts, parv[1], sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
source_p->id); ":%s TMODE %ld %s +o %s",
msptr->flags |= CHFL_CHANOP; me.id, (long) chptr->channelts, parv[1],
} source_p->id);
else if (parc == 4 && !strcmp(parv[2], "+h") && !irccmp(parv[3], source_p->name)) msptr->flags |= CHFL_CHANOP;
{ } else if (parc == 4 && !strcmp(parv[2], "+h") && !irccmp(parv[3], source_p->name)) {
/* Halfopping themselves */ /* Halfopping themselves */
if (!wasonchannel) if (!wasonchannel) {
{ sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname); return 0;
return 0; }
} sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s",
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s", me.name, parv[1], source_p->name);
me.name, parv[1], source_p->name); sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
sendto_server(NULL, chptr, CAP_TS6, NOCAPS, ":%s TMODE %ld %s +h %s",
":%s TMODE %ld %s +h %s", me.id, (long) chptr->channelts, parv[1],
me.id, (long) chptr->channelts, parv[1], source_p->id);
source_p->id); msptr->flags |= CHFL_HALFOP;
msptr->flags |= CHFL_HALFOP; } else if (ConfigChannel.use_owner) {
} /* I hope this is correct.
else if (ConfigChannel.use_owner) * -- Kabaka */
{
/* I hope this is correct.
* -- Kabaka */
/* Hack it so set_channel_mode() will accept */ /* Hack it so set_channel_mode() will accept */
if (wasonchannel) if (wasonchannel)
msptr->flags |= CHFL_OWNER; msptr->flags |= CHFL_OWNER;
else else {
{ add_user_to_channel(chptr, source_p, CHFL_CHANOP);
add_user_to_channel(chptr, source_p, CHFL_CHANOP); msptr = find_channel_membership(chptr, source_p);
msptr = find_channel_membership(chptr, source_p);
}
set_channel_mode(client_p, source_p, chptr, msptr,
parc - 2, parv + 2);
if (wasonchannel)
msptr->flags &= ~CHFL_OWNER;
else
remove_user_from_channel(msptr);
} }
else if (ConfigChannel.use_admin) set_channel_mode(client_p, source_p, chptr, msptr,
{ parc - 2, parv + 2);
/* Hack it so set_channel_mode() will accept */ if (wasonchannel)
if (wasonchannel) msptr->flags &= ~CHFL_OWNER;
msptr->flags |= CHFL_ADMIN; else
else remove_user_from_channel(msptr);
{ } else if (ConfigChannel.use_admin) {
add_user_to_channel(chptr, source_p, CHFL_CHANOP); /* Hack it so set_channel_mode() will accept */
msptr = find_channel_membership(chptr, source_p); if (wasonchannel)
} msptr->flags |= CHFL_ADMIN;
set_channel_mode(client_p, source_p, chptr, msptr, else {
parc - 2, parv + 2); add_user_to_channel(chptr, source_p, CHFL_CHANOP);
/* We know they were not opped before and they can't have opped msptr = find_channel_membership(chptr, source_p);
* themselves as set_channel_mode() does not allow that }
* -- jilles */ set_channel_mode(client_p, source_p, chptr, msptr,
if (wasonchannel) parc - 2, parv + 2);
msptr->flags &= ~CHFL_ADMIN; /* We know they were not opped before and they can't have opped
else * themselves as set_channel_mode() does not allow that
remove_user_from_channel(msptr); * -- jilles */
} if (wasonchannel)
else msptr->flags &= ~CHFL_ADMIN;
{ else
/* CHFL_ADMIN is only useful if admin is enabled remove_user_from_channel(msptr);
* so hack it with op if it is not. */ } else {
if (wasonchannel) /* CHFL_ADMIN is only useful if admin is enabled
msptr->flags |= CHFL_CHANOP; * so hack it with op if it is not. */
else if (wasonchannel)
{ msptr->flags |= CHFL_CHANOP;
add_user_to_channel(chptr, source_p, CHFL_CHANOP); else {
msptr = find_channel_membership(chptr, source_p); add_user_to_channel(chptr, source_p, CHFL_CHANOP);
} msptr = find_channel_membership(chptr, source_p);
set_channel_mode(client_p, source_p, chptr, msptr, }
parc - 2, parv + 2); set_channel_mode(client_p, source_p, chptr, msptr,
/* We know they were not opped before and they can't have opped parc - 2, parv + 2);
* themselves as set_channel_mode() does not allow that /* We know they were not opped before and they can't have opped
* -- jilles */ * themselves as set_channel_mode() does not allow that
if (wasonchannel) * -- jilles */
msptr->flags &= ~CHFL_CHANOP; if (wasonchannel)
else msptr->flags &= ~CHFL_CHANOP;
remove_user_from_channel(msptr); else
} remove_user_from_channel(msptr);
}
#endif #endif
return 0; return 0;
} }

View File

@ -37,8 +37,8 @@
static int mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); static int mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message opme_msgtab = { struct Message opme_msgtab = {
"OPME", 0, 0, 0, MFLG_SLOW, "OPME", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_opme, 2}} {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_opme, 2}}
}; };
mapi_clist_av1 opme_clist[] = { &opme_msgtab, NULL }; mapi_clist_av1 opme_clist[] = { &opme_msgtab, NULL };
@ -53,62 +53,57 @@ DECLARE_MODULE_AV1(opme, NULL, NULL, opme_clist, NULL, NULL, "$Revision: 3554 $"
static int static int
mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
struct Channel *chptr; struct Channel *chptr;
struct membership *msptr; struct membership *msptr;
rb_dlink_node *ptr; rb_dlink_node *ptr;
/* admins only */ /* admins only */
if(!IsOperAdmin(source_p)) if(!IsOperAdmin(source_p)) {
{ sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin"); return 0;
return 0; }
}
if((chptr = find_channel(parv[1])) == NULL) if((chptr = find_channel(parv[1])) == NULL) {
{ sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), parv[1]);
form_str(ERR_NOSUCHCHANNEL), parv[1]); return 0;
return 0; }
}
RB_DLINK_FOREACH(ptr, chptr->members.head) RB_DLINK_FOREACH(ptr, chptr->members.head) {
{ msptr = ptr->data;
msptr = ptr->data;
if(is_chanop(msptr) || is_admin(msptr) || is_owner(msptr)) if(is_chanop(msptr) || is_admin(msptr) || is_owner(msptr)) {
{ sendto_one_notice(source_p, ":%s Channel is not opless", parv[1]);
sendto_one_notice(source_p, ":%s Channel is not opless", parv[1]); return 0;
return 0; }
} }
}
msptr = find_channel_membership(chptr, source_p); msptr = find_channel_membership(chptr, source_p);
if(msptr == NULL) if(msptr == NULL)
return 0; return 0;
msptr->flags |= CHFL_CHANOP; msptr->flags |= CHFL_CHANOP;
sendto_wallops_flags(UMODE_WALLOP, &me, sendto_wallops_flags(UMODE_WALLOP, &me,
"OPME called for [%s] by %s!%s@%s", "OPME called for [%s] by %s!%s@%s",
parv[1], source_p->name, source_p->username, source_p->host); parv[1], source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OPME called for [%s] by %s", ilog(L_MAIN, "OPME called for [%s] by %s",
parv[1], get_oper_name(source_p)); parv[1], get_oper_name(source_p));
/* dont send stuff for local channels remotely. */ /* dont send stuff for local channels remotely. */
if(*chptr->chname != '&') if(*chptr->chname != '&') {
{ sendto_server(NULL, NULL, NOCAPS, NOCAPS,
sendto_server(NULL, NULL, NOCAPS, NOCAPS, ":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
":%s WALLOPS :OPME called for [%s] by %s!%s@%s", me.name, parv[1], source_p->name, source_p->username, source_p->host);
me.name, parv[1], source_p->name, source_p->username, source_p->host); sendto_server(NULL, chptr, CAP_TS6, NOCAPS, ":%s PART %s", source_p->id, parv[1]);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS, ":%s PART %s", source_p->id, parv[1]); sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
sendto_server(NULL, chptr, CAP_TS6, NOCAPS, ":%s SJOIN %ld %s + :@%s",
":%s SJOIN %ld %s + :@%s", me.id, (long) chptr->channelts, parv[1], source_p->id);
me.id, (long) chptr->channelts, parv[1], source_p->id); }
}
sendto_channel_local(ALL_MEMBERS, chptr, sendto_channel_local(ALL_MEMBERS, chptr,
":%s MODE %s +o %s", me.name, parv[1], source_p->name); ":%s MODE %s +o %s", me.name, parv[1], source_p->name);
return 0; return 0;
} }

View File

@ -6,9 +6,9 @@
* to clearly show that it is fake. SCENE is a special case and not underlined. * to clearly show that it is fake. SCENE is a special case and not underlined.
* these commands only work on channels set +N * these commands only work on channels set +N
* *
* also adds oper commands FSAY and FACTION, which are like NPC and NPCA * also adds oper commands FSAY and FACTION, which are like NPC and NPCA
* except without the underline. * except without the underline.
* *
* all of these messages have the hostmask npc.fakeuser.invalid, and their ident * all of these messages have the hostmask npc.fakeuser.invalid, and their ident
* is the nickname of the user running the commands. * is the nickname of the user running the commands.
*/ */
@ -39,57 +39,57 @@ static unsigned int mymode;
static int static int
_modinit(void) _modinit(void)
{ {
/* initalize the +N cmode */ /* initalize the +N cmode */
mymode = cflag_add('N', chm_simple); mymode = cflag_add('N', chm_simple);
if (mymode == 0) if (mymode == 0)
return -1; return -1;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
/* orphan the +N cmode on modunload */ /* orphan the +N cmode on modunload */
cflag_orphan('N'); cflag_orphan('N');
} }
struct Message scene_msgtab = { struct Message scene_msgtab = {
"SCENE", 0, 0, 0, MFLG_SLOW, "SCENE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}} {mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}}
}; };
/* this serves as an alias for people who are used to inspircd/unreal m_roleplay */ /* this serves as an alias for people who are used to inspircd/unreal m_roleplay */
struct Message ambiance_msgtab = { struct Message ambiance_msgtab = {
"AMBIANCE", 0, 0, 0, MFLG_SLOW, "AMBIANCE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}} {mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}}
}; };
struct Message fsay_msgtab = { struct Message fsay_msgtab = {
"FSAY", 0, 0, 0, MFLG_SLOW, "FSAY", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_fsay, 4}} {mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_fsay, 4}}
}; };
struct Message faction_msgtab = { struct Message faction_msgtab = {
"FACTION", 0, 0, 0, MFLG_SLOW, "FACTION", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_faction, 4}} {mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_faction, 4}}
}; };
struct Message npc_msgtab = { struct Message npc_msgtab = {
"NPC", 0, 0, 0, MFLG_SLOW, "NPC", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npc, 4}} {mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npc, 4}}
}; };
struct Message npca_msgtab = { struct Message npca_msgtab = {
"NPCA", 0, 0, 0, MFLG_SLOW, "NPCA", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npca, 4}} {mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npca, 4}}
}; };
struct Message roleplay_msgtab = { struct Message roleplay_msgtab = {
"ROLEPLAY", 0, 0, 0, MFLG_SLOW, "ROLEPLAY", 0, 0, 0, MFLG_SLOW,
{mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_roleplay, 4}, mg_ignore} {mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_roleplay, 4}, mg_ignore}
}; };
mapi_clist_av1 roleplay_clist[] = { &scene_msgtab, &ambiance_msgtab, &fsay_msgtab, &faction_msgtab, &npc_msgtab, &npca_msgtab, &roleplay_msgtab, NULL }; mapi_clist_av1 roleplay_clist[] = { &scene_msgtab, &ambiance_msgtab, &fsay_msgtab, &faction_msgtab, &npc_msgtab, &npca_msgtab, &roleplay_msgtab, NULL };
@ -98,118 +98,112 @@ DECLARE_MODULE_AV1(roleplay, _modinit, _moddeinit, roleplay_clist, NULL, NULL, "
static int static int
m_scene(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) m_scene(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
m_displaymsg(source_p, parv[1], 0, 0, "=Scene=", parv[2]); m_displaymsg(source_p, parv[1], 0, 0, "=Scene=", parv[2]);
return 0; return 0;
} }
static int static int
m_fsay(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) m_fsay(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
m_displaymsg(source_p, parv[1], 0, 0, parv[2], parv[3]); m_displaymsg(source_p, parv[1], 0, 0, parv[2], parv[3]);
return 0; return 0;
} }
static int static int
m_faction(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) m_faction(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
m_displaymsg(source_p, parv[1], 0, 1, parv[2], parv[3]); m_displaymsg(source_p, parv[1], 0, 1, parv[2], parv[3]);
return 0; return 0;
} }
static int static int
m_npc(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) m_npc(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
m_displaymsg(source_p, parv[1], 1, 0, parv[2], parv[3]); m_displaymsg(source_p, parv[1], 1, 0, parv[2], parv[3]);
return 0; return 0;
} }
static int static int
m_npca(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) m_npca(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
m_displaymsg(source_p, parv[1], 1, 1, parv[2], parv[3]); m_displaymsg(source_p, parv[1], 1, 1, parv[2], parv[3]);
return 0; return 0;
} }
static int static int
m_displaymsg(struct Client *source_p, const char *channel, int underline, int action, const char *nick, const char *text) m_displaymsg(struct Client *source_p, const char *channel, int underline, int action, const char *nick, const char *text)
{ {
struct Channel *chptr; struct Channel *chptr;
struct membership *msptr; struct membership *msptr;
char nick2[NICKLEN+1]; char nick2[NICKLEN+1];
char *nick3 = rb_strdup(nick); char *nick3 = rb_strdup(nick);
char text2[BUFSIZE]; char text2[BUFSIZE];
if((chptr = find_channel(channel)) == NULL) if((chptr = find_channel(channel)) == NULL) {
{ sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), channel);
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), channel); return 0;
return 0; }
}
if(!(msptr = find_channel_membership(chptr, source_p))) if(!(msptr = find_channel_membership(chptr, source_p))) {
{ sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), chptr->chname);
form_str(ERR_NOTONCHANNEL), chptr->chname); return 0;
return 0; }
}
if(!(chptr->mode.mode & chmode_flags['N'])) if(!(chptr->mode.mode & chmode_flags['N'])) {
{ sendto_one_numeric(source_p, 573, "%s :Roleplay commands are not enabled on this channel.", chptr->chname);
sendto_one_numeric(source_p, 573, "%s :Roleplay commands are not enabled on this channel.", chptr->chname); return 0;
return 0; }
}
if(!can_send(chptr, source_p, msptr)) if(!can_send(chptr, source_p, msptr)) {
{ sendto_one_numeric(source_p, 573, "%s :Cannot send to channel.", chptr->chname);
sendto_one_numeric(source_p, 573, "%s :Cannot send to channel.", chptr->chname); return 0;
return 0; }
}
/* enforce flood stuff on roleplay commands */ /* enforce flood stuff on roleplay commands */
if(flood_attack_channel(0, source_p, chptr, chptr->chname)) if(flood_attack_channel(0, source_p, chptr, chptr->chname))
return 0; return 0;
/* enforce target change on roleplay commands */ /* enforce target change on roleplay commands */
if(!is_chanop_voiced(msptr) && !IsOper(source_p) && !add_channel_target(source_p, chptr)) if(!is_chanop_voiced(msptr) && !IsOper(source_p) && !add_channel_target(source_p, chptr)) {
{ sendto_one(source_p, form_str(ERR_TARGCHANGE),
sendto_one(source_p, form_str(ERR_TARGCHANGE), me.name, source_p->name, chptr->chname);
me.name, source_p->name, chptr->chname); return 0;
return 0; }
}
if(underline) if(underline)
rb_snprintf(nick2, sizeof(nick2), "\x1F%s\x1F", strip_unprintable(nick3)); rb_snprintf(nick2, sizeof(nick2), "\x1F%s\x1F", strip_unprintable(nick3));
else else
rb_snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3)); rb_snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3));
/* don't allow nicks to be empty after stripping /* don't allow nicks to be empty after stripping
* this prevents nastiness like fake factions, etc. */ * this prevents nastiness like fake factions, etc. */
if(EmptyString(nick3)) if(EmptyString(nick3)) {
{ sendto_one_numeric(source_p, 573, "%s :No visible non-stripped characters in nick.", chptr->chname);
sendto_one_numeric(source_p, 573, "%s :No visible non-stripped characters in nick.", chptr->chname); return 0;
return 0; }
}
if(action) if(action)
rb_snprintf(text2, sizeof(text2), "\1ACTION %s\1", text); rb_snprintf(text2, sizeof(text2), "\1ACTION %s\1", text);
else else
rb_snprintf(text2, sizeof(text2), "%s", text); rb_snprintf(text2, sizeof(text2), "%s", text);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s (%s)", nick2, source_p->name, channel, text2, source_p->name); sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s (%s)", nick2, source_p->name, channel, text2, source_p->name);
sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ROLEPLAY %s %s :%s", sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ROLEPLAY %s %s :%s",
channel, nick2, text2); channel, nick2, text2);
return 0; return 0;
} }
static int static int
me_roleplay(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) me_roleplay(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
struct Channel *chptr; struct Channel *chptr;
/* Don't segfault if we get ROLEPLAY with an invalid channel. /* Don't segfault if we get ROLEPLAY with an invalid channel.
* This shouldn't happen but it's best to be on the safe side. */ * This shouldn't happen but it's best to be on the safe side. */
if((chptr = find_channel(parv[1])) == NULL) if((chptr = find_channel(parv[1])) == NULL)
return 0; return 0;
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s (%s)", parv[2], source_p->name, parv[1], parv[3], source_p->name); sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s (%s)", parv[2], source_p->name, parv[1], parv[3], source_p->name);
return 0; return 0;
} }

View File

@ -46,130 +46,120 @@
static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message sendbans_msgtab = { struct Message sendbans_msgtab = {
"SENDBANS", 0, 0, 0, MFLG_SLOW, "SENDBANS", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_sendbans, 2}} {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_sendbans, 2}}
}; };
mapi_clist_av1 sendbans_clist[] = { mapi_clist_av1 sendbans_clist[] = {
&sendbans_msgtab, &sendbans_msgtab,
NULL NULL
}; };
DECLARE_MODULE_AV1(sendbans, NULL, NULL, sendbans_clist, NULL, NULL, "$Revision$"); DECLARE_MODULE_AV1(sendbans, NULL, NULL, sendbans_clist, NULL, NULL, "$Revision$");
static const char *expand_xline(const char *mask) static const char *expand_xline(const char *mask)
{ {
static char buf[512]; static char buf[512];
const char *p; const char *p;
char *q; char *q;
if (!strchr(mask, ' ')) if (!strchr(mask, ' '))
return mask; return mask;
if (strlen(mask) > 250) if (strlen(mask) > 250)
return NULL; return NULL;
p = mask; p = mask;
q = buf; q = buf;
while (*p != '\0') while (*p != '\0') {
{ if (*p == ' ')
if (*p == ' ') *q++ = '\\', *q++ = 's';
*q++ = '\\', *q++ = 's'; else
else *q++ = *p;
*q++ = *p; p++;
p++; }
} *q = '\0';
*q = '\0'; return buf;
return buf;
} }
static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
struct ConfItem *aconf; struct ConfItem *aconf;
rb_dlink_node *ptr; rb_dlink_node *ptr;
int i, count; int i, count;
const char *target, *mask2; const char *target, *mask2;
struct Client *server_p; struct Client *server_p;
if (!IsOperRemoteBan(source_p)) if (!IsOperRemoteBan(source_p)) {
{ sendto_one(source_p, form_str(ERR_NOPRIVS),
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "remoteban");
me.name, source_p->name, "remoteban"); return 0;
return 0; }
} if (!IsOperXline(source_p)) {
if (!IsOperXline(source_p)) sendto_one(source_p, form_str(ERR_NOPRIVS),
{ me.name, source_p->name, "xline");
sendto_one(source_p, form_str(ERR_NOPRIVS), return 0;
me.name, source_p->name, "xline"); }
return 0; if (!IsOperResv(source_p)) {
} sendto_one(source_p, form_str(ERR_NOPRIVS),
if (!IsOperResv(source_p)) me.name, source_p->name, "resv");
{ return 0;
sendto_one(source_p, form_str(ERR_NOPRIVS), }
me.name, source_p->name, "resv");
return 0;
}
target = parv[1]; target = parv[1];
count = 0; count = 0;
RB_DLINK_FOREACH(ptr, global_serv_list.head) RB_DLINK_FOREACH(ptr, global_serv_list.head) {
{ server_p = ptr->data;
server_p = ptr->data; if (IsMe(server_p))
if (IsMe(server_p)) continue;
continue; if (match(target, server_p->name))
if (match(target, server_p->name)) count++;
count++; }
} if (count == 0) {
if (count == 0) sendto_one_numeric(source_p, ERR_NOSUCHSERVER,
{ form_str(ERR_NOSUCHSERVER), target);
sendto_one_numeric(source_p, ERR_NOSUCHSERVER, return 0;
form_str(ERR_NOSUCHSERVER), target); }
return 0;
}
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
"%s!%s@%s is sending resvs and xlines to %s", "%s!%s@%s is sending resvs and xlines to %s",
source_p->name, source_p->username, source_p->host, source_p->name, source_p->username, source_p->host,
target); target);
RB_DLINK_FOREACH(ptr, resv_conf_list.head) RB_DLINK_FOREACH(ptr, resv_conf_list.head) {
{ aconf = ptr->data;
aconf = ptr->data; if (aconf->hold)
if (aconf->hold) continue;
continue; sendto_match_servs(source_p, target,
sendto_match_servs(source_p, target, CAP_ENCAP, NOCAPS,
CAP_ENCAP, NOCAPS, "ENCAP %s RESV 0 %s 0 :%s",
"ENCAP %s RESV 0 %s 0 :%s", target, aconf->host, aconf->passwd);
target, aconf->host, aconf->passwd); }
}
HASH_WALK(i, R_MAX, ptr, resvTable) HASH_WALK(i, R_MAX, ptr, resvTable) {
{ aconf = ptr->data;
aconf = ptr->data; if (aconf->hold)
if (aconf->hold) continue;
continue; sendto_match_servs(source_p, target,
sendto_match_servs(source_p, target, CAP_ENCAP, NOCAPS,
CAP_ENCAP, NOCAPS, "ENCAP %s RESV 0 %s 0 :%s",
"ENCAP %s RESV 0 %s 0 :%s", target, aconf->host, aconf->passwd);
target, aconf->host, aconf->passwd); }
} HASH_WALK_END
HASH_WALK_END
RB_DLINK_FOREACH(ptr, xline_conf_list.head) RB_DLINK_FOREACH(ptr, xline_conf_list.head) {
{ aconf = ptr->data;
aconf = ptr->data; if (aconf->hold)
if (aconf->hold) continue;
continue; mask2 = expand_xline(aconf->host);
mask2 = expand_xline(aconf->host); if (mask2 == NULL) {
if (mask2 == NULL) sendto_one_notice(source_p, ":Skipping xline [%s]",
{ aconf->host);
sendto_one_notice(source_p, ":Skipping xline [%s]", continue;
aconf->host); }
continue; sendto_match_servs(source_p, target,
} CAP_ENCAP, NOCAPS,
sendto_match_servs(source_p, target, "ENCAP %s XLINE 0 %s 2 :%s",
CAP_ENCAP, NOCAPS, target, mask2, aconf->passwd);
"ENCAP %s XLINE 0 %s 2 :%s", }
target, mask2, aconf->passwd);
}
return 0; return 0;
} }

View File

@ -57,8 +57,8 @@
static int mr_webirc(struct Client *, struct Client *, int, const char **); static int mr_webirc(struct Client *, struct Client *, int, const char **);
struct Message webirc_msgtab = { struct Message webirc_msgtab = {
"WEBIRC", 0, 0, 0, MFLG_SLOW | MFLG_UNREG, "WEBIRC", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
{{mr_webirc, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg} {{mr_webirc, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
}; };
mapi_clist_av1 webirc_clist[] = { &webirc_msgtab, NULL }; mapi_clist_av1 webirc_clist[] = { &webirc_msgtab, NULL };
@ -68,74 +68,68 @@ DECLARE_MODULE_AV1(webirc, NULL, NULL, webirc_clist, NULL, NULL, "$Revision: 207
* mr_webirc - webirc message handler * mr_webirc - webirc message handler
* parv[1] = password * parv[1] = password
* parv[2] = fake username (we ignore this) * parv[2] = fake username (we ignore this)
* parv[3] = fake hostname * parv[3] = fake hostname
* parv[4] = fake ip * parv[4] = fake ip
*/ */
static int static int
mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
struct ConfItem *aconf; struct ConfItem *aconf;
const char *encr; const char *encr;
if (!strchr(parv[4], '.') && !strchr(parv[4], ':')) if (!strchr(parv[4], '.') && !strchr(parv[4], ':')) {
{ sendto_one(source_p, "NOTICE * :Invalid IP");
sendto_one(source_p, "NOTICE * :Invalid IP"); return 0;
return 0; }
}
aconf = find_address_conf(client_p->host, client_p->sockhost, aconf = find_address_conf(client_p->host, client_p->sockhost,
IsGotId(client_p) ? client_p->username : "webirc", IsGotId(client_p) ? client_p->username : "webirc",
IsGotId(client_p) ? client_p->username : "webirc", IsGotId(client_p) ? client_p->username : "webirc",
(struct sockaddr *) &client_p->localClient->ip, (struct sockaddr *) &client_p->localClient->ip,
client_p->localClient->ip.ss_family, NULL); client_p->localClient->ip.ss_family, NULL);
if (aconf == NULL || !(aconf->status & CONF_CLIENT)) if (aconf == NULL || !(aconf->status & CONF_CLIENT))
return 0; return 0;
if (!IsConfDoSpoofIp(aconf) || irccmp(aconf->info.name, "webirc.")) if (!IsConfDoSpoofIp(aconf) || irccmp(aconf->info.name, "webirc.")) {
{ /* XXX */
/* XXX */ sendto_one(source_p, "NOTICE * :Not a CGI:IRC auth block");
sendto_one(source_p, "NOTICE * :Not a CGI:IRC auth block"); return 0;
return 0; }
} if (EmptyString(aconf->passwd)) {
if (EmptyString(aconf->passwd)) sendto_one(source_p, "NOTICE * :CGI:IRC auth blocks must have a password");
{ return 0;
sendto_one(source_p, "NOTICE * :CGI:IRC auth blocks must have a password"); }
return 0;
}
if (EmptyString(parv[1])) if (EmptyString(parv[1]))
encr = ""; encr = "";
else if (IsConfEncrypted(aconf)) else if (IsConfEncrypted(aconf))
encr = rb_crypt(parv[1], aconf->passwd); encr = rb_crypt(parv[1], aconf->passwd);
else else
encr = parv[1]; encr = parv[1];
if (strcmp(encr, aconf->passwd)) if (strcmp(encr, aconf->passwd)) {
{ sendto_one(source_p, "NOTICE * :CGI:IRC password incorrect");
sendto_one(source_p, "NOTICE * :CGI:IRC password incorrect"); return 0;
return 0; }
}
rb_strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost)); rb_strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost));
if(strlen(parv[3]) <= HOSTLEN) if(strlen(parv[3]) <= HOSTLEN)
rb_strlcpy(source_p->host, parv[3], sizeof(source_p->host)); rb_strlcpy(source_p->host, parv[3], sizeof(source_p->host));
else else
rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host)); rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));
rb_inet_pton_sock(parv[4], (struct sockaddr *)&source_p->localClient->ip);
/* Check dlines now, klines will be checked on registration */ rb_inet_pton_sock(parv[4], (struct sockaddr *)&source_p->localClient->ip);
if((aconf = find_dline((struct sockaddr *)&source_p->localClient->ip,
source_p->localClient->ip.ss_family)))
{
if(!(aconf->status & CONF_EXEMPTDLINE))
{
exit_client(client_p, source_p, &me, "D-lined");
return 0;
}
}
sendto_one(source_p, "NOTICE * :CGI:IRC host/IP set to %s %s", parv[3], parv[4]); /* Check dlines now, klines will be checked on registration */
return 0; if((aconf = find_dline((struct sockaddr *)&source_p->localClient->ip,
source_p->localClient->ip.ss_family))) {
if(!(aconf->status & CONF_EXEMPTDLINE)) {
exit_client(client_p, source_p, &me, "D-lined");
return 0;
}
}
sendto_one(source_p, "NOTICE * :CGI:IRC host/IP set to %s %s", parv[3], parv[4]);
return 0;
} }

View File

@ -15,8 +15,8 @@
static void h_nl_umode_changed(hook_data_umode_changed *); static void h_nl_umode_changed(hook_data_umode_changed *);
mapi_hfn_list_av1 nl_hfnlist[] = { mapi_hfn_list_av1 nl_hfnlist[] = {
{ "umode_changed", (hookfn) h_nl_umode_changed }, { "umode_changed", (hookfn) h_nl_umode_changed },
{ NULL, NULL } { NULL, NULL }
}; };
DECLARE_MODULE_AV1(no_locops, NULL, NULL, NULL, NULL, nl_hfnlist, "$Revision: 3219 $"); DECLARE_MODULE_AV1(no_locops, NULL, NULL, NULL, NULL, nl_hfnlist, "$Revision: 3219 $");
@ -24,10 +24,9 @@ DECLARE_MODULE_AV1(no_locops, NULL, NULL, NULL, NULL, nl_hfnlist, "$Revision: 32
static void static void
h_nl_umode_changed(hook_data_umode_changed *hdata) h_nl_umode_changed(hook_data_umode_changed *hdata)
{ {
struct Client *source_p = hdata->client; struct Client *source_p = hdata->client;
if (MyClient(source_p) && source_p->umodes & UMODE_LOCOPS) if (MyClient(source_p) && source_p->umodes & UMODE_LOCOPS) {
{ source_p->umodes &= ~UMODE_LOCOPS;
source_p->umodes &= ~UMODE_LOCOPS; }
}
} }

View File

@ -17,8 +17,8 @@
static void h_noi_umode_changed(hook_data_umode_changed *); static void h_noi_umode_changed(hook_data_umode_changed *);
mapi_hfn_list_av1 noi_hfnlist[] = { mapi_hfn_list_av1 noi_hfnlist[] = {
{ "umode_changed", (hookfn) h_noi_umode_changed }, { "umode_changed", (hookfn) h_noi_umode_changed },
{ NULL, NULL } { NULL, NULL }
}; };
DECLARE_MODULE_AV1(no_oper_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "$Revision: 3219 $"); DECLARE_MODULE_AV1(no_oper_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "$Revision: 3219 $");
@ -26,15 +26,14 @@ DECLARE_MODULE_AV1(no_oper_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "$Revisio
static void static void
h_noi_umode_changed(hook_data_umode_changed *hdata) h_noi_umode_changed(hook_data_umode_changed *hdata)
{ {
struct Client *source_p = hdata->client; struct Client *source_p = hdata->client;
if (MyClient(source_p) && IsOper(source_p) && !IsOperInvis(source_p) && if (MyClient(source_p) && IsOper(source_p) && !IsOperInvis(source_p) &&
IsInvisible(source_p)) IsInvisible(source_p)) {
{ ClearInvisible(source_p);
ClearInvisible(source_p); /* If they tried /umode +i, complain; do not complain
/* If they tried /umode +i, complain; do not complain * if they opered up while invisible -- jilles */
* if they opered up while invisible -- jilles */ if (hdata->oldumodes & UMODE_OPER)
if (hdata->oldumodes & UMODE_OPER) sendto_one_notice(source_p, ":*** Opers may not set themselves invisible");
sendto_one_notice(source_p, ":*** Opers may not set themselves invisible"); }
}
} }

View File

@ -22,9 +22,9 @@ static void h_gcn_new_remote_user(struct Client *);
static void h_gcn_client_exit(hook_data_client_exit *); static void h_gcn_client_exit(hook_data_client_exit *);
mapi_hfn_list_av1 gcn_hfnlist[] = { mapi_hfn_list_av1 gcn_hfnlist[] = {
{ "new_remote_user", (hookfn) h_gcn_new_remote_user }, { "new_remote_user", (hookfn) h_gcn_new_remote_user },
{ "client_exit", (hookfn) h_gcn_client_exit }, { "client_exit", (hookfn) h_gcn_client_exit },
{ NULL, NULL } { NULL, NULL }
}; };
DECLARE_MODULE_AV1(globalconnexit, _modinit, _moddeinit, NULL, NULL, gcn_hfnlist, "$Revision: 1869 $"); DECLARE_MODULE_AV1(globalconnexit, _modinit, _moddeinit, NULL, NULL, gcn_hfnlist, "$Revision: 1869 $");
@ -32,49 +32,49 @@ DECLARE_MODULE_AV1(globalconnexit, _modinit, _moddeinit, NULL, NULL, gcn_hfnlist
static int static int
_modinit(void) _modinit(void)
{ {
/* add the snomask to the available slot */ /* add the snomask to the available slot */
snomask_modes['F'] = find_snomask_slot(); snomask_modes['F'] = find_snomask_slot();
/* show the fact that we are showing user information in /version */ /* show the fact that we are showing user information in /version */
opers_see_all_users = 1; opers_see_all_users = 1;
return 0; return 0;
} }
static void static void
_moddeinit(void) _moddeinit(void)
{ {
/* disable the snomask and remove it from the available list */ /* disable the snomask and remove it from the available list */
snomask_modes['F'] = 0; snomask_modes['F'] = 0;
} }
static void static void
h_gcn_new_remote_user(struct Client *source_p) h_gcn_new_remote_user(struct Client *source_p)
{ {
if (!HasSentEob(source_p->servptr)) if (!HasSentEob(source_p->servptr))
return; return;
sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr, sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
"Client connecting: %s (%s@%s) [%s] {%s} [%s]", "Client connecting: %s (%s@%s) [%s] {%s} [%s]",
source_p->name, source_p->username, source_p->orighost, source_p->name, source_p->username, source_p->orighost,
show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255", show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255",
"?", source_p->info); "?", source_p->info);
} }
static void static void
h_gcn_client_exit(hook_data_client_exit *hdata) h_gcn_client_exit(hook_data_client_exit *hdata)
{ {
struct Client *source_p; struct Client *source_p;
source_p = hdata->target; source_p = hdata->target;
if (MyConnect(source_p) || !IsClient(source_p)) if (MyConnect(source_p) || !IsClient(source_p))
return; return;
if (!HasSentEob(source_p->servptr)) if (!HasSentEob(source_p->servptr))
return; return;
sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr, sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
"Client exiting: %s (%s@%s) [%s] [%s]", "Client exiting: %s (%s@%s) [%s] [%s]",
source_p->name, source_p->name,
source_p->username, source_p->host, hdata->comment, source_p->username, source_p->host, hdata->comment,
show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255"); show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255");
} }

View File

@ -19,8 +19,8 @@
static void h_gla_client_exit(hook_data_client_exit *); static void h_gla_client_exit(hook_data_client_exit *);
mapi_hfn_list_av1 gla_hfnlist[] = { mapi_hfn_list_av1 gla_hfnlist[] = {
{ "client_exit", (hookfn) h_gla_client_exit }, { "client_exit", (hookfn) h_gla_client_exit },
{ NULL, NULL } { NULL, NULL }
}; };
DECLARE_MODULE_AV1(globallineactive, NULL, NULL, NULL, NULL, gla_hfnlist, "$Revision: 613 $"); DECLARE_MODULE_AV1(globallineactive, NULL, NULL, NULL, NULL, gla_hfnlist, "$Revision: 613 $");
@ -28,35 +28,28 @@ DECLARE_MODULE_AV1(globallineactive, NULL, NULL, NULL, NULL, gla_hfnlist, "$Revi
static void static void
h_gla_client_exit(hook_data_client_exit *hdata) h_gla_client_exit(hook_data_client_exit *hdata)
{ {
struct Client *source_p; struct Client *source_p;
source_p = hdata->target; source_p = hdata->target;
if (MyConnect(source_p) || !IsClient(source_p)) if (MyConnect(source_p) || !IsClient(source_p))
return; return;
if (!strcmp(hdata->comment, "Bad user info")) if (!strcmp(hdata->comment, "Bad user info")) {
{ sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr, "XLINE active for %s[%s@%s]",
"XLINE active for %s[%s@%s]", source_p->name, source_p->username, source_p->host);
source_p->name, source_p->username, source_p->host); } else if (ConfigFileEntry.kline_reason != NULL &&
} !strcmp(hdata->comment, ConfigFileEntry.kline_reason)) {
else if (ConfigFileEntry.kline_reason != NULL && sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
!strcmp(hdata->comment, ConfigFileEntry.kline_reason)) "K/DLINE active for %s[%s@%s]",
{ source_p->name, source_p->username, source_p->host);
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr, } else if (!strncmp(hdata->comment, "Temporary K-line ", 17)) {
"K/DLINE active for %s[%s@%s]", sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
source_p->name, source_p->username, source_p->host); "K/DLINE active for %s[%s@%s]",
} source_p->name, source_p->username, source_p->host);
else if (!strncmp(hdata->comment, "Temporary K-line ", 17)) } else if (!strncmp(hdata->comment, "Temporary D-line ", 17)) {
{ sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr, "K/DLINE active for %s[%s@%s]",
"K/DLINE active for %s[%s@%s]", source_p->name, source_p->username, source_p->host);
source_p->name, source_p->username, source_p->host); }
}
else if (!strncmp(hdata->comment, "Temporary D-line ", 17))
{
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"K/DLINE active for %s[%s@%s]",
source_p->name, source_p->username, source_p->host);
}
} }

View File

@ -15,8 +15,8 @@
static void h_sgo_umode_changed(void *); static void h_sgo_umode_changed(void *);
mapi_hfn_list_av1 sgo_hfnlist[] = { mapi_hfn_list_av1 sgo_hfnlist[] = {
{ "umode_changed", (hookfn) h_sgo_umode_changed }, { "umode_changed", (hookfn) h_sgo_umode_changed },
{ NULL, NULL } { NULL, NULL }
}; };
DECLARE_MODULE_AV1(sno_globaloper, NULL, NULL, NULL, NULL, sgo_hfnlist, "$Revision: 639 $"); DECLARE_MODULE_AV1(sno_globaloper, NULL, NULL, NULL, NULL, sgo_hfnlist, "$Revision: 639 $");
@ -24,14 +24,14 @@ DECLARE_MODULE_AV1(sno_globaloper, NULL, NULL, NULL, NULL, sgo_hfnlist, "$Revisi
static void static void
h_sgo_umode_changed(void *vdata) h_sgo_umode_changed(void *vdata)
{ {
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata; hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
struct Client *source_p = data->client; struct Client *source_p = data->client;
if (MyConnect(source_p) || !HasSentEob(source_p->servptr)) if (MyConnect(source_p) || !HasSentEob(source_p->servptr))
return; return;
if (!(data->oldumodes & UMODE_OPER) && IsOper(source_p)) if (!(data->oldumodes & UMODE_OPER) && IsOper(source_p))
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr, sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"%s (%s@%s) is now an operator", "%s (%s@%s) is now an operator",
source_p->name, source_p->username, source_p->host); source_p->name, source_p->username, source_p->host);
} }

View File

@ -20,23 +20,23 @@
void show_whois(hook_data_client *); void show_whois(hook_data_client *);
mapi_hfn_list_av1 whois_hfnlist[] = { mapi_hfn_list_av1 whois_hfnlist[] = {
{"doing_whois", (hookfn) show_whois}, {"doing_whois", (hookfn) show_whois},
{"doing_whois_global", (hookfn) show_whois}, {"doing_whois_global", (hookfn) show_whois},
{NULL, NULL} {NULL, NULL}
}; };
static int static int
init(void) init(void)
{ {
snomask_modes['W'] = find_snomask_slot(); snomask_modes['W'] = find_snomask_slot();
return 0; return 0;
} }
static void static void
fini(void) fini(void)
{ {
snomask_modes['W'] = find_snomask_slot(); snomask_modes['W'] = find_snomask_slot();
} }
DECLARE_MODULE_AV1(sno_whois, init, fini, NULL, NULL, whois_hfnlist, "$Revision: 3498 $"); DECLARE_MODULE_AV1(sno_whois, init, fini, NULL, NULL, whois_hfnlist, "$Revision: 3498 $");
@ -44,20 +44,19 @@ DECLARE_MODULE_AV1(sno_whois, init, fini, NULL, NULL, whois_hfnlist, "$Revision:
void void
show_whois(hook_data_client *data) show_whois(hook_data_client *data)
{ {
struct Client *source_p = data->client; struct Client *source_p = data->client;
struct Client *target_p = data->target; struct Client *target_p = data->target;
if(MyClient(target_p) && if(MyClient(target_p) &&
#ifdef OPERONLY #ifdef OPERONLY
IsOper(target_p) && IsOper(target_p) &&
#endif #endif
(source_p != target_p) && (source_p != target_p) &&
(target_p->snomask & snomask_modes['W'])) (target_p->snomask & snomask_modes['W'])) {
{ sendto_one_notice(target_p,
sendto_one_notice(target_p, ":*** Notice -- %s (%s@%s) is doing a whois on you [%s]",
":*** Notice -- %s (%s@%s) is doing a whois on you [%s]", source_p->name,
source_p->name, source_p->username, source_p->host,
source_p->username, source_p->host, source_p->servptr->name);
source_p->servptr->name); }
}
} }

View File

@ -30,8 +30,8 @@
void show_admin(hook_data *); void show_admin(hook_data *);
mapi_hfn_list_av1 admin_hfnlist[] = { mapi_hfn_list_av1 admin_hfnlist[] = {
{"doing_admin", (hookfn) show_admin}, {"doing_admin", (hookfn) show_admin},
{NULL, NULL} {NULL, NULL}
}; };
DECLARE_MODULE_AV1(admin_spy, NULL, NULL, NULL, NULL, admin_hfnlist, "$Revision: 498 $"); DECLARE_MODULE_AV1(admin_spy, NULL, NULL, NULL, NULL, admin_hfnlist, "$Revision: 498 $");
@ -39,8 +39,8 @@ DECLARE_MODULE_AV1(admin_spy, NULL, NULL, NULL, NULL, admin_hfnlist, "$Revision:
void void
show_admin(hook_data *data) show_admin(hook_data *data)
{ {
sendto_realops_snomask(SNO_SPY, L_ALL, sendto_realops_snomask(SNO_SPY, L_ALL,
"admin requested by %s (%s@%s) [%s]", "admin requested by %s (%s@%s) [%s]",
data->client->name, data->client->username, data->client->name, data->client->username,
data->client->host, data->client->servptr->name); data->client->host, data->client->servptr->name);
} }

View File

@ -30,8 +30,8 @@
void show_info(hook_data *); void show_info(hook_data *);
mapi_hfn_list_av1 info_hfnlist[] = { mapi_hfn_list_av1 info_hfnlist[] = {
{"doing_info", (hookfn) show_info}, {"doing_info", (hookfn) show_info},
{NULL, NULL} {NULL, NULL}
}; };
DECLARE_MODULE_AV1(info_spy, NULL, NULL, NULL, NULL, info_hfnlist, "$Revision: 498 $"); DECLARE_MODULE_AV1(info_spy, NULL, NULL, NULL, NULL, info_hfnlist, "$Revision: 498 $");
@ -39,8 +39,8 @@ DECLARE_MODULE_AV1(info_spy, NULL, NULL, NULL, NULL, info_hfnlist, "$Revision: 4
void void
show_info(hook_data *data) show_info(hook_data *data)
{ {
sendto_realops_snomask(SNO_SPY, L_ALL, sendto_realops_snomask(SNO_SPY, L_ALL,
"info requested by %s (%s@%s) [%s]", "info requested by %s (%s@%s) [%s]",
data->client->name, data->client->username, data->client->name, data->client->username,
data->client->host, data->client->servptr->name); data->client->host, data->client->servptr->name);
} }

View File

@ -30,8 +30,8 @@
void show_links(hook_data *); void show_links(hook_data *);
mapi_hfn_list_av1 links_hfnlist[] = { mapi_hfn_list_av1 links_hfnlist[] = {
{"doing_links", (hookfn) show_links}, {"doing_links", (hookfn) show_links},
{NULL, NULL} {NULL, NULL}
}; };
DECLARE_MODULE_AV1(links_spy, NULL, NULL, NULL, NULL, links_hfnlist, "$Revision: 498 $"); DECLARE_MODULE_AV1(links_spy, NULL, NULL, NULL, NULL, links_hfnlist, "$Revision: 498 $");
@ -39,10 +39,10 @@ DECLARE_MODULE_AV1(links_spy, NULL, NULL, NULL, NULL, links_hfnlist, "$Revision:
void void
show_links(hook_data *data) show_links(hook_data *data)
{ {
const char *mask = data->arg1; const char *mask = data->arg1;
sendto_realops_snomask(SNO_SPY, L_ALL, sendto_realops_snomask(SNO_SPY, L_ALL,
"LINKS '%s' requested by %s (%s@%s) [%s]", "LINKS '%s' requested by %s (%s@%s) [%s]",
mask, data->client->name, data->client->username, mask, data->client->name, data->client->username,
data->client->host, data->client->servptr->name); data->client->host, data->client->servptr->name);
} }

View File

@ -30,8 +30,8 @@
void show_motd(hook_data *); void show_motd(hook_data *);
mapi_hfn_list_av1 motd_hfnlist[] = { mapi_hfn_list_av1 motd_hfnlist[] = {
{"doing_motd", (hookfn) show_motd}, {"doing_motd", (hookfn) show_motd},
{NULL, NULL} {NULL, NULL}
}; };
DECLARE_MODULE_AV1(motd_spy, NULL, NULL, NULL, NULL, motd_hfnlist, "$Revision: 498 $"); DECLARE_MODULE_AV1(motd_spy, NULL, NULL, NULL, NULL, motd_hfnlist, "$Revision: 498 $");
@ -39,8 +39,8 @@ DECLARE_MODULE_AV1(motd_spy, NULL, NULL, NULL, NULL, motd_hfnlist, "$Revision: 4
void void
show_motd(hook_data *data) show_motd(hook_data *data)
{ {
sendto_realops_snomask(SNO_SPY, L_ALL, sendto_realops_snomask(SNO_SPY, L_ALL,
"motd requested by %s (%s@%s) [%s]", "motd requested by %s (%s@%s) [%s]",
data->client->name, data->client->username, data->client->name, data->client->username,
data->client->host, data->client->servptr->name); data->client->host, data->client->servptr->name);
} }

View File

@ -30,8 +30,8 @@
void show_stats(hook_data_int *); void show_stats(hook_data_int *);
mapi_hfn_list_av1 stats_hfnlist[] = { mapi_hfn_list_av1 stats_hfnlist[] = {
{"doing_stats", (hookfn) show_stats}, {"doing_stats", (hookfn) show_stats},
{NULL, NULL} {NULL, NULL}
}; };
DECLARE_MODULE_AV1(stats_spy, NULL, NULL, NULL, NULL, stats_hfnlist, "$Revision: 498 $"); DECLARE_MODULE_AV1(stats_spy, NULL, NULL, NULL, NULL, stats_hfnlist, "$Revision: 498 $");
@ -39,31 +39,28 @@ DECLARE_MODULE_AV1(stats_spy, NULL, NULL, NULL, NULL, stats_hfnlist, "$Revision:
void void
show_stats(hook_data_int *data) show_stats(hook_data_int *data)
{ {
char statchar = (char) data->arg2; char statchar = (char) data->arg2;
if(statchar == 'L' || statchar == 'l') if(statchar == 'L' || statchar == 'l') {
{ const char *name = data->arg1;
const char *name = data->arg1;
if(!EmptyString(name)) if(!EmptyString(name))
sendto_realops_snomask(SNO_SPY, L_ALL, sendto_realops_snomask(SNO_SPY, L_ALL,
"STATS %c requested by %s (%s@%s) [%s] on %s", "STATS %c requested by %s (%s@%s) [%s] on %s",
statchar, data->client->name, statchar, data->client->name,
data->client->username, data->client->username,
data->client->host, data->client->host,
data->client->servptr->name, name); data->client->servptr->name, name);
else else
sendto_realops_snomask(SNO_SPY, L_ALL, sendto_realops_snomask(SNO_SPY, L_ALL,
"STATS %c requested by %s (%s@%s) [%s]", "STATS %c requested by %s (%s@%s) [%s]",
statchar, data->client->name, statchar, data->client->name,
data->client->username, data->client->username,
data->client->host, data->client->servptr->name); data->client->host, data->client->servptr->name);
} } else {
else sendto_realops_snomask(SNO_SPY, L_ALL,
{ "STATS %c requested by %s (%s@%s) [%s]",
sendto_realops_snomask(SNO_SPY, L_ALL, statchar, data->client->name, data->client->username,
"STATS %c requested by %s (%s@%s) [%s]", data->client->host, data->client->servptr->name);
statchar, data->client->name, data->client->username, }
data->client->host, data->client->servptr->name);
}
} }

View File

@ -30,8 +30,8 @@
void show_stats_p(hook_data *); void show_stats_p(hook_data *);
mapi_hfn_list_av1 stats_p_hfnlist[] = { mapi_hfn_list_av1 stats_p_hfnlist[] = {
{"doing_stats_p", (hookfn) show_stats_p}, {"doing_stats_p", (hookfn) show_stats_p},
{NULL, NULL} {NULL, NULL}
}; };
DECLARE_MODULE_AV1(stats_p_spy, NULL, NULL, NULL, NULL, stats_p_hfnlist, "$Revision: 498 $"); DECLARE_MODULE_AV1(stats_p_spy, NULL, NULL, NULL, NULL, stats_p_hfnlist, "$Revision: 498 $");
@ -39,8 +39,8 @@ DECLARE_MODULE_AV1(stats_p_spy, NULL, NULL, NULL, NULL, stats_p_hfnlist, "$Revis
void void
show_stats_p(hook_data *data) show_stats_p(hook_data *data)
{ {
sendto_realops_snomask(SNO_SPY, L_ALL, sendto_realops_snomask(SNO_SPY, L_ALL,
"STATS p requested by %s (%s@%s) [%s]", "STATS p requested by %s (%s@%s) [%s]",
data->client->name, data->client->username, data->client->name, data->client->username,
data->client->host, data->client->servptr->name); data->client->host, data->client->servptr->name);
} }

View File

@ -30,8 +30,8 @@
void show_trace(hook_data_client *); void show_trace(hook_data_client *);
mapi_hfn_list_av1 trace_hfnlist[] = { mapi_hfn_list_av1 trace_hfnlist[] = {
{"doing_trace", (hookfn) show_trace}, {"doing_trace", (hookfn) show_trace},
{NULL, NULL} {NULL, NULL}
}; };
DECLARE_MODULE_AV1(trace_spy, NULL, NULL, NULL, NULL, trace_hfnlist, "$Revision: 498 $"); DECLARE_MODULE_AV1(trace_spy, NULL, NULL, NULL, NULL, trace_hfnlist, "$Revision: 498 $");
@ -39,15 +39,15 @@ DECLARE_MODULE_AV1(trace_spy, NULL, NULL, NULL, NULL, trace_hfnlist, "$Revision:
void void
show_trace(hook_data_client *data) show_trace(hook_data_client *data)
{ {
if(data->target) if(data->target)
sendto_realops_snomask(SNO_SPY, L_ALL, sendto_realops_snomask(SNO_SPY, L_ALL,
"trace requested by %s (%s@%s) [%s] on %s", "trace requested by %s (%s@%s) [%s] on %s",
data->client->name, data->client->username, data->client->name, data->client->username,
data->client->host, data->client->servptr->name, data->client->host, data->client->servptr->name,
data->target->name); data->target->name);
else else
sendto_realops_snomask(SNO_SPY, L_ALL, sendto_realops_snomask(SNO_SPY, L_ALL,
"trace requested by %s (%s@%s) [%s]", "trace requested by %s (%s@%s) [%s]",
data->client->name, data->client->username, data->client->name, data->client->username,
data->client->host, data->client->servptr->name); data->client->host, data->client->servptr->name);
} }

View File

@ -8,7 +8,7 @@
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
* *
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
*/ */
#include "services.h" #include "services.h"
@ -17,135 +17,137 @@
#include "version.h" #include "version.h"
IRCDVar myIrcd[] = { IRCDVar myIrcd[] = {
{"Elemental-IRCd 6.5", /* ircd name */ {
"+oiS", /* nickserv mode */ "Elemental-IRCd 6.5", /* ircd name */
"+oiS", /* chanserv mode */ "+oiS", /* nickserv mode */
"+oiS", /* memoserv mode */ "+oiS", /* chanserv mode */
"+oiS", /* hostserv mode */ "+oiS", /* memoserv mode */
"+oaiS", /* operserv mode */ "+oiS", /* hostserv mode */
"+oiS", /* botserv mode */ "+oaiS", /* operserv mode */
"+oiS", /* helpserv mode */ "+oiS", /* botserv mode */
"+oiS", /* Dev/Null mode */ "+oiS", /* helpserv mode */
"+oiS", /* Global mode */ "+oiS", /* Dev/Null mode */
"+oiS", /* nickserv alias mode */ "+oiS", /* Global mode */
"+oiS", /* chanserv alias mode */ "+oiS", /* nickserv alias mode */
"+oiS", /* memoserv alias mode */ "+oiS", /* chanserv alias mode */
"+oiS", /* hostserv alias mode */ "+oiS", /* memoserv alias mode */
"+oaiS", /* operserv alias mode */ "+oiS", /* hostserv alias mode */
"+oiS", /* botserv alias mode */ "+oaiS", /* operserv alias mode */
"+oiS", /* helpserv alias mode */ "+oiS", /* botserv alias mode */
"+oiS", /* Dev/Null alias mode */ "+oiS", /* helpserv alias mode */
"+oiS", /* Global alias mode */ "+oiS", /* Dev/Null alias mode */
"+oiS", /* Used by BotServ Bots */ "+oiS", /* Global alias mode */
2, /* Chan Max Symbols */ "+oiS", /* Used by BotServ Bots */
"-cijlmnpstrgzQF", /* Modes to Remove */ 2, /* Chan Max Symbols */
"+ao", /* Channel Umode used by Botserv bots */ "-cijlmnpstrgzQF", /* Modes to Remove */
1, /* SVSNICK */ "+ao", /* Channel Umode used by Botserv bots */
1, /* Vhost */ 1, /* SVSNICK */
1, /* Has Owner */ 1, /* Vhost */
"+y", /* Mode to set for an owner */ 1, /* Has Owner */
"-y", /* Mode to unset for an owner */ "+y", /* Mode to set for an owner */
"+a", /* Mode to set for chan admin */ "-y", /* Mode to unset for an owner */
"-a", /* Mode to unset for chan admin */ "+a", /* Mode to set for chan admin */
NULL, /* Mode On Reg */ "-a", /* Mode to unset for chan admin */
NULL, /* Mode on ID for Roots */ NULL, /* Mode On Reg */
NULL, /* Mode on ID for Admins */ NULL, /* Mode on ID for Roots */
NULL, /* Mode on ID for Opers */ NULL, /* Mode on ID for Admins */
NULL, /* Mode on UnReg */ NULL, /* Mode on ID for Opers */
NULL, /* Mode on Nick Change */ NULL, /* Mode on UnReg */
1, /* Supports SGlines */ NULL, /* Mode on Nick Change */
1, /* Supports SQlines */ 1, /* Supports SGlines */
1, /* Supports SZlines */ 1, /* Supports SQlines */
1, /* Supports Halfop +h */ 1, /* Supports SZlines */
3, /* Number of server args */ 1, /* Supports Halfop +h */
1, /* Join 2 Set */ 3, /* Number of server args */
1, /* Join 2 Message */ 1, /* Join 2 Set */
1, /* Has exceptions +e */ 1, /* Join 2 Message */
0, /* TS Topic Forward */ 1, /* Has exceptions +e */
0, /* TS Topci Backward */ 0, /* TS Topic Forward */
0, /* Protected Umode */ 0, /* TS Topci Backward */
1, /* Has Admin */ 0, /* Protected Umode */
1, /* Chan SQlines */ 1, /* Has Admin */
0, /* Quit on Kill */ 1, /* Chan SQlines */
0, /* SVSMODE unban */ 0, /* Quit on Kill */
1, /* Has Protect */ 0, /* SVSMODE unban */
0, /* Reverse */ 1, /* Has Protect */
0, /* Chan Reg */ 0, /* Reverse */
0, /* Channel Mode */ 0, /* Chan Reg */
0, /* vidents */ 0, /* Channel Mode */
1, /* svshold */ 0, /* vidents */
0, /* time stamp on mode */ 1, /* svshold */
0, /* NICKIP */ 0, /* time stamp on mode */
0, /* UMODE */ 0, /* NICKIP */
0, /* O:LINE */ 0, /* UMODE */
1, /* VHOST ON NICK */ 0, /* O:LINE */
0, /* Change RealName */ 1, /* VHOST ON NICK */
CMODE_p, /* No Knock */ 0, /* Change RealName */
0, /* Admin Only */ CMODE_p, /* No Knock */
DEFAULT_MLOCK, /* Default MLOCK */ 0, /* Admin Only */
0, /* Vhost Mode */ DEFAULT_MLOCK, /* Default MLOCK */
1, /* +f */ 0, /* Vhost Mode */
1, /* +L */ 1, /* +f */
CMODE_j, /* +f Mode */ 1, /* +L */
CMODE_f, /* +L Mode (+f <target>) */ CMODE_j, /* +f Mode */
1, /* On nick change check if they could be identified */ CMODE_f, /* +L Mode (+f <target>) */
0, /* No Knock requires +i */ 1, /* On nick change check if they could be identified */
NULL, /* CAPAB Chan Modes */ 0, /* No Knock requires +i */
0, /* We support TOKENS */ NULL, /* CAPAB Chan Modes */
1, /* TOKENS are CASE inSensitive */ 0, /* We support TOKENS */
0, /* TIME STAMPS are BASE64 */ 1, /* TOKENS are CASE inSensitive */
1, /* +I support */ 0, /* TIME STAMPS are BASE64 */
0, /* SJOIN ban char */ 1, /* +I support */
0, /* SJOIN except char */ 0, /* SJOIN ban char */
0, /* SJOIN invite char */ 0, /* SJOIN except char */
0, /* Can remove User Channel Modes with SVSMODE */ 0, /* SJOIN invite char */
0, /* Sglines are not enforced until user reconnects */ 0, /* Can remove User Channel Modes with SVSMODE */
NULL, /* vhost char */ 0, /* Sglines are not enforced until user reconnects */
1, /* ts6 */ NULL, /* vhost char */
0, /* support helper umode */ 1, /* ts6 */
0, /* p10 */ 0, /* support helper umode */
NULL, /* character set */ 0, /* p10 */
0, /* reports sync state */ NULL, /* character set */
1, /* CIDR channelbans */ 0, /* reports sync state */
0, /* +j */ 1, /* CIDR channelbans */
0, /* +j Mode */ 0, /* +j */
0, /* Use delayed client introduction. */ 0, /* +j Mode */
} 0, /* Use delayed client introduction. */
}
, ,
{NULL} {NULL}
}; };
IRCDCAPAB myIrcdcap[] = { IRCDCAPAB myIrcdcap[] = {
{ {
0, /* NOQUIT */ 0, /* NOQUIT */
0, /* TSMODE */ 0, /* TSMODE */
0, /* UNCONNECT */ 0, /* UNCONNECT */
0, /* NICKIP */ 0, /* NICKIP */
0, /* SJOIN */ 0, /* SJOIN */
CAPAB_ZIP, /* ZIP */ CAPAB_ZIP, /* ZIP */
0, /* BURST */ 0, /* BURST */
CAPAB_TS5, /* TS5 */ CAPAB_TS5, /* TS5 */
0, /* TS3 */ 0, /* TS3 */
0, /* DKEY */ 0, /* DKEY */
0, /* PT4 */ 0, /* PT4 */
0, /* SCS */ 0, /* SCS */
CAPAB_QS, /* QS */ CAPAB_QS, /* QS */
CAPAB_UID, /* UID */ CAPAB_UID, /* UID */
CAPAB_KNOCK, /* KNOCK */ CAPAB_KNOCK, /* KNOCK */
0, /* CLIENT */ 0, /* CLIENT */
0, /* IPV6 */ 0, /* IPV6 */
0, /* SSJ5 */ 0, /* SSJ5 */
0, /* SN2 */ 0, /* SN2 */
0, /* TOKEN */ 0, /* TOKEN */
0, /* VHOST */ 0, /* VHOST */
0, /* SSJ3 */ 0, /* SSJ3 */
0, /* NICK2 */ 0, /* NICK2 */
0, /* UMODE2 */ 0, /* UMODE2 */
0, /* VL */ 0, /* VL */
0, /* TLKEXT */ 0, /* TLKEXT */
0, /* DODKEY */ 0, /* DODKEY */
0, /* DOZIP */ 0, /* DOZIP */
0, 0, 0} 0, 0, 0
}
}; };
/*******************************************************************/ /*******************************************************************/
@ -471,8 +473,8 @@ void charybdis_cmd_notice(char *source, char *dest, char *buf)
ud = find_uid(source); ud = find_uid(source);
u = finduser(dest); u = finduser(dest);
send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), send_cmd((UseTS6 ? (ud ? ud->uid : source) : source),
"NOTICE %s :%s", (UseTS6 ? (u ? u->uid : dest) : dest), "NOTICE %s :%s", (UseTS6 ? (u ? u->uid : dest) : dest),
buf); buf);
} }
} }
@ -484,7 +486,7 @@ void charybdis_cmd_notice2(char *source, char *dest, char *msg)
ud = find_uid(source); ud = find_uid(source);
u = finduser(dest); u = finduser(dest);
send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "NOTICE %s :%s", send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "NOTICE %s :%s",
(UseTS6 ? (u ? u->uid : dest) : dest), msg); (UseTS6 ? (u ? u->uid : dest) : dest), msg);
} }
void charybdis_cmd_privmsg(char *source, char *dest, char *buf) void charybdis_cmd_privmsg(char *source, char *dest, char *buf)
@ -498,7 +500,7 @@ void charybdis_cmd_privmsg(char *source, char *dest, char *buf)
ud2 = find_uid(dest); ud2 = find_uid(dest);
send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "PRIVMSG %s :%s", send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "PRIVMSG %s :%s",
(UseTS6 ? (ud2 ? ud2->uid : dest) : dest), buf); (UseTS6 ? (ud2 ? ud2->uid : dest) : dest), buf);
} }
void charybdis_cmd_privmsg2(char *source, char *dest, char *msg) void charybdis_cmd_privmsg2(char *source, char *dest, char *msg)
@ -509,7 +511,7 @@ void charybdis_cmd_privmsg2(char *source, char *dest, char *msg)
ud2 = find_uid(dest); ud2 = find_uid(dest);
send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "PRIVMSG %s :%s", send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "PRIVMSG %s :%s",
(UseTS6 ? (ud2 ? ud2->uid : dest) : dest), msg); (UseTS6 ? (ud2 ? ud2->uid : dest) : dest), msg);
} }
void charybdis_cmd_serv_notice(char *source, char *dest, char *msg) void charybdis_cmd_serv_notice(char *source, char *dest, char *msg)
@ -645,7 +647,7 @@ int anope_event_euid(char *source, int ac, char **av)
s = findserver_uid(servlist, source); s = findserver_uid(servlist, source);
/* Source is always the server */ /* Source is always the server */
*source = '\0'; *source = '\0';
ts = strtoul(av[2], NULL, 10); ts = strtoul(av[2], NULL, 10);
user = do_nick(source, av[0], av[4], !strcmp(av[8], "*") ? av[5] : av[8], s->name, av[10], user = do_nick(source, av[0], av[4], !strcmp(av[8], "*") ? av[5] : av[8], s->name, av[10],
ts, !stricmp(av[0], av[9]) ? ts : 0, 0, av[5], av[7]); ts, !stricmp(av[0], av[9]) ? ts : 0, 0, av[5], av[7]);
if (user) { if (user) {
@ -696,11 +698,11 @@ int anope_event_topic(char *source, int ac, char **av)
c->topic_time = topic_time; c->topic_time = topic_time;
record_topic(av[0]); record_topic(av[0]);
if (ac > 1 && *av[1]) if (ac > 1 && *av[1])
send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]);
else else
send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); send_event(EVENT_TOPIC_UPDATED, 2, av[0], "");
} }
return MOD_CONT; return MOD_CONT;
} }
@ -748,10 +750,10 @@ int anope_event_tburst(char *source, int ac, char **av)
record_topic(av[0]); record_topic(av[0]);
if (ac > 1 && *av[3]) if (ac > 1 && *av[3])
send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[3]); send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[3]);
else else
send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); send_event(EVENT_TOPIC_UPDATED, 2, av[0], "");
if (setter) if (setter)
free(setter); free(setter);
@ -770,54 +772,92 @@ int anope_event_436(char *source, int ac, char **av)
/* *INDENT-OFF* */ /* *INDENT-OFF* */
void moduleAddIRCDMsgs(void) void moduleAddIRCDMsgs(void)
{ {
Message *m; Message *m;
updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-"); updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-");
if (UseTS6) { if (UseTS6) {
TS6SID = sstrdup(Numeric); TS6SID = sstrdup(Numeric);
} }
m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m); m = createMessage("401", anope_event_null);
m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); m = createMessage("402", anope_event_null);
m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("INVITE", anope_event_invite); addCoreMessage(IRCD,m); m = createMessage("436", anope_event_436);
m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); m = createMessage("AWAY", anope_event_away);
m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); m = createMessage("INVITE", anope_event_invite);
m = createMessage("TMODE", anope_event_tmode); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); m = createMessage("JOIN", anope_event_join);
m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("BMASK", anope_event_bmask); addCoreMessage(IRCD,m); m = createMessage("KICK", anope_event_kick);
m = createMessage("UID", anope_event_nick); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m); m = createMessage("KILL", anope_event_kill);
m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); m = createMessage("MODE", anope_event_mode);
m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); m = createMessage("TMODE", anope_event_tmode);
m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); m = createMessage("MOTD", anope_event_motd);
m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); m = createMessage("NICK", anope_event_nick);
m = createMessage("TB", anope_event_tburst); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m); m = createMessage("BMASK", anope_event_bmask);
m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); m = createMessage("UID", anope_event_nick);
m = createMessage("SVSMODE", anope_event_null); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m); m = createMessage("NOTICE", anope_event_notice);
m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); m = createMessage("PART", anope_event_part);
m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m); m = createMessage("PASS", anope_event_pass);
m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("421", anope_event_null); addCoreMessage(IRCD,m); m = createMessage("PING", anope_event_ping);
m = createMessage("ENCAP", anope_event_null); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("SID", anope_event_sid); addCoreMessage(IRCD,m); m = createMessage("PRIVMSG", anope_event_privmsg);
m = createMessage("EUID", anope_event_euid); addCoreMessage(IRCD,m); addCoreMessage(IRCD,m);
m = createMessage("QUIT", anope_event_quit);
addCoreMessage(IRCD,m);
m = createMessage("SERVER", anope_event_server);
addCoreMessage(IRCD,m);
m = createMessage("SQUIT", anope_event_squit);
addCoreMessage(IRCD,m);
m = createMessage("TOPIC", anope_event_topic);
addCoreMessage(IRCD,m);
m = createMessage("TB", anope_event_tburst);
addCoreMessage(IRCD,m);
m = createMessage("USER", anope_event_null);
addCoreMessage(IRCD,m);
m = createMessage("WALLOPS", anope_event_null);
addCoreMessage(IRCD,m);
m = createMessage("WHOIS", anope_event_whois);
addCoreMessage(IRCD,m);
m = createMessage("SVSMODE", anope_event_null);
addCoreMessage(IRCD,m);
m = createMessage("SVSNICK", anope_event_null);
addCoreMessage(IRCD,m);
m = createMessage("CAPAB", anope_event_capab);
addCoreMessage(IRCD,m);
m = createMessage("SJOIN", anope_event_sjoin);
addCoreMessage(IRCD,m);
m = createMessage("SVINFO", anope_event_svinfo);
addCoreMessage(IRCD,m);
m = createMessage("ADMIN", anope_event_admin);
addCoreMessage(IRCD,m);
m = createMessage("ERROR", anope_event_error);
addCoreMessage(IRCD,m);
m = createMessage("421", anope_event_null);
addCoreMessage(IRCD,m);
m = createMessage("ENCAP", anope_event_null);
addCoreMessage(IRCD,m);
m = createMessage("SID", anope_event_sid);
addCoreMessage(IRCD,m);
m = createMessage("EUID", anope_event_euid);
addCoreMessage(IRCD,m);
} }
/* *INDENT-ON* */ /* *INDENT-ON* */
@ -829,7 +869,7 @@ void charybdis_cmd_sqline(char *mask, char *reason)
ud = find_uid(s_OperServ); ud = find_uid(s_OperServ);
send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ), send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ),
"RESV * %s :%s", mask, reason); "RESV * %s :%s", mask, reason);
} }
void charybdis_cmd_unsgline(char *mask) void charybdis_cmd_unsgline(char *mask)
@ -838,7 +878,7 @@ void charybdis_cmd_unsgline(char *mask)
ud = find_uid(s_OperServ); ud = find_uid(s_OperServ);
send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ), send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ),
"UNXLINE * %s", mask); "UNXLINE * %s", mask);
} }
void charybdis_cmd_unszline(char *mask) void charybdis_cmd_unszline(char *mask)
@ -867,7 +907,7 @@ void charybdis_cmd_sgline(char *mask, char *reason)
ud = find_uid(s_OperServ); ud = find_uid(s_OperServ);
send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ), send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ),
"XLINE * %s 0 :%s", mask, reason); "XLINE * %s 0 :%s", mask, reason);
} }
void charybdis_cmd_remove_akill(char *user, char *host) void charybdis_cmd_remove_akill(char *user, char *host)
@ -879,17 +919,17 @@ void charybdis_cmd_remove_akill(char *user, char *host)
ud = find_uid(s_OperServ); ud = find_uid(s_OperServ);
send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ), send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ),
"UNKLINE * %s %s", user, host); "UNKLINE * %s %s", user, host);
} }
void charybdis_cmd_topic(char *whosets, char *chan, char *whosetit, void charybdis_cmd_topic(char *whosets, char *chan, char *whosetit,
char *topic, time_t when) char *topic, time_t when)
{ {
Uid *ud; Uid *ud;
ud = find_uid(whosets); ud = find_uid(whosets);
send_cmd((UseTS6 ? (ud ? ud->uid : whosets) : whosets), "TOPIC %s :%s", send_cmd((UseTS6 ? (ud ? ud->uid : whosets) : whosets), "TOPIC %s :%s",
chan, topic); chan, topic);
} }
void charybdis_cmd_vhost_off(User * u) void charybdis_cmd_vhost_off(User * u)
@ -910,7 +950,7 @@ void charybdis_cmd_unsqline(char *user)
ud = find_uid(s_OperServ); ud = find_uid(s_OperServ);
send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ), send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ),
"UNRESV * %s", user); "UNRESV * %s", user);
} }
void charybdis_cmd_join(char *user, char *channel, time_t chantime) void charybdis_cmd_join(char *user, char *channel, time_t chantime)
@ -932,15 +972,15 @@ reason: the reason for the kline.
*/ */
void charybdis_cmd_akill(char *user, char *host, char *who, time_t when, void charybdis_cmd_akill(char *user, char *host, char *who, time_t when,
time_t expires, char *reason) time_t expires, char *reason)
{ {
Uid *ud; Uid *ud;
ud = find_uid(s_OperServ); ud = find_uid(s_OperServ);
send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ), send_cmd((UseTS6 ? (ud ? ud->uid : s_OperServ) : s_OperServ),
"KLINE * %ld %s %s :%s", "KLINE * %ld %s %s :%s",
(long int) (expires - (long) time(NULL)), user, host, reason); (long int) (expires - (long) time(NULL)), user, host, reason);
} }
void charybdis_cmd_svskill(char *source, char *user, char *buf) void charybdis_cmd_svskill(char *source, char *user, char *buf)
@ -958,7 +998,7 @@ void charybdis_cmd_svskill(char *source, char *user, char *buf)
ud = find_uid(source); ud = find_uid(source);
ud2 = find_uid(user); ud2 = find_uid(user);
send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "KILL %s :%s", send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "KILL %s :%s",
(UseTS6 ? (ud2 ? ud2->uid : user) : user), buf); (UseTS6 ? (ud2 ? ud2->uid : user) : user), buf);
} }
void charybdis_cmd_svsmode(User * u, int ac, char **av) void charybdis_cmd_svsmode(User * u, int ac, char **av)
@ -988,18 +1028,18 @@ void charybdis_cmd_svsinfo()
/* CAPAB */ /* CAPAB */
/* /*
QS - Can handle quit storm removal QS - Can handle quit storm removal
EX - Can do channel +e exemptions EX - Can do channel +e exemptions
CHW - Can do channel wall @# CHW - Can do channel wall @#
LL - Can do lazy links LL - Can do lazy links
IE - Can do invite exceptions IE - Can do invite exceptions
EOB - Can do EOB message EOB - Can do EOB message
KLN - Can do KLINE message KLN - Can do KLINE message
GLN - Can do GLINE message GLN - Can do GLINE message
HUB - This server is a HUB HUB - This server is a HUB
UID - Can do UIDs UID - Can do UIDs
ZIP - Can do ZIPlinks ZIP - Can do ZIPlinks
ENC - Can do ENCrypted links ENC - Can do ENCrypted links
KNOCK - supports KNOCK KNOCK - supports KNOCK
TBURST - supports TBURST TBURST - supports TBURST
PARA - supports invite broadcasting for +p PARA - supports invite broadcasting for +p
ENCAP - supports message encapsulation ENCAP - supports message encapsulation
@ -1056,7 +1096,7 @@ void charybdis_cmd_bob()
} }
void charybdis_cmd_bot_nick(char *nick, char *user, char *host, char *real, void charybdis_cmd_bot_nick(char *nick, char *user, char *host, char *real,
char *modes) char *modes)
{ {
EnforceQlinedNick(nick, NULL); EnforceQlinedNick(nick, NULL);
if (UseTS6) { if (UseTS6) {
@ -1103,7 +1143,7 @@ int anope_event_away(char *source, int ac, char **av)
} }
m_away((UseTS6 ? (u ? u->nick : source) : source), m_away((UseTS6 ? (u ? u->nick : source) : source),
(ac ? av[0] : NULL)); (ac ? av[0] : NULL));
return MOD_CONT; return MOD_CONT;
} }
@ -1140,7 +1180,7 @@ void charybdis_cmd_eob()
int anope_event_join(char *source, int ac, char **av) int anope_event_join(char *source, int ac, char **av)
{ {
if (ac != 1) { if (ac != 1) {
/* ignore cmodes in JOIN as per TS6 v8 */ /* ignore cmodes in JOIN as per TS6 v8 */
do_sjoin(source, ac > 2 ? 2 : ac, av); do_sjoin(source, ac > 2 ? 2 : ac, av);
return MOD_CONT; return MOD_CONT;
} else { } else {
@ -1171,7 +1211,7 @@ int anope_event_privmsg(char *source, int ac, char **av)
u = find_byuid(source); u = find_byuid(source);
ud = find_nickuid(av[0]); ud = find_nickuid(av[0]);
m_privmsg((UseTS6 ? (u ? u->nick : source) : source), m_privmsg((UseTS6 ? (u ? u->nick : source) : source),
(UseTS6 ? (ud ? ud->nick : av[0]) : av[0]), av[1]); (UseTS6 ? (ud ? ud->nick : av[0]) : av[0]), av[1]);
return MOD_CONT; return MOD_CONT;
} }
@ -1409,7 +1449,7 @@ void charybdis_cmd_mode(char *source, char *dest, char *buf)
if (source) { if (source) {
ud = find_uid(source); ud = find_uid(source);
send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "MODE %s %s", send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "MODE %s %s",
dest, buf); dest, buf);
} else { } else {
send_cmd(NULL, "MODE %s %s", dest, buf); send_cmd(NULL, "MODE %s %s", dest, buf);
} }
@ -1460,11 +1500,11 @@ void charybdis_cmd_kick(char *source, char *chan, char *user, char *buf)
if (buf) { if (buf) {
send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), send_cmd((UseTS6 ? (ud ? ud->uid : source) : source),
"KICK %s %s :%s", chan, "KICK %s %s :%s", chan,
(UseTS6 ? (u ? u->uid : user) : user), buf); (UseTS6 ? (u ? u->uid : user) : user), buf);
} else { } else {
send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "KICK %s %s", send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "KICK %s %s",
chan, (UseTS6 ? (u ? u->uid : user) : user)); chan, (UseTS6 ? (u ? u->uid : user) : user));
} }
} }
@ -1487,7 +1527,7 @@ void charybdis_cmd_bot_chan_mode(char *nick, char *chan)
if (UseTS6) { if (UseTS6) {
u = find_uid(nick); u = find_uid(nick);
charybdis_cmd_tmode(nick, chan, "%s %s", ircd->botchanumode, charybdis_cmd_tmode(nick, chan, "%s %s", ircd->botchanumode,
(u ? u->uid : nick)); (u ? u->uid : nick));
} else { } else {
anope_cmd_mode(ServerName, chan, "%s %s", ircd->botchanumode, nick); anope_cmd_mode(ServerName, chan, "%s %s", ircd->botchanumode, nick);
} }
@ -1501,7 +1541,7 @@ void charybdis_cmd_quit(char *source, char *buf)
if (buf) { if (buf) {
send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "QUIT :%s", send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "QUIT :%s",
buf); buf);
} else { } else {
send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "QUIT"); send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "QUIT");
} }
@ -1532,7 +1572,7 @@ void charybdis_cmd_invite(char *source, char *chan, char *nick)
u = finduser(nick); u = finduser(nick);
send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "INVITE %s %s", send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "INVITE %s %s",
(UseTS6 ? (u ? u->uid : nick) : nick), chan); (UseTS6 ? (u ? u->uid : nick) : nick), chan);
} }
/* SQUIT */ /* SQUIT */
@ -1646,7 +1686,7 @@ void charybdis_cmd_svsnick(char *nick, char *newnick, time_t when)
} }
void charybdis_cmd_guest_nick(char *nick, char *user, char *host, char *real, void charybdis_cmd_guest_nick(char *nick, char *user, char *host, char *real,
char *modes) char *modes)
{ {
/* not supported */ /* not supported */
} }
@ -1833,7 +1873,7 @@ void charybdis_cmd_jupe(char *jserver, char *who, char *reason)
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
} }
/* /*
1 = valid nick 1 = valid nick
0 = nick is in valid 0 = nick is in valid
*/ */
@ -1845,7 +1885,7 @@ int charybdis_valid_nick(char *nick)
return 1; return 1;
} }
/* /*
1 = valid chan 1 = valid chan
0 = chan is invalid 0 = chan is invalid
*/ */
@ -1873,7 +1913,7 @@ void charybdis_cmd_ctcp(char *source, char *dest, char *buf)
int charybdis_send_account(int argc, char **argv) int charybdis_send_account(int argc, char **argv)
{ {
send_cmd((UseTS6 ? TS6SID : ServerName), "ENCAP * SU %s :%s", send_cmd((UseTS6 ? TS6SID : ServerName), "ENCAP * SU %s :%s",
argv[0], argv[0]); argv[0], argv[0]);
return MOD_CONT; return MOD_CONT;
} }
@ -1883,7 +1923,7 @@ int charybdis_send_account(int argc, char **argv)
int charybdis_send_deaccount(int argc, char **argv) int charybdis_send_deaccount(int argc, char **argv)
{ {
send_cmd((UseTS6 ? TS6SID : ServerName), "ENCAP * SU %s", send_cmd((UseTS6 ? TS6SID : ServerName), "ENCAP * SU %s",
argv[0]); argv[0]);
return MOD_CONT; return MOD_CONT;
} }
@ -1971,7 +2011,7 @@ void moduleAddAnopeCmds()
pmodule_set_umode(charybdis_set_umode); pmodule_set_umode(charybdis_set_umode);
} }
/** /**
* Now tell anope how to use us. * Now tell anope how to use us.
**/ **/
int AnopeInit(int argc, char **argv) int AnopeInit(int argc, char **argv)
@ -1994,7 +2034,7 @@ int AnopeInit(int argc, char **argv)
pmodule_ircd_csmodes(myCsmodes); pmodule_ircd_csmodes(myCsmodes);
pmodule_ircd_useTSMode(0); pmodule_ircd_useTSMode(0);
/** Deal with modes anope _needs_ to know **/ /** Deal with modes anope _needs_ to know **/
pmodule_invis_umode(UMODE_i); pmodule_invis_umode(UMODE_i);
pmodule_oper_umode(UMODE_o); pmodule_oper_umode(UMODE_o);
pmodule_invite_cmode(CMODE_i); pmodule_invite_cmode(CMODE_i);
@ -2014,7 +2054,7 @@ int AnopeInit(int argc, char **argv)
moduleAddEventHook(hk); moduleAddEventHook(hk);
/* XXX: It'd be nice if we could have an event like this, but it's not there yet :( */ /* XXX: It'd be nice if we could have an event like this, but it's not there yet :( */
/* It's there now! Trystan said so! -GD */ /* It's there now! Trystan said so! -GD */
hk = createEventHook(EVENT_NICK_LOGOUT, charybdis_send_deaccount); hk = createEventHook(EVENT_NICK_LOGOUT, charybdis_send_deaccount);
moduleAddEventHook(hk); moduleAddEventHook(hk);
@ -2024,8 +2064,8 @@ int AnopeInit(int argc, char **argv)
/* Clean up allocated things in here */ /* Clean up allocated things in here */
void AnopeFini(void) void AnopeFini(void)
{ {
if (UseTS6) if (UseTS6)
free(TS6SID); free(TS6SID);
} }
/* EOF */ /* EOF */

View File

@ -19,103 +19,103 @@ DECLARE_MODULE_V1("protocol/elemental-ircd", true, _modinit, NULL, PACKAGE_STRIN
/* *INDENT-OFF* */ /* *INDENT-OFF* */
ircd_t elemental_ircd = { ircd_t elemental_ircd = {
"elemental-ircd", /* IRCd name */ "elemental-ircd", /* IRCd name */
"$$", /* TLD Prefix, used by Global. */ "$$", /* TLD Prefix, used by Global. */
true, /* Whether or not we use IRCNet/TS6 UID */ true, /* Whether or not we use IRCNet/TS6 UID */
false, /* Whether or not we use RCOMMAND */ false, /* Whether or not we use RCOMMAND */
true, /* Whether or not we support channel owners. */ true, /* Whether or not we support channel owners. */
true, /* Whether or not we support channel protection. */ true, /* Whether or not we support channel protection. */
true, /* Whether or not we support halfops. */ true, /* Whether or not we support halfops. */
false, /* Whether or not we use P10 */ false, /* Whether or not we use P10 */
false, /* Whether or not we use vHosts. */ false, /* Whether or not we use vHosts. */
CMODE_EXLIMIT | CMODE_PERM | CMODE_IMMUNE, /* Oper-only cmodes */ CMODE_EXLIMIT | CMODE_PERM | CMODE_IMMUNE, /* Oper-only cmodes */
CSTATUS_OWNER, /* Integer flag for owner channel flag. */ CSTATUS_OWNER, /* Integer flag for owner channel flag. */
CSTATUS_PROTECT, /* Integer flag for protect channel flag. */ CSTATUS_PROTECT, /* Integer flag for protect channel flag. */
CSTATUS_HALFOP, /* Integer flag for halfops. */ CSTATUS_HALFOP, /* Integer flag for halfops. */
"+y", /* Mode we set for owner. */ "+y", /* Mode we set for owner. */
"+a", /* Mode we set for protect. */ "+a", /* Mode we set for protect. */
"+h", /* Mode we set for halfops. */ "+h", /* Mode we set for halfops. */
PROTOCOL_SHADOWIRCD, /* Protocol type */ PROTOCOL_SHADOWIRCD, /* Protocol type */
CMODE_PERM, /* Permanent cmodes */ CMODE_PERM, /* Permanent cmodes */
CMODE_IMMUNE, /* Oper-immune cmode */ CMODE_IMMUNE, /* Oper-immune cmode */
"beIq", /* Ban-like cmodes */ "beIq", /* Ban-like cmodes */
'e', /* Except mchar */ 'e', /* Except mchar */
'I', /* Invex mchar */ 'I', /* Invex mchar */
IRCD_CIDR_BANS | IRCD_HOLDNICK /* Flags */ IRCD_CIDR_BANS | IRCD_HOLDNICK /* Flags */
}; };
struct cmode_ elemental_mode_list[] = { struct cmode_ elemental_mode_list[] = {
{ 'i', CMODE_INVITE }, { 'i', CMODE_INVITE },
{ 'm', CMODE_MOD }, { 'm', CMODE_MOD },
{ 'n', CMODE_NOEXT }, { 'n', CMODE_NOEXT },
{ 'p', CMODE_PRIV }, { 'p', CMODE_PRIV },
{ 's', CMODE_SEC }, { 's', CMODE_SEC },
{ 't', CMODE_TOPIC }, { 't', CMODE_TOPIC },
{ 'c', CMODE_NOCOLOR}, { 'c', CMODE_NOCOLOR},
{ 'r', CMODE_REGONLY}, { 'r', CMODE_REGONLY},
{ 'z', CMODE_OPMOD }, { 'z', CMODE_OPMOD },
{ 'g', CMODE_FINVITE}, { 'g', CMODE_FINVITE},
{ 'L', CMODE_EXLIMIT}, { 'L', CMODE_EXLIMIT},
{ 'P', CMODE_PERM }, { 'P', CMODE_PERM },
{ 'F', CMODE_FTARGET}, { 'F', CMODE_FTARGET},
{ 'Q', CMODE_DISFWD }, { 'Q', CMODE_DISFWD },
{ 'M', CMODE_IMMUNE }, { 'M', CMODE_IMMUNE },
{ 'C', CMODE_NOCTCP }, { 'C', CMODE_NOCTCP },
{ 'A', CMODE_ADMINONLY }, { 'A', CMODE_ADMINONLY },
{ 'O', CMODE_OPERONLY }, { 'O', CMODE_OPERONLY },
{ 'S', CMODE_SSLONLY }, { 'S', CMODE_SSLONLY },
{ 'D', CMODE_NOACTIONS }, { 'D', CMODE_NOACTIONS },
{ 'T', CMODE_NONOTICE }, { 'T', CMODE_NONOTICE },
{ 'G', CMODE_NOCAPS }, { 'G', CMODE_NOCAPS },
{ 'E', CMODE_NOKICKS }, { 'E', CMODE_NOKICKS },
{ 'd', CMODE_NONICKS }, { 'd', CMODE_NONICKS },
{ 'K', CMODE_NOREPEAT }, { 'K', CMODE_NOREPEAT },
{ 'J', CMODE_KICKNOREJOIN }, { 'J', CMODE_KICKNOREJOIN },
{ '\0', 0 } { '\0', 0 }
}; };
struct cmode_ elemental_status_mode_list[] = { struct cmode_ elemental_status_mode_list[] = {
{ 'y', CSTATUS_OWNER }, { 'y', CSTATUS_OWNER },
{ 'a', CSTATUS_PROTECT }, { 'a', CSTATUS_PROTECT },
{ 'o', CSTATUS_OP }, { 'o', CSTATUS_OP },
{ 'h', CSTATUS_HALFOP }, { 'h', CSTATUS_HALFOP },
{ 'v', CSTATUS_VOICE }, { 'v', CSTATUS_VOICE },
{ '\0', 0 } { '\0', 0 }
}; };
struct cmode_ elemental_prefix_mode_list[] = { struct cmode_ elemental_prefix_mode_list[] = {
{ '~', CSTATUS_OWNER }, { '~', CSTATUS_OWNER },
{ '!', CSTATUS_PROTECT }, { '!', CSTATUS_PROTECT },
{ '@', CSTATUS_OP }, { '@', CSTATUS_OP },
{ '%', CSTATUS_HALFOP }, { '%', CSTATUS_HALFOP },
{ '+', CSTATUS_VOICE }, { '+', CSTATUS_VOICE },
{ '\0', 0 } { '\0', 0 }
}; };
struct cmode_ elemental_user_mode_list[] = { struct cmode_ elemental_user_mode_list[] = {
{ 'a', UF_ADMIN }, { 'a', UF_ADMIN },
{ 'i', UF_INVIS }, { 'i', UF_INVIS },
{ 'o', UF_IRCOP }, { 'o', UF_IRCOP },
{ 'D', UF_DEAF }, { 'D', UF_DEAF },
{ '\0', 0 } { '\0', 0 }
}; };
/* *INDENT-ON* */ /* *INDENT-ON* */
void _modinit(module_t * m) void _modinit(module_t * m)
{ {
MODULE_TRY_REQUEST_DEPENDENCY(m, "protocol/charybdis"); MODULE_TRY_REQUEST_DEPENDENCY(m, "protocol/charybdis");
mode_list = elemental_mode_list; mode_list = elemental_mode_list;
user_mode_list = elemental_user_mode_list; user_mode_list = elemental_user_mode_list;
status_mode_list = elemental_status_mode_list; status_mode_list = elemental_status_mode_list;
prefix_mode_list = elemental_prefix_mode_list; prefix_mode_list = elemental_prefix_mode_list;
ircd = &elemental_ircd; ircd = &elemental_ircd;
m->mflags = MODTYPE_CORE; m->mflags = MODTYPE_CORE;
pmodule_loaded = true; pmodule_loaded = true;
} }
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs

View File

@ -3,17 +3,16 @@
void init_bandb(void); void init_bandb(void);
typedef enum typedef enum {
{ BANDB_KLINE,
BANDB_KLINE, BANDB_DLINE,
BANDB_DLINE, BANDB_XLINE,
BANDB_XLINE, BANDB_RESV,
BANDB_RESV, LAST_BANDB_TYPE
LAST_BANDB_TYPE
} bandb_type; } bandb_type;
void bandb_add(bandb_type, struct Client *source_p, const char *mask1, void bandb_add(bandb_type, struct Client *source_p, const char *mask1,
const char *mask2, const char *reason, const char *oper_reason, int perm); const char *mask2, const char *reason, const char *oper_reason, int perm);
void bandb_del(bandb_type, const char *mask1, const char *mask2); void bandb_del(bandb_type, const char *mask1, const char *mask2);
void bandb_rehash_bans(void); void bandb_rehash_bans(void);
#endif #endif

View File

@ -26,26 +26,26 @@
/* A configured DNSBL */ /* A configured DNSBL */
struct Blacklist { struct Blacklist {
unsigned int status; /* If CONF_ILLEGAL, delete when no clients */ unsigned int status; /* If CONF_ILLEGAL, delete when no clients */
int refcount; int refcount;
int ipv4; /* Does this blacklist support IPv4 lookups? */ int ipv4; /* Does this blacklist support IPv4 lookups? */
int ipv6; /* Does this blacklist support IPv6 lookups? */ int ipv6; /* Does this blacklist support IPv6 lookups? */
char host[IRCD_RES_HOSTLEN + 1]; char host[IRCD_RES_HOSTLEN + 1];
char reject_reason[IRCD_BUFSIZE]; char reject_reason[IRCD_BUFSIZE];
unsigned int hits; unsigned int hits;
time_t lastwarning; time_t lastwarning;
}; };
/* A lookup in progress for a particular DNSBL for a particular client */ /* A lookup in progress for a particular DNSBL for a particular client */
struct BlacklistClient { struct BlacklistClient {
struct Blacklist *blacklist; struct Blacklist *blacklist;
struct Client *client_p; struct Client *client_p;
struct DNSQuery dns_query; struct DNSQuery dns_query;
rb_dlink_node node; rb_dlink_node node;
}; };
/* public interfaces */ /* public interfaces */
struct Blacklist *new_blacklist(char *host, char *reject_reason, int ipv4, int ipv6); struct Blacklist *new_blacklist(char *host, char *reject_reason, int ipv4, int ipv6);
void lookup_blacklists(struct Client *client_p); void lookup_blacklists(struct Client *client_p);
void abort_blacklist_queries(struct Client *client_p); void abort_blacklist_queries(struct Client *client_p);
void unref_blacklist(struct Blacklist *blptr); void unref_blacklist(struct Blacklist *blptr);

View File

@ -14,17 +14,15 @@
struct Client; struct Client;
struct cachefile struct cachefile {
{ char name[CACHEFILELEN];
char name[CACHEFILELEN]; rb_dlink_list contents;
rb_dlink_list contents; int flags;
int flags;
}; };
struct cacheline struct cacheline {
{ char data[CACHELINELEN];
char data[CACHELINELEN]; rb_dlink_node linenode;
rb_dlink_node linenode;
}; };
extern struct cachefile *user_motd; extern struct cachefile *user_motd;

View File

@ -35,110 +35,102 @@
struct Client; struct Client;
/* mode structure for channels */ /* mode structure for channels */
struct Mode struct Mode {
{ unsigned int mode;
unsigned int mode; int limit;
int limit; char key[KEYLEN];
char key[KEYLEN]; unsigned int join_num;
unsigned int join_num; unsigned int join_time;
unsigned int join_time; char forward[LOC_CHANNELLEN + 1];
char forward[LOC_CHANNELLEN + 1];
}; };
/* channel structure */ /* channel structure */
struct Channel struct Channel {
{ rb_dlink_node node;
rb_dlink_node node; struct Mode mode;
struct Mode mode; char *mode_lock;
char *mode_lock; char *topic;
char *topic; char *topic_info;
char *topic_info; time_t topic_time;
time_t topic_time; time_t last_knock; /* don't allow knock to flood */
time_t last_knock; /* don't allow knock to flood */
rb_dlink_list members; /* channel members */ rb_dlink_list members; /* channel members */
rb_dlink_list locmembers; /* local channel members */ rb_dlink_list locmembers; /* local channel members */
rb_dlink_list invites; rb_dlink_list invites;
rb_dlink_list banlist; rb_dlink_list banlist;
rb_dlink_list exceptlist; rb_dlink_list exceptlist;
rb_dlink_list invexlist; rb_dlink_list invexlist;
rb_dlink_list quietlist; rb_dlink_list quietlist;
time_t first_received_message_time; /* channel flood control */ time_t first_received_message_time; /* channel flood control */
int received_number_of_privmsgs; int received_number_of_privmsgs;
int flood_noticed; int flood_noticed;
unsigned int join_count; /* joins within delta */ unsigned int join_count; /* joins within delta */
unsigned int join_delta; /* last ts of join */ unsigned int join_delta; /* last ts of join */
struct Dictionary *metadata; struct Dictionary *metadata;
unsigned long bants; unsigned long bants;
time_t channelts; time_t channelts;
char *chname; char *chname;
}; };
struct membership struct membership {
{ rb_dlink_node channode;
rb_dlink_node channode; rb_dlink_node locchannode;
rb_dlink_node locchannode; rb_dlink_node usernode;
rb_dlink_node usernode;
struct Channel *chptr; struct Channel *chptr;
struct Client *client_p; struct Client *client_p;
unsigned int flags; unsigned int flags;
unsigned long bants; unsigned long bants;
}; };
#define BANLEN 195 #define BANLEN 195
struct Ban struct Ban {
{ char *banstr;
char *banstr; char *who;
char *who; time_t when;
time_t when; rb_dlink_node node;
rb_dlink_node node;
}; };
struct mode_letter struct mode_letter {
{ int mode;
int mode; char letter;
char letter;
}; };
struct ChModeChange struct ChModeChange {
{ char letter;
char letter; const char *arg;
const char *arg; const char *id;
const char *id; int dir;
int dir; int caps;
int caps; int nocaps;
int nocaps; int mems;
int mems; int override;
int override; struct Client *client;
struct Client *client;
}; };
struct ChCapCombo struct ChCapCombo {
{ int count;
int count; int cap_yes;
int cap_yes; int cap_no;
int cap_no;
}; };
typedef void (*ChannelModeFunc)(struct Client *source_p, struct Channel *chptr, typedef void (*ChannelModeFunc)(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
struct ChannelMode struct ChannelMode {
{ ChannelModeFunc set_func;
ChannelModeFunc set_func; long mode_type;
long mode_type;
}; };
typedef int (*ExtbanFunc)(const char *data, struct Client *client_p, typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type); struct Channel *chptr, long mode_type);
/* can_send results */ /* can_send results */
#define CAN_SEND_NO 0 #define CAN_SEND_NO 0
@ -232,14 +224,14 @@ void free_ban(struct Ban *bptr);
extern void destroy_channel(struct Channel *); extern void destroy_channel(struct Channel *);
extern int can_send(struct Channel *chptr, struct Client *who, extern int can_send(struct Channel *chptr, struct Client *who,
struct membership *); struct membership *);
extern int flood_attack_channel(int p_or_n, struct Client *source_p, extern int flood_attack_channel(int p_or_n, struct Client *source_p,
struct Channel *chptr, char *chname); struct Channel *chptr, char *chname);
extern int is_banned(struct Channel *chptr, struct Client *who, extern int is_banned(struct Channel *chptr, struct Client *who,
struct membership *msptr, const char *, const char *); struct membership *msptr, const char *, const char *);
extern int is_quieted(struct Channel *chptr, struct Client *who, extern int is_quieted(struct Channel *chptr, struct Client *who,
struct membership *msptr, const char *, const char *); struct membership *msptr, const char *, const char *);
extern int can_join(struct Client *source_p, struct Channel *chptr, char *key); extern int can_join(struct Client *source_p, struct Channel *chptr, char *key);
extern struct membership *find_channel_membership(struct Channel *, struct Client *); extern struct membership *find_channel_membership(struct Channel *, struct Client *);
@ -260,7 +252,7 @@ extern void free_channel_list(rb_dlink_list *);
extern int check_channel_name(const char *name); extern int check_channel_name(const char *name);
extern void channel_member_names(struct Channel *chptr, struct Client *, extern void channel_member_names(struct Channel *chptr, struct Client *,
int show_eon); int show_eon);
extern void del_invite(struct Channel *chptr, struct Client *who); extern void del_invite(struct Channel *chptr, struct Client *who);
@ -277,25 +269,25 @@ extern void check_spambot_warning(struct Client *source_p, const char *name);
extern void check_splitmode(void *); extern void check_splitmode(void *);
void set_channel_topic(struct Channel *chptr, const char *topic, void set_channel_topic(struct Channel *chptr, const char *topic,
const char *topic_info, time_t topicts); const char *topic_info, time_t topicts);
extern void init_chcap_usage_counts(void); extern void init_chcap_usage_counts(void);
extern void set_chcap_usage_counts(struct Client *serv_p); extern void set_chcap_usage_counts(struct Client *serv_p);
extern void unset_chcap_usage_counts(struct Client *serv_p); extern void unset_chcap_usage_counts(struct Client *serv_p);
extern void send_cap_mode_changes(struct Client *client_p, struct Client *source_p, extern void send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
struct Channel *chptr, struct ChModeChange foo[], int); struct Channel *chptr, struct ChModeChange foo[], int);
void resv_chan_forcepart(const char *name, const char *reason, int temp_time); void resv_chan_forcepart(const char *name, const char *reason, int temp_time);
extern void set_channel_mode(struct Client *client_p, struct Client *source_p, extern void set_channel_mode(struct Client *client_p, struct Client *source_p,
struct Channel *chptr, struct membership *msptr, int parc, const char *parv[]); struct Channel *chptr, struct membership *msptr, int parc, const char *parv[]);
extern void set_channel_mlock(struct Client *client_p, struct Client *source_p, extern void set_channel_mlock(struct Client *client_p, struct Client *source_p,
struct Channel *chptr, const char *newmlock, int propagate); struct Channel *chptr, const char *newmlock, int propagate);
extern struct ChannelMode chmode_table[256]; extern struct ChannelMode chmode_table[256];
extern int add_id(struct Client *source_p, struct Channel *chptr, const char *banid, extern int add_id(struct Client *source_p, struct Channel *chptr, const char *banid,
rb_dlink_list * list, long mode_type); rb_dlink_list * list, long mode_type);
extern int del_id(struct Channel *chptr, const char *banid, rb_dlink_list * list, long mode_type); extern int del_id(struct Channel *chptr, const char *banid, rb_dlink_list * list, long mode_type);

View File

@ -37,50 +37,50 @@
extern int chmode_flags[256]; extern int chmode_flags[256];
extern void chm_nosuch(struct Client *source_p, struct Channel *chptr, extern void chm_nosuch(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_orphaned(struct Client *source_p, struct Channel *chptr, extern void chm_orphaned(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_simple(struct Client *source_p, struct Channel *chptr, extern void chm_simple(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_ban(struct Client *source_p, struct Channel *chptr, extern void chm_ban(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_hidden(struct Client *source_p, struct Channel *chptr, extern void chm_hidden(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_staff(struct Client *source_p, struct Channel *chptr, extern void chm_staff(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_forward(struct Client *source_p, struct Channel *chptr, extern void chm_forward(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_throttle(struct Client *source_p, struct Channel *chptr, extern void chm_throttle(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_key(struct Client *source_p, struct Channel *chptr, extern void chm_key(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_limit(struct Client *source_p, struct Channel *chptr, extern void chm_limit(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_owner(struct Client *source_p, struct Channel *chptr, extern void chm_owner(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_admin(struct Client *source_p, struct Channel *chptr, extern void chm_admin(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_op(struct Client *source_p, struct Channel *chptr, extern void chm_op(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_halfop(struct Client *source_p, struct Channel *chptr, extern void chm_halfop(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_voice(struct Client *source_p, struct Channel *chptr, extern void chm_voice(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn, int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type); const char **parv, int *errors, int dir, char c, long mode_type);
extern unsigned int cflag_add(char c, ChannelModeFunc function); extern unsigned int cflag_add(char c, ChannelModeFunc function);
extern void cflag_orphan(char c); extern void cflag_orphan(char c);

View File

@ -30,22 +30,21 @@ struct ConfItem;
struct Client; struct Client;
struct _patricia_tree_t; struct _patricia_tree_t;
struct Class struct Class {
{ struct Class *next;
struct Class *next; char *class_name;
char *class_name; int max_total;
int max_total; int max_local;
int max_local; int max_global;
int max_global; int max_ident;
int max_ident; int max_sendq;
int max_sendq; int con_freq;
int con_freq; int ping_freq;
int ping_freq; int total;
int total; rb_patricia_tree_t *ip_limits;
rb_patricia_tree_t *ip_limits; int cidr_ipv4_bitlen;
int cidr_ipv4_bitlen; int cidr_ipv6_bitlen;
int cidr_ipv6_bitlen; int cidr_amount;
int cidr_amount;
}; };

View File

@ -76,238 +76,231 @@ struct scache_entry;
/* /*
* Client structures * Client structures
*/ */
struct User struct User {
{ rb_dlink_list channel; /* chain of channel pointer blocks */
rb_dlink_list channel; /* chain of channel pointer blocks */ rb_dlink_list invited; /* chain of invite pointer blocks */
rb_dlink_list invited; /* chain of invite pointer blocks */ char *away; /* pointer to away message */
char *away; /* pointer to away message */ int refcnt; /* Number of times this block is referenced */
int refcnt; /* Number of times this block is referenced */
struct Dictionary *metadata; struct Dictionary *metadata;
char suser[NICKLEN+1]; char suser[NICKLEN+1];
}; };
struct Server struct Server {
{ struct User *user; /* who activated this connection */
struct User *user; /* who activated this connection */ char by[NICKLEN];
char by[NICKLEN]; rb_dlink_list servers;
rb_dlink_list servers; rb_dlink_list users;
rb_dlink_list users; int caps; /* capabilities bit-field */
int caps; /* capabilities bit-field */ char *fullcaps;
char *fullcaps; struct scache_entry *nameinfo;
struct scache_entry *nameinfo;
}; };
struct ZipStats struct ZipStats {
{ unsigned long long in;
unsigned long long in; unsigned long long in_wire;
unsigned long long in_wire; unsigned long long out;
unsigned long long out; unsigned long long out_wire;
unsigned long long out_wire; double in_ratio;
double in_ratio; double out_ratio;
double out_ratio;
}; };
struct Client struct Client {
{ rb_dlink_node node;
rb_dlink_node node; rb_dlink_node lnode;
rb_dlink_node lnode; struct User *user; /* ...defined, if this is a User */
struct User *user; /* ...defined, if this is a User */ struct Server *serv; /* ...defined, if this is a server */
struct Server *serv; /* ...defined, if this is a server */ struct Client *servptr; /* Points to server this Client is on */
struct Client *servptr; /* Points to server this Client is on */ struct Client *from; /* == self, if Local Client, *NEVER* NULL! */
struct Client *from; /* == self, if Local Client, *NEVER* NULL! */
struct Whowas *whowas; /* Pointers to whowas structs */ struct Whowas *whowas; /* Pointers to whowas structs */
time_t tsinfo; /* TS on the nick, SVINFO on server */ time_t tsinfo; /* TS on the nick, SVINFO on server */
unsigned int umodes; /* opers, normal users subset */ unsigned int umodes; /* opers, normal users subset */
unsigned int flags; /* client flags */ unsigned int flags; /* client flags */
unsigned int flags2; /* ugh. overflow */ unsigned int flags2; /* ugh. overflow */
unsigned int snomask; /* server notice mask */ unsigned int snomask; /* server notice mask */
int hopcount; /* number of servers to this 0 = local */ int hopcount; /* number of servers to this 0 = local */
unsigned short status; /* Client type */ unsigned short status; /* Client type */
unsigned char handler; /* Handler index */ unsigned char handler; /* Handler index */
unsigned long serial; /* used to enforce 1 send per nick */ unsigned long serial; /* used to enforce 1 send per nick */
/* client->name is the unique name for a client nick or host */ /* client->name is the unique name for a client nick or host */
char name[HOSTLEN + 1]; char name[HOSTLEN + 1];
/* /*
* client->username is the username from ident or the USER message, * client->username is the username from ident or the USER message,
* If the client is idented the USER message is ignored, otherwise * If the client is idented the USER message is ignored, otherwise
* the username part of the USER message is put here prefixed with a * the username part of the USER message is put here prefixed with a
* tilde depending on the I:line, Once a client has registered, this * tilde depending on the I:line, Once a client has registered, this
* field should be considered read-only. * field should be considered read-only.
*/ */
char username[USERLEN + 1]; /* client's username */ char username[USERLEN + 1]; /* client's username */
/* /*
* client->host contains the resolved name or ip address * client->host contains the resolved name or ip address
* as a string for the user, it may be fiddled with for oper spoofing etc. * as a string for the user, it may be fiddled with for oper spoofing etc.
*/ */
char host[HOSTLEN + 1]; /* client's hostname */ char host[HOSTLEN + 1]; /* client's hostname */
char orighost[HOSTLEN + 1]; /* original hostname (before dynamic spoofing) */ char orighost[HOSTLEN + 1]; /* original hostname (before dynamic spoofing) */
char sockhost[HOSTIPLEN + 1]; /* clients ip */ char sockhost[HOSTIPLEN + 1]; /* clients ip */
char info[REALLEN + 1]; /* Free form additional client info */ char info[REALLEN + 1]; /* Free form additional client info */
char id[IDLEN]; /* UID/SID, unique on the network */ char id[IDLEN]; /* UID/SID, unique on the network */
/* list of who has this client on their allow list, its counterpart /* list of who has this client on their allow list, its counterpart
* is in LocalUser * is in LocalUser
*/ */
rb_dlink_list on_allow_list; rb_dlink_list on_allow_list;
time_t first_received_message_time; time_t first_received_message_time;
int received_number_of_privmsgs; int received_number_of_privmsgs;
int flood_noticed; int flood_noticed;
struct LocalUser *localClient; struct LocalUser *localClient;
struct PreClient *preClient; struct PreClient *preClient;
time_t large_ctcp_sent; /* ctcp to large group sent, relax flood checks */ time_t large_ctcp_sent; /* ctcp to large group sent, relax flood checks */
char *certfp; /* client certificate fingerprint */ char *certfp; /* client certificate fingerprint */
}; };
struct LocalUser struct LocalUser {
{ rb_dlink_node tnode; /* This is the node for the local list type the client is on*/
rb_dlink_node tnode; /* This is the node for the local list type the client is on*/ /*
/* * The following fields are allocated only for local clients
* The following fields are allocated only for local clients * (directly connected to *this* server with a socket.
* (directly connected to *this* server with a socket. */
*/ /* Anti flooding part, all because of lamers... */
/* Anti flooding part, all because of lamers... */ time_t last_join_time; /* when this client last
time_t last_join_time; /* when this client last
joined a channel */ joined a channel */
time_t last_leave_time; /* when this client last time_t last_leave_time; /* when this client last
* left a channel */ * left a channel */
int join_leave_count; /* count of JOIN/LEAVE in less than int join_leave_count; /* count of JOIN/LEAVE in less than
MIN_JOIN_LEAVE_TIME seconds */ MIN_JOIN_LEAVE_TIME seconds */
int oper_warn_count_down; /* warn opers of this possible int oper_warn_count_down; /* warn opers of this possible
spambot every time this gets to 0 */ spambot every time this gets to 0 */
time_t last_caller_id_time; time_t last_caller_id_time;
time_t lasttime; /* last time we parsed something */ time_t lasttime; /* last time we parsed something */
time_t firsttime; /* time client was created */ time_t firsttime; /* time client was created */
/* Send and receive linebuf queues .. */ /* Send and receive linebuf queues .. */
buf_head_t buf_sendq; buf_head_t buf_sendq;
buf_head_t buf_recvq; buf_head_t buf_recvq;
/* /*
* we want to use unsigned int here so the sizes have a better chance of * we want to use unsigned int here so the sizes have a better chance of
* staying the same on 64 bit machines. The current trend is to use * staying the same on 64 bit machines. The current trend is to use
* I32LP64, (32 bit ints, 64 bit longs and pointers) and since ircd * I32LP64, (32 bit ints, 64 bit longs and pointers) and since ircd
* will NEVER run on an operating system where ints are less than 32 bits, * will NEVER run on an operating system where ints are less than 32 bits,
* it's a relatively safe bet to use ints. Since right shift operations are * it's a relatively safe bet to use ints. Since right shift operations are
* performed on these, it's not safe to allow them to become negative, * performed on these, it's not safe to allow them to become negative,
* which is possible for long running server connections. Unsigned values * which is possible for long running server connections. Unsigned values
* generally overflow gracefully. --Bleep * generally overflow gracefully. --Bleep
*/ */
unsigned int sendM; /* Statistics: protocol messages send */ unsigned int sendM; /* Statistics: protocol messages send */
unsigned int sendK; /* Statistics: total k-bytes send */ unsigned int sendK; /* Statistics: total k-bytes send */
unsigned int receiveM; /* Statistics: protocol messages received */ unsigned int receiveM; /* Statistics: protocol messages received */
unsigned int receiveK; /* Statistics: total k-bytes received */ unsigned int receiveK; /* Statistics: total k-bytes received */
unsigned short sendB; /* counters to count upto 1-k lots of bytes */ unsigned short sendB; /* counters to count upto 1-k lots of bytes */
unsigned short receiveB; /* sent and received. */ unsigned short receiveB; /* sent and received. */
struct Listener *listener; /* listener accepted from */ struct Listener *listener; /* listener accepted from */
struct ConfItem *att_conf; /* attached conf */ struct ConfItem *att_conf; /* attached conf */
struct server_conf *att_sconf; struct server_conf *att_sconf;
struct rb_sockaddr_storage ip; struct rb_sockaddr_storage ip;
time_t last_nick_change; time_t last_nick_change;
int number_of_nick_changes; int number_of_nick_changes;
/* /*
* XXX - there is no reason to save this, it should be checked when it's * XXX - there is no reason to save this, it should be checked when it's
* received and not stored, this is not used after registration * received and not stored, this is not used after registration
* *
* agreed. lets get rid of it someday! --nenolod * agreed. lets get rid of it someday! --nenolod
*/ */
char *passwd; char *passwd;
char *auth_user; char *auth_user;
char *opername; /* name of operator{} block being used or tried (challenge) */ char *opername; /* name of operator{} block being used or tried (challenge) */
char *challenge; char *challenge;
char *fullcaps; char *fullcaps;
int caps; /* capabilities bit-field */ int caps; /* capabilities bit-field */
rb_fde_t *F; /* >= 0, for local clients */ rb_fde_t *F; /* >= 0, for local clients */
/* time challenge response is valid for */ /* time challenge response is valid for */
time_t chal_time; time_t chal_time;
struct DNSQuery *dnsquery; /* for outgoing server's name lookup */ struct DNSQuery *dnsquery; /* for outgoing server's name lookup */
time_t next_away; /* Don't allow next away before... */ time_t next_away; /* Don't allow next away before... */
time_t last; time_t last;
/* clients allowed to talk through +g */ /* clients allowed to talk through +g */
rb_dlink_list allow_list; rb_dlink_list allow_list;
/* nicknames theyre monitoring */ /* nicknames theyre monitoring */
rb_dlink_list monitor_list; rb_dlink_list monitor_list;
/* /*
* Anti-flood stuff. We track how many messages were parsed and how * Anti-flood stuff. We track how many messages were parsed and how
* many we were allowed in the current second, and apply a simple decay * many we were allowed in the current second, and apply a simple decay
* to avoid flooding. * to avoid flooding.
* -- adrian * -- adrian
*/ */
int allow_read; /* how many we're allowed to read in this second */ int allow_read; /* how many we're allowed to read in this second */
int actually_read; /* how many we've actually read in this second */ int actually_read; /* how many we've actually read in this second */
int sent_parsed; /* how many messages we've parsed in this second */ int sent_parsed; /* how many messages we've parsed in this second */
time_t last_knock; /* time of last knock */ time_t last_knock; /* time of last knock */
unsigned long random_ping; unsigned long random_ping;
struct AuthRequest *auth_request; struct AuthRequest *auth_request;
/* target change stuff */ /* target change stuff */
/* targets we're aware of (fnv32(use_id(target_p))): /* targets we're aware of (fnv32(use_id(target_p))):
* 0..TGCHANGE_NUM-1 regular slots * 0..TGCHANGE_NUM-1 regular slots
* TGCHANGE_NUM..TGCHANGE_NUM+TGCHANGE_REPLY-1 reply slots * TGCHANGE_NUM..TGCHANGE_NUM+TGCHANGE_REPLY-1 reply slots
*/ */
uint32_t targets[TGCHANGE_NUM + TGCHANGE_REPLY]; uint32_t targets[TGCHANGE_NUM + TGCHANGE_REPLY];
unsigned int targets_free; /* free targets */ unsigned int targets_free; /* free targets */
time_t target_last; /* last time we cleared a slot */ time_t target_last; /* last time we cleared a slot */
struct ListClient *safelist_data; struct ListClient *safelist_data;
char *mangledhost; /* non-NULL if host mangling module loaded and char *mangledhost; /* non-NULL if host mangling module loaded and
applicable to this client */ applicable to this client */
struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */ struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */
struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */ struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */
uint32_t localflags; uint32_t localflags;
struct ZipStats *zipstats; /* zipstats */ struct ZipStats *zipstats; /* zipstats */
uint16_t cork_count; /* used for corking/uncorking connections */ uint16_t cork_count; /* used for corking/uncorking connections */
struct ev_entry *event; /* used for associated events */ struct ev_entry *event; /* used for associated events */
struct PrivilegeSet *privset; /* privset... */ struct PrivilegeSet *privset; /* privset... */
struct ev_entry *override_timeout_event; struct ev_entry *override_timeout_event;
}; };
struct PreClient struct PreClient {
{ char spoofnick[NICKLEN + 1];
char spoofnick[NICKLEN + 1]; char spoofuser[USERLEN + 1];
char spoofuser[USERLEN + 1]; char spoofhost[HOSTLEN + 1];
char spoofhost[HOSTLEN + 1];
char sasl_agent[IDLEN]; char sasl_agent[IDLEN];
unsigned char sasl_out; unsigned char sasl_out;
unsigned char sasl_complete; unsigned char sasl_complete;
rb_dlink_list dnsbl_queries; /* list of struct BlacklistClient * */ rb_dlink_list dnsbl_queries; /* list of struct BlacklistClient * */
struct Blacklist *dnsbl_listed; /* first dnsbl where it's listed */ struct Blacklist *dnsbl_listed; /* first dnsbl where it's listed */
struct rb_sockaddr_storage lip; /* address of our side of the connection */ struct rb_sockaddr_storage lip; /* address of our side of the connection */
}; };
struct ListClient struct ListClient {
{ unsigned int hash_indice;
unsigned int hash_indice; unsigned int users_min, users_max;
unsigned int users_min, users_max; time_t created_min, created_max, topic_min, topic_max;
time_t created_min, created_max, topic_min, topic_max; int operspy;
int operspy;
}; };
/* /*

View File

@ -28,7 +28,7 @@
#include "setup.h" #include "setup.h"
/* /*
* Directory paths and filenames for UNIX systems. * Directory paths and filenames for UNIX systems.
* IRCD_PREFIX is set using ./configure --prefix, see INSTALL. * IRCD_PREFIX is set using ./configure --prefix, see INSTALL.
* The other defaults should be fine. * The other defaults should be fine.
@ -52,7 +52,7 @@
#define LIBPATH IRCD_PREFIX "/lib/" #define LIBPATH IRCD_PREFIX "/lib/"
#define MODPATH MODULE_DIR #define MODPATH MODULE_DIR
#define AUTOMODPATH MODULE_DIR "/autoload/" #define AUTOMODPATH MODULE_DIR "/autoload/"
#define ETCPATH ETC_DIR #define ETCPATH ETC_DIR
#define LOGPATH LOG_DIR #define LOGPATH LOG_DIR
#define UHPATH HELP_DIR "/users" #define UHPATH HELP_DIR "/users"
#define HPATH HELP_DIR "/opers" #define HPATH HELP_DIR "/opers"
@ -94,7 +94,7 @@
#define KILLCHASETIMELIMIT 90 /* Recommended value: 90 */ #define KILLCHASETIMELIMIT 90 /* Recommended value: 90 */
/* RATBOX_SOMAXCONN /* RATBOX_SOMAXCONN
* Use SOMAXCONN if OS has it, otherwise use this value for the * Use SOMAXCONN if OS has it, otherwise use this value for the
* listen(); backlog. 5 for AIX/SUNOS, 25 for other OSs. * listen(); backlog. 5 for AIX/SUNOS, 25 for other OSs.
*/ */
#define RATBOX_SOMAXCONN 25 #define RATBOX_SOMAXCONN 25

View File

@ -6,10 +6,9 @@
#ifndef INCLUDED_HOOK_H #ifndef INCLUDED_HOOK_H
#define INCLUDED_HOOK_H #define INCLUDED_HOOK_H
typedef struct typedef struct {
{ char *name;
char *name; rb_dlink_list hooks;
rb_dlink_list hooks;
} hook; } hook;
typedef void (*hookfn) (void *data); typedef void (*hookfn) (void *data);
@ -36,67 +35,58 @@ void add_hook(const char *name, hookfn fn);
void remove_hook(const char *name, hookfn fn); void remove_hook(const char *name, hookfn fn);
void call_hook(int id, void *arg); void call_hook(int id, void *arg);
typedef struct typedef struct {
{ struct Client *client;
struct Client *client; const void *arg1;
const void *arg1; const void *arg2;
const void *arg2;
} hook_data; } hook_data;
typedef struct typedef struct {
{ struct Client *client;
struct Client *client; const void *arg1;
const void *arg1; int arg2;
int arg2;
} hook_data_int; } hook_data_int;
typedef struct typedef struct {
{ struct Client *client;
struct Client *client; struct Client *target;
struct Client *target;
} hook_data_client; } hook_data_client;
typedef struct typedef struct {
{ struct Client *client;
struct Client *client; struct Channel *chptr;
struct Channel *chptr; int approved;
int approved;
} hook_data_channel; } hook_data_channel;
typedef struct typedef struct {
{ struct Client *client;
struct Client *client; struct Channel *chptr;
struct Channel *chptr; char *key;
char *key;
} hook_data_channel_activity; } hook_data_channel_activity;
typedef struct typedef struct {
{ struct Client *client;
struct Client *client; struct Channel *chptr;
struct Channel *chptr; struct Client *target;
struct Client *target; int approved;
int approved;
} hook_data_channel_approval; } hook_data_channel_approval;
typedef struct typedef struct {
{ struct Client *client;
struct Client *client; int approved;
int approved;
} hook_data_client_approval; } hook_data_client_approval;
typedef struct typedef struct {
{ struct Client *local_link; /* local client originating this, or NULL */
struct Client *local_link; /* local client originating this, or NULL */ struct Client *target; /* dying client */
struct Client *target; /* dying client */ struct Client *from; /* causing client (could be &me or target) */
struct Client *from; /* causing client (could be &me or target) */ const char *comment;
const char *comment;
} hook_data_client_exit; } hook_data_client_exit;
typedef struct typedef struct {
{ struct Client *client;
struct Client *client; unsigned int oldumodes;
unsigned int oldumodes; unsigned int oldsnomask;
unsigned int oldsnomask;
} hook_data_umode_changed; } hook_data_umode_changed;
#endif #endif

View File

@ -26,29 +26,28 @@
#ifndef INCLUDE_hostmask_h #ifndef INCLUDE_hostmask_h
#define INCLUDE_hostmask_h 1 #define INCLUDE_hostmask_h 1
enum enum {
{ HM_HOST,
HM_HOST, HM_IPV4
HM_IPV4
#ifdef RB_IPV6 #ifdef RB_IPV6
, HM_IPV6 , HM_IPV6
#endif #endif
}; };
int parse_netmask(const char *, struct sockaddr *, int *); int parse_netmask(const char *, struct sockaddr *, int *);
struct ConfItem *find_conf_by_address(const char *host, const char *sockhost, struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
const char *orighost, struct sockaddr *, const char *orighost, struct sockaddr *,
int, int, const char *, const char *); int, int, const char *, const char *);
struct ConfItem *find_exact_conf_by_address(const char *address, int type, struct ConfItem *find_exact_conf_by_address(const char *address, int type,
const char *username); const char *username);
void add_conf_by_address(const char *, int, const char *, const char *, struct ConfItem *); void add_conf_by_address(const char *, int, const char *, const char *, struct ConfItem *);
void delete_one_address_conf(const char *, struct ConfItem *); void delete_one_address_conf(const char *, struct ConfItem *);
void clear_out_address_conf(void); void clear_out_address_conf(void);
void clear_out_address_conf_bans(void); void clear_out_address_conf_bans(void);
void init_host_hash(void); void init_host_hash(void);
struct ConfItem *find_address_conf(const char *host, const char *sockhost, struct ConfItem *find_address_conf(const char *host, const char *sockhost,
const char *, const char *, struct sockaddr *, const char *, const char *, struct sockaddr *,
int, char *); int, char *);
struct ConfItem *find_dline(struct sockaddr *, int); struct ConfItem *find_dline(struct sockaddr *, int);
@ -70,40 +69,37 @@ int match_ipv4(struct sockaddr *, struct sockaddr *, int);
extern struct AddressRec *atable[ATABLE_SIZE]; extern struct AddressRec *atable[ATABLE_SIZE];
struct AddressRec struct AddressRec {
{ /* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */
/* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */ int masktype;
int masktype;
union union {
{ struct {
struct /* Pointer into ConfItem... -A1kmm */
{ struct rb_sockaddr_storage addr;
/* Pointer into ConfItem... -A1kmm */ int bits;
struct rb_sockaddr_storage addr; }
int bits; ipa;
}
ipa;
/* Pointer into ConfItem... -A1kmm */ /* Pointer into ConfItem... -A1kmm */
const char *hostname; const char *hostname;
} }
Mask; Mask;
/* type: CONF_CLIENT, CONF_DLINE, CONF_KILL etc... -A1kmm */ /* type: CONF_CLIENT, CONF_DLINE, CONF_KILL etc... -A1kmm */
int type; int type;
/* Higher precedences overrule lower ones... */ /* Higher precedences overrule lower ones... */
unsigned long precedence; unsigned long precedence;
/* Only checked if !(type & 1)... */ /* Only checked if !(type & 1)... */
const char *username; const char *username;
/* Only checked if type == CONF_CLIENT */ /* Only checked if type == CONF_CLIENT */
const char *auth_user; const char *auth_user;
struct ConfItem *aconf; struct ConfItem *aconf;
/* The next record in this hash bucket. */ /* The next record in this hash bucket. */
struct AddressRec *next; struct AddressRec *next;
}; };

View File

@ -30,96 +30,90 @@
static inline char * static inline char *
strip_colour(char *string) strip_colour(char *string)
{ {
char *c = string; char *c = string;
char *c2 = string; char *c2 = string;
char *last_non_space = NULL; char *last_non_space = NULL;
/* c is source, c2 is target */ /* c is source, c2 is target */
for(; c && *c; c++) for(; c && *c; c++)
switch (*c) switch (*c) {
{ case 3:
case 3: if(isdigit(c[1])) {
if(isdigit(c[1])) c++;
{ if(isdigit(c[1]))
c++; c++;
if(isdigit(c[1])) if(c[1] == ',' && isdigit(c[2])) {
c++; c += 2;
if(c[1] == ',' && isdigit(c[2])) if(isdigit(c[1]))
{ c++;
c += 2; }
if(isdigit(c[1])) }
c++; break;
} case 2:
} case 6:
break; case 7:
case 2: case 22:
case 6: case 23:
case 7: case 27:
case 22: case 29:
case 23: case 31:
case 27: break;
case 29: case 32:
case 31: *c2++ = *c;
break; break;
case 32: default:
*c2++ = *c; *c2++ = *c;
break; last_non_space = c2;
default: break;
*c2++ = *c; }
last_non_space = c2;
break;
}
*c2 = '\0'; *c2 = '\0';
if(last_non_space) if(last_non_space)
*last_non_space = '\0'; *last_non_space = '\0';
return string; return string;
} }
static inline char * static inline char *
strip_unprintable(char *string) strip_unprintable(char *string)
{ {
char *c = string; char *c = string;
char *c2 = string; char *c2 = string;
char *last_non_space = NULL; char *last_non_space = NULL;
/* c is source, c2 is target */ /* c is source, c2 is target */
for(; c && *c; c++) for(; c && *c; c++)
switch (*c) switch (*c) {
{ case 3:
case 3: if(isdigit(c[1])) {
if(isdigit(c[1])) c++;
{ if(isdigit(c[1]))
c++; c++;
if(isdigit(c[1])) if(c[1] == ',' && isdigit(c[2])) {
c++; c += 2;
if(c[1] == ',' && isdigit(c[2])) if(isdigit(c[1]))
{ c++;
c += 2; }
if(isdigit(c[1])) }
c++; break;
} case 32:
} *c2++ = *c;
break; break;
case 32: default:
*c2++ = *c; if (*c < 32 && *c >= 0)
break; break;
default: *c2++ = *c;
if (*c < 32 && *c >= 0) last_non_space = c2;
break; break;
*c2++ = *c; }
last_non_space = c2;
break;
}
*c2 = '\0'; *c2 = '\0';
if(last_non_space) if(last_non_space)
*last_non_space = '\0'; *last_non_space = '\0';
return string; return string;
} }
#endif #endif

View File

@ -29,17 +29,15 @@ struct Dictionary; /* defined in src/dictionary.c */
typedef int (*DCF)(const char *a, const char *b); typedef int (*DCF)(const char *a, const char *b);
struct DictionaryElement struct DictionaryElement {
{ struct DictionaryElement *left, *right, *prev, *next;
struct DictionaryElement *left, *right, *prev, *next; void *data;
void *data; const char *key;
const char *key; int position;
int position;
}; };
struct DictionaryIter struct DictionaryIter {
{ struct DictionaryElement *cur, *next;
struct DictionaryElement *cur, *next;
}; };
/* /*
@ -65,7 +63,7 @@ extern struct Dictionary *irc_dictionary_create_named(const char *name, DCF comp
* insertions in the DTree structure. * insertions in the DTree structure.
*/ */
extern void irc_dictionary_set_comparator_func(struct Dictionary *dict, extern void irc_dictionary_set_comparator_func(struct Dictionary *dict,
DCF compare_cb); DCF compare_cb);
/* /*
* irc_dictionary_get_comparator_func() returns the comparator used for lookups and * irc_dictionary_get_comparator_func() returns the comparator used for lookups and
@ -84,8 +82,8 @@ extern int irc_dictionary_get_linear_index(struct Dictionary *dict, const char *
* a defined callback function to destroy any data attached to it. * a defined callback function to destroy any data attached to it.
*/ */
extern void irc_dictionary_destroy(struct Dictionary *dtree, extern void irc_dictionary_destroy(struct Dictionary *dtree,
void (*destroy_cb)(struct DictionaryElement *delem, void *privdata), void (*destroy_cb)(struct DictionaryElement *delem, void *privdata),
void *privdata); void *privdata);
/* /*
* irc_dictionary_foreach() iterates all entries in a dtree, and also optionally calls * irc_dictionary_foreach() iterates all entries in a dtree, and also optionally calls
@ -94,8 +92,8 @@ extern void irc_dictionary_destroy(struct Dictionary *dtree,
* To shortcircuit iteration, return non-zero from the callback function. * To shortcircuit iteration, return non-zero from the callback function.
*/ */
extern void irc_dictionary_foreach(struct Dictionary *dtree, extern void irc_dictionary_foreach(struct Dictionary *dtree,
int (*foreach_cb)(struct DictionaryElement *delem, void *privdata), int (*foreach_cb)(struct DictionaryElement *delem, void *privdata),
void *privdata); void *privdata);
/* /*
* irc_dictionary_search() iterates all entries in a dtree, and also optionally calls * irc_dictionary_search() iterates all entries in a dtree, and also optionally calls
@ -105,8 +103,8 @@ extern void irc_dictionary_foreach(struct Dictionary *dtree,
* in that object being returned to the user. * in that object being returned to the user.
*/ */
extern void *irc_dictionary_search(struct Dictionary *dtree, extern void *irc_dictionary_search(struct Dictionary *dtree,
void *(*foreach_cb)(struct DictionaryElement *delem, void *privdata), void *(*foreach_cb)(struct DictionaryElement *delem, void *privdata),
void *privdata); void *privdata);
/* /*
* irc_dictionary_foreach_start() begins an iteration over all items * irc_dictionary_foreach_start() begins an iteration over all items
@ -115,20 +113,20 @@ extern void *irc_dictionary_search(struct Dictionary *dtree,
* of the iteration (but not any other element). * of the iteration (but not any other element).
*/ */
extern void irc_dictionary_foreach_start(struct Dictionary *dtree, extern void irc_dictionary_foreach_start(struct Dictionary *dtree,
struct DictionaryIter *state); struct DictionaryIter *state);
/* /*
* irc_dictionary_foreach_cur() returns the current element of the iteration, * irc_dictionary_foreach_cur() returns the current element of the iteration,
* or NULL if there are no more elements. * or NULL if there are no more elements.
*/ */
extern void *irc_dictionary_foreach_cur(struct Dictionary *dtree, extern void *irc_dictionary_foreach_cur(struct Dictionary *dtree,
struct DictionaryIter *state); struct DictionaryIter *state);
/* /*
* irc_dictionary_foreach_next() moves to the next element. * irc_dictionary_foreach_next() moves to the next element.
*/ */
extern void irc_dictionary_foreach_next(struct Dictionary *dtree, extern void irc_dictionary_foreach_next(struct Dictionary *dtree,
struct DictionaryIter *state); struct DictionaryIter *state);
/* /*
* irc_dictionary_add() adds a key->value entry to the dictionary tree. * irc_dictionary_add() adds a key->value entry to the dictionary tree.

View File

@ -31,37 +31,34 @@
struct Client; struct Client;
struct rb_dlink_list; struct rb_dlink_list;
struct SetOptions struct SetOptions {
{ int maxclients; /* max clients allowed */
int maxclients; /* max clients allowed */ int autoconn; /* autoconn enabled for all servers? */
int autoconn; /* autoconn enabled for all servers? */
int floodcount; /* Number of messages in 1 second */ int floodcount; /* Number of messages in 1 second */
int ident_timeout; /* timeout for identd lookups */ int ident_timeout; /* timeout for identd lookups */
int spam_num; int spam_num;
int spam_time; int spam_time;
char operhost[REALLEN]; char operhost[REALLEN];
char operstring[REALLEN]; char operstring[REALLEN];
char adminstring[REALLEN]; char adminstring[REALLEN];
}; };
struct Metadata struct Metadata {
{ const char *name;
const char *name; const char *value;
const char *value; time_t timevalue;
time_t timevalue;
}; };
struct Counter struct Counter {
{ int oper; /* Opers */
int oper; /* Opers */ int total; /* total clients */
int total; /* total clients */ int invisi; /* invisible clients */
int invisi; /* invisible clients */ int max_loc; /* MAX local clients */
int max_loc; /* MAX local clients */ int max_tot; /* MAX global clients */
int max_tot; /* MAX global clients */ unsigned long totalrestartcount; /* Total client count ever */
unsigned long totalrestartcount; /* Total client count ever */
}; };
extern struct SetOptions GlobalSetOptions; /* defined in ircd.c */ extern struct SetOptions GlobalSetOptions; /* defined in ircd.c */

View File

@ -26,7 +26,7 @@
/* /*
* NOTE: NICKLEN and TOPICLEN do not live here anymore. Set it with configure * NOTE: NICKLEN and TOPICLEN do not live here anymore. Set it with configure
* Otherwise there are no user servicable part here. * Otherwise there are no user servicable part here.
* *
*/ */
@ -94,7 +94,7 @@
#endif #endif
#define HOSTLEN 63 /* Length of hostname. Updated to */ #define HOSTLEN 63 /* Length of hostname. Updated to */
/* comply with RFC1123 */ /* comply with RFC1123 */
#define USERLEN 10 #define USERLEN 10
#define REALLEN 50 #define REALLEN 50
@ -121,8 +121,8 @@
#define HELPLEN 400 #define HELPLEN 400
/* /*
* message return values * message return values
*/ */
#define CLIENT_EXITED -2 #define CLIENT_EXITED -2
#define CLIENT_PARSE_ERROR -1 #define CLIENT_PARSE_ERROR -1

View File

@ -26,14 +26,13 @@
#ifndef __GETOPT_H_INCLUDED__ #ifndef __GETOPT_H_INCLUDED__
#define __GETOPT_H_INCLUDED__ #define __GETOPT_H_INCLUDED__
struct lgetopt struct lgetopt {
{ const char *opt; /* name of the argument */
const char *opt; /* name of the argument */ void *argloc; /* where we store the argument to it (-option argument) */
void *argloc; /* where we store the argument to it (-option argument) */ enum
enum { INTEGER, YESNO, STRING, USAGE, ENDEBUG }
{ INTEGER, YESNO, STRING, USAGE, ENDEBUG } argtype;
argtype; const char *desc; /* description of the argument, usage for printing help */
const char *desc; /* description of the argument, usage for printing help */
}; };
extern struct lgetopt myopts[]; extern struct lgetopt myopts[];

View File

@ -37,10 +37,9 @@
#include <dlfcn.h> #include <dlfcn.h>
struct ircd_symbol struct ircd_symbol {
{ char *sym; /* name of symbol to be bound to ptr */
char *sym; /* name of symbol to be bound to ptr */ void *ptr; /* ptr to symbol in library */
void *ptr; /* ptr to symbol in library */
}; };
extern void build_symtable(void *, struct ircd_symbol *); extern void build_symtable(void *, struct ircd_symbol *);

View File

@ -30,18 +30,17 @@
struct Client; struct Client;
struct Listener struct Listener {
{ struct Listener *next; /* list node pointer */
struct Listener *next; /* list node pointer */ const char *name; /* listener name */
const char *name; /* listener name */ rb_fde_t *F; /* file descriptor */
rb_fde_t *F; /* file descriptor */ int ref_count; /* number of connection references */
int ref_count; /* number of connection references */ int active; /* current state of listener */
int active; /* current state of listener */ int ssl; /* ssl listener */
int ssl; /* ssl listener */ int defer_accept; /* use TCP_DEFER_ACCEPT */
int defer_accept; /* use TCP_DEFER_ACCEPT */ struct rb_sockaddr_storage addr;
struct rb_sockaddr_storage addr; struct DNSQuery *dns_query;
struct DNSQuery *dns_query; char vhost[HOSTLEN + 1]; /* virtual name of listener */
char vhost[HOSTLEN + 1]; /* virtual name of listener */
}; };
extern void add_listener(int port, const char *vaddr_ip, int family, int ssl, int defer_accept); extern void add_listener(int port, const char *vaddr_ip, int family, int ssl, int defer_accept);

View File

@ -35,19 +35,18 @@
#include "ircd_defs.h" #include "ircd_defs.h"
typedef enum ilogfile typedef enum ilogfile {
{ L_MAIN,
L_MAIN, L_USER,
L_USER, L_FUSER,
L_FUSER, L_OPERED,
L_OPERED, L_FOPER,
L_FOPER, L_SERVER,
L_SERVER, L_KILL,
L_KILL, L_KLINE,
L_KLINE, L_OPERSPY,
L_OPERSPY, L_IOERROR,
L_IOERROR, LAST_LOGFILE
LAST_LOGFILE
} ilogfile; } ilogfile;
struct Client; struct Client;

View File

@ -28,136 +28,155 @@
#include "config.h" #include "config.h"
typedef struct Information typedef struct Information {
{ const char *name; /* name of item */
const char *name; /* name of item */ const char *strvalue; /* value of item if it's a boolean */
const char *strvalue; /* value of item if it's a boolean */ int intvalue; /* value of item if it's an integer */
int intvalue; /* value of item if it's an integer */ const char *desc; /* short description of item */
const char *desc; /* short description of item */
} }
Info; Info;
Info MyInformation[] = { Info MyInformation[] = {
#ifdef CPATH #ifdef CPATH
{"CPATH", CPATH, 0, "Path to Main Configuration File"}, {"CPATH", CPATH, 0, "Path to Main Configuration File"},
#else #else
{"CPATH", "NONE", 0, "Path to Main Configuration File"}, {"CPATH", "NONE", 0, "Path to Main Configuration File"},
#endif /* CPATH */ #endif /* CPATH */
#ifdef DPATH #ifdef DPATH
{"DPATH", DPATH, 0, "Directory Containing Configuration Files"}, {"DPATH", DPATH, 0, "Directory Containing Configuration Files"},
#else #else
{"DPATH", "NONE", 0, "Directory Containing Configuration Files"}, {"DPATH", "NONE", 0, "Directory Containing Configuration Files"},
#endif /* DPATH */ #endif /* DPATH */
#ifdef HPATH #ifdef HPATH
{"HPATH", HPATH, 0, "Path to Operator Help Files"}, {"HPATH", HPATH, 0, "Path to Operator Help Files"},
#else #else
{"HPATH", "NONE", 0, "Path to Operator Help Files"}, {"HPATH", "NONE", 0, "Path to Operator Help Files"},
#endif /* HPATH */ #endif /* HPATH */
#ifdef UHPATH #ifdef UHPATH
{"UHPATH", UHPATH, 0, "Path to User Help Files"}, {"UHPATH", UHPATH, 0, "Path to User Help Files"},
#else #else
{"UHPATH", "NONE", 0, "Path to User Help Files"}, {"UHPATH", "NONE", 0, "Path to User Help Files"},
#endif /* UH PATH */ #endif /* UH PATH */
#ifdef SOMAXCONN #ifdef SOMAXCONN
{"RATBOX_SOMAXCONN", "", SOMAXCONN, {
"Maximum Queue Length of Pending Connections"}, "RATBOX_SOMAXCONN", "", SOMAXCONN,
"Maximum Queue Length of Pending Connections"
},
#else #else
{"RATBOX_SOMAXCONN", "", RATBOX_SOMAXCONN, {
"Maximum Queue Length of Pending Connections"}, "RATBOX_SOMAXCONN", "", RATBOX_SOMAXCONN,
"Maximum Queue Length of Pending Connections"
},
#endif /* SOMAXCONN */ #endif /* SOMAXCONN */
#ifdef RB_IPV6 #ifdef RB_IPV6
{"IPV6", "ON", 0, "IPv6 Support"}, {"IPV6", "ON", 0, "IPv6 Support"},
#else #else
{"IPV6", "OFF", 0, "IPv6 Support"}, {"IPV6", "OFF", 0, "IPv6 Support"},
#endif #endif
{"JOIN_LEAVE_COUNT_EXPIRE_TIME", "", JOIN_LEAVE_COUNT_EXPIRE_TIME, {
"Anti SpamBot Parameter"}, "JOIN_LEAVE_COUNT_EXPIRE_TIME", "", JOIN_LEAVE_COUNT_EXPIRE_TIME,
"Anti SpamBot Parameter"
},
{"KILLCHASETIMELIMIT", "", KILLCHASETIMELIMIT, {
"Nick Change Tracker for KILL"}, "KILLCHASETIMELIMIT", "", KILLCHASETIMELIMIT,
"Nick Change Tracker for KILL"
},
#ifdef LPATH #ifdef LPATH
{"LPATH", LPATH, 0, "Path to Log File"}, {"LPATH", LPATH, 0, "Path to Log File"},
#else #else
{"LPATH", "NONE", 0, "Path to Log File"}, {"LPATH", "NONE", 0, "Path to Log File"},
#endif /* LPATH */ #endif /* LPATH */
{"MAX_BUFFER", "", MAX_BUFFER, "Maximum Buffer Connections Allowed"}, {"MAX_BUFFER", "", MAX_BUFFER, "Maximum Buffer Connections Allowed"},
{"MAX_JOIN_LEAVE_COUNT", "", MAX_JOIN_LEAVE_COUNT, {
"Anti SpamBot Parameter"}, "MAX_JOIN_LEAVE_COUNT", "", MAX_JOIN_LEAVE_COUNT,
"Anti SpamBot Parameter"
},
{"MIN_JOIN_LEAVE_TIME", "", MIN_JOIN_LEAVE_TIME, {
"Anti SpamBot Parameter"}, "MIN_JOIN_LEAVE_TIME", "", MIN_JOIN_LEAVE_TIME,
"Anti SpamBot Parameter"
},
#ifdef MPATH #ifdef MPATH
{"MPATH", MPATH, 0, "Path to MOTD File"}, {"MPATH", MPATH, 0, "Path to MOTD File"},
#else #else
{"MPATH", "NONE", 0, "Path to MOTD File"}, {"MPATH", "NONE", 0, "Path to MOTD File"},
#endif /* MPATH */ #endif /* MPATH */
{"NICKNAMEHISTORYLENGTH", "", NICKNAMEHISTORYLENGTH, {
"Size of WHOWAS Array"}, "NICKNAMEHISTORYLENGTH", "", NICKNAMEHISTORYLENGTH,
"Size of WHOWAS Array"
},
#ifdef OPATH #ifdef OPATH
{"OPATH", OPATH, 0, "Path to Operator MOTD File"}, {"OPATH", OPATH, 0, "Path to Operator MOTD File"},
#else #else
{"OPATH", "NONE", 0, "Path to Operator MOTD File"}, {"OPATH", "NONE", 0, "Path to Operator MOTD File"},
#endif /* OPATH */ #endif /* OPATH */
{"OPER_SPAM_COUNTDOWN", "", OPER_SPAM_COUNTDOWN, {
"Anti SpamBot Parameter"}, "OPER_SPAM_COUNTDOWN", "", OPER_SPAM_COUNTDOWN,
"Anti SpamBot Parameter"
},
#ifdef HAVE_LIBCRYPTO #ifdef HAVE_LIBCRYPTO
{"HAVE_LIBCRYPTO", "ON", 0, "Enable OpenSSL CHALLENGE Support"}, {"HAVE_LIBCRYPTO", "ON", 0, "Enable OpenSSL CHALLENGE Support"},
#else #else
{"HAVE_LIBCRYPTO", "OFF", 0, "Enable OpenSSL CHALLENGE Support"}, {"HAVE_LIBCRYPTO", "OFF", 0, "Enable OpenSSL CHALLENGE Support"},
#endif /* HAVE_LIBCRYPTO */ #endif /* HAVE_LIBCRYPTO */
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
{"HAVE_LIBZ", "YES", 0, "zlib (ziplinks) support"}, {"HAVE_LIBZ", "YES", 0, "zlib (ziplinks) support"},
#else #else
{"HAVE_LIBZ", "NO", 0, "zlib (ziplinks) support"}, {"HAVE_LIBZ", "NO", 0, "zlib (ziplinks) support"},
#endif /* HAVE_LIBZ */ #endif /* HAVE_LIBZ */
#ifdef PPATH #ifdef PPATH
{"PPATH", PPATH, 0, "Path to Pid File"}, {"PPATH", PPATH, 0, "Path to Pid File"},
#else #else
{"PPATH", "NONE", 0, "Path to Pid File"}, {"PPATH", "NONE", 0, "Path to Pid File"},
#endif /* PPATH */ #endif /* PPATH */
{"SELECT_TYPE", SELECT_TYPE, 0, "Method of Multiplexed I/O"}, {"SELECT_TYPE", SELECT_TYPE, 0, "Method of Multiplexed I/O"},
#ifdef SPATH #ifdef SPATH
{"SPATH", SPATH, 0, "Path to Server Executable"}, {"SPATH", SPATH, 0, "Path to Server Executable"},
#else #else
{"SPATH", "NONE", 0, "Path to Server Executable"}, {"SPATH", "NONE", 0, "Path to Server Executable"},
#endif /* SPATH */ #endif /* SPATH */
{"TS_MAX_DELTA_DEFAULT", "", TS_MAX_DELTA_DEFAULT, {
"Maximum Allowed TS Delta from another Server"}, "TS_MAX_DELTA_DEFAULT", "", TS_MAX_DELTA_DEFAULT,
{"TS_WARN_DELTA_DEFAULT", "", TS_WARN_DELTA_DEFAULT, "Maximum Allowed TS Delta from another Server"
"Maximum TS Delta before Sending Warning"}, },
{
"TS_WARN_DELTA_DEFAULT", "", TS_WARN_DELTA_DEFAULT,
"Maximum TS Delta before Sending Warning"
},
#ifdef USE_IODEBUG_HOOKS #ifdef USE_IODEBUG_HOOKS
{"USE_IODEBUG_HOOKS", "YES", 0, "IO Debugging support"}, {"USE_IODEBUG_HOOKS", "YES", 0, "IO Debugging support"},
#else #else
{"USE_IODEBUG_HOOKS", "NO", 0, "IO Debugging support"}, {"USE_IODEBUG_HOOKS", "NO", 0, "IO Debugging support"},
#endif #endif
/* /*
* since we don't want to include the world here, NULL probably * since we don't want to include the world here, NULL probably
* isn't defined by the time we read this, just use plain 0 instead * isn't defined by the time we read this, just use plain 0 instead
* 0 is guaranteed by the language to be assignable to ALL built * 0 is guaranteed by the language to be assignable to ALL built
* in types with the correct results. * in types with the correct results.
*/ */
{0, 0, 0, 0} {0, 0, 0, 0}
}; };

View File

@ -51,9 +51,9 @@ int comp_with_mask(void *addr, void *dest, u_int mask);
int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, u_int mask); int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, u_int mask);
/* /*
* collapse - collapse a string in place, converts multiple adjacent *'s * collapse - collapse a string in place, converts multiple adjacent *'s
* into a single *. * into a single *.
* collapse - modifies the contents of pattern * collapse - modifies the contents of pattern
* *
* collapse_esc() - collapse with support for escaping chars * collapse_esc() - collapse with support for escaping chars
*/ */

View File

@ -41,19 +41,17 @@
#include "msg.h" #include "msg.h"
#include "hook.h" #include "hook.h"
struct module struct module {
{ char *name;
char *name; const char *version;
const char *version; void *address;
void *address; int core;
int core; int mapi_version;
int mapi_version; void * mapi_header; /* actually struct mapi_mheader_av<mapi_version> */
void * mapi_header; /* actually struct mapi_mheader_av<mapi_version> */
}; };
struct module_path struct module_path {
{ char path[MAXPATHLEN];
char path[MAXPATHLEN];
}; };
#define MAPI_MAGIC_HDR 0x4D410000 #define MAPI_MAGIC_HDR 0x4D410000
@ -65,28 +63,25 @@ struct module_path
typedef struct Message* mapi_clist_av1; typedef struct Message* mapi_clist_av1;
typedef struct typedef struct {
{ const char * hapi_name;
const char * hapi_name; int * hapi_id;
int * hapi_id;
} mapi_hlist_av1; } mapi_hlist_av1;
typedef struct typedef struct {
{ const char * hapi_name;
const char * hapi_name; hookfn fn;
hookfn fn;
} mapi_hfn_list_av1; } mapi_hfn_list_av1;
struct mapi_mheader_av1 struct mapi_mheader_av1 {
{ int mapi_version; /* Module API version */
int mapi_version; /* Module API version */ int (*mapi_register) (void); /* Register function;
int (*mapi_register) (void); /* Register function;
ret -1 = failure (unload) */ ret -1 = failure (unload) */
void (*mapi_unregister) (void); /* Unregister function. */ void (*mapi_unregister) (void); /* Unregister function. */
mapi_clist_av1 * mapi_command_list; /* List of commands to add. */ mapi_clist_av1 * mapi_command_list; /* List of commands to add. */
mapi_hlist_av1 * mapi_hook_list; /* List of hooks to add. */ mapi_hlist_av1 * mapi_hook_list; /* List of hooks to add. */
mapi_hfn_list_av1 *mapi_hfn_list; /* List of hook_add_hook's to do */ mapi_hfn_list_av1 *mapi_hfn_list; /* List of hook_add_hook's to do */
const char * mapi_module_version; /* Module's version (freeform) */ const char * mapi_module_version; /* Module's version (freeform) */
}; };
#ifndef STATIC_MODULES #ifndef STATIC_MODULES

View File

@ -1,4 +1,4 @@
/* /*
* ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd). * ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd).
* monitor.h: Code for server-side notify lists. * monitor.h: Code for server-side notify lists.
* *
@ -11,11 +11,10 @@
struct rb_bh; struct rb_bh;
struct monitor struct monitor {
{ struct monitor *hnext;
struct monitor *hnext; char name[NICKLEN];
char name[NICKLEN]; rb_dlink_list users;
rb_dlink_list users;
}; };
extern struct monitor *monitorTable[]; extern struct monitor *monitorTable[];

View File

@ -31,15 +31,14 @@
struct Client; struct Client;
/* MessageHandler */ /* MessageHandler */
typedef enum HandlerType typedef enum HandlerType {
{ UNREGISTERED_HANDLER,
UNREGISTERED_HANDLER, CLIENT_HANDLER,
CLIENT_HANDLER, RCLIENT_HANDLER,
RCLIENT_HANDLER, SERVER_HANDLER,
SERVER_HANDLER, ENCAP_HANDLER,
ENCAP_HANDLER, OPER_HANDLER,
OPER_HANDLER, LAST_HANDLER_TYPE
LAST_HANDLER_TYPE
} }
HandlerType; HandlerType;
@ -50,27 +49,25 @@ HandlerType;
*/ */
typedef int (*MessageHandler) (struct Client *, struct Client *, int, const char *[]); typedef int (*MessageHandler) (struct Client *, struct Client *, int, const char *[]);
struct MessageEntry struct MessageEntry {
{ MessageHandler handler;
MessageHandler handler; int min_para;
int min_para;
}; };
/* Message table structure */ /* Message table structure */
struct Message struct Message {
{ const char *cmd;
const char *cmd; unsigned int count; /* number of times command used */
unsigned int count; /* number of times command used */ unsigned int rcount; /* number of times command used by server */
unsigned int rcount; /* number of times command used by server */ unsigned long bytes; /* bytes received for this message */
unsigned long bytes; /* bytes received for this message */ unsigned int flags; /* bit 0 set means that this command is allowed
unsigned int flags; /* bit 0 set means that this command is allowed
* to be used only on the average of once per 2 * to be used only on the average of once per 2
* seconds -SRB * seconds -SRB
*/ */
/* handlers: /* handlers:
* UNREGISTERED, CLIENT, RCLIENT, SERVER, OPER, LAST * UNREGISTERED, CLIENT, RCLIENT, SERVER, OPER, LAST
*/ */
struct MessageEntry handlers[LAST_HANDLER_TYPE]; struct MessageEntry handlers[LAST_HANDLER_TYPE];
}; };
#define MFLG_SLOW 0x01 /* executed roughly once per 2s */ #define MFLG_SLOW 0x01 /* executed roughly once per 2s */

View File

@ -5,22 +5,20 @@
#ifndef _NEWCONF_H_INCLUDED #ifndef _NEWCONF_H_INCLUDED
#define _NEWCONF_H_INCLUDED #define _NEWCONF_H_INCLUDED
struct ConfEntry struct ConfEntry {
{ const char *cf_name;
const char *cf_name; int cf_type;
int cf_type; void (*cf_func) (void *);
void (*cf_func) (void *); int cf_len;
int cf_len; void *cf_arg;
void *cf_arg;
}; };
struct TopConf struct TopConf {
{ const char *tc_name;
const char *tc_name; int (*tc_sfunc) (struct TopConf *);
int (*tc_sfunc) (struct TopConf *); int (*tc_efunc) (struct TopConf *);
int (*tc_efunc) (struct TopConf *); rb_dlink_list tc_items;
rb_dlink_list tc_items; struct ConfEntry *tc_entries;
struct ConfEntry *tc_entries;
}; };
@ -37,17 +35,15 @@ struct TopConf
#define CF_FLIST 0x1000 #define CF_FLIST 0x1000
#define CF_MFLAG 0xFF00 #define CF_MFLAG 0xFF00
typedef struct conf_parm_t_stru typedef struct conf_parm_t_stru {
{ struct conf_parm_t_stru *next;
struct conf_parm_t_stru *next; int type;
int type; union {
union char *string;
{ int number;
char *string; struct conf_parm_t_stru *list;
int number; }
struct conf_parm_t_stru *list; v;
}
v;
} }
conf_parm_t; conf_parm_t;

View File

@ -77,7 +77,7 @@ extern const char *form_str(int);
#define RPL_STATSYLINE 218 #define RPL_STATSYLINE 218
#define RPL_ENDOFSTATS 219 #define RPL_ENDOFSTATS 219
/* note ircu uses 217 for STATSPLINE frip. conflict /* note ircu uses 217 for STATSPLINE frip. conflict
* as RPL_STATSQLINE was used in old 2.8 for Q line * as RPL_STATSQLINE was used in old 2.8 for Q line
* I'm going to steal 220 for now *sigh* * I'm going to steal 220 for now *sigh*
* -Dianora * -Dianora
*/ */
@ -318,7 +318,7 @@ extern const char *form_str(int);
#define ERR_USERNOTONSERV 504 #define ERR_USERNOTONSERV 504
/* #define ERR_LAST_ERR_MSG 505 /* #define ERR_LAST_ERR_MSG 505
* moved to 999 * moved to 999
*/ */
#define ERR_WRONGPONG 513 #define ERR_WRONGPONG 513

View File

@ -35,7 +35,7 @@
* the network.. * the network..
* -- adrian * -- adrian
*/ */
/* MAX_FLOOD is the amount of lines in a 'burst' we allow from a client, /* MAX_FLOOD is the amount of lines in a 'burst' we allow from a client,
* anything beyond MAX_FLOOD is limited to about one line per second. * anything beyond MAX_FLOOD is limited to about one line per second.
* *
* MAX_FLOOD_CONN is the amount of lines we allow from a client who has * MAX_FLOOD_CONN is the amount of lines we allow from a client who has

View File

@ -32,8 +32,8 @@ struct Message;
struct Client; struct Client;
extern void parse(struct Client *, char *, char *); extern void parse(struct Client *, char *, char *);
extern void handle_encap(struct Client *, struct Client *, extern void handle_encap(struct Client *, struct Client *,
const char *, int, const char *parv[]); const char *, int, const char *parv[]);
extern void clear_hash_parse(void); extern void clear_hash_parse(void);
extern void mod_add_cmd(struct Message *msg); extern void mod_add_cmd(struct Message *msg);
extern void mod_del_cmd(struct Message *msg); extern void mod_del_cmd(struct Message *msg);

View File

@ -27,17 +27,17 @@
#include "stdinc.h" #include "stdinc.h"
enum { enum {
PRIV_NEEDOPER = 1 PRIV_NEEDOPER = 1
}; };
typedef unsigned int PrivilegeFlags; typedef unsigned int PrivilegeFlags;
struct PrivilegeSet { struct PrivilegeSet {
unsigned int status; /* If CONF_ILLEGAL, delete when no refs */ unsigned int status; /* If CONF_ILLEGAL, delete when no refs */
int refs; int refs;
char *name; char *name;
char *privs; char *privs;
PrivilegeFlags flags; PrivilegeFlags flags;
rb_dlink_node node; rb_dlink_node node;
}; };
int privilegeset_in_set(struct PrivilegeSet *set, const char *priv); int privilegeset_in_set(struct PrivilegeSet *set, const char *priv);

View File

@ -12,22 +12,20 @@
#include "match.h" #include "match.h"
#include "ircd.h" #include "ircd.h"
/* Maximum number of nameservers in /etc/resolv.conf we care about /* Maximum number of nameservers in /etc/resolv.conf we care about
* In hybrid, this was 2 -- but in Charybdis, we want to track * In hybrid, this was 2 -- but in Charybdis, we want to track
* a few more than that ;) --nenolod * a few more than that ;) --nenolod
*/ */
#define IRCD_MAXNS 10 #define IRCD_MAXNS 10
struct DNSReply struct DNSReply {
{ char *h_name;
char *h_name; struct rb_sockaddr_storage addr;
struct rb_sockaddr_storage addr;
}; };
struct DNSQuery struct DNSQuery {
{ void *ptr; /* pointer used by callback to identify request */
void *ptr; /* pointer used by callback to identify request */ void (*callback)(void* vptr, struct DNSReply *reply); /* callback to call */
void (*callback)(void* vptr, struct DNSReply *reply); /* callback to call */
}; };
extern struct rb_sockaddr_storage irc_nsaddr_list[]; extern struct rb_sockaddr_storage irc_nsaddr_list[];

View File

@ -34,41 +34,40 @@
#define RRFIXEDSZ 10 #define RRFIXEDSZ 10
#define HFIXEDSZ 12 #define HFIXEDSZ 12
typedef struct typedef struct {
{ unsigned id :16; /* query identification number */
unsigned id :16; /* query identification number */
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
/* fields in third byte */ /* fields in third byte */
unsigned qr: 1; /* response flag */ unsigned qr: 1; /* response flag */
unsigned opcode: 4; /* purpose of message */ unsigned opcode: 4; /* purpose of message */
unsigned aa: 1; /* authoritive answer */ unsigned aa: 1; /* authoritive answer */
unsigned tc: 1; /* truncated message */ unsigned tc: 1; /* truncated message */
unsigned rd: 1; /* recursion desired */ unsigned rd: 1; /* recursion desired */
/* fields in fourth byte */ /* fields in fourth byte */
unsigned ra: 1; /* recursion available */ unsigned ra: 1; /* recursion available */
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
unsigned ad: 1; /* authentic data from named */ unsigned ad: 1; /* authentic data from named */
unsigned cd: 1; /* checking disabled by resolver */ unsigned cd: 1; /* checking disabled by resolver */
unsigned rcode :4; /* response code */ unsigned rcode :4; /* response code */
#else #else
/* fields in third byte */ /* fields in third byte */
unsigned rd :1; /* recursion desired */ unsigned rd :1; /* recursion desired */
unsigned tc :1; /* truncated message */ unsigned tc :1; /* truncated message */
unsigned aa :1; /* authoritive answer */ unsigned aa :1; /* authoritive answer */
unsigned opcode :4; /* purpose of message */ unsigned opcode :4; /* purpose of message */
unsigned qr :1; /* response flag */ unsigned qr :1; /* response flag */
/* fields in fourth byte */ /* fields in fourth byte */
unsigned rcode :4; /* response code */ unsigned rcode :4; /* response code */
unsigned cd: 1; /* checking disabled by resolver */ unsigned cd: 1; /* checking disabled by resolver */
unsigned ad: 1; /* authentic data from named */ unsigned ad: 1; /* authentic data from named */
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
unsigned ra :1; /* recursion available */ unsigned ra :1; /* recursion available */
#endif #endif
/* remaining bytes */ /* remaining bytes */
unsigned qdcount :16; /* number of question entries */ unsigned qdcount :16; /* number of question entries */
unsigned ancount :16; /* number of answer entries */ unsigned ancount :16; /* number of answer entries */
unsigned nscount :16; /* number of authority entries */ unsigned nscount :16; /* number of authority entries */
unsigned arcount :16; /* number of resource entries */ unsigned arcount :16; /* number of resource entries */
} HEADER; } HEADER;
/* /*

View File

@ -43,39 +43,36 @@ struct hostent;
/* used by new parser */ /* used by new parser */
/* yacc/lex love globals!!! */ /* yacc/lex love globals!!! */
struct ip_value struct ip_value {
{ struct rb_sockaddr_storage ip;
struct rb_sockaddr_storage ip; int ip_mask;
int ip_mask; int type;
int type;
}; };
extern FILE *conf_fbfile_in; extern FILE *conf_fbfile_in;
extern char conf_line_in[256]; extern char conf_line_in[256];
struct ConfItem struct ConfItem {
{ unsigned int status; /* If CONF_ILLEGAL, delete when no clients */
unsigned int status; /* If CONF_ILLEGAL, delete when no clients */ unsigned int flags;
unsigned int flags; int clients; /* Number of *LOCAL* clients using this */
int clients; /* Number of *LOCAL* clients using this */ union {
union char *name; /* IRC name, nick, server name, or original u@h */
{ const char *oper;
char *name; /* IRC name, nick, server name, or original u@h */ } info;
const char *oper; char *host; /* host part of user@host */
} info; char *passwd; /* doubles as kline reason *ugh* */
char *host; /* host part of user@host */ char *spasswd; /* Password to send. */
char *passwd; /* doubles as kline reason *ugh* */ char *autojoin; /* channels for users to autojoin to on connect */
char *spasswd; /* Password to send. */ char *autojoin_opers; /* channels for opers to autojoin on oper-up */
char *autojoin; /* channels for users to autojoin to on connect */ char *user; /* user part of user@host */
char *autojoin_opers; /* channels for opers to autojoin on oper-up */ int port;
char *user; /* user part of user@host */ time_t hold; /* Hold action until this time (calendar time) */
int port; time_t created; /* Creation time (for klines etc) */
time_t hold; /* Hold action until this time (calendar time) */ time_t lifetime; /* Propagated lines: remember until this time */
time_t created; /* Creation time (for klines etc) */ char *className; /* Name of class */
time_t lifetime; /* Propagated lines: remember until this time */ struct Class *c_class; /* Class of connection */
char *className; /* Name of class */ rb_patricia_node_t *pnode; /* Our patricia node */
struct Class *c_class; /* Class of connection */
rb_patricia_node_t *pnode; /* Our patricia node */
}; };
#define CONF_ILLEGAL 0x80000000 #define CONF_ILLEGAL 0x80000000
@ -137,192 +134,186 @@ struct ConfItem
/* flag definitions for opers now in client.h */ /* flag definitions for opers now in client.h */
struct config_file_entry struct config_file_entry {
{ const char *dpath; /* DPATH if set from command line */
const char *dpath; /* DPATH if set from command line */ const char *configfile;
const char *configfile;
char *egdpool_path; char *egdpool_path;
char *default_operstring; char *default_operstring;
char *default_adminstring; char *default_adminstring;
char *default_operhost; char *default_operhost;
char *static_quit; char *static_quit;
char *servicestring; char *servicestring;
char *kline_reason; char *kline_reason;
char *identifyservice; char *identifyservice;
char *identifycommand; char *identifycommand;
char *fname_userlog;
char *fname_fuserlog;
char *fname_operlog;
char *fname_foperlog;
char *fname_serverlog;
char *fname_killlog;
char *fname_klinelog;
char *fname_operspylog;
char *fname_ioerrorlog;
unsigned char compression_level; char *fname_userlog;
int disable_fake_channels; char *fname_fuserlog;
int hide_channel_below_users; char *fname_operlog;
int dots_in_ident; char *fname_foperlog;
int failed_oper_notice; char *fname_serverlog;
int anti_nick_flood; char *fname_killlog;
int use_part_messages; char *fname_klinelog;
int anti_spam_exit_message_time; char *fname_operspylog;
int max_accept; char *fname_ioerrorlog;
int max_monitor;
int max_nick_time; unsigned char compression_level;
int max_nick_changes; int disable_fake_channels;
int ts_max_delta; int hide_channel_below_users;
int ts_warn_delta; int dots_in_ident;
int dline_with_reason; int failed_oper_notice;
int kline_with_reason; int anti_nick_flood;
int kline_delay; int use_part_messages;
int warn_no_nline; int anti_spam_exit_message_time;
int nick_delay; int max_accept;
int non_redundant_klines; int max_monitor;
int stats_e_disabled; int max_nick_time;
int stats_c_oper_only; int max_nick_changes;
int stats_y_oper_only; int ts_max_delta;
int stats_h_oper_only; int ts_warn_delta;
int stats_o_oper_only; int dline_with_reason;
int stats_k_oper_only; int kline_with_reason;
int stats_i_oper_only; int kline_delay;
int stats_P_oper_only; int warn_no_nline;
int map_oper_only; int nick_delay;
int operspy_admin_only; int non_redundant_klines;
int pace_wait; int stats_e_disabled;
int pace_wait_simple; int stats_c_oper_only;
int short_motd; int stats_y_oper_only;
int no_oper_flood; int stats_h_oper_only;
int true_no_oper_flood; int stats_o_oper_only;
int hide_server; int stats_k_oper_only;
int hide_spoof_ips; int stats_i_oper_only;
int hide_error_messages; int stats_P_oper_only;
int client_exit; int map_oper_only;
int oper_only_umodes; int operspy_admin_only;
int oper_umodes; int pace_wait;
int oper_snomask; int pace_wait_simple;
int max_targets; int short_motd;
int caller_id_wait; int no_oper_flood;
int min_nonwildcard; int true_no_oper_flood;
int min_nonwildcard_simple; int hide_server;
int default_floodcount; int hide_spoof_ips;
int client_flood; int hide_error_messages;
int default_ident_timeout; int client_exit;
int use_egd; int oper_only_umodes;
int ping_cookie; int oper_umodes;
int tkline_expire_notices; int oper_snomask;
int use_whois_actually; int max_targets;
int disable_auth; int caller_id_wait;
int connect_timeout; int min_nonwildcard;
int burst_away; int min_nonwildcard_simple;
int reject_ban_time; int default_floodcount;
int reject_after_count; int client_flood;
int reject_duration; int default_ident_timeout;
int throttle_count; int use_egd;
int throttle_duration; int ping_cookie;
int target_change; int tkline_expire_notices;
int collision_fnc; int use_whois_actually;
int default_umodes; int disable_auth;
int global_snotices; int connect_timeout;
int operspy_dont_care_user_info; int burst_away;
int use_propagated_bans; int reject_ban_time;
int secret_channels_in_whois; int reject_after_count;
int expire_override_time; int reject_duration;
int throttle_count;
int throttle_duration;
int target_change;
int collision_fnc;
int default_umodes;
int global_snotices;
int operspy_dont_care_user_info;
int use_propagated_bans;
int secret_channels_in_whois;
int expire_override_time;
int away_interval; int away_interval;
}; };
struct config_channel_entry struct config_channel_entry {
{ char * autochanmodes;
char * autochanmodes; char * exemptchanops;
char * exemptchanops; char * disabledmodes;
char * disabledmodes; int admin_on_channel_create;
int admin_on_channel_create; int use_halfop;
int use_halfop; int use_admin;
int use_admin; int use_owner;
int use_owner; int use_except;
int use_except; int use_invex;
int use_invex; int use_knock;
int use_knock; int use_forward;
int use_forward; int use_local_channels;
int use_local_channels; int knock_delay;
int knock_delay; int knock_delay_channel;
int knock_delay_channel; int max_bans;
int max_bans; int max_bans_large;
int max_bans_large; int max_chans_per_user;
int max_chans_per_user; int no_create_on_split;
int no_create_on_split; int no_join_on_split;
int no_join_on_split; int default_split_server_count;
int default_split_server_count; int default_split_user_count;
int default_split_user_count; int burst_topicwho;
int burst_topicwho; int kick_on_split_riding;
int kick_on_split_riding; int only_ascii_channels;
int only_ascii_channels; int cycle_host_change;
int cycle_host_change; int host_in_topic;
int host_in_topic; int resv_forcepart;
int resv_forcepart; int channel_target_change;
int channel_target_change;
int exempt_cmode_c; int exempt_cmode_c;
int exempt_cmode_C; int exempt_cmode_C;
int exempt_cmode_D; int exempt_cmode_D;
int exempt_cmode_T; int exempt_cmode_T;
int exempt_cmode_N; int exempt_cmode_N;
int exempt_cmode_G; int exempt_cmode_G;
int exempt_cmode_K; int exempt_cmode_K;
}; };
struct config_server_hide struct config_server_hide {
{ int flatten_links;
int flatten_links; int links_delay;
int links_delay; int hidden;
int hidden; int disable_hidden;
int disable_hidden;
}; };
struct server_info struct server_info {
{ char *name;
char *name; char sid[4];
char sid[4]; char *description;
char *description; char *network_name;
char *network_name; char *network_desc;
char *network_desc; char *helpchan;
char *helpchan; char *helpurl;
char *helpurl; int hub;
int hub; struct sockaddr_in ip;
struct sockaddr_in ip; int default_max_clients;
int default_max_clients;
#ifdef RB_IPV6 #ifdef RB_IPV6
struct sockaddr_in6 ip6; struct sockaddr_in6 ip6;
#endif #endif
int specific_ipv4_vhost; int specific_ipv4_vhost;
#ifdef RB_IPV6 #ifdef RB_IPV6
int specific_ipv6_vhost; int specific_ipv6_vhost;
#endif #endif
char *ssl_private_key; char *ssl_private_key;
char *ssl_ca_cert; char *ssl_ca_cert;
char *ssl_cert; char *ssl_cert;
char *ssl_dh_params; char *ssl_dh_params;
int ssld_count; int ssld_count;
}; };
struct admin_info struct admin_info {
{ char *name;
char *name; char *description;
char *description; char *email;
char *email;
}; };
struct alias_entry struct alias_entry {
{ char *name;
char *name; char *target;
char *target; int flags; /* reserved for later use */
int flags; /* reserved for later use */ int hits;
int hits;
}; };
/* All variables are GLOBAL */ /* All variables are GLOBAL */
@ -339,13 +330,12 @@ extern rb_dlink_list service_list;
extern rb_dlink_list prop_bans; extern rb_dlink_list prop_bans;
typedef enum temp_list typedef enum temp_list {
{ TEMP_MIN,
TEMP_MIN, TEMP_HOUR,
TEMP_HOUR, TEMP_DAY,
TEMP_DAY, TEMP_WEEK,
TEMP_WEEK, LAST_TEMP_TYPE
LAST_TEMP_TYPE
} temp_list; } temp_list;
extern rb_dlink_list temp_klines[LAST_TEMP_TYPE]; extern rb_dlink_list temp_klines[LAST_TEMP_TYPE];
@ -370,10 +360,10 @@ extern int detach_conf(struct Client *);
extern struct ConfItem *find_tkline(const char *, const char *, struct sockaddr *); extern struct ConfItem *find_tkline(const char *, const char *, struct sockaddr *);
extern char *show_iline_prefix(struct Client *, struct ConfItem *, char *); extern char *show_iline_prefix(struct Client *, struct ConfItem *, char *);
extern void get_printable_conf(struct ConfItem *, extern void get_printable_conf(struct ConfItem *,
char **, char **, char **, char **, int *, char **); char **, char **, char **, char **, int *, char **);
extern char *get_user_ban_reason(struct ConfItem *aconf); extern char *get_user_ban_reason(struct ConfItem *aconf);
extern void get_printable_kline(struct Client *, struct ConfItem *, extern void get_printable_kline(struct Client *, struct ConfItem *,
char **, char **, char **, char **); char **, char **, char **, char **);
extern void yyerror(const char *); extern void yyerror(const char *);
extern int conf_yy_fatal_error(const char *); extern int conf_yy_fatal_error(const char *);

View File

@ -59,25 +59,23 @@ extern void init_s_newconf(void);
extern void clear_s_newconf(void); extern void clear_s_newconf(void);
extern void clear_s_newconf_bans(void); extern void clear_s_newconf_bans(void);
typedef struct typedef struct {
{ char *ip;
char *ip; time_t expiry;
time_t expiry; rb_patricia_node_t *pnode;
rb_patricia_node_t *pnode; rb_dlink_node node;
rb_dlink_node node;
} tgchange; } tgchange;
void add_tgchange(const char *host); void add_tgchange(const char *host);
tgchange *find_tgchange(const char *host); tgchange *find_tgchange(const char *host);
/* shared/cluster/hub/leaf confs */ /* shared/cluster/hub/leaf confs */
struct remote_conf struct remote_conf {
{ char *username;
char *username; char *host;
char *host; char *server;
char *server; int flags;
int flags; rb_dlink_node node;
rb_dlink_node node;
}; };
/* flags used in shared/cluster */ /* flags used in shared/cluster */
@ -107,28 +105,27 @@ struct remote_conf
#define CONF_HUB 0x0001 #define CONF_HUB 0x0001
#define CONF_LEAF 0x0002 #define CONF_LEAF 0x0002
struct oper_conf struct oper_conf {
{ char *name;
char *name; char *username;
char *username; char *host;
char *host; char *passwd;
char *passwd; char *certfp;
char *certfp;
int flags; int flags;
int umodes; int umodes;
unsigned int snomask; unsigned int snomask;
char *vhost; char *vhost;
char *swhois; char *swhois;
char *operstring; char *operstring;
struct PrivilegeSet *privset; struct PrivilegeSet *privset;
#ifdef HAVE_LIBCRYPTO #ifdef HAVE_LIBCRYPTO
char *rsa_pubkey_file; char *rsa_pubkey_file;
RSA *rsa_pubkey; RSA *rsa_pubkey;
#endif #endif
}; };
@ -136,11 +133,11 @@ extern struct remote_conf *make_remote_conf(void);
extern void free_remote_conf(struct remote_conf *); extern void free_remote_conf(struct remote_conf *);
extern int find_shared_conf(const char *username, const char *host, extern int find_shared_conf(const char *username, const char *host,
const char *server, int flags); const char *server, int flags);
extern void propagate_generic(struct Client *source_p, const char *command, extern void propagate_generic(struct Client *source_p, const char *command,
const char *target, int cap, const char *format, ...); const char *target, int cap, const char *format, ...);
extern void cluster_generic(struct Client *, const char *, int cltype, extern void cluster_generic(struct Client *, const char *, int cltype,
int cap, const char *format, ...); int cap, const char *format, ...);
#define OPER_ENCRYPTED 0x00001 #define OPER_ENCRYPTED 0x00001
#define OPER_NEEDSSL 0x80000 #define OPER_NEEDSSL 0x80000
@ -177,28 +174,27 @@ extern void free_oper_conf(struct oper_conf *);
extern void clear_oper_conf(void); extern void clear_oper_conf(void);
extern struct oper_conf *find_oper_conf(const char *username, const char *host, extern struct oper_conf *find_oper_conf(const char *username, const char *host,
const char *locip, const char *oname); const char *locip, const char *oname);
extern const char *get_oper_privs(int flags); extern const char *get_oper_privs(int flags);
struct server_conf struct server_conf {
{ char *name;
char *name; char *host;
char *host; char *passwd;
char *passwd; char *spasswd;
char *spasswd; char *certfp;
char *certfp; int port;
int port; int flags;
int flags; int servers;
int servers; time_t hold;
time_t hold;
int aftype; int aftype;
struct rb_sockaddr_storage my_ipnum; struct rb_sockaddr_storage my_ipnum;
char *class_name; char *class_name;
struct Class *class; struct Class *class;
rb_dlink_node node; rb_dlink_node node;
}; };
#define SERVER_ILLEGAL 0x0001 #define SERVER_ILLEGAL 0x0001
@ -226,8 +222,8 @@ extern struct server_conf *find_server_conf(const char *name);
extern void attach_server_conf(struct Client *, struct server_conf *); extern void attach_server_conf(struct Client *, struct server_conf *);
extern void detach_server_conf(struct Client *); extern void detach_server_conf(struct Client *);
extern void set_server_conf_autoconn(struct Client *source_p, const char *name, extern void set_server_conf_autoconn(struct Client *source_p, const char *name,
int newval); int newval);
extern void disable_server_conf_autoconn(const char *name); extern void disable_server_conf_autoconn(const char *name);
@ -240,11 +236,10 @@ extern int valid_wild_card_simple(const char *);
extern int clean_resv_nick(const char *); extern int clean_resv_nick(const char *);
time_t valid_temp_time(const char *p); time_t valid_temp_time(const char *p);
struct nd_entry struct nd_entry {
{ char name[NICKLEN+1];
char name[NICKLEN+1]; time_t expire;
time_t expire; rb_dlink_node lnode; /* node in ll */
rb_dlink_node lnode; /* node in ll */
}; };
extern void add_nd_entry(const char *name); extern void add_nd_entry(const char *name);

View File

@ -37,7 +37,7 @@
/* /*
* number of seconds to wait after server starts up, before * number of seconds to wait after server starts up, before
* starting try_connections() * starting try_connections()
* TOO SOON and you can nick collide like crazy. * TOO SOON and you can nick collide like crazy.
*/ */
#define STARTUP_CONNECTIONS_TIME 60 #define STARTUP_CONNECTIONS_TIME 60
@ -46,11 +46,10 @@ struct server_conf;
struct Channel; struct Channel;
/* Capabilities */ /* Capabilities */
struct Capability struct Capability {
{ const char *name; /* name of capability */
const char *name; /* name of capability */ unsigned int cap; /* mask value */
unsigned int cap; /* mask value */ unsigned int required; /* 1 if required, 0 if not */
unsigned int required; /* 1 if required, 0 if not */
}; };
#define CAP_CAP 0x00001 /* received a CAP to begin with */ #define CAP_CAP 0x00001 /* received a CAP to begin with */
@ -110,7 +109,7 @@ extern int MaxConnectionCount; /* GLOBAL - highest number of connections */
extern int refresh_user_links; extern int refresh_user_links;
/* /*
* return values for hunt_server() * return values for hunt_server()
*/ */
#define HUNTED_NOSUCH (-1) /* if the hunted server is not found */ #define HUNTED_NOSUCH (-1) /* if the hunted server is not found */
#define HUNTED_ISME 0 /* if this server should execute the command */ #define HUNTED_ISME 0 /* if this server should execute the command */
@ -118,8 +117,8 @@ extern int refresh_user_links;
extern int hunt_server(struct Client *client_pt, extern int hunt_server(struct Client *client_pt,
struct Client *source_pt, struct Client *source_pt,
const char *command, int server, int parc, const char **parv); const char *command, int server, int parc, const char **parv);
extern void send_capabilities(struct Client *, int); extern void send_capabilities(struct Client *, int);
extern const char *show_capabilities(struct Client *client); extern const char *show_capabilities(struct Client *client);
extern void try_connections(void *unused); extern void try_connections(void *unused);

View File

@ -39,33 +39,32 @@ struct Client;
/* /*
* statistics structures * statistics structures
*/ */
struct ServerStatistics struct ServerStatistics {
{ unsigned int is_cl; /* number of client connections */
unsigned int is_cl; /* number of client connections */ unsigned int is_sv; /* number of server connections */
unsigned int is_sv; /* number of server connections */ unsigned int is_ni; /* connection but no idea who it was */
unsigned int is_ni; /* connection but no idea who it was */ unsigned long long int is_cbs; /* bytes sent to clients */
unsigned long long int is_cbs; /* bytes sent to clients */ unsigned long long int is_cbr; /* bytes received to clients */
unsigned long long int is_cbr; /* bytes received to clients */ unsigned long long int is_sbs; /* bytes sent to servers */
unsigned long long int is_sbs; /* bytes sent to servers */ unsigned long long int is_sbr; /* bytes received to servers */
unsigned long long int is_sbr; /* bytes received to servers */ unsigned long long int is_cti; /* time spent connected by clients */
unsigned long long int is_cti; /* time spent connected by clients */ unsigned long long int is_sti; /* time spent connected by servers */
unsigned long long int is_sti; /* time spent connected by servers */ unsigned int is_ac; /* connections accepted */
unsigned int is_ac; /* connections accepted */ unsigned int is_ref; /* accepts refused */
unsigned int is_ref; /* accepts refused */ unsigned int is_unco; /* unknown commands */
unsigned int is_unco; /* unknown commands */ unsigned int is_wrdi; /* command going in wrong direction */
unsigned int is_wrdi; /* command going in wrong direction */ unsigned int is_unpf; /* unknown prefix */
unsigned int is_unpf; /* unknown prefix */ unsigned int is_empt; /* empty message */
unsigned int is_empt; /* empty message */ unsigned int is_num; /* numeric message */
unsigned int is_num; /* numeric message */ unsigned int is_kill; /* number of kills generated on collisions */
unsigned int is_kill; /* number of kills generated on collisions */ unsigned int is_save; /* number of saves generated on collisions */
unsigned int is_save; /* number of saves generated on collisions */ unsigned int is_asuc; /* successful auth requests */
unsigned int is_asuc; /* successful auth requests */ unsigned int is_abad; /* bad auth requests */
unsigned int is_abad; /* bad auth requests */ unsigned int is_rej; /* rejected from cache */
unsigned int is_rej; /* rejected from cache */ unsigned int is_thr; /* number of throttled connections */
unsigned int is_thr; /* number of throttled connections */ unsigned int is_ssuc; /* successful sasl authentications */
unsigned int is_ssuc; /* successful sasl authentications */ unsigned int is_sbad; /* failed sasl authentications */
unsigned int is_sbad; /* failed sasl authentications */ unsigned int is_tgch; /* messages blocked due to target change */
unsigned int is_tgch; /* messages blocked due to target change */
}; };
extern struct ServerStatistics ServerStats; extern struct ServerStatistics ServerStats;

View File

@ -42,11 +42,11 @@ extern void send_umode_out(struct Client *, struct Client *, int);
extern int show_lusers(struct Client *source_p); extern int show_lusers(struct Client *source_p);
extern int register_local_user(struct Client *, struct Client *, const char *); extern int register_local_user(struct Client *, struct Client *, const char *);
extern int introduce_client(struct Client *client_p, struct Client *source_p, extern int introduce_client(struct Client *client_p, struct Client *source_p,
struct User *user, const char *nick, int use_euid); struct User *user, const char *nick, int use_euid);
extern void change_nick_user_host(struct Client *target_p, const char *nick, const char *user, extern void change_nick_user_host(struct Client *target_p, const char *nick, const char *user,
const char *host, int newts, const char *format, ...); const char *host, int newts, const char *format, ...);
extern int user_modes[256]; extern int user_modes[256];
extern unsigned int find_umode_slot(void); extern unsigned int find_umode_slot(void);

View File

@ -46,19 +46,19 @@ extern void send_queued(struct Client *to);
extern void sendto_one(struct Client *target_p, const char *, ...) AFP(2, 3); extern void sendto_one(struct Client *target_p, const char *, ...) AFP(2, 3);
extern void sendto_one_notice(struct Client *target_p,const char *, ...) AFP(2, 3); extern void sendto_one_notice(struct Client *target_p,const char *, ...) AFP(2, 3);
extern void sendto_one_prefix(struct Client *target_p, struct Client *source_p, extern void sendto_one_prefix(struct Client *target_p, struct Client *source_p,
const char *command, const char *, ...) AFP(4, 5); const char *command, const char *, ...) AFP(4, 5);
extern void sendto_one_numeric(struct Client *target_p, extern void sendto_one_numeric(struct Client *target_p,
int numeric, const char *, ...) AFP(3, 4); int numeric, const char *, ...) AFP(3, 4);
extern void sendto_server(struct Client *one, struct Channel *chptr, extern void sendto_server(struct Client *one, struct Channel *chptr,
unsigned long caps, unsigned long nocaps, unsigned long caps, unsigned long nocaps,
const char *format, ...) AFP(5, 6); const char *format, ...) AFP(5, 6);
extern void sendto_channel_flags(struct Client *one, int type, struct Client *source_p, extern void sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
struct Channel *chptr, const char *, ...) AFP(5, 6); struct Channel *chptr, const char *, ...) AFP(5, 6);
extern void sendto_channel_opmod(struct Client *one, struct Client *source_p, extern void sendto_channel_opmod(struct Client *one, struct Client *source_p,
struct Channel *chptr, const char *command, struct Channel *chptr, const char *command,
const char *text); const char *text);
extern void sendto_channel_local(int type, struct Channel *, const char *, ...) AFP(3, 4); extern void sendto_channel_local(int type, struct Channel *, const char *, ...) AFP(3, 4);
extern void sendto_channel_local_butone(struct Client *, int type, struct Channel *, const char *, ...) AFP(4, 5); extern void sendto_channel_local_butone(struct Client *, int type, struct Channel *, const char *, ...) AFP(4, 5);
@ -70,14 +70,14 @@ extern void sendto_common_channels_local_butone(struct Client *, int cap, const
extern void sendto_match_butone(struct Client *, struct Client *, extern void sendto_match_butone(struct Client *, struct Client *,
const char *, int, const char *, ...) AFP(5, 6); const char *, int, const char *, ...) AFP(5, 6);
extern void sendto_match_servs(struct Client *source_p, const char *mask, extern void sendto_match_servs(struct Client *source_p, const char *mask,
int capab, int, const char *, ...) AFP(5, 6); int capab, int, const char *, ...) AFP(5, 6);
extern void sendto_monitor(struct monitor *monptr, const char *, ...) AFP(2, 3); extern void sendto_monitor(struct monitor *monptr, const char *, ...) AFP(2, 3);
extern void sendto_anywhere(struct Client *, struct Client *, const char *, extern void sendto_anywhere(struct Client *, struct Client *, const char *,
const char *, ...) AFP(4, 5); const char *, ...) AFP(4, 5);
extern void sendto_realops_snomask(int, int, const char *, ...) AFP(3, 4); extern void sendto_realops_snomask(int, int, const char *, ...) AFP(3, 4);
extern void sendto_realops_snomask_from(int, int, struct Client *, const char *, ...) AFP(4, 5); extern void sendto_realops_snomask_from(int, int, struct Client *, const char *, ...) AFP(4, 5);
@ -85,9 +85,9 @@ extern void sendto_realops_snomask_from(int, int, struct Client *, const char *,
extern void sendto_wallops_flags(int, struct Client *, const char *, ...) AFP(3, 4); extern void sendto_wallops_flags(int, struct Client *, const char *, ...) AFP(3, 4);
extern void kill_client(struct Client *client_p, struct Client *diedie, extern void kill_client(struct Client *client_p, struct Client *diedie,
const char *pattern, ...) AFP(3, 4); const char *pattern, ...) AFP(3, 4);
extern void kill_client_serv_butone(struct Client *one, struct Client *source_p, extern void kill_client_serv_butone(struct Client *one, struct Client *source_p,
const char *pattern, ...) AFP(3, 4); const char *pattern, ...) AFP(3, 4);
#define L_ALL 0 #define L_ALL 0
#define L_OPER 1 #define L_OPER 1

View File

@ -39,7 +39,7 @@
# include <alloca.h> # include <alloca.h>
# else # else
# ifdef _AIX # ifdef _AIX
#pragma alloca #pragma alloca
# else # else
# ifndef alloca /* predefined by HP cc +Olibcalls */ # ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca (); char *alloca ();
@ -48,7 +48,7 @@ char *alloca ();
# endif # endif
# endif # endif
#endif #endif
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
@ -142,7 +142,7 @@ extern int errno;
#ifdef strdupa #ifdef strdupa
#define LOCAL_COPY(s) strdupa(s) #define LOCAL_COPY(s) strdupa(s)
#else #else
#if defined(__INTEL_COMPILER) || defined(__GNUC__) #if defined(__INTEL_COMPILER) || defined(__GNUC__)
# define LOCAL_COPY(s) __extension__({ char *_s = alloca(strlen(s) + 1); strcpy(_s, s); _s; }) # define LOCAL_COPY(s) __extension__({ char *_s = alloca(strlen(s) + 1); strcpy(_s, s); _s; })

View File

@ -4,11 +4,11 @@
* *
* Entirely rewritten, August 2006 by Jilles Tjoelker * Entirely rewritten, August 2006 by Jilles Tjoelker
* Copyright (C) 2006 Jilles Tjoelker * Copyright (C) 2006 Jilles Tjoelker
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
* met: * met:
* *
* 1.Redistributions of source code must retain the above copyright notice, * 1.Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2.Redistributions in binary form must reproduce the above copyright * 2.Redistributions in binary form must reproduce the above copyright
@ -16,7 +16,7 @@
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3.The name of the author may not be used to endorse or promote products * 3.The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE

View File

@ -45,22 +45,21 @@ struct Client;
also removed away information. *tough* also removed away information. *tough*
- Dianora - Dianora
*/ */
struct Whowas struct Whowas {
{ int hashv;
int hashv; char name[NICKLEN + 1];
char name[NICKLEN + 1]; char username[USERLEN + 1];
char username[USERLEN + 1]; char hostname[HOSTLEN + 1];
char hostname[HOSTLEN + 1]; char sockhost[HOSTIPLEN + 1];
char sockhost[HOSTIPLEN + 1]; char realname[REALLEN + 1];
char realname[REALLEN + 1]; char suser[NICKLEN + 1];
char suser[NICKLEN + 1]; const char *servername;
const char *servername; time_t logoff;
time_t logoff; struct Client *online; /* Pointer to new nickname for chasing or NULL */
struct Client *online; /* Pointer to new nickname for chasing or NULL */ struct Whowas *next; /* for hash table... */
struct Whowas *next; /* for hash table... */ struct Whowas *prev; /* for hash table... */
struct Whowas *prev; /* for hash table... */ struct Whowas *cnext; /* for client struct linked list */
struct Whowas *cnext; /* for client struct linked list */ struct Whowas *cprev; /* for client struct linked list */
struct Whowas *cprev; /* for client struct linked list */
}; };
/* /*
@ -93,8 +92,8 @@ void off_history(struct Client *);
** one found... ** one found...
*/ */
struct Client *get_history(const char *, time_t); struct Client *get_history(const char *, time_t);
/* Nick name */ /* Nick name */
/* Time limit in seconds */ /* Time limit in seconds */
/* /*
** for debugging...counts related structures stored in whowas array. ** for debugging...counts related structures stored in whowas array.

View File

@ -44,13 +44,13 @@
#ifdef HAVE_WRITEV #ifdef HAVE_WRITEV
#ifndef UIO_MAXIOV #ifndef UIO_MAXIOV
# if defined(__FreeBSD__) || defined(__APPLE__) || defined(__NetBSD__) # if defined(__FreeBSD__) || defined(__APPLE__) || defined(__NetBSD__)
/* FreeBSD 4.7 defines it in sys/uio.h only if _KERNEL is specified */ /* FreeBSD 4.7 defines it in sys/uio.h only if _KERNEL is specified */
# define RB_UIO_MAXIOV 1024 # define RB_UIO_MAXIOV 1024
# elif defined(__sgi) # elif defined(__sgi)
/* IRIX 6.5 has sysconf(_SC_IOV_MAX) which might return 512 or bigger */ /* IRIX 6.5 has sysconf(_SC_IOV_MAX) which might return 512 or bigger */
# define RB_UIO_MAXIOV 512 # define RB_UIO_MAXIOV 512
# elif defined(__sun) # elif defined(__sun)
/* Solaris (and SunOS?) defines IOV_MAX instead */ /* Solaris (and SunOS?) defines IOV_MAX instead */
# ifndef IOV_MAX # ifndef IOV_MAX
# define RB_UIO_MAXIOV 16 # define RB_UIO_MAXIOV 16
# else # else
@ -68,24 +68,22 @@
#else #else
#define RB_UIO_MAXIOV 16 #define RB_UIO_MAXIOV 16
#endif #endif
struct conndata struct conndata {
{ /* We don't need the host here ? */
/* We don't need the host here ? */ struct rb_sockaddr_storage S;
struct rb_sockaddr_storage S; struct rb_sockaddr_storage hostaddr;
struct rb_sockaddr_storage hostaddr; time_t t;
time_t t; CNCB *callback;
CNCB *callback; void *data;
void *data; /* We'd also add the retry count here when we get to that -- adrian */
/* We'd also add the retry count here when we get to that -- adrian */
}; };
struct acceptdata struct acceptdata {
{ struct rb_sockaddr_storage S;
struct rb_sockaddr_storage S; rb_socklen_t addrlen;
rb_socklen_t addrlen; ACCB *callback;
ACCB *callback; ACPRE *precb;
ACPRE *precb; void *data;
void *data;
}; };
/* Only have open flags for now, could be more later */ /* Only have open flags for now, could be more later */
@ -95,40 +93,38 @@ struct acceptdata
#define ClearFDOpen(F) (F->flags &= ~FLAG_OPEN) #define ClearFDOpen(F) (F->flags &= ~FLAG_OPEN)
struct _fde struct _fde {
{ /* New-school stuff, again pretty much ripped from squid */
/* New-school stuff, again pretty much ripped from squid */ /*
/* * Yes, this gives us only one pending read and one pending write per
* Yes, this gives us only one pending read and one pending write per * filedescriptor. Think though: when do you think we'll need more?
* filedescriptor. Think though: when do you think we'll need more? */
*/ rb_dlink_node node;
rb_dlink_node node; int fd; /* So we can use the rb_fde_t as a callback ptr */
int fd; /* So we can use the rb_fde_t as a callback ptr */ uint8_t flags;
uint8_t flags; uint8_t type;
uint8_t type; int pflags;
int pflags; char *desc;
char *desc; PF *read_handler;
PF *read_handler; void *read_data;
void *read_data; PF *write_handler;
PF *write_handler; void *write_data;
void *write_data; struct timeout_data *timeout;
struct timeout_data *timeout; struct conndata *connect;
struct conndata *connect; struct acceptdata *accept;
struct acceptdata *accept; void *ssl;
void *ssl; unsigned int handshake_count;
unsigned int handshake_count; unsigned long ssl_errno;
unsigned long ssl_errno;
}; };
typedef void (*comm_event_cb_t) (void *); typedef void (*comm_event_cb_t) (void *);
#ifdef USE_TIMER_CREATE #ifdef USE_TIMER_CREATE
typedef struct timer_data typedef struct timer_data {
{ timer_t td_timer_id;
timer_t td_timer_id; comm_event_cb_t td_cb;
comm_event_cb_t td_cb; void *td_udata;
void *td_udata; int td_repeat;
int td_repeat;
} *comm_event_id; } *comm_event_id;
#endif #endif
@ -137,24 +133,23 @@ extern rb_dlink_list *rb_fd_table;
static inline rb_fde_t * static inline rb_fde_t *
rb_find_fd(int fd) rb_find_fd(int fd)
{ {
rb_dlink_list *hlist; rb_dlink_list *hlist;
rb_dlink_node *ptr; rb_dlink_node *ptr;
if(rb_unlikely(fd < 0)) if(rb_unlikely(fd < 0))
return NULL; return NULL;
hlist = &rb_fd_table[rb_hash_fd(fd)]; hlist = &rb_fd_table[rb_hash_fd(fd)];
if(hlist->head == NULL) if(hlist->head == NULL)
return NULL; return NULL;
RB_DLINK_FOREACH(ptr, hlist->head) RB_DLINK_FOREACH(ptr, hlist->head) {
{ rb_fde_t *F = ptr->data;
rb_fde_t *F = ptr->data; if(F->fd == fd)
if(F->fd == fd) return F;
return F; }
} return NULL;
return NULL;
} }

View File

@ -35,7 +35,7 @@ const char *rb_get_ssl_strerror(rb_fde_t *F);
void rb_ssl_start_accepted(rb_fde_t *new_F, ACCB * cb, void *data, int timeout); void rb_ssl_start_accepted(rb_fde_t *new_F, ACCB * cb, void *data, int timeout);
void rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout); void rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout);
void rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest, struct sockaddr *clocal, int socklen, void rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest, struct sockaddr *clocal, int socklen,
CNCB * callback, void *data, int timeout); CNCB * callback, void *data, int timeout);
void rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen); void rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen);
void rb_ssl_shutdown(rb_fde_t *F); void rb_ssl_shutdown(rb_fde_t *F);
ssize_t rb_ssl_read(rb_fde_t *F, void *buf, size_t count); ssize_t rb_ssl_read(rb_fde_t *F, void *buf, size_t count);

View File

@ -22,16 +22,15 @@
* *
*/ */
struct ev_entry struct ev_entry {
{ rb_dlink_node node;
rb_dlink_node node; EVH *func;
EVH *func; void *arg;
void *arg; char *name;
char *name; time_t frequency;
time_t frequency; time_t when;
time_t when; time_t next;
time_t next; void *data;
void *data; void *comm_ptr;
void *comm_ptr;
}; };
void rb_event_io_register_all(void); void rb_event_io_register_all(void);

View File

@ -184,7 +184,7 @@ void rb_set_time(void);
const char *rb_lib_version(void); const char *rb_lib_version(void);
void rb_lib_init(log_cb * xilog, restart_cb * irestart, die_cb * idie, int closeall, int maxfds, void rb_lib_init(log_cb * xilog, restart_cb * irestart, die_cb * idie, int closeall, int maxfds,
size_t dh_size, size_t fd_heap_size); size_t dh_size, size_t fd_heap_size);
void rb_lib_loop(long delay); void rb_lib_loop(long delay);
time_t rb_current_time(void); time_t rb_current_time(void);

Some files were not shown because too many files have changed in this diff Show More