Browse Source

Merge branch 'unrealircd:unreal60_dev' into piss60

piss60
angryce 2 months ago committed by GitHub
parent
commit
8802fcaec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      doc/RELEASE-NOTES.md
  2. 20
      doc/conf/examples/example.conf
  3. 20
      src/api-extban.c
  4. 2
      src/misc.c
  5. 6
      src/modules/chghost.c
  6. 4
      src/modules/mode.c
  7. 10
      src/modules/oper.c
  8. 47
      src/modules/restrict-commands.c
  9. 1
      src/modules/sethost.c
  10. 1
      src/modules/vhost.c
  11. 5
      src/user.c

1
doc/RELEASE-NOTES.md

@ -42,6 +42,7 @@ Enhancements:
class clients;
maxperip 128;
}
// Not working yet (work in progress):
except ban {
mask { security-group irccloud; }
type { blacklist; connect-flood; handshake-data-flood; }

20
doc/conf/examples/example.conf

@ -481,14 +481,18 @@ set {
*/
restrict-commands {
list {
connect-delay 60;
exempt-identified yes;
exempt-reputation-score 24;
except {
connect-time 60; /* after 60 seconds you can use LIST */
identified yes; /* or immediately, if you are identified to services */
reputation-score 24; /* or if you have a reputation score of 24 or more */
}
}
invite {
connect-delay 120;
exempt-identified yes;
exempt-reputation-score 24;
except {
connect-time 120;
identified yes;
reputation-score 24;
}
}
/* In addition to the ability to restrict any command,
* such as shown above. There are also 4 special types
@ -497,10 +501,10 @@ set {
* They are commented out (disabled) in this example:
*/
//private-message {
// connect-delay 10;
// except { connect-delay 10; }
//}
//private-notice {
// connect-delay 10;
// except { connect-delay 10; }
//}
}
}

20
src/api-extban.c

@ -126,6 +126,7 @@ static void extban_add_sorted(Extban *n)
Extban *ExtbanAdd(Module *module, ExtbanInfo req)
{
Extban *e;
ModuleObject *banobj;
int existing = 0;
if (!req.name)
@ -200,8 +201,7 @@ Extban *ExtbanAdd(Module *module, ExtbanInfo req)
return e;
} else
{
if (module)
module->errorcode = MODERR_EXISTS;
module->errorcode = MODERR_EXISTS;
return NULL;
}
}
@ -222,16 +222,16 @@ Extban *ExtbanAdd(Module *module, ExtbanInfo req)
e->is_banned_events = req.is_banned_events;
e->owner = module;
e->options = req.options;
if (module->flags == MODFLAG_NONE)
e->preregistered = 1;
if (module)
{
ModuleObject *banobj = safe_alloc(sizeof(ModuleObject));
banobj->object.extban = e;
banobj->type = MOBJ_EXTBAN;
AddListItem(banobj, module->objects);
module->errorcode = MODERR_NOERROR;
}
banobj = safe_alloc(sizeof(ModuleObject));
banobj->object.extban = e;
banobj->type = MOBJ_EXTBAN;
AddListItem(banobj, module->objects);
module->errorcode = MODERR_NOERROR;
set_isupport_extban();
return e;
}

2
src/misc.c

@ -1115,7 +1115,7 @@ const char *namevalue_nospaces(NameValuePrioList *n)
return "";
if (!n->value)
strlcpy(buf, n->name, sizeof(n->name));
strlcpy(buf, n->name, sizeof(buf));
snprintf(buf, sizeof(buf), "%s:%s", n->name, n->value);

6
src/modules/chghost.c

