1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-25 05:36:37 +02:00
Commit Graph

2517 Commits

Author SHA1 Message Date
Bram Matthys bb0a50d839 ** UnrealIRCd 6.0.5-rc1 ** 2022-12-07 08:53:44 +01:00
Bram Matthys d9ac4cac07 Add RPC 'rpc.info': returns list of RPC methods, RPC module name and version.
This can be useful for checking if a server supports something and what
format it expects or returns things, etc.
2022-12-05 14:48:14 +01:00
Bram Matthys ee1f8d84a0 Require TLSv1.2 or later and require a modern cipher with forward secrecy.
This also fixes a bug with OpenSSL 3.x where, when the ircd was
configured to still allow old TLSv1.0 / TLSv1.1, it would still
only allow TLSv1.2+.

But, as said, allowing TLSv1.0/TLSv1.1 is now no longer the default.

See release notes for more information or the documentation at
https://www.unrealircd.org/docs/TLS_Ciphers_and_protocols
2022-11-27 17:04:22 +01:00
Bram Matthys c3824ad47d Fix potentially sending invalid data over websockets on REHASH.
This makes websocket_common unload last (and near-last: rpc & websocket)
and makes us call Mod_Init for these three modules first.
This way, the period where the websocket handler is unavailable is kept
to a minimum.

This also renames the ModuleSetOptions option MOD_OPT_UNLOAD_PRIORITY
to MOD_OPT_PRIORITY since it dynamically changes the module priority
in the list. For 6.x compatibility, MOD_OPT_UNLOAD_PRIORITY can still
be used.
2022-11-04 10:54:53 +01:00
Bram Matthys 3de3087c95 Fix read-after-free when linking in a server (that is fully authenticated)
when there is already another established link with a server with the same name.
For example, when there is a network issue and the "old server" is still
waiting to be timed out and the "new server" is already linking in.
2022-10-01 08:48:44 +02:00
Bram Matthys dc55c3ec9f Add CALL_CMD_FUNC(cmd_func_name) and use it.
This is only for calls within the same module, as otherwise you
should use do_cmd().

Benefit of this way is that it is short and you don't have to worry
about passing the right command parameters, which may change over time.
Example as used in src/modules/nick.c:
-               cmd_nick_remote(client, recv_mtags, parc, parv);
+               CALL_CMD_FUNC(cmd_nick_remote);
2022-08-28 09:04:12 +02:00
Bram Matthys 4e5598b6cf Create and use new CALL_NEXT_COMMAND_OVERRIDE() instead of CallCommandOverride().
This is an easier way to call the next command override handler from command
override functions. It passes the standard parameters so you don't have to
worry about which parameters a CMD_OVERRIDE_FUNC() contains.
This so it is easier to change command parameters in future UnrealIRCd versions,
should it be needed, then it may be possible without any source code changes
on the module developer side.

-       CallCommandOverride(ovr, client, recv_mtags, parc, parv);
+       CALL_NEXT_COMMAND_OVERRIDE();
2022-08-28 08:52:51 +02:00
Bram Matthys 24e3d39aea Update windows setup.h for last change.
[skip ci]
2022-08-20 14:06:54 +02:00
Bram Matthys 401ab6f5a1 Make strlncpy() and strlncat() use strlncat() instead of strlen().
This fixes a possible crash when using RPC with unix domain sockets,
reported by Valware.

This also adds a configure check so we use our own strlncat if the
C library does not have one, e.g. some non-Linux.
2022-08-20 13:50:19 +02:00
Bram Matthys 0d139c6e7c Make /INVITE bypass (nearly) all channel mode restrictions, as it used to be
and as it should be IMO. Both for invites by channel ops and for OperOverride.

This also fixes a bug where an IRCOp with OperOverride could not bypass +l
and other restrictions. Only +b and +i could be bypassed.

Module coders: HOOKTYPE_OPER_INVITE_BAN is now gone and HOOKTYPE_INVITE_BYPASS
is now new. The HOOKTYPE_INVITE_BYPASS is called when the user is joining
a channel to which they were invited to. If you return HOOK_DENY there then
the join is still blocked, otherwise it is allowed.
Using this hook would be sortof unusual since usually you would want users
to be able to bypass restrictions when they were invited by another user
or when they invited themselves using OperOverride.
The only example where we use it in UnrealIRCd is for +O channels so an
IRCOp cannot use OperOverride to join +O channels when they would otherwise
not be allowed to do so. Actually even that is a corner case that you could
debate about, but.. whatever.
2022-08-06 15:52:16 +02:00
Bram Matthys 55c52c3693 Log file (log::destination::file) now creates directory structure if needed.
You could already have something like:
log { source { !debug; all; } destination { file "ircd.%Y-%m-%d.log"; } }
But now you can also have:
log { source { !debug; all; } destination { file "%Y-%m-%d/ircd.log"; } }

This is especially useful if you output to multiple log files and then
want them grouped by date in a directory.
2022-08-05 13:02:19 +02:00
Bram Matthys 0e6fc07bd9 Update verify_link() to return rather than set the link block in a variable.
Hopefully this fixes a crash when linking (succesfully authenticated) servers,
something which only happens with GCC and only for some people in some cases.
2022-08-03 14:55:37 +02:00
Bram Matthys 7371498ffd Make auto-expansion work for IPv6 bans as well: +b A:B:C:IP -> *!*@A:B:C:IP.
Reported by armyn in https://bugs.unrealircd.org/view.php?id=6147

This also adds a new function convert_regular_ban() which is now
used by both clean_ban_mask() and extban_conv_param_nuh().
2022-07-01 10:13:57 +02:00
Bram Matthys c60fdad7eb RPC: add server_ban.add
This also moves some of the adding code (sending notice, broadcasting to
other servers, etc) to a function tkl_added().

We should probably do the same for deletion and not use the tkllayer
anymore for that?
2022-06-24 19:49:32 +02:00
Bram Matthys 3d9b7e4b70 RPC: remove tkl, split this up.. starting with server_ban.
Currently available:
* server_ban.list
* server_ban.get with params: name="*@1.2.3.4", type="kline"

This also adds server_ban_parse_mask() which is now used by both GLINE/etc
and the RPC API to parse the same way and convey the same error messages.
2022-06-24 18:53:10 +02:00
Bram Matthys 36946c6c51 Move JSON stuff from log.c to json.c now that it is more universal. 2022-06-24 13:21:27 +02:00
Bram Matthys 7c8918e22d Update rpc_error() to use JsonRpcError (enum) and add more error values. 2022-06-20 19:02:52 +02:00
Bram Matthys b38b0f5086 Set loop.config_state to one of CONFIG_STATE_* so modules (and core)
can track at what step we are during configuration file and module
processing.
2022-06-20 12:54:22 +02:00
Bram Matthys 85784e8118 Bump version to 6.0.5-git 2022-06-19 16:30:50 +02:00
Bram Matthys 941439a710 Use RPC_CALL_FUNC() just like how we have CMD_FUNC() 2022-06-19 13:13:33 +00:00
Bram Matthys c24a8e43e3 Fix outdated doxygen information on CMD_FUNC() 2022-06-19 13:13:33 +00:00
Bram Matthys 853f0685ed Split off big chunk of websocket module into websocket_common module.
And load the websocket_common module by default (which is just an API).
2022-06-19 13:13:33 +00:00
Bram Matthys 0eb42155dd Limit request body to 4k by default. 2022-06-19 13:13:33 +00:00
Bram Matthys 467e3d847a Handle chunked encoding in webserver (mostly meant for RPC). 2022-06-19 13:13:33 +00:00
Bram Matthys 4a68008b81 Rename some more:
* WEB() now has handle_request() and handle_body(), makes more sense.
* webserver_handle_body_data() -> webserver_handle_body()
* and similar cases
2022-06-19 13:13:33 +00:00
Bram Matthys 12f2cd8555 Rename webserver_handle_body_data() -> webserver_handle_request_body() 2022-06-19 13:13:33 +00:00
Bram Matthys 9afdcb7ff0 Add request body handler in webserver -- only a beginning, the
chunked encoding stuff is copied from the modulemanager and #if'd out.
The non-chunked is not OK yet either, as it must check the Content-Length,
while we currently assume a single packet == the complete request.
2022-06-19 13:13:33 +00:00
Bram Matthys b710fb188b Add get_nvplist() function.
Requested by westor in https://bugs.unrealircd.org/view.php?id=6125
2022-06-19 13:13:33 +00:00
Bram Matthys 5e81a6ee67 Add listener->start_handshake function pointer.
This is start_of_normal_client_handshake() by default, but is
start_of_control_client_handshake() for the control channel
(for './unrealircd rehash' and such). Previously that was hardcoded.

It is also used by the RPC code now.
2022-06-19 13:13:33 +00:00
Bram Matthys 46588db89a Fix rehash crash since adding RPC code. 2022-06-19 13:13:33 +00:00
Bram Matthys df8c5cfd76 Add ability to skip connect-flood and zlined checks via listener->options
with LISTENER_NO_CHECK_CONNECT_FLOOD and LISTENER_NO_CHECK_ZLINED.
2022-06-19 13:13:33 +00:00
Bram Matthys 60c83b4ba1 Move connect-flood and max-unknown-connections-per-ip into their own module.
These deal with set::anti-flood::everyone::connect-flood and
set::max-unknown-connections-per-ip respectively.

This adds a new hook HOOKTYPE_ACCEPT, that is mostly meant for internal
usage by UnrealIRCd. Most module coders will want to use the existing
hook HOOKTYPE_HANDSHAKE instead.

This also gets of check_banned() which is now spread over the individual
modules (eg: checking banned is done in tkl on HOOKTYPE_ACCEPT and
HOOKTYPE_IP_CHANGE).
2022-06-19 13:13:33 +00:00
Bram Matthys a09d4a7e88 Add CLIENT_STATUS_RPC and add SetRPC() and IsRPC(). 2022-06-19 13:13:33 +00:00
Bram Matthys 1830f3e53f Add RPC channel.list call to show list of channels (with all details) 2022-06-19 13:13:33 +00:00
Bram Matthys 61ba3727df JSON-RPC: Use proper error response with error codes according to
the official specification (one of JSON_RPC_ERROR_*).

