1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-12 17:14:46 +02:00
Commit Graph

199 Commits

Author SHA1 Message Date
Bram Matthys e5be93a9f8 Suppress high rate events via set::log-throttle (similar to Linux kernel)
And ship with these by default (no need to copy this set block):

set {
	log-throttle {
		CONNTHROTTLE_IPV6_LIMIT 100:60;
		MAXPERIP_LIMIT 100:60;
	};
};

You can do the same for other events, or even override existing ones,
and use the special value "unlimited" to turn default set ratelimits off:

set {
	log-throttle {
		CONNTHROTTLE_IPV6_LIMIT 50:60;
		MAXPERIP_LIMIT unlimited;
	};
};

Suggested in 2020 at https://bugs.unrealircd.org/view.php?id=5523
(and keeping it simple)
2026-05-05 19:07:42 +02:00
Bram Matthys 0940ed5d13 Update the messages regarding too many (new) connections.
Changed "Too many connections from your IP" to have "[maxperip]" at the end.
Also create new setting and swap it with existing-one-during-development.

Long story short, we now have 3 different messages for these limits:

set::reject-message::too-many-connections
 "Too many connections from your IP [maxperip]"

set::reject-message::too-many-connections-ipv6-range
 "Too many connections from your IPv6 range ($prefix_addr/$prefix_len) [maxperip]"

set::reject-message::too-many-new-connections-ipv6-range
 "Too many new connections from this IPv6 range ($prefix_addr/$prefix_len) [connthrottle]"

