Add support for downstream LIST to a single upstream
Sometimes, doing a LIST on a single upstream can be useful: if a user is already connected to Rizon and freenode, sending a LIST will contain tens of thousands of LIST replies that may not be useful if the user is interested in another upstream. This adds support for sending `LIST */network`, which follows the ELIST M mask extension, that will only send LIST to that specific network. No other masks are supported by this commit.
This commit is contained in:
parent
2d47d7067f
commit
a64e1d6761
@ -1220,21 +1220,30 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
downstreamID: dc.id,
|
downstreamID: dc.id,
|
||||||
pendingCommands: make(map[int64]*irc.Message),
|
pendingCommands: make(map[int64]*irc.Message),
|
||||||
}
|
}
|
||||||
|
var upstream *upstreamConn
|
||||||
var upstreamChannels map[int64][]string
|
var upstreamChannels map[int64][]string
|
||||||
if len(msg.Params) > 0 {
|
if len(msg.Params) > 0 {
|
||||||
upstreamChannels = make(map[int64][]string)
|
uc, upstreamMask, err := dc.unmarshalEntity(msg.Params[0])
|
||||||
channels := strings.Split(msg.Params[0], ",")
|
if err == nil && upstreamMask == "*" { // LIST */network: send LIST only to one network
|
||||||
for _, channel := range channels {
|
upstream = uc
|
||||||
uc, upstreamChannel, err := dc.unmarshalEntity(channel)
|
} else {
|
||||||
if err != nil {
|
upstreamChannels = make(map[int64][]string)
|
||||||
return err
|
channels := strings.Split(msg.Params[0], ",")
|
||||||
|
for _, channel := range channels {
|
||||||
|
uc, upstreamChannel, err := dc.unmarshalEntity(channel)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
upstreamChannels[uc.network.ID] = append(upstreamChannels[uc.network.ID], upstreamChannel)
|
||||||
}
|
}
|
||||||
upstreamChannels[uc.network.ID] = append(upstreamChannels[uc.network.ID], upstreamChannel)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.user.pendingLISTs = append(dc.user.pendingLISTs, pl)
|
dc.user.pendingLISTs = append(dc.user.pendingLISTs, pl)
|
||||||
dc.forEachUpstream(func(uc *upstreamConn) {
|
dc.forEachUpstream(func(uc *upstreamConn) {
|
||||||
|
if upstream != nil && upstream != uc {
|
||||||
|
return
|
||||||
|
}
|
||||||
var params []string
|
var params []string
|
||||||
if upstreamChannels != nil {
|
if upstreamChannels != nil {
|
||||||
if channels, ok := upstreamChannels[uc.network.ID]; ok {
|
if channels, ok := upstreamChannels[uc.network.ID]; ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user