Changeset 478 in code for trunk/downstream.go
- Timestamp:
- Mar 24, 2021, 5:15:52 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r464 r478 117 117 user *user 118 118 nick string 119 nickCM string 119 120 rawUsername string 120 121 networkName string … … 193 194 // TODO: this doesn't account for nick changes 194 195 if net.conn != nil { 195 return n ick == net.conn.nick196 return net.casemap(nick) == net.conn.nickCM 196 197 } 197 198 // We're not currently connected to the upstream connection, so we don't … … 199 200 // configured nickname and hope it was the one being used when we were 200 201 // connected. 201 return n ick == net.Nick202 return net.casemap(nick) == net.casemap(net.Nick) 202 203 } 203 204 … … 211 212 return dc.nick 212 213 } 214 name = partialCasemap(net.casemap, name) 213 215 if dc.network != nil { 214 216 if dc.network != net { … … 224 226 return dc.prefix() 225 227 } 228 prefix.Name = partialCasemap(net.casemap, prefix.Name) 226 229 if dc.network != nil { 227 230 if dc.network != net { … … 359 362 } 360 363 361 delivered , ok := network.delivered[entity]362 if !ok{364 delivered := network.delivered.Value(entity) 365 if delivered == nil { 363 366 return 364 367 } … … 446 449 }} 447 450 } 448 if nick == serviceNick { 451 nickCM := casemapASCII(nick) 452 if nickCM == serviceNickCM { 449 453 return ircError{&irc.Message{ 450 454 Command: irc.ERR_NICKNAMEINUSE, … … 453 457 } 454 458 dc.nick = nick 459 dc.nickCM = nickCM 455 460 case "USER": 456 461 if err := parseMessageParams(msg, &dc.rawUsername, nil, nil, &dc.realname); err != nil { … … 767 772 }) 768 773 dc.nick = uc.nick 774 dc.nickCM = casemapASCII(dc.nick) 769 775 } 770 776 } … … 912 918 isupport := []string{ 913 919 fmt.Sprintf("CHATHISTORY=%v", dc.srv.HistoryLimit), 920 "CASEMAPPING=ascii", 914 921 } 915 922 … … 961 968 962 969 dc.forEachUpstream(func(uc *upstreamConn) { 963 for _, ch := range uc.channels { 970 for _, entry := range uc.channels.innerMap { 971 ch := entry.value.(*upstreamChannel) 964 972 if !ch.complete { 965 973 continue 966 974 } 967 if record, ok := uc.network.channels[ch.Name]; ok && record.Detached { 975 record := uc.network.channels.Value(ch.Name) 976 if record != nil && record.Detached { 968 977 continue 969 978 } … … 988 997 989 998 // Fast-forward history to last message 990 for target, delivered := range net.delivered { 991 if ch, ok := net.channels[target]; ok && ch.Detached { 999 for target, entry := range net.delivered.innerMap { 1000 delivered := entry.value.(map[string]string) 1001 ch := net.channels.Value(target) 1002 if ch != nil && ch.Detached { 992 1003 continue 993 1004 } … … 1020 1031 1021 1032 func (dc *downstreamConn) sendNetworkBacklog(net *network) { 1022 for target := range net.delivered { 1033 for _, entry := range net.delivered.innerMap { 1034 target := entry.originalKey 1023 1035 dc.sendTargetBacklog(net, target) 1024 1036 } … … 1029 1041 return 1030 1042 } 1031 if ch , ok := net.channels[target]; ok&& ch.Detached {1043 if ch := net.channels.Value(target); ch != nil && ch.Detached { 1032 1044 return 1033 1045 } 1034 delivered , ok := net.delivered[target]1035 if !ok{1046 delivered := net.delivered.Value(target) 1047 if delivered == nil { 1036 1048 return 1037 1049 } … … 1159 1171 }} 1160 1172 } 1161 if nick == serviceNick{1173 if casemapASCII(nick) == serviceNickCM { 1162 1174 return ircError{&irc.Message{ 1163 1175 Command: irc.ERR_NICKNAMEINUSE, … … 1195 1207 }) 1196 1208 dc.nick = nick 1209 dc.nickCM = casemapASCII(dc.nick) 1197 1210 } 1198 1211 case "JOIN": … … 1227 1240 }) 1228 1241 1229 var ch *Channel 1230 var ok bool 1231 if ch, ok = uc.network.channels[upstreamName]; ok { 1242 ch := uc.network.channels.Value(upstreamName) 1243 if ch != nil { 1232 1244 // Don't clear the channel key if there's one set 1233 1245 // TODO: add a way to unset the channel key … … 1241 1253 Key: key, 1242 1254 } 1243 uc.network.channels [upstreamName] = ch1255 uc.network.channels.SetValue(upstreamName, ch) 1244 1256 } 1245 1257 if err := dc.srv.db.StoreChannel(uc.network.ID, ch); err != nil { … … 1265 1277 1266 1278 if strings.EqualFold(reason, "detach") { 1267 var ch *Channel 1268 var ok bool 1269 if ch, ok = uc.network.channels[upstreamName]; ok { 1279 ch := uc.network.channels.Value(upstreamName) 1280 if ch != nil { 1270 1281 uc.network.detach(ch) 1271 1282 } else { … … 1274 1285 Detached: true, 1275 1286 } 1276 uc.network.channels [upstreamName] = ch1287 uc.network.channels.SetValue(upstreamName, ch) 1277 1288 } 1278 1289 if err := dc.srv.db.StoreChannel(uc.network.ID, ch); err != nil { … … 1361 1372 } 1362 1373 1363 if name == dc.nick{1374 if casemapASCII(name) == dc.nickCM { 1364 1375 if modeStr != "" { 1365 1376 dc.forEachUpstream(func(uc *upstreamConn) { … … 1399 1410 }) 1400 1411 } else { 1401 ch , ok := uc.channels[upstreamName]1402 if !ok{1412 ch := uc.channels.Value(upstreamName) 1413 if ch == nil { 1403 1414 return ircError{&irc.Message{ 1404 1415 Command: irc.ERR_NOSUCHCHANNEL, … … 1436 1447 } 1437 1448 1438 uc, upstream Channel, err := dc.unmarshalEntity(channel)1449 uc, upstreamName, err := dc.unmarshalEntity(channel) 1439 1450 if err != nil { 1440 1451 return err … … 1445 1456 uc.SendMessageLabeled(dc.id, &irc.Message{ 1446 1457 Command: "TOPIC", 1447 Params: []string{upstream Channel, topic},1458 Params: []string{upstreamName, topic}, 1448 1459 }) 1449 1460 } else { // getting topic 1450 ch , ok := uc.channels[upstreamChannel]1451 if !ok{1461 ch := uc.channels.Value(upstreamName) 1462 if ch == nil { 1452 1463 return ircError{&irc.Message{ 1453 1464 Command: irc.ERR_NOSUCHCHANNEL, 1454 Params: []string{dc.nick, upstream Channel, "No such channel"},1465 Params: []string{dc.nick, upstreamName, "No such channel"}, 1455 1466 }} 1456 1467 } … … 1514 1525 channels := strings.Split(msg.Params[0], ",") 1515 1526 for _, channel := range channels { 1516 uc, upstream Channel, err := dc.unmarshalEntity(channel)1527 uc, upstreamName, err := dc.unmarshalEntity(channel) 1517 1528 if err != nil { 1518 1529 return err 1519 1530 } 1520 1531 1521 ch , ok := uc.channels[upstreamChannel]1522 if ok{1532 ch := uc.channels.Value(upstreamName) 1533 if ch != nil { 1523 1534 sendNames(dc, ch) 1524 1535 } else { … … 1526 1537 uc.SendMessageLabeled(dc.id, &irc.Message{ 1527 1538 Command: "NAMES", 1528 Params: []string{upstream Channel},1539 Params: []string{upstreamName}, 1529 1540 }) 1530 1541 } … … 1543 1554 // TODO: support WHO masks 1544 1555 entity := msg.Params[0] 1545 1546 if entity == dc.nick { 1556 entityCM := casemapASCII(entity) 1557 1558 if entityCM == dc.nickCM { 1547 1559 // TODO: support AWAY (H/G) in self WHO reply 1548 1560 dc.SendMessage(&irc.Message{ … … 1558 1570 return nil 1559 1571 } 1560 if entity == serviceNick{1572 if entityCM == serviceNickCM { 1561 1573 dc.SendMessage(&irc.Message{ 1562 1574 Prefix: dc.srv.prefix(), … … 1609 1621 } 1610 1622 1611 if mask == dc.nick{1623 if casemapASCII(mask) == dc.nickCM { 1612 1624 dc.SendMessage(&irc.Message{ 1613 1625 Prefix: dc.srv.prefix(),
Note:
See TracChangeset
for help on using the changeset viewer.