Changeset 230 in code for trunk/downstream.go
- Timestamp:
- Apr 6, 2020, 4:23:39 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r228 r230 9 9 "strconv" 10 10 "strings" 11 "sync"12 11 "time" 13 12 … … 69 68 70 69 ringConsumers map[*network]*RingConsumer 70 ourMessages map[*irc.Message]struct{} 71 caps map[string]bool 71 72 72 73 negociatingCaps bool … … 74 75 75 76 saslServer sasl.Server 76 77 lock sync.Mutex78 ourMessages map[*irc.Message]struct{}79 caps map[string]bool80 77 } 81 78 … … 210 207 } 211 208 212 func (dc *downstreamConn) getCap(name string) bool { 213 dc.lock.Lock() 214 defer dc.lock.Unlock() 215 return dc.caps[name] 216 } 217 209 // SendMessage sends an outgoing message. 210 // 211 // This can only called from the user goroutine. 218 212 func (dc *downstreamConn) SendMessage(msg *irc.Message) { 219 if !dc. getCap("message-tags"){213 if !dc.caps["message-tags"] { 220 214 msg = msg.Copy() 221 215 for name := range msg.Tags { … … 223 217 switch name { 224 218 case "time": 225 supported = dc. getCap("server-time")219 supported = dc.caps["server-time"] 226 220 } 227 221 if !supported { … … 235 229 236 230 func (dc *downstreamConn) sendFromUpstream(msg *irc.Message, uc *upstreamConn) { 237 dc.lock.Lock()238 231 _, ours := dc.ourMessages[msg] 239 232 delete(dc.ourMessages, msg) 240 dc.lock.Unlock() 241 if ours && !dc.getCap("echo-message") { 233 if ours && !dc.caps["echo-message"] { 242 234 // The message comes from our connection, don't echo it 243 235 // back … … 301 293 } 302 294 case "AUTHENTICATE": 303 if !dc. getCap("sasl"){295 if !dc.caps["sasl"] { 304 296 return ircError{&irc.Message{ 305 297 Command: irc.ERR_SASLFAIL, … … 442 434 case "LIST": 443 435 var caps []string 444 dc.lock.Lock()445 436 for name := range dc.caps { 446 437 caps = append(caps, name) 447 438 } 448 dc.lock.Unlock()449 439 450 440 // TODO: multi-line replies … … 464 454 caps := strings.Fields(args[0]) 465 455 ack := true 466 dc.lock.Lock()467 456 for _, name := range caps { 468 457 name = strings.ToLower(name) … … 484 473 } 485 474 } 486 dc.lock.Unlock()487 475 488 476 reply := "NAK" … … 1213 1201 Params: []string{upstreamName, text}, 1214 1202 } 1215 dc.lock.Lock()1216 1203 dc.ourMessages[echoMsg] = struct{}{} 1217 dc.lock.Unlock()1218 1204 1219 1205 uc.appendLog(upstreamName, echoMsg)
Note:
See TracChangeset
for help on using the changeset viewer.