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

6426 Commits

Author SHA1 Message Date
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 cf60b22b31 Close RPC web connection immediately when all has been sent. 2022-06-19 13:13:33 +00:00
Bram Matthys f9794c7ed5 Make RPC API work over HTTP(S). Well, first steps, anyway.
* No ACL checking yet
* No chunked encoding support
* No multi-frame support
etc...
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 2bf41a47d2 Don't check for connect-flood on RPC connections.
Same for control channel, even though it was harmless to check,
still... can now skip it so why not?
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 2c8fc5e641 Move special handling of control socket to procio_server.c.
Things like setting the client->status to CLIENT_STATUS_CONTROL
and list_add(&client->lclient_node, &control_list);

This does mean that we now add clients earlier to the unknown list,
even ones that are going to be control sockets and clients that are
going to be z-lined etc, but it should be a minimal performance hit
since it are just 1-4 insertions in a circular list.
At the same time it makes the code more cleaner and more maintainable
especially with all the "special cases" and such that are there now
and will only become more and more...
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 29eb89a528 Attach client->local->listener to a client very early, now that it is safe.
This makes other code safer as well since they can assume that if the
client is local (client->local) that the listener (client->local->listener)
is non-NULL and safe to access until the client is completely destroyed.
2022-06-19 13:13:33 +00:00
Bram Matthys 1d613a592c Remove freeing of client->local->listener and refdec from exit_client()
to free_client().
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 6b30482c04 Don't apply registration timeout to *NIX domain socket connections.
May want to reconsider this but.. for now..
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 53732e0f78 Warn if 'websocket' module is loaded without 'webserver' (= won't work). 2022-06-19 13:13:33 +00:00
Bram Matthys b9d1af8fa0 Call config run hooks for CONFIG_LISTEN and CONFIG_LISTEN_OPTIONS also
for unix domain sockets.
2022-06-19 13:13:33 +00:00
Bram Matthys 0134c435d5 Don't apply handshake-delay to any *NIX domain socket connections,
instead of only exempting *NIX domain socket control channels.
2022-06-19 13:13:33 +00:00
Bram Matthys cbfcfa1428 Create src/modules/rpc directory 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 0c32151be1 Sort modes returned by "MODE #channel" (request) 2022-06-18 15:08:45 +02:00
Bram Matthys 88190d08c4 ** UnrealIRCd 6.0.4 ** 2022-06-17 13:33:13 +02:00
Bram Matthys 8ea7fcfc9f Fix tld::mask not working with the new form.
Reported by musk.
2022-06-08 08:22:14 +02:00
Bram Matthys b5f35dfff5 Fix regular users being able to -o a service bot (that has umode +S).
Reported by ComputerTech in https://bugs.unrealircd.org/view.php?id=6126

HOOKTYPE_MODE_DEOP wasn't called.
2022-06-08 07:37:03 +02:00
Bram Matthys 8fe7b1bc41 Fix wrong security-group example in release notes for auto oper up.
This should be:
security-group Syzop { certfp "1234etc."; }
As this is wrong:
security-group Syzop { mask { certfp "1234etc."; } }

Reported by Han`.

This also makes us throw a config error on the wrong case.
2022-06-05 08:42:05 +02:00
Bram Matthys 28d3875aa9 Make variables in set::reject-message and other buildvarstring() usage
no longer expand shorter versions of a variable. It previously had some
unintended form of magic autocomplete where $serv was handled the same
way as if it was $server. This could cause issues in the long run when
variables are added and the meaning of the short form changes.

Reported by westor in https://bugs.unrealircd.org/view.php?id=6123
2022-06-05 08:17:06 +02:00
Bram Matthys 020c3d1fa3 ** UnrealIRCd 6.0.4-rc2 ** 2022-06-03 18:48:52 +02:00
Bram Matthys 1311c8a963 Fix connthrottle message when throttling (bug introduced in 6.0.4-rc1).
Reported by westor in https://bugs.unrealircd.org/view.php?id=6121
2022-06-01 08:49:35 +02:00
Bram Matthys d5989695e8 Remove last global 'buf' variables. This was already done a lot in time
but it seems there were still a couple left. These are now gone as well.
There seem to be no issues with the ones that were left, but it is just
too easy to get it wrong. Declaring buf in function now. This should be
faster anyway, since it is located on nearby memory (stack).

Inspired by previous find from westor (c708a99955c034e842f913479cc597d87b311394).
2022-06-01 08:34:48 +02:00
Bram Matthys d3f655cb63 Fix space stripping at end of connect and disconnect message, in the
"extended_client_info". Was a typo, 'buf' vs 'retbuf'.
Reported by westor in https://github.com/unrealircd/unrealircd/pull/217
2022-06-01 08:21:03 +02:00
Bram Matthys 731adb308d set::restrict-commands: better error message if you use the same command twice (or more) 2022-05-30 13:05:04 +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 c8ef9b2740 Fix set::restrict-commands::except not working. Reported by Rain. 2022-05-29 15:13:12 +02:00
Bram Matthys 965bfa441b Crash reporter: use fclose() and not pclose() since this particular
file descriptor was opened by fopen() and not popen().
Fixes compile warning on Ubuntu 22.04 / GCC 11.
[skip ci]
2022-05-28 18:00:24 +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 c183c06d06 Move HOOKTYPE_LOCAL_CONNECT slightly further down.
[skip ci]
2022-05-26 20:56:36 +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 a4902e121c Fix crash when using 'account' in 'except ban'. 2022-05-26 17:31:45 +02:00
Bram Matthys 960c3cc1c1 And a similar fix for multi account, eg security-group xyz { account { a; b; c; } } 2022-05-26 17:21:30 +02:00
Bram Matthys fba0249ec3 Fix for when using security-group xyz { security-group { a; b; c; } } 2022-05-26 17:11:47 +02:00
Bram Matthys c9f8c42281 Fix CIDR not working in match { ip ....; } 2022-05-26 17:03:17 +02:00
Bram Matthys fe11f77be6 Fix +H not working in set::modes-on-join.
Reported by ZarTek-Creole in https://bugs.unrealircd.org/view.php?id=6114

We now call HOOKTYPE_LOCAL_CHANMODE on the modes we set in modes-on-join,
where 'client' is '&me'. Should be fine, as we already did the same for
+P modes (indirectly) in channeldb.
2022-05-26 07:14:12 +02:00
Bram Matthys 3936059768 ** UnrealIRCd 6.0.4-rc1 ** 2022-05-25 17:14:32 +02:00
Bram Matthys c86e5a3c2d Fix memory leak on REHASH when using parameter modes in set::modes-on-join 2022-05-25 16:52:41 +02:00