mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-10 06:03:13 +02:00
Reformat all source code, using 'make format' (clang-format 21.1.8)
This reformats entire UnrealIRCd source code, according to .clang-format which was previously commited. This is reproducable using clang-format version 21.1.8. These are only visual changes, they have no effect on code. This commit will be added to .git-blame-ignore-revs so 'git blame' and the similar blame view on GitHub will ignore this commit.
This commit is contained in:
@@ -22,14 +22,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"account-notify", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"account-notify CAP", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"account-notify", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"account-notify CAP", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Variables */
|
||||
long CAP_ACCOUNT_NOTIFY = 0L;
|
||||
@@ -67,10 +66,10 @@ int account_notify_account_login(Client *client, MessageTag *recv_mtags)
|
||||
MessageTag *mtags = NULL;
|
||||
new_message(client, recv_mtags, &mtags);
|
||||
sendto_local_common_channels(client, client,
|
||||
CAP_ACCOUNT_NOTIFY, mtags,
|
||||
":%s ACCOUNT %s",
|
||||
client->name,
|
||||
IsLoggedIn(client) ? client->user->account : "*");
|
||||
CAP_ACCOUNT_NOTIFY, mtags,
|
||||
":%s ACCOUNT %s",
|
||||
client->name,
|
||||
IsLoggedIn(client) ? client->user->account : "*");
|
||||
free_message_tags(mtags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -22,14 +22,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"account-tag",
|
||||
"5.0",
|
||||
"account-tag CAP",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"account-tag",
|
||||
"5.0",
|
||||
"account-tag CAP",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Variables */
|
||||
long CAP_ACCOUNT_TAG = 0L;
|
||||
|
||||
+9
-10
@@ -24,16 +24,15 @@
|
||||
|
||||
CMD_FUNC(cmd_addmotd);
|
||||
|
||||
#define MSG_ADDMOTD "ADDMOTD"
|
||||
#define MSG_ADDMOTD "ADDMOTD"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"addmotd",
|
||||
"5.0",
|
||||
"command /addmotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"addmotd",
|
||||
"5.0",
|
||||
"command /addmotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
@@ -67,7 +66,7 @@ CMD_FUNC(cmd_addmotd)
|
||||
if (!MyConnect(client))
|
||||
return;
|
||||
|
||||
if (!ValidatePermissionsForPath("server:addmotd",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("server:addmotd", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
|
||||
+9
-10
@@ -24,16 +24,15 @@
|
||||
|
||||
CMD_FUNC(cmd_addomotd);
|
||||
|
||||
#define MSG_ADDOMOTD "ADDOMOTD"
|
||||
#define MSG_ADDOMOTD "ADDOMOTD"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"addomotd",
|
||||
"5.0",
|
||||
"command /addomotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"addomotd",
|
||||
"5.0",
|
||||
"command /addomotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
@@ -67,7 +66,7 @@ CMD_FUNC(cmd_addomotd)
|
||||
if (!MyConnect(client))
|
||||
return;
|
||||
|
||||
if (!ValidatePermissionsForPath("server:addomotd",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("server:addomotd", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
|
||||
+9
-10
@@ -24,20 +24,19 @@
|
||||
|
||||
CMD_FUNC(cmd_admin);
|
||||
|
||||
#define MSG_ADMIN "ADMIN"
|
||||
#define MSG_ADMIN "ADMIN"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"admin",
|
||||
"5.0",
|
||||
"command /admin",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"admin",
|
||||
"5.0",
|
||||
"command /admin",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CommandAdd(modinfo->handle, MSG_ADMIN, cmd_admin, MAXPARA, CMD_USER|CMD_SHUN|CMD_VIRUS);
|
||||
CommandAdd(modinfo->handle, MSG_ADMIN, cmd_admin, MAXPARA, CMD_USER | CMD_SHUN | CMD_VIRUS);
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
+20
-31
@@ -47,13 +47,12 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"antimixedutf8",
|
||||
"1.0",
|
||||
"Mixed UTF8 character filter (look-alike character spam) - by Syzop",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"antimixedutf8",
|
||||
"1.0",
|
||||
"Mixed UTF8 character filter (look-alike character spam) - by Syzop",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
struct {
|
||||
@@ -84,14 +83,13 @@ int antimixedutf8_check(Client *client, TextAnalysis *txa, const char **errmsg)
|
||||
unreal_log(ULOG_INFO, "antimixedutf8", "ANTIMIXEDUTF8_HIT", client,
|
||||
"[antimixedutf8] Client $client.details hit score $score -- taking action",
|
||||
log_data_integer("score", txa->antimixedutf8_points),
|
||||
log_data_textanalysis("text_analysis",txa));
|
||||
log_data_textanalysis("text_analysis", txa));
|
||||
/* Take the action */
|
||||
retval = take_action(client, cfg.ban_action, cfg.ban_reason, cfg.ban_time, 0, NULL);
|
||||
if ((retval == BAN_ACT_WARN) || (retval == BAN_ACT_SOFT_WARN))
|
||||
{
|
||||
/* no action */
|
||||
} else
|
||||
if ((retval == BAN_ACT_BLOCK) || (retval == BAN_ACT_SOFT_BLOCK))
|
||||
} else if ((retval == BAN_ACT_BLOCK) || (retval == BAN_ACT_SOFT_BLOCK))
|
||||
{
|
||||
*errmsg = cfg.ban_reason;
|
||||
return HOOK_DENY;
|
||||
@@ -182,36 +180,31 @@ int antimixedutf8_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *er
|
||||
if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
test_match_block(cf, cep, &errors);
|
||||
} else
|
||||
if (!cep->value)
|
||||
} else if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::antimixedutf8::%s with no value",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "score"))
|
||||
} else if (!strcmp(cep->name, "score"))
|
||||
{
|
||||
int v = atoi(cep->value);
|
||||
if ((v < 1) || (v > 99))
|
||||
{
|
||||
config_error("%s:%i: set::antimixedutf8::score: must be between 1 - 99 (got: %d)",
|
||||
cep->file->filename, cep->line_number, v);
|
||||
cep->file->filename, cep->line_number, v);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action"))
|
||||
} else if (!strcmp(cep->name, "ban-action"))
|
||||
{
|
||||
errors += test_ban_action_config(cep);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-reason"))
|
||||
} else if (!strcmp(cep->name, "ban-reason"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::antimixedutf8::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -235,20 +228,16 @@ int antimixedutf8_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (!strcmp(cep->name, "score"))
|
||||
{
|
||||
cfg.score = atoi(cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action"))
|
||||
} else if (!strcmp(cep->name, "ban-action"))
|
||||
{
|
||||
parse_ban_action_config(cep, &cfg.ban_action);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-reason"))
|
||||
} else if (!strcmp(cep->name, "ban-reason"))
|
||||
{
|
||||
safe_strdup(cfg.ban_reason, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
cfg.ban_time = config_checkval(cep->value, CFG_TIME);
|
||||
} else
|
||||
if (!strcmp(cep->name, "except"))
|
||||
} else if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
conf_match_block(cf, cep, &cfg.except);
|
||||
}
|
||||
|
||||
+78
-78
@@ -22,17 +22,16 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"antirandom",
|
||||
"1.5",
|
||||
"Detect and ban users with random names",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"antirandom",
|
||||
"1.5",
|
||||
"Detect and ban users with random names",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x,y) ((x) > (y) ? (x) : (y))
|
||||
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
/* "<char1><char2>" followed by "<rest>" */
|
||||
@@ -482,7 +481,7 @@ static char *triples_txt[] = {
|
||||
/* clang-format on */
|
||||
|
||||
/* Used for parsed triples: */
|
||||
#define TRIPLES_REST_SIZE 32
|
||||
#define TRIPLES_REST_SIZE 32
|
||||
typedef struct Triples Triples;
|
||||
struct Triples {
|
||||
Triples *next;
|
||||
@@ -576,21 +575,19 @@ int antirandom_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::antirandom... */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "antirandom"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
test_match_block(cf, cep, &errors);
|
||||
} else
|
||||
if (!strcmp(cep->name, "except-hosts"))
|
||||
} else if (!strcmp(cep->name, "except-hosts"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "except-webirc"))
|
||||
} else if (!strcmp(cep->name, "except-webirc"))
|
||||
{
|
||||
/* This should normally be UNDER the generic 'set::antirandom::%s with no value'
|
||||
* stuff but I put it here because people may think it's a hostlist and then
|
||||
@@ -602,39 +599,32 @@ int antirandom_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
if (!cep->value)
|
||||
} else if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::antirandom::%s with no value",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "threshold"))
|
||||
} else if (!strcmp(cep->name, "threshold"))
|
||||
{
|
||||
req.threshold = 1;
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "action"))
|
||||
} else if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "action"))
|
||||
{
|
||||
req.ban_action = 1;
|
||||
errors += test_ban_action_config(cep);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-reason"))
|
||||
} else if (!strcmp(cep->name, "ban-reason"))
|
||||
{
|
||||
req.ban_reason = 1;
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
req.ban_time = 1;
|
||||
} else
|
||||
if (!strcmp(cep->name, "convert-to-lowercase"))
|
||||
} else if (!strcmp(cep->name, "convert-to-lowercase"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "show-failedconnects"))
|
||||
} else if (!strcmp(cep->name, "show-failedconnects"))
|
||||
{
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::antirandom::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -648,45 +638,38 @@ int antirandom_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::antirandom... */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "antirandom"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
conf_match_block(cf, cep, &cfg.except);
|
||||
} else
|
||||
if (!strcmp(cep->name, "except-hosts"))
|
||||
} else if (!strcmp(cep->name, "except-hosts"))
|
||||
{
|
||||
/* backwards compatible with set::antirandom::except */
|
||||
for (cep2 = cep->items; cep2; cep2 = cep2->next)
|
||||
unreal_add_masks(&cfg.except->mask, cep2);
|
||||
} else
|
||||
if (!strcmp(cep->name, "except-webirc"))
|
||||
} else if (!strcmp(cep->name, "except-webirc"))
|
||||
{
|
||||
/* backwards compatible with set::antirandom::except */
|
||||
cfg.except->webirc = config_checkval(cep->value, CFG_YESNO);
|
||||
} else
|
||||
if (!strcmp(cep->name, "threshold"))
|
||||
} else if (!strcmp(cep->name, "threshold"))
|
||||
{
|
||||
cfg.threshold = atoi(cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "action"))
|
||||
} else if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "action"))
|
||||
{
|
||||
parse_ban_action_config(cep, &cfg.ban_action);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-reason"))
|
||||
} else if (!strcmp(cep->name, "ban-reason"))
|
||||
{
|
||||
safe_strdup(cfg.ban_reason, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
cfg.ban_time = config_checkval(cep->value, CFG_TIME);
|
||||
} else
|
||||
if (!strcmp(cep->name, "convert-to-lowercase"))
|
||||
} else if (!strcmp(cep->name, "convert-to-lowercase"))
|
||||
{
|
||||
cfg.convert_to_lowercase = config_checkval(cep->value, CFG_YESNO);
|
||||
}
|
||||
@@ -702,11 +685,27 @@ int antirandom_config_posttest(int *errs)
|
||||
{
|
||||
int errors = 0;
|
||||
|
||||
if (!req.threshold) { config_error("set::antirandom::threshold missing"); errors++; }
|
||||
if (!req.ban_action) { config_error("set::antirandom::ban-action missing"); errors++; }
|
||||
if (!req.ban_time) { config_error("set::antirandom::ban-time missing"); errors++; }
|
||||
if (!req.ban_reason) { config_error("set::antirandom::ban-reason missing"); errors++; }
|
||||
|
||||
if (!req.threshold)
|
||||
{
|
||||
config_error("set::antirandom::threshold missing");
|
||||
errors++;
|
||||
}
|
||||
if (!req.ban_action)
|
||||
{
|
||||
config_error("set::antirandom::ban-action missing");
|
||||
errors++;
|
||||
}
|
||||
if (!req.ban_time)
|
||||
{
|
||||
config_error("set::antirandom::ban-time missing");
|
||||
errors++;
|
||||
}
|
||||
if (!req.ban_reason)
|
||||
{
|
||||
config_error("set::antirandom::ban-reason missing");
|
||||
errors++;
|
||||
}
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -722,17 +721,17 @@ static int init_stuff(void)
|
||||
static int init_triples(void)
|
||||
{
|
||||
char **s;
|
||||
Triples *e, *last=NULL;
|
||||
int cnt=0;
|
||||
Triples *e, *last = NULL;
|
||||
int cnt = 0;
|
||||
|
||||
for (s=triples_txt; *s; s++)
|
||||
for (s = triples_txt; *s; s++)
|
||||
{
|
||||
cnt++;
|
||||
e = safe_alloc(sizeof(Triples));
|
||||
if (strlen(*s) > 2)
|
||||
{
|
||||
config_error("init_triples: error parsing triples_txt, cnt=%d, item='%s' (length>2)",
|
||||
cnt, *s);
|
||||
cnt, *s);
|
||||
return 0;
|
||||
}
|
||||
strcpy(e->two, *s); /* (SAFE) */
|
||||
@@ -740,13 +739,13 @@ static int init_triples(void)
|
||||
if (!*s)
|
||||
{
|
||||
config_error("init_triples: error parsing triples_txt, cnt=%d, got NULL expected param",
|
||||
cnt);
|
||||
cnt);
|
||||
return 0;
|
||||
}
|
||||
if (strlen(*s) > TRIPLES_REST_SIZE-1)
|
||||
if (strlen(*s) > TRIPLES_REST_SIZE - 1)
|
||||
{
|
||||
config_error("init_triples: error parsing triples_txt, cnt=%d, item='%s' (length>%d)",
|
||||
cnt, *s, TRIPLES_REST_SIZE-1);
|
||||
cnt, *s, TRIPLES_REST_SIZE - 1);
|
||||
return 0;
|
||||
}
|
||||
strcpy(e->rest, *s); /* (SAFE) */
|
||||
@@ -772,27 +771,30 @@ static int internal_getscore(char *str)
|
||||
Triples *t;
|
||||
register char *s;
|
||||
int score = 0;
|
||||
int highest_vowels=0, highest_consonants=0, highest_digits=0;
|
||||
int vowels=0, consonants=0, digits=0;
|
||||
int highest_vowels = 0, highest_consonants = 0, highest_digits = 0;
|
||||
int vowels = 0, consonants = 0, digits = 0;
|
||||
|
||||
/* Fast digit/consonant/vowel checks... */
|
||||
for (s=str; *s; s++)
|
||||
for (s = str; *s; s++)
|
||||
{
|
||||
if ((*s >= '0') && (*s <= '9'))
|
||||
digits++;
|
||||
else {
|
||||
else
|
||||
{
|
||||
highest_digits = MAX(highest_digits, digits);
|
||||
digits = 0;
|
||||
}
|
||||
if (strchr("bcdfghjklmnpqrstvwxz", *s))
|
||||
consonants++;
|
||||
else {
|
||||
else
|
||||
{
|
||||
highest_consonants = MAX(highest_consonants, consonants);
|
||||
consonants = 0;
|
||||
}
|
||||
if (strchr("aeiou", *s))
|
||||
vowels++;
|
||||
else {
|
||||
else
|
||||
{
|
||||
highest_vowels = MAX(highest_vowels, vowels);
|
||||
vowels = 0;
|
||||
}
|
||||
@@ -801,7 +803,7 @@ static int internal_getscore(char *str)
|
||||
digits = MAX(highest_digits, digits);
|
||||
consonants = MAX(highest_consonants, consonants);
|
||||
vowels = MAX(highest_vowels, vowels);
|
||||
|
||||
|
||||
if (digits >= 5)
|
||||
{
|
||||
score += digits;
|
||||
@@ -814,18 +816,17 @@ static int internal_getscore(char *str)
|
||||
{
|
||||
score += consonants;
|
||||
}
|
||||
|
||||
for (t=triples; t; t=t->next)
|
||||
|
||||
for (t = triples; t; t = t->next)
|
||||
{
|
||||
for (s=str; *s; s++)
|
||||
for (s = str; *s; s++)
|
||||
if ((t->two[0] == s[0]) && (t->two[1] == s[1]) && s[2] && strchr(t->rest, s[2]))
|
||||
{
|
||||
score++; /* OK */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
@@ -837,7 +838,7 @@ static int get_spam_score(Client *client)
|
||||
char *nick = client->name;
|
||||
char *user = client->user->username;
|
||||
char *gecos = client->info;
|
||||
char nbuf[NICKLEN+1], ubuf[USERLEN+1], rbuf[REALLEN+1];
|
||||
char nbuf[NICKLEN + 1], ubuf[USERLEN + 1], rbuf[REALLEN + 1];
|
||||
int nscore, uscore, gscore, score;
|
||||
|
||||
if (cfg.convert_to_lowercase)
|
||||
@@ -874,8 +875,7 @@ int antirandom_preconnect(Client *client)
|
||||
unreal_log(ULOG_INFO, "antirandom", "ANTIRANDOM_DENIED_USER", client,
|
||||
"[antirandom] would have denied access to user with score $score: $client.details:$client.user.realname",
|
||||
log_data_integer("score", score));
|
||||
} else
|
||||
if (n <= 0)
|
||||
} else if (n <= 0)
|
||||
{
|
||||
/* No action / exempt */
|
||||
} else
|
||||
@@ -883,8 +883,8 @@ int antirandom_preconnect(Client *client)
|
||||
if (cfg.show_failedconnects)
|
||||
{
|
||||
unreal_log(ULOG_INFO, "antirandom", "ANTIRANDOM_DENIED_USER", client,
|
||||
"[antirandom] denied access to user with score $score: $client.details:$client.user.realname",
|
||||
log_data_integer("score", score));
|
||||
"[antirandom] denied access to user with score $score: $client.details:$client.user.realname",
|
||||
log_data_integer("score", score));
|
||||
}
|
||||
return HOOK_DENY;
|
||||
}
|
||||
@@ -896,7 +896,7 @@ static void free_stuff(void)
|
||||
{
|
||||
Triples *t, *t_next;
|
||||
|
||||
for (t=triples; t; t=t_next)
|
||||
for (t = triples; t; t = t_next)
|
||||
{
|
||||
t_next = t->next;
|
||||
safe_free(t);
|
||||
|
||||
+36
-39
@@ -19,13 +19,12 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"authprompt",
|
||||
"1.0",
|
||||
"SASL authentication for clients that don't support SASL",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"authprompt",
|
||||
"1.0",
|
||||
"SASL authentication for clients that don't support SASL",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/** Configuration settings */
|
||||
@@ -62,9 +61,13 @@ CMD_FUNC(cmd_auth);
|
||||
void authprompt_md_free(ModData *md);
|
||||
|
||||
/* Some macros */
|
||||
#define SetAPUser(x, y) do { moddata_local_client(x, authprompt_md).ptr = y; } while(0)
|
||||
#define SEUSER(x) ((APUser *)moddata_local_client(x, authprompt_md).ptr)
|
||||
#define AGENT_SID(agent_p) (agent_p->user != NULL ? agent_p->user->server : agent_p->name)
|
||||
#define SetAPUser(x, y) \
|
||||
do \
|
||||
{ \
|
||||
moddata_local_client(x, authprompt_md).ptr = y; \
|
||||
} while (0)
|
||||
#define SEUSER(x) ((APUser *)moddata_local_client(x, authprompt_md).ptr)
|
||||
#define AGENT_SID(agent_p) (agent_p->user != NULL ? agent_p->user->server : agent_p->name)
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -167,24 +170,20 @@ int authprompt_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::authentication-prompt::%s with no value",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "enabled"))
|
||||
} else if (!strcmp(cep->name, "enabled"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "message"))
|
||||
} else if (!strcmp(cep->name, "message"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "fail-message"))
|
||||
} else if (!strcmp(cep->name, "fail-message"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "unconfirmed-message"))
|
||||
} else if (!strcmp(cep->name, "unconfirmed-message"))
|
||||
{
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::authentication-prompt::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -208,16 +207,13 @@ int authprompt_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (!strcmp(cep->name, "enabled"))
|
||||
{
|
||||
cfg.enabled = config_checkval(cep->value, CFG_YESNO);
|
||||
} else
|
||||
if (!strcmp(cep->name, "message"))
|
||||
} else if (!strcmp(cep->name, "message"))
|
||||
{
|
||||
addmultiline(&cfg.message, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "fail-message"))
|
||||
} else if (!strcmp(cep->name, "fail-message"))
|
||||
{
|
||||
addmultiline(&cfg.fail_message, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "unconfirmed-message"))
|
||||
} else if (!strcmp(cep->name, "unconfirmed-message"))
|
||||
{
|
||||
addmultiline(&cfg.unconfirmed_message, cep->value);
|
||||
}
|
||||
@@ -273,14 +269,14 @@ char *make_authbuf(const char *username, const char *password)
|
||||
int size;
|
||||
|
||||
size = strlen(username) + 1 + strlen(username) + 1 + strlen(password);
|
||||
if (size >= sizeof(inbuf)-1)
|
||||
if (size >= sizeof(inbuf) - 1)
|
||||
return NULL; /* too long */
|
||||
|
||||
/* Because size limits are already checked above, we can cut some corners here: */
|
||||
memset(inbuf, 0, sizeof(inbuf));
|
||||
strcpy(inbuf, username);
|
||||
strcpy(inbuf+strlen(username)+1, username);
|
||||
strcpy(inbuf+strlen(username)+1+strlen(username)+1, password);
|
||||
strcpy(inbuf + strlen(username) + 1, username);
|
||||
strcpy(inbuf + strlen(username) + 1 + strlen(username) + 1, password);
|
||||
/* ^ normal people use stpcpy here ;) */
|
||||
|
||||
if (b64_encode(inbuf, size, outbuf, sizeof(outbuf)) < 0)
|
||||
@@ -309,22 +305,23 @@ void send_first_auth(Client *client)
|
||||
/* Make them a user, needed for CHGHOST etc that we may receive */
|
||||
if (!client->user)
|
||||
make_user(client);
|
||||
|
||||
|
||||
if (Hooks[HOOKTYPE_SASL_AUTHENTICATE] && (find_client(SASL_SERVER, NULL) == &me))
|
||||
{
|
||||
/* We are the SASL server (some module handling auth) */
|
||||
RunHook(HOOKTYPE_SASL_AUTHENTICATE, client, 1, "PLAIN");
|
||||
RunHook(HOOKTYPE_SASL_AUTHENTICATE, client, 0, SEUSER(client)->authmsg);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
sendto_one(sasl_server, NULL, ":%s SASL %s %s H %s %s",
|
||||
me.id, SASL_SERVER, client->id, addr, addr);
|
||||
me.id, SASL_SERVER, client->id, addr, addr);
|
||||
|
||||
if (certfp)
|
||||
sendto_one(sasl_server, NULL, ":%s SASL %s %s S %s %s",
|
||||
me.id, SASL_SERVER, client->id, "PLAIN", certfp);
|
||||
me.id, SASL_SERVER, client->id, "PLAIN", certfp);
|
||||
else
|
||||
sendto_one(sasl_server, NULL, ":%s SASL %s %s S %s",
|
||||
me.id, SASL_SERVER, client->id, "PLAIN");
|
||||
me.id, SASL_SERVER, client->id, "PLAIN");
|
||||
}
|
||||
/* The rest is sent from authprompt_sasl_continuation() */
|
||||
|
||||
@@ -426,10 +423,10 @@ int authprompt_find_tkline_match(Client *client, TKL *tkl)
|
||||
* and the user is not yet online, then we will handle this user.
|
||||
*/
|
||||
if (cfg.enabled &&
|
||||
TKLIsServerBan(tkl) &&
|
||||
(tkl->ptr.serverban->subtype & TKL_SUBTYPE_SOFT) &&
|
||||
!IsLoggedIn(client) &&
|
||||
!IsUser(client))
|
||||
TKLIsServerBan(tkl) &&
|
||||
(tkl->ptr.serverban->subtype & TKL_SUBTYPE_SOFT) &&
|
||||
!IsLoggedIn(client) &&
|
||||
!IsUser(client))
|
||||
{
|
||||
/* And tag the user */
|
||||
authprompt_tag_as_auth_required(client, tkl->ptr.serverban->reason);
|
||||
@@ -463,7 +460,7 @@ int authprompt_sasl_continuation(Client *client, const char *buf)
|
||||
if (agent)
|
||||
{
|
||||
sendto_one(agent, NULL, ":%s SASL %s %s C %s",
|
||||
me.id, AGENT_SID(agent), client->id, SEUSER(client)->authmsg);
|
||||
me.id, AGENT_SID(agent), client->id, SEUSER(client)->authmsg);
|
||||
}
|
||||
safe_free(SEUSER(client)->authmsg);
|
||||
}
|
||||
|
||||
+12
-13
@@ -29,16 +29,15 @@ int away_join(Client *client, Channel *channel, MessageTag *mtags);
|
||||
|
||||
long CAP_AWAY_NOTIFY = 0L;
|
||||
|
||||
#define MSG_AWAY "AWAY"
|
||||
#define MSG_AWAY "AWAY"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"away",
|
||||
"5.0",
|
||||
"command /away",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"away",
|
||||
"5.0",
|
||||
"command /away",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
@@ -46,7 +45,7 @@ MOD_INIT()
|
||||
memset(&c, 0, sizeof(c));
|
||||
c.name = "away-notify";
|
||||
ClientCapabilityAdd(modinfo->handle, &c, &CAP_AWAY_NOTIFY);
|
||||
CommandAdd(modinfo->handle, MSG_AWAY, cmd_away, 1, CMD_USER|CMD_TEXTANALYSIS);
|
||||
CommandAdd(modinfo->handle, MSG_AWAY, cmd_away, 1, CMD_USER | CMD_TEXTANALYSIS);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_LOCAL_JOIN, 0, away_join);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_REMOTE_JOIN, 0, away_join);
|
||||
|
||||
@@ -137,7 +136,7 @@ CMD_FUNC(cmd_away)
|
||||
|
||||
/* Check away-flood */
|
||||
if (MyUser(client) &&
|
||||
!ValidatePermissionsForPath("immune:away-flood",client,NULL,NULL,NULL) &&
|
||||
!ValidatePermissionsForPath("immune:away-flood", client, NULL, NULL, NULL) &&
|
||||
flood_limit_exceeded(client, FLD_AWAY))
|
||||
{
|
||||
sendnumeric(client, ERR_TOOMANYAWAY);
|
||||
@@ -153,7 +152,7 @@ CMD_FUNC(cmd_away)
|
||||
client->user->away_since = t;
|
||||
else
|
||||
client->user->away_since = TStime();
|
||||
|
||||
|
||||
new_message(client, recv_mtags, &mtags);
|
||||
|
||||
sendto_server(client, 0, 0, mtags, ":%s AWAY :%s", client->id, reason);
|
||||
@@ -163,7 +162,7 @@ CMD_FUNC(cmd_away)
|
||||
safe_free(client->user->away);
|
||||
already_as_away = 1;
|
||||
}
|
||||
|
||||
|
||||
safe_strdup(client->user->away, reason);
|
||||
|
||||
if (MyConnect(client))
|
||||
|
||||
+10
-10
@@ -22,14 +22,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"batch",
|
||||
"5.0",
|
||||
"Batch CAP",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"batch",
|
||||
"5.0",
|
||||
"Batch CAP",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
CMD_FUNC(cmd_batch);
|
||||
@@ -57,7 +56,7 @@ MOD_INIT()
|
||||
mtag.clicap_handler = c;
|
||||
MessageTagHandlerAdd(modinfo->handle, &mtag);
|
||||
|
||||
CommandAdd(modinfo->handle, "BATCH", cmd_batch, MAXPARA, CMD_USER|CMD_SERVER);
|
||||
CommandAdd(modinfo->handle, "BATCH", cmd_batch, MAXPARA, CMD_USER | CMD_SERVER);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -116,7 +115,8 @@ CMD_FUNC(cmd_batch)
|
||||
parv[1] = "BATCH";
|
||||
concat_params(buf, sizeof(buf), parc, parv);
|
||||
sendto_prefix_one(target, client, recv_mtags, ":%s %s", client->name, buf);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Relay the batch message to the server */
|
||||
concat_params(buf, sizeof(buf), parc, parv);
|
||||
sendto_prefix_one(target, client, recv_mtags, ":%s BATCH %s", client->name, buf);
|
||||
|
||||
+119
-132
@@ -19,13 +19,12 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"blacklist",
|
||||
"5.0",
|
||||
"Check connecting users against DNS Blacklists",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"blacklist",
|
||||
"5.0",
|
||||
"Check connecting users against DNS Blacklists",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* In this module and the config syntax I tried to 'abstract' things
|
||||
@@ -40,13 +39,18 @@ static long BLACKLIST_RECHECK_TIME_FIRST = 120;
|
||||
/* After that, check every <this>: */
|
||||
static long BLACKLIST_RECHECK_TIME = 900;
|
||||
|
||||
#define LastBLCheck(x) (moddata_local_client(x, blacklistrecheck_md).l)
|
||||
#define SetLastBLCheck(x, y) do { moddata_local_client(x, blacklistrecheck_md).l = y; } while(0)
|
||||
#define LastBLCheck(x) (moddata_local_client(x, blacklistrecheck_md).l)
|
||||
#define SetLastBLCheck(x, y) \
|
||||
do \
|
||||
{ \
|
||||
moddata_local_client(x, blacklistrecheck_md).l = y; \
|
||||
} while (0)
|
||||
|
||||
/* Types */
|
||||
|
||||
typedef enum {
|
||||
DNSBL_RECORD=1, DNSBL_BITMASK=2
|
||||
DNSBL_RECORD = 1,
|
||||
DNSBL_BITMASK = 2
|
||||
} DNSBLType;
|
||||
|
||||
typedef struct DNSBL DNSBL;
|
||||
@@ -57,8 +61,7 @@ struct DNSBL {
|
||||
};
|
||||
|
||||
typedef union BlacklistBackend BlacklistBackend;
|
||||
union BlacklistBackend
|
||||
{
|
||||
union BlacklistBackend {
|
||||
DNSBL *dns;
|
||||
};
|
||||
|
||||
@@ -124,8 +127,12 @@ void blacklist_set_handshake_delay(void);
|
||||
void blacklist_free_bluser_if_able(BLUser *bl);
|
||||
EVENT(blacklist_recheck);
|
||||
|
||||
#define SetBLUser(x, y) do { moddata_local_client(x, blacklist_md).ptr = y; } while(0)
|
||||
#define BLUSER(x) ((BLUser *)moddata_local_client(x, blacklist_md).ptr)
|
||||
#define SetBLUser(x, y) \
|
||||
do \
|
||||
{ \
|
||||
moddata_local_client(x, blacklist_md).ptr = y; \
|
||||
} while (0)
|
||||
#define BLUSER(x) ((BLUser *)moddata_local_client(x, blacklist_md).ptr)
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -142,7 +149,7 @@ MOD_INIT()
|
||||
ModDataInfo mreq;
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
|
||||
memset(&mreq, 0, sizeof(mreq));
|
||||
mreq.name = "blacklist";
|
||||
mreq.type = MODDATATYPE_LOCAL_CLIENT;
|
||||
@@ -225,7 +232,7 @@ void blacklist_set_handshake_delay(void)
|
||||
Blacklist *blacklist_find_block_by_dns(char *name)
|
||||
{
|
||||
Blacklist *d;
|
||||
|
||||
|
||||
for (d = conf_blacklist; d; d = d->next)
|
||||
if ((d->backend_type == BLACKLIST_BACKEND_DNS) && !strcmp(name, d->backend->dns->name))
|
||||
return d;
|
||||
@@ -256,7 +263,7 @@ void delete_blacklist_block(Blacklist *e)
|
||||
safe_free(e->backend->dns);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
safe_free(e->backend);
|
||||
|
||||
safe_free(e->name);
|
||||
@@ -269,24 +276,24 @@ void delete_blacklist_block(Blacklist *e)
|
||||
|
||||
int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
{
|
||||
ConfigEntry *cep, *cepp, *ceppp;
|
||||
ConfigEntry *cep, *cepp, *ceppp;
|
||||
int errors = 0;
|
||||
char has_reason = 0, has_ban_time = 0, has_action = 0;
|
||||
char has_dns_type = 0, has_dns_reply = 0, has_dns_name = 0, has_recheck = 0;
|
||||
|
||||
if (type != CONFIG_MAIN)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!ce)
|
||||
return 0;
|
||||
|
||||
|
||||
if (strcmp(ce->name, "blacklist"))
|
||||
return 0; /* not interested in non-blacklist stuff.. */
|
||||
|
||||
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error("%s:%i: blacklist block without name (use: blacklist somename { })",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
*errs = 1;
|
||||
return -1;
|
||||
}
|
||||
@@ -304,8 +311,8 @@ int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
{
|
||||
/* this is an error (not a warning) */
|
||||
config_error("%s:%i: blacklist block may contain only one blacklist::dns::reply item. "
|
||||
"You can specify multiple replies by using: reply { 1; 2; 4; };",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
"You can specify multiple replies by using: reply { 1; 2; 4; };",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -319,8 +326,8 @@ int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (cepp->value && cepp->items)
|
||||
{
|
||||
config_error("%s:%i: blacklist::dns::reply must be either using format 'reply 1;' or "
|
||||
"'reply { 1; 2; 4; }; but not both formats at the same time.",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
"'reply { 1; 2; 4; }; but not both formats at the same time.",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -329,46 +336,43 @@ int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (atoi(cepp->value) <= 0)
|
||||
{
|
||||
config_error("%s:%i: blacklist::dns::reply must be >0",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (cepp->items)
|
||||
{
|
||||
for (ceppp = cepp->items; ceppp; ceppp=ceppp->next)
|
||||
for (ceppp = cepp->items; ceppp; ceppp = ceppp->next)
|
||||
{
|
||||
if (atoi(ceppp->name) <= 0)
|
||||
{
|
||||
config_error("%s:%i: all items in blacklist::dns::reply must be >0",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!cepp->value)
|
||||
} else if (!cepp->value)
|
||||
{
|
||||
config_error_empty(cepp->file->filename, cepp->line_number,
|
||||
"blacklist::dns", cepp->name);
|
||||
"blacklist::dns", cepp->name);
|
||||
errors++;
|
||||
continue;
|
||||
} else
|
||||
if (!strcmp(cepp->name, "name"))
|
||||
} else if (!strcmp(cepp->name, "name"))
|
||||
{
|
||||
if (has_dns_name)
|
||||
{
|
||||
config_warn_duplicate(cepp->file->filename,
|
||||
cepp->line_number, "blacklist::dns::name");
|
||||
cepp->line_number, "blacklist::dns::name");
|
||||
}
|
||||
has_dns_name = 1;
|
||||
} else
|
||||
if (!strcmp(cepp->name, "type"))
|
||||
} else if (!strcmp(cepp->name, "type"))
|
||||
{
|
||||
if (has_dns_type)
|
||||
{
|
||||
config_warn_duplicate(cepp->file->filename,
|
||||
cepp->line_number, "blacklist::dns::type");
|
||||
cepp->line_number, "blacklist::dns::type");
|
||||
}
|
||||
has_dns_type = 1;
|
||||
if (!strcmp(cepp->value, "record"))
|
||||
@@ -378,68 +382,61 @@ int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
else
|
||||
{
|
||||
config_error("%s:%i: unknown blacklist::dns::type '%s', must be either 'record' or 'bitmask'",
|
||||
cepp->file->filename, cepp->line_number, cepp->value);
|
||||
cepp->file->filename, cepp->line_number, cepp->value);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "except"))
|
||||
} else if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
test_match_block(cf, cep, &errors);
|
||||
} else
|
||||
if (!cep->value)
|
||||
} else if (!cep->value)
|
||||
{
|
||||
config_error_empty(cep->file->filename, cep->line_number,
|
||||
"blacklist", cep->name);
|
||||
"blacklist", cep->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
else if (!strcmp(cep->name, "action"))
|
||||
} else if (!strcmp(cep->name, "action"))
|
||||
{
|
||||
if (has_action)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "blacklist::action");
|
||||
cep->line_number, "blacklist::action");
|
||||
continue;
|
||||
}
|
||||
has_action = 1;
|
||||
errors += test_ban_action_config(cep);
|
||||
}
|
||||
else if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
if (has_ban_time)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "blacklist::ban-time");
|
||||
cep->line_number, "blacklist::ban-time");
|
||||
continue;
|
||||
}
|
||||
has_ban_time = 1;
|
||||
}
|
||||
else if (!strcmp(cep->name, "reason"))
|
||||
} else if (!strcmp(cep->name, "reason"))
|
||||
{
|
||||
if (has_reason)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "blacklist::reason");
|
||||
cep->line_number, "blacklist::reason");
|
||||
continue;
|
||||
}
|
||||
has_reason = 1;
|
||||
}
|
||||
else if (!strcmp(cep->name, "recheck"))
|
||||
} else if (!strcmp(cep->name, "recheck"))
|
||||
{
|
||||
if (has_recheck)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "blacklist::recheck");
|
||||
cep->line_number, "blacklist::recheck");
|
||||
continue;
|
||||
}
|
||||
has_recheck = 1;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename, cep->line_number,
|
||||
"blacklist", cep->name);
|
||||
"blacklist", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -447,35 +444,35 @@ int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!has_action)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"blacklist::action");
|
||||
"blacklist::action");
|
||||
errors++;
|
||||
}
|
||||
|
||||
if (!has_reason)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"blacklist::reason");
|
||||
"blacklist::reason");
|
||||
errors++;
|
||||
}
|
||||
|
||||
if (!has_dns_name)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"blacklist::dns::name");
|
||||
"blacklist::dns::name");
|
||||
errors++;
|
||||
}
|
||||
|
||||
if (!has_dns_type)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"blacklist::dns::type");
|
||||
"blacklist::dns::type");
|
||||
errors++;
|
||||
}
|
||||
|
||||
if (!has_dns_reply)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"blacklist::dns::reply");
|
||||
"blacklist::dns::reply");
|
||||
errors++;
|
||||
}
|
||||
|
||||
@@ -487,10 +484,10 @@ int blacklist_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
{
|
||||
ConfigEntry *cep, *cepp, *ceppp;
|
||||
Blacklist *d = NULL;
|
||||
|
||||
|
||||
if (type != CONFIG_MAIN)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!ce || !ce->name || strcmp(ce->name, "blacklist"))
|
||||
return 0; /* not interested */
|
||||
|
||||
@@ -499,7 +496,7 @@ int blacklist_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
/* set some defaults */
|
||||
d->ban_time = 3600;
|
||||
d->recheck = 1;
|
||||
|
||||
|
||||
/* assume dns for now ;) */
|
||||
d->backend_type = BLACKLIST_BACKEND_DNS;
|
||||
d->backend = safe_alloc(sizeof(BlacklistBackend));
|
||||
@@ -516,11 +513,10 @@ int blacklist_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (cepp->value)
|
||||
{
|
||||
/* single reply */
|
||||
d->backend->dns->reply = safe_alloc(sizeof(int)*2);
|
||||
d->backend->dns->reply = safe_alloc(sizeof(int) * 2);
|
||||
d->backend->dns->reply[0] = atoi(cepp->value);
|
||||
d->backend->dns->reply[1] = 0;
|
||||
} else
|
||||
if (cepp->items)
|
||||
} else if (cepp->items)
|
||||
{
|
||||
/* (potentially) multiple reply values */
|
||||
int cnt = 0;
|
||||
@@ -529,12 +525,12 @@ int blacklist_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (ceppp->name)
|
||||
cnt++;
|
||||
}
|
||||
|
||||
|
||||
if (cnt == 0)
|
||||
abort(); /* impossible */
|
||||
|
||||
d->backend->dns->reply = safe_alloc(sizeof(int)*(cnt+1));
|
||||
|
||||
|
||||
d->backend->dns->reply = safe_alloc(sizeof(int) * (cnt + 1));
|
||||
|
||||
cnt = 0;
|
||||
for (ceppp = cepp->items; ceppp; ceppp = ceppp->next)
|
||||
{
|
||||
@@ -542,44 +538,37 @@ int blacklist_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
}
|
||||
d->backend->dns->reply[cnt] = 0;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cepp->name, "type"))
|
||||
} else if (!strcmp(cepp->name, "type"))
|
||||
{
|
||||
if (!strcmp(cepp->value, "record"))
|
||||
d->backend->dns->type = DNSBL_RECORD;
|
||||
else if (!strcmp(cepp->value, "bitmask"))
|
||||
d->backend->dns->type = DNSBL_BITMASK;
|
||||
} else
|
||||
if (!strcmp(cepp->name, "name"))
|
||||
} else if (!strcmp(cepp->name, "name"))
|
||||
{
|
||||
safe_strdup(d->backend->dns->name, cepp->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcmp(cep->name, "action"))
|
||||
} else if (!strcmp(cep->name, "action"))
|
||||
{
|
||||
parse_ban_action_config(cep, &d->action);
|
||||
}
|
||||
else if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
d->ban_time = config_checkval(cep->value, CFG_TIME);
|
||||
}
|
||||
else if (!strcmp(cep->name, "reason"))
|
||||
} else if (!strcmp(cep->name, "reason"))
|
||||
{
|
||||
safe_strdup(d->reason, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "except"))
|
||||
} else if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
conf_match_block(cf, cep, &d->except);
|
||||
}
|
||||
else if (!strcmp(cep->name, "recheck"))
|
||||
} else if (!strcmp(cep->name, "recheck"))
|
||||
{
|
||||
d->recheck = config_checkval(cep->value, CFG_YESNO);
|
||||
}
|
||||
}
|
||||
|
||||
AddListItem(d, conf_blacklist);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -591,11 +580,11 @@ int blacklist_set_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *er
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::blacklist.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "blacklist"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "recheck-time-first"))
|
||||
@@ -604,7 +593,7 @@ int blacklist_set_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *er
|
||||
if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::blacklist::recheck-time-first with no value",
|
||||
cep->file->filename, cep->line_number);
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -621,17 +610,16 @@ int blacklist_set_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *er
|
||||
if (v < 60)
|
||||
{
|
||||
config_error("%s:%i: set::blacklist::recheck-time-first cannot be less than 60 seconds",
|
||||
cep->file->filename, cep->line_number);
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "recheck-time"))
|
||||
} else if (!strcmp(cep->name, "recheck-time"))
|
||||
{
|
||||
int v;
|
||||
if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::blacklist::recheck-time with no value",
|
||||
cep->file->filename, cep->line_number);
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -641,19 +629,19 @@ int blacklist_set_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *er
|
||||
if (v < 60)
|
||||
{
|
||||
config_error("%s:%i: set::blacklist::recheck-time cannot be less than 60 seconds",
|
||||
cep->file->filename, cep->line_number);
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::blacklist::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -665,11 +653,11 @@ int blacklist_set_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::blacklist.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "blacklist"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "recheck-time"))
|
||||
@@ -739,7 +727,7 @@ int blacklist_start_check(Client *client, int recheck)
|
||||
if (bl->backend_type == BLACKLIST_BACKEND_DNS)
|
||||
blacklist_dns_request(client, bl);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -748,7 +736,7 @@ int blacklist_dns_request(Client *client, Blacklist *d)
|
||||
char buf[256], wbuf[128];
|
||||
unsigned int e[8];
|
||||
char *ip = GetIP(client);
|
||||
|
||||
|
||||
if (!ip)
|
||||
return 0;
|
||||
|
||||
@@ -759,16 +747,15 @@ int blacklist_dns_request(Client *client, Blacklist *d)
|
||||
/* IPv4 */
|
||||
if (sscanf(ip, "%u.%u.%u.%u", &e[0], &e[1], &e[2], &e[3]) != 4)
|
||||
return 0;
|
||||
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u.%u.%u.%u.%s", e[3], e[2], e[1], e[0], d->backend->dns->name);
|
||||
} else
|
||||
if (strchr(ip, ':'))
|
||||
} else if (strchr(ip, ':'))
|
||||
{
|
||||
/* IPv6 */
|
||||
int i;
|
||||
BLUSER(client)->is_ipv6 = 1;
|
||||
if (sscanf(ip, "%x:%x:%x:%x:%x:%x:%x:%x",
|
||||
&e[0], &e[1], &e[2], &e[3], &e[4], &e[5], &e[6], &e[7]) != 8)
|
||||
&e[0], &e[1], &e[2], &e[3], &e[4], &e[5], &e[6], &e[7]) != 8)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -776,21 +763,20 @@ int blacklist_dns_request(Client *client, Blacklist *d)
|
||||
for (i = 7; i >= 0; i--)
|
||||
{
|
||||
snprintf(wbuf, sizeof(wbuf), "%x.%x.%x.%x.",
|
||||
(unsigned int)(e[i] & 0xf),
|
||||
(unsigned int)((e[i] >> 4) & 0xf),
|
||||
(unsigned int)((e[i] >> 8) & 0xf),
|
||||
(unsigned int)((e[i] >> 12) & 0xf));
|
||||
(unsigned int)(e[i] & 0xf),
|
||||
(unsigned int)((e[i] >> 4) & 0xf),
|
||||
(unsigned int)((e[i] >> 8) & 0xf),
|
||||
(unsigned int)((e[i] >> 12) & 0xf));
|
||||
strlcat(buf, wbuf, sizeof(buf));
|
||||
}
|
||||
strlcat(buf, d->backend->dns->name, sizeof(buf));
|
||||
}
|
||||
else
|
||||
} else
|
||||
return 0; /* unknown IP format */
|
||||
|
||||
BLUSER(client)->refcnt++; /* one (more) blacklist result remaining */
|
||||
|
||||
|
||||
unreal_gethostbyname_api(buf, AF_INET, "blacklist_resolver_callback", BLUSER(client));
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -850,7 +836,7 @@ char *getdnsblname(char *p, Client *client)
|
||||
{
|
||||
dots++;
|
||||
if (dots == dots_count)
|
||||
return p+1;
|
||||
return p + 1;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -870,12 +856,12 @@ int blacklist_parse_reply(struct hostent *he, int entry)
|
||||
*ipbuf = '\0';
|
||||
if (!inet_ntop(AF_INET, he->h_addr_list[entry], ipbuf, sizeof(ipbuf)))
|
||||
return 0;
|
||||
|
||||
|
||||
p = strrchr(ipbuf, '.');
|
||||
if (!p)
|
||||
return 0;
|
||||
|
||||
return atoi(p+1);
|
||||
|
||||
return atoi(p + 1);
|
||||
}
|
||||
|
||||
/** Take the actual ban action.
|
||||
@@ -908,10 +894,10 @@ void blacklist_hit(Client *client, Blacklist *bl, int reply)
|
||||
|
||||
if (IsUser(client))
|
||||
snprintf(opernotice, sizeof(opernotice), "[Blacklist] IP %s (%s) matches blacklist %s (%s/reply=%d)",
|
||||
GetIP(client), client->name, bl->name, bl->backend->dns->name, reply);
|
||||
GetIP(client), client->name, bl->name, bl->backend->dns->name, reply);
|
||||
else
|
||||
snprintf(opernotice, sizeof(opernotice), "[Blacklist] IP %s matches blacklist %s (%s/reply=%d)",
|
||||
GetIP(client), bl->name, bl->backend->dns->name, reply);
|
||||
GetIP(client), bl->name, bl->backend->dns->name, reply);
|
||||
|
||||
snprintf(reply_num, sizeof(reply_num), "%d", reply);
|
||||
|
||||
@@ -934,7 +920,8 @@ void blacklist_hit(Client *client, Blacklist *bl, int reply)
|
||||
safe_strdup(blu->save_blacklist_dns_name, bl->backend->dns->name);
|
||||
blu->save_blacklist_dns_reply = reply;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Otherwise, execute the action immediately */
|
||||
blacklist_action(client, opernotice, bl->action, banbuf, bl->ban_time, bl->name, bl->backend->dns->name, reply);
|
||||
}
|
||||
@@ -947,27 +934,27 @@ void blacklist_process_result(Client *client, int status, struct hostent *he)
|
||||
int reply;
|
||||
int i;
|
||||
int replycnt;
|
||||
|
||||
|
||||
if ((status != 0) || (he->h_length != 4) || !he->h_name)
|
||||
return; /* invalid reply */
|
||||
|
||||
|
||||
domain = getdnsblname(he->h_name, client);
|
||||
if (!domain)
|
||||
return; /* odd */
|
||||
bl = blacklist_find_block_by_dns(domain);
|
||||
if (!bl)
|
||||
return; /* possibly just rehashed and the blacklist block is gone now */
|
||||
|
||||
|
||||
/* walk through all replies for this record... until we have a hit */
|
||||
for (replycnt=0; he->h_addr_list[replycnt]; replycnt++)
|
||||
for (replycnt = 0; he->h_addr_list[replycnt]; replycnt++)
|
||||
{
|
||||
reply = blacklist_parse_reply(he, replycnt);
|
||||
|
||||
for (i = 0; bl->backend->dns->reply[i]; i++)
|
||||
{
|
||||
if ((bl->backend->dns->reply[i] == -1) ||
|
||||
( (bl->backend->dns->type == DNSBL_BITMASK) && (reply & bl->backend->dns->reply[i]) ) ||
|
||||
( (bl->backend->dns->type == DNSBL_RECORD) && (bl->backend->dns->reply[i] == reply) ) )
|
||||
((bl->backend->dns->type == DNSBL_BITMASK) && (reply & bl->backend->dns->reply[i])) ||
|
||||
((bl->backend->dns->type == DNSBL_RECORD) && (bl->backend->dns->reply[i] == reply)))
|
||||
{
|
||||
blacklist_hit(client, bl, reply);
|
||||
return;
|
||||
@@ -1043,9 +1030,9 @@ EVENT(blacklist_recheck)
|
||||
/* First time: check after 60 seconds already */
|
||||
blacklist_recheck_user(client);
|
||||
} else /* After that, check every <...> seconds */
|
||||
if (last_check && (TStime() - last_check) >= BLACKLIST_RECHECK_TIME)
|
||||
{
|
||||
blacklist_recheck_user(client);
|
||||
}
|
||||
if (last_check && (TStime() - last_check) >= BLACKLIST_RECHECK_TIME)
|
||||
{
|
||||
blacklist_recheck_user(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"bot-tag",
|
||||
"5.0",
|
||||
"bot message tag",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"bot-tag",
|
||||
"5.0",
|
||||
"bot message tag",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
int bottag_mtag_is_ok(Client *client, const char *name, const char *value);
|
||||
void mtag_add_bottag(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
|
||||
|
||||
+9
-10
@@ -24,20 +24,19 @@
|
||||
|
||||
CMD_FUNC(cmd_botmotd);
|
||||
|
||||
#define MSG_BOTMOTD "BOTMOTD"
|
||||
#define MSG_BOTMOTD "BOTMOTD"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"botmotd",
|
||||
"5.0",
|
||||
"command /botmotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"botmotd",
|
||||
"5.0",
|
||||
"command /botmotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CommandAdd(modinfo->handle, MSG_BOTMOTD, cmd_botmotd, MAXPARA, CMD_USER|CMD_SERVER);
|
||||
CommandAdd(modinfo->handle, MSG_BOTMOTD, cmd_botmotd, MAXPARA, CMD_USER | CMD_SERVER);
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
+24
-27
@@ -26,16 +26,15 @@ typedef int (*bqcmp)(const void *, const void *);
|
||||
|
||||
CMD_FUNC(cmd_cap);
|
||||
|
||||
#define MSG_CAP "CAP"
|
||||
#define MSG_CAP "CAP"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"cap", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"command /cap", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"cap", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"command /cap", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cap_is_handshake_finished(Client *client);
|
||||
@@ -48,9 +47,9 @@ long CAP_NOTIFY = 0L;
|
||||
MOD_INIT()
|
||||
{
|
||||
ClientCapabilityInfo c;
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
CommandAdd(modinfo->handle, MSG_CAP, cmd_cap, MAXPARA, CMD_UNREGISTERED|CMD_USER|CMD_NOLAG);
|
||||
CommandAdd(modinfo->handle, MSG_CAP, cmd_cap, MAXPARA, CMD_UNREGISTERED | CMD_USER | CMD_NOLAG);
|
||||
|
||||
/* This first cap is special, in the sense that it is hidden
|
||||
* and indicates a cap exchange is in progress.
|
||||
@@ -100,7 +99,7 @@ static ClientCapability *clicap_find(Client *client, const char *data, int *nega
|
||||
return NULL;
|
||||
|
||||
/* skip any whitespace */
|
||||
while(*p && isspace(*p))
|
||||
while (*p && isspace(*p))
|
||||
p++;
|
||||
|
||||
if (BadPtr(p))
|
||||
@@ -125,7 +124,7 @@ static ClientCapability *clicap_find(Client *client, const char *data, int *nega
|
||||
cap = ClientCapabilityFind(p, client);
|
||||
if (!s)
|
||||
*finished = 1;
|
||||
|
||||
|
||||
p = s; /* point to next token for next iteration */
|
||||
|
||||
if (cap && (cap->flags & CLICAP_FLAGS_ADVERTISE_ONLY))
|
||||
@@ -146,7 +145,7 @@ static void clicap_generate(Client *client, const char *subcmd, int flags)
|
||||
int buflen = 0;
|
||||
int curlen, mlen;
|
||||
|
||||
mlen = snprintf(buf, BUFSIZE, ":%s CAP %s %s", me.name, BadPtr(client->name) ? "*" : client->name, subcmd);
|
||||
mlen = snprintf(buf, BUFSIZE, ":%s CAP %s %s", me.name, BadPtr(client->name) ? "*" : client->name, subcmd);
|
||||
|
||||
p = capbuf;
|
||||
buflen = mlen;
|
||||
@@ -259,13 +258,13 @@ static void cap_req(Client *client, const char *arg)
|
||||
return;
|
||||
|
||||
buflen = snprintf(buf, sizeof(buf), ":%s CAP %s ACK",
|
||||
me.name, BadPtr(client->name) ? "*" : client->name);
|
||||
me.name, BadPtr(client->name) ? "*" : client->name);
|
||||
|
||||
pbuf[0][0] = '\0';
|
||||
plen = 0;
|
||||
|
||||
for(cap = clicap_find(client, arg, &negate, &finished, &errors); cap;
|
||||
cap = clicap_find(client, NULL, &negate, &finished, &errors))
|
||||
for (cap = clicap_find(client, arg, &negate, &finished, &errors); cap;
|
||||
cap = clicap_find(client, NULL, &negate, &finished, &errors))
|
||||
{
|
||||
/* filled the first array, but cant send it in case the
|
||||
* request fails. one REQ should never fill more than two
|
||||
@@ -284,8 +283,7 @@ static void cap_req(Client *client, const char *arg)
|
||||
plen++;
|
||||
|
||||
capdel |= cap->cap;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
capadd |= cap->cap;
|
||||
}
|
||||
@@ -309,8 +307,7 @@ static void cap_req(Client *client, const char *arg)
|
||||
{
|
||||
sendto_one(client, NULL, "%s * :%s", buf, pbuf[0]);
|
||||
sendto_one(client, NULL, "%s :%s", buf, pbuf[1]);
|
||||
}
|
||||
else
|
||||
} else
|
||||
sendto_one(client, NULL, "%s :%s", buf, pbuf[0]);
|
||||
|
||||
client->local->caps |= capadd;
|
||||
@@ -323,10 +320,10 @@ struct clicap_cmd {
|
||||
};
|
||||
|
||||
static struct clicap_cmd clicap_cmdtable[] = {
|
||||
{ "END", cap_end },
|
||||
{ "LIST", cap_list },
|
||||
{ "LS", cap_ls },
|
||||
{ "REQ", cap_req },
|
||||
{"END", cap_end},
|
||||
{"LIST", cap_list},
|
||||
{"LS", cap_ls},
|
||||
{"REQ", cap_req},
|
||||
};
|
||||
|
||||
static int clicap_cmd_search(const char *command, struct clicap_cmd *entry)
|
||||
@@ -380,8 +377,8 @@ CMD_FUNC(cmd_cap)
|
||||
}
|
||||
|
||||
if (!(cmd = bsearch(parv[1], clicap_cmdtable,
|
||||
sizeof(clicap_cmdtable) / sizeof(struct clicap_cmd),
|
||||
sizeof(struct clicap_cmd), (bqcmp) clicap_cmd_search)))
|
||||
sizeof(clicap_cmdtable) / sizeof(struct clicap_cmd),
|
||||
sizeof(struct clicap_cmd), (bqcmp)clicap_cmd_search)))
|
||||
{
|
||||
sendnumeric(client, ERR_INVALIDCAPCMD, parv[1]);
|
||||
|
||||
|
||||
+26
-30
@@ -5,14 +5,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"central-api",
|
||||
"1.0.2",
|
||||
"Acquire and set API key for unrealircd.org services",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"central-api",
|
||||
"1.0.2",
|
||||
"Acquire and set API key for unrealircd.org services",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
struct cfgstruct {
|
||||
char *request_key_challenge;
|
||||
@@ -83,20 +82,19 @@ int capi_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::central-api.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "central-api"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::central-api::%s with no value",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "request-key"))
|
||||
} else if (!strcmp(cep->name, "request-key"))
|
||||
{
|
||||
char *p = strchr(cep->value, '-');
|
||||
if (!p)
|
||||
@@ -107,29 +105,28 @@ int capi_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
errors++;
|
||||
}
|
||||
req.request_key = 1;
|
||||
|
||||
} else
|
||||
if (!strcmp(cep->name, "api-key"))
|
||||
|
||||
} else if (!strcmp(cep->name, "api-key"))
|
||||
{
|
||||
if (!strchr(cep->value, ':'))
|
||||
{
|
||||
config_error("%s:%i: set::central-api::api-key: Invalid format. "
|
||||
"Please check if you copy-pasted the api-key correctly. "
|
||||
"You can log in at your account to view API keys at "
|
||||
"https://www.unrealircd.org/central-api/account/",
|
||||
cep->file->filename, cep->line_number);
|
||||
"Please check if you copy-pasted the api-key correctly. "
|
||||
"You can log in at your account to view API keys at "
|
||||
"https://www.unrealircd.org/central-api/account/",
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
}
|
||||
req.api_key = 1;
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::central-api::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -143,7 +140,7 @@ int capi_config_posttest(int *errs)
|
||||
config_error("You need to set either set::central-api::request-key or set::central-api::api-key (not both or none).");
|
||||
config_error("See https://www.unrealircd.org/docs/Central_API for the documentation");
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
@@ -166,9 +163,9 @@ char *capi_hash(const char *in)
|
||||
static char hashbuf[128];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s:%s:%s",
|
||||
CAPI_HASH_STRING_PREFIX,
|
||||
in,
|
||||
CAPI_HASH_STRING_SUFFIX);
|
||||
CAPI_HASH_STRING_PREFIX,
|
||||
in,
|
||||
CAPI_HASH_STRING_SUFFIX);
|
||||
return sha256hash(hashbuf, buf, strlen(buf));
|
||||
}
|
||||
|
||||
@@ -179,11 +176,11 @@ int capi_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::central-api.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "central-api"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "request-key"))
|
||||
@@ -198,8 +195,7 @@ int capi_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
safe_strdup(cfg.request_key_challenge, capi_hash(buf));
|
||||
safe_strdup(cfg.request_key_response, capi_hash(p));
|
||||
} else
|
||||
if (!strcmp(cep->name, "api-key"))
|
||||
} else if (!strcmp(cep->name, "api-key"))
|
||||
{
|
||||
safe_strdup(cfg.api_key, cep->value);
|
||||
}
|
||||
|
||||
+104
-118
@@ -5,29 +5,27 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"central-blocklist",
|
||||
"1.0.8",
|
||||
"Check users at central blocklist",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"central-blocklist",
|
||||
"1.0.8",
|
||||
"Check users at central blocklist",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
ModDataInfo *centralblocklist_md = NULL;
|
||||
Module *cbl_module = NULL;
|
||||
|
||||
#define CBL_URL "https://centralblocklist.unrealircd-api.org/api/v1"
|
||||
#define SPAMREPORT_URL "https://spamreport.unrealircd-api.org/api/spamreport-v1"
|
||||
#define CBL_TRANSFER_TIMEOUT 10
|
||||
#define CBL_URL "https://centralblocklist.unrealircd-api.org/api/v1"
|
||||
#define SPAMREPORT_URL "https://spamreport.unrealircd-api.org/api/spamreport-v1"
|
||||
#define CBL_TRANSFER_TIMEOUT 10
|
||||
#define SPAMREPORT_NUM_REMEMBERED_CMDS 20
|
||||
|
||||
#define WEB(client) ((WebRequest *)moddata_local_client(client, webserver_md).ptr)
|
||||
#define WSU(client) ((WebSocketUser *)moddata_client(client, websocket_md).ptr)
|
||||
#define WEB(client) ((WebRequest *)moddata_local_client(client, webserver_md).ptr)
|
||||
#define WSU(client) ((WebSocketUser *)moddata_client(client, websocket_md).ptr)
|
||||
|
||||
typedef struct CBLUser CBLUser;
|
||||
struct CBLUser
|
||||
{
|
||||
struct CBLUser {
|
||||
json_t *handshake;
|
||||
time_t request_sent;
|
||||
char request_pending;
|
||||
@@ -39,8 +37,7 @@ struct CBLUser
|
||||
|
||||
/* For tracking current HTTPS requests */
|
||||
typedef struct CBLTransfer CBLTransfer;
|
||||
struct CBLTransfer
|
||||
{
|
||||
struct CBLTransfer {
|
||||
CBLTransfer *prev, *next;
|
||||
time_t started;
|
||||
NameList *clients;
|
||||
@@ -96,19 +93,26 @@ void send_request_for_pending_clients(void);
|
||||
const char *get_api_key(void);
|
||||
void set_tag(Client *client, const char *tag, int value);
|
||||
|
||||
#define CBLRAW(x) (moddata_local_client(x, centralblocklist_md).ptr)
|
||||
#define CBL(x) ((CBLUser *)(moddata_local_client(x, centralblocklist_md).ptr))
|
||||
#define CBLRAW(x) (moddata_local_client(x, centralblocklist_md).ptr)
|
||||
#define CBL(x) ((CBLUser *)(moddata_local_client(x, centralblocklist_md).ptr))
|
||||
|
||||
#define alloc_cbl_if_needed(x) do { \
|
||||
if (!moddata_local_client(x, centralblocklist_md).ptr) \
|
||||
{ \
|
||||
CBLUser *u = safe_alloc(sizeof(CBLUser)); \
|
||||
u->handshake = json_object(); \
|
||||
moddata_local_client(x, centralblocklist_md).ptr = u; \
|
||||
} \
|
||||
} while(0)
|
||||
#define alloc_cbl_if_needed(x) \
|
||||
do \
|
||||
{ \
|
||||
if (!moddata_local_client(x, centralblocklist_md).ptr) \
|
||||
{ \
|
||||
CBLUser *u = safe_alloc(sizeof(CBLUser)); \
|
||||
u->handshake = json_object(); \
|
||||
moddata_local_client(x, centralblocklist_md).ptr = u; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define AddScoreAction(item,list) do { item->priority = 0 - item->score; AddListItemPrio(item, list, item->priority); } while(0)
|
||||
#define AddScoreAction(item, list) \
|
||||
do \
|
||||
{ \
|
||||
item->priority = 0 - item->score; \
|
||||
AddListItemPrio(item, list, item->priority); \
|
||||
} while (0)
|
||||
|
||||
CMD_OVERRIDE_FUNC(cbl_override);
|
||||
CMD_OVERRIDE_FUNC(cbl_override_spamreport_gather);
|
||||
@@ -244,7 +248,8 @@ MOD_LOAD()
|
||||
"Acquire a key via https://www.unrealircd.org/central-api/ and then "
|
||||
"make sure the central-api-key module is loaded and set::central-api::api-key set.");
|
||||
return MOD_SUCCESS;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
safe_strdup(cfg.api_key, central_api_key);
|
||||
}
|
||||
|
||||
@@ -284,11 +289,11 @@ int cbl_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::central-blocklist.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "central-blocklist"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "api-key"))
|
||||
@@ -298,18 +303,16 @@ int cbl_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
"central-api module and put the key in set::central-api::api-key",
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "except"))
|
||||
} else if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
test_match_block(cf, cep, &errors);
|
||||
} else
|
||||
if (!strcmp(cep->name, "score"))
|
||||
} else if (!strcmp(cep->name, "score"))
|
||||
{
|
||||
int v = atoi(cep->value);
|
||||
if ((v < 1) || (v > 99))
|
||||
{
|
||||
config_error("%s:%i: set::central-blocklist::score: must be between 1 - 99 (got: %d)",
|
||||
cep->file->filename, cep->line_number, v);
|
||||
cep->file->filename, cep->line_number, v);
|
||||
errors++;
|
||||
}
|
||||
if (cep->items)
|
||||
@@ -320,32 +323,27 @@ int cbl_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!strcmp(cepp->name, "ban-action"))
|
||||
{
|
||||
errors += test_ban_action_config(cepp);
|
||||
} else
|
||||
if (!strcmp(cepp->name, "ban-reason"))
|
||||
} else if (!strcmp(cepp->name, "ban-reason"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cepp->name, "ban-time"))
|
||||
} else if (!strcmp(cepp->name, "ban-time"))
|
||||
{
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::central-blocklist::score::%s",
|
||||
cepp->file->filename, cepp->line_number, cepp->name);
|
||||
cepp->file->filename, cepp->line_number, cepp->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!cep->value)
|
||||
} else if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::central-blocklist::%s with no value",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "url"))
|
||||
} else if (!strcmp(cep->name, "url"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "spamreport") || !strcmp(cep->name, "spamreport-enabled"))
|
||||
} else if (!strcmp(cep->name, "spamreport") || !strcmp(cep->name, "spamreport-enabled"))
|
||||
{
|
||||
config_error("%s:%i: set::central-blocklist::%s: This setting is deprecated. "
|
||||
"Please remove this setting, and, if you wish to use spamreport, add a "
|
||||
@@ -353,24 +351,20 @@ int cbl_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
"See https://www.unrealircd.org/docs/Central_spamreport",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "blocklist") || !strcmp(cep->name, "blocklist-enabled"))
|
||||
} else if (!strcmp(cep->name, "blocklist") || !strcmp(cep->name, "blocklist-enabled"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "spamreport-url"))
|
||||
} else if (!strcmp(cep->name, "spamreport-url"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "max-downloads"))
|
||||
} else if (!strcmp(cep->name, "max-downloads"))
|
||||
{
|
||||
int v = atoi(cep->value);
|
||||
if ((v < 1) || (v > 500))
|
||||
{
|
||||
config_error("%s:%i: set::central-blocklist::score: must be between 1 - 500 (got: %d)",
|
||||
cep->file->filename, cep->line_number, v);
|
||||
cep->file->filename, cep->line_number, v);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "ban-reason") || !strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "ban-reason") || !strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
config_error("%s:%i: set::central-blocklist: you cannot use ban-action/ban-reason/ban-time here. "
|
||||
"There are now multiple score blocks. "
|
||||
@@ -380,12 +374,12 @@ int cbl_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::central-blocklist::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -405,18 +399,17 @@ int cbl_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::central-blocklist.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "central-blocklist"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "api-key"))
|
||||
{
|
||||
safe_strdup(cfg.api_key, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "score"))
|
||||
} else if (!strcmp(cep->name, "score"))
|
||||
{
|
||||
if (!cep->items)
|
||||
{
|
||||
@@ -433,47 +426,37 @@ int cbl_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (!strcmp(cepp->name, "ban-action"))
|
||||
{
|
||||
parse_ban_action_config(cepp, &action->ban_action);
|
||||
} else
|
||||
if (!strcmp(cepp->name, "ban-reason"))
|
||||
} else if (!strcmp(cepp->name, "ban-reason"))
|
||||
{
|
||||
safe_strdup(action->ban_reason, cepp->value);
|
||||
} else
|
||||
if (!strcmp(cepp->name, "ban-time"))
|
||||
} else if (!strcmp(cepp->name, "ban-time"))
|
||||
{
|
||||
action->ban_time = config_checkval(cepp->value, CFG_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "url"))
|
||||
} else if (!strcmp(cep->name, "url"))
|
||||
{
|
||||
safe_strdup(cfg.url, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "blocklist-enabled"))
|
||||
} else if (!strcmp(cep->name, "blocklist-enabled"))
|
||||
{
|
||||
cfg.blocklist_enabled = config_checkval(cep->value, CFG_YESNO);
|
||||
} else
|
||||
if (!strcmp(cep->name, "spamreport-url"))
|
||||
} else if (!strcmp(cep->name, "spamreport-url"))
|
||||
{
|
||||
safe_strdup(cfg.spamreport_url, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "max-downloads"))
|
||||
} else if (!strcmp(cep->name, "max-downloads"))
|
||||
{
|
||||
cfg.max_downloads = atoi(cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action"))
|
||||
} else if (!strcmp(cep->name, "ban-action"))
|
||||
{
|
||||
parse_ban_action_config(cep, &cfg.actions->ban_action);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-reason"))
|
||||
} else if (!strcmp(cep->name, "ban-reason"))
|
||||
{
|
||||
safe_strdup(cfg.actions->ban_reason, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
cfg.actions->ban_time = config_checkval(cep->value, CFG_TIME);
|
||||
} else
|
||||
if (!strcmp(cep->name, "except"))
|
||||
} else if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
if (cfg.except)
|
||||
{
|
||||
@@ -543,9 +526,9 @@ EVENT(centralblocklist_timeout_evt)
|
||||
(TStime() - cbl->request_sent > CBL_TRANSFER_TIMEOUT))
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "central-blocklist", "CENTRAL_BLOCKLIST_TIMEOUT", client,
|
||||
"Central blocklist too slow to respond. "
|
||||
"Possible problem with infrastructure at unrealircd.org. "
|
||||
"Allowing user $client.details in unchecked.");
|
||||
"Central blocklist too slow to respond. "
|
||||
"Possible problem with infrastructure at unrealircd.org. "
|
||||
"Allowing user $client.details in unchecked.");
|
||||
cbl_allow(client);
|
||||
}
|
||||
}
|
||||
@@ -560,14 +543,14 @@ void show_client_json(Client *client)
|
||||
json_serialized = json_dumps(CBL(client)->handshake, JSON_COMPACT);
|
||||
|
||||
unreal_log(ULOG_DEBUG, "central-blocklist", "DEBUG_CENTRAL_BLOCKLIST", client,
|
||||
"OUT: $data",
|
||||
log_data_string("data", json_serialized));
|
||||
"OUT: $data",
|
||||
log_data_string("data", json_serialized));
|
||||
safe_free(json_serialized);
|
||||
}
|
||||
|
||||
void cbl_add_client_info(Client *client)
|
||||
{
|
||||
char buf[BUFSIZE+1];
|
||||
char buf[BUFSIZE + 1];
|
||||
json_t *cbl = CBL(client)->handshake;
|
||||
json_t *child = json_object();
|
||||
const char *str;
|
||||
@@ -576,7 +559,7 @@ void cbl_add_client_info(Client *client)
|
||||
json_object_set_new(cbl, "client", child);
|
||||
|
||||
//// THE FOLLOWING IS TAKEN FROM src/json.c AND MODIFIED /////
|
||||
|
||||
|
||||
/* First the information that is available for ALL client types: */
|
||||
json_object_set_new(child, "name", json_string_unreal(client->name));
|
||||
json_object_set_new(child, "id", json_string_unreal(client->id));
|
||||
@@ -599,13 +582,15 @@ void cbl_add_client_info(Client *client)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s!%s@%s", client->name, client->user->username, client->user->realhost);
|
||||
json_object_set_new(child, "details", json_string_unreal(buf));
|
||||
} else if (client->ip) {
|
||||
} else if (client->ip)
|
||||
{
|
||||
if (*client->name)
|
||||
snprintf(buf, sizeof(buf), "%s@%s", client->name, client->ip);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "[%s]", client->ip);
|
||||
json_object_set_new(child, "details", json_string_unreal(buf));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
json_object_set_new(child, "details", json_string_unreal(client->name));
|
||||
}
|
||||
|
||||
@@ -670,13 +655,13 @@ void cbl_add_client_info(Client *client)
|
||||
{
|
||||
json_t *j = json_object();
|
||||
json_object_set_new(child, "tcp_info", j);
|
||||
json_object_set_new(j, "rtt", json_integer(MAX(tcp_info.tcpi_rtt,1)/1000));
|
||||
json_object_set_new(j, "rtt_var", json_integer(MAX(tcp_info.tcpi_rttvar,1)/1000));
|
||||
#if defined(__FreeBSD__)
|
||||
json_object_set_new(j, "rtt", json_integer(MAX(tcp_info.tcpi_rtt, 1) / 1000));
|
||||
json_object_set_new(j, "rtt_var", json_integer(MAX(tcp_info.tcpi_rttvar, 1) / 1000));
|
||||
#if defined(__FreeBSD__)
|
||||
json_object_set_new(j, "pmtu", json_integer(tcp_info.__tcpi_pmtu));
|
||||
#else
|
||||
#else
|
||||
json_object_set_new(j, "pmtu", json_integer(tcp_info.tcpi_pmtu));
|
||||
#endif
|
||||
#endif
|
||||
json_object_set_new(j, "snd_cwnd", json_integer(tcp_info.tcpi_snd_cwnd));
|
||||
json_object_set_new(j, "snd_mss", json_integer(tcp_info.tcpi_snd_mss));
|
||||
json_object_set_new(j, "rcv_mss", json_integer(tcp_info.tcpi_rcv_mss));
|
||||
@@ -737,8 +722,7 @@ CMD_OVERRIDE_FUNC(cbl_override)
|
||||
{
|
||||
isnick = 1;
|
||||
nospoof = client->local->nospoof;
|
||||
} else
|
||||
if (!strcmp(ovr->command->cmd, "PONG") && (parc > 1) && !BadPtr(parv[1]))
|
||||
} else if (!strcmp(ovr->command->cmd, "PONG") && (parc > 1) && !BadPtr(parv[1]))
|
||||
{
|
||||
unsigned long result = strtoul(parv[1], NULL, 16);
|
||||
if (client->local->nospoof && (client->local->nospoof == result))
|
||||
@@ -858,12 +842,13 @@ void cbl_handle_response(Client *client, json_t *response)
|
||||
if (highest_ban_action(action->ban_action) <= BAN_ACT_WARN)
|
||||
{
|
||||
unreal_log(ULOG_INFO, "central-blocklist", "CBL_HIT", client,
|
||||
"CBL: Client $client.details flagged by central-blocklist, but allowed in (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
} else {
|
||||
"CBL: Client $client.details flagged by central-blocklist, but allowed in (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
} else
|
||||
{
|
||||
unreal_log(ULOG_INFO, "central-blocklist", "CBL_HIT_REJECTED_USER", client,
|
||||
"CBL: Client $client.details is rejected by central-blocklist (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
"CBL: Client $client.details is rejected by central-blocklist (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
}
|
||||
if (take_action(client, action->ban_action, action->ban_reason, action->ban_time, 0, NULL) <= BAN_ACT_WARN)
|
||||
cbl_allow(client);
|
||||
@@ -871,8 +856,8 @@ void cbl_handle_response(Client *client, json_t *response)
|
||||
}
|
||||
}
|
||||
unreal_log(ULOG_DEBUG, "central-blocklist", "DEBUG_CENTRAL_BLOCKLIST", client,
|
||||
"CBL: Client $client.details is allowed (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
"CBL: Client $client.details is allowed (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
cbl_allow(client);
|
||||
}
|
||||
|
||||
@@ -890,17 +875,17 @@ void cbl_error_response(CBLTransfer *transfer, const char *error)
|
||||
if (CBL(client) && CBL(client)->allowed_in)
|
||||
continue; /* Client allowed in already (eg due to timeout) */
|
||||
unreal_log(ULOG_DEBUG, "central-blocklist", "DEBUG_CENTRAL_BLOCKLIST_ERROR", client,
|
||||
"CBL: Client $client.details allowed in due to CBL error: $error",
|
||||
log_data_string("error", error));
|
||||
"CBL: Client $client.details allowed in due to CBL error: $error",
|
||||
log_data_string("error", error));
|
||||
cbl_allow(client);
|
||||
num++;
|
||||
}
|
||||
if (num > 0)
|
||||
{
|
||||
unreal_log(ULOG_INFO, "central-blocklist", "CENTRAL_BLOCKLIST_ERROR", NULL,
|
||||
"CBL: Allowed $num_clients client(s) in due to CBL error: $error",
|
||||
log_data_integer("num_clients", num),
|
||||
log_data_string("error", error));
|
||||
"CBL: Allowed $num_clients client(s) in due to CBL error: $error",
|
||||
log_data_integer("num_clients", num),
|
||||
log_data_string("error", error));
|
||||
}
|
||||
del_cbl_transfer(transfer);
|
||||
}
|
||||
@@ -1021,8 +1006,8 @@ void send_request_for_pending_clients(void)
|
||||
if (num > cfg.max_downloads)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "central-blocklist", "CENTRAL_BLOCKLIST_TOO_MANY_CONCURRENT_REQUESTS", NULL,
|
||||
"Already $num_requests HTTP(S) requests in progress.",
|
||||
log_data_integer("num_requests", num));
|
||||
"Already $num_requests HTTP(S) requests in progress.",
|
||||
log_data_integer("num_requests", num));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1051,7 +1036,7 @@ void send_request_for_pending_clients(void)
|
||||
if (!json_serialized)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "central-blocklist", "CENTRAL_BLOCKLIST_BUG_SERIALIZE", client,
|
||||
"Unable to serialize JSON request. Weird.");
|
||||
"Unable to serialize JSON request. Weird.");
|
||||
json_decref(j);
|
||||
free_entire_name_list(clientlist);
|
||||
return;
|
||||
@@ -1116,7 +1101,8 @@ CMD_OVERRIDE_FUNC(cbl_override_spamreport_gather)
|
||||
if (clictx && clictx->textanalysis)
|
||||
{
|
||||
memcpy(&CBL(client)->last_cmds_textanalysis[slot], clictx->textanalysis, sizeof(TextAnalysis));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
memset(&CBL(client)->last_cmds_textanalysis[slot], 0, sizeof(TextAnalysis));
|
||||
}
|
||||
CBL(client)->last_cmds_slot++;
|
||||
@@ -1149,8 +1135,8 @@ int _central_spamreport(Client *client, Client *by, const char *url)
|
||||
if (num > cfg.max_downloads)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "central-blocklist", "CENTRAL_BLOCKLIST_TOO_MANY_CONCURRENT_REQUESTS", NULL,
|
||||
"Already $num_requests HTTP(S) requests in progress.",
|
||||
log_data_integer("num_requests", num));
|
||||
"Already $num_requests HTTP(S) requests in progress.",
|
||||
log_data_integer("num_requests", num));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1206,7 +1192,7 @@ int _central_spamreport(Client *client, Client *by, const char *url)
|
||||
if (!json_serialized)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "central-blocklist", "CENTRAL_BLOCKLIST_BUG_SERIALIZE", client,
|
||||
"Unable to serialize JSON request. Weird.");
|
||||
"Unable to serialize JSON request. Weird.");
|
||||
json_decref(j);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+12
-12
@@ -11,14 +11,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"certfp",
|
||||
"5.0",
|
||||
"Certificate fingerprint",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"certfp",
|
||||
"5.0",
|
||||
"Certificate fingerprint",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
void certfp_free(ModData *m);
|
||||
@@ -36,7 +35,7 @@ MOD_INIT()
|
||||
ModDataInfo mreq;
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
|
||||
memset(&mreq, 0, sizeof(mreq));
|
||||
mreq.name = "certfp";
|
||||
mreq.free = certfp_free;
|
||||
@@ -83,12 +82,13 @@ char *get_fingerprint_for_client(Client *client)
|
||||
|
||||
if (!MyConnect(client) || !client->local->ssl)
|
||||
return NULL;
|
||||
|
||||
|
||||
x509_clientcert = SSL_get_peer_certificate(client->local->ssl);
|
||||
|
||||
if (x509_clientcert)
|
||||
{
|
||||
if (X509_digest(x509_clientcert, digest, md, &n)) {
|
||||
if (X509_digest(x509_clientcert, digest, md, &n))
|
||||
{
|
||||
binarytohex(md, n, hex);
|
||||
X509_free(x509_clientcert);
|
||||
return hex;
|
||||
@@ -117,7 +117,7 @@ int certfp_connect(Client *client)
|
||||
if (IsSecure(client))
|
||||
{
|
||||
const char *fp = moddata_client_get(client, "certfp");
|
||||
|
||||
|
||||
if (fp && !iConf.no_connect_tls_info)
|
||||
sendnotice(client, "*** Your TLS certificate fingerprint is %s", fp);
|
||||
}
|
||||
|
||||
@@ -6,14 +6,13 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/censor",
|
||||
"4.2",
|
||||
"Channel Mode +G",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/censor",
|
||||
"4.2",
|
||||
"Channel Mode +G",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
|
||||
Cmode_t EXTMODE_CENSOR = 0L;
|
||||
@@ -37,7 +36,7 @@ MOD_TEST()
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CONFIGTEST, 0, censor_config_test);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
@@ -87,24 +86,24 @@ int censor_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
|
||||
if (type != CONFIG_MAIN)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!ce || !ce->name || strcmp(ce->name, "badword"))
|
||||
return 0; /* not interested */
|
||||
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error("%s:%i: badword without type",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
*errs = 1;
|
||||
return -1;
|
||||
}
|
||||
else if (strcmp(ce->value, "channel") &&
|
||||
strcmp(ce->value, "quit") && strcmp(ce->value, "all")) {
|
||||
} else if (strcmp(ce->value, "channel") &&
|
||||
strcmp(ce->value, "quit") && strcmp(ce->value, "all"))
|
||||
{
|
||||
/* config_error("%s:%i: badword with unknown type",
|
||||
ce->file->filename, ce->line_number); -- can't do that.. */
|
||||
return 0; /* unhandled */
|
||||
}
|
||||
|
||||
|
||||
if (!strcmp(ce->value, "quit"))
|
||||
{
|
||||
config_error("%s:%i: badword quit has been removed. We just use the bad words from "
|
||||
@@ -125,36 +124,34 @@ int censor_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
const char *errbuf;
|
||||
if (has_word)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::word");
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::word");
|
||||
continue;
|
||||
}
|
||||
has_word = 1;
|
||||
if ((errbuf = badword_config_check_regex(cep->value,1,1)))
|
||||
if ((errbuf = badword_config_check_regex(cep->value, 1, 1)))
|
||||
{
|
||||
config_error("%s:%i: badword::%s contains an invalid regex: %s",
|
||||
cep->file->filename,
|
||||
cep->line_number,
|
||||
cep->name, errbuf);
|
||||
cep->file->filename,
|
||||
cep->line_number,
|
||||
cep->name, errbuf);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(cep->name, "replace"))
|
||||
} else if (!strcmp(cep->name, "replace"))
|
||||
{
|
||||
if (has_replace)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::replace");
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::replace");
|
||||
continue;
|
||||
}
|
||||
has_replace = 1;
|
||||
}
|
||||
else if (!strcmp(cep->name, "action"))
|
||||
} else if (!strcmp(cep->name, "action"))
|
||||
{
|
||||
if (has_action)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::action");
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::action");
|
||||
continue;
|
||||
}
|
||||
has_action = 1;
|
||||
@@ -165,16 +162,15 @@ int censor_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
else
|
||||
{
|
||||
config_error("%s:%d: Unknown badword::action '%s'",
|
||||
cep->file->filename, cep->line_number,
|
||||
cep->value);
|
||||
cep->file->filename, cep->line_number,
|
||||
cep->value);
|
||||
errors++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename, cep->line_number,
|
||||
"badword", cep->name);
|
||||
"badword", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -182,7 +178,7 @@ int censor_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!has_word)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"badword::word");
|
||||
"badword::word");
|
||||
errors++;
|
||||
}
|
||||
if (has_action)
|
||||
@@ -190,11 +186,11 @@ int censor_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (has_replace && action == 'b')
|
||||
{
|
||||
config_error("%s:%i: badword::action is block but badword::replace exists",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -207,12 +203,12 @@ int censor_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
if (type != CONFIG_MAIN)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!ce || !ce->name || strcmp(ce->name, "badword"))
|
||||
return 0; /* not interested */
|
||||
|
||||
if (strcmp(ce->value, "channel") && strcmp(ce->value, "all"))
|
||||
return 0; /* not for us */
|
||||
return 0; /* not for us */
|
||||
|
||||
ca = safe_alloc(sizeof(ConfigItem_badword));
|
||||
ca->action = BADWORD_REPLACE;
|
||||
@@ -225,12 +221,10 @@ int censor_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
{
|
||||
ca->action = BADWORD_BLOCK;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(cep->name, "replace"))
|
||||
} else if (!strcmp(cep->name, "replace"))
|
||||
{
|
||||
safe_strdup(ca->replace, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "word"))
|
||||
} else if (!strcmp(cep->name, "word"))
|
||||
{
|
||||
word = cep;
|
||||
}
|
||||
@@ -330,9 +324,9 @@ int censor_stats_badwords_channel(Client *client, const char *para)
|
||||
for (words = conf_badword_channel; words; words = words->next)
|
||||
{
|
||||
sendtxtnumeric(client, "c %c %s%s%s %s", words->type & BADW_TYPE_REGEX ? 'R' : 'F',
|
||||
(words->type & BADW_TYPE_FAST_L) ? "*" : "", words->word,
|
||||
(words->type & BADW_TYPE_FAST_R) ? "*" : "",
|
||||
words->action == BADWORD_REPLACE ? (words->replace ? words->replace : "<censored>") : "");
|
||||
(words->type & BADW_TYPE_FAST_L) ? "*" : "", words->word,
|
||||
(words->type & BADW_TYPE_FAST_R) ? "*" : "",
|
||||
words->action == BADWORD_REPLACE ? (words->replace ? words->replace : "<censored>") : "");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/chanadmin",
|
||||
"6.0",
|
||||
"Channel Mode +a",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/chanadmin",
|
||||
"6.0",
|
||||
"Channel Mode +a",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cmode_chanadmin_is_ok(Client *client, Channel *channel, char mode, const char *para, int type, int what);
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/chanop",
|
||||
"6.0",
|
||||
"Channel Mode +o",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/chanop",
|
||||
"6.0",
|
||||
"Channel Mode +o",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cmode_chanop_is_ok(Client *client, Channel *channel, char mode, const char *para, int type, int what);
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/chanowner",
|
||||
"6.0",
|
||||
"Channel Mode +q",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/chanowner",
|
||||
"6.0",
|
||||
"Channel Mode +q",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cmode_chanowner_is_ok(Client *client, Channel *channel, char mode, const char *para, int type, int what);
|
||||
|
||||
@@ -5,16 +5,15 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/delayjoin", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"delayed join (+D,+d)", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/delayjoin", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"delayed join (+D,+d)", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
#define MOD_DATA_STR "delayjoin"
|
||||
#define MOD_DATA_STR "delayjoin"
|
||||
#define MOD_DATA_INVISIBLE "1"
|
||||
|
||||
static long UMODE_PRIVDEAF = 0;
|
||||
@@ -130,12 +129,12 @@ void clear_user_invisible_announce(Channel *channel, Client *client, MessageTag
|
||||
set_user_invisible(client, channel, 0);
|
||||
|
||||
ircsnprintf(joinbuf, sizeof(joinbuf), ":%s!%s@%s JOIN %s",
|
||||
client->name, client->user->username, GetHost(client), channel->name);
|
||||
client->name, client->user->username, GetHost(client), channel->name);
|
||||
|
||||
ircsnprintf(exjoinbuf, sizeof(exjoinbuf), ":%s!%s@%s JOIN %s %s :%s",
|
||||
client->name, client->user->username, GetHost(client), channel->name,
|
||||
IsLoggedIn(client) ? client->user->account : "*",
|
||||
client->info);
|
||||
client->name, client->user->username, GetHost(client), channel->name,
|
||||
IsLoggedIn(client) ? client->user->account : "*",
|
||||
client->info);
|
||||
|
||||
new_message_special(client, recv_mtags, &mtags, ":%s JOIN %s", client->name, channel->name);
|
||||
for (i = channel->members; i; i = i->next)
|
||||
@@ -153,7 +152,7 @@ void clear_user_invisible_announce(Channel *channel, Client *client, MessageTag
|
||||
|
||||
/* If this was the last invisible user to become visible, then set -d */
|
||||
if ((channel->mode.mode & EXTMODE_POST_DELAYED) && !channel_has_invisible_users(channel))
|
||||
clear_post_delayed(channel);
|
||||
clear_post_delayed(channel);
|
||||
}
|
||||
|
||||
int delayjoin_is_ok(Client *client, Channel *channel, char mode, const char *para, int checkt, int what)
|
||||
@@ -176,7 +175,7 @@ int moded_part(Client *client, Channel *channel, MessageTag *mtags, const char *
|
||||
{
|
||||
set_user_invisible(client, channel, 0);
|
||||
if (!channel_has_invisible_users(channel))
|
||||
clear_post_delayed(channel);
|
||||
clear_post_delayed(channel);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -186,7 +185,7 @@ int moded_quit(Client *client, MessageTag *mtags, const char *comment)
|
||||
Membership *membership;
|
||||
Channel *channel;
|
||||
|
||||
for (membership = client->user->channel; membership; membership=membership->next)
|
||||
for (membership = client->user->channel; membership; membership = membership->next)
|
||||
{
|
||||
channel = membership->channel;
|
||||
/* Identical to moded_part() */
|
||||
@@ -244,8 +243,8 @@ int moded_chanmode(Client *client, Channel *channel, MessageTag *recv_mtags, con
|
||||
{
|
||||
if (pm.what == MODE_ADD && (pm.modechar == 'o' || pm.modechar == 'h' || pm.modechar == 'a' || pm.modechar == 'q' || pm.modechar == 'v'))
|
||||
{
|
||||
Member* i;
|
||||
Client *user = find_client(pm.param,NULL);
|
||||
Member *i;
|
||||
Client *user = find_client(pm.param, NULL);
|
||||
if (!user)
|
||||
continue;
|
||||
|
||||
@@ -271,18 +270,18 @@ int moded_chanmode(Client *client, Channel *channel, MessageTag *recv_mtags, con
|
||||
channel->name,
|
||||
IsLoggedIn(i->client) ? i->client->user->account : "*",
|
||||
i->client->info);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
sendto_one(user, mtags, ":%s!%s@%s JOIN :%s", i->client->name, i->client->user->username, GetHost(i->client), channel->name);
|
||||
}
|
||||
free_message_tags(mtags);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (pm.what == MODE_DEL && (pm.modechar == 'o' || pm.modechar == 'h' || pm.modechar == 'a' || pm.modechar == 'q' || pm.modechar == 'v'))
|
||||
{
|
||||
Member* i;
|
||||
Client *user = find_client(pm.param,NULL);
|
||||
Member *i;
|
||||
Client *user = find_client(pm.param, NULL);
|
||||
if (!user)
|
||||
continue;
|
||||
|
||||
@@ -305,7 +304,6 @@ int moded_chanmode(Client *client, Channel *channel, MessageTag *recv_mtags, con
|
||||
free_message_tags(mtags);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+135
-132
@@ -19,26 +19,25 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/floodprot",
|
||||
"6.0",
|
||||
"Channel Mode +f and +F",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/floodprot",
|
||||
"6.0",
|
||||
"Channel Mode +f and +F",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
typedef enum Flood {
|
||||
CHFLD_CTCP = 0,
|
||||
CHFLD_JOIN = 1,
|
||||
CHFLD_KNOCK = 2,
|
||||
CHFLD_MSG = 3,
|
||||
CHFLD_NICK = 4,
|
||||
CHFLD_TEXT = 5,
|
||||
CHFLD_REPEAT = 6,
|
||||
CHFLD_PASTE = 7,
|
||||
CHFLD_CTCP = 0,
|
||||
CHFLD_JOIN = 1,
|
||||
CHFLD_KNOCK = 2,
|
||||
CHFLD_MSG = 3,
|
||||
CHFLD_NICK = 4,
|
||||
CHFLD_TEXT = 5,
|
||||
CHFLD_REPEAT = 6,
|
||||
CHFLD_PASTE = 7,
|
||||
} Flood;
|
||||
#define NUMFLD 8 /* 8 flood types */
|
||||
#define NUMFLD 8 /* 8 flood types */
|
||||
|
||||
/** Configuration settings */
|
||||
struct {
|
||||
@@ -77,8 +76,8 @@ FloodType floodtypes[] = {
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
#define MODEF_DEFAULT_UNSETTIME cfg.modef_default_unsettime
|
||||
#define MODEF_MAX_UNSETTIME cfg.modef_max_unsettime
|
||||
#define MODEF_DEFAULT_UNSETTIME cfg.modef_default_unsettime
|
||||
#define MODEF_MAX_UNSETTIME cfg.modef_max_unsettime
|
||||
|
||||
typedef struct ChannelFloodProtection ChannelFloodProtection;
|
||||
typedef struct ChannelFloodProfile ChannelFloodProfile;
|
||||
@@ -109,14 +108,14 @@ struct MemberFlood {
|
||||
|
||||
/** Per-channel flood protection settings and counters */
|
||||
struct ChannelFloodProtection {
|
||||
unsigned short per; /**< setting: per <XX> seconds */
|
||||
time_t timer[NUMFLD]; /**< runtime: timers */
|
||||
unsigned short counter[NUMFLD]; /**< runtime: counters */
|
||||
unsigned short counter_unknown_users[NUMFLD]; /**< runtime: counters */
|
||||
unsigned short limit[NUMFLD]; /**< setting: limit */
|
||||
unsigned char action[NUMFLD]; /**< setting: action */
|
||||
unsigned char remove_after[NUMFLD]; /**< setting: remove-after <this> minutes */
|
||||
unsigned char timers_running[MAXCHMODEFACTIONS+1]; /**< if for example a '-m' timer is running then this contains 'm' */
|
||||
unsigned short per; /**< setting: per <XX> seconds */
|
||||
time_t timer[NUMFLD]; /**< runtime: timers */
|
||||
unsigned short counter[NUMFLD]; /**< runtime: counters */
|
||||
unsigned short counter_unknown_users[NUMFLD]; /**< runtime: counters */
|
||||
unsigned short limit[NUMFLD]; /**< setting: limit */
|
||||
unsigned char action[NUMFLD]; /**< setting: action */
|
||||
unsigned char remove_after[NUMFLD]; /**< setting: remove-after <this> minutes */
|
||||
unsigned char timers_running[MAXCHMODEFACTIONS + 1]; /**< if for example a '-m' timer is running then this contains 'm' */
|
||||
char *profile;
|
||||
};
|
||||
|
||||
@@ -132,18 +131,20 @@ ModDataInfo *mdflood = NULL;
|
||||
* protection (+f/+F), per flood type. Read via the channel_flood_blocked_count efunc
|
||||
* (eg the total_channel_flood_count() crule). Local-only, freed on disconnect.
|
||||
*/
|
||||
typedef struct ChannelFloodBlocks { int blocked[NUMFLD]; } ChannelFloodBlocks;
|
||||
typedef struct ChannelFloodBlocks {
|
||||
int blocked[NUMFLD];
|
||||
} ChannelFloodBlocks;
|
||||
ModDataInfo *md_channelflood_blocked = NULL;
|
||||
/* Friendly type names for the efunc/crule, indexed by enum Flood. KEEP IN SYNC. */
|
||||
static const char *channelfloodtype_names[NUMFLD] = {
|
||||
"ctcp", /* CHFLD_CTCP */
|
||||
"join", /* CHFLD_JOIN */
|
||||
"knock", /* CHFLD_KNOCK */
|
||||
"msg", /* CHFLD_MSG */
|
||||
"nick", /* CHFLD_NICK */
|
||||
"text", /* CHFLD_TEXT */
|
||||
"repeat", /* CHFLD_REPEAT */
|
||||
"paste", /* CHFLD_PASTE */
|
||||
"ctcp", /* CHFLD_CTCP */
|
||||
"join", /* CHFLD_JOIN */
|
||||
"knock", /* CHFLD_KNOCK */
|
||||
"msg", /* CHFLD_MSG */
|
||||
"nick", /* CHFLD_NICK */
|
||||
"text", /* CHFLD_TEXT */
|
||||
"repeat", /* CHFLD_REPEAT */
|
||||
"paste", /* CHFLD_PASTE */
|
||||
};
|
||||
Cmode_t EXTMODE_FLOODLIMIT = 0L;
|
||||
Cmode_t EXTMODE_FLOOD_PROFILE = 0L;
|
||||
@@ -153,7 +154,7 @@ ChannelFloodProfile *channel_flood_profiles = NULL;
|
||||
char *floodprot_msghash_key = NULL;
|
||||
long long floodprot_splittime = 0;
|
||||
|
||||
#define IsFloodLimit(x) (((x)->mode.mode & EXTMODE_FLOODLIMIT) || ((x)->mode.mode & EXTMODE_FLOOD_PROFILE) || (cfg.default_profile && GETPARASTRUCT((x), 'F')))
|
||||
#define IsFloodLimit(x) (((x)->mode.mode & EXTMODE_FLOODLIMIT) || ((x)->mode.mode & EXTMODE_FLOOD_PROFILE) || (cfg.default_profile && GETPARASTRUCT((x), 'F')))
|
||||
|
||||
/* Forward declarations */
|
||||
static void init_config(void);
|
||||
@@ -199,7 +200,7 @@ void floodprot_free_msghash_key(ModData *m);
|
||||
CMD_OVERRIDE_FUNC(floodprot_override_mode);
|
||||
ChannelFloodProtection *get_channel_flood_profile(const char *name);
|
||||
int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int strict, Client *client, const char **error_out);
|
||||
int parse_channel_mode_flood_failed(const char **error_out, ChannelFloodProtection *fld, FORMAT_STRING(const char *fmt), ...) __attribute__((format(printf,3,4)));
|
||||
int parse_channel_mode_flood_failed(const char **error_out, ChannelFloodProtection *fld, FORMAT_STRING(const char *fmt), ...) __attribute__((format(printf, 3, 4)));
|
||||
int floodprot_server_quit(Client *client, MessageTag *mtags);
|
||||
void inherit_settings(ChannelFloodProtection *from, ChannelFloodProtection *to);
|
||||
void reapply_profiles(void);
|
||||
@@ -267,7 +268,7 @@ MOD_INIT()
|
||||
mreq.free = memberflood_free;
|
||||
mdflood = ModDataAdd(modinfo->handle, mreq);
|
||||
if (!mdflood)
|
||||
abort();
|
||||
abort();
|
||||
|
||||
memset(&mreq, 0, sizeof(mreq));
|
||||
mreq.name = "channelfloodblocks";
|
||||
@@ -429,36 +430,36 @@ int floodprot_config_test_set_block(ConfigFile *cf, ConfigEntry *ce, int type, i
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error_empty(ce->file->filename, ce->line_number,
|
||||
"set", ce->name);
|
||||
"set", ce->name);
|
||||
errors++;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
int v = atoi(ce->value);
|
||||
if ((v <= 0) || (v > 255))
|
||||
{
|
||||
config_error("%s:%i: set::modef-default-unsettime: value '%d' out of range (should be 1-255)",
|
||||
ce->file->filename, ce->line_number, v);
|
||||
ce->file->filename, ce->line_number, v);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(ce->name, "modef-max-unsettime"))
|
||||
} else if (!strcmp(ce->name, "modef-max-unsettime"))
|
||||
{
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error_empty(ce->file->filename, ce->line_number,
|
||||
"set", ce->name);
|
||||
"set", ce->name);
|
||||
errors++;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
int v = atoi(ce->value);
|
||||
if ((v <= 0) || (v > 255))
|
||||
{
|
||||
config_error("%s:%i: set::modef-max-unsettime: value '%d' out of range (should be 1-255)",
|
||||
ce->file->filename, ce->line_number, v);
|
||||
ce->file->filename, ce->line_number, v);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(ce->name, "modef-boot-delay"))
|
||||
} else if (!strcmp(ce->name, "modef-boot-delay"))
|
||||
{
|
||||
config_error("%s:%i: set::modef-boot-delay is now called set::anti-flood::channel::boot-delay. "
|
||||
"See https://www.unrealircd.org/docs/Channel_anti-flood_settings#config",
|
||||
@@ -521,27 +522,26 @@ int floodprot_config_test_antiflood_block(ConfigFile *cf, ConfigEntry *ce, int t
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(ce->name, "boot-delay") || !strcmp(ce->name, "split-delay"))
|
||||
} else if (!strcmp(ce->name, "boot-delay") || !strcmp(ce->name, "split-delay"))
|
||||
{
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error_empty(ce->file->filename, ce->line_number,
|
||||
"set", ce->name);
|
||||
"set", ce->name);
|
||||
errors++;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
long v = config_checkval(ce->value, CFG_TIME);
|
||||
if ((v < 0) || (v > 600))
|
||||
{
|
||||
config_error("%s:%i: set::anti-flood::channel::%s: value '%ld' out of range (should be 0-600)",
|
||||
ce->file->filename, ce->line_number,
|
||||
ce->name,
|
||||
v);
|
||||
ce->file->filename, ce->line_number,
|
||||
ce->name,
|
||||
v);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(ce->name, "profile"))
|
||||
} else if (!strcmp(ce->name, "profile"))
|
||||
{
|
||||
if (!ce->value)
|
||||
{
|
||||
@@ -583,9 +583,9 @@ int floodprot_config_test_antiflood_block(ConfigFile *cf, ConfigEntry *ce, int t
|
||||
} else if (!BadPtr(err))
|
||||
{
|
||||
config_warn("%s:%i: set::anti-flood::channel::profile %s::flood-mode: %s",
|
||||
cep->file->filename, cep->line_number,
|
||||
ce->value,
|
||||
err);
|
||||
cep->file->filename, cep->line_number,
|
||||
ce->value,
|
||||
err);
|
||||
}
|
||||
if (fld.limit[CHFLD_TEXT] || fld.limit[CHFLD_REPEAT])
|
||||
{
|
||||
@@ -595,9 +595,10 @@ int floodprot_config_test_antiflood_block(ConfigFile *cf, ConfigEntry *ce, int t
|
||||
ce->value);
|
||||
errors++;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename, cep->line_number,
|
||||
"set::anti-flood::channel::profile", cep->name);
|
||||
"set::anti-flood::channel::profile", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -629,16 +630,13 @@ int floodprot_config_run_antiflood_block(ConfigFile *cf, ConfigEntry *ce, int ty
|
||||
/* Let's handle 'off' in a special way -> becomes NULL */
|
||||
if (!strcmp(cfg.default_profile, "off"))
|
||||
safe_free(cfg.default_profile);
|
||||
} else
|
||||
if (!strcmp(ce->name, "boot-delay"))
|
||||
} else if (!strcmp(ce->name, "boot-delay"))
|
||||
{
|
||||
cfg.boot_delay = config_checkval(ce->value, CFG_TIME);
|
||||
} else
|
||||
if (!strcmp(ce->name, "split-delay"))
|
||||
} else if (!strcmp(ce->name, "split-delay"))
|
||||
{
|
||||
cfg.split_delay = config_checkval(ce->value, CFG_TIME);
|
||||
} else
|
||||
if (!strcmp(ce->name, "profile"))
|
||||
} else if (!strcmp(ce->name, "profile"))
|
||||
{
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
@@ -653,7 +651,7 @@ int floodprot_config_run_antiflood_block(ConfigFile *cf, ConfigEntry *ce, int ty
|
||||
FloodType *find_floodprot_by_letter(char c)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
for (i = 0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
if (floodtypes[i].letter == c)
|
||||
return &floodtypes[i];
|
||||
|
||||
@@ -663,7 +661,7 @@ FloodType *find_floodprot_by_letter(char c)
|
||||
FloodType *find_floodprot_by_index(Flood index)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
for (i = 0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
if (floodtypes[i].index == index)
|
||||
return &floodtypes[i];
|
||||
|
||||
@@ -693,7 +691,7 @@ int parse_channel_mode_flood_failed(const char **error_out, ChannelFloodProtecti
|
||||
va_end(vl);
|
||||
|
||||
/* Zero out all settings */
|
||||
for (v=0; v < NUMFLD; v++)
|
||||
for (v = 0; v < NUMFLD; v++)
|
||||
{
|
||||
fld->limit[v] = 0;
|
||||
fld->action[v] = 0;
|
||||
@@ -736,7 +734,7 @@ int floodprot_valid_alternate_action(char action, FloodType *floodtype)
|
||||
int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int strict, Client *client, const char **error_out)
|
||||
{
|
||||
static char retbuf[512];
|
||||
char xbuf[256], c, a, *p, *p2, *x = xbuf+1;
|
||||
char xbuf[256], c, a, *p, *p2, *x = xbuf + 1;
|
||||
int v;
|
||||
unsigned short breakit;
|
||||
unsigned char r;
|
||||
@@ -750,7 +748,7 @@ int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int
|
||||
*error_out = NULL;
|
||||
|
||||
/* always reset settings (l, a, r) */
|
||||
for (v=0; v < NUMFLD; v++)
|
||||
for (v = 0; v < NUMFLD; v++)
|
||||
{
|
||||
fld->limit[v] = 0;
|
||||
fld->action[v] = 0;
|
||||
@@ -763,19 +761,22 @@ int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int
|
||||
return parse_channel_mode_flood_failed(error_out, fld, "Invalid format (brackets missing)");
|
||||
|
||||
/* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
|
||||
p2 = strchr(xbuf+1, ']');
|
||||
p2 = strchr(xbuf + 1, ']');
|
||||
if (!p2)
|
||||
return parse_channel_mode_flood_failed(error_out, fld, "Invalid format (brackets missing)");
|
||||
*p2 = '\0';
|
||||
if (*(p2+1) != ':')
|
||||
if (*(p2 + 1) != ':')
|
||||
return parse_channel_mode_flood_failed(error_out, fld, "Invalid format (:XX period missing)");
|
||||
|
||||
breakit = 0;
|
||||
for (x = strtok(xbuf+1, ","); x; x = strtok(NULL, ","))
|
||||
for (x = strtok(xbuf + 1, ","); x; x = strtok(NULL, ","))
|
||||
{
|
||||
/* <number><1 letter>[optional: '#'+1 letter] */
|
||||
p = x;
|
||||
while(isdigit(*p)) { p++; }
|
||||
while (isdigit(*p))
|
||||
{
|
||||
p++;
|
||||
}
|
||||
|
||||
/* letter */
|
||||
c = *p;
|
||||
@@ -850,7 +851,7 @@ int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int
|
||||
if (v < fld->per)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < NUMFLD; i++)
|
||||
for (i = 0; i < NUMFLD; i++)
|
||||
{
|
||||
fld->timer[i] = 0;
|
||||
fld->counter[i] = 0;
|
||||
@@ -861,9 +862,9 @@ int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int
|
||||
|
||||
/* Is anything turned on? (to stop things like '+f []:15' */
|
||||
breakit = 1;
|
||||
for (v=0; v < NUMFLD; v++)
|
||||
for (v = 0; v < NUMFLD; v++)
|
||||
if (fld->limit[v])
|
||||
breakit=0;
|
||||
breakit = 0;
|
||||
if (breakit)
|
||||
{
|
||||
/* Nothing is turned on.. */
|
||||
@@ -891,8 +892,7 @@ int cmodef_is_ok(Client *client, Channel *channel, char mode, const char *param,
|
||||
if (type == EXCHK_ACCESS_ERR) /* can only be due to being halfop */
|
||||
sendnumeric(client, ERR_NOTFORHALFOPS, 'f');
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
ChannelFloodProtection fld;
|
||||
const char *err;
|
||||
@@ -1014,7 +1014,7 @@ int cmodef_sjoin_check(Channel *channel, void *ourx, void *theirx)
|
||||
return EXSJ_SAME;
|
||||
|
||||
our->per = MAX(our->per, their->per);
|
||||
for (i=0; i < NUMFLD; i++)
|
||||
for (i = 0; i < NUMFLD; i++)
|
||||
{
|
||||
our->limit[i] = MAX(our->limit[i], their->limit[i]);
|
||||
our->action[i] = MAX(our->action[i], their->action[i]);
|
||||
@@ -1061,8 +1061,7 @@ int cmodef_profile_is_ok(Client *client, Channel *channel, char mode, const char
|
||||
if (type == EXCHK_ACCESS_ERR) /* can only be due to being halfop */
|
||||
sendnumeric(client, ERR_NOTFORHALFOPS, 'f');
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
if (get_channel_flood_profile(param))
|
||||
return EX_ALLOW;
|
||||
@@ -1082,7 +1081,7 @@ void inherit_settings(ChannelFloodProtection *from, ChannelFloodProtection *to)
|
||||
/* If new 'per xxx seconds' is smaller than current 'per' then reset timers/counters (t, c) */
|
||||
if (from->per < to->per)
|
||||
{
|
||||
for (i=0; i < NUMFLD; i++)
|
||||
for (i = 0; i < NUMFLD; i++)
|
||||
{
|
||||
to->timer[i] = 0;
|
||||
to->counter[i] = 0;
|
||||
@@ -1091,7 +1090,7 @@ void inherit_settings(ChannelFloodProtection *from, ChannelFloodProtection *to)
|
||||
}
|
||||
|
||||
/* inherit settings (limit/action/remove_after) */
|
||||
for (i=0; i < NUMFLD; i++)
|
||||
for (i = 0; i < NUMFLD; i++)
|
||||
{
|
||||
to->limit[i] = from->limit[i];
|
||||
to->action[i] = from->action[i];
|
||||
@@ -1174,7 +1173,7 @@ int is_floodprot_exempt(Client *client, Channel *channel, char flood_type_letter
|
||||
b->channel = channel;
|
||||
b->ban_check_types = BANCHK_MSG;
|
||||
|
||||
for (ban = channel->exlist; ban; ban=ban->next)
|
||||
for (ban = channel->exlist; ban; ban = ban->next)
|
||||
{
|
||||
char *p, *x;
|
||||
char *matchby;
|
||||
@@ -1234,7 +1233,7 @@ int floodprot_join(Client *client, Channel *channel, MessageTag *mtags)
|
||||
#endif
|
||||
!IsULine(client))
|
||||
{
|
||||
do_floodprot(channel, client, CHFLD_JOIN);
|
||||
do_floodprot(channel, client, CHFLD_JOIN);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1273,8 +1272,8 @@ int cmodef_channel_destroy(Channel *channel, int *should_destroy)
|
||||
/* [just a helper for channel_modef_string()] */
|
||||
static inline char *chmodefstrhelper(char *buf, char t, char tdef, unsigned short l, unsigned char a, unsigned char r)
|
||||
{
|
||||
char *p;
|
||||
char tmpbuf[16], *p2 = tmpbuf;
|
||||
char *p;
|
||||
char tmpbuf[16], *p2 = tmpbuf;
|
||||
|
||||
sprintf(buf, "%hd", l);
|
||||
p = buf + strlen(buf);
|
||||
@@ -1305,7 +1304,7 @@ char *channel_modef_string(ChannelFloodProtection *x, char *retbuf)
|
||||
|
||||
*p++ = '[';
|
||||
|
||||
for (i=0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
for (i = 0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
{
|
||||
f = &floodtypes[i];
|
||||
if (x->limit[f->index])
|
||||
@@ -1387,7 +1386,7 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership *
|
||||
ChannelFloodProtection *fld;
|
||||
MemberFlood *memberflood;
|
||||
uint64_t msghash;
|
||||
unsigned char is_flooding_text=0, is_flooding_repeat=0;
|
||||
unsigned char is_flooding_text = 0, is_flooding_repeat = 0;
|
||||
static char errbuf[256];
|
||||
|
||||
/* This is redundant, right? */
|
||||
@@ -1397,7 +1396,7 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership *
|
||||
if (sendtype == SEND_TYPE_TAGMSG)
|
||||
return 0; // TODO: some TAGMSG specific limit? (1 of 2)
|
||||
|
||||
if (ValidatePermissionsForPath("channel:override:flood",client,NULL,channel,NULL) || !IsFloodLimit(channel) || check_channel_access(client, channel, "hoaq"))
|
||||
if (ValidatePermissionsForPath("channel:override:flood", client, NULL, channel, NULL) || !IsFloodLimit(channel) || check_channel_access(client, channel, "hoaq"))
|
||||
return HOOK_CONTINUE;
|
||||
|
||||
#ifdef TESTSUITE
|
||||
@@ -1508,7 +1507,8 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership *
|
||||
snprintf(mask, sizeof(mask), "~time:%d:*!*@%s", fld->remove_after[flood_type], GetHost(client));
|
||||
else
|
||||
snprintf(mask, sizeof(mask), "~t:%d:*!*@%s", fld->remove_after[flood_type], GetHost(client));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
snprintf(mask, sizeof(mask), "*!*@%s", GetHost(client));
|
||||
}
|
||||
if (add_listmode(&channel->banlist, &me, channel, mask) == 1)
|
||||
@@ -1517,7 +1517,7 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership *
|
||||
new_message(&me, NULL, &mtags);
|
||||
sendto_server(NULL, 0, 0, mtags, ":%s MODE %s +b %s 0", me.id, channel->name, mask);
|
||||
sendto_channel(channel, &me, NULL, 0, 0, SEND_LOCAL, mtags,
|
||||
":%s MODE %s +b %s", me.name, channel->name, mask);
|
||||
":%s MODE %s +b %s", me.name, channel->name, mask);
|
||||
free_message_tags(mtags);
|
||||
} /* else.. ban list is full or already exists */
|
||||
}
|
||||
@@ -1546,7 +1546,7 @@ int floodprot_post_chanmsg(Client *client, Channel *channel, int sendflags, cons
|
||||
|
||||
do_floodprot(channel, client, CHFLD_MSG);
|
||||
|
||||
if ((text[0] == '\001') && strncmp(text+1, "ACTION ", 7))
|
||||
if ((text[0] == '\001') && strncmp(text + 1, "ACTION ", 7))
|
||||
do_floodprot(channel, client, CHFLD_CTCP);
|
||||
|
||||
return 0;
|
||||
@@ -1585,7 +1585,7 @@ int floodprot_nickchange(Client *client, MessageTag *mtags, const char *oldnick)
|
||||
void floodprot_chanmode_del_helper(ChannelFloodProtection *fld, char modechar)
|
||||
{
|
||||
/* reset joinflood on -i, reset msgflood on -m, etc.. */
|
||||
switch(modechar)
|
||||
switch (modechar)
|
||||
{
|
||||
case 'C':
|
||||
fld->counter[CHFLD_CTCP] = 0;
|
||||
@@ -1652,7 +1652,7 @@ RemoveChannelModeTimer *floodprottimer_find(Channel *channel, char mflag)
|
||||
{
|
||||
RemoveChannelModeTimer *e;
|
||||
|
||||
for (e=removechannelmodetimer_list; e; e=e->next)
|
||||
for (e = removechannelmodetimer_list; e; e = e->next)
|
||||
{
|
||||
if ((e->channel == channel) && (e->m == mflag))
|
||||
return e;
|
||||
@@ -1663,7 +1663,8 @@ RemoveChannelModeTimer *floodprottimer_find(Channel *channel, char mflag)
|
||||
/** strcat-like */
|
||||
void strccat(char *s, char c)
|
||||
{
|
||||
for (; *s; s++);
|
||||
for (; *s; s++)
|
||||
;
|
||||
*s++ = c;
|
||||
*s++ = '\0';
|
||||
}
|
||||
@@ -1683,7 +1684,7 @@ void strccat(char *s, char c)
|
||||
void floodprottimer_add(Channel *channel, ChannelFloodProtection *fld, char mflag, time_t when)
|
||||
{
|
||||
RemoveChannelModeTimer *e = NULL;
|
||||
unsigned char add=1;
|
||||
unsigned char add = 1;
|
||||
|
||||
if (strchr(fld->timers_running, mflag))
|
||||
{
|
||||
@@ -1695,7 +1696,7 @@ void floodprottimer_add(Channel *channel, ChannelFloodProtection *fld, char mfla
|
||||
|
||||
if (!strchr(fld->timers_running, mflag))
|
||||
{
|
||||
if (strlen(fld->timers_running)+1 >= sizeof(fld->timers_running))
|
||||
if (strlen(fld->timers_running) + 1 >= sizeof(fld->timers_running))
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "flood", "BUG_FLOODPROTTIMER_ADD", NULL,
|
||||
"[BUG] floodprottimer_add: too many timers running for $channel ($timers_running)",
|
||||
@@ -1731,15 +1732,15 @@ void floodprottimer_del(Channel *channel, ChannelFloodProtection *fld, char mfla
|
||||
safe_free(e);
|
||||
|
||||
if (fld)
|
||||
{
|
||||
char newtf[MAXCHMODEFACTIONS+1];
|
||||
char *i, *o;
|
||||
for (i=fld->timers_running, o=newtf; *i; i++)
|
||||
if (*i != mflag)
|
||||
*o++ = *i;
|
||||
*o = '\0';
|
||||
strcpy(fld->timers_running, newtf); /* always shorter (or equal) */
|
||||
}
|
||||
{
|
||||
char newtf[MAXCHMODEFACTIONS + 1];
|
||||
char *i, *o;
|
||||
for (i = fld->timers_running, o = newtf; *i; i++)
|
||||
if (*i != mflag)
|
||||
*o++ = *i;
|
||||
*o = '\0';
|
||||
strcpy(fld->timers_running, newtf); /* always shorter (or equal) */
|
||||
}
|
||||
}
|
||||
|
||||
EVENT(modef_event)
|
||||
@@ -1850,8 +1851,8 @@ void do_floodprot_action_standard(Channel *channel, int what, FloodType *floodty
|
||||
text, fld->limit[what], fld->per, m, channel->name);
|
||||
ircsnprintf(target, sizeof(target), "%%%s", channel->name);
|
||||
sendto_channel(channel, &me, NULL, "ho",
|
||||
0, SEND_ALL, mtags,
|
||||
":%s NOTICE %s :%s", me.name, target, comment);
|
||||
0, SEND_ALL, mtags,
|
||||
":%s NOTICE %s :%s", me.name, target, comment);
|
||||
free_message_tags(mtags);
|
||||
|
||||
/* Then the MODE broadcast */
|
||||
@@ -1897,11 +1898,11 @@ int do_floodprot_action_alternative(Channel *channel, int what, FloodType *flood
|
||||
ircsnprintf(comment, sizeof(comment),
|
||||
"*** Channel %s detected (limit is %d per %d seconds), "
|
||||
"mostly caused by 'unknown-users', setting mode +b %s",
|
||||
text, fld->limit[what], fld->per, ban);
|
||||
text, fld->limit[what], fld->per, ban);
|
||||
ircsnprintf(target, sizeof(target), "%%%s", channel->name);
|
||||
sendto_channel(channel, &me, NULL, "ho",
|
||||
0, SEND_ALL, mtags,
|
||||
":%s NOTICE %s :%s", me.name, target, comment);
|
||||
0, SEND_ALL, mtags,
|
||||
":%s NOTICE %s :%s", me.name, target, comment);
|
||||
free_message_tags(mtags);
|
||||
|
||||
/* Then the MODE broadcast */
|
||||
@@ -1956,7 +1957,7 @@ void do_floodprot_action(Channel *channel, int what)
|
||||
if (!ban_exists)
|
||||
{
|
||||
/* Calculate the percentage of unknown-users that is responsible for the action trigger */
|
||||
perc = ((double)fld->counter_unknown_users[what] / (double)fld->counter[what])*100;
|
||||
perc = ((double)fld->counter_unknown_users[what] / (double)fld->counter[what]) * 100;
|
||||
if (perc >= cfg.modef_alternate_action_percentage_threshold)
|
||||
{
|
||||
/* ACTION: We need to add the ban (+b) */
|
||||
@@ -2132,7 +2133,7 @@ void floodprot_free_removechannelmodetimer_list(ModData *m)
|
||||
{
|
||||
RemoveChannelModeTimer *e, *e_next;
|
||||
|
||||
for (e=removechannelmodetimer_list; e; e=e_next)
|
||||
for (e = removechannelmodetimer_list; e; e = e_next)
|
||||
{
|
||||
e_next = e->next;
|
||||
safe_free(e);
|
||||
@@ -2166,19 +2167,18 @@ CMD_OVERRIDE_FUNC(floodprot_override_mode)
|
||||
if (!advanced && !profile)
|
||||
{
|
||||
sendnotice(client, "No channel mode +f/+F is active on %s", channel->name);
|
||||
} else
|
||||
if (advanced && !profile)
|
||||
} else if (advanced && !profile)
|
||||
{
|
||||
channel_modef_string(advanced, buf);
|
||||
sendnotice(client, "Channel '%s' has effective flood setting '%s' (custom settings via +f)",
|
||||
channel->name, buf);
|
||||
} else
|
||||
if (profile && !advanced)
|
||||
} else if (profile && !advanced)
|
||||
{
|
||||
channel_modef_string(profile, buf);
|
||||
sendnotice(client, "Channel '%s' has effective flood setting '%s' (flood profile '%s')",
|
||||
channel->name, buf, profile->profile);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Both +f and +F are set */
|
||||
int v;
|
||||
ChannelFloodProtection mix;
|
||||
@@ -2186,9 +2186,9 @@ CMD_OVERRIDE_FUNC(floodprot_override_mode)
|
||||
char overridden[64];
|
||||
*overridden = '\0';
|
||||
memcpy(&mix, profile, sizeof(mix));
|
||||
for (v=0; v < NUMFLD; v++)
|
||||
for (v = 0; v < NUMFLD; v++)
|
||||
{
|
||||
if ((advanced->limit[v]>0) && (mix.limit[v]>0))
|
||||
if ((advanced->limit[v] > 0) && (mix.limit[v] > 0))
|
||||
{
|
||||
mix.limit[v] = 0;
|
||||
mix.action[v] = 0;
|
||||
@@ -2201,11 +2201,12 @@ CMD_OVERRIDE_FUNC(floodprot_override_mode)
|
||||
if (*overridden)
|
||||
{
|
||||
sendnotice(client, "Channel '%s' uses flood profile '%s', without action(s) '%s' as they are overridden by +f.",
|
||||
channel->name, profile->profile, overridden);
|
||||
channel->name, profile->profile, overridden);
|
||||
sendnotice(client, "Effective flood setting via +F: '%s'", buf);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
sendnotice(client, "Channel '%s' has effective flood setting '%s' (flood profile '%s')",
|
||||
channel->name, buf, profile->profile);
|
||||
channel->name, buf, profile->profile);
|
||||
}
|
||||
channel_modef_string(advanced, buf);
|
||||
sendnotice(client, "Plus flood setting via +f: '%s'", buf);
|
||||
@@ -2238,7 +2239,7 @@ void reapply_profiles(void)
|
||||
{
|
||||
Channel *channel;
|
||||
|
||||
for (channel = channels; channel; channel=channel->nextch)
|
||||
for (channel = channels; channel; channel = channel->nextch)
|
||||
{
|
||||
ChannelFloodProtection *fld = GETPARASTRUCT(channel, 'F');
|
||||
ChannelFloodProtection *base;
|
||||
@@ -2260,7 +2261,8 @@ void reapply_profiles(void)
|
||||
if (!fld)
|
||||
{
|
||||
cmodef_channel_create(channel);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
base = get_channel_flood_profile(cfg.default_profile);
|
||||
if (base)
|
||||
{
|
||||
@@ -2268,7 +2270,8 @@ void reapply_profiles(void)
|
||||
safe_strdup(fld->profile, cfg.default_profile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (fld)
|
||||
{
|
||||
/* Not +F, previously we had a default profile
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/halfop",
|
||||
"6.0",
|
||||
"Channel Mode +h",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/halfop",
|
||||
"6.0",
|
||||
"Channel Mode +h",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cmode_halfop_is_ok(Client *client, Channel *channel, char mode, const char *para, int type, int what);
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/history",
|
||||
"1.0",
|
||||
"Channel Mode +H",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/history",
|
||||
"1.0",
|
||||
"Channel Mode +H",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
typedef struct ConfigHistoryExt ConfigHistoryExt;
|
||||
struct ConfigHistoryExt {
|
||||
@@ -40,7 +39,7 @@ static cfgstruct test;
|
||||
/* Externally looked up */
|
||||
long CAP_CHATHISTORY_DRAFT = 0;
|
||||
|
||||
#define HistoryEnabled(channel) (channel->mode.mode & EXTMODE_HISTORY)
|
||||
#define HistoryEnabled(channel) (channel->mode.mode & EXTMODE_HISTORY)
|
||||
|
||||
/* Forward declarations */
|
||||
static void init_config(cfgstruct *cfg);
|
||||
@@ -125,17 +124,17 @@ static void init_config(cfgstruct *cfg)
|
||||
cfg->playback_on_join.lines = 15;
|
||||
cfg->playback_on_join.time = 86400;
|
||||
cfg->max_storage_per_channel_unregistered.lines = 200;
|
||||
cfg->max_storage_per_channel_unregistered.time = 86400*31;
|
||||
cfg->max_storage_per_channel_unregistered.time = 86400 * 31;
|
||||
cfg->max_storage_per_channel_registered.lines = 5000;
|
||||
cfg->max_storage_per_channel_registered.time = 86400*31;
|
||||
cfg->max_storage_per_channel_registered.time = 86400 * 31;
|
||||
}
|
||||
|
||||
int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
{
|
||||
int errors = 0;
|
||||
ConfigEntry *cep, *cepp, *cep4, *cep5;
|
||||
int on_join_lines=0, maximum_storage_lines_registered=0, maximum_storage_lines_unregistered=0;
|
||||
long on_join_time=0L, maximum_storage_time_registered=0L, maximum_storage_time_unregistered=0L;
|
||||
int on_join_lines = 0, maximum_storage_lines_registered = 0, maximum_storage_lines_unregistered = 0;
|
||||
long on_join_time = 0L, maximum_storage_time_registered = 0L, maximum_storage_time_unregistered = 0L;
|
||||
|
||||
/* We only care about set::history */
|
||||
if ((type != CONFIG_SET) || strcmp(ce->name, "history"))
|
||||
@@ -165,8 +164,7 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
continue;
|
||||
}
|
||||
test.playback_on_join.lines = v;
|
||||
} else
|
||||
if (!strcmp(cep4->name, "time"))
|
||||
} else if (!strcmp(cep4->name, "time"))
|
||||
{
|
||||
long v;
|
||||
CheckNull(cep4);
|
||||
@@ -182,12 +180,11 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep4->file->filename,
|
||||
cep4->line_number, "set::history::channel::playback-on-join", cep4->name);
|
||||
cep4->line_number, "set::history::channel::playback-on-join", cep4->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cepp->name, "max-storage-per-channel"))
|
||||
} else if (!strcmp(cepp->name, "max-storage-per-channel"))
|
||||
{
|
||||
for (cep4 = cepp->items; cep4; cep4 = cep4->next)
|
||||
{
|
||||
@@ -203,13 +200,12 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (v < 1)
|
||||
{
|
||||
config_error("%s:%i: set::history::channel::max-storage-per-channel::registered::lines must be a positive number.",
|
||||
cep5->file->filename, cep5->line_number);
|
||||
cep5->file->filename, cep5->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
test.max_storage_per_channel_registered.lines = v;
|
||||
} else
|
||||
if (!strcmp(cep5->name, "time"))
|
||||
} else if (!strcmp(cep5->name, "time"))
|
||||
{
|
||||
long v;
|
||||
CheckNull(cep5);
|
||||
@@ -217,7 +213,7 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (v < 1)
|
||||
{
|
||||
config_error("%s:%i: set::history::channel::max-storage-per-channel::registered::time must be a positive number.",
|
||||
cep5->file->filename, cep5->line_number);
|
||||
cep5->file->filename, cep5->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -225,12 +221,11 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep5->file->filename,
|
||||
cep5->line_number, "set::history::channel::max-storage-per-channel::registered", cep5->name);
|
||||
cep5->line_number, "set::history::channel::max-storage-per-channel::registered", cep5->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep4->name, "unregistered"))
|
||||
} else if (!strcmp(cep4->name, "unregistered"))
|
||||
{
|
||||
for (cep5 = cep4->items; cep5; cep5 = cep5->next)
|
||||
{
|
||||
@@ -242,13 +237,12 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (v < 1)
|
||||
{
|
||||
config_error("%s:%i: set::history::channel::max-storage-per-channel::unregistered::lines must be a positive number.",
|
||||
cep5->file->filename, cep5->line_number);
|
||||
cep5->file->filename, cep5->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
test.max_storage_per_channel_unregistered.lines = v;
|
||||
} else
|
||||
if (!strcmp(cep5->name, "time"))
|
||||
} else if (!strcmp(cep5->name, "time"))
|
||||
{
|
||||
long v;
|
||||
CheckNull(cep5);
|
||||
@@ -256,7 +250,7 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (v < 1)
|
||||
{
|
||||
config_error("%s:%i: set::history::channel::max-storage-per-channel::unregistered::time must be a positive number.",
|
||||
cep5->file->filename, cep5->line_number);
|
||||
cep5->file->filename, cep5->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -264,14 +258,14 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep5->file->filename,
|
||||
cep5->line_number, "set::history::channel::max-storage-per-channel::unregistered", cep5->name);
|
||||
cep5->line_number, "set::history::channel::max-storage-per-channel::unregistered", cep5->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename,
|
||||
cep->line_number, "set::history::max-storage-per-channel", cep->name);
|
||||
cep->line_number, "set::history::max-storage-per-channel", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -283,8 +277,7 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
for (h = Hooks[HOOKTYPE_CONFIGTEST]; h; h = h->next)
|
||||
{
|
||||
int value, errs = 0;
|
||||
if (h->owner && !(h->owner->flags & MODFLAG_TESTING)
|
||||
&& !(h->owner->options & MOD_OPT_PERM))
|
||||
if (h->owner && !(h->owner->flags & MODFLAG_TESTING) && !(h->owner->options & MOD_OPT_PERM))
|
||||
continue;
|
||||
value = (*(h->func.intfunc))(cf, cepp, CONFIG_SET_HISTORY_CHANNEL, &errs);
|
||||
if (value == 2)
|
||||
@@ -309,14 +302,15 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!used)
|
||||
{
|
||||
config_error_unknown(cepp->file->filename,
|
||||
cepp->line_number, "set::history::channel", cepp->name);
|
||||
cepp->line_number, "set::history::channel", cepp->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename,
|
||||
cep->line_number, "set::history", cep->name);
|
||||
cep->line_number, "set::history", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -357,14 +351,12 @@ int history_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (!strcmp(cep4->name, "lines"))
|
||||
{
|
||||
cfg.playback_on_join.lines = atoi(cep4->value);
|
||||
} else
|
||||
if (!strcmp(cep4->name, "time"))
|
||||
} else if (!strcmp(cep4->name, "time"))
|
||||
{
|
||||
cfg.playback_on_join.time = config_checkval(cep4->value, CFG_TIME);
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cepp->name, "max-storage-per-channel"))
|
||||
} else if (!strcmp(cepp->name, "max-storage-per-channel"))
|
||||
{
|
||||
for (cep4 = cepp->items; cep4; cep4 = cep4->next)
|
||||
{
|
||||
@@ -375,22 +367,19 @@ int history_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (!strcmp(cep5->name, "lines"))
|
||||
{
|
||||
cfg.max_storage_per_channel_registered.lines = atoi(cep5->value);
|
||||
} else
|
||||
if (!strcmp(cep5->name, "time"))
|
||||
} else if (!strcmp(cep5->name, "time"))
|
||||
{
|
||||
cfg.max_storage_per_channel_registered.time = config_checkval(cep5->value, CFG_TIME);
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep4->name, "unregistered"))
|
||||
} else if (!strcmp(cep4->name, "unregistered"))
|
||||
{
|
||||
for (cep5 = cep4->items; cep5; cep5 = cep5->next)
|
||||
{
|
||||
if (!strcmp(cep5->name, "lines"))
|
||||
{
|
||||
cfg.max_storage_per_channel_unregistered.lines = atoi(cep5->value);
|
||||
} else
|
||||
if (!strcmp(cep5->name, "time"))
|
||||
} else if (!strcmp(cep5->name, "time"))
|
||||
{
|
||||
cfg.max_storage_per_channel_unregistered.time = config_checkval(cep5->value, CFG_TIME);
|
||||
}
|
||||
@@ -441,7 +430,7 @@ int history_parse_chanmode(Channel *channel, const char *param, int *lines, long
|
||||
|
||||
/* Parse time value */
|
||||
/* If it is all digits then it is in minutes */
|
||||
for (q=p; *q; q++)
|
||||
for (q = p; *q; q++)
|
||||
{
|
||||
if (!isdigit(*q))
|
||||
{
|
||||
@@ -469,7 +458,8 @@ int history_parse_chanmode(Channel *channel, const char *param, int *lines, long
|
||||
|
||||
if (*t > cfg.max_storage_per_channel_registered.time)
|
||||
*t = cfg.max_storage_per_channel_registered.time;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (*lines > cfg.max_storage_per_channel_unregistered.lines)
|
||||
*lines = cfg.max_storage_per_channel_unregistered.lines;
|
||||
|
||||
@@ -492,8 +482,7 @@ int history_chanmode_is_ok(Client *client, Channel *channel, char mode, const ch
|
||||
if (type == EXCHK_ACCESS_ERR) /* can only be due to being halfop */
|
||||
sendnumeric(client, ERR_NOTFORHALFOPS, 'H');
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
int lines = 0;
|
||||
long t = 0L;
|
||||
@@ -518,8 +507,7 @@ static void history_chanmode_helper(char *buf, size_t bufsize, int lines, long t
|
||||
{
|
||||
/* Can be represented in full days, eg "1d" */
|
||||
snprintf(buf, bufsize, "%d:%ldd", lines, t / 86400);
|
||||
} else
|
||||
if ((t % 3600) == 0)
|
||||
} else if ((t % 3600) == 0)
|
||||
{
|
||||
/* Can be represented in hours, eg "8h" */
|
||||
snprintf(buf, bufsize, "%d:%ldh", lines, t / 3600);
|
||||
@@ -659,7 +647,7 @@ int history_chanmsg(Client *client, Channel *channel, int sendflags, const char
|
||||
return 0;
|
||||
|
||||
/* Filter out CTCP / CTCP REPLY */
|
||||
if ((*text == '\001') && strncmp(text+1, "ACTION", 6))
|
||||
if ((*text == '\001') && strncmp(text + 1, "ACTION", 6))
|
||||
return 0;
|
||||
|
||||
/* Filter out TAGMSG */
|
||||
@@ -678,10 +666,10 @@ int history_chanmsg(Client *client, Channel *channel, int sendflags, const char
|
||||
strlcpy(source, client->name, sizeof(source));
|
||||
|
||||
snprintf(buf, sizeof(buf), ":%s %s %s :%s",
|
||||
source,
|
||||
sendtype_to_cmd(sendtype),
|
||||
channel->name,
|
||||
text);
|
||||
source,
|
||||
sendtype_to_cmd(sendtype),
|
||||
channel->name,
|
||||
text);
|
||||
|
||||
history_add(channel->name, mtags, buf);
|
||||
|
||||
@@ -704,7 +692,7 @@ int history_chanmsg_multiline(Client *client, Channel *channel, int sendflags, c
|
||||
return 0;
|
||||
|
||||
/* Filter out CTCP (except ACTION) based on first line */
|
||||
if (lines && lines->text && (*lines->text == '\001') && strncmp(lines->text+1, "ACTION", 6))
|
||||
if (lines && lines->text && (*lines->text == '\001') && strncmp(lines->text + 1, "ACTION", 6))
|
||||
return 0;
|
||||
|
||||
if (IsUser(client))
|
||||
@@ -820,11 +808,11 @@ CMD_OVERRIDE_FUNC(override_mode)
|
||||
new_message(&me, NULL, &mtags);
|
||||
|
||||
sendto_channel(channel, &me, &me, 0, 0, SEND_LOCAL, mtags,
|
||||
":%s MODE %s %s %s",
|
||||
me.name, channel->name, modebuf, parabuf);
|
||||
":%s MODE %s %s %s",
|
||||
me.name, channel->name, modebuf, parabuf);
|
||||
sendto_server(NULL, 0, 0, mtags, ":%s MODE %s %s %s %lld",
|
||||
me.id, channel->name, modebuf, parabuf,
|
||||
(long long)channel->creationtime);
|
||||
me.id, channel->name, modebuf, parabuf,
|
||||
(long long)channel->creationtime);
|
||||
|
||||
/* Activate this hook just like cmd_mode.c */
|
||||
RunHook(HOOKTYPE_REMOTE_CHANMODE, &me, channel, mtags, modebuf, parabuf, 0, 0, &destroy_channel);
|
||||
|
||||
@@ -20,18 +20,17 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/inviteonly",
|
||||
"6.0",
|
||||
"Channel Mode +i",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/inviteonly",
|
||||
"6.0",
|
||||
"Channel Mode +i",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_INVITE_ONLY;
|
||||
|
||||
#define IsInviteOnly(channel) (channel->mode.mode & EXTCMODE_INVITE_ONLY)
|
||||
#define IsInviteOnly(channel) (channel->mode.mode & EXTCMODE_INVITE_ONLY)
|
||||
|
||||
int inviteonly_can_join(Client *client, Channel *channel, const char *key, char **errmsg);
|
||||
|
||||
@@ -62,7 +61,7 @@ MOD_UNLOAD()
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
int inviteonly_can_join (Client *client, Channel *channel, const char *key, char **errmsg)
|
||||
int inviteonly_can_join(Client *client, Channel *channel, const char *key, char **errmsg)
|
||||
{
|
||||
if (IsInviteOnly(channel))
|
||||
{
|
||||
|
||||
@@ -20,18 +20,17 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/isregistered",
|
||||
"6.0",
|
||||
"Channel Mode +r",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/isregistered",
|
||||
"6.0",
|
||||
"Channel Mode +r",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_REGISTERED;
|
||||
|
||||
#define IsRegisteredChannel(channel) (channel->mode.mode & EXTCMODE_REGISTERED)
|
||||
#define IsRegisteredChannel(channel) (channel->mode.mode & EXTCMODE_REGISTERED)
|
||||
|
||||
int isregistered_chanmode_is_ok(Client *client, Channel *channel, char mode, const char *param, int type, int what);
|
||||
|
||||
|
||||
@@ -28,18 +28,17 @@
|
||||
|
||||
CMD_FUNC(issecure);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/issecure",
|
||||
"4.2",
|
||||
"Channel Mode +Z",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/issecure",
|
||||
"4.2",
|
||||
"Channel Mode +Z",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_ISSECURE;
|
||||
|
||||
#define IsSecureChanIndicated(channel) (channel->mode.mode & EXTCMODE_ISSECURE)
|
||||
#define IsSecureChanIndicated(channel) (channel->mode.mode & EXTCMODE_ISSECURE)
|
||||
|
||||
int IsSecureJoin(Channel *channel);
|
||||
int modeZ_is_ok(Client *client, Channel *channel, char mode, const char *para, int checkt, int what);
|
||||
@@ -48,8 +47,8 @@ int issecure_part(Client *client, Channel *channel, MessageTag *mtags, const cha
|
||||
int issecure_quit(Client *client, MessageTag *mtags, const char *comment);
|
||||
int issecure_kick(Client *client, Client *victim, Channel *channel, MessageTag *mtags, const char *comment);
|
||||
int issecure_chanmode(Client *client, Channel *channel, MessageTag *mtags,
|
||||
const char *modebuf, const char *parabuf, time_t sendts, int samode, int *destroy_channel);
|
||||
|
||||
const char *modebuf, const char *parabuf, time_t sendts, int samode, int *destroy_channel);
|
||||
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -58,7 +57,7 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
/* Channel mode */
|
||||
memset(&req, 0, sizeof(req));
|
||||
@@ -67,7 +66,7 @@ CmodeInfo req;
|
||||
req.letter = 'Z';
|
||||
req.local = 1; /* local channel mode */
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_ISSECURE);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_LOCAL_JOIN, 0, issecure_join);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_REMOTE_JOIN, 0, issecure_join);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_LOCAL_PART, 0, issecure_part);
|
||||
@@ -78,7 +77,7 @@ CmodeInfo req;
|
||||
HookAdd(modinfo->handle, HOOKTYPE_REMOTE_KICK, 0, issecure_kick);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_LOCAL_CHANMODE, 0, issecure_chanmode);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_REMOTE_CHANMODE, 0, issecure_chanmode);
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -116,7 +115,7 @@ int modeZ_is_ok(Client *client, Channel *channel, char mode, const char *para, i
|
||||
|
||||
int channel_has_insecure_users_butone(Channel *channel, Client *skip)
|
||||
{
|
||||
Member *member;
|
||||
Member *member;
|
||||
|
||||
for (member = channel->members; member; member = member->next)
|
||||
{
|
||||
@@ -149,7 +148,7 @@ void issecure_unset(Channel *channel, Client *client, MessageTag *recv_mtags, in
|
||||
me.name, channel->name, client->name);
|
||||
free_message_tags(mtags);
|
||||
}
|
||||
|
||||
|
||||
channel->mode.mode &= ~EXTCMODE_ISSECURE;
|
||||
mtags = NULL;
|
||||
new_message_special(&me, recv_mtags, &mtags, "MODE %s -Z", channel->name);
|
||||
@@ -224,14 +223,14 @@ int issecure_part(Client *client, Channel *channel, MessageTag *mtags, const cha
|
||||
|
||||
int issecure_quit(Client *client, MessageTag *mtags, const char *comment)
|
||||
{
|
||||
Membership *membership;
|
||||
Channel *channel;
|
||||
Membership *membership;
|
||||
Channel *channel;
|
||||
|
||||
for (membership = client->user->channel; membership; membership=membership->next)
|
||||
for (membership = client->user->channel; membership; membership = membership->next)
|
||||
{
|
||||
channel = membership->channel;
|
||||
/* Identical to part */
|
||||
if (IsSecureJoin(channel) && !IsSecureChanIndicated(channel) &&
|
||||
if (IsSecureJoin(channel) && !IsSecureChanIndicated(channel) &&
|
||||
!IsSecureConnect(client) && !channel_has_insecure_users_butone(channel, client))
|
||||
issecure_set(channel, client, mtags, 1);
|
||||
}
|
||||
@@ -248,7 +247,7 @@ int issecure_kick(Client *client, Client *victim, Channel *channel, MessageTag *
|
||||
}
|
||||
|
||||
int issecure_chanmode(Client *client, Channel *channel, MessageTag *mtags,
|
||||
const char *modebuf, const char *parabuf, time_t sendts, int samode, int *destroy_channel)
|
||||
const char *modebuf, const char *parabuf, time_t sendts, int samode, int *destroy_channel)
|
||||
{
|
||||
if (!strchr(modebuf, 'z'))
|
||||
return 0; /* don't care */
|
||||
@@ -264,12 +263,14 @@ int issecure_chanmode(Client *client, Channel *channel, MessageTag *mtags,
|
||||
/* Should be -Z, if not already */
|
||||
if (IsSecureChanIndicated(channel))
|
||||
issecure_unset(channel, NULL, mtags, 0); /* would be odd if we got here ;) */
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Should be +Z, but check if it isn't already.. */
|
||||
if (!IsSecureChanIndicated(channel))
|
||||
issecure_set(channel, NULL, mtags, 0);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* there was a -z, check if the channel is currently +Z and if so, set it -Z */
|
||||
if (IsSecureChanIndicated(channel))
|
||||
issecure_unset(channel, NULL, mtags, 0);
|
||||
|
||||
+13
-15
@@ -19,25 +19,24 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/key",
|
||||
"6.0",
|
||||
"Channel Mode +k",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/key",
|
||||
"6.0",
|
||||
"Channel Mode +k",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
typedef struct ChannelKey ChannelKey;
|
||||
struct ChannelKey {
|
||||
char key[KEYLEN+1];
|
||||
char key[KEYLEN + 1];
|
||||
};
|
||||
|
||||
/* Global variables */
|
||||
ModDataInfo *mdkey = NULL;
|
||||
Cmode_t EXTMODE_KEY = 0L;
|
||||
|
||||
#define IsKey(x) ((x)->mode.mode & EXTMODE_KEY)
|
||||
#define IsKey(x) ((x)->mode.mode & EXTMODE_KEY)
|
||||
|
||||
/* Forward declarations */
|
||||
int key_can_join(Client *client, Channel *channel, const char *key, char **errmsg);
|
||||
@@ -110,13 +109,12 @@ int cmode_key_is_ok(Client *client, Channel *channel, char mode, const char *par
|
||||
if (IsUser(client) && check_channel_access(client, channel, "hoaq"))
|
||||
return EX_ALLOW;
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
if (!is_valid_key(param))
|
||||
{
|
||||
sendnumeric(client, ERR_INVALIDMODEPARAM,
|
||||
channel->name, 'k', "*", "Channel key contains forbidden characters or is too long");
|
||||
channel->name, 'k', "*", "Channel key contains forbidden characters or is too long");
|
||||
return EX_DENY;
|
||||
}
|
||||
return EX_ALLOW;
|
||||
@@ -141,7 +139,7 @@ void *cmode_key_put_param(void *k_in, const char *param)
|
||||
const char *cmode_key_get_param(void *r_in)
|
||||
{
|
||||
ChannelKey *r = (ChannelKey *)r_in;
|
||||
static char retbuf[KEYLEN+1];
|
||||
static char retbuf[KEYLEN + 1];
|
||||
|
||||
if (!r)
|
||||
return NULL;
|
||||
@@ -152,7 +150,7 @@ const char *cmode_key_get_param(void *r_in)
|
||||
|
||||
const char *cmode_key_conv_param(const char *param, Client *client, Channel *channel)
|
||||
{
|
||||
static char retbuf[KEYLEN+1];
|
||||
static char retbuf[KEYLEN + 1];
|
||||
|
||||
transform_channel_key(param, retbuf, sizeof(retbuf));
|
||||
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/limit",
|
||||
"6.0",
|
||||
"Channel Mode +l",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/limit",
|
||||
"6.0",
|
||||
"Channel Mode +l",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
typedef struct ChannelLimit ChannelLimit;
|
||||
struct ChannelLimit {
|
||||
@@ -37,10 +36,10 @@ struct ChannelLimit {
|
||||
ModDataInfo *mdlimit = NULL;
|
||||
Cmode_t EXTMODE_LIMIT = 0L;
|
||||
|
||||
#define IsLimit(x) ((x)->mode.mode & EXTMODE_LIMIT)
|
||||
#define IsLimit(x) ((x)->mode.mode & EXTMODE_LIMIT)
|
||||
|
||||
/* Just for buffers, nothing else */
|
||||
#define LIMITLEN 32
|
||||
#define LIMITLEN 32
|
||||
|
||||
/* Forward declarations */
|
||||
int limit_can_join(Client *client, Channel *channel, const char *key, char **errmsg);
|
||||
@@ -95,9 +94,9 @@ int limit_can_join(Client *client, Channel *channel, const char *key, char **err
|
||||
if (r && r->limit && (channel->users >= r->limit))
|
||||
{
|
||||
Hook *h;
|
||||
for (h = Hooks[HOOKTYPE_CAN_JOIN_LIMITEXCEEDED]; h; h = h->next)
|
||||
for (h = Hooks[HOOKTYPE_CAN_JOIN_LIMITEXCEEDED]; h; h = h->next)
|
||||
{
|
||||
int i = (*(h->func.intfunc))(client,channel,key,errmsg);
|
||||
int i = (*(h->func.intfunc))(client, channel, key, errmsg);
|
||||
if (i != 0)
|
||||
return i;
|
||||
}
|
||||
@@ -116,14 +115,13 @@ int cmode_limit_is_ok(Client *client, Channel *channel, char mode, const char *p
|
||||
if (IsUser(client) && check_channel_access(client, channel, "hoaq"))
|
||||
return EX_ALLOW;
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
/* When coming from an IRC client, we reject limit <=0 explicitly, as it makes no sense */
|
||||
if (atoi(param) <= 0)
|
||||
{
|
||||
sendnumeric(client, ERR_INVALIDMODEPARAM,
|
||||
channel->name, 'l', "*", "Channel limit (+l) needs to be a positive number");
|
||||
channel->name, 'l', "*", "Channel limit (+l) needs to be a positive number");
|
||||
return EX_DENY;
|
||||
}
|
||||
/* Any other value is valid, we just morph it */
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
#define MAX_EB_LEN 128 // Max extban length
|
||||
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/link",
|
||||
"5.0",
|
||||
"Channel Mode +L",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
"chanmodes/link",
|
||||
"5.0",
|
||||
"Channel Mode +L",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTMODE_LINK = 0L;
|
||||
@@ -115,8 +115,7 @@ int cmodeL_is_ok(Client *client, Channel *channel, char mode, const char *para,
|
||||
if (type == EXCHK_ACCESS_ERR) /* can only be due to being halfop */
|
||||
sendnumeric(client, ERR_NOTFORHALFOPS, 'L');
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
/* Check parameter.. syntax is +L #channel */
|
||||
if (strchr(para, ','))
|
||||
@@ -132,7 +131,7 @@ int cmodeL_is_ok(Client *client, Channel *channel, char mode, const char *para,
|
||||
{
|
||||
if (MyUser(client))
|
||||
sendnumeric(client, ERR_CANNOTCHANGECHANMODE, 'L',
|
||||
"a channel cannot be linked to itself");
|
||||
"a channel cannot be linked to itself");
|
||||
return EX_DENY;
|
||||
}
|
||||
return EX_ALLOW;
|
||||
@@ -158,7 +157,7 @@ void *cmodeL_put_param(void *r_in, const char *param)
|
||||
const char *cmodeL_get_param(void *r_in)
|
||||
{
|
||||
aModeLEntry *r = (aModeLEntry *)r_in;
|
||||
static char retbuf[CHANNELLEN+1];
|
||||
static char retbuf[CHANNELLEN + 1];
|
||||
|
||||
if (!r)
|
||||
return NULL;
|
||||
@@ -284,7 +283,7 @@ const char *extban_link_conv_param(BanContext *b, Extban *extban)
|
||||
|
||||
int link_doforward(Client *client, Channel *channel, const char *linked, linkType type)
|
||||
{
|
||||
char linked_channel_buffer[CHANNELLEN+1];
|
||||
char linked_channel_buffer[CHANNELLEN + 1];
|
||||
char desc[64];
|
||||
const char *parv[3];
|
||||
|
||||
@@ -368,12 +367,10 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, const char *key)
|
||||
if (!strncmp(ban->banstr, "~f:", 3))
|
||||
{
|
||||
strlcpy(bantmp, ban->banstr + 3, sizeof(bantmp));
|
||||
} else
|
||||
if (!strncmp(ban->banstr, "~forward:", 9))
|
||||
} else if (!strncmp(ban->banstr, "~forward:", 9))
|
||||
{
|
||||
strlcpy(bantmp, ban->banstr + 9, sizeof(bantmp));
|
||||
} else
|
||||
if (!strncmp(ban->banstr, "~t:", 3))
|
||||
} else if (!strncmp(ban->banstr, "~t:", 3))
|
||||
{
|
||||
/* A timed ban, but is it for us? Need to parse a little:
|
||||
* ~t:dddd:~f:...
|
||||
@@ -382,16 +379,15 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, const char *key)
|
||||
if (p && !strncmp(p, ":~f:", 4))
|
||||
{
|
||||
strlcpy(bantmp, p + 4, sizeof(bantmp));
|
||||
} else
|
||||
if (p && !strncmp(p, ":~forward:", 10))
|
||||
} else if (p && !strncmp(p, ":~forward:", 10))
|
||||
{
|
||||
strlcpy(bantmp, p + 10, sizeof(bantmp));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Not for us - some other ~t ban */
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
if (!strncmp(ban->banstr, "~time:", 6))
|
||||
} else if (!strncmp(ban->banstr, "~time:", 6))
|
||||
{
|
||||
/* A timed ban, but is it for us? Need to parse a little:
|
||||
* ~t:dddd:~f:...
|
||||
@@ -400,11 +396,11 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, const char *key)
|
||||
if (p && !strncmp(p, ":~f:", 4))
|
||||
{
|
||||
strlcpy(bantmp, p + 4, sizeof(bantmp));
|
||||
} else
|
||||
if (p && !strncmp(p, ":~forward:", 10))
|
||||
} else if (p && !strncmp(p, ":~forward:", 10))
|
||||
{
|
||||
strlcpy(bantmp, p + 10, sizeof(bantmp));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Not for us - some other ~t ban */
|
||||
continue;
|
||||
}
|
||||
@@ -439,7 +435,8 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, const char *key)
|
||||
/* A ~forward ban matched, go for it.. */
|
||||
safe_free(b);
|
||||
return link_doforward(client, channel, banchan, LINKTYPE_BAN);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Break the outer loop as well: the user is exempt,
|
||||
* so it makes no sense to check other bans anymore.
|
||||
* no "safe_free(b);" here because that is taken
|
||||
@@ -474,7 +471,8 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, const char *key)
|
||||
return link_doforward(client, channel, linked, LINKTYPE_REG);
|
||||
|
||||
// For a couple of conditions we can use the return value from can_join() =]
|
||||
switch(canjoin) {
|
||||
switch (canjoin)
|
||||
{
|
||||
// Any ban other than our own ~f: extban
|
||||
case ERR_BANNEDFROMCHAN:
|
||||
return link_doforward(client, channel, linked, LINKTYPE_BAN);
|
||||
|
||||
@@ -20,14 +20,13 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/moderated",
|
||||
"6.0",
|
||||
"Channel Mode +m",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/moderated",
|
||||
"6.0",
|
||||
"Channel Mode +m",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Global variables */
|
||||
Cmode_t EXTCMODE_MODERATED;
|
||||
@@ -38,7 +37,7 @@ const char *moderated_pre_local_part(Client *client, Channel *channel, const cha
|
||||
int moderated_can_set_topic(Client *client, Channel *channel, const char *topic, const char **errmsg);
|
||||
|
||||
/* Macros */
|
||||
#define IsModerated(channel) (channel->mode.mode & EXTCMODE_MODERATED)
|
||||
#define IsModerated(channel) (channel->mode.mode & EXTCMODE_MODERATED)
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
@@ -72,7 +71,7 @@ MOD_UNLOAD()
|
||||
int moderated_can_send_to_channel(Client *client, Channel *channel, Membership *m, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx)
|
||||
{
|
||||
if (IsModerated(channel) && (!m || !check_channel_access_membership(m, "vhoaq")) &&
|
||||
!op_can_override("channel:override:message:moderated",client,channel,NULL))
|
||||
!op_can_override("channel:override:message:moderated", client, channel, NULL))
|
||||
{
|
||||
Hook *h;
|
||||
for (h = Hooks[HOOKTYPE_CAN_BYPASS_CHANNEL_MESSAGE_RESTRICTION]; h; h = h->next)
|
||||
@@ -101,7 +100,7 @@ const char *moderated_pre_local_part(Client *client, Channel *channel, const cha
|
||||
|
||||
int moderated_can_set_topic(Client *client, Channel *channel, const char *topic, const char **errmsg)
|
||||
{
|
||||
static char errmsg_buf[NICKLEN+256];
|
||||
static char errmsg_buf[NICKLEN + 256];
|
||||
|
||||
/* Channel is +m but user is not +vhoaq: reject the topic change */
|
||||
if (has_channel_mode(channel, 'm') && !check_channel_access(client, channel, "vhoaq"))
|
||||
|
||||
@@ -21,18 +21,17 @@
|
||||
|
||||
CMD_FUNC(nocolor);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/nocolor",
|
||||
"4.2",
|
||||
"Channel Mode +c",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/nocolor",
|
||||
"4.2",
|
||||
"Channel Mode +c",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NOCOLOR;
|
||||
|
||||
#define IsNoColor(channel) (channel->mode.mode & EXTCMODE_NOCOLOR)
|
||||
#define IsNoColor(channel) (channel->mode.mode & EXTCMODE_NOCOLOR)
|
||||
|
||||
int nocolor_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx);
|
||||
const char *nocolor_prelocalpart(Client *client, Channel *channel, const char *comment);
|
||||
@@ -45,7 +44,7 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
/* Channel mode */
|
||||
memset(&req, 0, sizeof(req));
|
||||
@@ -53,12 +52,12 @@ CmodeInfo req;
|
||||
req.letter = 'c';
|
||||
req.is_ok = extcmode_default_requirechop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NOCOLOR);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, nocolor_can_send_to_channel);
|
||||
HookAddConstString(modinfo->handle, HOOKTYPE_PRE_LOCAL_PART, 0, nocolor_prelocalpart);
|
||||
HookAddConstString(modinfo->handle, HOOKTYPE_PRE_LOCAL_QUIT_CHAN, 0, nocolor_prelocalpart);
|
||||
HookAddConstString(modinfo->handle, HOOKTYPE_PRE_LOCAL_QUIT, 0, nocolor_prelocalquit);
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -75,14 +74,14 @@ MOD_UNLOAD()
|
||||
|
||||
static int IsUsingColor(const char *s)
|
||||
{
|
||||
if (!s)
|
||||
return 0;
|
||||
if (!s)
|
||||
return 0;
|
||||
|
||||
for (; *s; s++)
|
||||
if (*s == 3 || *s == 27 || *s == 4 || *s == 22) /* mirc color, ansi, rgb, reverse */
|
||||
return 1;
|
||||
for (; *s; s++)
|
||||
if (*s == 3 || *s == 27 || *s == 4 || *s == 22) /* mirc color, ansi, rgb, reverse */
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nocolor_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx)
|
||||
|
||||
@@ -21,18 +21,17 @@
|
||||
|
||||
CMD_FUNC(noctcp);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/noctcp",
|
||||
"4.2",
|
||||
"Channel Mode +C",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/noctcp",
|
||||
"4.2",
|
||||
"Channel Mode +C",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NOCTCP;
|
||||
|
||||
#define IsNoCTCP(channel) (channel->mode.mode & EXTCMODE_NOCTCP)
|
||||
#define IsNoCTCP(channel) (channel->mode.mode & EXTCMODE_NOCTCP)
|
||||
|
||||
int noctcp_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx);
|
||||
|
||||
@@ -43,16 +42,16 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.paracount = 0;
|
||||
req.letter = 'C';
|
||||
req.is_ok = extcmode_default_requirehalfop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NOCTCP);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, noctcp_can_send_to_channel);
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -20,18 +20,17 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/noexternalmsgs",
|
||||
"6.0",
|
||||
"Channel Mode +n",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/noexternalmsgs",
|
||||
"6.0",
|
||||
"Channel Mode +n",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NO_EXTERNAL_MESSAGES;
|
||||
|
||||
#define IsNoExternalMessages(channel) (channel->mode.mode & EXTCMODE_NO_EXTERNAL_MESSAGES)
|
||||
#define IsNoExternalMessages(channel) (channel->mode.mode & EXTCMODE_NO_EXTERNAL_MESSAGES)
|
||||
|
||||
int noexternalmsgs_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx);
|
||||
|
||||
@@ -64,7 +63,7 @@ MOD_UNLOAD()
|
||||
|
||||
int noexternalmsgs_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx)
|
||||
{
|
||||
if (IsNoExternalMessages(channel) && !IsMember(client,channel))
|
||||
if (IsNoExternalMessages(channel) && !IsMember(client, channel))
|
||||
{
|
||||
/* Channel does not accept external messages (+n).
|
||||
* Reject, unless HOOKTYPE_CAN_BYPASS_NO_EXTERNAL_MSGS tells otherwise.
|
||||
|
||||
@@ -21,18 +21,17 @@
|
||||
|
||||
CMD_FUNC(noinvite);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/noinvite",
|
||||
"4.2",
|
||||
"Channel Mode +V",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/noinvite",
|
||||
"4.2",
|
||||
"Channel Mode +V",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NOINVITE;
|
||||
|
||||
#define IsNoInvite(channel) (channel->mode.mode & EXTCMODE_NOINVITE)
|
||||
#define IsNoInvite(channel) (channel->mode.mode & EXTCMODE_NOINVITE)
|
||||
|
||||
int noinvite_pre_knock(Client *client, Channel *channel, const char **reason);
|
||||
int noinvite_pre_invite(Client *client, Client *target, Channel *channel, int *override);
|
||||
@@ -51,10 +50,10 @@ MOD_INIT()
|
||||
req.letter = 'V';
|
||||
req.is_ok = extcmode_default_requirechop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NOINVITE);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_PRE_KNOCK, 0, noinvite_pre_knock);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_PRE_INVITE, 0, noinvite_pre_invite);
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -86,10 +85,11 @@ int noinvite_pre_invite(Client *client, Client *target, Channel *channel, int *o
|
||||
{
|
||||
if (MyUser(client) && IsNoInvite(channel))
|
||||
{
|
||||
if (ValidatePermissionsForPath("channel:override:invite:noinvite",client,NULL,channel,NULL) && client == target)
|
||||
if (ValidatePermissionsForPath("channel:override:invite:noinvite", client, NULL, channel, NULL) && client == target)
|
||||
{
|
||||
*override = 1;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
sendnumeric(client, ERR_NOINVITE, channel->name);
|
||||
return HOOK_DENY;
|
||||
}
|
||||
|
||||
@@ -20,20 +20,19 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/nokick",
|
||||
"4.2",
|
||||
"Channel Mode +Q",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/nokick",
|
||||
"4.2",
|
||||
"Channel Mode +Q",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NOKICK;
|
||||
|
||||
#define IsNoKick(channel) (channel->mode.mode & EXTCMODE_NOKICK)
|
||||
#define IsNoKick(channel) (channel->mode.mode & EXTCMODE_NOKICK)
|
||||
|
||||
int nokick_check (Client *client, Client *target, Channel *channel, const char *comment, const char *client_member_modes, const char *target_member_modes, const char **reject_reason);
|
||||
int nokick_check(Client *client, Client *target, Channel *channel, const char *comment, const char *client_member_modes, const char *target_member_modes, const char **reject_reason);
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -49,10 +48,10 @@ MOD_INIT()
|
||||
req.letter = 'Q';
|
||||
req.is_ok = extcmode_default_requirechop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NOKICK);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_KICK, 0, nokick_check);
|
||||
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -67,7 +66,7 @@ MOD_UNLOAD()
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
int nokick_check (Client *client, Client *target, Channel *channel, const char *comment, const char *client_member_modes, const char *target_member_modes, const char **reject_reason)
|
||||
int nokick_check(Client *client, Client *target, Channel *channel, const char *comment, const char *client_member_modes, const char *target_member_modes, const char **reject_reason)
|
||||
{
|
||||
static char errmsg[256];
|
||||
|
||||
@@ -82,4 +81,3 @@ int nokick_check (Client *client, Client *target, Channel *channel, const char *
|
||||
|
||||
return EX_ALLOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,22 +19,21 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/noknock",
|
||||
"4.2",
|
||||
"Channel Mode +K",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/noknock",
|
||||
"4.2",
|
||||
"Channel Mode +K",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NOKNOCK;
|
||||
|
||||
#define IsNoKnock(channel) (channel->mode.mode & EXTCMODE_NOKNOCK)
|
||||
#define IsNoKnock(channel) (channel->mode.mode & EXTCMODE_NOKNOCK)
|
||||
|
||||
int noknock_check_knock(Client *client, Channel *channel, const char **reason);
|
||||
int noknock_mode_allow(Client *client, Channel *channel, char mode, const char *para, int checkt, int what);
|
||||
int noknock_mode_del (Channel *channel, int modeChar);
|
||||
int noknock_mode_del(Channel *channel, int modeChar);
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -43,18 +42,18 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.paracount = 0;
|
||||
req.letter = 'K';
|
||||
req.is_ok = noknock_mode_allow;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NOKNOCK);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_PRE_KNOCK, 0, noknock_check_knock);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_MODECHAR_DEL, 0, noknock_mode_del);
|
||||
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -70,7 +69,7 @@ MOD_UNLOAD()
|
||||
}
|
||||
|
||||
|
||||
int noknock_check_knock (Client *client, Channel *channel, const char **reason)
|
||||
int noknock_check_knock(Client *client, Channel *channel, const char **reason)
|
||||
{
|
||||
if (MyUser(client) && IsNoKnock(channel))
|
||||
{
|
||||
@@ -81,7 +80,7 @@ int noknock_check_knock (Client *client, Channel *channel, const char **reason)
|
||||
return HOOK_CONTINUE;
|
||||
}
|
||||
|
||||
int noknock_mode_del (Channel *channel, int modeChar)
|
||||
int noknock_mode_del(Channel *channel, int modeChar)
|
||||
{
|
||||
// Remove noknock when we're removing invite only
|
||||
if (modeChar == 'i')
|
||||
|
||||
@@ -20,20 +20,19 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/nonickchange",
|
||||
"4.2",
|
||||
"Channel Mode +N",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/nonickchange",
|
||||
"4.2",
|
||||
"Channel Mode +N",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NONICKCHANGE;
|
||||
|
||||
#define IsNoNickChange(channel) (channel->mode.mode & EXTCMODE_NONICKCHANGE)
|
||||
#define IsNoNickChange(channel) (channel->mode.mode & EXTCMODE_NONICKCHANGE)
|
||||
|
||||
int nonickchange_check (Client *client, Channel *channel);
|
||||
int nonickchange_check(Client *client, Channel *channel);
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -42,17 +41,17 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.paracount = 0;
|
||||
req.letter = 'N';
|
||||
req.is_ok = extcmode_default_requirehalfop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NONICKCHANGE);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CHAN_PERMIT_NICK_CHANGE, 0, nonickchange_check);
|
||||
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -67,15 +66,12 @@ MOD_UNLOAD()
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
int nonickchange_check (Client *client, Channel *channel)
|
||||
int nonickchange_check(Client *client, Channel *channel)
|
||||
{
|
||||
if (!IsOper(client) && !IsULine(client)
|
||||
&& IsNoNickChange(channel)
|
||||
&& !check_channel_access(client, channel, "oaq"))
|
||||
if (!IsOper(client) && !IsULine(client) && IsNoNickChange(channel) && !check_channel_access(client, channel, "oaq"))
|
||||
{
|
||||
return HOOK_DENY;
|
||||
}
|
||||
|
||||
return HOOK_ALLOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,18 +19,17 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/nonotice",
|
||||
"4.2",
|
||||
"Channel Mode +T",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/nonotice",
|
||||
"4.2",
|
||||
"Channel Mode +T",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NONOTICE;
|
||||
|
||||
#define IsNoNotice(channel) (channel->mode.mode & EXTCMODE_NONOTICE)
|
||||
#define IsNoNotice(channel) (channel->mode.mode & EXTCMODE_NONOTICE)
|
||||
|
||||
int nonotice_check_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx);
|
||||
|
||||
@@ -48,7 +47,7 @@ MOD_INIT()
|
||||
req.letter = 'T';
|
||||
req.is_ok = extcmode_default_requirechop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NONOTICE);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, nonotice_check_can_send_to_channel);
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
@@ -21,14 +21,13 @@
|
||||
|
||||
CMD_FUNC(operonly);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/operonly",
|
||||
"4.2",
|
||||
"Channel Mode +O",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/operonly",
|
||||
"4.2",
|
||||
"Channel Mode +O",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_OPERONLY;
|
||||
|
||||
@@ -44,19 +43,19 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.paracount = 0;
|
||||
req.letter = 'O';
|
||||
req.is_ok = operonly_require_oper;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_OPERONLY);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_JOIN, 0, operonly_can_join);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_INVITE_BYPASS, 0, operonly_invite_bypass);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_VIEW_TOPIC_OUTSIDE_CHANNEL, 0, operonly_view_topic_outside_channel);
|
||||
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -73,7 +72,7 @@ MOD_UNLOAD()
|
||||
|
||||
int operonly_can_join(Client *client, Channel *channel, const char *key, char **errmsg)
|
||||
{
|
||||
if ((channel->mode.mode & EXTCMODE_OPERONLY) && !ValidatePermissionsForPath("channel:operonly:join",client,NULL,channel,NULL))
|
||||
if ((channel->mode.mode & EXTCMODE_OPERONLY) && !ValidatePermissionsForPath("channel:operonly:join", client, NULL, channel, NULL))
|
||||
{
|
||||
*errmsg = STR_ERR_OPERONLY;
|
||||
return ERR_OPERONLY;
|
||||
@@ -83,15 +82,15 @@ int operonly_can_join(Client *client, Channel *channel, const char *key, char **
|
||||
|
||||
int operonly_invite_bypass(Client *client, Channel *channel)
|
||||
{
|
||||
if ((channel->mode.mode & EXTCMODE_OPERONLY) && !ValidatePermissionsForPath("channel:operonly:ban",client,NULL,NULL,NULL))
|
||||
return HOOK_DENY;
|
||||
if ((channel->mode.mode & EXTCMODE_OPERONLY) && !ValidatePermissionsForPath("channel:operonly:ban", client, NULL, NULL, NULL))
|
||||
return HOOK_DENY;
|
||||
|
||||
return HOOK_CONTINUE;
|
||||
return HOOK_CONTINUE;
|
||||
}
|
||||
|
||||
int operonly_view_topic_outside_channel(Client *client, Channel *channel)
|
||||
{
|
||||
if (channel->mode.mode & EXTCMODE_OPERONLY && !ValidatePermissionsForPath("channel:operonly:topic",client,NULL,channel,NULL))
|
||||
if (channel->mode.mode & EXTCMODE_OPERONLY && !ValidatePermissionsForPath("channel:operonly:topic", client, NULL, channel, NULL))
|
||||
return HOOK_DENY;
|
||||
|
||||
return HOOK_CONTINUE;
|
||||
@@ -99,7 +98,7 @@ int operonly_view_topic_outside_channel(Client *client, Channel *channel)
|
||||
|
||||
int operonly_require_oper(Client *client, Channel *channel, char mode, const char *para, int checkt, int what)
|
||||
{
|
||||
if (!MyUser(client) || ValidatePermissionsForPath("channel:operonly:set",client,NULL,channel,NULL))
|
||||
if (!MyUser(client) || ValidatePermissionsForPath("channel:operonly:set", client, NULL, channel, NULL))
|
||||
return EX_ALLOW;
|
||||
|
||||
if (checkt == EXCHK_ACCESS_ERR)
|
||||
@@ -107,4 +106,3 @@ int operonly_require_oper(Client *client, Channel *channel, char mode, const cha
|
||||
|
||||
return EX_DENY;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/permanent",
|
||||
"4.2",
|
||||
"Permanent channel mode (+P)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/permanent",
|
||||
"4.2",
|
||||
"Permanent channel mode (+P)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
static Cmode_t EXTMODE_PERMANENT = 0L;
|
||||
|
||||
@@ -34,7 +33,7 @@ static int permanent_channel_destroy(Channel *channel, int *should_destroy)
|
||||
{
|
||||
if (channel->mode.mode & EXTMODE_PERMANENT)
|
||||
*should_destroy = 0;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -62,14 +61,14 @@ int permanent_chanmode(Client *client, Channel *channel, MessageTag *mtags, cons
|
||||
sub1_from_channel(channel);
|
||||
*destroy_channel = 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This is called on module init, before Server Ready */
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
@@ -97,4 +96,3 @@ MOD_UNLOAD()
|
||||
{
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,18 +20,17 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/private",
|
||||
"6.0",
|
||||
"Channel Mode +p",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/private",
|
||||
"6.0",
|
||||
"Channel Mode +p",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_PRIVATE;
|
||||
|
||||
#define IsPrivate(channel) (channel->mode.mode & EXTCMODE_PRIVATE)
|
||||
#define IsPrivate(channel) (channel->mode.mode & EXTCMODE_PRIVATE)
|
||||
|
||||
int private_modechar_add(Channel *channel, int modechar);
|
||||
|
||||
|
||||
@@ -20,18 +20,17 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/regonly",
|
||||
"4.2",
|
||||
"Channel Mode +R",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/regonly",
|
||||
"4.2",
|
||||
"Channel Mode +R",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_REGONLY;
|
||||
|
||||
#define IsRegOnly(channel) (channel->mode.mode & EXTCMODE_REGONLY)
|
||||
#define IsRegOnly(channel) (channel->mode.mode & EXTCMODE_REGONLY)
|
||||
|
||||
int regonly_check(Client *client, Channel *channel, const char *key, char **errmsg);
|
||||
|
||||
@@ -43,17 +42,17 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.paracount = 0;
|
||||
req.letter = 'R';
|
||||
req.is_ok = extcmode_default_requirehalfop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_REGONLY);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_JOIN, 0, regonly_check);
|
||||
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -68,7 +67,7 @@ MOD_UNLOAD()
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
int regonly_check (Client *client, Channel *channel, const char *key, char **errmsg)
|
||||
int regonly_check(Client *client, Channel *channel, const char *key, char **errmsg)
|
||||
{
|
||||
if (IsRegOnly(channel) && !IsLoggedIn(client))
|
||||
{
|
||||
@@ -77,4 +76,3 @@ int regonly_check (Client *client, Channel *channel, const char *key, char **err
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,22 +20,21 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/regonlyspeak",
|
||||
"4.2",
|
||||
"Channel Mode +M",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/regonlyspeak",
|
||||
"4.2",
|
||||
"Channel Mode +M",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_REGONLYSPEAK;
|
||||
static char errMsg[2048];
|
||||
|
||||
#define IsRegOnlySpeak(channel) (channel->mode.mode & EXTCMODE_REGONLYSPEAK)
|
||||
#define IsRegOnlySpeak(channel) (channel->mode.mode & EXTCMODE_REGONLYSPEAK)
|
||||
|
||||
int regonlyspeak_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx);
|
||||
const char *regonlyspeak_part_message (Client *client, Channel *channel, const char *comment);
|
||||
const char *regonlyspeak_part_message(Client *client, Channel *channel, const char *comment);
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -51,11 +50,11 @@ MOD_INIT()
|
||||
req.letter = 'M';
|
||||
req.is_ok = extcmode_default_requirehalfop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_REGONLYSPEAK);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, regonlyspeak_can_send_to_channel);
|
||||
HookAddConstString(modinfo->handle, HOOKTYPE_PRE_LOCAL_PART, 0, regonlyspeak_part_message);
|
||||
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -70,12 +69,12 @@ MOD_UNLOAD()
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
const char *regonlyspeak_part_message (Client *client, Channel *channel, const char *comment)
|
||||
const char *regonlyspeak_part_message(Client *client, Channel *channel, const char *comment)
|
||||
{
|
||||
if (!comment)
|
||||
return NULL;
|
||||
|
||||
if (IsRegOnlySpeak(channel) && !IsLoggedIn(client) && !ValidatePermissionsForPath("channel:override:message:regonlyspeak",client,NULL,NULL,NULL))
|
||||
if (IsRegOnlySpeak(channel) && !IsLoggedIn(client) && !ValidatePermissionsForPath("channel:override:message:regonlyspeak", client, NULL, NULL, NULL))
|
||||
return NULL;
|
||||
|
||||
return comment;
|
||||
@@ -87,7 +86,7 @@ int regonlyspeak_can_send_to_channel(Client *client, Channel *channel, Membershi
|
||||
int i;
|
||||
|
||||
if (IsRegOnlySpeak(channel) &&
|
||||
!op_can_override("channel:override:message:regonlyspeak",client,channel,NULL) &&
|
||||
!op_can_override("channel:override:message:regonlyspeak", client, channel, NULL) &&
|
||||
!IsLoggedIn(client) &&
|
||||
!check_channel_access_membership(lp, "vhoaq"))
|
||||
{
|
||||
|
||||
@@ -20,18 +20,17 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/secret",
|
||||
"6.0",
|
||||
"Channel Mode +s",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/secret",
|
||||
"6.0",
|
||||
"Channel Mode +s",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_SECRET;
|
||||
|
||||
#define IsSecret(channel) (channel->mode.mode & EXTCMODE_SECRET)
|
||||
#define IsSecret(channel) (channel->mode.mode & EXTCMODE_SECRET)
|
||||
|
||||
int secret_modechar_add(Channel *channel, int modechar);
|
||||
|
||||
|
||||
@@ -19,21 +19,20 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/secureonly",
|
||||
"4.2",
|
||||
"Channel Mode +z",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/secureonly",
|
||||
"4.2",
|
||||
"Channel Mode +z",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_SECUREONLY;
|
||||
|
||||
#define IsSecureOnly(channel) (channel->mode.mode & EXTCMODE_SECUREONLY)
|
||||
#define IsSecureOnly(channel) (channel->mode.mode & EXTCMODE_SECUREONLY)
|
||||
|
||||
int secureonly_check_join(Client *client, Channel *channel, const char *key, char **errmsg);
|
||||
int secureonly_channel_sync (Channel *channel, int merge, int removetheirs, int nomode);
|
||||
int secureonly_channel_sync(Channel *channel, int merge, int removetheirs, int nomode);
|
||||
int secureonly_check_secure(Channel *channel);
|
||||
int secureonly_check_sajoin(Client *target, Channel *channel, Client *requester);
|
||||
int secureonly_pre_local_join(Client *client, Channel *channel, const char *key);
|
||||
@@ -109,10 +108,10 @@ static int secureonly_kick_insecure_users(Channel *channel)
|
||||
RunHook(HOOKTYPE_LOCAL_KICK, &me, &me, client, channel, mtags, comment);
|
||||
|
||||
sendto_channel(channel, &me, client,
|
||||
prefix, 0,
|
||||
SEND_LOCAL, mtags,
|
||||
":%s KICK %s %s :%s",
|
||||
me.name, channel->name, client->name, comment);
|
||||
prefix, 0,
|
||||
SEND_LOCAL, mtags,
|
||||
":%s KICK %s %s :%s",
|
||||
me.name, channel->name, client->name, comment);
|
||||
|
||||
sendto_prefix_one(client, &me, mtags, ":%s KICK %s %s :%s", me.name, channel->name, client->name, comment);
|
||||
|
||||
@@ -133,7 +132,7 @@ int secureonly_check_join(Client *client, Channel *channel, const char *key, cha
|
||||
|
||||
if (IsSecureOnly(channel) && !(client->umodes & UMODE_SECURE))
|
||||
{
|
||||
if (ValidatePermissionsForPath("channel:override:secureonly",client,NULL,channel,NULL))
|
||||
if (ValidatePermissionsForPath("channel:override:secureonly", client, NULL, channel, NULL))
|
||||
{
|
||||
/* if the channel is +z we still allow an ircop to bypass it
|
||||
* if they are invited.
|
||||
@@ -169,7 +168,7 @@ int secureonly_check_sajoin(Client *target, Channel *channel, Client *requester)
|
||||
if (IsSecureOnly(channel) && !IsSecure(target))
|
||||
{
|
||||
sendnotice(requester, "You cannot SAJOIN %s to %s because the channel is +z and the user is not connected via TLS",
|
||||
target->name, channel->name);
|
||||
target->name, channel->name);
|
||||
return HOOK_DENY;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,18 +21,17 @@
|
||||
|
||||
CMD_FUNC(stripcolor);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/stripcolor",
|
||||
"4.2",
|
||||
"Channel Mode +S",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/stripcolor",
|
||||
"4.2",
|
||||
"Channel Mode +S",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_STRIPCOLOR;
|
||||
|
||||
#define IsStripColor(channel) (channel->mode.mode & EXTCMODE_STRIPCOLOR)
|
||||
#define IsStripColor(channel) (channel->mode.mode & EXTCMODE_STRIPCOLOR)
|
||||
|
||||
int stripcolor_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx);
|
||||
const char *stripcolor_prelocalpart(Client *client, Channel *channel, const char *comment);
|
||||
@@ -45,7 +44,7 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
/* Channel mode */
|
||||
memset(&req, 0, sizeof(req));
|
||||
@@ -53,12 +52,12 @@ CmodeInfo req;
|
||||
req.letter = 'S';
|
||||
req.is_ok = extcmode_default_requirechop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_STRIPCOLOR);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, stripcolor_can_send_to_channel);
|
||||
HookAddConstString(modinfo->handle, HOOKTYPE_PRE_LOCAL_PART, 0, stripcolor_prelocalpart);
|
||||
HookAddConstString(modinfo->handle, HOOKTYPE_PRE_LOCAL_QUIT_CHAN, 0, stripcolor_prelocalpart);
|
||||
HookAddConstString(modinfo->handle, HOOKTYPE_PRE_LOCAL_QUIT, 0, stripcolor_prelocalquit);
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -125,7 +124,6 @@ const char *stripcolor_prelocalquit(Client *client, const char *comment)
|
||||
|
||||
if (MyUser(client) && !BadPtr(comment) && IsAnyChannelStripColor(client))
|
||||
comment = StripColors(comment);
|
||||
|
||||
|
||||
return comment;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,13 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/topiclimit",
|
||||
"6.0",
|
||||
"Channel Mode +t",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/topiclimit",
|
||||
"6.0",
|
||||
"Channel Mode +t",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Global variables */
|
||||
Cmode_t EXTCMODE_TOPIC_LIMIT;
|
||||
@@ -36,7 +35,7 @@ Cmode_t EXTCMODE_TOPIC_LIMIT;
|
||||
int topiclimit_can_set_topic(Client *client, Channel *channel, const char *topic, const char **errmsg);
|
||||
|
||||
/* Macros */
|
||||
#define IsTopicLimit(channel) (channel->mode.mode & EXTCMODE_TOPIC_LIMIT)
|
||||
#define IsTopicLimit(channel) (channel->mode.mode & EXTCMODE_TOPIC_LIMIT)
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
@@ -66,7 +65,7 @@ MOD_UNLOAD()
|
||||
|
||||
int topiclimit_can_set_topic(Client *client, Channel *channel, const char *topic, const char **errmsg)
|
||||
{
|
||||
static char errmsg_buf[NICKLEN+256];
|
||||
static char errmsg_buf[NICKLEN + 256];
|
||||
|
||||
if (has_channel_mode(channel, 't') &&
|
||||
!check_channel_access(client, channel, "hoaq") &&
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/voice",
|
||||
"6.0",
|
||||
"Channel Mode +v",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/voice",
|
||||
"6.0",
|
||||
"Channel Mode +v",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cmode_voice_is_ok(Client *client, Channel *channel, char mode, const char *para, int type, int what);
|
||||
|
||||
@@ -22,14 +22,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"channel-context",
|
||||
"1.0",
|
||||
"Channel Context (IRCv3)",
|
||||
"UnrealIRCd team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"channel-context",
|
||||
"1.0",
|
||||
"Channel Context (IRCv3)",
|
||||
"UnrealIRCd team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
int chancontext_mtag_is_ok(Client *client, const char *name, const char *value);
|
||||
void mtag_add_chancontext(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
|
||||
|
||||
+46
-38
@@ -7,11 +7,11 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"channeldb",
|
||||
"1.0",
|
||||
"Stores and retrieves channel settings for persistent (+P) channels",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
"channeldb",
|
||||
"1.0",
|
||||
"Stores and retrieves channel settings for persistent (+P) channels",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Database version */
|
||||
@@ -24,35 +24,40 @@ ModuleHeader MOD_HEADER = {
|
||||
*/
|
||||
#define CHANNELDB_SAVE_EVERY_DELTA -15
|
||||
|
||||
#define MAGIC_CHANNEL_START 0x11111111
|
||||
#define MAGIC_CHANNEL_END 0x22222222
|
||||
#define MAGIC_CHANNEL_START 0x11111111
|
||||
#define MAGIC_CHANNEL_END 0x22222222
|
||||
|
||||
// #undef BENCHMARK
|
||||
|
||||
#define WARN_WRITE_ERROR(fname) \
|
||||
do { \
|
||||
do \
|
||||
{ \
|
||||
unreal_log(ULOG_ERROR, "channeldb", "CHANNELDB_FILE_WRITE_ERROR", NULL, \
|
||||
"[channeldb] Error writing to temporary database file $filename: $system_error", \
|
||||
log_data_string("filename", fname), \
|
||||
log_data_string("system_error", unrealdb_get_error_string())); \
|
||||
} while(0)
|
||||
"[channeldb] Error writing to temporary database file $filename: $system_error", \
|
||||
log_data_string("filename", fname), \
|
||||
log_data_string("system_error", unrealdb_get_error_string())); \
|
||||
} while (0)
|
||||
|
||||
#define W_SAFE(x) \
|
||||
do { \
|
||||
if (!(x)) { \
|
||||
do \
|
||||
{ \
|
||||
if (!(x)) \
|
||||
{ \
|
||||
WARN_WRITE_ERROR(tmpfname); \
|
||||
unrealdb_close(db); \
|
||||
return 0; \
|
||||
} \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
#define IsMDErr(x, y, z) \
|
||||
do { \
|
||||
if (!(x)) { \
|
||||
do \
|
||||
{ \
|
||||
if (!(x)) \
|
||||
{ \
|
||||
config_error("A critical error occurred when registering ModData for %s: %s", MOD_HEADER.name, ModuleGetErrorStr((z)->handle)); \
|
||||
return MOD_FAILED; \
|
||||
} \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
/* Structs */
|
||||
struct cfgstruct {
|
||||
@@ -175,13 +180,11 @@ int channeldb_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
{
|
||||
config_error("%s:%i: blank set::channeldb::%s without value", cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "database"))
|
||||
} else if (!strcmp(cep->name, "database"))
|
||||
{
|
||||
convert_to_absolute_path(&cep->value, PERMDATADIR);
|
||||
safe_strdup(test.database, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "db-secret"))
|
||||
} else if (!strcmp(cep->name, "db-secret"))
|
||||
{
|
||||
const char *err;
|
||||
if ((err = unrealdb_test_secret(cep->value)))
|
||||
@@ -270,12 +273,12 @@ int write_channeldb(void)
|
||||
W_SAFE(unrealdb_write_int32(db, channeldb_version));
|
||||
|
||||
/* First, count +P channels and write the count to the database */
|
||||
for (channel = channels; channel; channel=channel->nextch)
|
||||
for (channel = channels; channel; channel = channel->nextch)
|
||||
if (has_channel_mode(channel, 'P'))
|
||||
cnt++;
|
||||
W_SAFE(unrealdb_write_int64(db, cnt));
|
||||
|
||||
for (channel = channels; channel; channel=channel->nextch)
|
||||
for (channel = channels; channel; channel = channel->nextch)
|
||||
{
|
||||
/* We only care about +P (persistent) channels */
|
||||
if (has_channel_mode(channel, 'P'))
|
||||
@@ -304,7 +307,7 @@ int write_channeldb(void)
|
||||
#ifdef BENCHMARK
|
||||
gettimeofday(&tv_beta, NULL);
|
||||
config_status("[channeldb] Benchmark: SAVE DB: %ld microseconds",
|
||||
((tv_beta.tv_sec - tv_alpha.tv_sec) * 1000000) + (tv_beta.tv_usec - tv_alpha.tv_usec));
|
||||
((tv_beta.tv_sec - tv_alpha.tv_sec) * 1000000) + (tv_beta.tv_usec - tv_alpha.tv_usec));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -360,8 +363,10 @@ int write_channel_entry(UnrealDB *db, const char *tmpfname, Channel *channel)
|
||||
}
|
||||
|
||||
#define R_SAFE(x) \
|
||||
do { \
|
||||
if (!(x)) { \
|
||||
do \
|
||||
{ \
|
||||
if (!(x)) \
|
||||
{ \
|
||||
config_warn("[channeldb] Read error from database file '%s' (possible corruption): %s", cfg.database, unrealdb_get_error_string()); \
|
||||
if (e) \
|
||||
{ \
|
||||
@@ -371,7 +376,7 @@ int write_channel_entry(UnrealDB *db, const char *tmpfname, Channel *channel)
|
||||
} \
|
||||
return 0; \
|
||||
} \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
int read_listmode(UnrealDB *db, Channel *channel, ExtbanType ban_type, Ban **lst)
|
||||
{
|
||||
@@ -407,7 +412,8 @@ int read_listmode(UnrealDB *db, Channel *channel, ExtbanType ban_type, Ban **lst
|
||||
safe_free(e->banstr);
|
||||
safe_free(e->who);
|
||||
safe_free(e);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Add to list */
|
||||
e->when = when;
|
||||
e->next = *lst;
|
||||
@@ -420,7 +426,8 @@ int read_listmode(UnrealDB *db, Channel *channel, ExtbanType ban_type, Ban **lst
|
||||
#undef R_SAFE
|
||||
|
||||
#define FreeChannelEntry() \
|
||||
do { \
|
||||
do \
|
||||
{ \
|
||||
/* Some of these might be NULL */ \
|
||||
safe_free(chname); \
|
||||
safe_free(topic); \
|
||||
@@ -428,17 +435,19 @@ int read_listmode(UnrealDB *db, Channel *channel, ExtbanType ban_type, Ban **lst
|
||||
safe_free(modes1); \
|
||||
safe_free(modes2); \
|
||||
safe_free(mode_lock); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
#define R_SAFE(x) \
|
||||
do { \
|
||||
if (!(x)) { \
|
||||
do \
|
||||
{ \
|
||||
if (!(x)) \
|
||||
{ \
|
||||
config_warn("[channeldb] Read error from database file '%s' (possible corruption): %s", cfg.database, unrealdb_get_error_string()); \
|
||||
unrealdb_close(db); \
|
||||
FreeChannelEntry(); \
|
||||
return 0; \
|
||||
} \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
int read_channeldb(void)
|
||||
{
|
||||
@@ -472,8 +481,7 @@ int read_channeldb(void)
|
||||
/* Database does not exist. Could be first boot */
|
||||
config_warn("[channeldb] No database present at '%s', will start a new one", cfg.database);
|
||||
return 1;
|
||||
} else
|
||||
if (unrealdb_get_error_code() == UNREALDB_ERROR_NOTCRYPTED)
|
||||
} else if (unrealdb_get_error_code() == UNREALDB_ERROR_NOTCRYPTED)
|
||||
{
|
||||
/* Re-open as unencrypted */
|
||||
db = unrealdb_open(cfg.database, UNREALDB_MODE_READ, NULL);
|
||||
@@ -500,7 +508,7 @@ int read_channeldb(void)
|
||||
|
||||
R_SAFE(unrealdb_read_int64(db, &count));
|
||||
|
||||
for (i=1; i <= count; i++)
|
||||
for (i = 1; i <= count; i++)
|
||||
{
|
||||
// Variables
|
||||
chname = NULL;
|
||||
@@ -511,7 +519,7 @@ int read_channeldb(void)
|
||||
modes1 = NULL;
|
||||
modes2 = NULL;
|
||||
mode_lock = NULL;
|
||||
|
||||
|
||||
Channel *channel;
|
||||
R_SAFE(unrealdb_read_int32(db, &magic));
|
||||
if (magic != MAGIC_CHANNEL_START)
|
||||
|
||||
+61
-65
@@ -23,16 +23,15 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
#ifndef ARRAY_SIZEOF
|
||||
#define ARRAY_SIZEOF(x) (sizeof((x))/sizeof((x)[0]))
|
||||
#define ARRAY_SIZEOF(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"charsys", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"Character System (set::allowed-nickchars)", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"charsys", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"Character System (set::allowed-nickchars)", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* NOTE: it is guaranteed that char is unsigned by compiling options
|
||||
@@ -43,8 +42,7 @@ ModuleHeader MOD_HEADER
|
||||
|
||||
/** Our multibyte structure */
|
||||
typedef struct MBList MBList;
|
||||
struct MBList
|
||||
{
|
||||
struct MBList {
|
||||
MBList *next;
|
||||
char s1, e1, s2, e2;
|
||||
};
|
||||
@@ -57,26 +55,25 @@ static int langav = 0;
|
||||
char langsinuse[4096];
|
||||
|
||||
/* bitmasks: */
|
||||
#define LANGAV_ASCII 0x000001 /* 8 bit ascii */
|
||||
#define LANGAV_LATIN1 0x000002 /* latin1 (western europe) */
|
||||
#define LANGAV_LATIN2 0x000004 /* latin2 (eastern europe, eg: polish) */
|
||||
#define LANGAV_ISO8859_7 0x000008 /* greek */
|
||||
#define LANGAV_ISO8859_8I 0x000010 /* hebrew */
|
||||
#define LANGAV_ISO8859_9 0x000020 /* turkish */
|
||||
#define LANGAV_W1250 0x000040 /* windows-1250 (eg: polish-w1250) */
|
||||
#define LANGAV_W1251 0x000080 /* windows-1251 (eg: russian) */
|
||||
#define LANGAV_LATIN2W1250 0x000100 /* Compatible with both latin2 AND windows-1250 (eg: hungarian) */
|
||||
#define LANGAV_ISO8859_6 0x000200 /* arabic */
|
||||
#define LANGAV_GBK 0x001000 /* (Chinese) GBK encoding */
|
||||
#define LANGAV_UTF8 0x002000 /* any UTF8 encoding */
|
||||
#define LANGAV_LATIN_UTF8 0x004000 /* UTF8: latin script */
|
||||
#define LANGAV_CYRILLIC_UTF8 0x008000 /* UTF8: cyrillic script */
|
||||
#define LANGAV_GREEK_UTF8 0x010000 /* UTF8: greek script */
|
||||
#define LANGAV_HEBREW_UTF8 0x020000 /* UTF8: hebrew script */
|
||||
#define LANGAV_ARABIC_UTF8 0x040000 /* UTF8: arabic script */
|
||||
#define LANGAV_ASCII 0x000001 /* 8 bit ascii */
|
||||
#define LANGAV_LATIN1 0x000002 /* latin1 (western europe) */
|
||||
#define LANGAV_LATIN2 0x000004 /* latin2 (eastern europe, eg: polish) */
|
||||
#define LANGAV_ISO8859_7 0x000008 /* greek */
|
||||
#define LANGAV_ISO8859_8I 0x000010 /* hebrew */
|
||||
#define LANGAV_ISO8859_9 0x000020 /* turkish */
|
||||
#define LANGAV_W1250 0x000040 /* windows-1250 (eg: polish-w1250) */
|
||||
#define LANGAV_W1251 0x000080 /* windows-1251 (eg: russian) */
|
||||
#define LANGAV_LATIN2W1250 0x000100 /* Compatible with both latin2 AND windows-1250 (eg: hungarian) */
|
||||
#define LANGAV_ISO8859_6 0x000200 /* arabic */
|
||||
#define LANGAV_GBK 0x001000 /* (Chinese) GBK encoding */
|
||||
#define LANGAV_UTF8 0x002000 /* any UTF8 encoding */
|
||||
#define LANGAV_LATIN_UTF8 0x004000 /* UTF8: latin script */
|
||||
#define LANGAV_CYRILLIC_UTF8 0x008000 /* UTF8: cyrillic script */
|
||||
#define LANGAV_GREEK_UTF8 0x010000 /* UTF8: greek script */
|
||||
#define LANGAV_HEBREW_UTF8 0x020000 /* UTF8: hebrew script */
|
||||
#define LANGAV_ARABIC_UTF8 0x040000 /* UTF8: arabic script */
|
||||
typedef struct LangList LangList;
|
||||
struct LangList
|
||||
{
|
||||
struct LangList {
|
||||
char *directive;
|
||||
char *code;
|
||||
int setflags;
|
||||
@@ -149,8 +146,7 @@ static LangList langlist[] = {
|
||||
|
||||
/* For temporary use during config_run */
|
||||
typedef struct ILangList ILangList;
|
||||
struct ILangList
|
||||
{
|
||||
struct ILangList {
|
||||
ILangList *prev, *next;
|
||||
char *name;
|
||||
};
|
||||
@@ -237,20 +233,20 @@ int charsys_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (ce->value)
|
||||
{
|
||||
config_error("%s:%i: set::allowed-nickchars: please use 'allowed-nickchars { name; };' "
|
||||
"and not 'allowed-nickchars name;'",
|
||||
ce->file->filename, ce->line_number);
|
||||
"and not 'allowed-nickchars name;'",
|
||||
ce->file->filename, ce->line_number);
|
||||
/* Give up immediately. Don't bother the user with any other errors. */
|
||||
errors++;
|
||||
*errs = errors;
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (cep = ce->items; cep; cep=cep->next)
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!charsys_test_language(cep->name))
|
||||
{
|
||||
config_error("%s:%i: set::allowed-nickchars: Unknown (sub)language '%s'",
|
||||
ce->file->filename, ce->line_number, cep->name);
|
||||
ce->file->filename, ce->line_number, cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -283,7 +279,7 @@ int charsys_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
int charsys_config_posttest(int *errs)
|
||||
{
|
||||
int errors = 0;
|
||||
int x=0;
|
||||
int x = 0;
|
||||
|
||||
if ((langav & LANGAV_ASCII) && (langav & LANGAV_GBK))
|
||||
{
|
||||
@@ -315,7 +311,7 @@ int charsys_config_posttest(int *errs)
|
||||
if (langav & LANGAV_W1251)
|
||||
x++;
|
||||
if ((langav & LANGAV_LATIN2W1250) && !(langav & LANGAV_LATIN2) && !(langav & LANGAV_W1250))
|
||||
x++;
|
||||
x++;
|
||||
if (x > 1)
|
||||
{
|
||||
#if 0
|
||||
@@ -356,12 +352,12 @@ int charsys_config_posttest(int *errs)
|
||||
void charsys_free_mblist(void)
|
||||
{
|
||||
MBList *m, *m_next;
|
||||
for (m=mblist; m; m=m_next)
|
||||
for (m = mblist; m; m = m_next)
|
||||
{
|
||||
m_next = m->next;
|
||||
safe_free(m);
|
||||
}
|
||||
mblist=mblist_tail=NULL;
|
||||
mblist = mblist_tail = NULL;
|
||||
}
|
||||
|
||||
/** Called on boot and just before config run */
|
||||
@@ -371,7 +367,7 @@ void charsys_reset(void)
|
||||
MBList *m, *m_next;
|
||||
|
||||
/* First, reset everything */
|
||||
for (i=0; i < 256; i++)
|
||||
for (i = 0; i < 256; i++)
|
||||
char_atribs[i] &= ~ALLOWN;
|
||||
charsys_free_mblist();
|
||||
/* Then add the default which will always be allowed */
|
||||
@@ -404,9 +400,9 @@ static void ilang_sort(void)
|
||||
/* Selection sort -- perhaps optimize to qsort/whatever if
|
||||
* possible? ;)
|
||||
*/
|
||||
for (outer=ilanglist; outer; outer=outer->next)
|
||||
for (outer = ilanglist; outer; outer = outer->next)
|
||||
{
|
||||
for (inner=outer->next; inner; inner=inner->next)
|
||||
for (inner = outer->next; inner; inner = inner->next)
|
||||
{
|
||||
if (strcmp(outer->name, inner->name) > 0)
|
||||
ilang_swap(outer, inner);
|
||||
@@ -423,7 +419,7 @@ void charsys_finish(void)
|
||||
|
||||
/* [note: this can be optimized] */
|
||||
langsinuse[0] = '\0';
|
||||
for (e=ilanglist; e; e=e->next)
|
||||
for (e = ilanglist; e; e = e->next)
|
||||
{
|
||||
strlcat(langsinuse, e->name, sizeof(langsinuse));
|
||||
if (e->next)
|
||||
@@ -431,9 +427,9 @@ void charsys_finish(void)
|
||||
}
|
||||
|
||||
/* Free everything */
|
||||
for (e=ilanglist; e; e=e_next)
|
||||
for (e = ilanglist; e; e = e_next)
|
||||
{
|
||||
e_next=e->next;
|
||||
e_next = e->next;
|
||||
safe_free(e->name);
|
||||
safe_free(e);
|
||||
}
|
||||
@@ -454,7 +450,7 @@ void charsys_finish(void)
|
||||
*/
|
||||
void charsys_addmultibyterange(char s1, char e1, char s2, char e2)
|
||||
{
|
||||
MBList *m = safe_alloc(sizeof(MBList));
|
||||
MBList *m = safe_alloc(sizeof(MBList));
|
||||
|
||||
m->s1 = s1;
|
||||
m->e1 = e1;
|
||||
@@ -508,7 +504,7 @@ static int do_nick_name_standard(char *nick)
|
||||
if ((*nick == '-') || isdigit(*nick))
|
||||
return 0;
|
||||
|
||||
for (ch=nick,len=0; *ch && len <= NICKLEN; ch++, len++)
|
||||
for (ch = nick, len = 0; *ch && len <= NICKLEN; ch++, len++)
|
||||
if (!isvalid(*ch))
|
||||
return 0; /* reject the full nick */
|
||||
*ch = '\0';
|
||||
@@ -519,11 +515,11 @@ static int isvalidmbyte(unsigned char c1, unsigned char c2)
|
||||
{
|
||||
MBList *m;
|
||||
|
||||
for (m=mblist; m; m=m->next)
|
||||
for (m = mblist; m; m = m->next)
|
||||
{
|
||||
if ((c1 >= m->s1) && (c1 <= m->e1) &&
|
||||
(c2 >= m->s2) && (c2 <= m->e2))
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -541,7 +537,7 @@ static int do_nick_name_multibyte(char *nick)
|
||||
if ((*nick == '-') || isdigit(*nick))
|
||||
return 0;
|
||||
|
||||
for (ch=nick,len=0; *ch && len <= NICKLEN; ch++, len++)
|
||||
for (ch = nick, len = 0; *ch && len <= NICKLEN; ch++, len++)
|
||||
{
|
||||
/* Some characters are ALWAYS illegal, so they have to be disallowed here */
|
||||
if ((*ch <= 32) || strchr(illegalnickchars, *ch))
|
||||
@@ -580,7 +576,7 @@ int _do_remote_nick_name(char *nick)
|
||||
return 0;
|
||||
|
||||
/* Now the other, more relaxed checks.. */
|
||||
for (c=nick; *c; c++)
|
||||
for (c = nick; *c; c++)
|
||||
if ((*c <= 32) || strchr(illegalnickchars, *c))
|
||||
return 0;
|
||||
|
||||
@@ -590,18 +586,18 @@ int _do_remote_nick_name(char *nick)
|
||||
static LangList *charsys_find_language(char *name)
|
||||
{
|
||||
int start = 0;
|
||||
int stop = ARRAY_SIZEOF(langlist)-1;
|
||||
int stop = ARRAY_SIZEOF(langlist) - 1;
|
||||
int mid;
|
||||
|
||||
while (start <= stop)
|
||||
{
|
||||
mid = (start+stop)/2;
|
||||
mid = (start + stop) / 2;
|
||||
if (!langlist[mid].directive || smycmp(name, langlist[mid].directive) < 0)
|
||||
stop = mid-1;
|
||||
stop = mid - 1;
|
||||
else if (strcmp(name, langlist[mid].directive) == 0)
|
||||
return &langlist[mid];
|
||||
else
|
||||
start = mid+1;
|
||||
start = mid + 1;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -637,10 +633,10 @@ int charsys_test_language(char *name)
|
||||
|
||||
static void charsys_doadd_language(char *name)
|
||||
{
|
||||
LangList *l;
|
||||
ILangList *li;
|
||||
int found;
|
||||
char tmp[512], *lang, *p;
|
||||
LangList *l;
|
||||
ILangList *li;
|
||||
int found;
|
||||
char tmp[512], *lang, *p;
|
||||
|
||||
l = charsys_find_language(name);
|
||||
if (!l)
|
||||
@@ -655,8 +651,8 @@ char tmp[512], *lang, *p;
|
||||
for (lang = strtoken(&p, tmp, ","); lang; lang = strtoken(&p, NULL, ","))
|
||||
{
|
||||
/* Check if present... */
|
||||
found=0;
|
||||
for (li=ilanglist; li; li=li->next)
|
||||
found = 0;
|
||||
for (li = ilanglist; li; li = li->next)
|
||||
if (!strcmp(li->name, lang))
|
||||
{
|
||||
found = 1;
|
||||
@@ -674,8 +670,8 @@ char tmp[512], *lang, *p;
|
||||
|
||||
void charsys_add_language(char *name)
|
||||
{
|
||||
char latin1=0, latin2=0, w1250=0, w1251=0, chinese=0;
|
||||
char latin_utf8=0, cyrillic_utf8=0;
|
||||
char latin1 = 0, latin2 = 0, w1250 = 0, w1251 = 0, chinese = 0;
|
||||
char latin_utf8 = 0, cyrillic_utf8 = 0;
|
||||
|
||||
/** Note: there could well be some characters missing in the lists below.
|
||||
* While I've seen other altnernatives that just allow pretty much
|
||||
@@ -1245,9 +1241,9 @@ char *charsys_displaychars(void)
|
||||
* try this instead (lazy).. this is only used in DEBUGMODE
|
||||
* via a command line option anyway:
|
||||
*/
|
||||
for (i=0; i <= 255; i++)
|
||||
for (i = 0; i <= 255; i++)
|
||||
{
|
||||
for (j=0; j <= 255; j++)
|
||||
for (j = 0; j <= 255; j++)
|
||||
{
|
||||
if (isvalidmbyte(i, j))
|
||||
{
|
||||
|
||||
+32
-34
@@ -7,13 +7,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chathistory",
|
||||
"1.0",
|
||||
"IRCv3 CHATHISTORY command",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chathistory",
|
||||
"1.0",
|
||||
"IRCv3 CHATHISTORY command",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Structs */
|
||||
@@ -123,7 +122,8 @@ static void add_chathistory_target_list(ChatHistoryTarget *new, ChatHistoryTarge
|
||||
new->next = x;
|
||||
x->prev->next = new;
|
||||
x->prev = new;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* We are the new head */
|
||||
*list = new;
|
||||
new->next = x;
|
||||
@@ -167,7 +167,7 @@ static void chathistory_targets_send_line(Client *client, ChatHistoryTarget *r,
|
||||
}
|
||||
|
||||
sendto_one(client, mtags, ":%s CHATHISTORY TARGETS %s %s",
|
||||
me.name, r->object, r->datetime);
|
||||
me.name, r->object, r->datetime);
|
||||
|
||||
if (mtags)
|
||||
free_message_tags(mtags);
|
||||
@@ -177,7 +177,7 @@ void chathistory_targets(Client *client, HistoryFilter *filter, int limit)
|
||||
{
|
||||
Membership *mp;
|
||||
HistoryResult *r;
|
||||
char batch[BATCHLEN+1];
|
||||
char batch[BATCHLEN + 1];
|
||||
int sent = 0;
|
||||
ChatHistoryTarget *targets = NULL, *targets_next;
|
||||
|
||||
@@ -247,7 +247,7 @@ void chathistory_targets(Client *client, HistoryFilter *filter, int limit)
|
||||
|
||||
void send_empty_batch(Client *client, const char *target)
|
||||
{
|
||||
char batch[BATCHLEN+1];
|
||||
char batch[BATCHLEN + 1];
|
||||
|
||||
if (HasCapability(client, "batch"))
|
||||
{
|
||||
@@ -294,13 +294,13 @@ CMD_FUNC(cmd_chathistory)
|
||||
if (!chathistory_token(parv[2], "timestamp", &filter->timestamp_a))
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_PARAMS %s %s :Invalid parameter, must be timestamp=xxx",
|
||||
me.name, parv[1], parv[3]);
|
||||
me.name, parv[1], parv[3]);
|
||||
goto end;
|
||||
}
|
||||
if (!chathistory_token(parv[3], "timestamp", &filter->timestamp_b))
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_PARAMS %s %s :Invalid parameter, must be timestamp=xxx",
|
||||
me.name, parv[1], parv[4]);
|
||||
me.name, parv[1], parv[4]);
|
||||
goto end;
|
||||
}
|
||||
limit = atoi(parv[4]);
|
||||
@@ -319,14 +319,14 @@ CMD_FUNC(cmd_chathistory)
|
||||
if (!channel)
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_TARGET %s %s :Messages could not be retrieved, not an existing channel",
|
||||
me.name, parv[1], parv[2]);
|
||||
me.name, parv[1], parv[2]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsMember(client, channel))
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_TARGET %s %s :Messages could not be retrieved, you are not a member",
|
||||
me.name, parv[1], parv[2]);
|
||||
me.name, parv[1], parv[2]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -347,24 +347,22 @@ CMD_FUNC(cmd_chathistory)
|
||||
!chathistory_token(parv[3], "msgid", &filter->msgid_a))
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_PARAMS %s %s :Invalid parameter, must be timestamp=xxx or msgid=xxx",
|
||||
me.name, parv[1], parv[3]);
|
||||
me.name, parv[1], parv[3]);
|
||||
goto end;
|
||||
}
|
||||
filter->limit = atoi(parv[4]);
|
||||
} else
|
||||
if (!strcasecmp(parv[1], "AFTER"))
|
||||
} else if (!strcasecmp(parv[1], "AFTER"))
|
||||
{
|
||||
filter->cmd = HFC_AFTER;
|
||||
if (!chathistory_token(parv[3], "timestamp", &filter->timestamp_a) &&
|
||||
!chathistory_token(parv[3], "msgid", &filter->msgid_a))
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_PARAMS %s %s :Invalid parameter, must be timestamp=xxx or msgid=xxx",
|
||||
me.name, parv[1], parv[3]);
|
||||
me.name, parv[1], parv[3]);
|
||||
goto end;
|
||||
}
|
||||
filter->limit = atoi(parv[4]);
|
||||
} else
|
||||
if (!strcasecmp(parv[1], "LATEST"))
|
||||
} else if (!strcasecmp(parv[1], "LATEST"))
|
||||
{
|
||||
filter->cmd = HFC_LATEST;
|
||||
if (!chathistory_token(parv[3], "timestamp", &filter->timestamp_a) &&
|
||||
@@ -372,24 +370,22 @@ CMD_FUNC(cmd_chathistory)
|
||||
strcmp(parv[3], "*"))
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_PARAMS %s %s :Invalid parameter, must be timestamp=xxx or msgid=xxx or *",
|
||||
me.name, parv[1], parv[3]);
|
||||
me.name, parv[1], parv[3]);
|
||||
goto end;
|
||||
}
|
||||
filter->limit = atoi(parv[4]);
|
||||
} else
|
||||
if (!strcasecmp(parv[1], "AROUND"))
|
||||
} else if (!strcasecmp(parv[1], "AROUND"))
|
||||
{
|
||||
filter->cmd = HFC_AROUND;
|
||||
if (!chathistory_token(parv[3], "timestamp", &filter->timestamp_a) &&
|
||||
!chathistory_token(parv[3], "msgid", &filter->msgid_a))
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_PARAMS %s %s :Invalid parameter, must be timestamp=xxx or msgid=xxx",
|
||||
me.name, parv[1], parv[3]);
|
||||
me.name, parv[1], parv[3]);
|
||||
goto end;
|
||||
}
|
||||
filter->limit = atoi(parv[4]);
|
||||
} else
|
||||
if (!strcasecmp(parv[1], "BETWEEN"))
|
||||
} else if (!strcasecmp(parv[1], "BETWEEN"))
|
||||
{
|
||||
filter->cmd = HFC_BETWEEN;
|
||||
if (BadPtr(parv[5]))
|
||||
@@ -401,18 +397,19 @@ CMD_FUNC(cmd_chathistory)
|
||||
!chathistory_token(parv[3], "msgid", &filter->msgid_a))
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_PARAMS %s %s :Invalid parameter, must be timestamp=xxx or msgid=xxx",
|
||||
me.name, parv[1], parv[3]);
|
||||
me.name, parv[1], parv[3]);
|
||||
goto end;
|
||||
}
|
||||
if (!chathistory_token(parv[4], "timestamp", &filter->timestamp_b) &&
|
||||
!chathistory_token(parv[4], "msgid", &filter->msgid_b))
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_PARAMS %s %s :Invalid parameter, must be timestamp=xxx or msgid=xxx",
|
||||
me.name, parv[1], parv[4]);
|
||||
me.name, parv[1], parv[4]);
|
||||
goto end;
|
||||
}
|
||||
filter->limit = atoi(parv[5]);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_PARAMS %s :Invalid subcommand", me.name, parv[1]);
|
||||
goto end;
|
||||
}
|
||||
@@ -420,7 +417,7 @@ CMD_FUNC(cmd_chathistory)
|
||||
if (filter->limit <= 0)
|
||||
{
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY INVALID_PARAMS %s %d :Specified limit is =<0",
|
||||
me.name, parv[1], filter->limit);
|
||||
me.name, parv[1], filter->limit);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -429,14 +426,15 @@ CMD_FUNC(cmd_chathistory)
|
||||
|
||||
if ((r = history_request(channel->name, filter)))
|
||||
{
|
||||
if ((r->num_bytes*1.5) > get_sendq(client))
|
||||
if ((r->num_bytes * 1.5) > get_sendq(client))
|
||||
{
|
||||
/* This would get rather close to max sendq. We reject
|
||||
* the request as to not cause "Max SendQ exceeded".
|
||||
*/
|
||||
sendto_one(client, NULL, ":%s FAIL CHATHISTORY MESSAGE_ERROR %s %s :History too large to deliver",
|
||||
me.name, parv[1], channel->name);
|
||||
} else {
|
||||
me.name, parv[1], channel->name);
|
||||
} else
|
||||
{
|
||||
/* All ok, bump fake lag and add the result.
|
||||
* The fakelag bump under normal circumstances is tiny
|
||||
* at like 400ms worst-case without multiline. However, it
|
||||
|
||||
+34
-35
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
#define MSG_CHGHOST "CHGHOST"
|
||||
#define MSG_CHGHOST "CHGHOST"
|
||||
|
||||
CMD_FUNC(cmd_chghost);
|
||||
void _userhost_save_current(Client *client);
|
||||
@@ -30,14 +30,13 @@ void _userhost_changed(Client *client);
|
||||
|
||||
long CAP_CHGHOST = 0L;
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chghost", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"/chghost", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chghost", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"/chghost", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -51,7 +50,7 @@ MOD_INIT()
|
||||
{
|
||||
ClientCapabilityInfo c;
|
||||
|
||||
CommandAdd(modinfo->handle, MSG_CHGHOST, cmd_chghost, MAXPARA, CMD_USER|CMD_SERVER);
|
||||
CommandAdd(modinfo->handle, MSG_CHGHOST, cmd_chghost, MAXPARA, CMD_USER | CMD_SERVER);
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
memset(&c, 0, sizeof(c));
|
||||
@@ -64,18 +63,17 @@ MOD_INIT()
|
||||
MOD_LOAD()
|
||||
{
|
||||
return MOD_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
MOD_UNLOAD()
|
||||
{
|
||||
return MOD_SUCCESS;
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static char remember_nick[NICKLEN+1];
|
||||
static char remember_user[USERLEN+1];
|
||||
static char remember_host[HOSTLEN+1];
|
||||
static char remember_nick[NICKLEN + 1];
|
||||
static char remember_user[USERLEN + 1];
|
||||
static char remember_host[HOSTLEN + 1];
|
||||
|
||||
/** Save current nick/user/host. Used later by userhost_changed(). */
|
||||
void _userhost_save_current(Client *client)
|
||||
@@ -143,17 +141,17 @@ void _userhost_changed(Client *client)
|
||||
|
||||
/* Prepare buffers for PART, JOIN, MODE */
|
||||
ircsnprintf(partbuf, sizeof(partbuf), ":%s!%s@%s PART %s :%s",
|
||||
remember_nick, remember_user, remember_host,
|
||||
channel->name,
|
||||
"Changing host");
|
||||
remember_nick, remember_user, remember_host,
|
||||
channel->name,
|
||||
"Changing host");
|
||||
|
||||
ircsnprintf(joinbuf, sizeof(joinbuf), ":%s!%s@%s JOIN %s",
|
||||
client->name, client->user->username, GetHost(client), channel->name);
|
||||
client->name, client->user->username, GetHost(client), channel->name);
|
||||
|
||||
ircsnprintf(exjoinbuf, sizeof(exjoinbuf), ":%s!%s@%s JOIN %s %s :%s",
|
||||
client->name, client->user->username, GetHost(client), channel->name,
|
||||
IsLoggedIn(client) ? client->user->account : "*",
|
||||
client->info);
|
||||
client->name, client->user->username, GetHost(client), channel->name,
|
||||
IsLoggedIn(client) ? client->user->account : "*",
|
||||
client->info);
|
||||
|
||||
modes = get_chmodes_for_user(client, channels->member_modes);
|
||||
if (!BadPtr(modes))
|
||||
@@ -218,7 +216,7 @@ void _userhost_changed(Client *client)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RunHook(HOOKTYPE_USERHOST_CHANGE, client, remember_user, remember_host);
|
||||
|
||||
if (MyUser(client))
|
||||
@@ -258,7 +256,7 @@ CMD_FUNC(cmd_chghost)
|
||||
{
|
||||
Client *target;
|
||||
|
||||
if (MyUser(client) && !ValidatePermissionsForPath("client:set:host",client,NULL,NULL,NULL))
|
||||
if (MyUser(client) && !ValidatePermissionsForPath("client:set:host", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
@@ -322,7 +320,7 @@ CMD_FUNC(cmd_chghost)
|
||||
if (MyUser(client))
|
||||
{
|
||||
sendnumeric(client, ERR_DISABLED, "CHGHOST",
|
||||
"This command is disabled on this server");
|
||||
"This command is disabled on this server");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -346,17 +344,18 @@ CMD_FUNC(cmd_chghost)
|
||||
if (issuer)
|
||||
{
|
||||
unreal_log(ULOG_INFO, "chgcmds", "CHGHOST_COMMAND", client,
|
||||
"CHGHOST: $issuer changed the virtual hostname of $target.details to be $new_hostname",
|
||||
log_data_string("issuer", issuer),
|
||||
log_data_string("change_type", "hostname"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_hostname", parv[2]));
|
||||
} else {
|
||||
"CHGHOST: $issuer changed the virtual hostname of $target.details to be $new_hostname",
|
||||
log_data_string("issuer", issuer),
|
||||
log_data_string("change_type", "hostname"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_hostname", parv[2]));
|
||||
} else
|
||||
{
|
||||
unreal_log(ULOG_INFO, "chgcmds", "CHGHOST_COMMAND", client,
|
||||
"CHGHOST: $client changed the virtual hostname of $target.details to be $new_hostname",
|
||||
log_data_string("change_type", "hostname"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_hostname", parv[2]));
|
||||
"CHGHOST: $client changed the virtual hostname of $target.details to be $new_hostname",
|
||||
log_data_string("change_type", "hostname"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_hostname", parv[2]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-22
@@ -22,22 +22,21 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
#define MSG_CHGIDENT "CHGIDENT"
|
||||
#define MSG_CHGIDENT "CHGIDENT"
|
||||
|
||||
CMD_FUNC(cmd_chgident);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chgident", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"/chgident", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chgident", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"/chgident", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CommandAdd(modinfo->handle, MSG_CHGIDENT, cmd_chgident, MAXPARA, CMD_USER|CMD_SERVER);
|
||||
CommandAdd(modinfo->handle, MSG_CHGIDENT, cmd_chgident, MAXPARA, CMD_USER | CMD_SERVER);
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -66,7 +65,7 @@ CMD_FUNC(cmd_chgident)
|
||||
const char *s;
|
||||
int legalident = 1;
|
||||
|
||||
if (!ValidatePermissionsForPath("client:set:ident",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("client:set:ident", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
@@ -118,7 +117,7 @@ CMD_FUNC(cmd_chgident)
|
||||
if (MyUser(client))
|
||||
{
|
||||
sendnumeric(client, ERR_DISABLED, "CHGIDENT",
|
||||
"This command is disabled on this server");
|
||||
"This command is disabled on this server");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -141,17 +140,18 @@ CMD_FUNC(cmd_chgident)
|
||||
if (issuer)
|
||||
{
|
||||
unreal_log(ULOG_INFO, "chgcmds", "CHGIDENT_COMMAND", client,
|
||||
"CHGIDENT: $issuer changed the username of $target.details to be $new_username",
|
||||
log_data_string("issuer", issuer),
|
||||
log_data_string("change_type", "username"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_username", parv[2]));
|
||||
} else {
|
||||
"CHGIDENT: $issuer changed the username of $target.details to be $new_username",
|
||||
log_data_string("issuer", issuer),
|
||||
log_data_string("change_type", "username"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_username", parv[2]));
|
||||
} else
|
||||
{
|
||||
unreal_log(ULOG_INFO, "chgcmds", "CHGIDENT_COMMAND", client,
|
||||
"CHGIDENT: $client changed the username of $target.details to be $new_username",
|
||||
log_data_string("change_type", "username"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_username", parv[2]));
|
||||
"CHGIDENT: $client changed the username of $target.details to be $new_username",
|
||||
log_data_string("change_type", "username"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_username", parv[2]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+26
-26
@@ -20,26 +20,25 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
#define MSG_CHGNAME "CHGNAME"
|
||||
#define MSG_SVSNAME "SVSNAME"
|
||||
#define MSG_CHGNAME "CHGNAME"
|
||||
#define MSG_SVSNAME "SVSNAME"
|
||||
|
||||
CMD_FUNC(cmd_chgname);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chgname", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"command /chgname", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chgname", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"command /chgname", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
|
||||
/* This is called on module init, before Server Ready */
|
||||
MOD_INIT()
|
||||
{
|
||||
CommandAdd(modinfo->handle, MSG_CHGNAME, cmd_chgname, 2, CMD_USER|CMD_SERVER);
|
||||
CommandAdd(modinfo->handle, MSG_SVSNAME, cmd_chgname, 2, CMD_USER|CMD_SERVER);
|
||||
CommandAdd(modinfo->handle, MSG_CHGNAME, cmd_chgname, 2, CMD_USER | CMD_SERVER);
|
||||
CommandAdd(modinfo->handle, MSG_SVSNAME, cmd_chgname, 2, CMD_USER | CMD_SERVER);
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -70,7 +69,7 @@ CMD_FUNC(cmd_chgname)
|
||||
Client *target;
|
||||
ConfigItem_ban *bconf;
|
||||
|
||||
if (!ValidatePermissionsForPath("client:set:name",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("client:set:name", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
@@ -101,17 +100,18 @@ CMD_FUNC(cmd_chgname)
|
||||
if (issuer)
|
||||
{
|
||||
unreal_log(ULOG_INFO, "chgcmds", "CHGNAME_COMMAND", client,
|
||||
"CHGNAME: $issuer changed the realname of $target.details to be $new_realname",
|
||||
log_data_string("issuer", issuer),
|
||||
log_data_string("change_type", "realname"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_realname", parv[2]));
|
||||
} else {
|
||||
"CHGNAME: $issuer changed the realname of $target.details to be $new_realname",
|
||||
log_data_string("issuer", issuer),
|
||||
log_data_string("change_type", "realname"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_realname", parv[2]));
|
||||
} else
|
||||
{
|
||||
unreal_log(ULOG_INFO, "chgcmds", "CHGNAME_COMMAND", client,
|
||||
"CHGNAME: $client changed the realname of $target.details to be $new_realname",
|
||||
log_data_string("change_type", "realname"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_realname", parv[2]));
|
||||
"CHGNAME: $client changed the realname of $target.details to be $new_realname",
|
||||
log_data_string("change_type", "realname"),
|
||||
log_data_client("target", target),
|
||||
log_data_string("new_realname", parv[2]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,14 +121,14 @@ CMD_FUNC(cmd_chgname)
|
||||
if (MyUser(target))
|
||||
{
|
||||
/* only check for realname bans if the person who's name is being changed is NOT an oper */
|
||||
if (!ValidatePermissionsForPath("immune:server-ban:ban-realname",target,NULL,NULL,NULL) &&
|
||||
if (!ValidatePermissionsForPath("immune:server-ban:ban-realname", target, NULL, NULL, NULL) &&
|
||||
((bconf = find_ban(NULL, target->info, CONF_BAN_REALNAME))))
|
||||
{
|
||||
banned_client(target, "realname", bconf->reason?bconf->reason:"", NULL, 0, 0);
|
||||
banned_client(target, "realname", bconf->reason ? bconf->reason : "", NULL, 0, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sendto_server(client, 0, 0, recv_mtags, ":%s CHGNAME %s :%s",
|
||||
client->id, target->name, parv[2]);
|
||||
client->id, target->name, parv[2]);
|
||||
}
|
||||
|
||||
+21
-15
@@ -28,20 +28,22 @@ int tags_rehash_complete(void);
|
||||
Module *module;
|
||||
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"clienttagdeny",
|
||||
"5.0",
|
||||
"Informs clients about supported client tags",
|
||||
"k4be",
|
||||
"unrealircd-6",
|
||||
"clienttagdeny",
|
||||
"5.0",
|
||||
"Informs clients about supported client tags",
|
||||
"k4be",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT(){
|
||||
MOD_INIT()
|
||||
{
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
MOD_LOAD(){
|
||||
MOD_LOAD()
|
||||
{
|
||||
module = modinfo->handle;
|
||||
ISupportAdd(module, "CLIENTTAGDENY", ct_isupport_param());
|
||||
HookAdd(module, HOOKTYPE_REHASH_COMPLETE, 0, tags_rehash_complete);
|
||||
@@ -49,29 +51,33 @@ MOD_LOAD(){
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
MOD_UNLOAD(){
|
||||
MOD_UNLOAD()
|
||||
{
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
#define BUFLEN 500
|
||||
|
||||
char *ct_isupport_param(void){
|
||||
char *ct_isupport_param(void)
|
||||
{
|
||||
static char buf[BUFLEN];
|
||||
MessageTagHandler *m;
|
||||
|
||||
|
||||
strlcpy(buf, "*", sizeof(buf));
|
||||
|
||||
for (m = mtaghandlers; m; m = m->next) {
|
||||
if (!m->unloaded && m->name[0] == '+'){
|
||||
for (m = mtaghandlers; m; m = m->next)
|
||||
{
|
||||
if (!m->unloaded && m->name[0] == '+')
|
||||
{
|
||||
strlcat(buf, ",-", sizeof(buf));
|
||||
strlcat(buf, m->name+1, sizeof(buf));
|
||||
strlcat(buf, m->name + 1, sizeof(buf));
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
int tags_rehash_complete(void){
|
||||
int tags_rehash_complete(void)
|
||||
{
|
||||
ISupportSet(module, "CLIENTTAGDENY", ct_isupport_param());
|
||||
return HOOK_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
+71
-71
@@ -47,11 +47,11 @@ static char *hidehost_normalhost(char *host);
|
||||
static inline unsigned int downsample(char *i);
|
||||
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"cloak_md5",
|
||||
"1.0",
|
||||
"Old cloaking module (MD5)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
"cloak_md5",
|
||||
"1.0",
|
||||
"Old cloaking module (MD5)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_TEST()
|
||||
@@ -110,9 +110,9 @@ MOD_UNLOAD()
|
||||
|
||||
static int check_badrandomness(char *key)
|
||||
{
|
||||
char gotlowcase=0, gotupcase=0, gotdigit=0;
|
||||
char *p;
|
||||
for (p=key; *p; p++)
|
||||
char gotlowcase = 0, gotupcase = 0, gotdigit = 0;
|
||||
char *p;
|
||||
for (p = key; *p; p++)
|
||||
if (islower(*p))
|
||||
gotlowcase = 1;
|
||||
else if (isupper(*p))
|
||||
@@ -141,13 +141,12 @@ int cloak_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error("%s:%i: set::cloak-method: no method specified. The only supported methods are: 'ip' and 'host'",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
errors++;
|
||||
} else
|
||||
if (strcmp(ce->value, "ip") && strcmp(ce->value, "host"))
|
||||
} else if (strcmp(ce->value, "ip") && strcmp(ce->value, "host"))
|
||||
{
|
||||
config_error("%s:%i: set::cloak-method: unknown method '%s'. The only supported methods are: 'ip' and 'host'",
|
||||
ce->file->filename, ce->line_number, ce->value);
|
||||
ce->file->filename, ce->line_number, ce->value);
|
||||
errors++;
|
||||
}
|
||||
|
||||
@@ -165,34 +164,35 @@ int cloak_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (check_badrandomness(cep->name))
|
||||
{
|
||||
config_error("%s:%i: set::cloak-keys: (key %d) Keys should be mixed a-zA-Z0-9, "
|
||||
"like \"a2JO6fh3Q6w4oN3s7\"", cep->file->filename, cep->line_number, keycnt);
|
||||
"like \"a2JO6fh3Q6w4oN3s7\"",
|
||||
cep->file->filename, cep->line_number, keycnt);
|
||||
errors++;
|
||||
}
|
||||
if (strlen(cep->name) < 5)
|
||||
{
|
||||
config_error("%s:%i: set::cloak-keys: (key %d) Each key should be at least 5 characters",
|
||||
cep->file->filename, cep->line_number, keycnt);
|
||||
cep->file->filename, cep->line_number, keycnt);
|
||||
errors++;
|
||||
}
|
||||
if (strlen(cep->name) > 100)
|
||||
{
|
||||
config_error("%s:%i: set::cloak-keys: (key %d) Each key should be less than 100 characters",
|
||||
cep->file->filename, cep->line_number, keycnt);
|
||||
cep->file->filename, cep->line_number, keycnt);
|
||||
errors++;
|
||||
}
|
||||
if (keycnt < 4)
|
||||
keys[keycnt-1] = cep->name;
|
||||
keys[keycnt - 1] = cep->name;
|
||||
}
|
||||
if (keycnt != 3)
|
||||
{
|
||||
config_error("%s:%i: set::cloak-keys: we want 3 values, not %i!",
|
||||
ce->file->filename, ce->line_number, keycnt);
|
||||
ce->file->filename, ce->line_number, keycnt);
|
||||
errors++;
|
||||
}
|
||||
if ((keycnt == 3) && (!strcmp(keys[0], keys[1]) || !strcmp(keys[1], keys[2])))
|
||||
{
|
||||
config_error("%s:%i: set::cloak-keys: All your 3 keys should be RANDOM, they should not be equal",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
errors++;
|
||||
}
|
||||
*errs = errors;
|
||||
@@ -201,7 +201,7 @@ int cloak_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
|
||||
int cloak_config_posttest(int *errs)
|
||||
{
|
||||
int errors = 0;
|
||||
int errors = 0;
|
||||
|
||||
if (nokeys)
|
||||
{
|
||||
@@ -215,8 +215,8 @@ int errors = 0;
|
||||
|
||||
int cloak_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
{
|
||||
ConfigEntry *cep;
|
||||
char buf[512], result[16];
|
||||
ConfigEntry *cep;
|
||||
char buf[512], result[16];
|
||||
|
||||
if (type == CONFIG_SET)
|
||||
{
|
||||
@@ -245,23 +245,23 @@ char buf[512], result[16];
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%s:%s", KEY1, KEY2, KEY3);
|
||||
DoMD5(result, buf, strlen(buf));
|
||||
ircsnprintf(cloak_checksum, sizeof(cloak_checksum),
|
||||
"MD5:%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x",
|
||||
(u_int)(result[0] & 0xf), (u_int)(result[0] >> 4),
|
||||
(u_int)(result[1] & 0xf), (u_int)(result[1] >> 4),
|
||||
(u_int)(result[2] & 0xf), (u_int)(result[2] >> 4),
|
||||
(u_int)(result[3] & 0xf), (u_int)(result[3] >> 4),
|
||||
(u_int)(result[4] & 0xf), (u_int)(result[4] >> 4),
|
||||
(u_int)(result[5] & 0xf), (u_int)(result[5] >> 4),
|
||||
(u_int)(result[6] & 0xf), (u_int)(result[6] >> 4),
|
||||
(u_int)(result[7] & 0xf), (u_int)(result[7] >> 4),
|
||||
(u_int)(result[8] & 0xf), (u_int)(result[8] >> 4),
|
||||
(u_int)(result[9] & 0xf), (u_int)(result[9] >> 4),
|
||||
(u_int)(result[10] & 0xf), (u_int)(result[10] >> 4),
|
||||
(u_int)(result[11] & 0xf), (u_int)(result[11] >> 4),
|
||||
(u_int)(result[12] & 0xf), (u_int)(result[12] >> 4),
|
||||
(u_int)(result[13] & 0xf), (u_int)(result[13] >> 4),
|
||||
(u_int)(result[14] & 0xf), (u_int)(result[14] >> 4),
|
||||
(u_int)(result[15] & 0xf), (u_int)(result[15] >> 4));
|
||||
"MD5:%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x",
|
||||
(u_int)(result[0] & 0xf), (u_int)(result[0] >> 4),
|
||||
(u_int)(result[1] & 0xf), (u_int)(result[1] >> 4),
|
||||
(u_int)(result[2] & 0xf), (u_int)(result[2] >> 4),
|
||||
(u_int)(result[3] & 0xf), (u_int)(result[3] >> 4),
|
||||
(u_int)(result[4] & 0xf), (u_int)(result[4] >> 4),
|
||||
(u_int)(result[5] & 0xf), (u_int)(result[5] >> 4),
|
||||
(u_int)(result[6] & 0xf), (u_int)(result[6] >> 4),
|
||||
(u_int)(result[7] & 0xf), (u_int)(result[7] >> 4),
|
||||
(u_int)(result[8] & 0xf), (u_int)(result[8] >> 4),
|
||||
(u_int)(result[9] & 0xf), (u_int)(result[9] >> 4),
|
||||
(u_int)(result[10] & 0xf), (u_int)(result[10] >> 4),
|
||||
(u_int)(result[11] & 0xf), (u_int)(result[11] >> 4),
|
||||
(u_int)(result[12] & 0xf), (u_int)(result[12] >> 4),
|
||||
(u_int)(result[13] & 0xf), (u_int)(result[13] >> 4),
|
||||
(u_int)(result[14] & 0xf), (u_int)(result[14] >> 4),
|
||||
(u_int)(result[15] & 0xf), (u_int)(result[15] >> 4));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -291,25 +291,25 @@ char *cloakcsum()
|
||||
/** Downsamples a 128bit result to 32bits (md5 -> unsigned int) */
|
||||
static inline unsigned int downsample(char *i)
|
||||
{
|
||||
char r[4];
|
||||
char r[4];
|
||||
|
||||
r[0] = i[0] ^ i[1] ^ i[2] ^ i[3];
|
||||
r[1] = i[4] ^ i[5] ^ i[6] ^ i[7];
|
||||
r[2] = i[8] ^ i[9] ^ i[10] ^ i[11];
|
||||
r[3] = i[12] ^ i[13] ^ i[14] ^ i[15];
|
||||
|
||||
return ( ((unsigned int)r[0] << 24) +
|
||||
((unsigned int)r[1] << 16) +
|
||||
((unsigned int)r[2] << 8) +
|
||||
(unsigned int)r[3]);
|
||||
|
||||
return (((unsigned int)r[0] << 24) +
|
||||
((unsigned int)r[1] << 16) +
|
||||
((unsigned int)r[2] << 8) +
|
||||
(unsigned int)r[3]);
|
||||
}
|
||||
|
||||
static char *hidehost_ipv4(char *host)
|
||||
{
|
||||
unsigned int a, b, c, d;
|
||||
static char buf[512], res[512], res2[512], result[128];
|
||||
unsigned long n;
|
||||
unsigned int alpha, beta, gamma;
|
||||
unsigned int a, b, c, d;
|
||||
static char buf[512], res[512], res2[512], result[128];
|
||||
unsigned long n;
|
||||
unsigned int alpha, beta, gamma;
|
||||
|
||||
/*
|
||||
* Output: ALPHA.BETA.GAMMA.IP
|
||||
@@ -326,24 +326,24 @@ unsigned int alpha, beta, gamma;
|
||||
/* ALPHA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%s:%s", KEY2, host, KEY3);
|
||||
DoMD5(res, buf, strlen(buf));
|
||||
strlcpy(res+16, KEY1, sizeof(res)-16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res+16) + 16;
|
||||
strlcpy(res + 16, KEY1, sizeof(res) - 16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res + 16) + 16;
|
||||
DoMD5(res2, res, n);
|
||||
alpha = downsample(res2);
|
||||
|
||||
/* BETA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%d.%d.%d:%s", KEY3, a, b, c, KEY1);
|
||||
DoMD5(res, buf, strlen(buf));
|
||||
strlcpy(res+16, KEY2, sizeof(res)-16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res+16) + 16;
|
||||
strlcpy(res + 16, KEY2, sizeof(res) - 16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res + 16) + 16;
|
||||
DoMD5(res2, res, n);
|
||||
beta = downsample(res2);
|
||||
|
||||
/* GAMMA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%d.%d:%s", KEY1, a, b, KEY2);
|
||||
DoMD5(res, buf, strlen(buf));
|
||||
strlcpy(res+16, KEY3, sizeof(res)-16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res+16) + 16;
|
||||
strlcpy(res + 16, KEY3, sizeof(res) - 16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res + 16) + 16;
|
||||
DoMD5(res2, res, n);
|
||||
gamma = downsample(res2);
|
||||
|
||||
@@ -353,10 +353,10 @@ unsigned int alpha, beta, gamma;
|
||||
|
||||
static char *hidehost_ipv6(char *host)
|
||||
{
|
||||
unsigned int a, b, c, d, e, f, g, h;
|
||||
static char buf[512], res[512], res2[512], result[128];
|
||||
unsigned long n;
|
||||
unsigned int alpha, beta, gamma;
|
||||
unsigned int a, b, c, d, e, f, g, h;
|
||||
static char buf[512], res[512], res2[512], result[128];
|
||||
unsigned long n;
|
||||
unsigned int alpha, beta, gamma;
|
||||
|
||||
/*
|
||||
* Output: ALPHA:BETA:GAMMA:IP
|
||||
@@ -369,29 +369,29 @@ unsigned int alpha, beta, gamma;
|
||||
* GAMMA = downsample(md5(md5("KEY1:a:b:c:d:KEY2")+"KEY3"));
|
||||
*/
|
||||
sscanf(host, "%x:%x:%x:%x:%x:%x:%x:%x",
|
||||
&a, &b, &c, &d, &e, &f, &g, &h);
|
||||
&a, &b, &c, &d, &e, &f, &g, &h);
|
||||
|
||||
/* ALPHA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%s:%s", KEY2, host, KEY3);
|
||||
DoMD5(res, buf, strlen(buf));
|
||||
strlcpy(res+16, KEY1, sizeof(res)-16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res+16) + 16;
|
||||
strlcpy(res + 16, KEY1, sizeof(res) - 16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res + 16) + 16;
|
||||
DoMD5(res2, res, n);
|
||||
alpha = downsample(res2);
|
||||
|
||||
/* BETA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%x:%x:%x:%x:%x:%x:%x:%s", KEY3, a, b, c, d, e, f, g, KEY1);
|
||||
DoMD5(res, buf, strlen(buf));
|
||||
strlcpy(res+16, KEY2, sizeof(res)-16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res+16) + 16;
|
||||
strlcpy(res + 16, KEY2, sizeof(res) - 16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res + 16) + 16;
|
||||
DoMD5(res2, res, n);
|
||||
beta = downsample(res2);
|
||||
|
||||
/* GAMMA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%x:%x:%x:%x:%s", KEY1, a, b, c, d, KEY2);
|
||||
DoMD5(res, buf, strlen(buf));
|
||||
strlcpy(res+16, KEY3, sizeof(res)-16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res+16) + 16;
|
||||
strlcpy(res + 16, KEY3, sizeof(res) - 16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res + 16) + 16;
|
||||
DoMD5(res2, res, n);
|
||||
gamma = downsample(res2);
|
||||
|
||||
@@ -401,14 +401,14 @@ unsigned int alpha, beta, gamma;
|
||||
|
||||
static char *hidehost_normalhost(char *host)
|
||||
{
|
||||
char *p;
|
||||
static char buf[512], res[512], res2[512], result[HOSTLEN+1];
|
||||
unsigned int alpha, n;
|
||||
char *p;
|
||||
static char buf[512], res[512], res2[512], result[HOSTLEN + 1];
|
||||
unsigned int alpha, n;
|
||||
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%s:%s", KEY1, host, KEY2);
|
||||
DoMD5(res, buf, strlen(buf));
|
||||
strlcpy(res+16, KEY3, sizeof(res)-16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res+16) + 16;
|
||||
strlcpy(res + 16, KEY3, sizeof(res) - 16); /* first 16 bytes are filled, append our key.. */
|
||||
n = strlen(res + 16) + 16;
|
||||
DoMD5(res2, res, n);
|
||||
alpha = downsample(res2);
|
||||
|
||||
@@ -428,7 +428,7 @@ unsigned int alpha, n;
|
||||
else
|
||||
strlcat(result, p + (len - HOSTLEN), sizeof(result));
|
||||
} else
|
||||
ircsnprintf(result, sizeof(result), "%s-%X", CLOAK_PREFIX, alpha);
|
||||
ircsnprintf(result, sizeof(result), "%s-%X", CLOAK_PREFIX, alpha);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ char *cloakcsum();
|
||||
int cloak_config_test(ConfigFile *, ConfigEntry *, int, int *);
|
||||
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"cloak_none",
|
||||
"1.0",
|
||||
"Cloaking module that does nothing",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
"cloak_none",
|
||||
"1.0",
|
||||
"Cloaking module that does nothing",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_TEST()
|
||||
|
||||
+40
-40
@@ -35,7 +35,7 @@ int CLOAK_IP_ONLY = 0;
|
||||
#define KEY2 cloak_key2
|
||||
#define KEY3 cloak_key3
|
||||
|
||||
#define SHA256_HASH_SIZE (256/8)
|
||||
#define SHA256_HASH_SIZE (256 / 8)
|
||||
|
||||
char *hidehost(Client *client, char *host);
|
||||
char *cloakcsum();
|
||||
@@ -49,11 +49,11 @@ static char *hidehost_normalhost(char *host);
|
||||
static inline unsigned int downsample(char *i);
|
||||
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"cloak_sha256",
|
||||
"1.0",
|
||||
"Cloaking module (SHA256)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
"cloak_sha256",
|
||||
"1.0",
|
||||
"Cloaking module (SHA256)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_TEST()
|
||||
@@ -100,10 +100,10 @@ MOD_UNLOAD()
|
||||
|
||||
static int check_badrandomness(char *key)
|
||||
{
|
||||
char gotlowcase=0, gotupcase=0, gotdigit=0;
|
||||
char gotlowcase = 0, gotupcase = 0, gotdigit = 0;
|
||||
char *p;
|
||||
|
||||
for (p=key; *p; p++)
|
||||
for (p = key; *p; p++)
|
||||
{
|
||||
if (islower(*p))
|
||||
gotlowcase = 1;
|
||||
@@ -135,13 +135,12 @@ int cloak_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error("%s:%i: set::cloak-method: no method specified. The only supported methods are: 'ip' and 'host'",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
errors++;
|
||||
} else
|
||||
if (strcmp(ce->value, "ip") && strcmp(ce->value, "host"))
|
||||
} else if (strcmp(ce->value, "ip") && strcmp(ce->value, "host"))
|
||||
{
|
||||
config_error("%s:%i: set::cloak-method: unknown method '%s'. The only supported methods are: 'ip' and 'host'",
|
||||
ce->file->filename, ce->line_number, ce->value);
|
||||
ce->file->filename, ce->line_number, ce->value);
|
||||
errors++;
|
||||
}
|
||||
|
||||
@@ -159,34 +158,35 @@ int cloak_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (check_badrandomness(cep->name))
|
||||
{
|
||||
config_error("%s:%i: set::cloak-keys: (key %d) Keys should be mixed a-zA-Z0-9, "
|
||||
"like \"a2JO6fh3Q6w4oN3s7\"", cep->file->filename, cep->line_number, keycnt);
|
||||
"like \"a2JO6fh3Q6w4oN3s7\"",
|
||||
cep->file->filename, cep->line_number, keycnt);
|
||||
errors++;
|
||||
}
|
||||
if (strlen(cep->name) < 80)
|
||||
{
|
||||
config_error("%s:%i: set::cloak-keys: (key %d) Each key should be at least 80 characters",
|
||||
cep->file->filename, cep->line_number, keycnt);
|
||||
cep->file->filename, cep->line_number, keycnt);
|
||||
errors++;
|
||||
}
|
||||
if (strlen(cep->name) > 1000)
|
||||
{
|
||||
config_error("%s:%i: set::cloak-keys: (key %d) Each key should be less than 1000 characters",
|
||||
cep->file->filename, cep->line_number, keycnt);
|
||||
cep->file->filename, cep->line_number, keycnt);
|
||||
errors++;
|
||||
}
|
||||
if (keycnt < 4)
|
||||
keys[keycnt-1] = cep->name;
|
||||
keys[keycnt - 1] = cep->name;
|
||||
}
|
||||
if (keycnt != 3)
|
||||
{
|
||||
config_error("%s:%i: set::cloak-keys: we want 3 values, not %i!",
|
||||
ce->file->filename, ce->line_number, keycnt);
|
||||
ce->file->filename, ce->line_number, keycnt);
|
||||
errors++;
|
||||
}
|
||||
if ((keycnt == 3) && (!strcmp(keys[0], keys[1]) || !strcmp(keys[1], keys[2])))
|
||||
{
|
||||
config_error("%s:%i: set::cloak-keys: All your 3 keys should be RANDOM, they should not be equal",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
errors++;
|
||||
}
|
||||
*errs = errors;
|
||||
@@ -274,11 +274,11 @@ static inline unsigned int downsample(char *i)
|
||||
r[1] = i[8] ^ i[9] ^ i[10] ^ i[11] ^ i[12] ^ i[13] ^ i[14] ^ i[15];
|
||||
r[2] = i[16] ^ i[17] ^ i[18] ^ i[19] ^ i[20] ^ i[21] ^ i[22] ^ i[23];
|
||||
r[3] = i[24] ^ i[25] ^ i[26] ^ i[27] ^ i[28] ^ i[29] ^ i[30] ^ i[31];
|
||||
|
||||
return ( ((unsigned int)r[0] << 24) +
|
||||
((unsigned int)r[1] << 16) +
|
||||
((unsigned int)r[2] << 8) +
|
||||
(unsigned int)r[3]);
|
||||
|
||||
return (((unsigned int)r[0] << 24) +
|
||||
((unsigned int)r[1] << 16) +
|
||||
((unsigned int)r[2] << 8) +
|
||||
(unsigned int)r[3]);
|
||||
}
|
||||
|
||||
static char *hidehost_ipv4(char *host)
|
||||
@@ -303,24 +303,24 @@ static char *hidehost_ipv4(char *host)
|
||||
/* ALPHA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%s:%s", KEY2, host, KEY3);
|
||||
sha256hash_binary(res, buf, strlen(buf));
|
||||
strlcpy(res+SHA256_HASH_SIZE, KEY1, sizeof(res)-SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res+SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
strlcpy(res + SHA256_HASH_SIZE, KEY1, sizeof(res) - SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res + SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
sha256hash_binary(res2, res, n);
|
||||
alpha = downsample(res2);
|
||||
|
||||
/* BETA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%d.%d.%d:%s", KEY3, a, b, c, KEY1);
|
||||
sha256hash_binary(res, buf, strlen(buf));
|
||||
strlcpy(res+SHA256_HASH_SIZE, KEY2, sizeof(res)-SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res+SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
strlcpy(res + SHA256_HASH_SIZE, KEY2, sizeof(res) - SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res + SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
sha256hash_binary(res2, res, n);
|
||||
beta = downsample(res2);
|
||||
|
||||
/* GAMMA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%d.%d:%s", KEY1, a, b, KEY2);
|
||||
sha256hash_binary(res, buf, strlen(buf));
|
||||
strlcpy(res+SHA256_HASH_SIZE, KEY3, sizeof(res)-SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res+SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
strlcpy(res + SHA256_HASH_SIZE, KEY3, sizeof(res) - SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res + SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
sha256hash_binary(res2, res, n);
|
||||
gamma = downsample(res2);
|
||||
|
||||
@@ -346,29 +346,29 @@ static char *hidehost_ipv6(char *host)
|
||||
* GAMMA = downsample(sha256(sha256("KEY1:a:b:c:d:KEY2")+"KEY3"));
|
||||
*/
|
||||
sscanf(host, "%x:%x:%x:%x:%x:%x:%x:%x",
|
||||
&a, &b, &c, &d, &e, &f, &g, &h);
|
||||
&a, &b, &c, &d, &e, &f, &g, &h);
|
||||
|
||||
/* ALPHA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%s:%s", KEY2, host, KEY3);
|
||||
sha256hash_binary(res, buf, strlen(buf));
|
||||
strlcpy(res+SHA256_HASH_SIZE, KEY1, sizeof(res)-SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res+SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
strlcpy(res + SHA256_HASH_SIZE, KEY1, sizeof(res) - SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res + SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
sha256hash_binary(res2, res, n);
|
||||
alpha = downsample(res2);
|
||||
|
||||
/* BETA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%x:%x:%x:%x:%x:%x:%x:%s", KEY3, a, b, c, d, e, f, g, KEY1);
|
||||
sha256hash_binary(res, buf, strlen(buf));
|
||||
strlcpy(res+SHA256_HASH_SIZE, KEY2, sizeof(res)-SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res+SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
strlcpy(res + SHA256_HASH_SIZE, KEY2, sizeof(res) - SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res + SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
sha256hash_binary(res2, res, n);
|
||||
beta = downsample(res2);
|
||||
|
||||
/* GAMMA... */
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%x:%x:%x:%x:%s", KEY1, a, b, c, d, KEY2);
|
||||
sha256hash_binary(res, buf, strlen(buf));
|
||||
strlcpy(res+SHA256_HASH_SIZE, KEY3, sizeof(res)-SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res+SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
strlcpy(res + SHA256_HASH_SIZE, KEY3, sizeof(res) - SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res + SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
sha256hash_binary(res2, res, n);
|
||||
gamma = downsample(res2);
|
||||
|
||||
@@ -379,13 +379,13 @@ static char *hidehost_ipv6(char *host)
|
||||
static char *hidehost_normalhost(char *host)
|
||||
{
|
||||
char *p;
|
||||
static char buf[512], res[512], res2[512], result[HOSTLEN+1];
|
||||
static char buf[512], res[512], res2[512], result[HOSTLEN + 1];
|
||||
unsigned int alpha, n;
|
||||
|
||||
ircsnprintf(buf, sizeof(buf), "%s:%s:%s", KEY1, host, KEY2);
|
||||
sha256hash_binary(res, buf, strlen(buf));
|
||||
strlcpy(res+SHA256_HASH_SIZE, KEY3, sizeof(res)-SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res+SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
strlcpy(res + SHA256_HASH_SIZE, KEY3, sizeof(res) - SHA256_HASH_SIZE); /* first bytes are filled, append our key.. */
|
||||
n = strlen(res + SHA256_HASH_SIZE) + SHA256_HASH_SIZE;
|
||||
sha256hash_binary(res2, res, n);
|
||||
alpha = downsample(res2);
|
||||
|
||||
@@ -405,7 +405,7 @@ static char *hidehost_normalhost(char *host)
|
||||
else
|
||||
strlcat(result, p + (len - HOSTLEN), sizeof(result));
|
||||
} else
|
||||
ircsnprintf(result, sizeof(result), "%s-%X", CLOAK_PREFIX, alpha);
|
||||
ircsnprintf(result, sizeof(result), "%s-%X", CLOAK_PREFIX, alpha);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
+11
-12
@@ -24,16 +24,15 @@
|
||||
|
||||
CMD_FUNC(cmd_close);
|
||||
|
||||
#define MSG_CLOSE "CLOSE"
|
||||
#define MSG_CLOSE "CLOSE"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"close",
|
||||
"5.0",
|
||||
"command /close",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"close",
|
||||
"5.0",
|
||||
"command /close",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
@@ -58,9 +57,9 @@ MOD_UNLOAD()
|
||||
CMD_FUNC(cmd_close)
|
||||
{
|
||||
Client *target, *next;
|
||||
int closed = 0;
|
||||
int closed = 0;
|
||||
|
||||
if (!ValidatePermissionsForPath("server:close",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("server:close", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
@@ -69,7 +68,7 @@ CMD_FUNC(cmd_close)
|
||||
list_for_each_entry_safe(target, next, &unknown_list, lclient_node)
|
||||
{
|
||||
sendnumeric(client, RPL_CLOSING,
|
||||
get_client_name(target, TRUE), target->status);
|
||||
get_client_name(target, TRUE), target->status);
|
||||
exit_client(target, NULL, "Oper Closing");
|
||||
closed++;
|
||||
}
|
||||
|
||||
+17
-20
@@ -6,22 +6,20 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"connect-flood",
|
||||
"6.0.0",
|
||||
"set::anti-flood::connect-flood",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"connect-flood",
|
||||
"6.0.0",
|
||||
"set::anti-flood::connect-flood",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Defines */
|
||||
#define THROTTLING_HASH_TABLE_SIZE 8192
|
||||
|
||||
/* Structs */
|
||||
typedef struct ThrottlingBucket ThrottlingBucket;
|
||||
struct ThrottlingBucket
|
||||
{
|
||||
struct ThrottlingBucket {
|
||||
ThrottlingBucket *prev, *next;
|
||||
char *ip;
|
||||
time_t since;
|
||||
@@ -100,9 +98,9 @@ int connect_flood_throttle(Client *client, int exitflags)
|
||||
if (!(val = throttle_can_connect(client)))
|
||||
{
|
||||
ircsnprintf(zlinebuf, sizeof(zlinebuf),
|
||||
"Throttled: Reconnecting too fast - "
|
||||
"Email %s for more information.",
|
||||
KLINE_ADDRESS);
|
||||
"Throttled: Reconnecting too fast - "
|
||||
"Email %s for more information.",
|
||||
KLINE_ADDRESS);
|
||||
/* There are two reasons why we can't use exit_client() here:
|
||||
* 1) Because the HOOKTYPE_IP_CHANGE call may be too deep.
|
||||
* Eg: read_packet -> webserver_packet_in ->
|
||||
@@ -114,8 +112,7 @@ int connect_flood_throttle(Client *client, int exitflags)
|
||||
*/
|
||||
dead_socket(client, zlinebuf);
|
||||
return HOOK_DENY;
|
||||
}
|
||||
else if (val == 1)
|
||||
} else if (val == 1)
|
||||
add_throttling_bucket(client);
|
||||
|
||||
return 0;
|
||||
@@ -153,10 +150,10 @@ void add_throttling_timeout_timer(ModuleInfo *modinfo)
|
||||
|
||||
if (!THROTTLING_PERIOD)
|
||||
{
|
||||
v = 120*1000;
|
||||
v = 120 * 1000;
|
||||
} else
|
||||
{
|
||||
v = (THROTTLING_PERIOD*1000)/2;
|
||||
v = (THROTTLING_PERIOD * 1000) / 2;
|
||||
if (v > 5000)
|
||||
v = 5000; /* run at least every 5s */
|
||||
if (v < 1000)
|
||||
@@ -175,7 +172,7 @@ ThrottlingBucket *find_throttling_bucket(Client *client)
|
||||
{
|
||||
int hash;
|
||||
ThrottlingBucket *p;
|
||||
char ip[HOSTLEN+1];
|
||||
char ip[HOSTLEN + 1];
|
||||
|
||||
/* Apply set::default-ipv6-clone-mask: bucket is keyed by the network
|
||||
* portion of the IP, so all addresses in the same /64 share one bucket.
|
||||
@@ -218,7 +215,7 @@ void add_throttling_bucket(Client *client)
|
||||
{
|
||||
int hash;
|
||||
ThrottlingBucket *n;
|
||||
char ip[HOSTLEN+1];
|
||||
char ip[HOSTLEN + 1];
|
||||
|
||||
/* Apply set::default-ipv6-clone-mask: bucket is keyed by the network
|
||||
* portion of the IP, so all addresses in the same /64 share one bucket.
|
||||
@@ -255,7 +252,7 @@ int throttle_can_connect(Client *client)
|
||||
{
|
||||
if (find_tkl_exception(TKL_CONNECT_FLOOD, client))
|
||||
return 2;
|
||||
if (b->count+1 > (THROTTLING_COUNT ? THROTTLING_COUNT : 3))
|
||||
if (b->count + 1 > (THROTTLING_COUNT ? THROTTLING_COUNT : 3))
|
||||
return 0;
|
||||
b->count++;
|
||||
return 2;
|
||||
|
||||
+23
-23
@@ -24,20 +24,19 @@
|
||||
|
||||
CMD_FUNC(cmd_connect);
|
||||
|
||||
#define MSG_CONNECT "CONNECT"
|
||||
#define MSG_CONNECT "CONNECT"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"connect",
|
||||
"5.0",
|
||||
"command /connect",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"connect",
|
||||
"5.0",
|
||||
"command /connect",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CommandAdd(modinfo->handle, MSG_CONNECT, cmd_connect, MAXPARA, CMD_USER|CMD_SERVER); /* hmm.. server.. really? */
|
||||
CommandAdd(modinfo->handle, MSG_CONNECT, cmd_connect, MAXPARA, CMD_USER | CMD_SERVER); /* hmm.. server.. really? */
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -54,24 +53,25 @@ MOD_UNLOAD()
|
||||
|
||||
/***********************************************************************
|
||||
* cmd_connect() - Added by Jto 11 Feb 1989
|
||||
***********************************************************************//*
|
||||
***********************************************************************/
|
||||
/*
|
||||
** cmd_connect
|
||||
** parv[1] = servername
|
||||
*/
|
||||
CMD_FUNC(cmd_connect)
|
||||
{
|
||||
int retval;
|
||||
ConfigItem_link *aconf;
|
||||
int retval;
|
||||
ConfigItem_link *aconf;
|
||||
Client *server;
|
||||
const char *str;
|
||||
|
||||
if (!IsServer(client) && MyConnect(client) && !ValidatePermissionsForPath("route:global",client,NULL,NULL,NULL) && parc > 3)
|
||||
{ /* Only allow LocOps to make */
|
||||
if (!IsServer(client) && MyConnect(client) && !ValidatePermissionsForPath("route:global", client, NULL, NULL, NULL) && parc > 3)
|
||||
{ /* Only allow LocOps to make */
|
||||
/* local CONNECTS --SRB */
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
}
|
||||
if (!IsServer(client) && MyUser(client) && !ValidatePermissionsForPath("route:local",client,NULL,NULL,NULL) && parc <= 3)
|
||||
if (!IsServer(client) && MyUser(client) && !ValidatePermissionsForPath("route:local", client, NULL, NULL, NULL) && parc <= 3)
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
@@ -88,7 +88,7 @@ CMD_FUNC(cmd_connect)
|
||||
if ((server = find_server_quick(parv[1])))
|
||||
{
|
||||
sendnotice(client, "*** Connect: Server %s already exists from %s.",
|
||||
parv[1], server->direction->name);
|
||||
parv[1], server->direction->name);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,16 +96,16 @@ CMD_FUNC(cmd_connect)
|
||||
if (!aconf)
|
||||
{
|
||||
sendnotice(client,
|
||||
"*** Connect: Server %s is not configured for linking",
|
||||
parv[1]);
|
||||
"*** Connect: Server %s is not configured for linking",
|
||||
parv[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aconf->outgoing.hostname && !aconf->outgoing.file)
|
||||
{
|
||||
sendnotice(client,
|
||||
"*** Connect: Server %s is not configured to be an outgoing link (has a link block, but no link::outgoing::hostname or link::outgoing::file)",
|
||||
parv[1]);
|
||||
"*** Connect: Server %s is not configured to be an outgoing link (has a link block, but no link::outgoing::hostname or link::outgoing::file)",
|
||||
parv[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ CMD_FUNC(cmd_connect)
|
||||
}
|
||||
|
||||
unreal_log(ULOG_INFO, "link", "LINK_REQUEST", client,
|
||||
"CONNECT: Link to $link_block requested by $client",
|
||||
log_data_link_block(aconf));
|
||||
"CONNECT: Link to $link_block requested by $client",
|
||||
log_data_link_block(aconf));
|
||||
|
||||
connect_server(aconf, client, NULL);
|
||||
}
|
||||
|
||||
+133
-126
@@ -13,14 +13,13 @@
|
||||
#define CALLBACKTYPE_REPUTATION_STARTTIME 5
|
||||
#endif
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"connthrottle",
|
||||
CONNTHROTTLE_VERSION,
|
||||
"Connection throttler - by Syzop",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"connthrottle",
|
||||
CONNTHROTTLE_VERSION,
|
||||
"Connection throttler - by Syzop",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
@@ -50,16 +49,16 @@ typedef struct {
|
||||
|
||||
typedef struct UCounter UCounter;
|
||||
struct UCounter {
|
||||
ThrottleCounter local; /**< Local counter */
|
||||
ThrottleCounter global; /**< Global counter */
|
||||
int rejected_clients; /**< Number of rejected clients this minute */
|
||||
int allowed_except; /**< Number of allowed clients - on except list */
|
||||
int allowed_unknown_users; /**< Number of allowed clients - not on except list */
|
||||
char disabled; /**< Module disabled by oper? */
|
||||
int throttling_this_minute; /**< Did we do any throttling this minute? */
|
||||
int throttling_previous_minute; /**< Did we do any throttling previous minute? */
|
||||
ThrottleCounter local; /**< Local counter */
|
||||
ThrottleCounter global; /**< Global counter */
|
||||
int rejected_clients; /**< Number of rejected clients this minute */
|
||||
int allowed_except; /**< Number of allowed clients - on except list */
|
||||
int allowed_unknown_users; /**< Number of allowed clients - not on except list */
|
||||
char disabled; /**< Module disabled by oper? */
|
||||
int throttling_this_minute; /**< Did we do any throttling this minute? */
|
||||
int throttling_previous_minute; /**< Did we do any throttling previous minute? */
|
||||
int throttling_banner_displayed;/**< Big we-are-now-throttling banner displayed? */
|
||||
time_t next_event; /**< When is next event? (for "last 60 seconds" stats) */
|
||||
time_t next_event; /**< When is next event? (for "last 60 seconds" stats) */
|
||||
};
|
||||
UCounter *ucounter = NULL;
|
||||
|
||||
@@ -81,12 +80,12 @@ RPC_CALL_FUNC(rpc_connthrottle_reset);
|
||||
|
||||
/* IPv6 wider-prefix bucket tracking (/56, /48, /32) */
|
||||
|
||||
#define CT_NUM_TIERS 3
|
||||
#define CT_NUM_TIERS 3
|
||||
#define CT_BUCKET_HASH_SIZE 2048
|
||||
|
||||
#ifdef DEBUGMODE
|
||||
/** Self-check of IPv6 CIDR limits every <this> msec */
|
||||
#define CONNTHROTTLE_CHECK 1000
|
||||
#define CONNTHROTTLE_CHECK 1000
|
||||
#endif
|
||||
|
||||
/* Per-client classification stored in our ModData slot.
|
||||
@@ -94,10 +93,10 @@ RPC_CALL_FUNC(rpc_connthrottle_reset);
|
||||
* "this client has not been added to our buckets yet".
|
||||
*/
|
||||
typedef enum {
|
||||
CT_CATEGORY_NONE = 0,
|
||||
CT_CATEGORY_KNOWN_USERS = 1,
|
||||
CT_CATEGORY_NONE = 0,
|
||||
CT_CATEGORY_KNOWN_USERS = 1,
|
||||
CT_CATEGORY_EXCEPTED_UNKNOWNS = 2,
|
||||
CT_CATEGORY_UNKNOWN_USERS = 3,
|
||||
CT_CATEGORY_UNKNOWN_USERS = 3,
|
||||
} ConnThrottleCategory;
|
||||
|
||||
typedef struct ConnThrottleBucket ConnThrottleBucket;
|
||||
@@ -114,7 +113,7 @@ struct ConnThrottleBucket {
|
||||
#endif
|
||||
};
|
||||
|
||||
static const int ct_tier_prefix[CT_NUM_TIERS] = { 56, 48, 32 };
|
||||
static const int ct_tier_prefix[CT_NUM_TIERS] = {56, 48, 32};
|
||||
static ConnThrottleBucket **ct_bucket_hash[CT_NUM_TIERS];
|
||||
static char *siphashkey_ct_buckets = NULL;
|
||||
static ModDataInfo *connthrottle_md = NULL;
|
||||
@@ -122,7 +121,7 @@ static ModDataInfo *connthrottle_md = NULL;
|
||||
/* Per-client classification cached in ModData. CT_CATEGORY_NONE means
|
||||
* "this client has not been added to our buckets yet" (or has been removed).
|
||||
*/
|
||||
#define CT_CATEGORY(client) moddata_client((client), connthrottle_md).l
|
||||
#define CT_CATEGORY(client) moddata_client((client), connthrottle_md).l
|
||||
|
||||
static void ct_make_rawip(Client *client, int tier, char *out);
|
||||
static uint64_t ct_hash_bucket(const char *masked);
|
||||
@@ -148,24 +147,26 @@ EVENT(ct_check);
|
||||
MOD_TEST()
|
||||
{
|
||||
memset(&cfg, 0, sizeof(cfg));
|
||||
|
||||
|
||||
/* Defaults: */
|
||||
cfg.local.count = 20; cfg.local.period = 60;
|
||||
cfg.global.count = 30; cfg.global.period = 60;
|
||||
cfg.start_delay = 180; /* 3 minutes */
|
||||
cfg.reputation_gathering = 7*86400; /* 1 week */
|
||||
cfg.local.count = 20;
|
||||
cfg.local.period = 60;
|
||||
cfg.global.count = 30;
|
||||
cfg.global.period = 60;
|
||||
cfg.start_delay = 180; /* 3 minutes */
|
||||
cfg.reputation_gathering = 7 * 86400; /* 1 week */
|
||||
safe_strdup(cfg.reason, "Throttled: Too many users trying to connect, please wait a while and try again");
|
||||
cfg.except = safe_alloc(sizeof(SecurityGroup));
|
||||
cfg.except->reputation_score = 24;
|
||||
cfg.except->identified = 1;
|
||||
cfg.except->webirc = 0;
|
||||
cfg.ipv6_unknown_users_limit[0] = 8; /* /56 */
|
||||
cfg.ipv6_unknown_users_limit[1] = 32; /* /48 */
|
||||
cfg.ipv6_unknown_users_limit[2] = 256; /* /32 */
|
||||
cfg.ipv6_unknown_users_limit[0] = 8; /* /56 */
|
||||
cfg.ipv6_unknown_users_limit[1] = 32; /* /48 */
|
||||
cfg.ipv6_unknown_users_limit[2] = 256; /* /32 */
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CONFIGTEST, 0, ct_config_test);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CONFIGPOSTTEST, 0, ct_config_posttest);
|
||||
|
||||
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -187,7 +188,7 @@ MOD_INIT()
|
||||
memset(&mreq, 0, sizeof(mreq));
|
||||
mreq.name = "connthrottle_category";
|
||||
mreq.type = MODDATATYPE_CLIENT;
|
||||
mreq.sync = 0; /* local only, no S2S sync */
|
||||
mreq.sync = 0; /* local only, no S2S sync */
|
||||
connthrottle_md = ModDataAdd(modinfo->handle, mreq);
|
||||
if (!connthrottle_md)
|
||||
{
|
||||
@@ -207,7 +208,7 @@ MOD_INIT()
|
||||
HookAdd(modinfo->handle, HOOKTYPE_KNOWN_USER_CACHE_CHANGE, 0, ct_known_user_cache_change);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_STATS, 0, stats_connthrottle);
|
||||
|
||||
CommandAdd(modinfo->handle, MSG_THROTTLE, ct_throttle, MAXPARA, CMD_USER|CMD_SERVER);
|
||||
CommandAdd(modinfo->handle, MSG_THROTTLE, ct_throttle, MAXPARA, CMD_USER | CMD_SERVER);
|
||||
|
||||
/* RPC handlers */
|
||||
memset(&r, 0, sizeof(r));
|
||||
@@ -295,18 +296,17 @@ int ct_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::connthrottle.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "connthrottle"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
test_match_block(cf, cep, &errors);
|
||||
} else
|
||||
if (!strcmp(cep->name, "known-users"))
|
||||
} else if (!strcmp(cep->name, "known-users"))
|
||||
{
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
{
|
||||
@@ -317,15 +317,13 @@ int ct_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (cnt < 1)
|
||||
{
|
||||
config_error("%s:%i: set::connthrottle::known-users::minimum-reputation-score should be at least 1",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cepp->name, "sasl-bypass"))
|
||||
} else if (!strcmp(cepp->name, "sasl-bypass"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cepp->name, "webirc-bypass"))
|
||||
} else if (!strcmp(cepp->name, "webirc-bypass"))
|
||||
{
|
||||
} else
|
||||
{
|
||||
@@ -334,8 +332,7 @@ int ct_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "new-users"))
|
||||
} else if (!strcmp(cep->name, "new-users"))
|
||||
{
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
{
|
||||
@@ -347,23 +344,22 @@ int ct_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
(cnt < 1) || (cnt > 2000000000) || (period > 2000000000))
|
||||
{
|
||||
config_error("%s:%i: set::connthrottle::new-users::local-throttle error. "
|
||||
"Syntax is <count>:<period> (eg 6:60), "
|
||||
"and count and period should be non-zero.",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
"Syntax is <count>:<period> (eg 6:60), "
|
||||
"and count and period should be non-zero.",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cepp->name, "global-throttle"))
|
||||
} else if (!strcmp(cepp->name, "global-throttle"))
|
||||
{
|
||||
int cnt, period;
|
||||
if (!config_parse_flood(cepp->value, &cnt, &period) ||
|
||||
(cnt < 1) || (cnt > 2000000000) || (period > 2000000000))
|
||||
{
|
||||
config_error("%s:%i: set::connthrottle::new-users::global-throttle error. "
|
||||
"Syntax is <count>:<period> (eg 6:60), "
|
||||
"and count and period should be non-zero.",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
"Syntax is <count>:<period> (eg 6:60), "
|
||||
"and count and period should be non-zero.",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -374,8 +370,7 @@ int ct_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "disabled-when"))
|
||||
} else if (!strcmp(cep->name, "disabled-when"))
|
||||
{
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
{
|
||||
@@ -386,12 +381,11 @@ int ct_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if ((cnt < 0) || (cnt > 3600))
|
||||
{
|
||||
config_error("%s:%i: set::connthrottle::disabled-when::start-delay should be in range 0-3600",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cepp->name, "reputation-gathering"))
|
||||
} else if (!strcmp(cepp->name, "reputation-gathering"))
|
||||
{
|
||||
} else
|
||||
{
|
||||
@@ -400,12 +394,10 @@ int ct_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "reason"))
|
||||
} else if (!strcmp(cep->name, "reason"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ipv6-unknown-users-limit"))
|
||||
} else if (!strcmp(cep->name, "ipv6-unknown-users-limit"))
|
||||
{
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
{
|
||||
@@ -441,12 +433,12 @@ int ct_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::connthrottle::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -458,18 +450,17 @@ int ct_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::connthrottle.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "connthrottle"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
conf_match_block(cf, cep, &cfg.except);
|
||||
} else
|
||||
if (!strcmp(cep->name, "known-users"))
|
||||
} else if (!strcmp(cep->name, "known-users"))
|
||||
{
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
{
|
||||
@@ -480,8 +471,7 @@ int ct_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
else if (!strcmp(cepp->name, "webirc-bypass"))
|
||||
cfg.except->webirc = config_checkval(cepp->value, CFG_YESNO);
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "new-users"))
|
||||
} else if (!strcmp(cep->name, "new-users"))
|
||||
{
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
{
|
||||
@@ -490,8 +480,7 @@ int ct_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
else if (!strcmp(cepp->name, "global-throttle"))
|
||||
config_parse_flood(cepp->value, &cfg.global.count, &cfg.global.period);
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "disabled-when"))
|
||||
} else if (!strcmp(cep->name, "disabled-when"))
|
||||
{
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
{
|
||||
@@ -500,14 +489,12 @@ int ct_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
else if (!strcmp(cepp->name, "reputation-gathering"))
|
||||
cfg.reputation_gathering = config_checkval(cepp->value, CFG_TIME);
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "reason"))
|
||||
} else if (!strcmp(cep->name, "reason"))
|
||||
{
|
||||
safe_free(cfg.reason);
|
||||
cfg.reason = safe_alloc(strlen(cep->value)+16);
|
||||
cfg.reason = safe_alloc(strlen(cep->value) + 16);
|
||||
sprintf(cfg.reason, "Throttled: %s", cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ipv6-unknown-users-limit"))
|
||||
} else if (!strcmp(cep->name, "ipv6-unknown-users-limit"))
|
||||
{
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
{
|
||||
@@ -580,11 +567,11 @@ EVENT(connthrottle_evt)
|
||||
ucounter->throttling_banner_displayed = 0; /* reset */
|
||||
}
|
||||
|
||||
#define THROT_LOCAL 1
|
||||
#define THROT_LOCAL 1
|
||||
#define THROT_GLOBAL 2
|
||||
int ct_pre_lconnect(Client *client)
|
||||
{
|
||||
int throttle=0;
|
||||
int throttle = 0;
|
||||
int score;
|
||||
|
||||
if (me.local->creationtime + cfg.start_delay > TStime())
|
||||
@@ -603,11 +590,11 @@ int ct_pre_lconnect(Client *client)
|
||||
/* If we reach this then the user is NEW */
|
||||
|
||||
/* +1 global client would reach global limit? */
|
||||
if ((TStime() - ucounter->global.t < cfg.global.period) && (ucounter->global.count+1 > cfg.global.count))
|
||||
if ((TStime() - ucounter->global.t < cfg.global.period) && (ucounter->global.count + 1 > cfg.global.count))
|
||||
throttle |= THROT_GLOBAL;
|
||||
|
||||
/* +1 local client would reach local limit? */
|
||||
if ((TStime() - ucounter->local.t < cfg.local.period) && (ucounter->local.count+1 > cfg.local.count))
|
||||
if ((TStime() - ucounter->local.t < cfg.local.period) && (ucounter->local.count + 1 > cfg.local.count))
|
||||
throttle |= THROT_LOCAL;
|
||||
|
||||
if (throttle)
|
||||
@@ -640,7 +627,8 @@ void bump_connect_counter(int local_connect)
|
||||
{
|
||||
ucounter->local.t = TStime();
|
||||
ucounter->local.count = 1;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
ucounter->local.count++;
|
||||
}
|
||||
}
|
||||
@@ -650,7 +638,8 @@ void bump_connect_counter(int local_connect)
|
||||
{
|
||||
ucounter->global.t = TStime();
|
||||
ucounter->global.count = 1;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
ucounter->global.count++;
|
||||
}
|
||||
}
|
||||
@@ -750,7 +739,7 @@ void ct_off(Client *client)
|
||||
|
||||
ucounter->disabled = 1;
|
||||
unreal_log(ULOG_WARNING, "connthrottle", "CONNTHROTTLE_MODULE_DISABLED", client,
|
||||
"[ConnThrottle] $client.details DISABLED the connthrottle module.");
|
||||
"[ConnThrottle] $client.details DISABLED the connthrottle module.");
|
||||
}
|
||||
|
||||
void ct_on(Client *client)
|
||||
@@ -759,7 +748,7 @@ void ct_on(Client *client)
|
||||
return; /* Already on */
|
||||
|
||||
unreal_log(ULOG_WARNING, "connthrottle", "CONNTHROTTLE_MODULE_ENABLED", client,
|
||||
"[ConnThrottle] $client.details ENABLED the connthrottle module.");
|
||||
"[ConnThrottle] $client.details ENABLED the connthrottle module.");
|
||||
ucounter->disabled = 0;
|
||||
}
|
||||
|
||||
@@ -767,7 +756,7 @@ void ct_reset(Client *client)
|
||||
{
|
||||
memset(ucounter, 0, sizeof(UCounter));
|
||||
unreal_log(ULOG_WARNING, "connthrottle", "CONNTHROTTLE_RESET", client,
|
||||
"[ConnThrottle] $client.details did a RESET on the statistics/counters.");
|
||||
"[ConnThrottle] $client.details did a RESET on the statistics/counters.");
|
||||
}
|
||||
|
||||
CMD_FUNC(ct_throttle)
|
||||
@@ -788,8 +777,7 @@ CMD_FUNC(ct_throttle)
|
||||
{
|
||||
sendnotice(client, "STATUS:");
|
||||
sendnotice(client, "%s", ct_module_status_text());
|
||||
} else
|
||||
if (!strcasecmp(parv[1], "OFF"))
|
||||
} else if (!strcasecmp(parv[1], "OFF"))
|
||||
{
|
||||
if (ucounter->disabled == 1)
|
||||
{
|
||||
@@ -797,8 +785,7 @@ CMD_FUNC(ct_throttle)
|
||||
return;
|
||||
}
|
||||
ct_off(client);
|
||||
} else
|
||||
if (!strcasecmp(parv[1], "ON"))
|
||||
} else if (!strcasecmp(parv[1], "ON"))
|
||||
{
|
||||
if (ucounter->disabled == 0)
|
||||
{
|
||||
@@ -806,8 +793,7 @@ CMD_FUNC(ct_throttle)
|
||||
return;
|
||||
}
|
||||
ct_on(client);
|
||||
} else
|
||||
if (!strcasecmp(parv[1], "RESET"))
|
||||
} else if (!strcasecmp(parv[1], "RESET"))
|
||||
{
|
||||
ct_reset(client);
|
||||
} else
|
||||
@@ -877,14 +863,14 @@ static void ct_check_walk_one(Client *client)
|
||||
|
||||
category = CT_CATEGORY(client);
|
||||
if (category == CT_CATEGORY_NONE)
|
||||
return; /* not in our buckets */
|
||||
return; /* not in our buckets */
|
||||
if (!IsIPV6(client) || !client->ip)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "connthrottle", "BUG_CT_CHECK_NO_IP", client,
|
||||
"[BUG] connthrottle counter check: client has category but no IPv6 IP");
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
abort();
|
||||
#endif
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
for (tier = 0; tier < CT_NUM_TIERS; tier++)
|
||||
@@ -896,17 +882,24 @@ static void ct_check_walk_one(Client *client)
|
||||
unreal_log(ULOG_ERROR, "connthrottle", "BUG_CT_CHECK_NO_BUCKET", client,
|
||||
"[BUG] connthrottle counter check: client has category but no bucket at /$prefix",
|
||||
log_data_integer("prefix", ct_tier_prefix[tier]));
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
abort();
|
||||
#endif
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
switch (category)
|
||||
{
|
||||
case CT_CATEGORY_KNOWN_USERS: b->check_known++; break;
|
||||
case CT_CATEGORY_EXCEPTED_UNKNOWNS: b->check_excepted++; break;
|
||||
case CT_CATEGORY_UNKNOWN_USERS: b->check_unknown++; break;
|
||||
case CT_CATEGORY_NONE: break; /* unreachable per filter */
|
||||
case CT_CATEGORY_KNOWN_USERS:
|
||||
b->check_known++;
|
||||
break;
|
||||
case CT_CATEGORY_EXCEPTED_UNKNOWNS:
|
||||
b->check_excepted++;
|
||||
break;
|
||||
case CT_CATEGORY_UNKNOWN_USERS:
|
||||
b->check_unknown++;
|
||||
break;
|
||||
case CT_CATEGORY_NONE:
|
||||
break; /* unreachable per filter */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -923,9 +916,9 @@ EVENT(ct_check)
|
||||
b->check_known = b->check_excepted = b->check_unknown = 0;
|
||||
|
||||
list_for_each_entry(client, &client_list, client_node)
|
||||
ct_check_walk_one(client);
|
||||
ct_check_walk_one(client);
|
||||
list_for_each_entry(client, &unknown_list, lclient_node)
|
||||
ct_check_walk_one(client);
|
||||
ct_check_walk_one(client);
|
||||
|
||||
for (tier = 0; tier < CT_NUM_TIERS; tier++)
|
||||
{
|
||||
@@ -933,9 +926,9 @@ EVENT(ct_check)
|
||||
{
|
||||
for (b = ct_bucket_hash[tier][i]; b; b = b->next)
|
||||
{
|
||||
if (b->check_known != b->known_users ||
|
||||
if (b->check_known != b->known_users ||
|
||||
b->check_excepted != b->excepted_unknowns ||
|
||||
b->check_unknown != b->unknown_users)
|
||||
b->check_unknown != b->unknown_users)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "connthrottle", "BUG_CT_CHECK_DRIFT", NULL,
|
||||
"[BUG] connthrottle bucket counter drift at /$prefix: "
|
||||
@@ -948,9 +941,9 @@ EVENT(ct_check)
|
||||
log_data_integer("exp_k", b->check_known),
|
||||
log_data_integer("exp_e", b->check_excepted),
|
||||
log_data_integer("exp_u", b->check_unknown));
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
abort();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1100,10 +1093,17 @@ static void ct_bucket_increment(ConnThrottleBucket *b, ConnThrottleCategory cate
|
||||
{
|
||||
switch (category)
|
||||
{
|
||||
case CT_CATEGORY_NONE: break; /* not classified: no-op */
|
||||
case CT_CATEGORY_KNOWN_USERS: b->known_users++; break;
|
||||
case CT_CATEGORY_EXCEPTED_UNKNOWNS: b->excepted_unknowns++; break;
|
||||
case CT_CATEGORY_UNKNOWN_USERS: b->unknown_users++; break;
|
||||
case CT_CATEGORY_NONE:
|
||||
break; /* not classified: no-op */
|
||||
case CT_CATEGORY_KNOWN_USERS:
|
||||
b->known_users++;
|
||||
break;
|
||||
case CT_CATEGORY_EXCEPTED_UNKNOWNS:
|
||||
b->excepted_unknowns++;
|
||||
break;
|
||||
case CT_CATEGORY_UNKNOWN_USERS:
|
||||
b->unknown_users++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,10 +1111,17 @@ static void ct_bucket_decrement(ConnThrottleBucket *b, ConnThrottleCategory cate
|
||||
{
|
||||
switch (category)
|
||||
{
|
||||
case CT_CATEGORY_NONE: break; /* not classified: no-op */
|
||||
case CT_CATEGORY_KNOWN_USERS: b->known_users--; break;
|
||||
case CT_CATEGORY_EXCEPTED_UNKNOWNS: b->excepted_unknowns--; break;
|
||||
case CT_CATEGORY_UNKNOWN_USERS: b->unknown_users--; break;
|
||||
case CT_CATEGORY_NONE:
|
||||
break; /* not classified: no-op */
|
||||
case CT_CATEGORY_KNOWN_USERS:
|
||||
b->known_users--;
|
||||
break;
|
||||
case CT_CATEGORY_EXCEPTED_UNKNOWNS:
|
||||
b->excepted_unknowns--;
|
||||
break;
|
||||
case CT_CATEGORY_UNKNOWN_USERS:
|
||||
b->unknown_users--;
|
||||
break;
|
||||
}
|
||||
if ((b->known_users < 0) || (b->excepted_unknowns < 0) || (b->unknown_users < 0))
|
||||
{
|
||||
@@ -1251,13 +1258,13 @@ const char *ct_allow_client(Client *client, ConfigItem_allow *aconf)
|
||||
if (b && (b->unknown_users > effective_limit))
|
||||
{
|
||||
unreal_log(ULOG_INFO, "connthrottle", "CONNTHROTTLE_IPV6_LIMIT", client,
|
||||
"Client $client.name with IP $client.ip rejected: connthrottle ipv6-unknown-users-limit (cidr-$prefix_len, max $max) exceeded for $prefix_addr/$prefix_len ($unknown_users unknown / $excepted_users excepted / $known_users known)",
|
||||
log_data_string("prefix_addr", format_ipv6_addr(masked)),
|
||||
log_data_integer("prefix_len", ct_tier_prefix[tier]),
|
||||
log_data_integer("max", effective_limit),
|
||||
log_data_integer("unknown_users", b->unknown_users),
|
||||
log_data_integer("excepted_users", b->excepted_unknowns),
|
||||
log_data_integer("known_users", b->known_users));
|
||||
"Client $client.name with IP $client.ip rejected: connthrottle ipv6-unknown-users-limit (cidr-$prefix_len, max $max) exceeded for $prefix_addr/$prefix_len ($unknown_users unknown / $excepted_users excepted / $known_users known)",
|
||||
log_data_string("prefix_addr", format_ipv6_addr(masked)),
|
||||
log_data_integer("prefix_len", ct_tier_prefix[tier]),
|
||||
log_data_integer("max", effective_limit),
|
||||
log_data_integer("unknown_users", b->unknown_users),
|
||||
log_data_integer("excepted_users", b->excepted_unknowns),
|
||||
log_data_integer("known_users", b->known_users));
|
||||
return format_ipv6_prefix_reject_message(
|
||||
iConf.reject_message_too_many_new_connections_ipv6_range,
|
||||
masked, ct_tier_prefix[tier]);
|
||||
@@ -1276,7 +1283,7 @@ int ct_remote_connect_buckets(Client *client)
|
||||
ConnThrottleCategory category;
|
||||
|
||||
if (IsULine(client))
|
||||
return 0; /* U-lined service: skip */
|
||||
return 0; /* U-lined service: skip */
|
||||
if (!IsIPV6(client) || !client->ip)
|
||||
return 0;
|
||||
if (CT_CATEGORY(client) != CT_CATEGORY_NONE)
|
||||
@@ -1355,7 +1362,7 @@ static void ct_buckets_rebuild(void)
|
||||
list_for_each_entry(client, &client_list, client_node)
|
||||
{
|
||||
if (!IsUser(client) || IsULine(client))
|
||||
continue; /* only regular IRC users; skip servers, services, pre-registration */
|
||||
continue; /* only regular IRC users; skip servers, services, pre-registration */
|
||||
if (!IsIPV6(client) || !client->ip)
|
||||
continue;
|
||||
category = ct_classify(client);
|
||||
@@ -1365,7 +1372,7 @@ static void ct_buckets_rebuild(void)
|
||||
list_for_each_entry(client, &unknown_list, lclient_node)
|
||||
{
|
||||
if (!IsUser(client) || IsULine(client))
|
||||
continue; /* only regular IRC users; skip servers, services, pre-registration */
|
||||
continue; /* only regular IRC users; skip servers, services, pre-registration */
|
||||
if (!IsIPV6(client) || !client->ip)
|
||||
continue;
|
||||
category = ct_classify(client);
|
||||
|
||||
@@ -6,14 +6,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"creationtime",
|
||||
"6.1",
|
||||
"Store and retrieve creation time of clients",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"creationtime",
|
||||
"6.1",
|
||||
"Store and retrieve creation time of clients",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
void creationtime_free(ModData *m);
|
||||
@@ -25,7 +24,11 @@ int creationtime_whois(Client *client, Client *target);
|
||||
|
||||
ModDataInfo *creationtime_md; /* Module Data structure which we acquire */
|
||||
|
||||
#define SetCreationTime(x,y) do { moddata_client(x, creationtime_md).ll = y; } while(0)
|
||||
#define SetCreationTime(x, y) \
|
||||
do \
|
||||
{ \
|
||||
moddata_client(x, creationtime_md).ll = y; \
|
||||
} while (0)
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
|
||||
+127
-138
@@ -21,13 +21,12 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"crule",
|
||||
"1.0.1",
|
||||
"Crule support for and deny link::rule and spamfilter::rule",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"crule",
|
||||
"1.0.1",
|
||||
"Crule support for and deny link::rule and spamfilter::rule",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Originally by Tony Vencill (Tonto on IRC) <vencill@bga.com>
|
||||
@@ -88,7 +87,7 @@ enum crule_token {
|
||||
CR_WORD /**< Something that looks like a hostmask (alphanumerics, "*?.-"). */
|
||||
};
|
||||
|
||||
#define IsComparisson(x) ((x == CR_EQUAL) || (x == CR_LESS_THAN) || (x == CR_MORE_THAN))
|
||||
#define IsComparisson(x) ((x == CR_EQUAL) || (x == CR_LESS_THAN) || (x == CR_MORE_THAN))
|
||||
|
||||
/** Parser error codes. */
|
||||
typedef enum crule_errcode crule_errcode;
|
||||
@@ -110,7 +109,7 @@ enum crule_errcode {
|
||||
|
||||
int _crule_test(const char *rule);
|
||||
CRuleNode *_crule_parse(const char *rule);
|
||||
void _crule_free(CRuleNode**);
|
||||
void _crule_free(CRuleNode **);
|
||||
int _crule_eval(crule_context *context, CRuleNode *rule);
|
||||
const char *_crule_errstring(int errcode);
|
||||
|
||||
@@ -190,17 +189,17 @@ static int crule_parsearglist(CRuleNode *, crule_token *, const char **);
|
||||
|
||||
/* error messages */
|
||||
char *crule_errstr[] = {
|
||||
"Unknown error", /* NOERR? - for completeness */
|
||||
"Unexpected token", /* UNEXPCTTOK */
|
||||
"Unknown token", /* UNKNWTOK */
|
||||
"And expr expected", /* EXPCTAND */
|
||||
"Or expr expected", /* EXPCTOR */
|
||||
"Primary expected", /* EXPCTPRIM */
|
||||
"( expected", /* EXPCTOPEN */
|
||||
") expected", /* EXPCTCLOSE */
|
||||
"Unknown function", /* UNKNWFUNC */
|
||||
"Argument mismatch", /* ARGMISMAT */
|
||||
"Missing value in comparisson", /* CR_EXPCTVALUE */
|
||||
"Unknown error", /* NOERR? - for completeness */
|
||||
"Unexpected token", /* UNEXPCTTOK */
|
||||
"Unknown token", /* UNKNWTOK */
|
||||
"And expr expected", /* EXPCTAND */
|
||||
"Or expr expected", /* EXPCTOR */
|
||||
"Primary expected", /* EXPCTPRIM */
|
||||
"( expected", /* EXPCTOPEN */
|
||||
") expected", /* EXPCTCLOSE */
|
||||
"Unknown function", /* UNKNWFUNC */
|
||||
"Argument mismatch", /* ARGMISMAT */
|
||||
"Missing value in comparisson", /* CR_EXPCTVALUE */
|
||||
};
|
||||
|
||||
/* function table - null terminated */
|
||||
@@ -212,67 +211,67 @@ struct crule_funclistent {
|
||||
|
||||
/* This table MUST remain sorted alphabetically (due to binary search) */
|
||||
struct crule_funclistent crule_funclist[] = {
|
||||
{"bytes_received", 0, crule_bytes_received},
|
||||
{"bytes_sent", 0, crule_bytes_sent},
|
||||
{"cap_set", 1, crule_cap_set},
|
||||
{"cap_version", 0, crule_cap_version},
|
||||
{"channel_count", 0, crule_channel_count},
|
||||
{"channel_member_count", 0, crule_channel_member_count},
|
||||
{"connected", 1, crule_connected},
|
||||
{"connections_from_ip", 0, crule_connections_from_ip},
|
||||
{"destination", 1, crule_destination},
|
||||
{"digit_percentage", 0, crule_digit_percentage},
|
||||
{"directcon", 1, crule_directcon},
|
||||
{"directop", 0, crule_directop},
|
||||
{"has_channel_mode", 1, crule_has_channel_mode},
|
||||
{"has_swhois", 0, crule_has_swhois},
|
||||
{"has_user_mode", 1, crule_has_user_mode},
|
||||
{"idle_time", 0, crule_idle_time},
|
||||
{"in_channel", 1, crule_in_channel},
|
||||
{"in_security_group", 1, crule_in_security_group},
|
||||
{"inchannel", 1, crule_in_channel}, // old name, keep it around for now..
|
||||
{"is_away", 0, crule_away},
|
||||
{"is_identified", 0, crule_is_identified},
|
||||
{"is_local", 0, crule_is_local},
|
||||
{"is_oper", 0, crule_is_oper},
|
||||
{"is_tls", 0, crule_tls},
|
||||
{"is_webirc", 0, crule_is_webirc},
|
||||
{"is_websocket", 0, crule_is_websocket},
|
||||
{"match_account", 1, crule_match_account},
|
||||
{"match_asn", 1, crule_match_asn},
|
||||
{"match_asname", 1, crule_match_asname},
|
||||
{"match_away", 1, crule_match_away},
|
||||
{"match_certfp", 1, crule_match_certfp},
|
||||
{"match_class", 1, crule_match_class},
|
||||
{"match_country", 1, crule_match_country},
|
||||
{"match_ip", 1, crule_match_ip},
|
||||
{"match_mask", 1, crule_match_mask},
|
||||
{"match_operclass", 1, crule_match_operclass},
|
||||
{"match_operlogin", 1, crule_match_operlogin},
|
||||
{"match_realhost", 1, crule_match_realhost},
|
||||
{"match_realname", 1, crule_match_realname},
|
||||
{"match_server", 1, crule_match_server},
|
||||
{"match_sni", 1, crule_match_sni},
|
||||
{"match_tls_cipher", 1, crule_match_tls_cipher},
|
||||
{"match_vhost", 1, crule_match_vhost},
|
||||
{"max_repeat_count", 0, crule_max_repeat_count},
|
||||
{"messages_received", 0, crule_messages_received},
|
||||
{"messages_sent", 0, crule_messages_sent},
|
||||
{"mixed_utf8_score", 0, crule_mixed_utf8_score},
|
||||
{"non_ascii_percentage", 0, crule_non_ascii_percentage},
|
||||
{"online_time", 0, crule_online_time},
|
||||
{"reputation", 0, crule_reputation},
|
||||
{"server_flood_count", 1, crule_server_flood_count},
|
||||
{"server_port", 0, crule_server_port},
|
||||
{"tag", 1, crule_tag},
|
||||
{"text_byte_count", 0, crule_text_byte_count},
|
||||
{"text_character_count", 0, crule_text_character_count},
|
||||
{"total_channel_flood_count", 1, crule_total_channel_flood_count},
|
||||
{"unicode_block_count", 0, crule_unicode_block_count},
|
||||
{"unicode_count", 1, crule_unicode_count},
|
||||
{"uppercase_percentage", 0, crule_uppercase_percentage},
|
||||
{"via", 2, crule_via},
|
||||
{"word_count", 0, crule_word_count},
|
||||
{"bytes_received", 0, crule_bytes_received},
|
||||
{"bytes_sent", 0, crule_bytes_sent},
|
||||
{"cap_set", 1, crule_cap_set},
|
||||
{"cap_version", 0, crule_cap_version},
|
||||
{"channel_count", 0, crule_channel_count},
|
||||
{"channel_member_count", 0, crule_channel_member_count},
|
||||
{"connected", 1, crule_connected},
|
||||
{"connections_from_ip", 0, crule_connections_from_ip},
|
||||
{"destination", 1, crule_destination},
|
||||
{"digit_percentage", 0, crule_digit_percentage},
|
||||
{"directcon", 1, crule_directcon},
|
||||
{"directop", 0, crule_directop},
|
||||
{"has_channel_mode", 1, crule_has_channel_mode},
|
||||
{"has_swhois", 0, crule_has_swhois},
|
||||
{"has_user_mode", 1, crule_has_user_mode},
|
||||
{"idle_time", 0, crule_idle_time},
|
||||
{"in_channel", 1, crule_in_channel},
|
||||
{"in_security_group", 1, crule_in_security_group},
|
||||
{"inchannel", 1, crule_in_channel}, // old name, keep it around for now..
|
||||
{"is_away", 0, crule_away},
|
||||
{"is_identified", 0, crule_is_identified},
|
||||
{"is_local", 0, crule_is_local},
|
||||
{"is_oper", 0, crule_is_oper},
|
||||
{"is_tls", 0, crule_tls},
|
||||
{"is_webirc", 0, crule_is_webirc},
|
||||
{"is_websocket", 0, crule_is_websocket},
|
||||
{"match_account", 1, crule_match_account},
|
||||
{"match_asn", 1, crule_match_asn},
|
||||
{"match_asname", 1, crule_match_asname},
|
||||
{"match_away", 1, crule_match_away},
|
||||
{"match_certfp", 1, crule_match_certfp},
|
||||
{"match_class", 1, crule_match_class},
|
||||
{"match_country", 1, crule_match_country},
|
||||
{"match_ip", 1, crule_match_ip},
|
||||
{"match_mask", 1, crule_match_mask},
|
||||
{"match_operclass", 1, crule_match_operclass},
|
||||
{"match_operlogin", 1, crule_match_operlogin},
|
||||
{"match_realhost", 1, crule_match_realhost},
|
||||
{"match_realname", 1, crule_match_realname},
|
||||
{"match_server", 1, crule_match_server},
|
||||
{"match_sni", 1, crule_match_sni},
|
||||
{"match_tls_cipher", 1, crule_match_tls_cipher},
|
||||
{"match_vhost", 1, crule_match_vhost},
|
||||
{"max_repeat_count", 0, crule_max_repeat_count},
|
||||
{"messages_received", 0, crule_messages_received},
|
||||
{"messages_sent", 0, crule_messages_sent},
|
||||
{"mixed_utf8_score", 0, crule_mixed_utf8_score},
|
||||
{"non_ascii_percentage", 0, crule_non_ascii_percentage},
|
||||
{"online_time", 0, crule_online_time},
|
||||
{"reputation", 0, crule_reputation},
|
||||
{"server_flood_count", 1, crule_server_flood_count},
|
||||
{"server_port", 0, crule_server_port},
|
||||
{"tag", 1, crule_tag},
|
||||
{"text_byte_count", 0, crule_text_byte_count},
|
||||
{"text_character_count", 0, crule_text_character_count},
|
||||
{"total_channel_flood_count", 1, crule_total_channel_flood_count},
|
||||
{"unicode_block_count", 0, crule_unicode_block_count},
|
||||
{"unicode_count", 1, crule_unicode_count},
|
||||
{"uppercase_percentage", 0, crule_uppercase_percentage},
|
||||
{"via", 2, crule_via},
|
||||
{"word_count", 0, crule_word_count},
|
||||
};
|
||||
|
||||
MOD_TEST()
|
||||
@@ -558,7 +557,7 @@ static int crule_cap_set(crule_context *context, int numargs, void *crulearg[])
|
||||
{
|
||||
const char *capname = (char *)crulearg[0];
|
||||
|
||||
if (!context || !context->client || !context->client->local )
|
||||
if (!context || !context->client || !context->client->local)
|
||||
return 0;
|
||||
|
||||
if (HasCapability(context->client, capname))
|
||||
@@ -586,7 +585,7 @@ static int crule_match_mask(crule_context *context, int numargs, void *crulearg[
|
||||
if (!context || !context->client)
|
||||
return 0;
|
||||
|
||||
if (match_user(arg, context->client, MATCH_CHECK_REAL_HOST|MATCH_CHECK_IP|MATCH_CHECK_EXTENDED))
|
||||
if (match_user(arg, context->client, MATCH_CHECK_REAL_HOST | MATCH_CHECK_IP | MATCH_CHECK_EXTENDED))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@@ -599,7 +598,7 @@ static int crule_match_ip(crule_context *context, int numargs, void *crulearg[])
|
||||
if (!context || !context->client)
|
||||
return 0;
|
||||
|
||||
if (match_user(arg, context->client, MATCH_CHECK_IP|MATCH_MASK_IS_HOST))
|
||||
if (match_user(arg, context->client, MATCH_CHECK_IP | MATCH_MASK_IS_HOST))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@@ -1011,7 +1010,8 @@ static int crule_max_repeat_count(crule_context *context, int numargs, void *cru
|
||||
if (*p == *(p - 1))
|
||||
{
|
||||
cur++;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (cur > max)
|
||||
max = cur;
|
||||
cur = 1;
|
||||
@@ -1026,7 +1026,7 @@ static int crule_max_repeat_count(crule_context *context, int numargs, void *cru
|
||||
* @param[in] rule Rule to evalute.
|
||||
* @return Non-zero if the rule allows the connection, zero otherwise.
|
||||
*/
|
||||
int _crule_eval(crule_context *context, CRuleNode* rule)
|
||||
int _crule_eval(crule_context *context, CRuleNode *rule)
|
||||
{
|
||||
int ret = rule->funcptr(context, rule->numargs, rule->arg);
|
||||
switch (rule->func_test_type)
|
||||
@@ -1146,7 +1146,7 @@ static int crule_gettoken(crule_token *next_tokp, const char **ruleptr)
|
||||
break;
|
||||
default:
|
||||
if ((isalnum(*(--(*ruleptr)))) || (**ruleptr == '*') ||
|
||||
(**ruleptr == '?') || (**ruleptr == '.') || (**ruleptr == '-') || (**ruleptr == '_') || (**ruleptr == '\''))
|
||||
(**ruleptr == '?') || (**ruleptr == '.') || (**ruleptr == '-') || (**ruleptr == '_') || (**ruleptr == '\''))
|
||||
*next_tokp = CR_WORD;
|
||||
else
|
||||
return CR_UNKNWTOK;
|
||||
@@ -1174,11 +1174,7 @@ static void crule_getword(char *word, int *wordlenp, size_t maxlen, const char *
|
||||
quoted = 1;
|
||||
}
|
||||
|
||||
while ((size_t)(word_ptr - word) < maxlen
|
||||
&& (isalnum(**ruleptr)
|
||||
|| **ruleptr == '*' || **ruleptr == '?'
|
||||
|| **ruleptr == '.' || **ruleptr == '-'
|
||||
|| **ruleptr == '_' || (quoted && (**ruleptr != '\''))))
|
||||
while ((size_t)(word_ptr - word) < maxlen && (isalnum(**ruleptr) || **ruleptr == '*' || **ruleptr == '?' || **ruleptr == '.' || **ruleptr == '-' || **ruleptr == '_' || (quoted && (**ruleptr != '\''))))
|
||||
{
|
||||
*word_ptr++ = *(*ruleptr)++;
|
||||
}
|
||||
@@ -1198,18 +1194,20 @@ CRuleNode *_crule_parse(const char *rule)
|
||||
{
|
||||
const char *ruleptr = rule;
|
||||
crule_token next_tok;
|
||||
CRuleNode* ruleroot = 0;
|
||||
CRuleNode *ruleroot = 0;
|
||||
int errcode = CR_NOERR;
|
||||
|
||||
if ((errcode = crule_gettoken(&next_tok, &ruleptr)) == CR_NOERR) {
|
||||
if ((errcode = crule_parseorexpr(&ruleroot, &next_tok, &ruleptr)) == CR_NOERR) {
|
||||
if (ruleroot != NULL) {
|
||||
if ((errcode = crule_gettoken(&next_tok, &ruleptr)) == CR_NOERR)
|
||||
{
|
||||
if ((errcode = crule_parseorexpr(&ruleroot, &next_tok, &ruleptr)) == CR_NOERR)
|
||||
{
|
||||
if (ruleroot != NULL)
|
||||
{
|
||||
if (next_tok == CR_END)
|
||||
return ruleroot;
|
||||
else
|
||||
errcode = CR_UNEXPCTTOK;
|
||||
}
|
||||
else
|
||||
} else
|
||||
errcode = CR_EXPCTOR;
|
||||
}
|
||||
}
|
||||
@@ -1226,22 +1224,25 @@ int _crule_test(const char *rule)
|
||||
{
|
||||
const char *ruleptr = rule;
|
||||
crule_token next_tok;
|
||||
CRuleNode* ruleroot = 0;
|
||||
CRuleNode *ruleroot = 0;
|
||||
int errcode = CR_NOERR;
|
||||
|
||||
if ((errcode = crule_gettoken(&next_tok, &ruleptr)) == CR_NOERR) {
|
||||
if ((errcode = crule_parseorexpr(&ruleroot, &next_tok, &ruleptr)) == CR_NOERR) {
|
||||
if (ruleroot != NULL) {
|
||||
if ((errcode = crule_gettoken(&next_tok, &ruleptr)) == CR_NOERR)
|
||||
{
|
||||
if ((errcode = crule_parseorexpr(&ruleroot, &next_tok, &ruleptr)) == CR_NOERR)
|
||||
{
|
||||
if (ruleroot != NULL)
|
||||
{
|
||||
if (next_tok == CR_END)
|
||||
{
|
||||
/* PASS */
|
||||
crule_free(&ruleroot);
|
||||
return 0;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
errcode = CR_UNEXPCTTOK;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
errcode = CR_EXPCTOR;
|
||||
}
|
||||
}
|
||||
@@ -1255,7 +1256,7 @@ const char *_crule_errstring(int errcode)
|
||||
if (errcode == 0)
|
||||
return "No error";
|
||||
else
|
||||
return crule_errstr[errcode-1];
|
||||
return crule_errstr[errcode - 1];
|
||||
}
|
||||
|
||||
/** Parse an or expression.
|
||||
@@ -1285,12 +1286,10 @@ static int crule_parseorexpr(CRuleNode **orrootp, crule_token *next_tokp, const
|
||||
{
|
||||
(*orrootp)->arg[1] = andexpr;
|
||||
orptr->arg[0] = *orrootp;
|
||||
}
|
||||
else
|
||||
} else
|
||||
orptr->arg[0] = andexpr;
|
||||
*orrootp = orptr;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
if (*orrootp != NULL)
|
||||
{
|
||||
@@ -1298,14 +1297,12 @@ static int crule_parseorexpr(CRuleNode **orrootp, crule_token *next_tokp, const
|
||||
{
|
||||
(*orrootp)->arg[1] = andexpr;
|
||||
return errcode;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
(*orrootp)->arg[1] = NULL; /* so free doesn't seg fault */
|
||||
(*orrootp)->arg[1] = NULL; /* so free doesn't seg fault */
|
||||
return CR_EXPCTAND;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
*orrootp = andexpr;
|
||||
return errcode;
|
||||
@@ -1343,12 +1340,10 @@ static int crule_parseandexpr(CRuleNode **androotp, crule_token *next_tokp, cons
|
||||
{
|
||||
(*androotp)->arg[1] = primary;
|
||||
andptr->arg[0] = *androotp;
|
||||
}
|
||||
else
|
||||
} else
|
||||
andptr->arg[0] = primary;
|
||||
*androotp = andptr;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
if (*androotp != NULL)
|
||||
{
|
||||
@@ -1356,14 +1351,12 @@ static int crule_parseandexpr(CRuleNode **androotp, crule_token *next_tokp, cons
|
||||
{
|
||||
(*androotp)->arg[1] = primary;
|
||||
return errcode;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
(*androotp)->arg[1] = NULL; /* so free doesn't seg fault */
|
||||
(*androotp)->arg[1] = NULL; /* so free doesn't seg fault */
|
||||
return CR_EXPCTPRIM;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
*androotp = primary;
|
||||
return errcode;
|
||||
@@ -1414,7 +1407,7 @@ static int crule_parseprimary(CRuleNode **primrootp, crule_token *next_tokp, con
|
||||
(*insertionp)->flags |= CRULE_FLAG_NOT;
|
||||
(*insertionp)->numargs = 1;
|
||||
(*insertionp)->arg[0] = NULL;
|
||||
insertionp = (CRuleNode **) & ((*insertionp)->arg[0]);
|
||||
insertionp = (CRuleNode **)&((*insertionp)->arg[0]);
|
||||
if ((errcode = crule_gettoken(next_tokp, ruleptr)) != CR_NOERR)
|
||||
break;
|
||||
continue;
|
||||
@@ -1466,9 +1459,9 @@ static int crule_parsefunction(CRuleNode **funcrootp, crule_token *next_tokp, co
|
||||
if ((errcode = crule_gettoken(next_tokp, ruleptr)) != CR_NOERR)
|
||||
return errcode;
|
||||
*funcrootp = safe_alloc(sizeof(CRuleNode));
|
||||
(*funcrootp)->funcptr = NULL; /* for freeing aborted trees */
|
||||
(*funcrootp)->funcptr = NULL; /* for freeing aborted trees */
|
||||
if ((errcode =
|
||||
crule_parsearglist(*funcrootp, next_tokp, ruleptr)) != CR_NOERR)
|
||||
crule_parsearglist(*funcrootp, next_tokp, ruleptr)) != CR_NOERR)
|
||||
return errcode;
|
||||
if (*next_tokp != CR_CLOSEPAREN)
|
||||
return CR_EXPCTCLOSE;
|
||||
@@ -1494,8 +1487,7 @@ static int crule_parsefunction(CRuleNode **funcrootp, crule_token *next_tokp, co
|
||||
}
|
||||
(*funcrootp)->funcptr = func->funcptr;
|
||||
return CR_NOERR;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return CR_EXPCTOPEN;
|
||||
}
|
||||
|
||||
@@ -1530,8 +1522,7 @@ static int crule_parsearglist(CRuleNode *argrootp, crule_token *next_tokp, const
|
||||
strcat(currarg, word);
|
||||
arglen += wordlen + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
strcpy(currarg, word);
|
||||
arglen = wordlen;
|
||||
@@ -1576,16 +1567,14 @@ void _crule_free(CRuleNode **elem)
|
||||
{
|
||||
/* type conversions and ()'s are fun! ;) here have an aspirin.. */
|
||||
if ((*(elem))->arg[0] != NULL)
|
||||
crule_free((CRuleNode**) &((*(elem))->arg[0]));
|
||||
}
|
||||
else if ((*(elem))->flags & CRULE_FLAG_AND_OR)
|
||||
crule_free((CRuleNode **)&((*(elem))->arg[0]));
|
||||
} else if ((*(elem))->flags & CRULE_FLAG_AND_OR)
|
||||
{
|
||||
if ((*(elem))->arg[0] != NULL)
|
||||
crule_free((CRuleNode**) &((*(elem))->arg[0]));
|
||||
crule_free((CRuleNode **)&((*(elem))->arg[0]));
|
||||
if ((*(elem))->arg[1] != NULL)
|
||||
crule_free((CRuleNode**) &((*(elem))->arg[1]));
|
||||
}
|
||||
else
|
||||
crule_free((CRuleNode **)&((*(elem))->arg[1]));
|
||||
} else
|
||||
{
|
||||
numargs = (*(elem))->numargs;
|
||||
for (arg = 0; arg < numargs; arg++)
|
||||
|
||||
+10
-12
@@ -22,16 +22,15 @@
|
||||
CMD_FUNC(cmd_cycle);
|
||||
|
||||
/* Place includes here */
|
||||
#define MSG_CYCLE "CYCLE"
|
||||
#define MSG_CYCLE "CYCLE"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"cycle", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"command /cycle", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"cycle", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"command /cycle", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* This is called on module init, before Server Ready */
|
||||
MOD_INIT()
|
||||
@@ -45,13 +44,12 @@ MOD_INIT()
|
||||
MOD_LOAD()
|
||||
{
|
||||
return MOD_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/* Called when module is unloaded */
|
||||
MOD_UNLOAD()
|
||||
{
|
||||
return MOD_SUCCESS;
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -64,7 +62,7 @@ CMD_FUNC(cmd_cycle)
|
||||
char channels[BUFSIZE];
|
||||
const char *parx[3];
|
||||
int n;
|
||||
|
||||
|
||||
if (parc < 2)
|
||||
return;
|
||||
|
||||
|
||||
+40
-44
@@ -24,16 +24,15 @@
|
||||
|
||||
CMD_FUNC(cmd_dccallow);
|
||||
|
||||
#define MSG_DCCALLOW "DCCALLOW"
|
||||
#define MSG_DCCALLOW "DCCALLOW"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"dccallow",
|
||||
"5.0",
|
||||
"command /dccallow",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"dccallow",
|
||||
"5.0",
|
||||
"command /dccallow",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
int dccallow_user_quit(Client *client, MessageTag *mtags, const char *comment);
|
||||
|
||||
@@ -68,11 +67,11 @@ void remove_dcc_references(Client *client)
|
||||
int found;
|
||||
|
||||
lp = client->user->dccallow;
|
||||
while(lp)
|
||||
while (lp)
|
||||
{
|
||||
nextlp = lp->next;
|
||||
acptr = lp->value.client;
|
||||
for(found = 0, lpp = &(acptr->user->dccallow); *lpp; lpp=&((*lpp)->next))
|
||||
for (found = 0, lpp = &(acptr->user->dccallow); *lpp; lpp = &((*lpp)->next))
|
||||
{
|
||||
if (lp->flags == (*lpp)->flags)
|
||||
continue; /* match only opposite types for sanity */
|
||||
@@ -81,8 +80,8 @@ void remove_dcc_references(Client *client)
|
||||
if ((*lpp)->flags == DCC_LINK_ME)
|
||||
{
|
||||
sendto_one(acptr, NULL, ":%s %d %s :%s has been removed from "
|
||||
"your DCC allow list for signing off",
|
||||
me.name, RPL_DCCINFO, acptr->name, client->name);
|
||||
"your DCC allow list for signing off",
|
||||
me.name, RPL_DCCINFO, acptr->name, client->name);
|
||||
}
|
||||
tmp = *lpp;
|
||||
*lpp = tmp->next;
|
||||
@@ -129,27 +128,27 @@ CMD_FUNC(cmd_dccallow)
|
||||
int ntargets = 0;
|
||||
int maxtargets = max_targets_for_command("WHOIS");
|
||||
static char *dcc_help[] = {
|
||||
"/DCCALLOW [<+|->nick[,<+|->nick, ...]] [list] [help]",
|
||||
"You may allow DCCs of files which are otherwise blocked by the IRC server",
|
||||
"by specifying a DCC allow for the user you want to recieve files from.",
|
||||
"For instance, to allow the user Bob to send you file.exe, you would type:",
|
||||
"/DCCALLOW +bob",
|
||||
"and Bob would then be able to send you files. Bob will have to resend the file",
|
||||
"if the server gave him an error message before you added him to your allow list.",
|
||||
"/DCCALLOW -bob",
|
||||
"Will do the exact opposite, removing him from your dcc allow list.",
|
||||
"/dccallow list",
|
||||
"Will list the users currently on your dcc allow list.",
|
||||
NULL,
|
||||
"/DCCALLOW [<+|->nick[,<+|->nick, ...]] [list] [help]",
|
||||
"You may allow DCCs of files which are otherwise blocked by the IRC server",
|
||||
"by specifying a DCC allow for the user you want to recieve files from.",
|
||||
"For instance, to allow the user Bob to send you file.exe, you would type:",
|
||||
"/DCCALLOW +bob",
|
||||
"and Bob would then be able to send you files. Bob will have to resend the file",
|
||||
"if the server gave him an error message before you added him to your allow list.",
|
||||
"/DCCALLOW -bob",
|
||||
"Will do the exact opposite, removing him from your dcc allow list.",
|
||||
"/dccallow list",
|
||||
"Will list the users currently on your dcc allow list.",
|
||||
NULL,
|
||||
};
|
||||
|
||||
if (!MyUser(client))
|
||||
return;
|
||||
|
||||
|
||||
if (parc < 2)
|
||||
{
|
||||
sendnotice(client, "No command specified for DCCALLOW. "
|
||||
"Type '/DCCALLOW HELP' for more information.");
|
||||
"Type '/DCCALLOW HELP' for more information.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -166,25 +165,24 @@ CMD_FUNC(cmd_dccallow)
|
||||
didanything = 1;
|
||||
if (!*++s)
|
||||
continue;
|
||||
|
||||
|
||||
friend = find_user(s, NULL);
|
||||
|
||||
|
||||
if (friend == client)
|
||||
continue;
|
||||
|
||||
|
||||
if (!friend)
|
||||
{
|
||||
sendnumeric(client, ERR_NOSUCHNICK, s);
|
||||
continue;
|
||||
}
|
||||
add_dccallow(client, friend);
|
||||
} else
|
||||
if (*s == '-')
|
||||
} else if (*s == '-')
|
||||
{
|
||||
didanything = 1;
|
||||
if (!*++s)
|
||||
continue;
|
||||
|
||||
|
||||
friend = find_user(s, NULL);
|
||||
if (friend == client)
|
||||
continue;
|
||||
@@ -194,25 +192,23 @@ CMD_FUNC(cmd_dccallow)
|
||||
continue;
|
||||
}
|
||||
del_dccallow(client, friend);
|
||||
} else
|
||||
if (!didlist && !strncasecmp(s, "list", 4))
|
||||
} else if (!didlist && !strncasecmp(s, "list", 4))
|
||||
{
|
||||
didanything = didlist = 1;
|
||||
sendnumeric(client, RPL_DCCINFO, "The following users are on your dcc allow list:");
|
||||
for(lp = client->user->dccallow; lp; lp = lp->next)
|
||||
for (lp = client->user->dccallow; lp; lp = lp->next)
|
||||
{
|
||||
if (lp->flags == DCC_LINK_REMOTE)
|
||||
continue;
|
||||
sendnumericfmt(client, RPL_DCCLIST, ":%s (%s@%s)", lp->value.client->name,
|
||||
lp->value.client->user->username,
|
||||
GetHost(lp->value.client));
|
||||
lp->value.client->user->username,
|
||||
GetHost(lp->value.client));
|
||||
}
|
||||
sendnumeric(client, RPL_ENDOFDCCLIST, s);
|
||||
} else
|
||||
if (!didhelp && !strncasecmp(s, "help", 4))
|
||||
} else if (!didhelp && !strncasecmp(s, "help", 4))
|
||||
{
|
||||
didanything = didhelp = 1;
|
||||
for(ptr = dcc_help; *ptr; ptr++)
|
||||
for (ptr = dcc_help; *ptr; ptr++)
|
||||
sendnumeric(client, RPL_DCCINFO, *ptr);
|
||||
sendnumeric(client, RPL_ENDOFDCCLIST, s);
|
||||
}
|
||||
@@ -246,7 +242,7 @@ int add_dccallow(Client *client, Client *optr)
|
||||
if (cnt >= MAXDCCALLOW)
|
||||
{
|
||||
sendnumeric(client, ERR_TOOMANYDCC,
|
||||
optr->name, MAXDCCALLOW);
|
||||
optr->name, MAXDCCALLOW);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -272,7 +268,7 @@ int del_dccallow(Client *client, Client *optr)
|
||||
Link **lpp, *lp;
|
||||
int found = 0;
|
||||
|
||||
for (lpp = &(client->user->dccallow); *lpp; lpp=&((*lpp)->next))
|
||||
for (lpp = &(client->user->dccallow); *lpp; lpp = &((*lpp)->next))
|
||||
{
|
||||
if ((*lpp)->flags != DCC_LINK_ME)
|
||||
continue;
|
||||
@@ -291,7 +287,7 @@ int del_dccallow(Client *client, Client *optr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (found = 0, lpp = &(optr->user->dccallow); *lpp; lpp=&((*lpp)->next))
|
||||
for (found = 0, lpp = &(optr->user->dccallow); *lpp; lpp = &((*lpp)->next))
|
||||
{
|
||||
if ((*lpp)->flags != DCC_LINK_REMOTE)
|
||||
continue;
|
||||
|
||||
+55
-62
@@ -22,18 +22,17 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"dccdeny",
|
||||
"6.0.2",
|
||||
"command /dccdeny",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"dccdeny",
|
||||
"6.0.2",
|
||||
"command /dccdeny",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Variables */
|
||||
ConfigItem_deny_dcc *conf_deny_dcc = NULL;
|
||||
ConfigItem_allow_dcc *conf_allow_dcc = NULL;
|
||||
ConfigItem_deny_dcc *conf_deny_dcc = NULL;
|
||||
ConfigItem_allow_dcc *conf_allow_dcc = NULL;
|
||||
|
||||
/* Forward declarions */
|
||||
int dccdeny_configtest_deny_dcc(ConfigFile *cf, ConfigEntry *ce, int type, int *errs);
|
||||
@@ -122,48 +121,45 @@ int dccdeny_configtest_deny_dcc(ConfigFile *cf, ConfigEntry *ce, int type, int *
|
||||
if (has_filename)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "deny dcc::filename");
|
||||
cep->line_number, "deny dcc::filename");
|
||||
continue;
|
||||
}
|
||||
has_filename = 1;
|
||||
}
|
||||
else if (!strcmp(cep->name, "reason"))
|
||||
} else if (!strcmp(cep->name, "reason"))
|
||||
{
|
||||
if (has_reason)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "deny dcc::reason");
|
||||
cep->line_number, "deny dcc::reason");
|
||||
continue;
|
||||
}
|
||||
has_reason = 1;
|
||||
}
|
||||
else if (!strcmp(cep->name, "soft"))
|
||||
} else if (!strcmp(cep->name, "soft"))
|
||||
{
|
||||
if (has_soft)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "deny dcc::soft");
|
||||
cep->line_number, "deny dcc::soft");
|
||||
continue;
|
||||
}
|
||||
has_soft = 1;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename,
|
||||
cep->line_number, "deny dcc", cep->name);
|
||||
cep->line_number, "deny dcc", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
if (!has_filename)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"deny dcc::filename");
|
||||
"deny dcc::filename");
|
||||
errors++;
|
||||
}
|
||||
if (!has_reason)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"deny dcc::reason");
|
||||
"deny dcc::reason");
|
||||
errors++;
|
||||
}
|
||||
|
||||
@@ -192,32 +188,30 @@ int dccdeny_configtest_allow_dcc(ConfigFile *cf, ConfigEntry *ce, int type, int
|
||||
if (has_filename)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "allow dcc::filename");
|
||||
cep->line_number, "allow dcc::filename");
|
||||
continue;
|
||||
}
|
||||
has_filename = 1;
|
||||
}
|
||||
else if (!strcmp(cep->name, "soft"))
|
||||
} else if (!strcmp(cep->name, "soft"))
|
||||
{
|
||||
if (has_soft)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "allow dcc::soft");
|
||||
cep->line_number, "allow dcc::soft");
|
||||
continue;
|
||||
}
|
||||
has_soft = 1;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename, cep->line_number,
|
||||
"allow dcc", cep->name);
|
||||
"allow dcc", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
if (!has_filename)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"allow dcc::filename");
|
||||
"allow dcc::filename");
|
||||
errors++;
|
||||
}
|
||||
|
||||
@@ -227,8 +221,8 @@ int dccdeny_configtest_allow_dcc(ConfigFile *cf, ConfigEntry *ce, int type, int
|
||||
|
||||
int dccdeny_configrun_deny_dcc(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
{
|
||||
ConfigItem_deny_dcc *deny = NULL;
|
||||
ConfigEntry *cep;
|
||||
ConfigItem_deny_dcc *deny = NULL;
|
||||
ConfigEntry *cep;
|
||||
|
||||
/* We are only interested in deny dcc { } */
|
||||
if ((type != CONFIG_DENY) || strcmp(ce->value, "dcc"))
|
||||
@@ -240,14 +234,12 @@ int dccdeny_configrun_deny_dcc(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (!strcmp(cep->name, "filename"))
|
||||
{
|
||||
safe_strdup(deny->filename, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "reason"))
|
||||
} else if (!strcmp(cep->name, "reason"))
|
||||
{
|
||||
safe_strdup(deny->reason, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "soft"))
|
||||
} else if (!strcmp(cep->name, "soft"))
|
||||
{
|
||||
int x = config_checkval(cep->value,CFG_YESNO);
|
||||
int x = config_checkval(cep->value, CFG_YESNO);
|
||||
if (x == 1)
|
||||
deny->flag.type = DCCDENY_SOFT;
|
||||
}
|
||||
@@ -280,7 +272,7 @@ int dccdeny_configrun_allow_dcc(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
safe_strdup(allow->filename, cep->value);
|
||||
else if (!strcmp(cep->name, "soft"))
|
||||
{
|
||||
int x = config_checkval(cep->value,CFG_YESNO);
|
||||
int x = config_checkval(cep->value, CFG_YESNO);
|
||||
if (x)
|
||||
allow->flag.type = DCCDENY_SOFT;
|
||||
}
|
||||
@@ -360,7 +352,7 @@ CMD_FUNC(cmd_dccdeny)
|
||||
if (!MyUser(client))
|
||||
return;
|
||||
|
||||
if (!ValidatePermissionsForPath("server-ban:dccdeny",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("server-ban:dccdeny", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
@@ -396,7 +388,7 @@ CMD_FUNC(cmd_undccdeny)
|
||||
if (!MyUser(client))
|
||||
return;
|
||||
|
||||
if (!ValidatePermissionsForPath("server-ban:dccdeny",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("server-ban:dccdeny", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
@@ -443,7 +435,7 @@ CMD_FUNC(cmd_svsfline)
|
||||
if (IsULine(client))
|
||||
{
|
||||
sendto_server(client, 0, 0, NULL, ":%s SVSFLINE + %s :%s",
|
||||
client->id, parv[2], parv[3]);
|
||||
client->id, parv[2], parv[3]);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -491,7 +483,7 @@ int dccdeny_server_sync(Client *client)
|
||||
{
|
||||
if (p->flag.type2 == CONF_BAN_TYPE_AKILL)
|
||||
sendto_one(client, NULL, ":%s SVSFLINE + %s :%s", me.id,
|
||||
p->filename, p->reason);
|
||||
p->filename, p->reason);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -565,14 +557,14 @@ static const char *dcc_displayfile(const char *f)
|
||||
}
|
||||
|
||||
/* Else, we show it as: [first 256 chars]+"[..TRUNCATED..]"+[last 20 chars] */
|
||||
for (i = f; i < f+256; i++)
|
||||
for (i = f; i < f + 256; i++)
|
||||
if (*i < 32)
|
||||
*o++ = '?';
|
||||
else
|
||||
*o++ = *i;
|
||||
strcpy(o, "[..TRUNCATED..]");
|
||||
o += sizeof("[..TRUNCATED..]");
|
||||
for (i = f+n-20; *i; i++)
|
||||
for (i = f + n - 20; *i; i++)
|
||||
if (*i < 32)
|
||||
*o++ = '?';
|
||||
else
|
||||
@@ -583,24 +575,25 @@ static const char *dcc_displayfile(const char *f)
|
||||
|
||||
static const char *get_dcc_filename(const char *text)
|
||||
{
|
||||
static char filename[BUFSIZE+1];
|
||||
static char filename[BUFSIZE + 1];
|
||||
char *end;
|
||||
int size_string;
|
||||
|
||||
if (*text != '\001')
|
||||
return 0;
|
||||
|
||||
if (!strncasecmp(text+1, "DCC SEND ", 9))
|
||||
if (!strncasecmp(text + 1, "DCC SEND ", 9))
|
||||
text = text + 10;
|
||||
else if (!strncasecmp(text+1, "DCC RESUME ", 11))
|
||||
else if (!strncasecmp(text + 1, "DCC RESUME ", 11))
|
||||
text = text + 12;
|
||||
else
|
||||
return 0;
|
||||
|
||||
for (; *text == ' '; text++); /* skip leading spaces */
|
||||
for (; *text == ' '; text++)
|
||||
; /* skip leading spaces */
|
||||
|
||||
if (*text == '"' && *(text+1))
|
||||
end = strchr(text+1, '"');
|
||||
if (*text == '"' && *(text + 1))
|
||||
end = strchr(text + 1, '"');
|
||||
else
|
||||
end = strchr(text, ' ');
|
||||
|
||||
@@ -612,7 +605,7 @@ static const char *get_dcc_filename(const char *text)
|
||||
if (!size_string || (size_string > (BUFSIZE - 1)))
|
||||
return 0;
|
||||
|
||||
strlcpy(filename, text, size_string+1);
|
||||
strlcpy(filename, text, size_string + 1);
|
||||
return filename;
|
||||
}
|
||||
|
||||
@@ -630,11 +623,11 @@ static int can_dcc(Client *client, const char *target, Client *targetcli, const
|
||||
int size_string, ret;
|
||||
|
||||
/* User (IRCOp) may bypass send restrictions */
|
||||
if (ValidatePermissionsForPath("immune:dcc",client,targetcli,NULL,NULL))
|
||||
if (ValidatePermissionsForPath("immune:dcc", client, targetcli, NULL, NULL))
|
||||
return 1;
|
||||
|
||||
/* User (IRCOp) likes to receive bad dcc's */
|
||||
if (targetcli && ValidatePermissionsForPath("self:getbaddcc",targetcli,NULL,NULL,NULL))
|
||||
if (targetcli && ValidatePermissionsForPath("self:getbaddcc", targetcli, NULL, NULL, NULL))
|
||||
return 1;
|
||||
|
||||
/* Check if user is already blocked (from the past) */
|
||||
@@ -692,11 +685,11 @@ static int can_dcc_soft(Client *from, Client *to, const char *filename, const ch
|
||||
static char errbuf[256];
|
||||
|
||||
/* User (IRCOp) may bypass send restrictions */
|
||||
if (ValidatePermissionsForPath("immune:dcc",from,to,NULL,NULL))
|
||||
if (ValidatePermissionsForPath("immune:dcc", from, to, NULL, NULL))
|
||||
return 1;
|
||||
|
||||
/* User (IRCOp) likes to receive bad dcc's */
|
||||
if (ValidatePermissionsForPath("self:getbaddcc",to,NULL,NULL,NULL))
|
||||
if (ValidatePermissionsForPath("self:getbaddcc", to, NULL, NULL, NULL))
|
||||
return 1;
|
||||
|
||||
/* On the 'soft' blocklist ? */
|
||||
@@ -715,14 +708,15 @@ static int can_dcc_soft(Client *from, Client *to, const char *filename, const ch
|
||||
|
||||
/* Inform target ('to') about the /DCCALLOW functionality */
|
||||
sendnotice(to, "%s (%s@%s) tried to DCC SEND you a file named '%s', the request has been blocked.",
|
||||
from->name, from->user->username, GetHost(from), displayfile);
|
||||
from->name, from->user->username, GetHost(from), displayfile);
|
||||
if (!IsDCCNotice(to))
|
||||
{
|
||||
SetDCCNotice(to);
|
||||
sendnotice(to, "Files like these might contain malicious content (viruses, trojans). "
|
||||
"Therefore, you must explicitly allow anyone that tries to send you such files.");
|
||||
"Therefore, you must explicitly allow anyone that tries to send you such files.");
|
||||
sendnotice(to, "If you trust %s, and want him/her to send you this file, you may obtain "
|
||||
"more information on using the dccallow system by typing '/DCCALLOW HELP'", from->name);
|
||||
"more information on using the dccallow system by typing '/DCCALLOW HELP'",
|
||||
from->name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -799,7 +793,7 @@ static void DCCdeny_del(ConfigItem_deny_dcc *deny)
|
||||
|
||||
ConfigItem_deny_dcc *find_deny_dcc(const char *name)
|
||||
{
|
||||
ConfigItem_deny_dcc *e;
|
||||
ConfigItem_deny_dcc *e;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
@@ -827,7 +821,6 @@ static void dcc_wipe_services(void)
|
||||
safe_free(dconf);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int dccdeny_stats(Client *client, const char *para)
|
||||
@@ -853,7 +846,7 @@ int dccdeny_stats(Client *client, const char *para)
|
||||
a = 'o';
|
||||
/* <d> <s|h> <howadded> <filemask> <reason> */
|
||||
sendtxtnumeric(client, "d %c %c %s %s", (denytmp->flag.type == DCCDENY_SOFT) ? 's' : 'h',
|
||||
a, filemask, reason);
|
||||
a, filemask, reason);
|
||||
}
|
||||
for (allowtmp = conf_allow_dcc; allowtmp; allowtmp = allowtmp->next)
|
||||
{
|
||||
@@ -866,7 +859,7 @@ int dccdeny_stats(Client *client, const char *para)
|
||||
a = 'o';
|
||||
/* <a> <s|h> <howadded> <filemask> */
|
||||
sendtxtnumeric(client, "a %c %c %s", (allowtmp->flag.type == DCCDENY_SOFT) ? 's' : 'h',
|
||||
a, filemask);
|
||||
a, filemask);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
+25
-24
@@ -22,14 +22,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"echo-message",
|
||||
"5.0",
|
||||
"echo-message CAP",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"echo-message",
|
||||
"5.0",
|
||||
"echo-message CAP",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Variables */
|
||||
long CAP_ECHO_MESSAGE = 0L;
|
||||
@@ -73,15 +72,16 @@ int em_chanmsg(Client *client, Channel *channel, int sendflags, const char *pref
|
||||
if (sendtype != SEND_TYPE_TAGMSG)
|
||||
{
|
||||
sendto_prefix_one(client, client, mtags, ":%s %s %s :%s",
|
||||
client->name,
|
||||
sendtype_to_cmd(sendtype),
|
||||
target,
|
||||
text);
|
||||
} else {
|
||||
client->name,
|
||||
sendtype_to_cmd(sendtype),
|
||||
target,
|
||||
text);
|
||||
} else
|
||||
{
|
||||
sendto_prefix_one(client, client, mtags, ":%s %s %s",
|
||||
client->name,
|
||||
sendtype_to_cmd(sendtype),
|
||||
target);
|
||||
client->name,
|
||||
sendtype_to_cmd(sendtype),
|
||||
target);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -96,15 +96,16 @@ int em_usermsg(Client *client, Client *to, MessageTag *mtags, const char *text,
|
||||
if (sendtype != SEND_TYPE_TAGMSG)
|
||||
{
|
||||
sendto_prefix_one(client, client, mtags, ":%s %s %s :%s",
|
||||
client->name,
|
||||
sendtype_to_cmd(sendtype),
|
||||
to->name,
|
||||
text);
|
||||
} else {
|
||||
client->name,
|
||||
sendtype_to_cmd(sendtype),
|
||||
to->name,
|
||||
text);
|
||||
} else
|
||||
{
|
||||
sendto_prefix_one(client, client, mtags, ":%s %s %s",
|
||||
client->name,
|
||||
sendtype_to_cmd(sendtype),
|
||||
to->name);
|
||||
client->name,
|
||||
sendtype_to_cmd(sendtype),
|
||||
to->name);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
+8
-9
@@ -24,16 +24,15 @@
|
||||
|
||||
CMD_FUNC(cmd_eos);
|
||||
|
||||
#define MSG_EOS "EOS"
|
||||
#define MSG_EOS "EOS"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"eos",
|
||||
"5.0",
|
||||
"command /eos",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"eos",
|
||||
"5.0",
|
||||
"command /eos",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/account",
|
||||
"4.2",
|
||||
"ExtBan ~a - Ban/exempt by services account name",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/account",
|
||||
"4.2",
|
||||
"ExtBan ~a - Ban/exempt by services account name",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -41,8 +40,8 @@ Extban *register_account_extban(ModuleInfo *modinfo)
|
||||
req.is_ok = NULL;
|
||||
req.conv_param = extban_account_conv_param;
|
||||
req.is_banned = extban_account_is_banned;
|
||||
req.is_banned_events = BANCHK_ALL|BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX|EXTBOPT_TKL;
|
||||
req.is_banned_events = BANCHK_ALL | BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX | EXTBOPT_TKL;
|
||||
return ExtbanAdd(modinfo->handle, req);
|
||||
}
|
||||
|
||||
|
||||
+10
-11
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/asn",
|
||||
"6.0",
|
||||
"ExtBan ~asn - Ban/exempt by ASN (geoip)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/asn",
|
||||
"6.0",
|
||||
"ExtBan ~asn - Ban/exempt by ASN (geoip)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -42,8 +41,8 @@ Extban *register_asn_extban(ModuleInfo *modinfo)
|
||||
req.is_ok = extban_asn_is_ok;
|
||||
req.conv_param = extban_asn_conv_param;
|
||||
req.is_banned = extban_asn_is_banned;
|
||||
req.is_banned_events = BANCHK_ALL|BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX|EXTBOPT_TKL;
|
||||
req.is_banned_events = BANCHK_ALL | BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX | EXTBOPT_TKL;
|
||||
return ExtbanAdd(modinfo->handle, req);
|
||||
}
|
||||
|
||||
@@ -90,7 +89,7 @@ int extban_asn_usage(Client *client)
|
||||
if (client)
|
||||
{
|
||||
sendnotice(client, "ERROR: ExtBan ~asn expects the AS number (all digits). "
|
||||
"For example: +b ~asn:64496");
|
||||
"For example: +b ~asn:64496");
|
||||
}
|
||||
return EX_DENY;
|
||||
}
|
||||
@@ -121,7 +120,7 @@ const char *extban_asn_conv_param(BanContext *b, Extban *extban)
|
||||
{
|
||||
static char retbuf[32];
|
||||
unsigned int asn;
|
||||
char *p=NULL;
|
||||
char *p = NULL;
|
||||
|
||||
if (!isdigit(b->banstr[0]))
|
||||
return NULL;
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/certfp",
|
||||
"4.2",
|
||||
"ExtBan ~certfp - Ban/exempt by SHA256 TLS certificate fingerprint",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/certfp",
|
||||
"4.2",
|
||||
"ExtBan ~certfp - Ban/exempt by SHA256 TLS certificate fingerprint",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -42,8 +41,8 @@ Extban *register_certfp_extban(ModuleInfo *modinfo)
|
||||
req.is_ok = extban_certfp_is_ok;
|
||||
req.conv_param = extban_certfp_conv_param;
|
||||
req.is_banned = extban_certfp_is_banned;
|
||||
req.is_banned_events = BANCHK_ALL|BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX|EXTBOPT_TKL;
|
||||
req.is_banned_events = BANCHK_ALL | BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX | EXTBOPT_TKL;
|
||||
return ExtbanAdd(modinfo->handle, req);
|
||||
}
|
||||
|
||||
@@ -92,7 +91,7 @@ int extban_certfp_usage(Client *client)
|
||||
if (client)
|
||||
{
|
||||
sendnotice(client, "ERROR: ExtBan ~certfp expects an SHA256 fingerprint in hexadecimal format (no colons). "
|
||||
"For example: +e ~certfp:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef)");
|
||||
"For example: +e ~certfp:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef)");
|
||||
}
|
||||
return EX_DENY;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/country",
|
||||
"6.0",
|
||||
"ExtBan ~country - Ban/exempt by country (geoip)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/country",
|
||||
"6.0",
|
||||
"ExtBan ~country - Ban/exempt by country (geoip)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -42,8 +41,8 @@ Extban *register_country_extban(ModuleInfo *modinfo)
|
||||
req.is_ok = extban_country_is_ok;
|
||||
req.conv_param = extban_country_conv_param;
|
||||
req.is_banned = extban_country_is_banned;
|
||||
req.is_banned_events = BANCHK_ALL|BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX|EXTBOPT_TKL;
|
||||
req.is_banned_events = BANCHK_ALL | BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX | EXTBOPT_TKL;
|
||||
return ExtbanAdd(modinfo->handle, req);
|
||||
}
|
||||
|
||||
@@ -90,7 +89,7 @@ int extban_country_usage(Client *client)
|
||||
if (client)
|
||||
{
|
||||
sendnotice(client, "ERROR: ExtBan ~country expects a two letter country code, or * to ban unknown countries. "
|
||||
"For example: +b ~country:UK");
|
||||
"For example: +b ~country:UK");
|
||||
}
|
||||
return EX_DENY;
|
||||
}
|
||||
|
||||
+10
-11
@@ -19,13 +19,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/flood",
|
||||
"1.0",
|
||||
"Extban ~flood - exempt from +f/+F checks",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/flood",
|
||||
"1.0",
|
||||
"Extban ~flood - exempt from +f/+F checks",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/** Maximum length of the ~flood ban exemption */
|
||||
@@ -90,9 +89,9 @@ static int flood_type_ok(char *str)
|
||||
|
||||
const char *flood_extban_conv_param(BanContext *b, Extban *extban)
|
||||
{
|
||||
static char retbuf[MAX_FLOODBAN_LENGTH+1];
|
||||
char para[MAX_FLOODBAN_LENGTH+1];
|
||||
char tmpmask[MAX_FLOODBAN_LENGTH+1];
|
||||
static char retbuf[MAX_FLOODBAN_LENGTH + 1];
|
||||
char para[MAX_FLOODBAN_LENGTH + 1];
|
||||
char tmpmask[MAX_FLOODBAN_LENGTH + 1];
|
||||
char *type; /**< Type(s), such as 'j' */
|
||||
char *matchby; /**< Matching method, such as 'n!u@h' */
|
||||
const char *newmask; /**< Cleaned matching method, such as 'n!u@h' */
|
||||
@@ -140,7 +139,7 @@ int flood_extban_syntax(Client *client, int checkt, char *reason)
|
||||
|
||||
int flood_extban_is_ok(BanContext *b)
|
||||
{
|
||||
static char para[MAX_FLOODBAN_LENGTH+1];
|
||||
static char para[MAX_FLOODBAN_LENGTH + 1];
|
||||
char *type; /**< Type(s), such as 'j' */
|
||||
char *matchby; /**< Matching method, such as 'n!u@h' */
|
||||
char *newmask; /**< Cleaned matching method, such as 'n!u@h' */
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/inchannel",
|
||||
"4.2",
|
||||
"ExtBan ~channel - banned when in specified channel",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/inchannel",
|
||||
"4.2",
|
||||
"ExtBan ~channel - banned when in specified channel",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -42,8 +41,8 @@ Extban *register_channel_extban(ModuleInfo *modinfo)
|
||||
req.is_ok = extban_inchannel_is_ok;
|
||||
req.conv_param = extban_inchannel_conv_param;
|
||||
req.is_banned = extban_inchannel_is_banned;
|
||||
req.is_banned_events = BANCHK_ALL|BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX|EXTBOPT_TKL;
|
||||
req.is_banned_events = BANCHK_ALL | BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX | EXTBOPT_TKL;
|
||||
return ExtbanAdd(modinfo->handle, req);
|
||||
}
|
||||
|
||||
@@ -83,15 +82,15 @@ MOD_UNLOAD()
|
||||
|
||||
const char *extban_inchannel_conv_param(BanContext *b, Extban *extban)
|
||||
{
|
||||
static char retbuf[CHANNELLEN+6];
|
||||
char *chan, *p, symbol='\0';
|
||||
static char retbuf[CHANNELLEN + 6];
|
||||
char *chan, *p, symbol = '\0';
|
||||
|
||||
strlcpy(retbuf, b->banstr, sizeof(retbuf));
|
||||
chan = retbuf;
|
||||
|
||||
if ((*chan == '+') || (*chan == '%') || (*chan == '%') ||
|
||||
(*chan == '@') || (*chan == '&') || (*chan == '~'))
|
||||
chan++;
|
||||
chan++;
|
||||
|
||||
if ((*chan != '#') && (*chan != '*') && (*chan != '?'))
|
||||
return NULL;
|
||||
@@ -116,7 +115,7 @@ int extban_inchannel_is_ok(BanContext *b)
|
||||
{
|
||||
if ((*p == '+') || (*p == '%') || (*p == '%') ||
|
||||
(*p == '@') || (*p == '&') || (*p == '~'))
|
||||
p++;
|
||||
p++;
|
||||
|
||||
if (*p != '#')
|
||||
{
|
||||
@@ -159,4 +158,3 @@ int extban_inchannel_is_banned(BanContext *b)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/inherit",
|
||||
"1.0",
|
||||
"ExtBan ~inherit - inherit bans from another channel",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/inherit",
|
||||
"1.0",
|
||||
"ExtBan ~inherit - inherit bans from another channel",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -56,7 +55,7 @@ Extban *register_channel_extban(ModuleInfo *modinfo)
|
||||
* We don't allow things like ~nick:~inherit, as we only work
|
||||
* on JOINs (option EXTBOPT_NOSTACKCHILD).
|
||||
*/
|
||||
req.options = EXTBOPT_INVEX|EXTBOPT_NOSTACKCHILD;
|
||||
req.options = EXTBOPT_INVEX | EXTBOPT_NOSTACKCHILD;
|
||||
return ExtbanAdd(modinfo->handle, req);
|
||||
}
|
||||
|
||||
@@ -120,11 +119,12 @@ static int inherit_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *e
|
||||
if (v < 0)
|
||||
{
|
||||
config_error("%s:%i: set::max-inherit-extended-bans::%s item has a value, which is unexpected. Check your syntax!",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename, cep->line_number,
|
||||
"set::max-inherit-extended-bans", cep->name);
|
||||
errors++;
|
||||
@@ -213,14 +213,13 @@ static int exceeds_inherit_ban_count(BanContext *b)
|
||||
/* Pretend time does not exist... */
|
||||
if (!strncmp(banstr, "~t:", 3))
|
||||
{
|
||||
banstr = strchr(banstr+3, ':');
|
||||
banstr = strchr(banstr + 3, ':');
|
||||
if (!banstr)
|
||||
continue;
|
||||
banstr++;
|
||||
}
|
||||
else if (!strncmp(banstr, "~time:", 6))
|
||||
} else if (!strncmp(banstr, "~time:", 6))
|
||||
{
|
||||
banstr = strchr(banstr+6, ':');
|
||||
banstr = strchr(banstr + 6, ':');
|
||||
if (!banstr)
|
||||
continue;
|
||||
banstr++;
|
||||
@@ -229,7 +228,7 @@ static int exceeds_inherit_ban_count(BanContext *b)
|
||||
/* Now check against ~inherit */
|
||||
if ((!strncasecmp(banstr, "~inherit:", 9) ||
|
||||
!strncmp(banstr, "~i:", 3)) &&
|
||||
++cnt >= limit)
|
||||
++cnt >= limit)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -240,7 +239,7 @@ static int exceeds_inherit_ban_count(BanContext *b)
|
||||
|
||||
const char *extban_inherit_conv_param(BanContext *b, Extban *extban)
|
||||
{
|
||||
static char retbuf[CHANNELLEN+1];
|
||||
static char retbuf[CHANNELLEN + 1];
|
||||
|
||||
strlcpy(retbuf, b->banstr, sizeof(retbuf));
|
||||
|
||||
@@ -258,7 +257,7 @@ const char *extban_inherit_conv_param(BanContext *b, Extban *extban)
|
||||
|
||||
int extban_inherit_is_ok(BanContext *b)
|
||||
{
|
||||
char retbuf[CHANNELLEN+1];
|
||||
char retbuf[CHANNELLEN + 1];
|
||||
|
||||
if (b->is_ok_check != EXBCHK_PARAM)
|
||||
return 1;
|
||||
@@ -286,10 +285,10 @@ int extban_inherit_is_ok(BanContext *b)
|
||||
if (exceeds_inherit_ban_count(b))
|
||||
{
|
||||
sendnotice(b->client, "Your ExtBan ~inherit:%s was not accepted because "
|
||||
"this channel already contains the maximum "
|
||||
"amount of ~inherit entries (%d).",
|
||||
b->banstr,
|
||||
maximum_ban_inherit_limit(b->ban_type));
|
||||
"this channel already contains the maximum "
|
||||
"amount of ~inherit entries (%d).",
|
||||
b->banstr,
|
||||
maximum_ban_inherit_limit(b->ban_type));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/join",
|
||||
"4.2",
|
||||
"Extban ~join - prevent join only",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/join",
|
||||
"4.2",
|
||||
"Extban ~join - prevent join only",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -34,7 +33,7 @@ int extban_modej_is_banned(BanContext *b);
|
||||
MOD_INIT()
|
||||
{
|
||||
ExtbanInfo req;
|
||||
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.letter = 'j';
|
||||
req.name = "join";
|
||||
@@ -50,7 +49,7 @@ MOD_INIT()
|
||||
}
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/msgbypass",
|
||||
"4.2",
|
||||
"ExtBan ~msgbypass - bypass +m/+n/+c/+S/+T (msgbypass)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/msgbypass",
|
||||
"4.2",
|
||||
"ExtBan ~msgbypass - bypass +m/+n/+c/+S/+T (msgbypass)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -36,7 +35,7 @@ const char *msgbypass_extban_conv_param(BanContext *b, Extban *extban);
|
||||
MOD_INIT()
|
||||
{
|
||||
ExtbanInfo req;
|
||||
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.letter = 'm';
|
||||
req.name = "msgbypass";
|
||||
@@ -50,7 +49,7 @@ MOD_INIT()
|
||||
}
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -78,7 +77,7 @@ int msgbypass_can_bypass(Client *client, Channel *channel, BypassChannelMessageR
|
||||
b->channel = channel;
|
||||
b->ban_check_types = BANCHK_MSG;
|
||||
b->ban_type = EXBTYPE_EXCEPT;
|
||||
for (ban = channel->exlist; ban; ban=ban->next)
|
||||
for (ban = channel->exlist; ban; ban = ban->next)
|
||||
{
|
||||
char *type;
|
||||
char *matchby;
|
||||
@@ -100,7 +99,7 @@ int msgbypass_can_bypass(Client *client, Channel *channel, BypassChannelMessageR
|
||||
if (!matchby)
|
||||
continue;
|
||||
matchby++;
|
||||
|
||||
|
||||
b->banstr = matchby;
|
||||
if (ban_check_mask(b))
|
||||
{
|
||||
@@ -131,15 +130,15 @@ int msgbypass_extban_type_ok(char *type)
|
||||
#define MAX_LENGTH 128
|
||||
const char *msgbypass_extban_conv_param(BanContext *b, Extban *extban)
|
||||
{
|
||||
static char retbuf[MAX_LENGTH+1];
|
||||
char para[MAX_LENGTH+1];
|
||||
char tmpmask[MAX_LENGTH+1];
|
||||
static char retbuf[MAX_LENGTH + 1];
|
||||
char para[MAX_LENGTH + 1];
|
||||
char tmpmask[MAX_LENGTH + 1];
|
||||
char *type; /**< Type, such as 'external' */
|
||||
char *matchby; /**< Matching method, such as 'n!u@h' */
|
||||
const char *newmask; /**< Cleaned matching method, such as 'n!u@h' */
|
||||
|
||||
strlcpy(para, b->banstr, sizeof(para)); /* work on a copy (and truncate it) */
|
||||
|
||||
|
||||
/* ~m:type:n!u@h for direct matching
|
||||
* ~m:type:~x:.... when calling another bantype
|
||||
*/
|
||||
@@ -178,7 +177,7 @@ int msgbypass_extban_syntax(Client *client, int checkt, char *reason)
|
||||
|
||||
int msgbypass_extban_is_ok(BanContext *b)
|
||||
{
|
||||
static char para[MAX_LENGTH+1];
|
||||
static char para[MAX_LENGTH + 1];
|
||||
char *type; /**< Type, such as 'external' */
|
||||
char *matchby; /**< Matching method, such as 'n!u@h' */
|
||||
char *newmask; /**< Cleaned matching method, such as 'n!u@h' */
|
||||
@@ -186,7 +185,7 @@ int msgbypass_extban_is_ok(BanContext *b)
|
||||
/* Always permit deletion */
|
||||
if (b->what == MODE_DEL)
|
||||
return 1;
|
||||
|
||||
|
||||
if (b->ban_type != EXBTYPE_EXCEPT)
|
||||
{
|
||||
if (b->is_ok_check == EXBCHK_PARAM)
|
||||
@@ -195,7 +194,7 @@ int msgbypass_extban_is_ok(BanContext *b)
|
||||
}
|
||||
|
||||
strlcpy(para, b->banstr, sizeof(para)); /* work on a copy (and truncate it) */
|
||||
|
||||
|
||||
/* ~m:type:n!u@h for direct matching
|
||||
* ~m:type:~x:.... when calling another bantype
|
||||
*/
|
||||
@@ -221,4 +220,3 @@ int msgbypass_extban_is_ok(BanContext *b)
|
||||
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/nickchange",
|
||||
"4.2",
|
||||
"ExtBan ~nickchange - prevent nick-changes only",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/nickchange",
|
||||
"4.2",
|
||||
"ExtBan ~nickchange - prevent nick-changes only",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -34,7 +33,7 @@ int extban_nickchange_is_banned(BanContext *b);
|
||||
MOD_INIT()
|
||||
{
|
||||
ExtbanInfo req;
|
||||
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.letter = 'n';
|
||||
req.name = "nickchange";
|
||||
@@ -50,7 +49,7 @@ MOD_INIT()
|
||||
}
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/operclass",
|
||||
"4.2",
|
||||
"ExtBan ~O - Ban/exempt operclass",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/operclass",
|
||||
"4.2",
|
||||
"ExtBan ~O - Ban/exempt operclass",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -35,15 +34,15 @@ int extban_operclass_is_banned(BanContext *b);
|
||||
MOD_INIT()
|
||||
{
|
||||
ExtbanInfo req;
|
||||
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.letter = 'O';
|
||||
req.name = "operclass";
|
||||
req.is_ok = NULL;
|
||||
req.conv_param = extban_operclass_conv_param;
|
||||
req.is_banned = extban_operclass_is_banned;
|
||||
req.is_banned_events = BANCHK_ALL|BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX|EXTBOPT_TKL;
|
||||
req.is_banned_events = BANCHK_ALL | BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX | EXTBOPT_TKL;
|
||||
if (!ExtbanAdd(modinfo->handle, req))
|
||||
{
|
||||
config_error("could not register extended ban type");
|
||||
@@ -51,7 +50,7 @@ MOD_INIT()
|
||||
}
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,12 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/partmsg",
|
||||
"4.2",
|
||||
"ExtBan ~partmsg - Ban/exempt Part/Quit message",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/partmsg",
|
||||
"4.2",
|
||||
"ExtBan ~partmsg - Ban/exempt Part/Quit message",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
int extban_partmsg_is_banned(BanContext *b);
|
||||
@@ -69,6 +68,6 @@ int extban_partmsg_is_banned(BanContext *b)
|
||||
{
|
||||
if (ban_check_mask(b))
|
||||
b->msg = NULL;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/quiet",
|
||||
"4.2",
|
||||
"ExtBan ~quiet - prevent messages only (quiet)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/quiet",
|
||||
"4.2",
|
||||
"ExtBan ~quiet - prevent messages only (quiet)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -34,7 +33,7 @@ int extban_quiet_is_banned(BanContext *b);
|
||||
MOD_INIT()
|
||||
{
|
||||
ExtbanInfo req;
|
||||
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.letter = 'q';
|
||||
req.name = "quiet";
|
||||
@@ -50,7 +49,7 @@ MOD_INIT()
|
||||
}
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/realname",
|
||||
"4.2",
|
||||
"ExtBan ~realname - Ban based on realname/gecos field",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/realname",
|
||||
"4.2",
|
||||
"ExtBan ~realname - Ban based on realname/gecos field",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -41,8 +40,8 @@ Extban *register_realname_extban(ModuleInfo *modinfo)
|
||||
req.is_ok = NULL;
|
||||
req.conv_param = extban_realname_conv_param;
|
||||
req.is_banned = extban_realname_is_banned;
|
||||
req.is_banned_events = BANCHK_ALL|BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX|EXTBOPT_TKL;
|
||||
req.is_banned_events = BANCHK_ALL | BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX | EXTBOPT_TKL;
|
||||
return ExtbanAdd(modinfo->handle, req);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/securitygroup",
|
||||
"4.2",
|
||||
"ExtBan ~G - Ban based on security-group",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/securitygroup",
|
||||
"4.2",
|
||||
"ExtBan ~G - Ban based on security-group",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -42,8 +41,8 @@ Extban *register_securitygroup_extban(ModuleInfo *modinfo)
|
||||
req.conv_param = extban_securitygroup_conv_param;
|
||||
req.is_ok = extban_securitygroup_is_ok;
|
||||
req.is_banned = extban_securitygroup_is_banned;
|
||||
req.is_banned_events = BANCHK_ALL|BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX|EXTBOPT_TKL;
|
||||
req.is_banned_events = BANCHK_ALL | BANCHK_TKL;
|
||||
req.options = EXTBOPT_INVEX | EXTBOPT_TKL;
|
||||
return ExtbanAdd(modinfo->handle, req);
|
||||
}
|
||||
|
||||
@@ -69,7 +68,7 @@ MOD_INIT()
|
||||
}
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -99,7 +98,8 @@ int extban_securitygroup_generic(char *mask, int strict)
|
||||
{
|
||||
if (!security_group_exists(mask))
|
||||
return 0; /* security group does not exist */
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (!security_group_valid_name(mask))
|
||||
return 0; /* invalid characters or too long */
|
||||
}
|
||||
@@ -114,7 +114,7 @@ int extban_securitygroup_is_ok(BanContext *b)
|
||||
{
|
||||
if (b->client && MyUser(b->client) && (b->what == MODE_ADD) && (b->is_ok_check == EXBCHK_PARAM))
|
||||
{
|
||||
char banbuf[SECURITYGROUPLEN+8];
|
||||
char banbuf[SECURITYGROUPLEN + 8];
|
||||
strlcpy(banbuf, b->banstr, sizeof(banbuf));
|
||||
if (!extban_securitygroup_generic(banbuf, 1))
|
||||
{
|
||||
@@ -148,6 +148,6 @@ const char *extban_securitygroup_conv_param(BanContext *b, Extban *extban)
|
||||
int extban_securitygroup_is_banned(BanContext *b)
|
||||
{
|
||||
if (*b->banstr == '!')
|
||||
return !user_allowed_by_security_group_name(b->client, b->banstr+1);
|
||||
return !user_allowed_by_security_group_name(b->client, b->banstr + 1);
|
||||
return user_allowed_by_security_group_name(b->client, b->banstr);
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@
|
||||
* textbans set.
|
||||
* UPDATE: The speed impact for 15 bans per channel is 42 usec PEAK.
|
||||
*/
|
||||
#define MAX_EXTBANT_PER_CHAN 15 /* Max number of ~T bans in a channel. */
|
||||
#define MAX_EXTBANT_PER_CHAN 15 /* Max number of ~T bans in a channel. */
|
||||
|
||||
/** Max length of a ban.
|
||||
* NOTE: This is mainly for 'cosmetic' purposes. Lowering it does not
|
||||
* decrease CPU usage for text processing.
|
||||
*/
|
||||
#define MAX_LENGTH 150 /* Max length of a ban */
|
||||
#define MAX_LENGTH 150 /* Max length of a ban */
|
||||
|
||||
/** Allow user@host in the textban? This changes the syntax! */
|
||||
#undef UHOSTFEATURE
|
||||
@@ -57,14 +57,13 @@
|
||||
/** Which censor replace word to use when CENSORFEATURE is enabled. */
|
||||
#define CENSORWORD "<censored>"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/textban",
|
||||
"2.2",
|
||||
"ExtBan ~textban",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/textban",
|
||||
"2.2",
|
||||
"ExtBan ~textban",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
const char *extban_modeT_conv_param(BanContext *b, Extban *extban);
|
||||
@@ -111,8 +110,8 @@ MOD_UNLOAD()
|
||||
static char *my_strcasestr(char *haystack, char *needle)
|
||||
{
|
||||
int i;
|
||||
int nlength = strlen (needle);
|
||||
int hlength = strlen (haystack);
|
||||
int nlength = strlen(needle);
|
||||
int hlength = strlen(haystack);
|
||||
|
||||
if (nlength > hlength)
|
||||
return NULL;
|
||||
@@ -122,14 +121,14 @@ static char *my_strcasestr(char *haystack, char *needle)
|
||||
return haystack;
|
||||
for (i = 0; i <= (hlength - nlength); i++)
|
||||
{
|
||||
if (strncasecmp (haystack + i, needle, nlength) == 0)
|
||||
if (strncasecmp(haystack + i, needle, nlength) == 0)
|
||||
return haystack + i;
|
||||
}
|
||||
return NULL; /* not found */
|
||||
}
|
||||
|
||||
#define TEXTBAN_WORD_LEFT 0x1
|
||||
#define TEXTBAN_WORD_RIGHT 0x2
|
||||
#define TEXTBAN_WORD_LEFT 0x1
|
||||
#define TEXTBAN_WORD_RIGHT 0x2
|
||||
|
||||
/* textban_replace:
|
||||
* a fast replace routine written by Syzop used for replacing.
|
||||
@@ -149,7 +148,7 @@ int textban_replace(int type, char *badword, char *line, char *buf)
|
||||
int cleaned = 0;
|
||||
|
||||
replacew = CENSORWORD;
|
||||
replacen = sizeof(CENSORWORD)-1;
|
||||
replacen = sizeof(CENSORWORD) - 1;
|
||||
|
||||
while (1)
|
||||
{
|
||||
@@ -159,12 +158,14 @@ int textban_replace(int type, char *badword, char *line, char *buf)
|
||||
if (searchn == -1)
|
||||
searchn = strlen(badword);
|
||||
/* Hunt for start of word */
|
||||
if (pold > line)
|
||||
{
|
||||
for (startw = pold; (!iswseperator(*startw) && (startw != line)); startw--);
|
||||
if (pold > line)
|
||||
{
|
||||
for (startw = pold; (!iswseperator(*startw) && (startw != line)); startw--)
|
||||
;
|
||||
if (iswseperator(*startw))
|
||||
startw++; /* Don't point at the space/seperator but at the word! */
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
startw = pold;
|
||||
}
|
||||
|
||||
@@ -179,9 +180,10 @@ int textban_replace(int type, char *badword, char *line, char *buf)
|
||||
* Fix for bug #4909: word will be at least 'searchn' long so we can skip
|
||||
* 'searchn' bytes and avoid stopping half-way the badword.
|
||||
*/
|
||||
for (endw = pold+searchn; ((*endw != '\0') && (!iswseperator(*endw))); endw++);
|
||||
for (endw = pold + searchn; ((*endw != '\0') && (!iswseperator(*endw))); endw++)
|
||||
;
|
||||
|
||||
if (!(type & TEXTBAN_WORD_RIGHT) && (pold+searchn != endw))
|
||||
if (!(type & TEXTBAN_WORD_RIGHT) && (pold + searchn != endw))
|
||||
{
|
||||
/* not matched */
|
||||
pold++;
|
||||
@@ -226,7 +228,8 @@ int textban_replace(int type, char *badword, char *line, char *buf)
|
||||
{
|
||||
strncpy(pnew, poldx, c_eol - pnew);
|
||||
*(c_eol) = '\0';
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
*pnew = '\0';
|
||||
}
|
||||
return cleaned;
|
||||
@@ -238,10 +241,10 @@ unsigned int counttextbans(Channel *channel)
|
||||
Ban *ban;
|
||||
unsigned int cnt = 0;
|
||||
|
||||
for (ban = channel->banlist; ban; ban=ban->next)
|
||||
for (ban = channel->banlist; ban; ban = ban->next)
|
||||
if ((ban->banstr[0] == '~') && (ban->banstr[1] == 'T') && (ban->banstr[2] == ':'))
|
||||
cnt++;
|
||||
for (ban = channel->exlist; ban; ban=ban->next)
|
||||
for (ban = channel->exlist; ban; ban = ban->next)
|
||||
if ((ban->banstr[0] == '~') && (ban->banstr[1] == 'T') && (ban->banstr[2] == ':'))
|
||||
cnt++;
|
||||
return cnt;
|
||||
@@ -257,7 +260,7 @@ int extban_modeT_is_ok(BanContext *b)
|
||||
|
||||
/* We check the # of bans in the channel, may not exceed MAX_EXTBANT_PER_CHAN */
|
||||
if ((b->what == MODE_ADD) && (b->is_ok_check == EXBCHK_PARAM) &&
|
||||
MyUser(b->client) && !IsOper(b->client) &&
|
||||
MyUser(b->client) && !IsOper(b->client) &&
|
||||
((n = counttextbans(b->channel)) >= MAX_EXTBANT_PER_CHAN))
|
||||
{
|
||||
/* We check the # of bans in the channel, may not exceed MAX_EXTBANT_PER_CHAN */
|
||||
@@ -274,20 +277,20 @@ char *conv_pattern_asterisks(const char *pattern)
|
||||
char missing_prefix = 0, missing_suffix = 0;
|
||||
if (*pattern != '*')
|
||||
missing_prefix = 1;
|
||||
if (*pattern && (pattern[strlen(pattern)-1] != '*'))
|
||||
if (*pattern && (pattern[strlen(pattern) - 1] != '*'))
|
||||
missing_suffix = 1;
|
||||
snprintf(buf, sizeof(buf), "%s%s%s",
|
||||
missing_prefix ? "*" : "",
|
||||
pattern,
|
||||
missing_suffix ? "*" : "");
|
||||
missing_prefix ? "*" : "",
|
||||
pattern,
|
||||
missing_suffix ? "*" : "");
|
||||
return buf;
|
||||
}
|
||||
|
||||
/** Ban callbacks */
|
||||
const char *extban_modeT_conv_param(BanContext *b, Extban *extban)
|
||||
{
|
||||
static char retbuf[MAX_LENGTH+1];
|
||||
char para[MAX_LENGTH+1], *action, *text, *p;
|
||||
static char retbuf[MAX_LENGTH + 1];
|
||||
char para[MAX_LENGTH + 1], *action, *text, *p;
|
||||
#ifdef UHOSTFEATURE
|
||||
char *uhost;
|
||||
int ap = 0;
|
||||
@@ -354,9 +357,9 @@ const char *extban_modeT_conv_param(BanContext *b, Extban *extban)
|
||||
return NULL; /* unknown action */
|
||||
|
||||
/* check the string.. */
|
||||
for (p=text; *p; p++)
|
||||
for (p = text; *p; p++)
|
||||
{
|
||||
if ((*p == '\003') || (*p == '\002') ||
|
||||
if ((*p == '\003') || (*p == '\002') ||
|
||||
(*p == '\037') || (*p == '\026') ||
|
||||
(*p == ' '))
|
||||
{
|
||||
@@ -387,21 +390,20 @@ int textban_can_send_to_channel(Client *client, Channel *channel, Membership *lp
|
||||
return HOOK_CONTINUE;
|
||||
|
||||
/* Now we have to manually walk the banlist and check if things match */
|
||||
for (ban = channel->banlist; ban; ban=ban->next)
|
||||
for (ban = channel->banlist; ban; ban = ban->next)
|
||||
{
|
||||
const char *banstr = ban->banstr;
|
||||
|
||||
/* Pretend time does not exist... */
|
||||
if (!strncmp(banstr, "~t:", 3))
|
||||
{
|
||||
banstr = strchr(banstr+3, ':');
|
||||
banstr = strchr(banstr + 3, ':');
|
||||
if (!banstr)
|
||||
continue;
|
||||
banstr++;
|
||||
}
|
||||
else if (!strncmp(banstr, "~time:", 6))
|
||||
} else if (!strncmp(banstr, "~time:", 6))
|
||||
{
|
||||
banstr = strchr(banstr+6, ':');
|
||||
banstr = strchr(banstr + 6, ':');
|
||||
if (!banstr)
|
||||
continue;
|
||||
banstr++;
|
||||
@@ -424,7 +426,7 @@ int textban_check_ban(Client *client, Channel *channel, const char *ban, const c
|
||||
static char retbuf[512];
|
||||
char filtered[512]; /* temp input buffer */
|
||||
long fl;
|
||||
int cleaned=0;
|
||||
int cleaned = 0;
|
||||
const char *p;
|
||||
#ifdef UHOSTFEATURE
|
||||
char buf[512], uhost[USERLEN + HOSTLEN + 16];
|
||||
@@ -462,7 +464,7 @@ int textban_check_ban(Client *client, Channel *channel, const char *ban, const c
|
||||
{
|
||||
if (!strncasecmp(p, "block:", 6))
|
||||
{
|
||||
if (match_simple(p+6, filtered))
|
||||
if (match_simple(p + 6, filtered))
|
||||
{
|
||||
if (errmsg)
|
||||
*errmsg = "Message blocked due to a text ban";
|
||||
@@ -472,7 +474,7 @@ int textban_check_ban(Client *client, Channel *channel, const char *ban, const c
|
||||
#ifdef CENSORFEATURE
|
||||
else if (!strncasecmp(p, "censor:", 7))
|
||||
{
|
||||
parse_word(p+7, &word, &type);
|
||||
parse_word(p + 7, &word, &type);
|
||||
if (textban_replace(type, word, filtered, tmp))
|
||||
{
|
||||
strlcpy(filtered, tmp, sizeof(filtered));
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
* then look at another extended ban * module as this module is not a
|
||||
* good starting point ;)
|
||||
*/
|
||||
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
/* Maximum time (in minutes) for a ban */
|
||||
#define TIMEDBAN_MAX_TIME 9999
|
||||
#define TIMEDBAN_MAX_TIME 9999
|
||||
|
||||
/* Maximum length of a ban */
|
||||
#define MAX_LENGTH 128
|
||||
@@ -36,23 +36,22 @@
|
||||
* NOTE: until all channels are processed it takes
|
||||
* TIMEDBAN_TIMER_ITERATION_SPLIT * TIMEDBAN_TIMER.
|
||||
*/
|
||||
#define TIMEDBAN_TIMER 2
|
||||
#define TIMEDBAN_TIMER 2
|
||||
|
||||
/* We allow a ban to (potentially) expire slightly before the deadline.
|
||||
* For example with TIMEDBAN_TIMER_ITERATION_SPLIT=4 and TIMEDBAN_TIMER=2
|
||||
* a 1 minute ban would expire at 56-63 seconds, rather than 60-67 seconds.
|
||||
* This is usually preferred.
|
||||
*/
|
||||
#define TIMEDBAN_TIMER_DELTA ((TIMEDBAN_TIMER_ITERATION_SPLIT*TIMEDBAN_TIMER)/2)
|
||||
#define TIMEDBAN_TIMER_DELTA ((TIMEDBAN_TIMER_ITERATION_SPLIT * TIMEDBAN_TIMER) / 2)
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extbans/timedban",
|
||||
"1.0",
|
||||
"ExtBan ~time: automatically removed timed bans",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extbans/timedban",
|
||||
"1.0",
|
||||
"ExtBan ~time: automatically removed timed bans",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
const char *timedban_extban_conv_param(BanContext *b, Extban *extban);
|
||||
@@ -89,8 +88,8 @@ MOD_INIT()
|
||||
config_error("timedban: unable to register 't' extban type!!");
|
||||
return MOD_FAILED;
|
||||
}
|
||||
|
||||
EventAdd(modinfo->handle, "timedban_timeout", timedban_timeout, NULL, TIMEDBAN_TIMER*1000, 0);
|
||||
|
||||
EventAdd(modinfo->handle, "timedban_timeout", timedban_timeout, NULL, TIMEDBAN_TIMER * 1000, 0);
|
||||
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -124,7 +123,8 @@ const char *generic_clean_ban_mask(BanContext *b, Extban *extban)
|
||||
*cp = '\0';
|
||||
|
||||
/* Strip any ':' at beginning since that would cause a desync */
|
||||
for (; (*mask && (*mask == ':')); mask++);
|
||||
for (; (*mask && (*mask == ':')); mask++)
|
||||
;
|
||||
if (!*mask)
|
||||
return NULL;
|
||||
|
||||
@@ -157,7 +157,7 @@ const char *generic_clean_ban_mask(BanContext *b, Extban *extban)
|
||||
}
|
||||
/* else, do some basic sanity checks and cut it off at 80 bytes */
|
||||
if ((mask[1] != ':') || (mask[2] == '\0'))
|
||||
return NULL; /* require a ":<char>" after extban type */
|
||||
return NULL; /* require a ":<char>" after extban type */
|
||||
if (strlen(mask) > 80)
|
||||
mask[80] = '\0';
|
||||
return mask;
|
||||
@@ -169,20 +169,20 @@ const char *generic_clean_ban_mask(BanContext *b, Extban *extban)
|
||||
/** Convert ban to an acceptable format (or return NULL to fully reject it) */
|
||||
const char *timedban_extban_conv_param(BanContext *b, Extban *extban)
|
||||
{
|
||||
static char retbuf[MAX_LENGTH+1];
|
||||
char para[MAX_LENGTH+1];
|
||||
char tmpmask[MAX_LENGTH+1];
|
||||
static char retbuf[MAX_LENGTH + 1];
|
||||
char para[MAX_LENGTH + 1];
|
||||
char tmpmask[MAX_LENGTH + 1];
|
||||
char *durationstr; /**< Duration, such as '5' */
|
||||
int duration;
|
||||
char *matchby; /**< Matching method, such as 'n!u@h' */
|
||||
const char *newmask; /**< Cleaned matching method, such as 'n!u@h' */
|
||||
static int timedban_extban_conv_param_recursion = 0;
|
||||
|
||||
|
||||
if (timedban_extban_conv_param_recursion)
|
||||
return NULL; /* reject: recursion detected! */
|
||||
|
||||
strlcpy(para, b->banstr, sizeof(para)); /* work on a copy (and truncate it) */
|
||||
|
||||
|
||||
/* ~time:duration:n!u@h for direct matching
|
||||
* ~time:duration:~x:.... when calling another bantype
|
||||
*/
|
||||
@@ -192,7 +192,7 @@ const char *timedban_extban_conv_param(BanContext *b, Extban *extban)
|
||||
if (!matchby || !matchby[1])
|
||||
return NULL;
|
||||
*matchby++ = '\0';
|
||||
|
||||
|
||||
duration = atoi(durationstr);
|
||||
|
||||
if ((duration <= 0) || (duration > TIMEDBAN_MAX_TIME))
|
||||
@@ -244,12 +244,11 @@ int generic_ban_is_ok(BanContext *b)
|
||||
if ((b->is_ok_check == EXBCHK_ACCESS) || (b->is_ok_check == EXBCHK_ACCESS_ERR))
|
||||
{
|
||||
if (!extban->is_ok(b) &&
|
||||
!ValidatePermissionsForPath("channel:override:mode:extban",b->client,NULL,b->channel,NULL))
|
||||
!ValidatePermissionsForPath("channel:override:mode:extban", b->client, NULL, b->channel, NULL))
|
||||
{
|
||||
return 0; /* REJECT */
|
||||
}
|
||||
} else
|
||||
if (b->is_ok_check == EXBCHK_PARAM)
|
||||
} else if (b->is_ok_check == EXBCHK_PARAM)
|
||||
{
|
||||
if (!extban->is_ok(b))
|
||||
{
|
||||
@@ -259,7 +258,7 @@ int generic_ban_is_ok(BanContext *b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ACCEPT:
|
||||
* - not an extban; OR
|
||||
* - extban with NULL is_ok; OR
|
||||
@@ -271,8 +270,8 @@ int generic_ban_is_ok(BanContext *b)
|
||||
/** Validate ban ("is this ban ok?") */
|
||||
int timedban_extban_is_ok(BanContext *b)
|
||||
{
|
||||
char para[MAX_LENGTH+1];
|
||||
char tmpmask[MAX_LENGTH+1];
|
||||
char para[MAX_LENGTH + 1];
|
||||
char tmpmask[MAX_LENGTH + 1];
|
||||
char *durationstr; /**< Duration, such as '5' */
|
||||
int duration;
|
||||
char *matchby; /**< Matching method, such as 'n!u@h' */
|
||||
@@ -288,7 +287,7 @@ int timedban_extban_is_ok(BanContext *b)
|
||||
return 0; /* Recursion detected (~time:1:~time:....) */
|
||||
|
||||
strlcpy(para, b->banstr, sizeof(para)); /* work on a copy (and truncate it) */
|
||||
|
||||
|
||||
/* ~time:duration:n!u@h for direct matching
|
||||
* ~time:duration:~x:.... when calling another bantype
|
||||
*/
|
||||
@@ -352,15 +351,15 @@ int timedban_has_ban_expired(Ban *ban)
|
||||
p1 = banstr + 6;
|
||||
else
|
||||
return 0; /* not for us */
|
||||
p2 = strchr(p1+1, ':'); /* skip time argument */
|
||||
p2 = strchr(p1 + 1, ':'); /* skip time argument */
|
||||
if (!p2)
|
||||
return 0; /* invalid fmt */
|
||||
*p2 = '\0'; /* danger.. must restore!! */
|
||||
t = atoi(p1);
|
||||
*p2 = ':'; /* restored.. */
|
||||
|
||||
|
||||
expire_on = ban->when + (t * 60) - TIMEDBAN_TIMER_DELTA;
|
||||
|
||||
|
||||
if (expire_on < TStime())
|
||||
return 1;
|
||||
return 0;
|
||||
@@ -391,30 +390,30 @@ EVENT(timedban_timeout)
|
||||
continue; /* not this time, maybe next */
|
||||
|
||||
*mbuf = *pbuf = '\0';
|
||||
for (ban = channel->banlist; ban; ban=nextban)
|
||||
for (ban = channel->banlist; ban; ban = nextban)
|
||||
{
|
||||
nextban = ban->next;
|
||||
if (!strncmp(ban->banstr, "~t", 2) && timedban_has_ban_expired(ban))
|
||||
{
|
||||
add_send_mode_param(channel, &me, '-', 'b', ban->banstr);
|
||||
add_send_mode_param(channel, &me, '-', 'b', ban->banstr);
|
||||
del_listmode(&channel->banlist, channel, ban->banstr);
|
||||
}
|
||||
}
|
||||
for (ban = channel->exlist; ban; ban=nextban)
|
||||
for (ban = channel->exlist; ban; ban = nextban)
|
||||
{
|
||||
nextban = ban->next;
|
||||
if (!strncmp(ban->banstr, "~t", 2) && timedban_has_ban_expired(ban))
|
||||
{
|
||||
add_send_mode_param(channel, &me, '-', 'e', ban->banstr);
|
||||
add_send_mode_param(channel, &me, '-', 'e', ban->banstr);
|
||||
del_listmode(&channel->exlist, channel, ban->banstr);
|
||||
}
|
||||
}
|
||||
for (ban = channel->invexlist; ban; ban=nextban)
|
||||
for (ban = channel->invexlist; ban; ban = nextban)
|
||||
{
|
||||
nextban = ban->next;
|
||||
if (!strncmp(ban->banstr, "~t", 2) && timedban_has_ban_expired(ban))
|
||||
{
|
||||
add_send_mode_param(channel, &me, '-', 'I', ban->banstr);
|
||||
add_send_mode_param(channel, &me, '-', 'I', ban->banstr);
|
||||
del_listmode(&channel->invexlist, channel, ban->banstr);
|
||||
}
|
||||
}
|
||||
@@ -434,14 +433,17 @@ EVENT(timedban_timeout)
|
||||
#error "add_send_mode_param() is not made for MODEBUFLEN > 512"
|
||||
#endif
|
||||
|
||||
void add_send_mode_param(Channel *channel, Client *from, char what, char mode, char *param) {
|
||||
void add_send_mode_param(Channel *channel, Client *from, char what, char mode, char *param)
|
||||
{
|
||||
static char *modes = NULL, lastwhat;
|
||||
static short count = 0;
|
||||
short send = 0;
|
||||
|
||||
if (!modes) modes = mbuf;
|
||||
|
||||
if (!mbuf[0]) {
|
||||
|
||||
if (!modes)
|
||||
modes = mbuf;
|
||||
|
||||
if (!mbuf[0])
|
||||
{
|
||||
modes = mbuf;
|
||||
*modes++ = what;
|
||||
*modes = 0;
|
||||
@@ -449,20 +451,21 @@ void add_send_mode_param(Channel *channel, Client *from, char what, char mode, c
|
||||
*pbuf = 0;
|
||||
count = 0;
|
||||
}
|
||||
if (lastwhat != what) {
|
||||
if (lastwhat != what)
|
||||
{
|
||||
*modes++ = what;
|
||||
*modes = 0;
|
||||
lastwhat = what;
|
||||
}
|
||||
if (strlen(pbuf) + strlen(param) + 11 < MODEBUFLEN) {
|
||||
if (*pbuf)
|
||||
if (strlen(pbuf) + strlen(param) + 11 < MODEBUFLEN)
|
||||
{
|
||||
if (*pbuf)
|
||||
strcat(pbuf, " ");
|
||||
strcat(pbuf, param);
|
||||
*modes++ = mode;
|
||||
*modes = 0;
|
||||
count++;
|
||||
}
|
||||
else if (*pbuf)
|
||||
} else if (*pbuf)
|
||||
send = 1;
|
||||
|
||||
if (count == MAXMODEPARAMS)
|
||||
@@ -486,7 +489,8 @@ void add_send_mode_param(Channel *channel, Client *from, char what, char mode, c
|
||||
strlcpy(pbuf, param, sizeof(pbuf));
|
||||
*modes++ = mode;
|
||||
count = 1;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
*modes = 0;
|
||||
|
||||
@@ -29,13 +29,12 @@ CMD_FUNC(cmd_isupport);
|
||||
/* Variables */
|
||||
long CAP_EXTISUPPORT = 0L;
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
={
|
||||
"extended-isupport", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"Implements IRCv3 draft/extended-isupport", /* Short description of module */
|
||||
"UnrealIRCd Team", /* Author */
|
||||
"unrealircd-6", /* Version of UnrealIRCd */
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extended-isupport", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"Implements IRCv3 draft/extended-isupport", /* Short description of module */
|
||||
"UnrealIRCd Team", /* Author */
|
||||
"unrealircd-6", /* Version of UnrealIRCd */
|
||||
};
|
||||
|
||||
// Module initialization
|
||||
@@ -48,7 +47,7 @@ MOD_INIT()
|
||||
cap.name = "draft/extended-isupport";
|
||||
ClientCapabilityAdd(modinfo->handle, &cap, &CAP_EXTISUPPORT);
|
||||
|
||||
CommandAdd(modinfo->handle, "ISUPPORT", cmd_isupport, 0, CMD_USER|CMD_UNREGISTERED);
|
||||
CommandAdd(modinfo->handle, "ISUPPORT", cmd_isupport, 0, CMD_USER | CMD_UNREGISTERED);
|
||||
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -38,20 +38,19 @@ int extended_monitor_userhost_change(Client *client, const char *olduser, const
|
||||
int extended_monitor_realname_change(Client *client, const char *oldinfo);
|
||||
int extended_monitor_notification(Client *client, Watch *watch, Link *lp, int event, void *data);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"extended-monitor",
|
||||
"5.0",
|
||||
"extended functionality for /monitor",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extended-monitor",
|
||||
"5.0",
|
||||
"extended functionality for /monitor",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
ClientCapabilityInfo cap;
|
||||
ClientCapability *c;
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
ModDataInfo mreq;
|
||||
@@ -159,7 +158,6 @@ int extended_monitor_notification(Client *client, Watch *watch, Link *lp, int ev
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+79
-61
@@ -24,29 +24,29 @@
|
||||
|
||||
/* internal definitions */
|
||||
|
||||
#define MSG_EXTJWT "EXTJWT"
|
||||
#define MYCONF "extjwt"
|
||||
#define MSG_EXTJWT "EXTJWT"
|
||||
#define MYCONF "extjwt"
|
||||
|
||||
#undef NEW_ISUPPORT /* enable this for https://github.com/ircv3/ircv3-specifications/pull/341#issuecomment-617038799 */
|
||||
|
||||
#define EXTJWT_METHOD_NOT_SET 0
|
||||
#define EXTJWT_METHOD_HS256 1
|
||||
#define EXTJWT_METHOD_HS384 2
|
||||
#define EXTJWT_METHOD_HS512 3
|
||||
#define EXTJWT_METHOD_RS256 4
|
||||
#define EXTJWT_METHOD_RS384 5
|
||||
#define EXTJWT_METHOD_RS512 6
|
||||
#define EXTJWT_METHOD_ES256 7
|
||||
#define EXTJWT_METHOD_ES384 8
|
||||
#define EXTJWT_METHOD_ES512 9
|
||||
#define EXTJWT_METHOD_NONE 10
|
||||
#define EXTJWT_METHOD_HS256 1
|
||||
#define EXTJWT_METHOD_HS384 2
|
||||
#define EXTJWT_METHOD_HS512 3
|
||||
#define EXTJWT_METHOD_RS256 4
|
||||
#define EXTJWT_METHOD_RS384 5
|
||||
#define EXTJWT_METHOD_RS512 6
|
||||
#define EXTJWT_METHOD_ES256 7
|
||||
#define EXTJWT_METHOD_ES384 8
|
||||
#define EXTJWT_METHOD_ES512 9
|
||||
#define EXTJWT_METHOD_NONE 10
|
||||
|
||||
#define NEEDS_KEY(x) (x>=EXTJWT_METHOD_RS256 && x<=EXTJWT_METHOD_ES512)
|
||||
#define NEEDS_KEY(x) (x >= EXTJWT_METHOD_RS256 && x <= EXTJWT_METHOD_ES512)
|
||||
|
||||
#define URL_LENGTH 4096
|
||||
#define MODES_SIZE 41 /* about 10 mode chars */
|
||||
#define TS_LENGTH 19 /* 64-bit integer */
|
||||
#define MAX_TOKEN_CHUNK (510-sizeof(extjwt_message_pattern)-HOSTLEN-CHANNELLEN)
|
||||
#define URL_LENGTH 4096
|
||||
#define MODES_SIZE 41 /* about 10 mode chars */
|
||||
#define TS_LENGTH 19 /* 64-bit integer */
|
||||
#define MAX_TOKEN_CHUNK (510 - sizeof(extjwt_message_pattern) - HOSTLEN - CHANNELLEN)
|
||||
|
||||
/* OpenSSL 1.0.x compatibility */
|
||||
|
||||
@@ -58,8 +58,8 @@ void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps)
|
||||
if (ps != NULL)
|
||||
*ps = sig->s;
|
||||
}
|
||||
#define EVP_MD_CTX_new EVP_MD_CTX_create
|
||||
#define EVP_MD_CTX_free EVP_MD_CTX_destroy
|
||||
#define EVP_MD_CTX_new EVP_MD_CTX_create
|
||||
#define EVP_MD_CTX_free EVP_MD_CTX_destroy
|
||||
#endif
|
||||
|
||||
/* struct definitions */
|
||||
@@ -83,9 +83,9 @@ CMD_FUNC(cmd_extjwt);
|
||||
char *extjwt_make_payload(Client *client, Channel *channel, struct extjwt_config *config);
|
||||
char *extjwt_generate_token(const char *payload, struct extjwt_config *config);
|
||||
void b64url(char *b64);
|
||||
unsigned char *extjwt_hmac_extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int* resultlen);
|
||||
unsigned char *extjwt_sha_pem_extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int* resultlen);
|
||||
unsigned char *extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int* resultlen);
|
||||
unsigned char *extjwt_hmac_extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int *resultlen);
|
||||
unsigned char *extjwt_sha_pem_extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int *resultlen);
|
||||
unsigned char *extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int *resultlen);
|
||||
char *extjwt_gen_header(int method);
|
||||
int extjwt_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *errs);
|
||||
int extjwt_configrun(ConfigFile *cf, ConfigEntry *ce, int type);
|
||||
@@ -107,11 +107,11 @@ const char extjwt_message_pattern[] = ":%s EXTJWT %s %s %s%s";
|
||||
/* global structs */
|
||||
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"extjwt",
|
||||
"6.1",
|
||||
"Command /EXTJWT (web service authorization)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
"extjwt",
|
||||
"6.1",
|
||||
"Command /EXTJWT (web service authorization)",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
struct {
|
||||
@@ -174,7 +174,7 @@ char *extjwt_isupport_param(void)
|
||||
strlcpy(buf, "V:1", sizeof(buf));
|
||||
while (services)
|
||||
{
|
||||
strlcat(buf, count?",":"&S:", sizeof(buf));
|
||||
strlcat(buf, count ? "," : "&S:", sizeof(buf));
|
||||
strlcat(buf, services->name, sizeof(buf));
|
||||
count++;
|
||||
services = services->next;
|
||||
@@ -183,7 +183,8 @@ char *extjwt_isupport_param(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
void extjwt_free_services(struct jwt_service **services){
|
||||
void extjwt_free_services(struct jwt_service **services)
|
||||
{
|
||||
struct jwt_service *ss, *next;
|
||||
ss = *services;
|
||||
while (ss)
|
||||
@@ -217,7 +218,8 @@ int extjwt_valid_integer_string(const char *in, int min, int max)
|
||||
int i, val;
|
||||
if (BadPtr(in))
|
||||
return 0;
|
||||
for (i=0; in[i]; i++){
|
||||
for (i = 0; in[i]; i++)
|
||||
{
|
||||
if (!isdigit(in[i]))
|
||||
return 0;
|
||||
}
|
||||
@@ -245,13 +247,18 @@ char *extjwt_test_key(const char *file, int method)
|
||||
BIO *bufkey = NULL;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
int type, pkey_type;
|
||||
do {
|
||||
do
|
||||
{
|
||||
switch (method)
|
||||
{
|
||||
case EXTJWT_METHOD_RS256: case EXTJWT_METHOD_RS384: case EXTJWT_METHOD_RS512:
|
||||
case EXTJWT_METHOD_RS256:
|
||||
case EXTJWT_METHOD_RS384:
|
||||
case EXTJWT_METHOD_RS512:
|
||||
type = EVP_PKEY_RSA;
|
||||
break;
|
||||
case EXTJWT_METHOD_ES256: case EXTJWT_METHOD_ES384: case EXTJWT_METHOD_ES512:
|
||||
case EXTJWT_METHOD_ES256:
|
||||
case EXTJWT_METHOD_ES384:
|
||||
case EXTJWT_METHOD_ES512:
|
||||
type = EVP_PKEY_EC;
|
||||
break;
|
||||
default:
|
||||
@@ -569,7 +576,8 @@ int extjwt_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
if (!have_scert && NEEDS_KEY(have_smethod)) {
|
||||
if (!have_scert && NEEDS_KEY(have_smethod))
|
||||
{
|
||||
config_error("%s:%i: invalid %s::service entry (must contain %s::service::key option)", cep->file->filename, cep->line_number, MYCONF, MYCONF);
|
||||
errors++;
|
||||
continue;
|
||||
@@ -629,7 +637,7 @@ int extjwt_configposttest(int *errs)
|
||||
if (NEEDS_KEY(cfg_state.have_method) && cfg_state.have_key && cfg_state.key_filename)
|
||||
{
|
||||
char *keyerr;
|
||||
|
||||
|
||||
keyerr = extjwt_test_key(cfg_state.key_filename, cfg_state.have_method);
|
||||
if (keyerr)
|
||||
{
|
||||
@@ -769,7 +777,7 @@ CMD_FUNC(cmd_extjwt)
|
||||
struct jwt_service *service = NULL;
|
||||
struct extjwt_config *config;
|
||||
int last = 0;
|
||||
char message[MAX_TOKEN_CHUNK+1];
|
||||
char message[MAX_TOKEN_CHUNK + 1];
|
||||
if (parc < 2 || BadPtr(parv[1]))
|
||||
{
|
||||
sendnumeric(client, ERR_NEEDMOREPARAMS, MSG_EXTJWT);
|
||||
@@ -796,9 +804,11 @@ CMD_FUNC(cmd_extjwt)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (service){
|
||||
if (service)
|
||||
{
|
||||
config = service->cfg; /* service config */
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
config = &cfg; /* default config */
|
||||
}
|
||||
if (!(payload = extjwt_make_payload(client, channel, config)) || !(full_token = extjwt_generate_token(payload, config)))
|
||||
@@ -816,10 +826,10 @@ CMD_FUNC(cmd_extjwt)
|
||||
strcpy(message, token);
|
||||
} else
|
||||
{ /* send a chunk and shift buffer */
|
||||
strlcpy(message, token, MAX_TOKEN_CHUNK+1);
|
||||
strlcpy(message, token, MAX_TOKEN_CHUNK + 1);
|
||||
token += MAX_TOKEN_CHUNK;
|
||||
}
|
||||
sendto_one(client, NULL, extjwt_message_pattern, me.name, parv[1], "*", last?"":"* ", message);
|
||||
sendto_one(client, NULL, extjwt_message_pattern, me.name, parv[1], "*", last ? "" : "* ", message);
|
||||
} while (!last);
|
||||
safe_free(full_token);
|
||||
}
|
||||
@@ -831,7 +841,7 @@ char *extjwt_make_payload(Client *client, Channel *channel, struct extjwt_config
|
||||
json_t *modes = NULL;
|
||||
json_t *umodes = NULL;
|
||||
char *modestring;
|
||||
char singlemode[2] = { '\0' };
|
||||
char singlemode[2] = {'\0'};
|
||||
char *result;
|
||||
|
||||
if (!IsUser(client))
|
||||
@@ -839,12 +849,12 @@ char *extjwt_make_payload(Client *client, Channel *channel, struct extjwt_config
|
||||
|
||||
payload = json_object();
|
||||
umodes = json_array();
|
||||
|
||||
json_object_set_new(payload, "exp", json_integer(TStime()+config->exp_delay));
|
||||
|
||||
json_object_set_new(payload, "exp", json_integer(TStime() + config->exp_delay));
|
||||
json_object_set_new(payload, "iss", json_string_unreal(me.name));
|
||||
json_object_set_new(payload, "sub", json_string_unreal(client->name));
|
||||
json_object_set_new(payload, "account", json_string_unreal(IsLoggedIn(client)?client->user->account:""));
|
||||
|
||||
json_object_set_new(payload, "account", json_string_unreal(IsLoggedIn(client) ? client->user->account : ""));
|
||||
|
||||
if (config->vfy) /* also add the URL */
|
||||
json_object_set_new(payload, "vfy", json_string_unreal(config->vfy));
|
||||
|
||||
@@ -867,7 +877,7 @@ char *extjwt_make_payload(Client *client, Channel *channel, struct extjwt_config
|
||||
}
|
||||
}
|
||||
json_object_set_new(payload, "channel", json_string_unreal(channel->name));
|
||||
json_object_set_new(payload, "joined", json_integer(lp?1:0));
|
||||
json_object_set_new(payload, "joined", json_integer(lp ? 1 : 0));
|
||||
json_object_set_new(payload, "cmodes", modes);
|
||||
}
|
||||
result = json_dumps(payload, JSON_COMPACT);
|
||||
@@ -892,19 +902,26 @@ void b64url(char *b64)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char *extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int* resultlen)
|
||||
unsigned char *extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int *resultlen)
|
||||
{
|
||||
switch(method)
|
||||
switch (method)
|
||||
{
|
||||
case EXTJWT_METHOD_HS256: case EXTJWT_METHOD_HS384: case EXTJWT_METHOD_HS512:
|
||||
case EXTJWT_METHOD_HS256:
|
||||
case EXTJWT_METHOD_HS384:
|
||||
case EXTJWT_METHOD_HS512:
|
||||
return extjwt_hmac_extjwt_hash(method, key, keylen, data, datalen, resultlen);
|
||||
case EXTJWT_METHOD_RS256: case EXTJWT_METHOD_RS384: case EXTJWT_METHOD_RS512: case EXTJWT_METHOD_ES256: case EXTJWT_METHOD_ES384: case EXTJWT_METHOD_ES512:
|
||||
case EXTJWT_METHOD_RS256:
|
||||
case EXTJWT_METHOD_RS384:
|
||||
case EXTJWT_METHOD_RS512:
|
||||
case EXTJWT_METHOD_ES256:
|
||||
case EXTJWT_METHOD_ES384:
|
||||
case EXTJWT_METHOD_ES512:
|
||||
return extjwt_sha_pem_extjwt_hash(method, key, keylen, data, datalen, resultlen);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned char* extjwt_sha_pem_extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int* resultlen)
|
||||
unsigned char *extjwt_sha_pem_extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int *resultlen)
|
||||
{
|
||||
EVP_MD_CTX *mdctx = NULL;
|
||||
ECDSA_SIG *ec_sig = NULL;
|
||||
@@ -1005,13 +1022,13 @@ unsigned char* extjwt_sha_pem_extjwt_hash(int method, const void *key, int keyle
|
||||
ECDSA_SIG_get0(ec_sig, &ec_sig_r, &ec_sig_s);
|
||||
r_len = BN_num_bytes(ec_sig_r);
|
||||
s_len = BN_num_bytes(ec_sig_s);
|
||||
bn_len = (degree+7)/8;
|
||||
bn_len = (degree + 7) / 8;
|
||||
if (r_len > bn_len || s_len > bn_len)
|
||||
break;
|
||||
buf_len = bn_len*2;
|
||||
buf_len = bn_len * 2;
|
||||
raw_buf = safe_alloc(buf_len);
|
||||
BN_bn2bin(ec_sig_r, raw_buf+bn_len-r_len);
|
||||
BN_bn2bin(ec_sig_s, raw_buf+buf_len-s_len);
|
||||
BN_bn2bin(ec_sig_r, raw_buf + bn_len - r_len);
|
||||
BN_bn2bin(ec_sig_s, raw_buf + buf_len - s_len);
|
||||
output = safe_alloc(buf_len);
|
||||
*resultlen = buf_len;
|
||||
memcpy(output, raw_buf, buf_len);
|
||||
@@ -1032,9 +1049,9 @@ unsigned char* extjwt_sha_pem_extjwt_hash(int method, const void *key, int keyle
|
||||
return retval;
|
||||
}
|
||||
|
||||
unsigned char* extjwt_hmac_extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int* resultlen)
|
||||
unsigned char *extjwt_hmac_extjwt_hash(int method, const void *key, int keylen, const unsigned char *data, int datalen, unsigned int *resultlen)
|
||||
{
|
||||
const EVP_MD* typ;
|
||||
const EVP_MD *typ;
|
||||
char *hmac = safe_alloc(EVP_MAX_MD_SIZE);
|
||||
switch (method)
|
||||
{
|
||||
@@ -1052,7 +1069,8 @@ unsigned char* extjwt_hmac_extjwt_hash(int method, const void *key, int keylen,
|
||||
if (HMAC(typ, key, keylen, data, datalen, hmac, resultlen))
|
||||
{ /* openssl call */
|
||||
return hmac;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
safe_free(hmac);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1110,9 +1128,9 @@ char *extjwt_gen_header(int method)
|
||||
char *extjwt_generate_token(const char *payload, struct extjwt_config *config)
|
||||
{
|
||||
char *header = extjwt_gen_header(config->method);
|
||||
size_t b64header_size = strlen(header)*4/3 + 8; // base64 has 4/3 overhead
|
||||
size_t b64payload_size = strlen(payload)*4/3 + 8;
|
||||
size_t b64sig_size = 4096*4/3 + 8;
|
||||
size_t b64header_size = strlen(header) * 4 / 3 + 8; // base64 has 4/3 overhead
|
||||
size_t b64payload_size = strlen(payload) * 4 / 3 + 8;
|
||||
size_t b64sig_size = 4096 * 4 / 3 + 8;
|
||||
size_t b64data_size = b64header_size + b64payload_size + b64sig_size + 4;
|
||||
char *b64header = safe_alloc(b64header_size);
|
||||
char *b64payload = safe_alloc(b64payload_size);
|
||||
|
||||
+10
-10
@@ -22,14 +22,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"geoip-tag",
|
||||
"6.0",
|
||||
"geoip message tag",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"geoip-tag",
|
||||
"6.0",
|
||||
"geoip message tag",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int geoip_mtag_is_ok(Client *client, const char *name, const char *value);
|
||||
@@ -80,7 +79,7 @@ int geoip_mtag_is_ok(Client *client, const char *name, const char *value)
|
||||
void mtag_add_geoip(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature)
|
||||
{
|
||||
MessageTag *m;
|
||||
|
||||
|
||||
GeoIPResult *geoip;
|
||||
|
||||
if (IsUser(client) && ((geoip = geoip_client(client))))
|
||||
@@ -89,7 +88,8 @@ void mtag_add_geoip(Client *client, MessageTag *recv_mtags, MessageTag **mtag_li
|
||||
if (m)
|
||||
{
|
||||
m = duplicate_mtag(m);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
m = safe_alloc(sizeof(MessageTag));
|
||||
safe_strdup(m->name, "unrealircd.org/geoip");
|
||||
safe_strdup(m->value, geoip->country_code);
|
||||
|
||||
+31
-29
@@ -7,14 +7,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"geoip_base",
|
||||
"5.0",
|
||||
"Base module for geoip",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"geoip_base",
|
||||
"5.0",
|
||||
"Base module for geoip",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
struct geoip_base_config_s {
|
||||
int check_on_load;
|
||||
@@ -43,15 +42,15 @@ struct geoip_base_config_s geoip_base_config;
|
||||
* should use geoip_client(client) !
|
||||
*/
|
||||
|
||||
#define GEOIPDATARAW(x) (moddata_client((x), geoip_md).ptr)
|
||||
#define GEOIPDATA(x) ((GeoIPResult *)moddata_client((x), geoip_md).ptr)
|
||||
#define GEOIPDATARAW(x) (moddata_client((x), geoip_md).ptr)
|
||||
#define GEOIPDATA(x) ((GeoIPResult *)moddata_client((x), geoip_md).ptr)
|
||||
|
||||
int geoip_base_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
{
|
||||
ConfigEntry *cep;
|
||||
int errors = 0;
|
||||
int i;
|
||||
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
@@ -70,7 +69,7 @@ int geoip_base_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
}
|
||||
config_warn("%s:%i: unknown item geoip::%s", cep->file->filename, cep->line_number, cep->name);
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -126,7 +125,7 @@ MOD_INIT()
|
||||
HookAdd(modinfo->handle, HOOKTYPE_IP_CHANGE, 0, geoip_base_ip_change);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_SERVER_HANDSHAKE_OUT, 0, geoip_base_handshake);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CONNECT_EXTINFO, 1, geoip_connect_extinfo); /* (prio: near-first) */
|
||||
HookAdd(modinfo->handle, HOOKTYPE_PRE_LOCAL_CONNECT, 0,geoip_base_handshake); /* in case the IP changed in registration phase (WEBIRC, HTTP Forwarded) */
|
||||
HookAdd(modinfo->handle, HOOKTYPE_PRE_LOCAL_CONNECT, 0, geoip_base_handshake); /* in case the IP changed in registration phase (WEBIRC, HTTP Forwarded) */
|
||||
HookAdd(modinfo->handle, HOOKTYPE_WHOIS, 0, geoip_base_whois_country);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_WHOIS, 0, geoip_base_whois_asn);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_JSON_EXPAND_CLIENT, 0, geoip_json_expand_client);
|
||||
@@ -224,22 +223,23 @@ const char *geoip_base_serialize(ModData *m)
|
||||
if (geo->asname)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "cc=%s|cd=%s|asn=%u|asname=%s",
|
||||
geo->country_code,
|
||||
geo->country_name,
|
||||
geo->asn,
|
||||
geoip_sanitized_asname(geo->asname));
|
||||
} else {
|
||||
geo->country_code,
|
||||
geo->country_name,
|
||||
geo->asn,
|
||||
geoip_sanitized_asname(geo->asname));
|
||||
} else
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "cc=%s|cd=%s|asn=%u",
|
||||
geo->country_code,
|
||||
geo->country_name,
|
||||
geo->asn);
|
||||
geo->country_code,
|
||||
geo->country_name,
|
||||
geo->asn);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
void geoip_base_unserialize(const char *str, ModData *m)
|
||||
{
|
||||
char buf[512], *p=NULL, *varname, *value;
|
||||
char buf[512], *p = NULL, *varname, *value;
|
||||
char *country_name = NULL;
|
||||
char *country_code = NULL;
|
||||
long asn = 0;
|
||||
@@ -370,11 +370,11 @@ int geoip_base_whois_asn(Client *client, Client *target, NameValuePrioList **lis
|
||||
|
||||
// WHOIS_CONFIG_DETAILS_LIMITED / WHOIS_CONFIG_DETAILS_FULL distinction makes no sense here
|
||||
add_nvplist_numeric_fmt(list, 0, "asn", client, RPL_WHOISASN,
|
||||
"%s %u :is connecting from AS%u [%s]",
|
||||
target->name,
|
||||
geo->asn,
|
||||
geo->asn,
|
||||
geo->asname ? geo->asname : "UNKNOWN");
|
||||
"%s %u :is connecting from AS%u [%s]",
|
||||
target->name,
|
||||
geo->asn,
|
||||
geo->asn,
|
||||
geo->asname ? geo->asname : "UNKNOWN");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -399,7 +399,8 @@ CMD_FUNC(cmd_geoip)
|
||||
if (strchr(parv[1], '.') || strchr(parv[1], ':'))
|
||||
{
|
||||
ip = parv[1];
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
target = find_user(parv[1], NULL);
|
||||
if (!target)
|
||||
{
|
||||
@@ -421,7 +422,8 @@ CMD_FUNC(cmd_geoip)
|
||||
{
|
||||
sendnotice(client, "- No information available");
|
||||
return;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (res->country_code)
|
||||
sendnotice(client, "- Country code: %s", res->country_code);
|
||||
if (res->country_name)
|
||||
|
||||
+26
-26
@@ -6,14 +6,13 @@
|
||||
#include "unrealircd.h"
|
||||
#include <GeoIP.h>
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"geoip_classic",
|
||||
"5.0",
|
||||
"GEOIP using classic databases",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"geoip_classic",
|
||||
"5.0",
|
||||
"GEOIP using classic databases",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
struct geoip_classic_config_s {
|
||||
char *v4_db_file;
|
||||
@@ -48,7 +47,7 @@ int geoip_classic_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *err
|
||||
ConfigEntry *cep;
|
||||
int errors = 0;
|
||||
int i;
|
||||
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
@@ -128,7 +127,7 @@ int geoip_classic_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *err
|
||||
}
|
||||
config_warn("%s:%i: unknown item set::geoip-classic::%s", cep->file->filename, cep->line_number, cep->name);
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -189,7 +188,8 @@ int geoip_classic_configposttest(int *errs)
|
||||
if (!geoip_classic_config.have_ipv4_database && !geoip_classic_config.have_ipv6_database)
|
||||
{
|
||||
config_error("[geoip_classic] couldn't read any database! Either put these in %s location "
|
||||
"or specify another in set::geoip-classic config block", PERMDATADIR);
|
||||
"or specify another in set::geoip-classic config block",
|
||||
PERMDATADIR);
|
||||
errors++;
|
||||
}
|
||||
/* The ASN ones are optional */
|
||||
@@ -269,9 +269,9 @@ MOD_LOAD()
|
||||
{
|
||||
int save_err = errno;
|
||||
unreal_log(ULOG_WARNING, "geoip_classic", "GEOIP_CANNOT_OPEN_DB", NULL,
|
||||
"[IPv4] Could not open '$filename': $system_error",
|
||||
log_data_string("filename", geoip_classic_config.v4_db_file),
|
||||
log_data_string("system_error", strerror(save_err)));
|
||||
"[IPv4] Could not open '$filename': $system_error",
|
||||
log_data_string("filename", geoip_classic_config.v4_db_file),
|
||||
log_data_string("system_error", strerror(save_err)));
|
||||
}
|
||||
}
|
||||
if (geoip_classic_config.v6_db_file)
|
||||
@@ -285,9 +285,9 @@ MOD_LOAD()
|
||||
{
|
||||
int save_err = errno;
|
||||
unreal_log(ULOG_WARNING, "geoip_classic", "GEOIP_CANNOT_OPEN_DB", NULL,
|
||||
"[IPv6] Could not open '$filename': $system_error",
|
||||
log_data_string("filename", geoip_classic_config.v6_db_file),
|
||||
log_data_string("system_error", strerror(save_err)));
|
||||
"[IPv6] Could not open '$filename': $system_error",
|
||||
log_data_string("filename", geoip_classic_config.v6_db_file),
|
||||
log_data_string("system_error", strerror(save_err)));
|
||||
}
|
||||
convert_to_absolute_path(&geoip_classic_config.v6_db_file, PERMDATADIR);
|
||||
}
|
||||
@@ -295,7 +295,7 @@ MOD_LOAD()
|
||||
if (!found_good_file)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "geoip_classic", "GEOIP_CANNOT_OPEN_DB", NULL,
|
||||
"could not open any database!");
|
||||
"could not open any database!");
|
||||
return MOD_FAILED;
|
||||
}
|
||||
|
||||
@@ -308,9 +308,9 @@ MOD_LOAD()
|
||||
{
|
||||
int save_err = errno;
|
||||
unreal_log(ULOG_WARNING, "geoip_classic", "GEOIP_CANNOT_OPEN_DB", NULL,
|
||||
"[ASN IPv4] Could not open '$filename': $system_error",
|
||||
log_data_string("filename", geoip_classic_config.asn_v4_db_file),
|
||||
log_data_string("system_error", strerror(save_err)));
|
||||
"[ASN IPv4] Could not open '$filename': $system_error",
|
||||
log_data_string("filename", geoip_classic_config.asn_v4_db_file),
|
||||
log_data_string("system_error", strerror(save_err)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,9 +322,9 @@ MOD_LOAD()
|
||||
{
|
||||
int save_err = errno;
|
||||
unreal_log(ULOG_WARNING, "geoip_classic", "GEOIP_CANNOT_OPEN_DB", NULL,
|
||||
"[ASN IPv6] Could not open '$filename': $system_error",
|
||||
log_data_string("filename", geoip_classic_config.asn_v6_db_file),
|
||||
log_data_string("system_error", strerror(save_err)));
|
||||
"[ASN IPv6] Could not open '$filename': $system_error",
|
||||
log_data_string("filename", geoip_classic_config.asn_v6_db_file),
|
||||
log_data_string("system_error", strerror(save_err)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ GeoIPResult *geoip_lookup_classic(char *ip)
|
||||
{
|
||||
static char buf[256];
|
||||
const char *country_code, *country_name;
|
||||
char *isp=NULL;
|
||||
char *isp = NULL;
|
||||
GeoIPLookup gl, asn_gl;
|
||||
GeoIP *gi;
|
||||
int geoid;
|
||||
@@ -414,7 +414,7 @@ GeoIPResult *geoip_lookup_classic(char *ip)
|
||||
if ((isp[0] == 'A') && (isp[1] == 'S') && isdigit(isp[2]))
|
||||
{
|
||||
char *p;
|
||||
r->asn = strtoul(isp+2, NULL, 10);
|
||||
r->asn = strtoul(isp + 2, NULL, 10);
|
||||
p = strchr(isp, ' ');
|
||||
if (p)
|
||||
{
|
||||
|
||||
+54
-54
@@ -22,14 +22,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"geoip_csv",
|
||||
"5.0",
|
||||
"GEOIP using csv data files",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"geoip_csv",
|
||||
"5.0",
|
||||
"GEOIP using csv data files",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
struct geoip_csv_config_s {
|
||||
char *v4_db_file;
|
||||
@@ -94,7 +93,7 @@ int geoip_csv_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
ConfigEntry *cep;
|
||||
int errors = 0;
|
||||
int i;
|
||||
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
@@ -158,7 +157,7 @@ int geoip_csv_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
}
|
||||
config_warn("%s:%i: unknown item set::geoip-csv::%s", cep->file->filename, cep->line_number, cep->name);
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -209,7 +208,8 @@ int geoip_csv_configposttest(int *errs)
|
||||
if (!geoip_csv_config.have_ipv4_database && !geoip_csv_config.have_ipv6_database)
|
||||
{
|
||||
config_error("[geoip_csv] couldn't read any blocks file! Either put these in %s location "
|
||||
"or specify another in set::geoip-csv config block", PERMDATADIR);
|
||||
"or specify another in set::geoip-csv config block",
|
||||
PERMDATADIR);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -295,7 +295,7 @@ MOD_LOAD()
|
||||
if (!geoip_csv_config.countries_db_file)
|
||||
{
|
||||
unreal_log(ULOG_DEBUG, "geoip_csv", "GEOIP_NO_COUNTRIES", NULL,
|
||||
"[BUG] No countries file specified");
|
||||
"[BUG] No countries file specified");
|
||||
geoip_csv_free();
|
||||
return MOD_FAILED;
|
||||
}
|
||||
@@ -303,7 +303,7 @@ MOD_LOAD()
|
||||
if (geoip_csv_read_countries(geoip_csv_config.countries_db_file))
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "geoip_csv", "GEOIP_CANNOT_OPEN_DB", NULL,
|
||||
"could not open required countries file!");
|
||||
"could not open required countries file!");
|
||||
geoip_csv_free();
|
||||
return MOD_FAILED;
|
||||
}
|
||||
@@ -311,7 +311,7 @@ MOD_LOAD()
|
||||
if (!found_good_file)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "geoip_csv", "GEOIP_CANNOT_OPEN_DB", NULL,
|
||||
"could not open any database!");
|
||||
"could not open any database!");
|
||||
geoip_csv_free();
|
||||
return MOD_FAILED;
|
||||
}
|
||||
@@ -328,7 +328,7 @@ static void geoip_csv_free_ipv4(void)
|
||||
{
|
||||
struct geoip_csv_ip_range *ptr, *oldptr;
|
||||
int i;
|
||||
for (i=0; i<256; i++)
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
ptr = geoip_csv_ip_range_list[i];
|
||||
geoip_csv_ip_range_list[i] = NULL;
|
||||
@@ -377,13 +377,13 @@ static void geoip_csv_free(void)
|
||||
/* reading data from files */
|
||||
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
#define BUFLEN 8191
|
||||
#define STR(x) STR_HELPER(x)
|
||||
#define BUFLEN 8191
|
||||
|
||||
static int geoip_csv_read_ipv4(char *file)
|
||||
{
|
||||
FILE *u;
|
||||
char buf[BUFLEN+1];
|
||||
char buf[BUFLEN + 1];
|
||||
int cidr, geoid;
|
||||
char ip[24];
|
||||
char netmask[24];
|
||||
@@ -394,7 +394,7 @@ static int geoip_csv_read_ipv4(char *file)
|
||||
memset(curr, 0, sizeof(curr));
|
||||
int i;
|
||||
char *filename = NULL;
|
||||
|
||||
|
||||
safe_strdup(filename, file);
|
||||
convert_to_absolute_path(&filename, CONFDIR);
|
||||
u = fopen(filename, "r");
|
||||
@@ -404,7 +404,7 @@ static int geoip_csv_read_ipv4(char *file)
|
||||
config_warn("[geoip_csv] Cannot open IPv4 ranges list file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (!fgets(buf, BUFLEN, u))
|
||||
{
|
||||
config_warn("[geoip_csv] IPv4 list file is empty");
|
||||
@@ -432,19 +432,19 @@ static int geoip_csv_read_ipv4(char *file)
|
||||
continue;
|
||||
}
|
||||
addr = htonl(addr);
|
||||
|
||||
|
||||
mask = 0;
|
||||
while (cidr)
|
||||
{ /* calculate netmask */
|
||||
mask >>= 1;
|
||||
mask |= (1<<31);
|
||||
mask |= (1 << 31);
|
||||
cidr--;
|
||||
}
|
||||
|
||||
i=0;
|
||||
|
||||
i = 0;
|
||||
do
|
||||
{ /* multiple iterations in case CIDR is <8 and we have multiple first octets matching */
|
||||
uint8_t index = addr>>24;
|
||||
uint8_t index = addr >> 24;
|
||||
if (!curr[index])
|
||||
{
|
||||
geoip_csv_ip_range_list[index] = safe_alloc(sizeof(struct geoip_csv_ip_range));
|
||||
@@ -461,7 +461,7 @@ static int geoip_csv_read_ipv4(char *file)
|
||||
ptr->geoid = geoid;
|
||||
i++;
|
||||
index++;
|
||||
} while (i<=((~mask)>>24));
|
||||
} while (i <= ((~mask) >> 24));
|
||||
}
|
||||
fclose(u);
|
||||
return 0;
|
||||
@@ -473,19 +473,19 @@ static int geoip_csv_ip6_convert(char *ip, uint16_t out[8])
|
||||
int i;
|
||||
if (inet_pton(AF_INET6, ip, out) < 1)
|
||||
return 0;
|
||||
for (i=0; i<8; i++)
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
out[i] = htons(out[i]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define IPV6_STRING_SIZE 40
|
||||
#define IPV6_STRING_SIZE 40
|
||||
|
||||
static int geoip_csv_read_ipv6(char *file)
|
||||
{
|
||||
FILE *u;
|
||||
char buf[BUFLEN+1];
|
||||
char buf[BUFLEN + 1];
|
||||
char *bptr, *optr;
|
||||
int cidr, geoid;
|
||||
char ip[IPV6_STRING_SIZE];
|
||||
@@ -527,7 +527,7 @@ static int geoip_csv_read_ipv6(char *file)
|
||||
}
|
||||
if (++length >= IPV6_STRING_SIZE)
|
||||
{
|
||||
ip[IPV6_STRING_SIZE-1] = '\0';
|
||||
ip[IPV6_STRING_SIZE - 1] = '\0';
|
||||
config_warn("[geoip_csv] Too long IPv6 address found, starts with %s. Bad CSV file?", ip);
|
||||
error = 1;
|
||||
break;
|
||||
@@ -551,11 +551,11 @@ static int geoip_csv_read_ipv6(char *file)
|
||||
}
|
||||
|
||||
memset(mask, 0, 16);
|
||||
|
||||
|
||||
int mask_bit = 0;
|
||||
while (cidr)
|
||||
{ /* calculate netmask */
|
||||
mask[mask_bit/16] |= 1<<(15-(mask_bit%16));
|
||||
mask[mask_bit / 16] |= 1 << (15 - (mask_bit % 16));
|
||||
mask_bit++;
|
||||
cidr--;
|
||||
}
|
||||
@@ -580,14 +580,14 @@ static int geoip_csv_read_ipv6(char *file)
|
||||
}
|
||||
|
||||
/* CSV fields; no STATE_GEONAME_ID because of using %d in fscanf */
|
||||
#define STATE_LOCALE_CODE 0
|
||||
#define STATE_CONTINENT_CODE 1
|
||||
#define STATE_CONTINENT_NAME 2
|
||||
#define STATE_COUNTRY_ISO_CODE 3
|
||||
#define STATE_COUNTRY_NAME 4
|
||||
#define STATE_IS_IN_EU 5
|
||||
#define STATE_LOCALE_CODE 0
|
||||
#define STATE_CONTINENT_CODE 1
|
||||
#define STATE_CONTINENT_NAME 2
|
||||
#define STATE_COUNTRY_ISO_CODE 3
|
||||
#define STATE_COUNTRY_NAME 4
|
||||
#define STATE_IS_IN_EU 5
|
||||
|
||||
#define MEMBER_SIZE(type,member) sizeof(((type *)0)->member)
|
||||
#define MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
|
||||
|
||||
static int geoip_csv_read_countries(char *file)
|
||||
{
|
||||
@@ -595,7 +595,7 @@ static int geoip_csv_read_countries(char *file)
|
||||
char code[MEMBER_SIZE(struct geoip_csv_country, code)];
|
||||
char continent[MEMBER_SIZE(struct geoip_csv_country, continent)];
|
||||
char name[MEMBER_SIZE(struct geoip_csv_country, name)];
|
||||
char buf[BUFLEN+1];
|
||||
char buf[BUFLEN + 1];
|
||||
int state;
|
||||
int id;
|
||||
struct geoip_csv_country *curr = NULL;
|
||||
@@ -610,7 +610,7 @@ static int geoip_csv_read_countries(char *file)
|
||||
config_warn("[geoip_csv] Cannot open countries list file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (!fgets(buf, BUFLEN, u))
|
||||
{
|
||||
config_warn("[geoip_csv] Countries list file is empty");
|
||||
@@ -644,8 +644,8 @@ static int geoip_csv_read_countries(char *file)
|
||||
length++;
|
||||
break;
|
||||
case STATE_COUNTRY_ISO_CODE:
|
||||
if (*ptr == ',') /* country code is empty */
|
||||
goto next_line; /* -- that means only the continent is specified - we ignore it completely */
|
||||
if (*ptr == ',') /* country code is empty */
|
||||
goto next_line; /* -- that means only the continent is specified - we ignore it completely */
|
||||
if (length >= MEMBER_SIZE(struct geoip_csv_country, code) - 1)
|
||||
{
|
||||
*codeptr = '\0';
|
||||
@@ -669,7 +669,7 @@ static int geoip_csv_read_countries(char *file)
|
||||
state++;
|
||||
}
|
||||
}
|
||||
read_country_name:
|
||||
read_country_name:
|
||||
*codeptr = '\0';
|
||||
*contptr = '\0';
|
||||
length = 0;
|
||||
@@ -697,7 +697,7 @@ static int geoip_csv_read_countries(char *file)
|
||||
break; // scan for country name
|
||||
}
|
||||
}
|
||||
end_country_name:
|
||||
end_country_name:
|
||||
*nptr = '\0';
|
||||
if (geoip_csv_country_list)
|
||||
{
|
||||
@@ -713,7 +713,8 @@ static int geoip_csv_read_countries(char *file)
|
||||
strcpy(curr->name, name);
|
||||
strcpy(curr->continent, continent);
|
||||
curr->id = id;
|
||||
next_line: continue;
|
||||
next_line:
|
||||
continue;
|
||||
}
|
||||
fclose(u);
|
||||
return 0;
|
||||
@@ -725,7 +726,7 @@ static struct geoip_csv_country *geoip_csv_get_country(int id)
|
||||
if (!curr)
|
||||
return NULL;
|
||||
int found = 0;
|
||||
for (;curr;curr = curr->next)
|
||||
for (; curr; curr = curr->next)
|
||||
{
|
||||
if (curr->id == id)
|
||||
{
|
||||
@@ -750,11 +751,11 @@ static int geoip_csv_get_v4_geoid(char *iip)
|
||||
return 0;
|
||||
}
|
||||
addr = htonl(addr);
|
||||
curr = geoip_csv_ip_range_list[addr>>24];
|
||||
curr = geoip_csv_ip_range_list[addr >> 24];
|
||||
if (curr)
|
||||
{
|
||||
i = 0;
|
||||
for (;curr;curr = curr->next)
|
||||
for (; curr; curr = curr->next)
|
||||
{
|
||||
tmp_addr = addr;
|
||||
tmp_addr &= curr->mask; /* mask the address to filter out net prefix only */
|
||||
@@ -777,7 +778,7 @@ static int geoip_csv_get_v6_geoid(char *iip)
|
||||
struct geoip_csv_ip6_range *curr;
|
||||
int i;
|
||||
int found = 0;
|
||||
|
||||
|
||||
if (!geoip_csv_ip6_convert(iip, addr))
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "geoip_csv", "UNSUPPORTED_IP", NULL, "Invalid or unsupported client IP $ip", log_data_string("ip", iip));
|
||||
@@ -786,10 +787,10 @@ static int geoip_csv_get_v6_geoid(char *iip)
|
||||
curr = geoip_csv_ip6_range_list;
|
||||
if (curr)
|
||||
{
|
||||
for (;curr;curr = curr->next)
|
||||
for (; curr; curr = curr->next)
|
||||
{
|
||||
found = 1;
|
||||
for (i=0; i<8; i++)
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (curr->addr[i] != (addr[i] & curr->mask[i]))
|
||||
{ /* compare net address to loaded data */
|
||||
@@ -797,7 +798,7 @@ static int geoip_csv_get_v6_geoid(char *iip)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found)
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -836,4 +837,3 @@ GeoIPResult *geoip_lookup_csv(char *ip)
|
||||
safe_strdup(r->country_name, country->name);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
+23
-24
@@ -6,14 +6,13 @@
|
||||
#include "unrealircd.h"
|
||||
#include "mmdb.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"geoip_mmdb",
|
||||
"5.2",
|
||||
"GEOIP using mmdb databases",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"geoip_mmdb",
|
||||
"5.2",
|
||||
"GEOIP using mmdb databases",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
struct geoip_mmdb_config_s {
|
||||
char *db_file;
|
||||
@@ -88,7 +87,7 @@ int geoip_mmdb_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
}
|
||||
config_warn("%s:%i: unknown item set::geoip-mmdb::%s", cep->file->filename, cep->line_number, cep->name);
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -159,9 +158,9 @@ MOD_TEST()
|
||||
if (!CallbackAddPVoid(modinfo->handle, CALLBACKTYPE_GEOIP_LOOKUP, TO_PVOIDFUNC(geoip_lookup_mmdb)))
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "geoip_mmdb", "GEOIP_ADD_CALLBACK_FAILED", NULL,
|
||||
"geoip_mmdb: Could not install GEOIP_LOOKUP callback. "
|
||||
"Most likely another geoip module is already loaded. "
|
||||
"You can only load one!");
|
||||
"geoip_mmdb: Could not install GEOIP_LOOKUP callback. "
|
||||
"Most likely another geoip module is already loaded. "
|
||||
"You can only load one!");
|
||||
return MOD_FAILED;
|
||||
}
|
||||
|
||||
@@ -193,9 +192,9 @@ MOD_LOAD()
|
||||
if (status != MMDB_OK)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "geoip_mmdb", "GEOIP_CANNOT_OPEN_DB", NULL,
|
||||
"Could not open '$filename' - $mmdb_error",
|
||||
log_data_string("filename", geoip_mmdb_config.db_file),
|
||||
log_data_string("mmdb_error", mmdb_strerror(status)));
|
||||
"Could not open '$filename' - $mmdb_error",
|
||||
log_data_string("filename", geoip_mmdb_config.db_file),
|
||||
log_data_string("mmdb_error", mmdb_strerror(status)));
|
||||
geoip_mmdb_config.have_database = 0;
|
||||
}
|
||||
}
|
||||
@@ -207,9 +206,9 @@ MOD_LOAD()
|
||||
if (status != MMDB_OK)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "geoip_mmdb", "GEOIP_CANNOT_OPEN_ASN_DB", NULL,
|
||||
"Could not open '$filename' - $mmdb_error",
|
||||
log_data_string("filename", geoip_mmdb_config.asn_db_file),
|
||||
log_data_string("mmdb_error", mmdb_strerror(status)));
|
||||
"Could not open '$filename' - $mmdb_error",
|
||||
log_data_string("filename", geoip_mmdb_config.asn_db_file),
|
||||
log_data_string("mmdb_error", mmdb_strerror(status)));
|
||||
geoip_mmdb_config.have_asn_database = 0;
|
||||
}
|
||||
}
|
||||
@@ -248,9 +247,9 @@ GeoIPResult *geoip_lookup_mmdb(char *ip)
|
||||
if (status != MMDB_OK)
|
||||
{
|
||||
unreal_log(ULOG_DEBUG, "geoip_mmdb", "GEOIP_DB_ERROR", NULL,
|
||||
"mmdb: lookup error for $ip: $error",
|
||||
log_data_string("ip", ip),
|
||||
log_data_string("error", mmdb_strerror(status)));
|
||||
"mmdb: lookup error for $ip: $error",
|
||||
log_data_string("ip", ip),
|
||||
log_data_string("error", mmdb_strerror(status)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -280,9 +279,9 @@ GeoIPResult *geoip_lookup_mmdb(char *ip)
|
||||
if (status != MMDB_OK)
|
||||
{
|
||||
unreal_log(ULOG_DEBUG, "geoip_mmdb", "GEOIP_ASN_DB_ERROR", NULL,
|
||||
"mmdb: lookup error for $ip: $error",
|
||||
log_data_string("ip", ip),
|
||||
log_data_string("error", mmdb_strerror(status)));
|
||||
"mmdb: lookup error for $ip: $error",
|
||||
log_data_string("ip", ip),
|
||||
log_data_string("error", mmdb_strerror(status)));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
+11
-12
@@ -24,20 +24,19 @@
|
||||
|
||||
CMD_FUNC(cmd_globops);
|
||||
|
||||
#define MSG_GLOBOPS "GLOBOPS"
|
||||
#define MSG_GLOBOPS "GLOBOPS"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"globops",
|
||||
"5.0",
|
||||
"command /globops",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"globops",
|
||||
"5.0",
|
||||
"command /globops",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CommandAdd(modinfo->handle, MSG_GLOBOPS, cmd_globops, 1, CMD_USER|CMD_SERVER);
|
||||
CommandAdd(modinfo->handle, MSG_GLOBOPS, cmd_globops, 1, CMD_USER | CMD_SERVER);
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -65,7 +64,7 @@ CMD_FUNC(cmd_globops)
|
||||
return;
|
||||
}
|
||||
|
||||
if (MyUser(client) && !ValidatePermissionsForPath("chat:globops",client,NULL,NULL,NULL))
|
||||
if (MyUser(client) && !ValidatePermissionsForPath("chat:globops", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
@@ -80,6 +79,6 @@ CMD_FUNC(cmd_globops)
|
||||
/* Backward-compatible (3.2.x) */
|
||||
sendto_umode(UMODE_OPER, "from %s: %s", client->name, message);
|
||||
sendto_server(client, 0, 0, NULL, ":%s SENDUMODE o :from %s: %s",
|
||||
me.id, client->name, message);
|
||||
me.id, client->name, message);
|
||||
}
|
||||
}
|
||||
|
||||
+19
-18
@@ -24,17 +24,16 @@
|
||||
|
||||
CMD_FUNC(cmd_help);
|
||||
|
||||
#define MSG_HELP "HELP"
|
||||
#define MSG_HELPOP "HELPOP"
|
||||
#define MSG_HELP "HELP"
|
||||
#define MSG_HELPOP "HELPOP"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"help",
|
||||
"5.0",
|
||||
"command /help",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"help",
|
||||
"5.0",
|
||||
"command /help",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
@@ -74,7 +73,7 @@ ConfigItem_help *find_Help(const char *command)
|
||||
{
|
||||
if (help->command == NULL)
|
||||
continue;
|
||||
else if (!strcasecmp(command,help->command))
|
||||
else if (!strcasecmp(command, help->command))
|
||||
return help;
|
||||
}
|
||||
return NULL;
|
||||
@@ -93,32 +92,34 @@ void parse_help(Client *client, const char *help)
|
||||
HDR(" ***** UnrealIRCd Help System *****");
|
||||
SND(" -");
|
||||
text = helpitem->text;
|
||||
while (text) {
|
||||
while (text)
|
||||
{
|
||||
SND(text->line);
|
||||
text = text->next;
|
||||
}
|
||||
SND(" -");
|
||||
return;
|
||||
|
||||
}
|
||||
helpitem = find_Help(help);
|
||||
if (!helpitem) {
|
||||
if (!helpitem)
|
||||
{
|
||||
SND(" -");
|
||||
HDR(" ***** No Help Available *****");
|
||||
SND(" -");
|
||||
SND(" We're sorry, we don't have help available for the command you requested.");
|
||||
SND(" -");
|
||||
sendto_one(client, NULL, ":%s 292 %s : ***** Go to %s if you have any further questions *****",
|
||||
me.name, client->name, HELP_CHANNEL);
|
||||
me.name, client->name, HELP_CHANNEL);
|
||||
SND(" -");
|
||||
return;
|
||||
}
|
||||
text = helpitem->text;
|
||||
SND(" -");
|
||||
sendto_one(client, NULL, ":%s 290 %s :***** %s *****",
|
||||
me.name, client->name, helpitem->command);
|
||||
me.name, client->name, helpitem->command);
|
||||
SND(" -");
|
||||
while (text) {
|
||||
while (text)
|
||||
{
|
||||
SND(text->line);
|
||||
text = text->next;
|
||||
}
|
||||
@@ -137,7 +138,7 @@ CMD_FUNC(cmd_help)
|
||||
return; /* never remote */
|
||||
|
||||
helptopic = parc > 1 ? parv[1] : NULL;
|
||||
|
||||
|
||||
if (helptopic && (*helptopic == '?'))
|
||||
helptopic++;
|
||||
|
||||
|
||||
+52
-54
@@ -33,40 +33,39 @@ ConfigItem_ulines *HiddenServers;
|
||||
|
||||
static struct
|
||||
{
|
||||
unsigned disable_map : 1;
|
||||
unsigned disable_links : 1;
|
||||
char *map_deny_message;
|
||||
char *links_deny_message;
|
||||
unsigned disable_map : 1;
|
||||
unsigned disable_links : 1;
|
||||
char *map_deny_message;
|
||||
char *links_deny_message;
|
||||
} Settings;
|
||||
|
||||
static ModuleInfo *MyModInfo;
|
||||
#define MyMod MyModInfo->handle
|
||||
#define SAVE_MODINFO MyModInfo = modinfo;
|
||||
static ModuleInfo *MyModInfo;
|
||||
#define MyMod MyModInfo->handle
|
||||
#define SAVE_MODINFO MyModInfo = modinfo;
|
||||
|
||||
static int lmax = 0;
|
||||
static int umax = 0;
|
||||
|
||||
static int dcount(int n)
|
||||
{
|
||||
int cnt = 0;
|
||||
int cnt = 0;
|
||||
|
||||
while (n != 0)
|
||||
{
|
||||
n = n/10;
|
||||
cnt++;
|
||||
}
|
||||
while (n != 0)
|
||||
{
|
||||
n = n / 10;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
return cnt;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"hideserver",
|
||||
"5.0",
|
||||
"Hide servers from /MAP & /LINKS",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"hideserver",
|
||||
"5.0",
|
||||
"Hide servers from /MAP & /LINKS",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
static void InitConf()
|
||||
{
|
||||
@@ -75,7 +74,7 @@ static void InitConf()
|
||||
|
||||
static void FreeConf()
|
||||
{
|
||||
ConfigItem_ulines *h, *next;
|
||||
ConfigItem_ulines *h, *next;
|
||||
|
||||
safe_free(Settings.map_deny_message);
|
||||
safe_free(Settings.links_deny_message);
|
||||
@@ -141,17 +140,15 @@ static int cb_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!strcmp(cep->name, "hide"))
|
||||
{
|
||||
/* No checking needed */
|
||||
}
|
||||
else if (!cep->value)
|
||||
} else if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: %s::%s without value",
|
||||
cep->file->filename,
|
||||
cep->line_number,
|
||||
ce->name, cep->name);
|
||||
cep->file->filename,
|
||||
cep->line_number,
|
||||
ce->name, cep->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
else if (!strcmp(cep->name, "disable-map"))
|
||||
} else if (!strcmp(cep->name, "disable-map"))
|
||||
;
|
||||
else if (!strcmp(cep->name, "disable-links"))
|
||||
;
|
||||
@@ -162,7 +159,7 @@ static int cb_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
else
|
||||
{
|
||||
config_error("%s:%i: unknown directive hideserver::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -176,8 +173,8 @@ static int cb_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
|
||||
static int cb_conf(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
{
|
||||
ConfigEntry *cep, *cepp;
|
||||
ConfigItem_ulines *ca;
|
||||
ConfigEntry *cep, *cepp;
|
||||
ConfigItem_ulines *ca;
|
||||
|
||||
if (type == CONFIG_MAIN)
|
||||
{
|
||||
@@ -192,12 +189,10 @@ static int cb_conf(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
else if (!strcmp(cep->name, "map-deny-message"))
|
||||
{
|
||||
safe_strdup(Settings.map_deny_message, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "links-deny-message"))
|
||||
} else if (!strcmp(cep->name, "links-deny-message"))
|
||||
{
|
||||
safe_strdup(Settings.links_deny_message, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "hide"))
|
||||
} else if (!strcmp(cep->name, "hide"))
|
||||
{
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
{
|
||||
@@ -237,7 +232,7 @@ static void dump_map(Client *client, Client *server, char *mask, int prompt_leng
|
||||
{
|
||||
static char prompt[64];
|
||||
char *p = &prompt[prompt_length];
|
||||
int cnt = 0;
|
||||
int cnt = 0;
|
||||
Client *acptr;
|
||||
|
||||
*p = '\0';
|
||||
@@ -261,9 +256,10 @@ static void dump_map(Client *client, Client *server, char *mask, int prompt_leng
|
||||
if (IsOper(client))
|
||||
snprintf(sid, sizeof(sid), " [%s]", server->id);
|
||||
sendnumeric(client, RPL_MAP, prompt, server->name, tbuf, umax,
|
||||
server->server->users, (double)(lmax < 10) ? 4 : (lmax == 100) ? 6 : 5,
|
||||
(server->server->users * 100.0 / irccounts.clients),
|
||||
IsOper(client) ? sid : "");
|
||||
server->server->users, (double)(lmax < 10) ? 4 : (lmax == 100) ? 6
|
||||
: 5,
|
||||
(server->server->users * 100.0 / irccounts.clients),
|
||||
IsOper(client) ? sid : "");
|
||||
cnt = 0;
|
||||
}
|
||||
|
||||
@@ -281,7 +277,7 @@ static void dump_map(Client *client, Client *server, char *mask, int prompt_leng
|
||||
list_for_each_entry(acptr, &global_server_list, client_node)
|
||||
{
|
||||
if (acptr->uplink != server ||
|
||||
(IsULine(acptr) && HIDE_ULINES && !ValidatePermissionsForPath("server:info:map:ulines",client,NULL,NULL,NULL)))
|
||||
(IsULine(acptr) && HIDE_ULINES && !ValidatePermissionsForPath("server:info:map:ulines", client, NULL, NULL, NULL)))
|
||||
continue;
|
||||
if (FindHiddenServer(acptr->name))
|
||||
break;
|
||||
@@ -291,7 +287,7 @@ static void dump_map(Client *client, Client *server, char *mask, int prompt_leng
|
||||
|
||||
list_for_each_entry(acptr, &global_server_list, client_node)
|
||||
{
|
||||
if (IsULine(acptr) && HIDE_ULINES && !ValidatePermissionsForPath("server:info:map:ulines",client,NULL,NULL,NULL))
|
||||
if (IsULine(acptr) && HIDE_ULINES && !ValidatePermissionsForPath("server:info:map:ulines", client, NULL, NULL, NULL))
|
||||
continue;
|
||||
if (FindHiddenServer(acptr->name))
|
||||
break;
|
||||
@@ -315,7 +311,7 @@ void dump_flat_map(Client *client, Client *server, int length)
|
||||
Client *acptr;
|
||||
int cnt = 0, len = 0, hide_ulines;
|
||||
|
||||
hide_ulines = (HIDE_ULINES && !ValidatePermissionsForPath("server:info:map:ulines",client,NULL,NULL,NULL)) ? 1 : 0;
|
||||
hide_ulines = (HIDE_ULINES && !ValidatePermissionsForPath("server:info:map:ulines", client, NULL, NULL, NULL)) ? 1 : 0;
|
||||
|
||||
len = length - strlen(server->name) + 3;
|
||||
if (len < 0)
|
||||
@@ -328,8 +324,9 @@ void dump_flat_map(Client *client, Client *server, int length)
|
||||
tbuf[len--] = '-';
|
||||
|
||||
sendnumeric(client, RPL_MAP, "", server->name, tbuf, umax, server->server->users,
|
||||
(lmax < 10) ? 4 : (lmax == 100) ? 6 : 5,
|
||||
(server->server->users * 100.0 / irccounts.clients), "");
|
||||
(lmax < 10) ? 4 : (lmax == 100) ? 6
|
||||
: 5,
|
||||
(server->server->users * 100.0 / irccounts.clients), "");
|
||||
|
||||
list_for_each_entry(acptr, &global_server_list, client_node)
|
||||
{
|
||||
@@ -361,8 +358,9 @@ void dump_flat_map(Client *client, Client *server, int length)
|
||||
tbuf[len--] = '-';
|
||||
|
||||
sendnumeric(client, RPL_MAP, buf, acptr->name, tbuf, umax, acptr->server->users,
|
||||
(lmax < 10) ? 4 : (lmax == 100) ? 6 : 5,
|
||||
(acptr->server->users * 100.0 / irccounts.clients), "");
|
||||
(lmax < 10) ? 4 : (lmax == 100) ? 6
|
||||
: 5,
|
||||
(acptr->server->users * 100.0 / irccounts.clients), "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +381,7 @@ CMD_OVERRIDE_FUNC(override_map)
|
||||
|
||||
if (parc < 2)
|
||||
parv[1] = "*";
|
||||
|
||||
|
||||
if (IsOper(client))
|
||||
{
|
||||
CALL_NEXT_COMMAND_OVERRIDE();
|
||||
@@ -417,14 +415,14 @@ CMD_OVERRIDE_FUNC(override_map)
|
||||
longest = 60;
|
||||
longest += 2;
|
||||
|
||||
if (FLAT_MAP && !ValidatePermissionsForPath("server:info:map:real-map",client,NULL,NULL,NULL))
|
||||
if (FLAT_MAP && !ValidatePermissionsForPath("server:info:map:real-map", client, NULL, NULL, NULL))
|
||||
dump_flat_map(client, &me, longest);
|
||||
else
|
||||
dump_map(client, &me, "*", 0, longest);
|
||||
|
||||
avg_users = irccounts.clients * 1.0 / irccounts.servers;
|
||||
sendnumeric(client, RPL_MAPUSERS, irccounts.servers, (irccounts.servers > 1 ? "s" : ""), irccounts.clients,
|
||||
(irccounts.clients > 1 ? "s" : ""), avg_users);
|
||||
(irccounts.clients > 1 ? "s" : ""), avg_users);
|
||||
sendnumeric(client, RPL_MAPEND);
|
||||
}
|
||||
|
||||
@@ -451,16 +449,16 @@ CMD_OVERRIDE_FUNC(override_links)
|
||||
list_for_each_entry(acptr, &global_server_list, client_node)
|
||||
{
|
||||
/* Some checks */
|
||||
if (HIDE_ULINES && IsULine(acptr) && !ValidatePermissionsForPath("server:info:map:ulines",client,NULL,NULL,NULL))
|
||||
if (HIDE_ULINES && IsULine(acptr) && !ValidatePermissionsForPath("server:info:map:ulines", client, NULL, NULL, NULL))
|
||||
continue;
|
||||
if (FindHiddenServer(acptr->name))
|
||||
continue;
|
||||
if (flat)
|
||||
sendnumeric(client, RPL_LINKS, acptr->name, me.name,
|
||||
1, (acptr->info[0] ? acptr->info : "(Unknown Location)"));
|
||||
1, (acptr->info[0] ? acptr->info : "(Unknown Location)"));
|
||||
else
|
||||
sendnumeric(client, RPL_LINKS, acptr->name, acptr->uplink ? acptr->uplink->name : me.name,
|
||||
acptr->hopcount, (acptr->info[0] ? acptr->info : "(Unknown Location)"));
|
||||
acptr->hopcount, (acptr->info[0] ? acptr->info : "(Unknown Location)"));
|
||||
}
|
||||
|
||||
sendnumeric(client, RPL_ENDOFLINKS, "*");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user