-
Notifications
You must be signed in to change notification settings - Fork 180
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
implement WHOX #1184
implement WHOX #1184
Conversation
irc/handlers.go
Outdated
@@ -2775,7 +2775,7 @@ func webircHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re | |||
return true | |||
} | |||
|
|||
// WHO [<mask> [o]] | |||
// WHO <mask> [<filteR>%<fields>,<type>] |
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.
smol nit, filteR
-> filter
happy to squash this before merge |
Still reviewing but wanted to get this down before I forget: we should be publishing a new ISUPPORT token with this, right? |
Could you post some sample input and output? |
irc/server.go
Outdated
flags = "G" | ||
} else { | ||
flags = "H" | ||
var whoFieldMap = map[rune]WhoFields{ |
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.
Here's what I'd actually do instead of defining these:
type WhoFields [128]bool
func (wf *WhoFields) Set(field rune) {
wf[int(field)] = true
}
func (wf *WhoFields) Has(field rune) bool {
return wf[int(field)]
}
i.e., just use the codepoint value of 't' or 'a' to index directly into a fixed-size array of bools. (We use similar techniques for modes.)
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 technique would also need bounds checking (or else you could up it to [256]bool
and operate on bytes instead of runes) but it's still probably worth it.
here's some example input and output
|
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.
Looks good. I'll leave this open for a bit so Dan (and possibly other people) can eyeball the sample output.
irc/server.go
Outdated
fAccount := "0" | ||
if target.accountName != "*" { | ||
// WHOX uses "0" to mean "no account" | ||
fAccount = target.accountName |
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.
details.accountName
irc/server.go
Outdated
params = append(params, details.nick) | ||
} | ||
if fields.Has('f') { // "flags" (away + oper state + channel status prefix + bot) | ||
flags := "" |
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.
maybe switch this to strings.Builder
while you're in the neighborhood?
I was asked to review this but my go fluency is poor. Probably best if this gets shoved onto a testnet somewhere and I'll exercise the implementation. |
I put this up on my stage: files.stronghold.network, TLS on port 6697. |
Behaviour of this looks fine and correct from a cursory check with /WHO #chan %tcuihsnfdlaor,123 calls |
@jesopo when you get a chance, can you:
|
This adds support for WHOX, without bothering about flags and mask2 because Solanum and Ergo [1] don't support it either. The motivation is to allow clients to reliably query account names. It's not possible to use WHOX tokens to route replies to the right client, because RPL_ENDOFWHO doesn't contain it. [1]: ergochat/ergo#1184 Closes: https://todo.sr.ht/~emersion/soju/135
first attempt. i assume there's going to be a few issues of artistic preference and me not being a Go expert so please be brutal.
mostly used InspIRCd's WHOX implementation as a reference for this (thnx @SadieCat ❤️) but also charybdis and http://faerion.sourceforge.net/doc/irc/whox.var
much like charybdis, we do not actually support the
filter
part of WHOX. I really do not think it's important enough for the complexity it would add to this PR.I've not yet implemented the
o
field (channel power level) because I couldn't quite figure out how I'd want to give channel status modes int values. thought I'd leave that up to a discussion,