Changeset 236 in code for trunk/downstream.go


Ignore:
Timestamp:
Apr 6, 2020, 5:08:43 PM (5 years ago)
Author:
contact
Message:

Remove downstreamConn.ourMessages

We can just do the filtering when dispatching the message.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r233 r236  
    6767        network     *network // can be nil
    6868
    69         ourMessages map[*irc.Message]struct{}
    70         caps        map[string]bool
    71 
    7269        negociatingCaps bool
    7370        capVersion      int
     71        caps            map[string]bool
    7472
    7573        saslServer sasl.Server
     
    7977        logger := &prefixLogger{srv.Logger, fmt.Sprintf("downstream %q: ", netConn.RemoteAddr())}
    8078        dc := &downstreamConn{
    81                 conn:        *newConn(srv, netConn, logger),
    82                 id:          id,
    83                 ourMessages: make(map[*irc.Message]struct{}),
    84                 caps:        make(map[string]bool),
     79                conn: *newConn(srv, netConn, logger),
     80                id:   id,
     81                caps: make(map[string]bool),
    8582        }
    8683        dc.hostname = netConn.RemoteAddr().String()
     
    227224
    228225func (dc *downstreamConn) sendFromUpstream(msg *irc.Message, uc *upstreamConn) {
    229         _, ours := dc.ourMessages[msg]
    230         delete(dc.ourMessages, msg)
    231         if ours && !dc.caps["echo-message"] {
    232                 // The message comes from our connection, don't echo it
    233                 // back
    234                 return
    235         }
    236 
    237226        msg = msg.Copy()
    238227        switch msg.Command {
     
    11971186                                Params:  []string{upstreamName, text},
    11981187                        }
    1199                         dc.ourMessages[echoMsg] = struct{}{}
    12001188
    12011189                        uc.appendLog(upstreamName, echoMsg)
    12021190
    1203                         uc.produce(echoMsg)
     1191                        uc.network.ring.Produce(echoMsg)
     1192
     1193                        uc.forEachDownstream(func(c *downstreamConn) {
     1194                                if c != dc || c.caps["echo-message"] {
     1195                                        c.sendFromUpstream(echoMsg, uc)
     1196                                }
     1197                        })
    12041198                }
    12051199        case "NOTICE":
Note: See TracChangeset for help on using the changeset viewer.