Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminate Connection if Browser is Closed During jbnc/irc Negotiation #68

Open
Madriix opened this issue Apr 5, 2024 · 3 comments
Open

Comments

@Madriix
Copy link
Collaborator

Madriix commented Apr 5, 2024

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,

@realrasengan
Copy link
Collaborator

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
Copy link
Collaborator

Sorry accidentally hit the close button :P

Just reopened!

@Madriix
Copy link
Collaborator Author

Madriix commented Apr 6, 2024

@realrasengan I believe you understood me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants