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

2659 Commits

Author SHA1 Message Date
Bram Matthys 2beefcd2ee crule: remove CR_DEBUG, bump some limits and remove collapse() call 2023-07-16 10:40:11 +02:00
Bram Matthys 08cb0fc05d Move crule to a module, so we can hot-patch if needed in the future.
This is a mandatory module to load, and included in modules.default.conf.

This also meant that the crule_test() etc efunctions are available
before running config test routines, so we now have a flag for
early efuncs. I guess we could consider doing that for all efuncs
though, so not sure if this flag is really needed.
2023-07-16 10:33:25 +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 a153a2cce3 Change definition of parse_ban_action_config(), was too easy to leak memory.
Often you have default values for the config, and then a subsequent config
parsing run would overwrite the return value (= memory leak), merging/appending
would make no sense either, so it would force a free in all code before
calling us, well... let's just deal with it ourselves instead then ;)
2023-07-14 08:08:47 +02:00
Bram Matthys 9625a1221b Make Cmode_t an unsigned long long to have more chanmodes on 32 bit archs.
Reported by BlackBishop in https://bugs.unrealircd.org/view.php?id=6301
[skip ci]
2023-07-11 15:27:13 +02:00
Bram Matthys 4c3d2a6d6d Fix write bug in tkldb and add spamfilter::action stop.
The spamfilter::action stop ill prevent processing other spamfilters.
This would normally be a bit unusual, and potentially dangerous when you
do exclude things this way, but can be useful in some circumstances.

Stopping only affects the same type of spamfilters (general or central
spamfilters), so they don't interfere.

The tkldb write DB bug had to do with that it was processing
central spamfilters, which should be skipped just like config
based spamfilters were already skipped.
2023-07-11 14:32:11 +02:00
Bram Matthys 32701e6f99 Central spamfilter: don't stop processing on 1 bad spamfilter block. 2023-07-11 13:34:28 +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 95902979dc Central spamfilter: now every 1hr and a default set::central-spamfilter::except
policy is added. This may be tweaked later.
2023-07-10 20:18:07 +02:00
Bram Matthys 15b9255b0e Add spamfilter::except as an alternative for spamfilter::rule and upd rls notes 2023-07-10 12:12:25 +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 d25fdeb950 Some more BanAction fixes/improvements:
* stats S one thingy (multi-actions)
* STATS spamfilter (multi-actions)
* warn w/user target ('u') if using multi-actions
* moving some code
2023-07-09 16:27:40 +02:00
Bram Matthys 3250c7c0b4 Add some temporary safety mechanism if too many HTTP(S) requests in progress.
Will allow tweaking in config later. This is separate from rate-limit btw,
which also still needs to be done.
2023-07-09 13:21:16 +02:00
Bram Matthys dec9aa0341 Reporting spam to DroneBL now works, see https://www.unrealircd.org/docs/Spamreport_block
This uses the RPC2 API. Tested with staging.

Note that there are likely some bugs here or there, like memory leaks,
but the functionality is there.

Also still need to implement various stuff, including spamreport::rate-limit
2023-07-09 13:07:29 +02:00
Bram Matthys 5d65e4a400 Rename place_host_ban() to take_action() since it is not only about banning... 2023-07-08 19:54:40 +02:00
Bram Matthys 8f4a19978a Deal properly with multi actions in spamfilter (untested) 2023-07-08 19:48:15 +02:00
Bram Matthys 64f57ae243 Add spamfilter::action report (work in progress) 2023-07-08 19:24:15 +02:00
Bram Matthys 84786cc005 Add flags argument to buildvarstring_nvp, and add BUILDVARSTRING_URLENCODE
[skip ci]
2023-07-08 18:12:24 +02:00
Bram Matthys 38771b6761 Spamreport: implement POST requests 2023-07-08 16:46:21 +02:00
Bram Matthys def77c4d52 Initial work on spamreport { } block. Not really useful yet.
Early commit before i make it actually work and implement the rest
and hunting for memory leaks etc...
2023-07-08 15:35:08 +02:00
Bram Matthys 01dd042089 Add support for spamfilter::id (currently not used or displayed anywhere)
For config-file only atm.
2023-07-08 12:34:21 +02:00
Bram Matthys d1877ae100 Add conditional config defines:
UNREALIRCD_VERSION
UNREALIRCD_VERSION_GENERATION
UNREALIRCD_VERSION_MAJOR
UNREALIRCD_VERSION_MINOR
UNREALIRCD_VERSION_SUFFIX

https://www.unrealircd.org/docs/Defines_and_conditional_config
2023-07-07 21:05:38 +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 662acb2442 Bump UNREAL_VERSION_TIME
[skip ci]
2023-07-07 11:34:16 +02:00
Bram Matthys d998846c64 Support setting tags via spamfilter { } blocks 2023-07-06 18:25:43 +02:00
Bram Matthys 6bbcdfd1b3 Add spamfilter::rule (preconditions), add context to crule parser,
and add the first functions: online_time() and reputation().

The more interesting stuff will follow later...
2023-07-06 16:14:26 +02:00
Bram Matthys 1e572e25b9 Add comparisson operator support to crule (< > ==)
Should probably add >= and <= as well :D
2023-07-06 14:31:36 +02:00
Bram Matthys 656ea105da First go at multi actions... 2023-07-06 11:51:55 +02:00
Bram Matthys 0af88581d3 Add support for restricting config file blocks. 2023-07-06 08:47:02 +02:00
Bram Matthys f932c21751 Bump MODDATA_MAX_LOCAL_CLIENT from 12 to 24. 2023-06-30 20:34:10 +02:00
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