Changeset 681 in code for trunk/downstream.go


Ignore:
Timestamp:
Nov 9, 2021, 8:32:26 PM (4 years ago)
Author:
contact
Message:

Remove support for mixed multi-upstream LIST

Multi-upstream connections can still send LIST commands with a
network suffix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r677 r681  
    18381838                // TODO: support ELIST when supported by all upstreams
    18391839
    1840                 pl := pendingLIST{
    1841                         downstreamID:    dc.id,
    1842                         pendingCommands: make(map[int64]*irc.Message),
    1843                 }
    1844                 var upstream *upstreamConn
    1845                 var upstreamChannels map[int64][]string
    1846                 if len(msg.Params) > 0 {
    1847                         uc, upstreamMask, err := dc.unmarshalEntity(msg.Params[0])
    1848                         if err == nil && upstreamMask == "*" { // LIST */network: send LIST only to one network
    1849                                 upstream = uc
    1850                         } else {
    1851                                 upstreamChannels = make(map[int64][]string)
    1852                                 channels := strings.Split(msg.Params[0], ",")
    1853                                 for _, channel := range channels {
    1854                                         uc, upstreamChannel, err := dc.unmarshalEntity(channel)
    1855                                         if err != nil {
    1856                                                 return err
    1857                                         }
    1858                                         upstreamChannels[uc.network.ID] = append(upstreamChannels[uc.network.ID], upstreamChannel)
    1859                                 }
    1860                         }
    1861                 }
    1862 
    1863                 dc.user.pendingLISTs = append(dc.user.pendingLISTs, pl)
    1864                 dc.forEachUpstream(func(uc *upstreamConn) {
    1865                         if upstream != nil && upstream != uc {
    1866                                 return
    1867                         }
    1868                         var params []string
    1869                         if upstreamChannels != nil {
    1870                                 if channels, ok := upstreamChannels[uc.network.ID]; ok {
    1871                                         params = []string{strings.Join(channels, ",")}
    1872                                 } else {
    1873                                         return
    1874                                 }
    1875                         }
    1876                         pl.pendingCommands[uc.network.ID] = &irc.Message{
    1877                                 Command: "LIST",
    1878                                 Params:  params,
    1879                         }
    1880                         uc.trySendLIST(dc.id)
    1881                 })
     1840                network := dc.network
     1841                if network == nil && len(msg.Params) > 0 {
     1842                        var err error
     1843                        network, msg.Params[0], err = dc.unmarshalEntityNetwork(msg.Params[0])
     1844                        if err != nil {
     1845                                return err
     1846                        }
     1847                }
     1848                if network == nil {
     1849                        dc.SendMessage(&irc.Message{
     1850                                Prefix:  dc.srv.prefix(),
     1851                                Command: irc.RPL_LISTEND,
     1852                                Params:  []string{dc.nick, "LIST without a network suffix is not supported in multi-upstream mode"},
     1853                        })
     1854                        return nil
     1855                }
     1856
     1857                uc := network.conn
     1858                if uc == nil {
     1859                        dc.SendMessage(&irc.Message{
     1860                                Prefix:  dc.srv.prefix(),
     1861                                Command: irc.RPL_LISTEND,
     1862                                Params:  []string{dc.nick, "Disconnected from upstream server"},
     1863                        })
     1864                        return nil
     1865                }
     1866
     1867                uc.enqueueLIST(dc, msg)
    18821868        case "NAMES":
    18831869                if len(msg.Params) == 0 {
Note: See TracChangeset for help on using the changeset viewer.