hirc

IRC client
Log | Files | Refs

commit bbb22f6ec23b81208c381317fa336bc7aca9db48
parent 194705d19cfdbe98d8dddf5cb6f5bf7e89076e73
Author: hhvn <dev@hhvn.uk>
Date:   Sun, 14 Nov 2021 13:48:54 +0000

handle.c: fix PONG expectation

Diffstat:
Mhandle.c | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/handle.c b/handle.c @@ -37,13 +37,18 @@ handle_PING(char *msg, char **params, struct Server *server, time_t timestamp) { void handle_PONG(char *msg, char **params, struct Server *server, time_t timestamp) { + int len; + if (**params == ':') params++; - if (param_len(params) < 2) + if ((len = param_len(params)) < 2) return; - if (strcmp_n(*(params+1), handle_expect_get(server, Expect_pong))) { + /* RFC1459 says that PONG should have a list of daemons, + * but that's not how PONG seems to work in modern IRC. + * Therefore, consider the last parameter as the "message" */ + if (strcmp_n(*(params + len - 1), handle_expect_get(server, Expect_pong)) == 0) { hist_add(server->history, NULL, msg, params, Activity_status, timestamp, HIST_DFL); handle_expect(server, Expect_pong, NULL); }