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

2628 Commits

Author SHA1 Message Date
Bram Matthys a8695dfe0b Whoops, removed an important backslash, fix compile error :D 2023-06-17 18:26:42 +02:00
Val Lorentz d5ceb664bc Add 'history_delete' method to HistoryBackend (#253)
This will allow modules to implement deletion of specific messages
(unlike history_destroy, which removes the entire history of a channel)
2023-06-17 16:10:10 +00:00
Bram Matthys 407bd84c11 Bump version to 6.1.2-git 2023-06-17 18:08:51 +02:00
Bram Matthys 7bce73a697 Some changes to HOOKTYPE_RECONFIGURE_WEB_LISTENER hack from earlier,
that was added late in 6.1.1 development to fix a crash with removing
websocket listeners. Now replaced with a generic HOOKTYPE_CONFIG_LISTENER
that is not only called for removed listeners, but for all listeners.
2023-06-17 18:04:12 +02:00
Bram Matthys 4c2bb2ff21 ** UnrealIRCd 6.1.1.1 ** 2023-06-16 18:06:44 +02:00
Bram Matthys 6e2569a9b7 ** UnrealIRCd 6.1.1 ** 2023-06-14 08:53:07 +02:00
Bram Matthys f1a5e30e8a ** UnrealIRCd 6.1.1-rc1 ** 2023-05-31 08:16:57 +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 2fcb5b4669 * Server to server lines can now be 16384 bytes in size when
`PROTOCTL BIGLINES` is set. This will allow us to do things more
  efficiently and possibly raise some other limits in the future.
  This 16k is the size of the complete line, including sender,
  message tags, content and \r\n. Also, in server-to-server traffic
  we now allow 30 parameters (MAXPARA*2).
  The original input size limits for non-servers remain the same: the
  complete line can be 4k+512, with the non-mtag portion limit set
  at 512 bytes (including \r\n), and MAXPARA is still 15 as well.
* I chose 16k because I don't want to first raise it to like 8k
  and then realize later that 16k would be better and raise it again.
* To receive BIGLINES in a command, you need to `CommandAdd()` with
  flags `CMD_BIGLINES`, without it you still get regular 512 max.
  This is so, because a lot of the code does not expect longer than
  512 bytes lines or in parameters, so we can gradually change that
  (where needed).
2023-05-28 15:06:32 +02:00
Bram Matthys 55670c5865 Fix memory leak created today on REHASH (free the proxy blocks) 2023-05-26 16:41:02 +02:00
Bram Matthys 995d28cacb Add duplicate_security_group() function, and also:
unreal_duplicate_masks()
duplicate_nvplist()
duplicate_name_list()

And use this for when proxy::type is web, to duplicate the
exact criteria to the ban exception as mentioned in previous
commit.
2023-05-26 16:15:09 +02:00
Bram Matthys fa4b39d4aa Fix "function returns an aggregate" to make GCC happy.
Actually I don't think this was really wrong as this is an
enum, which is probably why clang does not complain...
but still... whatever....
2023-05-26 14:40:24 +02:00
Bram Matthys cf5808dc44 Error on listen::options::websocket::forward and tell to use proxy { } block.
[skip ci]
2023-05-26 14:36:20 +02:00
Bram Matthys fb54d4a2c6 Replace do_parse_forwarded_header() and set WEB(client)->forwarded
depending on what we get from the proxy, so it can be used later
in the websocket module for setting the user secure or not
(the latter similar to what k4be already did in the old code).
2023-05-26 13:31:01 +02:00
Bram Matthys c537a72c10 Make proxy::mask and webirc::mask a generic mask item almost all
others in the config - https://www.unrealircd.org/docs/Mask_item
2023-05-26 12:39:11 +02:00
Bram Matthys 9aafdb7f9c Move handling of webirc { } block into new proxy { } block (allow the old name)
This is untested, as I'm first working on the rest...
2023-05-26 12:23:51 +02:00
Bram Matthys c2d465c5dd Move chunk of code from start_of_normal_client_handshake() to
a function called start_dns_and_ident_lookup(). This can then
be easily called from other places as well, like the code k4be
did in src/modules/websocket.c to handle proxies.

Side-effect is that ident lookups would now be done, if we are
configured to do so, for forwarded webirc stuff (not that I
think many people use that feature at the moment...).
2023-05-26 11:24:01 +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 6bbb5dee37 Add str_starts_with* and str_ends_with* functions:
int str_starts_with_case_sensitive(const char *haystack, const char *needle);
int str_ends_with_case_sensitive(const char *haystack, const char *needle);
int str_starts_with_case_insensitive(const char *haystack, const char *needle);
int str_ends_with_case_insensitive(const char *haystack, const char *needle);
[skip ci]
2023-05-22 07:42:26 +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 f2015ad865 Fix crash when removing a listen { } block with websocket or rpc
(or changing the port number). Reported by Nini.

Rather complex case: when the listen block is removed, obviously
the config hooks are not called for the (now non-existing) listen
block, and thus the websocket->request_handler and such are not
set to the new address of the websocket handler.
We now use a slightly silly workaround / new hook to fix this
corner case. Ideally there would be an extra layer in-between
like a handler lookup by name, or something like that.
(Or make the websocket module PERM but we don't want that!)
2023-05-19 19:29:46 +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 9b9434e442 Delay throttling check until IP is resolved or failed to resolve.
This so you can use throttling exceptions (eg in ELINE) on hostnames.

That is, the above is during normal circumstances. Similar to previous
commit we will turn this feature of during high connection rates.
That is a TODO item.
2023-05-18 11:51:22 +02:00
Bram Matthys 89075e532a Send throttling and some other error messages to SSL/TLS users (encrypted).
This is the start of "be more friendly to TLS users with disconnect
error messages" from https://bugs.unrealircd.org/view.php?id=5532

As that bug explains:
Consider doing the SSL/TLS handshake even for throttling errors and such
when the (reject) connection rate is below a certain amount per second.  If
it is higher than a certain rate, then fall back to the original behavior to
reject the user instantly without handshake or looking at any data.
Rationale: the current/original behavior is there so the ircd can handle
floods, both in terms of traffic and in terms of CPU usage (the SSL/TLS
handshake is quite costly after all).  The downside of the current behavior
is that TLS users don't see the error message, usually.  This feature
request tries to find a middle ground.

Still a TODO item:
* We don't detect high rates yet, so we only do this new behavior atm
  and not yet the old behavior during high connection rates.
* Verify that error messages/behavior hasn't changed (too) much,
  like the throttling and the banning disconnect messages.
2023-05-18 11:17:37 +02:00
Bram Matthys 40bdef6cd9 Make exceeds_maxperip() use a hash table (performance improvement) 2023-05-17 19:44:10 +02:00
Bram Matthys b19b70e876 Speed up invisibility checks for delayjoin mode (and when not used too).
This adds user_can_see_member_fast() which is used in at least 3 places
now, more places may follow later. It has extra paramters for membership
and membership modes that is very likely already looked up by the caller
(or if not, it is worth doing so by the caller).

This is work in progress so if everything crashes or people mysteriously
seem not present in channels (or the other way around) i would not be
surprised :D.
2023-05-15 16:58:51 +02:00
Bram Matthys 0874e376bc Add LineCache which is used when sending a message to a channel.
When sending to channel members this will cache full IRC protocol
lines, including message tags and \r\n, for similar clients.
This avoid the need for many mtags_to_string() calls and also
entire parts of sendbuf_to_one() can be skipped as well.
The "Similar clients" cache entries are defined as clients that:
1) Are of the same type: normal local client, ircop local client
   or remote client.
2) Have the same CAPs set, that is: we only look at CAPs that actually
   have anything to do with message tags ('clicaps_affecting_mtag')
3) Optionally there can be an explicit line_opts. It is not used yet
   but could be used when there are different type of lines sent
   depending on other criteria, such as chanop status or something
   else that doesn't fit in #1 and #2.
2023-05-15 15:27:52 +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 ef6ba9c0cc Bump max number of DNS cached entries from 241 to 4096.
This may help a little during mass connects.

Also clean up / doxygen the include/dns.h header a bit.
2023-05-06 11:15:38 +02:00
Bram Matthys 8cabbcb59b DNS: add negative caching of unresolved hosts (60 seconds)
Mostly to avoid repeated lookups for like clients that reconnect rapidly.
2023-05-06 10:34:26 +02:00
Bram Matthys 16531e53db Performance tweak to dbufs: 512 bytes -> 4K
This results in less write calls (lower load) and more data per packet
(more efficient network traffic). It helps for the webserver (JSON-RPC)
but should also help IRC traffic when returning more than a line or so.

Previously the first TCP packet was not always filled fully, eg it was
close to 512 bytes instead of being close to 1500 bytes (MTU). Strange
that this happened in the first place, by the way, as we don't set
TCP_NODELAY. But whatever...
2023-05-06 09:25:49 +02:00
Bram Matthys d48ccb1ec8 When rpc.modules.default.conf is loaded, remember last 1000 lines of log
entries for a maximum of 7 days, in memory.
[skip ci]
2023-05-05 12:16:54 +02:00
Bram Matthys 1dcef57970 Add safe_json_decref() which sets pointer to NULL after decref. 2023-05-05 09:51:09 +02:00
Bram Matthys 95074410a5 Set version to 6.1.1-git
[skip ci]
2023-05-05 09:50:48 +02:00
Bram Matthys 5d3319d662 Whoops.. fix windows compile issue :D. Let's not add a random x there. 2023-05-05 07:46:32 +02:00
Bram Matthys 1317784de1 ** UnrealIRCd 6.1.0 ** 2023-05-05 07:32:22 +02:00
Bram Matthys c400e9282e Remove CCM ciphers, which are likely unavailable anyway. 2023-04-27 13:16:15 +02:00
Bram Matthys 2922a8ae5a Fix crash if there is a parse error in an included file and there are
other remote included files still being downloaded.
This issue exists both with and without cURL, so in both url interfaces.

