Bram Matthys
61e68d65da
Update a comment
...
[skip ci]
2022-12-05 14:51:22 +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
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
3ca99ddd52
Fix JSON-RPC response, should be in "result" and not in "response".
...
This breaks all the current script(s) that depend on it, of course,
but makes us correctly conform to the JSON-RPC specification.
Reported by Valware.
2022-08-17 16:56:33 +02:00
Bram Matthys
7267d81278
RPC: add spamfilter.list and spamfilter.add calls.
2022-08-02 09:28:09 +02:00
Bram Matthys
eb9aff4c1c
RPC: user.get: use JSON_RPC_ERROR_NOT_FOUND if user is not found.
2022-08-02 08:31:46 +02:00
Bram Matthys
b079aa3498
RPC: Fix "id" not showing up in error responses.
...
rpc_error() and rpc_error_fmt() were called with a NULL request.
This also fixes logging of RPC errors to show the name of the RPC call.
2022-08-02 08:30:03 +02:00
Bram Matthys
6749ab4e0c
RPC: server_ban: add handling of "expire_at".
...
Was previously always setting expiry to 5 seconds as a placeholder/TODO.
2022-08-02 08:22:28 +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
2c1457ae6b
RPC: add server_ban.del
2022-06-24 19:18:39 +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
d3697b8684
RPC: add tkl.list
2022-06-24 13:33:20 +02:00
Bram Matthys
14215e1837
Fix two memory leaks in RPC:
...
* on REHASH rpc-user block name was not freed
* temporary construct was not freed (if params was missing)
2022-06-22 14:54:51 +02:00
Bram Matthys
fdf0d545d7
Split rpc_client_handshake() into rpc_client_handshake_unix_socket()
...
and rpc_client_handshake_web().
Makes the code easier to follow / less chance of mistakes.
2022-06-22 13:53:56 +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
55387a8aa4
RPC: Fix strchr() on non-nul-terminated string (leading to OOB read)
2022-06-19 17:59:05 +02:00
Bram Matthys
8b2caf5501
Make listen::options::rpc implicitly enable TLS, so nobody
...
accidentally allows JSON-RPC over insecure HTTP.
2022-06-19 16:17:15 +02:00
Bram Matthys
5301ab5be8
Add some TODO items
2022-06-19 13:13:33 +00: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
f99085fc03
RPC: add user.get()
2022-06-19 13:13:33 +00:00
Bram Matthys
0e60b8bbfb
RPC: Add ?username=xyz&password=zzz authentication as well
...
FIXME: move URI parsing to 'webserver' and deal with unescaping %xx
2022-06-19 13:13:33 +00:00
Bram Matthys
c611f18d56
RPC: Add rpc-user { } block and do authentication
2022-06-19 13:13:33 +00:00
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
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
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
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
cbfcfa1428
Create src/modules/rpc directory
2022-06-19 13:13:33 +00:00