1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-01 01:06:38 +02:00
Commit Graph

3235 Commits

Author SHA1 Message Date
Bram Matthys 08fb2b46ac Fix crash with "STATS S" if having vhosts with autologin (no login).
This crash is only triggerable by IRCOps.

Also, it shouldn't lists vhosts with "STATS S", it should be "STATS V".
2024-11-17 08:03:32 +01:00
Bram Matthys 6d60899007 Good idea to bump the vhost module version to 6.1.8.1
[skip ci]
2024-10-17 18:22:16 +02:00
Bram Matthys 019c327821 Fix crash with new auto-vhost code. 2024-10-17 17:44:50 +02:00
Bram Matthys 985a591df2 Previous commit broke "GLINE *@1.2.3.4 0 test" and had a memory leak.
The former was fixed by merging the 'if'. The latter by getting rid
of dynamic memory allocation, long live the stack!
2024-10-16 10:21:16 +02:00
Valerie Liu 8e47aff2cf Make *LINE behave smarter if missing reason or time value (#304)
Now this works like:
if the time param exists, even without a reason, it will be checked if it's a time param. if it's not a time param, it'll be considered to be the reason (or the first part of it anyway)

Reported by PeGaSuS in https://bugs.unrealircd.org/view.php?id=6105
2024-10-16 08:01:12 +00:00
Bram Matthys cf6718fdb2 Fix vhosts and blacklist reasons being lowercased
This was unintentional strtolower() in unreal_expand_string()
2024-10-14 18:56:21 +02:00
Bram Matthys c86b474ed8 Fix crash on crule "||"; in config file.
Reported by Valware in https://bugs.unrealircd.org/view.php?id=6438
2024-09-25 13:04:30 +02:00
Bram Matthys eae680c773 Update release notes a bit
... and make set::max-inherit-extended-bans::ban-exception default to 0
because that functionality is not implemented
The +e's are already checked when using +b ~inherit though..
2024-09-25 10:14:46 +02:00
Valerie Liu fff76c4b29 Make authprompt work with recently new "sasl-from-a-module" hooks (#302) 2024-09-25 07:15:31 +00:00
Bram Matthys 7a43448674 Add unrl_utf8_make_valid() special option 2 to fix previous commit.
Without this, the IRC message could be far beyond >510 characters
(excluding message tags).

This code is untested!
2024-09-24 18:32:14 +02:00
Valerie Liu 713414e716 Websockets with type 'text': don't truncate lines to 510 chars when there are message tags (#301)
Allow full mtag messages to be sent over websockets
2024-09-24 16:30:02 +00:00
Bram Matthys 5860172780 Free previous GeoIP result upon IP change. Otherwise if the new geoip
lookup fails the old result stays there which is confusing.

Reported on IRC where 10.x.x.x was shown as "Poland" which was a
leftover from the "real IP" before WEBIRC spoofing was used to set
the IP to 10.x.x.x. Reported by Jellis.
2024-09-23 19:10:33 +02:00
Bram Matthys 7d37795353 Don't list security groups by default, add 'public <yes|no>'
* [Security group blocks](https://www.unrealircd.org/docs/Security-group_block)
  are now hidden in lists by default. If you want the security group to be shown
  in things like `MODE #channel +b ~security-group:x` (which shows a list)
  then you need to use `public yes;`. The default security groups
  like known-users, webirc-users, etc. are public by default.
2024-09-23 13:11:24 +02:00
Bram Matthys afbb0c283b Accept multiple masks in ban ip { } and ban nick { } such as:
ban ip {
	mask { 1.1.1.1; 2.2.2.2; 3.3.3.3; }
	reason "Go away";
}

Or the alternate form:

ban ip {
	mask 1.1.1.1;
	mask 2.2.2.2;
	mask 3.3.3.3;
	reason "Go away";
}

Suggested by magic000 in https://bugs.unrealircd.org/view.php?id=4599

Note that this is not a Mask item, these are special, hence the
special code.
2024-09-23 12:29:35 +02:00
Bram Matthys 7dc3c230a7 Now that we support $variables, add set::oper-vhost so you can set a default
vhost for opers, such as: set { oper-vhost $operclass.admin.example.net; }

If the oper has an oper::vhost then that one will override.

https://www.unrealircd.org/docs/Set_block#set::oper-vhost
2024-09-20 17:54:39 +02:00
Bram Matthys 9a2d54cd01 Support $variables in oper::vhost (for variables see previous commit)
Eg: vhost "$operlogin@$operclass.example.net";

Also add potentially_valid_vhost() function which can be used in
config code to ignore invalid $vars. Then at runtime you use the
real valid_vhost() function after variable expansion by
unreal_expand_string().
2024-09-20 17:26:16 +02:00
Bram Matthys 4557036cd6 Move unreal_expand_string() to an efunc so all code can access it
and use it not only from vhost { } block code but also for like
blacklist::reason.

This so the same variables with the same names are available at
those places.

Supported are:
$nick, $username, $realname, $ip, $hostname, $server, $account,
$operlogin, $operclass, $country_code (xx for unknown),
$asn (0 for unknown).
2024-09-20 17:13:23 +02:00
Bram Matthys 60c0ab8da2 Make vhost::vhost support $variables. Currently supported are:
$nick, $username, $realname, $ip, $account, $operlogin, $operclass,
$country_code (xx for unknown), $asn (0 for unknown).

Note that if a $variable fails to expand, eg $operlogin but the
user is not oper, then the vhost will not be applied. A warning
is sent to the vhost snomask (+s +v) in such a case.

Examples:

/* Set authenticated users to $account.example.org */
vhost { auto-login yes; vhost $account.example.org; mask { identified yes; } }

/* Obviously not really a good idea, but.. to illustrate: */
vhost { auto-login yes; vhost $country_code.example.org; mask *; }

Also, when vhost { } blocks are read and need to be matched, they
are read top-down now, which is the most logical way. First match wins.

All this needs testing :)
2024-09-20 16:48:22 +02:00
Bram Matthys e9ffe5b5e7 Add vhost::auto-login: checks on-connect if user meets ::mask criteria
and if so, it sets the vhost on the user. Except when the user already
has a vhost (eg from anope during SASL).
If vhost::auto-login is 'yes' then you don't need ::login and ::password.

Suggested by PeGaSuS.

Support for variables like $account in vhost::vhost, more examples and
a release notes entry will follow in later commit(s).
2024-09-20 15:43:55 +02:00
Bram Matthys 55c04d9887 vhost: move struct as well, reorder and document. 2024-09-20 14:51:50 +02:00
Bram Matthys fe751fdc9d Move all vhost { } block handling to vhost module.
* Convert to use module-based config handling
* Split part of VHOST command into do_vhost() for later
* Use AppendListItem instead of AddListItem so they are in config-order.
  This is not really important atm but will matter later if we go auto.
* No other code changes at this point
2024-09-20 14:45:52 +02:00
Bram Matthys 8e8384628b Fix decode_authenticate_plain() reading OOB.
This is a helper function for modules, it is not actually used by
UnrealIRCd itself.
2024-09-18 15:49:53 +02:00
Valerie Liu 71798963e0 rpc/log: Add ability to send log messages via RPC log.send (#299) 2024-09-17 15:40:03 +00:00
Bram Matthys 72c4b718f6 Move remove_dcc_references() to dccallow module. 2024-09-15 17:58:48 +02:00
Bram Matthys c39d763e00 Move 416 lines from src/misc.c to src/modules/quit.c: exit_client() etc.
This so if there is ever an issue, we can hot-patch it. This affects
exit_client(), exit_client_fmt(), exit_client_ex(), banned_client(),
and various (internal) help functions.

This also means you cannot call these functions during TEST/INIT (eg
during REHASH) since the 'quit' module which provides these modules
may not be loaded yet. I don't think that's a situation/problem but
this needs some more testing.
2024-09-15 17:45:25 +02:00
Bram Matthys a41ab32d16 maxperip: use siphash_raw(client->rawip.... 2024-09-14 20:33:57 +02:00
Bram Matthys 2ef39497c7 Similar to previous commit, move maxperip stuff from core to module.
This was in src/hash.c, src/list.c and src/modules/stats.c.
Now all in src/modules/nick.c... or should this go into a new module?

Again, this needs some more testing, like previous commit.
2024-09-14 20:18:22 +02:00
Bram Matthys 710afe7cc7 Move throttling code from src/hash.c to src/modules/connect-flood.c
Better to have this all in one place. Though, must admit, the
config checking is still in src/conf.c and a bit of a hassle to move.

Some testing may be wise to see if everything still works ;)
2024-09-14 19:55:43 +02:00
Bram Matthys ca7e4ab966 Prevent +b ~inherit:#chan in #chan. This didn't cause any problem but
doesn't make any sense either, so just reject it. Reported by alice.
2024-09-14 19:07:15 +02:00
Bram Matthys b6cdca5525 Fix b->ban_type not being set properly at all places (BanContext).
This probably didn't cause any issues earlier, or maybe it did
with some 3rd party mods, but is relevant now that we have ~inherit.
2024-09-09 16:44:57 +02:00
Bram Matthys 10ec67d163 Fix +I ~inherit:#chan (invite exceptions) 2024-09-09 16:28:22 +02:00
Valerie Liu 879e365ed5 extbans/partmsg.c: Actually check if there's a matching ban before removing the part message (#295) 2024-09-08 16:52:01 +00:00
Bram Matthys 3c1ef65a00 Add set::max-inherit-extended-bans to configure limits for ~inherit extban:
Looks like this, with the current defaults:
set {
        max-inherit-extended-bans {
                ban 1;
                ban-exception 1;
                invite-exception 1;
        }
}
2024-09-08 17:15:26 +02:00
Valerie Liu ae8b039831 Fix $nick log string in debug message re spamfilter tag (#294) 2024-09-08 14:37:26 +00:00
Bram Matthys c4c72ecaca Fix spamfilter.get unable to retrieve config-based spamfilters.
Reported in https://bugs.unrealircd.org/view.php?id=6467 by adator.
2024-09-08 10:16:15 +02:00
Bram Matthys ee1d6818b4 Add +b/+e/+I ~inherit:#channel to inherit channel bans from another channel
Several notes:
* This only checks on-JOIN (not on nick change, message, etc)
  for performance reasons
* If the #channel in ~inherit:#channel also contains ~inherit
  entries then those are not processed (no recursion and no looping)
* Only a limited number of ~inherit entries is permitted.
  This will be moved to set:: items in a future commit so you
  can set different amounts for +b/+e/+I ~inherit.
* This is work in progress, UnrealIRCd or the entire world could explode
* Documentation will follow later

Developers:
* Sadly, clean_ban_mask() needed to be changed to have two more
  parameters, 'ban_type' and 'channel' were added at different positions.
  This because the module needs the ban type (EXBTYPE_BAN, EXBTYPE_EXCEPT,
  EXBTYPE_INVEX) and channel because it rejects based on number of
  existing ~inherit entries in the channel... and while is_ok() is called
  for local clients and has all this information, for services clients
  is_ok() is not called so the only way to reject the +beI is through
  xxx_conv_param() which comes from clean_ban_mask().
2024-09-07 21:02:15 +02:00
Bram Matthys e17e11dd73 Make "MD" S2S command support BIGLINES. We don't need it now but maybe
in the future we will, or some third party module. And then it would
be nice if all servers on the IRC network support it, of course.
2024-09-05 20:06:58 +02:00
Bram Matthys 99bc061a74 Fix require authentication { } not allowing SASL users in.
It was behaving like a ban user { } block.

Reported by Jellis in https://bugs.unrealircd.org/view.php?id=6464
2024-08-30 20:01:20 +02:00
Bram Matthys 5092fa985d Central Blocklist: fix issue with clients being killed if too slow.
We already allow users in after 10 seconds if CBL is too slow, and
that part worked correctly. However 5 seconds later, when the URL
API 15 second timeout hits, it would try to allow the user in AGAIN.
This caused the user to be introduced twice, causing remote servers
to kill the user, and also screwing up user counts.

Reported by multiple people, including Jellis who actually filed
a report with logs, and alice providing logs as well, all when CBL
was temporarily down for a few hours in August 2024. In hindsight
this bug was already reported by k4be back in November 2023 but
was more rare at the time and mistaken for another very similar
bug that was fixed in 6.1.3.

With this patch, we check before we call cbl_allow(), but also
cbl_allow() itself checks the "user already allowed in?".

Oh yeah and this is hot patchable, within the hour I will make
this work: ./unrealircd hot-patch cbl-timeout-fix
2024-08-20 13:29:08 +02:00
Bram Matthys 4f3e524602 Add function set_client_ip() and call HOOKTYPE_IP_CHANGE there if needed.
This to replace the scattered IP setting. It is very important to always
use set_client_ip() from this point. Everywhere!

Also, in addition to client->ip, this adds client->rawip that contains
the IP in network byte order. In older UnrealIRCd versions we always had
the raw IP but not the IP as a string, so we moved to IP as a string,
but it can be useful to have both in terms of optimizations.
Of course, then the client->ip and client->rawip always need to 100% match,
hence the set_client_ip().

This also changes IsIPV6() to do A BUGFIX, it changes it from:
* if local user is the user connected over IPv6? Otherwise, does it have ':' in the IP?
To:
* check if the IPv6 flag is set (which is set if IP contains ':')
This may seem insignificant but it means that for spoofed IP addresses,
such as WEBIRC or transparant proxy, we use the correct transport.
Previously, if the proxy was IPv6 then even if the spoofed user was using
IPv4, the ident check would still be tried over IPv6. That sort of fun.
From now in, in such a situation client->local->socket_type will be
SOCKET_TYPE_IPV6 but since client->ip (and rawip) will contain IPv4
the IsIPV6() will actually return false, as it should be.

Also, in the HOOKTYPE_IP_CHANGE, enforce that if HOOK_DENY is returned,
the the user is killed by dead_link(). The user must be killed because
that is what we expect, and you cannot use exit_client() because from
some code paths that would be too much freed structures / hassle,
as a comment in src/modules/connect-flood.c correctly states:
/* 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 ->
 *    webserver_handle_request_header -> webserver_handle_request ->
 *    RunHook().... and then returning without touching anything
 *    after an exit_client() would not be feasible.
 * 2) Because in HOOKTYPE_ACCEPT we always need to use dead_socket
 *    if we want to print a friendly message to TLS users.
 */
2024-07-20 12:22:26 +02:00
Bram Matthys 9232db12ae Remove an annoying BLACKLIST_RESOLVER_CALLBACK message in DEBUGMODE
[skip ci]
2024-07-18 08:00:06 +02:00
Bram Matthys 5ad5c4cfe2 JSON-RPC whowas.get: add geoip object with country_code, asn and asname.
(only if the information is available, of course)
2024-07-17 17:15:10 +02:00
Bram Matthys 5c810d0c63 In WHOWAS also show country and ASN information to IRCOps 2024-07-17 17:03:49 +02:00
Bram Matthys cabd7c1ede Fix memory leak in rpc-user::rpc-class (at least this one is small) 2024-07-16 09:33:45 +02:00
Bram Matthys 34d23c8b5c Fix memory leak in ASN code
Contrary to retrieving country code / country name, the AS organisation
name that was returned needs to be freed by *US*. Makes sense, though
a bit inconsistent, heh.

[skip ci]
2024-07-16 09:32:25 +02:00
k4be e950bb53bc Add ASN support for geoip_maxmind 2024-07-15 19:22:48 +02:00
Bram Matthys f6b448df2c Fix error with ASN lookups for IPv6
This line should not be here, it is for country lookups (also wasn't
there for IPv4, which actually does work)

[skip ci]
2024-07-13 07:48:34 +02:00
Bram Matthys 3efc62fc75 Allow +b ~operclass:xyz checking against remote users too.
Yeah not really important except for like SVSMODE -b nick, which
removes all bans that affect nick. That's the only type of code
that runs bans against external users.
2024-07-12 20:31:56 +02:00
Bram Matthys 1b4f987ab7 Move displaying of ASN in WHOIS to separate RPL_WHOISASN (569)
This is the numeric that the inspircd third party module uses
https://github.com/inspircd/inspircd-contrib/blob/master/4/m_asn.cpp
and it does not seem taken at
https://defs.ircdocs.horse/defs/numerics.html or
https://www.alien.net.au/irc/irc2numerics.html

This also means AS displaying is now separately configured via
set::whois-details::asn. By default only IRCOps can see it.
2024-07-12 12:17:39 +02:00
Bram Matthys da6cf4f6fa Add crule function match_asn(64496) 2024-07-12 11:37:18 +02:00