Changeset 338 in code


Ignore:
Timestamp:
Jun 12, 2020, 12:43:45 PM (5 years ago)
Author:
delthas
Message:

Fix sending messages from detached channels

Currently, a downstream receives MODE, RPL_CHANNELMODEIS and
RPL_CREATIONTIME messages from soju for detached channels. It should not
be sent any of these messages.

This adds a detach check to the handling of these messages to avoid
receiving these messages.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upstream.go

    r323 r338  
    859859
    860860                        uc.appendLog(ch.Name, msg)
    861                         uc.forEachDownstream(func(dc *downstreamConn) {
    862                                 params := make([]string, len(msg.Params))
    863                                 params[0] = dc.marshalEntity(uc.network, name)
    864                                 params[1] = modeStr
    865 
    866                                 copy(params[2:], msg.Params[2:])
    867                                 for i, modeParam := range params[2:] {
    868                                         if _, ok := needMarshaling[i]; ok {
    869                                                 params[2+i] = dc.marshalEntity(uc.network, modeParam)
     861
     862                        if ch, ok := uc.network.channels[name]; !ok || !ch.Detached {
     863                                uc.forEachDownstream(func(dc *downstreamConn) {
     864                                        params := make([]string, len(msg.Params))
     865                                        params[0] = dc.marshalEntity(uc.network, name)
     866                                        params[1] = modeStr
     867
     868                                        copy(params[2:], msg.Params[2:])
     869                                        for i, modeParam := range params[2:] {
     870                                                if _, ok := needMarshaling[i]; ok {
     871                                                        params[2+i] = dc.marshalEntity(uc.network, modeParam)
     872                                                }
    870873                                        }
    871                                 }
    872 
    873                                 dc.SendMessage(&irc.Message{
    874                                         Prefix:  dc.marshalUserPrefix(uc.network, msg.Prefix),
    875                                         Command: "MODE",
    876                                         Params:  params,
     874
     875                                        dc.SendMessage(&irc.Message{
     876                                                Prefix:  dc.marshalUserPrefix(uc.network, msg.Prefix),
     877                                                Command: "MODE",
     878                                                Params:  params,
     879                                        })
    877880                                })
    878                         })
     881                        }
    879882                }
    880883        case irc.RPL_UMODEIS:
     
    913916                }
    914917                if firstMode {
    915                         modeStr, modeParams := ch.modes.Format()
    916 
    917                         uc.forEachDownstream(func(dc *downstreamConn) {
    918                                 params := []string{dc.nick, dc.marshalEntity(uc.network, channel), modeStr}
    919                                 params = append(params, modeParams...)
    920 
    921                                 dc.SendMessage(&irc.Message{
    922                                         Prefix:  dc.srv.prefix(),
    923                                         Command: irc.RPL_CHANNELMODEIS,
    924                                         Params:  params,
     918                        if c, ok := uc.network.channels[channel]; !ok || !c.Detached {
     919                                modeStr, modeParams := ch.modes.Format()
     920
     921                                uc.forEachDownstream(func(dc *downstreamConn) {
     922                                        params := []string{dc.nick, dc.marshalEntity(uc.network, channel), modeStr}
     923                                        params = append(params, modeParams...)
     924
     925                                        dc.SendMessage(&irc.Message{
     926                                                Prefix:  dc.srv.prefix(),
     927                                                Command: irc.RPL_CHANNELMODEIS,
     928                                                Params:  params,
     929                                        })
    925930                                })
    926                         })
     931                        }
    927932                }
    928933        case rpl_creationtime:
     
    10491054                ch.complete = true
    10501055
    1051                 uc.forEachDownstream(func(dc *downstreamConn) {
    1052                         forwardChannel(dc, ch)
    1053                 })
     1056                if c, ok := uc.network.channels[name]; !ok || !c.Detached {
     1057                        uc.forEachDownstream(func(dc *downstreamConn) {
     1058                                forwardChannel(dc, ch)
     1059                        })
     1060                }
    10541061        case irc.RPL_WHOREPLY:
    10551062                var channel, username, host, server, nick, mode, trailing string
Note: See TracChangeset for help on using the changeset viewer.