Simplify and improve WHOIS forwarding
Group together most WHOIS replies. While at it, add a few missing replies.
This commit is contained in:
parent
303c663d02
commit
747263fc2d
11
irc.go
11
irc.go
@ -15,13 +15,20 @@ const (
|
||||
rpl_statsping = "246"
|
||||
rpl_localusers = "265"
|
||||
rpl_globalusers = "266"
|
||||
rpl_whoiscertfp = "276"
|
||||
rpl_whoisregnick = "307"
|
||||
rpl_whoisspecial = "320"
|
||||
rpl_creationtime = "329"
|
||||
rpl_topicwhotime = "333"
|
||||
rpl_whospcrpl = "354"
|
||||
rpl_whoisaccount = "330"
|
||||
rpl_topicwhotime = "333"
|
||||
rpl_whoisactually = "338"
|
||||
rpl_whospcrpl = "354"
|
||||
rpl_whoishost = "378"
|
||||
rpl_whoismodes = "379"
|
||||
rpl_visiblehost = "396"
|
||||
err_unknownerror = "400"
|
||||
err_invalidcapcmd = "410"
|
||||
rpl_whoissecure = "671"
|
||||
|
||||
// https://ircv3.net/specs/extensions/bot-mode
|
||||
rpl_whoisbot = "335"
|
||||
|
55
upstream.go
55
upstream.go
@ -1428,63 +1428,16 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
||||
Command: irc.RPL_ENDOFWHO,
|
||||
Params: []string{dc.nick, mask, "End of /WHO list"},
|
||||
})
|
||||
case irc.RPL_WHOISUSER:
|
||||
var nick, username, host, realname string
|
||||
if err := parseMessageParams(msg, nil, &nick, &username, &host, nil, &realname); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) {
|
||||
nick := dc.marshalEntity(uc.network, nick)
|
||||
dc.SendMessage(&irc.Message{
|
||||
Prefix: dc.srv.prefix(),
|
||||
Command: irc.RPL_WHOISUSER,
|
||||
Params: []string{dc.nick, nick, username, host, "*", realname},
|
||||
})
|
||||
})
|
||||
case irc.RPL_WHOISSERVER:
|
||||
var nick, server, serverInfo string
|
||||
if err := parseMessageParams(msg, nil, &nick, &server, &serverInfo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) {
|
||||
nick := dc.marshalEntity(uc.network, nick)
|
||||
dc.SendMessage(&irc.Message{
|
||||
Prefix: dc.srv.prefix(),
|
||||
Command: irc.RPL_WHOISSERVER,
|
||||
Params: []string{dc.nick, nick, server, serverInfo},
|
||||
})
|
||||
})
|
||||
case irc.RPL_WHOISOPERATOR:
|
||||
case rpl_whoiscertfp, rpl_whoisregnick, irc.RPL_WHOISUSER, irc.RPL_WHOISSERVER, irc.RPL_WHOISOPERATOR, irc.RPL_WHOISIDLE, rpl_whoisspecial, rpl_whoisaccount, rpl_whoisactually, rpl_whoishost, rpl_whoismodes, rpl_whoissecure:
|
||||
var nick string
|
||||
if err := parseMessageParams(msg, nil, &nick); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) {
|
||||
nick := dc.marshalEntity(uc.network, nick)
|
||||
dc.SendMessage(&irc.Message{
|
||||
Prefix: dc.srv.prefix(),
|
||||
Command: irc.RPL_WHOISOPERATOR,
|
||||
Params: []string{dc.nick, nick, "is an IRC operator"},
|
||||
})
|
||||
})
|
||||
case irc.RPL_WHOISIDLE:
|
||||
var nick string
|
||||
if err := parseMessageParams(msg, nil, &nick, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) {
|
||||
nick := dc.marshalEntity(uc.network, nick)
|
||||
params := []string{dc.nick, nick}
|
||||
params = append(params, msg.Params[2:]...)
|
||||
dc.SendMessage(&irc.Message{
|
||||
Prefix: dc.srv.prefix(),
|
||||
Command: irc.RPL_WHOISIDLE,
|
||||
Params: params,
|
||||
})
|
||||
msg := msg.Copy()
|
||||
msg.Params[1] = dc.marshalEntity(uc.network, nick)
|
||||
dc.SendMessage(msg)
|
||||
})
|
||||
case irc.RPL_WHOISCHANNELS:
|
||||
var nick, channelList string
|
||||
|
Loading…
Reference in New Issue
Block a user