Changeset 298 in code for trunk/downstream.go


Ignore:
Timestamp:
May 27, 2020, 9:43:46 PM (5 years ago)
Author:
delthas
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r297 r298  
    12211221                        pendingCommands: make(map[int64]*irc.Message),
    12221222                }
     1223                var upstream *upstreamConn
    12231224                var upstreamChannels map[int64][]string
    12241225                if len(msg.Params) > 0 {
    1225                         upstreamChannels = make(map[int64][]string)
    1226                         channels := strings.Split(msg.Params[0], ",")
    1227                         for _, channel := range channels {
    1228                                 uc, upstreamChannel, err := dc.unmarshalEntity(channel)
    1229                                 if err != nil {
    1230                                         return err
     1226                        uc, upstreamMask, err := dc.unmarshalEntity(msg.Params[0])
     1227                        if err == nil && upstreamMask == "*" { // LIST */network: send LIST only to one network
     1228                                upstream = uc
     1229                        } else {
     1230                                upstreamChannels = make(map[int64][]string)
     1231                                channels := strings.Split(msg.Params[0], ",")
     1232                                for _, channel := range channels {
     1233                                        uc, upstreamChannel, err := dc.unmarshalEntity(channel)
     1234                                        if err != nil {
     1235                                                return err
     1236                                        }
     1237                                        upstreamChannels[uc.network.ID] = append(upstreamChannels[uc.network.ID], upstreamChannel)
    12311238                                }
    1232                                 upstreamChannels[uc.network.ID] = append(upstreamChannels[uc.network.ID], upstreamChannel)
    12331239                        }
    12341240                }
     
    12361242                dc.user.pendingLISTs = append(dc.user.pendingLISTs, pl)
    12371243                dc.forEachUpstream(func(uc *upstreamConn) {
     1244                        if upstream != nil && upstream != uc {
     1245                                return
     1246                        }
    12381247                        var params []string
    12391248                        if upstreamChannels != nil {
Note: See TracChangeset for help on using the changeset viewer.