- Timestamp:
- Apr 29, 2020, 5:34:44 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r275 r276 54 54 // capabilities. 55 55 var permanentDownstreamCaps = map[string]string{ 56 "batch": "",57 "cap-notify": "",56 "batch": "", 57 "cap-notify": "", 58 58 "echo-message": "", 59 59 "message-tags": "", 60 "sasl": "PLAIN",61 "server-time": "",60 "sasl": "PLAIN", 61 "server-time": "", 62 62 } 63 63 … … 89 89 logger := &prefixLogger{srv.Logger, fmt.Sprintf("downstream %q: ", netConn.RemoteAddr())} 90 90 dc := &downstreamConn{ 91 conn: *newConn(srv, netConn, logger),92 id: id,91 conn: *newConn(srv, netConn, logger), 92 id: id, 93 93 supportedCaps: make(map[string]string), 94 caps: make(map[string]bool),94 caps: make(map[string]bool), 95 95 } 96 96 dc.hostname = netConn.RemoteAddr().String() … … 459 459 for k, v := range dc.supportedCaps { 460 460 if dc.capVersion >= 302 && v != "" { 461 caps = append(caps, k + "=" +v)461 caps = append(caps, k+"="+v) 462 462 } else { 463 463 caps = append(caps, k) … … 594 594 Params: []string{replyTo, "DEL", name}, 595 595 }) 596 } 597 598 func (dc *downstreamConn) updateSupportedCaps() { 599 awayNotifySupported := true 600 dc.forEachUpstream(func(uc *upstreamConn) { 601 awayNotifySupported = awayNotifySupported && uc.awayNotifySupported 602 }) 603 604 if awayNotifySupported { 605 dc.setSupportedCap("away-notify", "") 606 } else { 607 dc.unsetSupportedCap("away-notify") 608 } 596 609 } 597 610 -
trunk/upstream.go
r274 r276 47 47 modes userModes 48 48 channels map[string]*upstreamChannel 49 caps map[string]string 49 caps map[string]string // available capabilities 50 50 batches map[string]batch 51 51 away bool 52 52 53 tagsSupported bool 54 labelsSupported bool 55 nextLabelID uint64 53 tagsSupported bool 54 awayNotifySupported bool 55 labelsSupported bool 56 nextLabelID uint64 56 57 57 58 saslClient sasl.Client … … 318 319 319 320 requestCaps := make([]string, 0, 16) 320 for _, c := range []string{"message-tags", "batch", "labeled-response", "server-time" } {321 for _, c := range []string{"message-tags", "batch", "labeled-response", "server-time", "away-notify"} { 321 322 if _, ok := uc.caps[c]; ok { 322 323 requestCaps = append(requestCaps, c) … … 450 451 uc.registered = true 451 452 uc.logger.Printf("connection registered") 453 454 uc.forEachDownstream(func(dc *downstreamConn) { 455 dc.updateSupportedCaps() 456 }) 452 457 453 458 for _, ch := range uc.network.channels { … … 1149 1154 }) 1150 1155 }) 1156 case "AWAY": 1157 if msg.Prefix == nil { 1158 return fmt.Errorf("expected a prefix") 1159 } 1160 1161 uc.forEachDownstream(func(dc *downstreamConn) { 1162 if !dc.caps["away-notify"] { 1163 return 1164 } 1165 dc.SendMessage(&irc.Message{ 1166 Prefix: dc.marshalUserPrefix(uc.network, msg.Prefix), 1167 Command: "AWAY", 1168 Params: msg.Params, 1169 }) 1170 }) 1151 1171 case "TAGMSG": 1152 1172 // TODO: relay to downstream connections that accept message-tags … … 1263 1283 1264 1284 func (uc *upstreamConn) handleCapAck(name string, ok bool) error { 1265 auth := &uc.network.SASL1266 1285 switch name { 1267 1286 case "sasl": … … 1271 1290 } 1272 1291 1292 auth := &uc.network.SASL 1273 1293 switch auth.Mechanism { 1274 1294 case "PLAIN": … … 1287 1307 case "labeled-response": 1288 1308 uc.labelsSupported = ok 1309 case "away-notify": 1310 uc.awayNotifySupported = ok 1289 1311 case "batch", "server-time": 1290 1312 // Nothing to do -
trunk/user.go
r267 r276 256 256 257 257 uc.forEachDownstream(func(dc *downstreamConn) { 258 dc.updateSupportedCaps() 258 259 sendServiceNOTICE(dc, fmt.Sprintf("connected to %s", uc.network.GetName())) 259 260 }) … … 271 272 272 273 uc.endPendingLISTs(true) 274 275 uc.forEachDownstream(func(dc *downstreamConn) { 276 dc.updateSupportedCaps() 277 }) 273 278 274 279 if uc.network.lastError == nil { … … 315 320 uc.updateAway() 316 321 }) 322 323 dc.updateSupportedCaps() 317 324 case eventDownstreamDisconnected: 318 325 dc := e.dc
Note:
See TracChangeset
for help on using the changeset viewer.