-
Notifications
You must be signed in to change notification settings - Fork 32
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ import ( | |
"github.com/gobwas/glob" | ||
"github.com/pkg/errors" | ||
"github.com/qaisjp/go-discord-irc/bridge" | ||
ircnick "github.com/qaisjp/go-discord-irc/irc/nick" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/viper" | ||
) | ||
|
@@ -119,9 +118,10 @@ func main() { | |
// | ||
viper.SetDefault("show_joinquit", false) | ||
showJoinQuit := viper.GetBool("show_joinquit") | ||
// Maximum length of user nicks aloud | ||
viper.SetDefault("max_nick_length", ircnick.MAXLENGTH) | ||
maxNickLength := viper.GetInt("max_nick_length") | ||
Comment on lines
-122
to
-124
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add it like we did for There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
if viper.GetInt("max_nick_length") != 0 { | ||
log.Println("This field should be removed from your configuration - go-discord-irc now detects the proper max accepted nick length at runtime.") | ||
} | ||
|
||
if webIRCPass == "" { | ||
log.Warnln("webirc_pass is empty") | ||
|
@@ -167,7 +167,6 @@ func main() { | |
ChannelMappings: channelMappings, | ||
CooldownDuration: time.Second * time.Duration(cooldownDuration), | ||
ShowJoinQuit: showJoinQuit, | ||
MaxNickLength: maxNickLength, | ||
|
||
Debug: *debugMode, | ||
DebugPresence: *debugPresence, | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :/
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.