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

2760 Commits

Author SHA1 Message Date
Bram Matthys ab999659fc Remove some FIXME's and cleanup code a little bit. 2022-06-19 13:13:33 +00:00
Bram Matthys e718d2021f Make websocket work over RPC 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 7679ec7920 Get rid of cast, do things properly. 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 3e35b8e96a Small code cleanup 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 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 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 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 53732e0f78 Warn if 'websocket' module is loaded without 'webserver' (= won't work). 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 2397fb8a49 Split 'websocket' module up in 'webserver' and 'websocket' 2022-06-19 13:13:33 +00: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 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 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 c8ef9b2740 Fix set::restrict-commands::except not working. Reported by Rain. 2022-05-29 15:13:12 +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 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 ce6be5df61 Reputation was synced correctly on IP basis (and thus the databases)
across servers if they differed, however the individual IP of users
was not updated until next add_scores() run. So, there would be an
up to 5 minute delay during which scores for individual users were
possibly too low, with all the effects that it could possibly have
nowadays such as restrict-commands, more stringent flood limits, etc.

If your servers are all linked all the time then you would not have
noticed this issue. It mostly matters if you are linking in a new
server or if the server has been delinked or out of order for days
or weeks.
2022-05-25 16:40:06 +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 c04ad96357 Add to JSON logging output: "geoip" with subitem "country_code".
Suggested by westor in https://bugs.unrealircd.org/view.php?id=6083

(It is not under "user" because the info can be useful before someone
 is considered a user, eg when flooding/rejected/etc)
2022-05-23 11:20:59 +02:00
Bram Matthys 0f7555e4c5 Add to JSON logging output: "tls" with subitems "cipher" and "certfp".
Suggested by westor in https://bugs.unrealircd.org/view.php?id=6083

(It is not under "user" because it is for servers too)
2022-05-23 11:07:08 +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
Bram Matthys 5d9a201df8 Don't show security-groups of ulines like NickServ (since it is irrelevant anyway).
Reported by Lord255.
2022-05-16 11:22:57 +02:00
Bram Matthys 2108bb48fa Run labeled-response through the quick path. 2022-05-16 09:53:23 +02:00
Bram Matthys 519d027a62 Fix geoip_base_unserialize() check being the wrong way around.
Could have caused a memory leak but likely did not happen at all
in practice.
2022-05-15 19:34:46 +02:00
Bram Matthys c037486263 Add blacklist::except for exempting users from individual blacklists,
this is a https://www.unrealircd.org/docs/Mask_item so very flexible.

Note that most people would want to use except ban { } instead to
simply exempt from ALL blacklists. (that one does not yet have the
flexible mask capability though.. but it wil have it soon..)
2022-05-15 15:13:19 +02:00
Bram Matthys 0b45e34e62 Simplifly RPL_HOSTHIDDEN notification.
Pretty much everywhere we had:
0001 userhost_changed(client);
0002 if (MyUser(client))
0003         sendnumeric(client, RPL_HOSTHIDDEN, client->user->virthost);

Lines 2-3 are now integrated in userhost_changed().

Also fix two issues with CHGHOST in make_oper():
* if user was -x, modes had +x and a vhost, it would send the cloaked
  host in the original vhost, while it should have been the real host
* if user was -x and went +x without vhost (so only uncloaked to cloaked)
  then no CHGHOST message was sent at all
2022-05-15 07:45:00 +02:00
Bram Matthys 9e0340d4c1 Change restrict-commands to use ::except which is a
https://www.unrealircd.org/docs/Mask_item so has more functionality.

The old style config still works and UnrealIRCd won't complain
about it for now.
2022-05-14 18:50:24 +02:00
Bram Matthys 3241338cf3 Add set::connthrottle::except, which is a mask item.
Automatically convert the old options ::sasl-bypass, ::webirc-bypass
and ::minimum-reputation-score, so nobody needs to update their config.

The example.conf has been updated.
2022-05-14 15:31:30 +02:00
Bram Matthys 915b603a6a Add set::antirandom::except, which is a mask item.
Automatically convert the old style ::except-hosts and ::except-webirc
so nobody needs to update their config.
2022-05-14 15:17:29 +02:00
Bram Matthys f0ddbdaa44 Add set::antimixedutf8::except, which is a mask item too. 2022-05-14 15:07:33 +02:00