Add proper rpc_error() and rpc_error_fmt()

Don't steal reference in rpc_response().
2022-06-19 13:13:33 +00:00
Bram Matthys 4cd520d327 Make user.list() RPC API return a list of all users with details.
This is the 1st RPC API call that actually works :D
2022-06-19 13:13:33 +00:00
Bram Matthys 31fc2843a2 Add "rpc" module. Supports parsing from *NIX domain sockets for starters. 2022-06-19 13:13:33 +00:00
Bram Matthys 97c8274695 Add RPC API (the beginning..) 2022-06-19 13:13:33 +00:00
Bram Matthys 2397fb8a49 Split 'websocket' module up in 'webserver' and 'websocket' 2022-06-19 13:13:33 +00:00
Bram Matthys 88190d08c4 ** UnrealIRCd 6.0.4 ** 2022-06-17 13:33:13 +02:00
Bram Matthys 020c3d1fa3 ** UnrealIRCd 6.0.4-rc2 ** 2022-06-03 18:48:52 +02:00
Bram Matthys b4f6c83821 Fix multiline log messages not working, they showed up as single lines
with their content added together.
2022-05-30 08:59:44 +02:00
Bram Matthys d47fdbede4 Add oper::auto-login. When set to yes, opers are automatically logged in
if the oper block permits, the user does not have to send "OPER xyz".

Eg:
security-group Syzop { certfp "xyz"; }
oper Syzop {
	auto-login yes;
        mask { security-group Syzop; }
        operclass netadmin-with-override;
        class opers;
}

Then, if you connect with SSL with that certificate fingerprint,
you become IRCOp automatically.
2022-05-26 21:01:13 +02:00
Bram Matthys 96897289e0 Allow oper block without password, now that you can use security-group
and other selectors in 'mask'. This allows for things like:

security-group Syzop { certfp "xyz"; }

oper Syzop {
	mask { security-group Syzop; }
	operclass netadmin-with-override;
	class opers;
}

except ban {
	mask { security-group Syzop; }
	type all;
}

allow {
	mask { security-group Syzop; }
	class special;
	maxperip 32;
}

etc...

We do error on the obvious case of mask * and mask *@* when no password
is set, but otherwise try not to stop all cases of user stupidity
(there are just too many...).
2022-05-26 20:31:28 +02:00
Bram Matthys 3936059768 ** UnrealIRCd 6.0.4-rc1 ** 2022-05-25 17:14:32 +02:00
Bram Matthys b28d8aecd7 Add "ip" to mask item and security-group for easy matching on IP.
So you can just use mask { ip { 127.*; 192.168.*; } } without
having to worry about hostnames like 127.example.net.
(Of course you could also have used CIDR notation)

Another benefit is that, since we are dealing with IP's only,
the matching is faster than going through the more universal
match_user() routine.
2022-05-25 08:34:22 +02:00
Bram Matthys 7ff4a3e897 Add the promised support of security group functionality in except ban { }
So now the example in the release notes actually works:
except ban {
    mask { security-group irccloud; }
    type { blacklist; connect-flood; handshake-data-flood; }
}
2022-05-25 08:01:05 +02:00
Bram Matthys 16264e944f Add HOOKTYPE_JSON_EXPAND_CLIENT etc. so modules can add more fields when
clients etc. are expanded in the logging routines.

HOOKTYPE_JSON_EXPAND_CLIENT - for all clients
HOOKTYPE_JSON_EXPAND_CLIENT_USER - for clients that are users
HOOKTYPE_JSON_EXPAND_CLIENT_SERVER - for clients that are servers
HOOKTYPE_JSON_EXPAND_CHANNEL - for channels
2022-05-23 11:02:05 +02:00
Bram Matthys 7740d64042 Limit individual JSON strings to 512 bytes and call StripControlCodes()
on each string. Note that the entire JSON dump may still be much larger,
this is just about each individual string item within an object.

This commit also adds a more flexible StripControlCodesEx() function
to the core (which is used by the logging system), the existing
StripControlCodes() function is unchanged and can still be used.

+/** Strip color, bold, underline, and reverse codes from a string.
+ * @param text                 The input text
+ * @param output               The buffer for the output text
+ * @param outputlen            The length of the output buffer
+ * @param strip_all_low_ascii  If set to 1 then all ASCII < 32 is stripped
+ *                             (the ASCII control codes), otherwise we only
+ *                             strip the IRC control- and color codes.
+ * @returns The new string, which will be 'output', or in unusual cases (outputlen==0) will be NULL.
+ */
+const char *StripControlCodesEx(const char *text, char *output, size_t outputlen, int strip_all_low_ascii)
 {
2022-05-23 10:35:52 +02:00
Bram Matthys 3fbdb7fd4b Move StripControlCodes() from message.c to misc.c.
Because I need in the core (again) due to early calls / calls during
rehashes / etc...
2022-05-23 10:10:47 +02:00