So we explicitly mention whether it is maxperip or connthrottle limiting the
user, that should provide enough clue to the IRCOp if the user pastes the
message to them.
2026-05-05 13:24:01 +02:00
Bram Matthys 2ae69be391 Implement IPv6 CIDR restrictions for unknown-users
Will do more in follow-up commits.
2026-05-05 10:03:25 +02:00
Bram Matthys 3a96bdf6ec Add set::allow-setident (default: 'no'), set::allow-setname ('yes')
Two new settings that control the use of `SETIDENT` and `SETNAME`:
* [set::allow-setident](https://www.unrealircd.org/docs/Set_block#set::allow-setident)
  now defaults to 'no'. Previously all users were allowed to change their
  ident (taking into account
  [set::allow-userhost-change](https://www.unrealircd.org/docs/Set_block#set::allow-userhost-change)
  restrictions).
* [set::allow-setname])(https://www.unrealircd.org/docs/Set_block#set::allow-setname)
  has a default of 'yes' which matches older UnrealIRCd versions (no change).
  Perhaps some admins who use controlled (web)chats may want to set this
  to 'no' if users are not supposed to change their realname/gecos.
  This is probably rare, but they have the option now.
2026-02-23 08:58:39 +01:00
Bram Matthys 19d17832fe Remove set::restrict-extendedbans as it didn't work. Simply don't load
the particular extended ban module if you don't want it.

For example, if you include the default modules.default.conf and, say,
you don't want ~quiet extbans then you add this in your unrealircd.conf:

blacklist-module "extbans/quiet";
2026-02-22 13:07:57 +01:00
Bram Matthys 68f01814be Some minor updates to previous.
* We try to keep the dynconf variables the same name as in the conf
  (well, with hyphens to underscores, and there are some exceptions)
* Remove unnecessary but otherwise harmless second safe_free()
* The URL could have been too long. It is now limited to 360 characters,
  which should be plenty.
2025-11-12 10:14:27 +01:00
Valerie Liu 557595fd1c Implement IRCv3 network icon support (PR #326)
set { network-icon 'https://...........'; }
https://ircv3.net/specs/extensions/network-icon
2025-11-12 10:01:42 +01:00
Bram Matthys f22f8d0dcd Add set::utf8-only: if set to 'yes' this means all IRC traffic is UTF only.
See https://www.unrealircd.org/docs/Set_block#set::utf8-only and the
UTF8ONLY specification at https://ircv3.net/specs/extensions/utf8-only
for more information.

Reported by PeGaSuS, who reported it based on a #unreal-support message
from uMut, who reported it based on a message from itsonlybinary.
This closes https://bugs.unrealircd.org/view.php?id=6458

This feature still needs to go through our internal tests.
2025-09-20 09:00:52 +02:00
Bram Matthys 74538e77d4 Another best practices fix: this one is with listen-nontls-port.
It could cause a spurious
"Your config has NO errors, but you received some best practices tips above, in summary"
even though no best practices were displayed... which was a bit mysterious.

Also, ::listen-nontls-port was actually meant to be called ::listen-tls-only
so accept both forms from now on. The reason it was supposed to be like that
is that all best-practices options are... best practices...
hashed passwords, trusted cert, trusted cert with valid hostname,
listening on a nontls port... ? NOPE! listen-tls-only! Aaaaa.
2025-09-10 16:45:52 +02:00
Bram Matthys 84a1e59a44 Best practices: check if the certificate is actually valid for me::name.
That is, if the set::best-practices::trusted-cert check is on and passed
("certificate is valid and issued by a trusted CA") then we also
do this new set::best-practices::trusted-cert-valid-hostname check:

/* If the trusted-cert check passes, then we do another check to see if
 * the certificate is valid for me::name. Since users usually connect to your
 * server by your server name it is important for the certificate to be
 * valid for that name. Unless you really only care about e.g. irc.example.net,
 * and not about individual irc2.example.net server names, in which case you
 * can turn this off, but not sure if that is good practice.
 */
trusted-cert-valid-hostname yes;
2025-07-28 09:55:01 +02:00
Bram Matthys 990fe22e64 Print a best practices message if any plaintext port is open (eg 6667).
Ports that listen on 127.0.0.1 or ::1 are ignored (useful for e.g. services)

Looks like this:
[info] You have at least one IRC plaintext port open (such as 5668). Nowadays, everyone should be using SSL/TLS (on port 6697). See https://www.unrealircd.org/docs/Use_TLS.

See that https://www.unrealircd.org/docs/Use_TLS for more info (feedback welcome)

All this is in addition to somewhat related 29ce0ce29a:
[info] Your SSL/TLS certificate is not issued by a trusted Certificate Authority.
[info] It is highly recommended to use a 'real certificate'. To get a free one, see: https://www.unrealircd.org/docs/Using_Let's_Encrypt_with_UnrealIRCd

If applicable, that message is printed first, the 6667 one comes after ;)

Suggested in https://bugs.unrealircd.org/view.php?id=6500
and numerous times / discussions on IRC over the past years
It's finally time.. no.. it's overdue..
2025-07-26 16:02:33 +02:00
Bram Matthys 29ce0ce29a Best Practices: If zero SSL/TLS certs are issued by a trusted CA, complain and
suggest to use Let's Encrypt.

This can be turned off via set::best-practices::trusted-cert, see
https://www.unrealircd.org/docs/Set_block#set::best-practices

Oh yeah, and this only works at OpenSSL 1.1.0 and higher, i didn't bother
with people running ancient versions.
2025-07-13 09:26:54 +02:00
Bram Matthys ba8c587e44 Update to previous commit: disable by default, enable via set { send-isupport-updates yes; }
I totally agree with the goal to have this enabled, but let's do some more
testing with more clients first to see if they misbehave. Last thing I want
is a similar situation to when we were the first IRCd that sent "CAP DEL sasl"
and "CAP NEW sasl" when services went offline and online and it caused all
mIRC clients to reconnect. I don't expect this one to be so bad (also because
users would get the 005's when they typed /VERSION) but... let's test to be sure.

Should probably deploy this with enabled on irc.unrealircd.org and such :)
2025-07-06 09:28:38 +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 9cc2918d5f Make set::spamfilter::except a Mask item
* [set::spamfilter::except](https://www.unrealircd.org/docs/Set_block#set::spamfilter::except)
  is now a [Mask item](https://www.unrealircd.org/docs/Mask_item) instead of
  only a list of exempted targets. A warning is created to existing users
  along with a suggestion of how to use the new syntax. Technically, this is
  not really new functionality as all this was already possible via
  the [Except ban block](https://www.unrealircd.org/docs/Except_ban_block)
  with type spamfilter, but it is more visible/logical to have this also.
2024-07-06 10:09:35 +02:00
Bram Matthys a804b24150 Add set::hide-killed-by which shortens the quit to "Killed (Reason)".
* New option [set::hide-killed-by](https://www.unrealircd.org/docs/Set_block#set::hide-killed-by):
  We normally show the nickname of the oper who did the /KILL in the quit message.
  When set to `yes` the quit message becomes shortened to "Killed (Reason)".
  This can prevent oper harassment.

Suggested by PeGaSuS in https://bugs.unrealircd.org/view.php?id=6425
2024-07-06 08:12:11 +02:00
Bram Matthys d85ed7a51f For set::hide-ban-reason add a new option auto and make it the default.
This will hide the *LINE reason to other users if the *LINE contains the
IP of the user. This to protect the privacy of the user for cases such
as a KLINE due to a blacklist with a DroneBL URL.
Other possible settings are `no` (never hide, the previous default) and
`yes` to always hide the *LINE reason. In all cases the user affected by
the server ban can still see the reason and IRCOps too.

https://bugs.unrealircd.org/view.php?id=6362
2023-11-22 14:48:14 +01:00
Bram Matthys a04295c588 Add set::dns and increase DNS timeout for DNSBL (3000ms first, then on retry 6000ms).
This is quite a bit higher than client DNS lookups (1500ms first, on retry 3000ms)
and is because some DNSBL are reported to be quite a bit slower than ordinary DNS.
(Maybe just some, but.. the higher timeout does not hurt anyone anyway)

Note that all this has no effect on client handshake times, as DNSBL checks are
done in the background. Only side-effect is that if we do get a "late hit" then
you may now see a kill a few seconds after the client is online (which was actually
already possible before too for quick clients, but.. yeah...)

These settings can be overriden via set::dns, these are the defaults:

set {
        dns {
                client {
                        timeout 1500;
                        retry 2;
                }
                dnsbl {
                        timeout 3000;
                        retry 2;
                }
        }
}

When you REHASH we will check if the values are different than the current
c-ares settings and if so, reinitialize the resolver. Reinitializing the
resolver will destroy outstanding DNS requests, eg DNS lookups for clients
currently connecting, but so be it. Not a super-huge issue since changing
this is rare.

Requested by BlackBishop in https://bugs.unrealircd.org/view.php?id=6306
2023-10-11 19:04:06 +02:00
Bram Matthys 89e5309326 Add set::central-spamfilter::feed and update the page at
https://www.unrealircd.org/docs/Central_Spamfilter
2023-07-21 12:03:43 +02:00
Bram Matthys cdc14569a9 Warn on plaintext oper::password in conf and even go as far as
generating the password hashes and suggesting using those.

This also starts the initial work on set::best-practices
https://www.unrealircd.org/docs/Set_block#set::best-practices
with hashed-passwords as the first setting there.
2023-07-15 19:02:31 +02:00
Bram Matthys f333aa0c09 New option set::spamfilter::show-message-content-on-hit:
you can now configure to hide the message content in spamfilter hit
messages. Generally it is very useful to see if a spamfilter hit is
correct or not, so the default is 'always', but it also has privacy
implications so there is now this option to disable it.

Suggested by alice, quite a while ago.

https://www.unrealircd.org/docs/Set_block#set::spamfilter::show-message-content-on-hit

Also as mentioned there:
UnrealIRCd has the following spying countermeasure (for many years) to help
that spamfilters are not abused for spying. When a spamfilter hit happens
that has an action like gline or blocking, it is visible to the user that an
action was taken. There is also the action 'warn', which means: take no
action and only warn IRCOps, that one would be easy to use as a spy tool, so
when this happens and message content was revealed, numeric 659
(RPL_SPAMCMDFWD) is sent to the client to indicate that the message is
allowed through but IRCOps were informed.
With this new set::spamfilter::show-message-content-on-hit feature, when
the message content was hidden due to this setting (eg due to 'never' or
'channel-only'), the warn message will not be sent as there is no need to
inform the user in such a case.
2023-07-11 12:11:26 +02:00
Bram Matthys f277880fb3 Add set::central-spamfilter::limit-ban-action and ::limit-ban-time
to limit actions to limit-ban-action as the highest, and limit
ban times to limit-ban-time the highest, see
https://www.unrealircd.org/docs/Central_Spamfilter

This also changes highest_spamfilter_action() to highest_ban_action().
2023-07-11 10:17:51 +02:00
Bram Matthys c18c79e88b Add spamfilter hits and hits for exempted users.
* This means we always run spamfilters, even if users are exempts
* This way we can gather hits for exempted users on individual
  spamfilter entries, and possibly detect false positives
  (which relies on the assumption that those users are innocent)
* The hit counters are shown in in RPL_STATSSPAMF and also
  exposed via the JSON-RCP API.
* This commit also adds set::central-spamfilter::except but more
  on that later since i still want to set a default for that in
  a future commit.
* This also changes take_action() to take flags and adds the
  option TAKE_ACTION_SIMULATE_USER_ACTION which i intended to
  use but didn't in the end... not sure if i should keep it :D
2023-07-10 11:30:51 +02:00
Bram Matthys 1006292681 Initial work on central spamfilter with auto refreshing URL / rules 2023-07-07 18:43:29 +02:00
Bram Matthys 656ea105da First go at multi actions... 2023-07-06 11:51:55 +02:00
Bram Matthys bb419b95d1 Remove set::maxbanlength as it is not useful and only confusing.
https://www.unrealircd.org/docs/Set_block#set::maxbanlength
2023-05-28 20:25:02 +02:00
Bram Matthys 52472a9a88 Add support for set unknown-users { } and the like:
It is now possible to override some set settings per-security group by
having a set block with a name, like `set unknown-users { }`
* You could use this to set more limitations for unknown-users:
  ```
  set unknown-users {
          max-channels-per-user 5;
          static-quit "Quit";
          static-part yes;
  }
  ```
* Or to set higher values (higher than the normal set block)
  for trusted users:
  ```
  security-group trusted-bots {
          account { BotOne; BotTwo; }
  }
  set trusted-bots {
          max-channels-per-user 25;
  }
  ```
* Currently the following settings can be used in a set xxx { } block:
  set::auto-join, set::modes-on-connect, set::restrict-usermodes,
  set::max-channels-per-user, set::static-quit, set::static-part.
2023-05-22 12:07:43 +02:00
Bram Matthys 3652940c2c Add set::anti-flood::<secgroup>::max-channels-per-user setting to override
the default set::max-channels-per-user (also called set::maxchannelsperuser).

This way you can give known-users a higher max-channels-per-user,
or even a special security group for trusted users (that you may
already have given a more lax flood setting and lower lag-penalty
etc. etc. so that fits in nicely)

And yeah this also:
* Makes it both in set and the anti-flood block accept both
  maxchannelsperuser and max-channels-per-user.
* Removes old MAXCHANNELS= in 005, as we already have CHANLIMIT=
This does not:
* Re-announce the 005 CHANLIMIT= if someone transitions from a security
  group with a different max-channels-per-user. We don't do that for
  IRCOps either, and I think no IRCd does that actually...
  To be honest i wonder if sending the limit in 005 is useful at all,
  do client really track this and limit their GUI based on it?? Doubt it!
2023-05-19 21:47:23 +02:00
Bram Matthys f804c5ed65 Add detection and set the high connect rate to 1000 per seconds.
https://www.unrealircd.org/docs/FAQ#hi-conn-rate
This finishes https://bugs.unrealircd.org/view.php?id=5532
2023-05-18 13:15:17 +02:00
Bram Matthys 2c73a37ac7 * New setting set::handshake-boot-delay
https://www.unrealircd.org/docs/Set_block#set%3A%3Ahandshake-boot-delay
  which allows server linking autoconnects to kick in (and incoming
  servers on serversonly ports), before allowing clients in. This
  potentially avoids part of the mess when initially linking on-boot.
  This option is not turned on by default, you have to set it explicitly.
  * This is not a useful feature on hubs, as they don't have clients.
  * It can be useful on client servers, if you `autoconnect` to your hub.
  * If you connect services to a server with clients this can be useful
    as well, especially in single-server setups. You would have to set
    a low `retrywait` in your anope conf (or similar services package)
    of like `5s` instead of the default `60s`.
    Then after an IRCd restart, your services link in before your clients
    and your IRC users have SASL available straight from the start.
2023-05-07 11:21:22 +02:00
Bram Matthys 4b4562516c Another attempt at UTF8-aware spamfilter.
This was previously tried at 19-apr-2020 in bc70882bd3
in UnrealIRCd 5.0.5. Sadly it had to be reverted immediately with a quick 5.0.5.1
release, all because of a PCRE2 100% CPU usage. Since then that bug has been fixed,
plus another bug. I'm now readding it "as an option" that is marked experimental.
Hopefully people test it out and can report back if it works well and then we can
make it the default someday.

This makes it a runtime setting so makes it much easier to switch back/forth if
there are any issues without recompiling anything. Had to use a bit more code now
though to handle the recompiling of spamfilters if the setting is changed.

Original issue was https://bugs.unrealircd.org/view.php?id=5187

* [Spamfilter](https://www.unrealircd.org/docs/Spamfilter) can be made UTF8-aware.
  * This is experimental, to enable: `set { spamfilter { utf8 yes; } }``
  * Case insensitive matches will then work better. For example, with extended
    Latin, a spamfilter on `ę` then also matches `Ę`.
  * Other PCRE2 features such as [\p](https://www.pcre.org/current/doc/html/pcre2syntax.html#SEC5)
    can then be used. For example you can then set a spamfilter with the regex
    `\p{Arabic}` to block all Arabic script.
    Please do use these new tools with care. Blocking an entire language
    or script is quite a drastic measure.
  * As a consequence of this we require PCRE2 10.36 or newer. If your system
    PCRE2 is older than this will mean the UnrealIRCd-shipped-library version
    will be compiled and `./Config` may take a little longer than usual.
2023-03-22 09:00:31 +01:00
Bram Matthys 7d9dcb5e0a Allow SVS* commands to be sent by non-ulined servers by default,
this is needed by various future JSON-RPC calls.
See https://www.unrealircd.org/docs/Set_block#set::limit-svscmds
2023-01-07 14:21:31 +01:00
Bram Matthys 329fd07f3a Revert set::spamfilter::utf8-support from yesterday.
This will be for a later release, needs more thought and work.
2022-01-06 18:03:26 +01:00
Bram Matthys dedff543b5 Add option set::spamfilter::utf8-support which defaults to 'no' for now.
When you set this to 'yes' you get more options...
See next (modified) copy-paste from April 2020, which had to be reverted
because PCRE2 was broken. Now it's an opt-in and hopefully matured a bit.

This means:
* Case insensitive matches work better in UTF8 now, such as extended Latin.
  For example, a spamfilter on "ę" now also matches "Ę", while previously
  it did not catch this.
* Other PCRE2 features such as https://www.pcre.org/current/doc/html/pcre2syntax.html#SEC5
  are now available. For example you can now set a spamfilter with the regex
  \p{Arabic} to block all Arabic script, or
  \p{Cyrillic} to block all Cyrillic script (such as Russian)
  Use these new tools with care, of course. Blocking an entire language,
  or script, is quite a drastic measure.

All of this was possible because of the new PCRE2_MATCH_INVALID_UTF
compile time option which was introduced in PCRE2 10.34. Now, that
version turned out to be buggy. As recent as PCRE 10.36 some major bugs
were fixed. This also means we now require at least PCRE2 10.36 version
so everyone can benefit from this new spamfilter UTF8 feature, IF they
enable set::spamfilter::utf8-support, that is.

Many systems come with older PCRE2 versions so this means we will
fall back to the shipped PCRE2 version in UnrealIRCd. This means
./Config will take a little longer to compile things.

For packagers (rpm/deb/ports): if you choose to patch configure to
not require such a recent PCRE2, then please do not allow enabling
of set::spamfilter::utf8-support since it will likely cause crashes
and misbehavior. Check PCRE2 changelog, CTRL+F at PCRE2_MATCH_INVALID_UTF
2022-01-05 18:08:52 +01:00
Bram Matthys d677ce04de New option set::server-notice-show-event which, if set to 'no', can be used
to hide the event information (eg. connect.LOCAL_CLIENT_CONNECT) in
server notices. This can be overriden in oper::server-notice-show-event.

See https://www.unrealircd.org/docs/Set_block#set::server-notice-show-event
2021-12-30 11:29:30 +01:00
Bram Matthys d74ab4cfb1 Add set::server-notice-colors and oper::server-notice-colors so one
can turn colors in snomask server notices on or off.
2021-11-10 08:22:00 +01:00
Bram Matthys 4cea88645c Modularize member modes (vhoaq).
Still need to clean up a bit after this, but it passes all tests :)
2021-09-13 18:44:18 +02:00
Bram Matthys 9ef1d06afd Remove more unused stuff in dynconf.h, and drop set::dns which did
nothing since 3.2 or so.
2021-09-03 21:17:51 +02:00
Bram Matthys 4c2aeab75e Windows compile fixes 2021-08-28 16:35:37 +02:00
Bram Matthys e0504b2e52 Remove Mode.mode, it now only contains Mode.extmode and Mode.extmodeparams
Also make MODES_ON_JOIN point to iConf.modes_on_join.extmodes instead
of iConf.modes_on_join.mode

Actually in next commit I may reorder again...
2021-08-22 18:33:25 +02:00
Bram Matthys 783cc3ff5b Cmode API: change from Channelmode_Table[<num>] to channelmodes linked list.
And now we can easily sort the channel modes too, makes it easier for
our test cases.
2021-08-22 17:57:14 +02:00
Bram Matthys 8a5a0723e9 Fix the default set::modes-on-join (+nt) not working anymore, since
at the time of setting the default settings the channel mode modules
are not fully initialized yet.
2021-08-22 13:12:55 +02:00
Bram Matthys a70580cc86 Enable sending of named extended bans. This can be changed via the
configuration file via set::named-extended-bans <yes|no>; and now
defaults to yes.
Still to do:
* explicitly set names instead of using stupid module names
* update test suite to check for these new names (other git tree)
* backwards compatible sending to U5 and lower using ugly shit
2021-08-14 10:12:43 +02:00
Bram Matthys f742d08643 Remove some whitespace 2021-08-10 14:25:34 +02:00
Bram Matthys 2c011202a4 Integrate iConf.network in iConf itself as the distinction between
these "network settings" and other settings has been lost in time.

Rename some of these variables and macro's.
ircnetwork -> NETWORK_NAME
ircnet005 -> NETWORK_NAME_005
defserv ->? DEFAULT_SERVER
hidden_host -> CLOAK_PREFIX
helpchan -> HELP_CHANNEL

Also one config change (visible to admins):
set::hiddenhost-prefix is now set::cloak-prefix
We still accept the old name, though.
The example conf has been updated as well, but not the wiki yet.
2021-08-10 14:22:42 +02:00
Bram Matthys f4af4acb16 Newlog: fix rehash and memory leak 2021-08-07 14:01:44 +02:00
Bram Matthys e59cd278cd log { } now uses the new log system and is used for logging to disk,
snomasks, opers, global (remote), ..

For disk logs we currently ignore the sources and log everything.

NOTE: REHASH is untested and will memory leak for sure.
2021-08-07 13:04:07 +02:00
Bram Matthys b8837844fb Newlog: new config plan, ditch set::logging and use log blocks soon.
In this commit it is still called logx { }. Will merge them soon
into one log { } block.
2021-08-07 10:39:54 +02:00
Bram Matthys f34d3bd861 Add set::logging block and the logging to snomask mapping.
Note that without such a block nothing will be sent to ircops at all
(anything that comes from unreal_log anyway).
In a later commit either a snomasks.default.conf will be added and/or
an internal default mapping.

This also moves the recursion trap to earlier in the logging code,
which has the side effect that debug traffic regarding snomasks is
no longer logged.
2021-08-06 15:19:36 +02:00
Bram Matthys 413def178c Add early loglevel to snomask code. Hardcoded atm. 2021-08-05 07:34:03 +02:00