From 08e13a3ac58896fd9a0a2e5a004f9b180d1dfeeb Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 18 Jun 2021 20:34:11 +0100 Subject: Replace identify-msg support with solanum.chat/identify-msg. --- src/common/proto-irc.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) (limited to 'src/common/proto-irc.c') diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index c8e44b62..54a73e97 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -1189,8 +1189,6 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[], case WORDL('N','O','T','I'): { - int id = FALSE; /* identified */ - text = word_eol[4]; if (*text == ':') { @@ -1219,18 +1217,8 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[], } #endif - if (serv->have_idmsg) - { - if (*text == '+') - { - id = TRUE; - text++; - } else if (*text == '-') - text++; - } - if (!ignore_check (word[1], IG_NOTI)) - inbound_notice (serv, word[3], nick, text, ip, id, tags_data); + inbound_notice (serv, word[3], nick, text, ip, tags_data->identified, tags_data); } return; @@ -1238,7 +1226,6 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[], { char *to = word[3]; int len; - int id = FALSE; /* identified */ if (*to) { /* Handle limited channel messages, for now no special event */ @@ -1249,15 +1236,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[], text = word_eol[4]; if (*text == ':') text++; - if (serv->have_idmsg) - { - if (*text == '+') - { - id = TRUE; - text++; - } else if (*text == '-') - text++; - } + len = strlen (text); if (text[0] == 1) /* ctcp */ { @@ -1289,7 +1268,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[], } } - ctcp_handle (sess, to, nick, ip, text, word, word_eol, id, + ctcp_handle (sess, to, nick, ip, text, word, word_eol, tags_data->identified, tags_data); /* Note word will be invalid beyond this scope */ @@ -1300,13 +1279,13 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[], { if (ignore_check (word[1], IG_CHAN)) return; - inbound_chanmsg (serv, NULL, to, nick, text, FALSE, id, + inbound_chanmsg (serv, NULL, to, nick, text, FALSE, tags_data->identified, tags_data); } else { if (ignore_check (word[1], IG_PRIV)) return; - inbound_privmsg (serv, nick, ip, text, id, tags_data); + inbound_privmsg (serv, nick, ip, text, tags_data->identified, tags_data); } } } @@ -1537,6 +1516,9 @@ handle_message_tags (server *serv, const char *tags_str, if (serv->have_account_tag && !strcmp (key, "account")) tags_data->account = g_strdup (value); + if (serv->have_idmsg && strcmp (key, "solanum.chat/identified")) + tags_data->identified = TRUE; + if (serv->have_server_time && !strcmp (key, "time")) handle_message_tag_time (value, tags_data); } -- cgit 1.4.1 From d5b45773157f40e1f078a5b02695d3fa2bb41b2d Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 21 Jun 2021 00:29:36 +0100 Subject: Implement generic support for IRCv3 standard replies. (#2589) https://ircv3.net/specs/extensions/standard-replies Co-authored-by: Patrick --- src/common/proto-irc.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/common/text.c | 11 +++++++++++ src/common/textevents.in | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) (limited to 'src/common/proto-irc.c') diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index 54a73e97..e0aa888e 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -460,6 +460,18 @@ channel_date (session *sess, char *chan, char *timestr, tags_data->timestamp); } +static int +trailing_index(const char *word_eol[]) +{ + int param_index; + for (param_index = 3; param_index < PDIWORDS; ++param_index) + { + if (word_eol[param_index][0] == ':') + break; + } + return param_index; +} + static void process_numeric (session * sess, int n, char *word[], char *word_eol[], char *text, @@ -1139,6 +1151,39 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[], (word_eol[3][0] == ':') ? word_eol[3] + 1 : NULL, tags_data); return; + + case WORDL('F','A','I','L'): + text = STRIP_COLON(word, word_eol, trailing_index(word_eol)); + if (g_strcmp0(word[3], "*") == 0) + { + EMIT_SIGNAL_TIMESTAMP (XP_TE_FAIL, sess, word[4], text, NULL, NULL, NULL, tags_data->timestamp); + } else + { + EMIT_SIGNAL_TIMESTAMP (XP_TE_FAILCMD, sess, word[3], word[4], text, NULL, NULL, tags_data->timestamp); + } + return; + + case WORDL('W','A','R','N'): + text = STRIP_COLON(word, word_eol, trailing_index(word_eol)); + if (g_strcmp0(word[3], "*") == 0) + { + EMIT_SIGNAL_TIMESTAMP (XP_TE_WARN, sess, word[4], text, NULL, NULL, NULL, tags_data->timestamp); + } else + { + EMIT_SIGNAL_TIMESTAMP (XP_TE_WARNCMD, sess, word[3], word[4], text, NULL, NULL, tags_data->timestamp); + } + return; + + case WORDL('N','O','T','E'): + text = STRIP_COLON(word, word_eol, trailing_index(word_eol)); + if (g_strcmp0(word[3], "*") == 0) + { + EMIT_SIGNAL_TIMESTAMP (XP_TE_NOTE, sess, word[4], text, NULL, NULL, NULL, tags_data->timestamp); + } else + { + EMIT_SIGNAL_TIMESTAMP (XP_TE_NOTECMD, sess, word[3], word[4], text, NULL, NULL, tags_data->timestamp); + } + return; } goto garbage; diff --git a/src/common/text.c b/src/common/text.c index b0a90e03..a77700fa 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -1512,6 +1512,17 @@ static char * const pevt_discon_help[] = { N_("Error"), }; +static char * const pevt_stdrpl_help[] = { + N_("Error Code"), + N_("Error Message"), +}; + +static char * const pevt_stdrplcmd_help[] = { + N_("Command"), + N_("Error Code"), + N_("Error Message"), +}; + #include "textevents.h" static void diff --git a/src/common/textevents.in b/src/common/textevents.in index 14bd4b06..19b0d497 100644 --- a/src/common/textevents.in +++ b/src/common/textevents.in @@ -436,6 +436,18 @@ pevt_discon_help %C20*%O$tDisconnected (%C20$1%O) 1 +Fail +XP_TE_FAIL +pevt_stdrpl_help +%C20*%O$t$2%O +2 + +Fail Command +XP_TE_FAILCMD +pevt_stdrplcmd_help +%C20*%O$t$1: $3%O +3 + Found IP XP_TE_FOUNDIP pevt_foundip_help @@ -574,6 +586,18 @@ pevt_generic_none_help %C23*%O$tNo process is currently running 0 +Note +XP_TE_NOTE +pevt_stdrpl_help +%C22*%O$t$2%O +2 + +Note Command +XP_TE_NOTECMD +pevt_stdrplcmd_help +%C22*%O$t$1: $3%O +3 + Notice XP_TE_NOTICE pevt_notice_help @@ -802,6 +826,18 @@ pevt_usersonchan_help %C22*%O$tUsers on %C22$1%C: %C24$2%O 2 +Warn +XP_TE_WARN +pevt_stdrpl_help +%C23*%O$t$2%O +2 + +Warn Command +XP_TE_WARNCMD +pevt_stdrplcmd_help +%C23*%O$t$1: $3%O +3 + WhoIs Authenticated XP_TE_WHOIS_AUTH pevt_whoisauth_help -- cgit 1.4.1 From 199c03c8c671d86819cace9a75d7f6bca54b6589 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 22 Jun 2021 13:59:43 +0100 Subject: Fix parsing +beI lists on InspIRCd. --- src/common/proto-irc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/common/proto-irc.c') diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index e0aa888e..501bf5a0 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -813,7 +813,7 @@ process_numeric (session * sess, int n, break; case 346: /* +I-list entry */ - if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 346, + if (!inbound_banlist (sess, atol (STRIP_COLON (word, word_eol, 7)), word[4], word[5], word[6], 346, tags_data)) goto def; break; @@ -824,7 +824,7 @@ process_numeric (session * sess, int n, break; case 348: /* +e-list entry */ - if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 348, + if (!inbound_banlist (sess, atol (STRIP_COLON (word, word_eol, 7)), word[4], word[5], word[6], 348, tags_data)) goto def; break; @@ -849,7 +849,7 @@ process_numeric (session * sess, int n, break; case 367: /* banlist entry */ - if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 367, + if (!inbound_banlist (sess, atol (STRIP_COLON (word, word_eol, 7)), word[4], word[5], word[6], 367, tags_data)) goto def; break; -- cgit 1.4.1 From ef0e67039258b7db11838496c61dbdec0be97f60 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 23 Aug 2021 16:34:13 +0100 Subject: Remove some weird guesswork on the 004 numeric. (#2621) Bahamut and ircu both send 005 MODES and ELIST so this is entirely unnecessary. The other IRCd checked for here is for a dead network. While we're editing this code fix HexChat on servers that can only support one mode at a time (these are mostly gateway servers). --- src/common/modes.c | 4 ++-- src/common/proto-irc.c | 16 ---------------- src/common/server.c | 2 ++ 3 files changed, 4 insertions(+), 18 deletions(-) (limited to 'src/common/proto-irc.c') diff --git a/src/common/modes.c b/src/common/modes.c index 17f9ce99..188d2197 100644 --- a/src/common/modes.c +++ b/src/common/modes.c @@ -67,8 +67,8 @@ send_channel_modes (session *sess, char *tbuf, char *word[], int wpos, int usable_modes, orig_len, len, wlen, i, max; server *serv = sess->server; - /* sanity check. IRC RFC says three per line. */ - if (serv->modes_per_line < 3) + /* sanity check. IRC RFC says three per line but some servers may support less. */ + if (serv->modes_per_line < 1) serv->modes_per_line = 3; if (modes_per_line < 1) modes_per_line = serv->modes_per_line; diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index 501bf5a0..49017506 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -503,22 +503,6 @@ process_numeric (session * sess, int n, goto def; - case 4: /* check the ircd type */ - serv->use_listargs = FALSE; - serv->modes_per_line = 3; /* default to IRC RFC */ - if (strncmp (word[5], "bahamut", 7) == 0) /* DALNet */ - { - serv->use_listargs = TRUE; /* use the /list args */ - } else if (strncmp (word[5], "u2.10.", 6) == 0) /* Undernet */ - { - serv->use_listargs = TRUE; /* use the /list args */ - serv->modes_per_line = 6; /* allow 6 modes per line */ - } else if (strncmp (word[5], "glx2", 4) == 0) - { - serv->use_listargs = TRUE; /* use the /list args */ - } - goto def; - case 5: inbound_005 (serv, word, tags_data); goto def; diff --git a/src/common/server.c b/src/common/server.c index 4f809fa8..0c0306d5 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -1770,6 +1770,7 @@ server_set_defaults (server *serv) serv->chanmodes = g_strdup ("beI,k,l"); serv->nick_prefixes = g_strdup ("@%+"); serv->nick_modes = g_strdup ("ohv"); + serv->modes_per_line = 3; /* https://datatracker.ietf.org/doc/html/rfc1459#section-4.2.3.1 */ serv->sasl_mech = MECH_PLAIN; if (!serv->encoding) @@ -1778,6 +1779,7 @@ server_set_defaults (server *serv) serv->nickcount = 1; serv->end_of_motd = FALSE; serv->sent_capend = FALSE; + serv->use_listargs = FALSE; serv->is_away = FALSE; serv->supports_watch = FALSE; serv->supports_monitor = FALSE; -- cgit 1.4.1 From f42f6af1b96f80280a2e5a5e2431dc32d2b8fd55 Mon Sep 17 00:00:00 2001 From: alicetries <92898519+alicetries@users.noreply.github.com> Date: Thu, 21 Oct 2021 01:56:05 +0100 Subject: Adjust parsing of RPL_WHOISSPECIAL to handle missing : for single-word whois messages This is to support parsing the RPL_WHOISSPECIAL from unrealircd correctly if the whois message is a single word. --- src/common/proto-irc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common/proto-irc.c') diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index 49017506..a8d997b6 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -627,7 +627,7 @@ process_numeric (session * sess, int n, case 320: /* :is an identified user */ if (!serv->skip_next_whois) EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS_ID, whois_sess, word[4], - word_eol[5] + 1, NULL, NULL, 0, + word_eol[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], NULL, NULL, 0, tags_data->timestamp); break; -- cgit 1.4.1 From 133f62806441a5db1156653aa1f077d2e8deeb34 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 1 Apr 2022 17:24:59 +0100 Subject: Display common help numerics as SERVTEXT. This makes it a lot easier for users to actually read. --- src/common/proto-irc.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/common/proto-irc.c') diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index a8d997b6..32cc47f2 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -920,6 +920,14 @@ process_numeric (session * sess, int n, notify_set_online (serv, word[4], tags_data); break; + case 524: // ERR_HELPNOTFOUND + case 704: // RPL_HELPSTART + case 705: // RPL_HELPTXT + case 706: // RPL_ENDOFHELP + EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, sess, STRIP_COLON(word, word_eol, 5), NULL, NULL, NULL, + 0, tags_data->timestamp); + break; + case 728: /* +q-list entry */ /* NOTE: FREENODE returns these results inconsistent with e.g. +b */ /* Who else has imlemented MODE_QUIET, I wonder? */ -- cgit 1.4.1