diff --git a/doc/RELEASE-NOTES.md b/doc/RELEASE-NOTES.md index d78d3776a..bb72eda0a 100644 --- a/doc/RELEASE-NOTES.md +++ b/doc/RELEASE-NOTES.md @@ -51,6 +51,12 @@ in progress and not a stable version. * The [blacklist-module](https://www.unrealircd.org/docs/Blacklist-module_directive) directive now accepts wildcards, eg `blacklist-module rpc/*;` +### Developers and protocol: +* JSON-RPC supports + [UNIX domain sockets](https://www.unrealircd.org/docs/JSON-RPC:Technical_documentation#UNIX_domain_socket) + for making RPC calls. If those are used, we now split on `\n` (newline) + so multiple parallel requests can be handled properly. + UnrealIRCd 6.0.7 ----------------- diff --git a/src/modules/rpc/rpc.c b/src/modules/rpc/rpc.c index dabf6755e..ddc5429ee 100644 --- a/src/modules/rpc/rpc.c +++ b/src/modules/rpc/rpc.c @@ -498,13 +498,22 @@ int rpc_packet_in_websocket(Client *client, char *readbuf, int length) int rpc_packet_in_unix_socket(Client *client, const char *readbuf, int *length) { + char buf[READBUFSIZE]; + if (!RPC_PORT(client) || !(client->local->listener->socket_type == SOCKET_TYPE_UNIX) || (*length <= 0)) return 1; /* Not for us */ - // FIXME: this assumes a single request in 'readbuf' while in fact: - // - it could only contain partial JSON, eg no ending } yet - // - there could be multiple requests - rpc_call_text(client, readbuf, *length); + dbuf_put(&client->local->recvQ, readbuf, *length); + + while (DBufLength(&client->local->recvQ)) + { + int len = dbuf_getmsg(&client->local->recvQ, buf); + if (len <= 0) + break; + rpc_call_text(client, buf, len); + if (IsDead(client)) + break; + } return 0; }