Was finally able to reproduce this on my own machine. This bug exists
since at least 6.0.0 and perhaps even before that. Just doesn't get
triggered that often due to needing an error and a certain timing
condition (well, and ASan catches it, but on some systems it may
go unnoticed).
2023-04-22 14:08:29 +02:00
Val Lorentz ebcfe6a6bc Add sendtaggednumeric/sendtaggednumericfmt (#250)
They are similar to sendnumeric/sendnumericfmt, but allow an array of message
tags are parameter.

sendnumeric/sendnumericfmt are now shorthands for sendtaggednumeric/sendtaggednumericfmt
which pass NULL as mtags.
2023-04-15 14:34:38 +00:00
Bram Matthys 2b1fad89be ** UnrealIRCd 6.1.0-rc2 ** 2023-04-15 14:08:47 +02:00
Bram Matthys 4b448f2aaa New option listen::spoof-ip, only valid when using UNIX domain sockets
(so listen::file). This way you can override the IP address that users come
online with when they use the socket (default was and still is `127.0.0.1`).

Add a new guide https://www.unrealircd.org/docs/Running_Tor_hidden_service_with_UnrealIRCd
which uses the new listen::spoof-ip and optionally requires a services account.
2023-04-15 10:37:30 +02:00
Bram Matthys 7ad160f57a JSON-RPC: WHOWAS fetching is now whowas.get, also expose not only
logon_time/logoff_time but also connected_since.

This also fixes the Makefile for the Windows build (i hope)
2023-04-15 09:24:57 +02:00
Bram Matthys 2184f38e7e Expose more WHOWAS fields in JSON-RPC and change add_history() to take a reason
for the add, like: nick-change, quit, server terminating. Add logon time.

I also think i will move from user.get_whowas to a whowas.XXX since the
returned object is not a user object and getting more different each commit :D.
2023-04-15 09:00:06 +02:00
Bram Matthys e7e2a5a275 whowasdb: write currently online users as well, as if they already
left. This so, if we die, there is still a history of them.
2023-04-15 08:17:54 +02:00
Bram Matthys 45201fffe7 New module 'whowasdb': persistent WHOWAS history (preserved between reboots) 2023-04-14 19:29:45 +02:00
Bram Matthys 66b8259234 JSON-RPC: don't do filtering on low ASCII like we do for JSON logging.
This way things like the TOPIC will keep their color codes if they have it.

Reported by armyn in https://bugs.unrealircd.org/view.php?id=6259

(And yeah i used a global to achieve this, otherwise it has too much
 of a cascading effect in XYZ functions)
2023-04-13 18:53:49 +02:00
Bram Matthys 7c22f37a9f JSON-RPC: add log.subscribe and log.unsubscribe
https://www.unrealircd.org/docs/JSON-RPC:Log
2023-04-08 17:56:59 +02:00
Bram Matthys ec7077f4a1 ** UnrealIRCd 6.1.0-rc1 ** 2023-04-07 14:54:43 +02:00
Bram Matthys 254afbb9c6 Make set::hide-ban-reason not affect opers (eg. show full gline reason).
Suggested by Chris_dc in https://bugs.unrealircd.org/view.php?id=6252

This uses unrealircd.org/real-quit-reason internally, but is only
exposed to servers, never to users. It results in using that quit
reason for IRCOps, while using the regular quit reason for normal users.
2023-04-05 07:26:12 +02:00
Bram Matthys a19b2aebf6 New cmode.flood_type_action which can be used to indicate a channel mode
can be used from +f/+F as an action. You need to specify for which
flood type your mode is, eg `cmode.flood_type_action = 'j';` for joinflood.

Currently a mode can only choose one flood type action due to +f/+F
timer fights that could otherwise occur, but that shouldn't be too
much of an issue since we can live with that in core as well.
2023-04-02 18:14:45 +02:00