@ -231,6 +231,9 @@ void _userhost_changed(Client *client)
if (HasCapabilityFast(client, CAP_CHGHOST))
sendto_one(client, NULL, "%s", buf);
if (MyUser(client))
sendnumeric(client, RPL_HOSTHIDDEN, GetHost(client));
/* A userhost change always generates the following network traffic:
* server to server traffic, CAP "chghost" notifications, and
* possibly PART+JOIN+MODE if force-rejoin had work to do.
@ -338,7 +341,4 @@ CMD_FUNC(cmd_chghost)
safe_strdup(target->user->virthost, parv[2]);
userhost_changed(target);
if (MyUser(target))
sendnumeric(target, RPL_HOSTHIDDEN, parv[2]);
}

4
src/modules/mode.c

@ -1307,8 +1307,6 @@ CMD_FUNC(_cmd_umode)
/* Notify */
userhost_changed(client);
if (MyUser(client))
sendnumeric(client, RPL_HOSTHIDDEN, client->user->virthost);
}
/* -x */
@ -1322,8 +1320,6 @@ CMD_FUNC(_cmd_umode)
/* Notify */
userhost_changed(client);
if (MyUser(client))
sendnumeric(client, RPL_HOSTHIDDEN, client->user->realhost);
}
/*
* If I understand what this code is doing correctly...

10
src/modules/oper.c

@ -74,14 +74,18 @@ void set_oper_host(Client *client, const char *host)
client->id, client->user->username);
host = p;
}
iNAH_host(client, host);
SetHidden(client);
safe_strdup(client->user->virthost, host);
if (MyConnect(client))
sendto_server(NULL, 0, 0, NULL, ":%s SETHOST :%s", client->id, client->user->virthost);
client->umodes |= UMODE_SETHOST|UMODE_HIDE;
}
int _make_oper(Client *client, const char *operblock_name, const char *operclass, ConfigItem_class *clientclass, long modes, const char *snomask, const char *vhost)
{
long old_umodes = client->umodes & ALL_UMODES;
userhost_save_current(client);
/* Put in the right class (if any) */
if (clientclass)
{
@ -109,6 +113,8 @@ int _make_oper(Client *client, const char *operblock_name, const char *operclass
safe_strdup(client->user->virthost, client->user->cloakedhost);
}
userhost_changed(client);
unreal_log(ULOG_INFO, "oper", "OPER_SUCCESS", client,
"$client.details is now an IRC Operator [oper-block: $oper_block] [operclass: $operclass]",
log_data_string("oper_block", operblock_name),

47
src/modules/restrict-commands.c

@ -32,11 +32,7 @@ struct RestrictedCommand {
RestrictedCommand *prev, *next;
char *cmd;
char *conftag;
long connect_delay;
int exempt_identified;
int exempt_reputation_score;
int exempt_webirc;
int exempt_tls;
SecurityGroup *except;
};
typedef struct {
@ -103,6 +99,7 @@ MOD_UNLOAD()
next = rcmd->next;
safe_free(rcmd->conftag);
safe_free(rcmd->cmd);
free_security_group(rcmd->except);
DelListItem(rcmd, RestrictedCommandList);
safe_free(rcmd);
}
@ -170,6 +167,11 @@ int rcmd_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
continue;
}
if (!strcmp(cep2->name, "except"))
{
test_match_block(cf, cep2, &errors);
}
if (!cep2->value)
{
config_error("%s:%i: blank set::restrict-commands::%s:%s without value", cep2->file->filename, cep2->line_number, cep->name, cep2->name);
@ -260,38 +262,45 @@ int rcmd_configrun(ConfigFile *cf, ConfigEntry *ce, int type)
rcmd = safe_alloc(sizeof(RestrictedCommand));
safe_strdup(rcmd->cmd, cmd);
safe_strdup(rcmd->conftag, conftag);
rcmd->except = safe_alloc(sizeof(SecurityGroup));
for (cep2 = cep->items; cep2; cep2 = cep2->next)
{
if (!strcmp(cep2->name, "except"))
{
conf_match_block(cf, cep2, &rcmd->except);
}
if (!cep2->value)
continue;
if (!strcmp(cep2->name, "connect-delay"))
{
rcmd->connect_delay = config_checkval(cep2->value, CFG_TIME);
rcmd->except->connect_time = config_checkval(cep2->value, CFG_TIME);
continue;
}
if (!strcmp(cep2->name, "exempt-identified"))
{
rcmd->exempt_identified = config_checkval(cep2->value, CFG_YESNO);
rcmd->except->identified = config_checkval(cep2->value, CFG_YESNO);
continue;
}
if (!strcmp(cep2->name, "exempt-webirc"))
{
rcmd->exempt_webirc = config_checkval(cep2->value, CFG_YESNO);
rcmd->except->webirc = config_checkval(cep2->value, CFG_YESNO);
continue;
}
if (!strcmp(cep2->name, "exempt-tls"))
{
rcmd->exempt_tls = config_checkval(cep2->value, CFG_YESNO);
rcmd->except->tls = config_checkval(cep2->value, CFG_YESNO);
continue;
}
if (!strcmp(cep2->name, "exempt-reputation-score"))
{
rcmd->exempt_reputation_score = atoi(cep2->value);
rcmd->except->reputation_score = atoi(cep2->value);
continue;
}
}
@ -305,15 +314,7 @@ int rcmd_canbypass(Client *client, RestrictedCommand *rcmd)
{
if (!client || !rcmd)
return 1;
if (rcmd->exempt_identified && IsLoggedIn(client))
return 1;
if (rcmd->exempt_webirc && moddata_client_get(client, "webirc"))
return 1;
if (rcmd->exempt_tls && IsSecureConnect(client))
return 1;
if (rcmd->exempt_reputation_score > 0 && (GetReputation(client) >= rcmd->exempt_reputation_score))
return 1;
if (rcmd->connect_delay && client->local && (TStime() - client->local->creationtime >= rcmd->connect_delay))
if (user_allowed_by_security_group(client, rcmd->except))
return 1;
return 0;
}
@ -351,11 +352,11 @@ int rcmd_block_message(Client *client, const char *text, SendType sendtype, cons
if (rcmd && !rcmd_canbypass(client, rcmd))
{
int notice = (sendtype == SEND_TYPE_NOTICE ? 1 : 0); // temporary hack FIXME !!!
if (rcmd->connect_delay)
if (rcmd->except->connect_time)
{
ircsnprintf(errbuf, sizeof(errbuf),
"You cannot send %ss to %ss until you've been connected for %ld seconds or more",
(notice ? "notice" : "message"), display, rcmd->connect_delay);
(notice ? "notice" : "message"), display, rcmd->except->connect_time);
} else {
ircsnprintf(errbuf, sizeof(errbuf),
"Sending of %ss to %ss been disabled by the network administrators",
@ -382,11 +383,11 @@ CMD_OVERRIDE_FUNC(rcmd_override)
rcmd = find_restrictions_bycmd(ovr->command->cmd);
if (rcmd && !rcmd_canbypass(client, rcmd))
{
if (rcmd->connect_delay)
if (rcmd->except->connect_time)
{
sendnumericfmt(client, ERR_UNKNOWNCOMMAND,
"%s :You must be connected for at least %ld seconds before you can use this command",
ovr->command->cmd, rcmd->connect_delay);
ovr->command->cmd, rcmd->except->connect_time);
} else {
sendnumericfmt(client, ERR_UNKNOWNCOMMAND,
"%s :This command is disabled by the network administrator",

1
src/modules/sethost.c

@ -143,7 +143,6 @@ CMD_FUNC(cmd_sethost)
if (MyConnect(client))
{
sendto_one(client, NULL, ":%s MODE %s :+xt", client->name, client->name);
sendnumeric(client, RPL_HOSTHIDDEN, vhost);
sendnotice(client,
"Your nick!user@host-mask is now (%s!%s@%s) - To disable it type /mode %s -x",
client->name, client->user->username, vhost,

1
src/modules/vhost.c

@ -157,7 +157,6 @@ CMD_FUNC(cmd_vhost)
for (s = vhost->swhois; s; s = s->next)
swhois_add(client, "vhost", -100, s->line, &me, NULL);
}
sendnumeric(client, RPL_HOSTHIDDEN, vhost->virthost);
sendnotice(client, "*** Your vhost is now %s%s%s",
vhost->virtuser ? vhost->virtuser : "",
vhost->virtuser ? "@" : "",

5
src/user.c

@ -69,11 +69,9 @@ void iNAH_host(Client *client, const char *host)
safe_strdup(client->user->virthost, host);
if (MyConnect(client))
sendto_server(NULL, 0, 0, NULL, ":%s SETHOST :%s", client->id, client->user->virthost);
client->umodes |= UMODE_SETHOST;
client->umodes |= UMODE_SETHOST|UMODE_HIDE;
userhost_changed(client);
sendnumeric(client, RPL_HOSTHIDDEN, client->user->virthost);
}
/** Convert a user mode string to a bitmask - only used by config.
@ -814,6 +812,7 @@ void free_security_group(SecurityGroup *s)
free_entire_name_list(s->exclude_security_group);
free_nvplist(s->extended);
free_nvplist(s->exclude_extended);
free_nvplist(s->printable_list);
safe_free(s);
}

Loading…
Cancel
Save