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

Cleanup: remove max_nick_length #109

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

llmII
Copy link
Contributor

@llmII llmII commented Mar 5, 2021

This setting is no longer needed as the information can be gained via the listener at runtime. This changes things to use go-ircevent's ISUPPORT support instead of defining it in the config.

Closes #106.

This one will need some testing, creating a draft. Need to review and see if puppets are only created after the listener has processed OnWelcome or if it is possible they exist before in which case getting the value from ISUPPORT isn't possible since the listener doesn't exist yet...

This setting is no longer needed as the information can be gained via
the listener at runtime. This changes things to use go-ircevent's
ISUPPORT support instead of defining it in the config.

Closes qaisjp#106.
@llmII llmII force-pushed the deprecate-max-nick-len branch from e58253f to d74cf45 Compare March 6, 2021 02:50
Comment on lines -122 to -124
// Maximum length of user nicks aloud
viper.SetDefault("max_nick_length", ircnick.MAXLENGTH)
maxNickLength := viper.GetInt("max_nick_length")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets tell the user that it's not detected at runtime and they should remove this field from their config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add it like we did for nickserv_identify (or you can if you want, I won't be able to get back to this till tomorrow, life events).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. In this one I merely inform the user, but don't actually exit the program. Let me know if we should tell the program to exit in this case.

@@ -302,7 +302,7 @@ func (m *IRCManager) generateNickname(discord DiscordUser) string {
suffix := m.bridge.Config.Suffix
newNick := nick + suffix

useFallback := len(newNick) > m.bridge.Config.MaxNickLength || m.bridge.ircListener.DoesUserExist(newNick)
useFallback := len(newNick) > int(m.bridge.ircListener.NickLength()) || m.bridge.ircListener.DoesUserExist(newNick)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this acquires a lock, so might not run great when connecting 300 people. but lets leave it in here for now unless you can think of an easy better solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, might be best to handle figuring out NickLength once per OnWelcome event in the listener and set it as a field on the Listener. However, probably need to also do an on disconnect and quit ordeal so as to clear it to a "hold up, we're not connected yet) value. Probably is overkill that last part because if a server changes this between the time of a quick disconnect and reconnect there's probably going to be other issues anyway...

Same as above applies... I'll try to get this implemented like I noted above tomorrow or if you want to you can take over for it, life events are gonna keep me away from it for the rest of today :/

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's okay, life is more important than a random internet irc bridge :) Take care of yourself!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC IRCd's send 376 (end of motd), and 422 (no motd found). Ideally the client should listen for these events and then process their prejoin commands and access ISUPPORT (which was sent earlier in 005). Should we go forward this direction instead of processing at 001?

Even if we do, I need to lock the HandleUser function out from running until 376/422 are handled and a NickLength is stored on the Listener. So to achieve a "don't lock per puppet creation" we sort of need the Listener to have a NickLength() call that with a sentinel variable that way we only lock once for the entire ordeal of getting the NickLength.

How expensive is a lock? would it actually make it impossible for 300 users to connect in the same second. I think I'm going to do the above but if you figure it's too complex or have a better idea I could go for that instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be committed, and a separate PR to fix things to use 376/422 should be created (which would include locking). I'm not trying to split things up too much but that's possibly a change that would need far deeper review than this change here.

@qaisjp
Copy link
Owner

qaisjp commented Mar 8, 2021

Need to review and see if puppets are only created after the listener has processed OnWelcome or if it is possible they exist before in which case getting the value from ISUPPORT isn't possible since the listener doesn't exist yet...

It seems to work, but very good call on wanting to test this!

qaisjp and others added 2 commits March 9, 2021 00:19
We now inform users they should remove this field from their config as
it is no longer necessary.
@llmII llmII marked this pull request as ready for review March 9, 2021 16:41
@qaisjp
Copy link
Owner

qaisjp commented Apr 6, 2021

Did you manage to test whether ISUPPORT is fetched from the listener before connecting the puppets?

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

Successfully merging this pull request may close these issues.

Removal of max_nick_length is now possible
2 participants