pounce: 004 RPL_MYINFO problem

pounce: 004 RPL_MYINFO problem

From: Sebastien Marie
Hi,

I am starting to look to use pounce(1) for my personal usage, and I has
some problems with the expectation from handleReplyMyInfo() for 2
differents IRC servers.

The first public server is `irc.chat.twitch.tv` (see
https://dev.twitch.tv/docs/chat/irc/).

pounce output is the following:

```
<< CAP LS 302
<< PASS :oauth:.......
<< NICK semarie_
<< USER semarie_ 0 * :Sebastien Marie
>> :tmi.twitch.tv CAP * LS :twitch.tv/commands twitch.tv/membership twitch.tv/tags
<< CAP END
>> :tmi.twitch.tv 001 semarie_ :Welcome, GLHF!
>> :tmi.twitch.tv 002 semarie_ :Your host is tmi.twitch.tv
>> :tmi.twitch.tv 003 semarie_ :This server is rather new
>> :tmi.twitch.tv 004 semarie_ :-
pounce: 004 missing parameter 3
```

The second server is icbirc program, a proxy between irc and icb
protocol. see https://www.benzedrine.ch/icbirc.html

icbirc only send 001 (RPL_WELCOME) and 002 (RPL_YOURHOST) on successful
registration. But it seems not compliant with rfc2812 section 5.1 "The
server sends Replies 001 to 004 to a user upon successful
registration.", and I could send a patch to upstream if need.


For both servers, catgirl(1) is working. Only pounce(1) has an hard
requirement on the number of parameters for 004 (RPL_MYINFO).

From the rfc2812, it isn't clear to me if the reply should have
different parameters or is just a "free string".

https://www.rfc-editor.org/rfc/rfc2812 section 5.1
       004    RPL_MYINFO
              "<servername> <version> <available user modes>
               <available channel modes>"

pounce(1) seems to be using RPL_MYINFO only as part of stateReady() (so
it is blocking advancement for icbirc as no 004 RPL_MYINFO are issued).

The following diff (against pounce 3.1) removes the hard requirement on
the number of parameters.

--- state.c.orig.port	Mon Oct 28 11:23:37 2024
+++ state.c	Mon Oct 28 11:24:41 2024
@@ -198,11 +198,11 @@
 }
 
 static void handleReplyMyInfo(struct Message *msg) {
-	require(msg, false, 5);
+	require(msg, false, 2);
 	set(&intro.myInfo[0], msg->params[1]);
-	set(&intro.myInfo[1], msg->params[2]);
-	set(&intro.myInfo[2], msg->params[3]);
-	set(&intro.myInfo[3], msg->params[4]);
+	if (msg->params[2]) set(&intro.myInfo[1], msg->params[2]);
+	if (msg->params[3]) set(&intro.myInfo[2], msg->params[3]);
+	if (msg->params[4]) set(&intro.myInfo[3], msg->params[4]);
 	if (msg->params[5]) set(&intro.myInfo[4], msg->params[5]);
 }
 
@@ -418,9 +418,12 @@
 		intro.origin, self.nick, intro.created
 	);
 	clientFormat(
-		client, ":%s 004 %s %s %s %s %s%s%s\r\n",
+		client, ":%s 004 %s %s%s%s%s%s%s%s%s%s\r\n",
 		intro.origin, self.nick,
-		intro.myInfo[0], intro.myInfo[1], intro.myInfo[2], intro.myInfo[3],
+		intro.myInfo[0],
+		(intro.myInfo[1] ? " " : ""), (intro.myInfo[1] ? intro.myInfo[1] : ""),
+		(intro.myInfo[2] ? " " : ""), (intro.myInfo[2] ? intro.myInfo[2] : ""),
+		(intro.myInfo[3] ? " " : ""), (intro.myInfo[3] ? intro.myInfo[3] : ""),
 		(intro.myInfo[4] ? " " : ""), (intro.myInfo[4] ? intro.myInfo[4] : "")
 	);
 
With it, I am able to connect to twitch irc server, and to (patched)
icbirc server.

I didn't change stateReady() function
(https://git.causal.agency/pounce/tree/state.c#stateReady) as 001-004
seems to be a rfc2812 requirement.

Thanks.
-- 
Sebastien Marie

Re: pounce: 004 RPL_MYINFO problem

From: june
could you let me know if this alternative patch works for you?

https://git.causal.agency/pounce/commit/?id=c23e879d060730d6b9484fd7c6554f11ad76b5fa

Re: pounce: 004 RPL_MYINFO problem

From: Sebastien Marie
To: june
june <june@causal.agency> writes:

> could you let me know if this alternative patch works for you?
>
> https://git.causal.agency/pounce/commit/?id=c23e879d060730d6b9484fd7c6554f11ad76b5fa
>

yes it is working.

thanks.
-- 
Sebastien Marie