jbnc icon indicating copy to clipboard operation
jbnc copied to clipboard

Terminate Connection if Browser is Closed During jbnc/irc Negotiation

Open Madriix opened this issue 1 year ago • 3 comments

Hi,

I have an idea in mind for jbnc but it's not easy to implement, let me explain in detail. Imagine that during the process from when we connect to IRC with jbnc, we go through the PASS, NICK, USER, SASL, 001, 005, MOTD steps; I'll refer to this as the "connection path." Now, imagine with a web IRC client, you're in your browser and you connect to IRC, but you close the browser before reaching the raw 005. Without the regular user knowing, the connection persists, but it should abruptly stop, disconnecting from IRC.

There's also the same issue with reconnecting to IRC (with clientReconnect). During reconnection, sometimes the regular user closes the browser before reaching raw 005, but the connection still reaches its goal. However, it should stop immediately, disregarding all commands sent to IRC, or even stopping the connection to IRC or jbnc altogether.

In summary, we need to find a way to send socket.end(); and close all connections if we exit jbnc without reaching 005/MOTD; here, it should either terminate jbnc or the IRC connection.

How would we go about doing this?

Best regards,

Madriix avatar Apr 05 '24 10:04 Madriix

I think I understand the dilemma being presented.

For this, in a websocket you could create an "ACKNOWLEDGEMENT" system such that every message sent must be proceeded with a response msg acknowledging receipt of said packet (e..g., a hash or other identifying material such that the sender can be certain the original packet was received intact). This would be the best but would, overcourse, create significant overhead.

Another option would be to create a Temporary connection class until 005/MOTD is reached such that the user never becomes a 'connected user' until 005/MOTD is reached.

I've been working on a 'decentralized IRC' implementation, and this is what I did there:

https://github.com/realrasengan/dwebchat/blob/main/lib/tempclient.js https://github.com/realrasengan/dwebchat/blob/main/lib/client.js

The user only becomes a full client after the registration is complete (in the JBNC case we could make registration complete after receipt of 005/or MOTD).

Is this inline with what you were thinking or am I way off? x_x;

realrasengan avatar Apr 05 '24 13:04 realrasengan

Sorry accidentally hit the close button :P

Just reopened!

realrasengan avatar Apr 05 '24 13:04 realrasengan

@realrasengan I believe you understood me.

Madriix avatar Apr 06 '24 14:04 Madriix