Changeset 302 in code
- Timestamp:
- May 27, 2020, 9:47:49 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/upstream.go
r300 r302 1183 1183 }) 1184 1184 }) 1185 case irc.ERR_UNKNOWNCOMMAND, irc.RPL_TRYAGAIN:1186 var command, reason string1187 if err := parseMessageParams(msg, nil, &command, &reason); err != nil {1188 return err1189 }1190 1191 if command == "LIST" {1192 ok := uc.endPendingLISTs(false)1193 if !ok {1194 return fmt.Errorf("unexpected response for LIST: %q: no matching pending LIST", msg.Command)1195 }1196 uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) {1197 dc.SendMessage(&irc.Message{1198 Prefix: uc.srv.prefix(),1199 Command: msg.Command,1200 Params: []string{dc.nick, "LIST", reason},1201 })1202 })1203 }1204 1185 case irc.RPL_AWAY: 1205 1186 var nick, reason string … … 1272 1253 }) 1273 1254 }) 1255 case irc.ERR_UNKNOWNCOMMAND, irc.RPL_TRYAGAIN: 1256 var command, reason string 1257 if err := parseMessageParams(msg, nil, &command, &reason); err != nil { 1258 return err 1259 } 1260 1261 if command == "LIST" { 1262 ok := uc.endPendingLISTs(false) 1263 if !ok { 1264 return fmt.Errorf("unexpected response for LIST: %q: no matching pending LIST", msg.Command) 1265 } 1266 } 1267 1268 if downstreamID != 0 { 1269 uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) { 1270 dc.SendMessage(&irc.Message{ 1271 Prefix: uc.srv.prefix(), 1272 Command: msg.Command, 1273 Params: []string{dc.nick, command, reason}, 1274 }) 1275 }) 1276 } 1274 1277 case "TAGMSG": 1275 1278 // TODO: relay to downstream connections that accept message-tags … … 1292 1295 default: 1293 1296 uc.logger.Printf("unhandled message: %v", msg) 1297 if downstreamID != 0 { 1298 uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) { 1299 // best effort marshaling for unknown messages, replies and errors: 1300 // most numerics start with the user nick, marshal it if that's the case 1301 // otherwise, conservately keep the params without marshaling 1302 params := msg.Params 1303 if _, err := strconv.Atoi(msg.Command); err == nil { // numeric 1304 if len(msg.Params) > 0 && isOurNick(uc.network, msg.Params[0]) { 1305 params[0] = dc.nick 1306 } 1307 } 1308 dc.SendMessage(&irc.Message{ 1309 Prefix: uc.srv.prefix(), 1310 Command: msg.Command, 1311 Params: params, 1312 }) 1313 }) 1314 } 1294 1315 } 1295 1316 return nil
Note:
See TracChangeset
for help on using the changeset viewer.