Changeset 105 in code


Ignore:
Timestamp:
Mar 16, 2020, 1:28:45 PM (5 years ago)
Author:
contact
Message:

Echo downstream PRIVMSGs to other downstream connections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r104 r105  
    77        "net"
    88        "strings"
     9        "sync"
    910        "time"
    1011
     
    7071        password    string   // empty after authentication
    7172        network     *network // can be nil
     73
     74        lock        sync.Mutex
     75        ourMessages map[*irc.Message]struct{}
    7276}
    7377
     
    8185                ringMessages: make(chan ringMessage),
    8286                closed:       make(chan struct{}),
     87                ourMessages:  make(map[*irc.Message]struct{}),
    8388        }
    8489
     
    230235                                        break
    231236                                }
     237
     238                                dc.lock.Lock()
     239                                _, ours := dc.ourMessages[msg]
     240                                delete(dc.ourMessages, msg)
     241                                dc.lock.Unlock()
     242                                if ours {
     243                                        // The message comes from our connection, don't echo it
     244                                        // back
     245                                        continue
     246                                }
     247
    232248                                msg = msg.Copy()
    233249                                switch msg.Command {
     
    639655                                Params:  []string{upstreamName, text},
    640656                        })
     657
     658                        dc.lock.Lock()
     659                        dc.ourMessages[msg] = struct{}{}
     660                        dc.lock.Unlock()
     661
     662                        uc.ring.Produce(msg)
    641663                }
    642664        default:
Note: See TracChangeset for help on using the changeset viewer.