Changeset 245 in code for trunk/downstream.go
- Timestamp:
- Apr 7, 2020, 5:45:29 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r242 r245 223 223 } 224 224 225 func (dc *downstreamConn) sendFromUpstream(msg *irc.Message, uc *upstreamConn) { 225 // marshalMessage re-formats a message coming from an upstream connection so 226 // that it's suitable for being sent on this downstream connection. Only 227 // messages that may appear in logs are supported. 228 func (dc *downstreamConn) marshalMessage(msg *irc.Message, uc *upstreamConn) *irc.Message { 226 229 msg = msg.Copy() 230 msg.Prefix = dc.marshalUserPrefix(uc, msg.Prefix) 231 227 232 switch msg.Command { 228 233 case "PRIVMSG", "NOTICE": 229 msg.Prefix = dc.marshalUserPrefix(uc, msg.Prefix)230 234 msg.Params[0] = dc.marshalEntity(uc, msg.Params[0]) 235 case "NICK": 236 // Nick change for another user 237 msg.Params[0] = dc.marshalNick(uc, msg.Params[0]) 238 case "JOIN", "PART": 239 msg.Params[0] = dc.marshalChannel(uc, msg.Params[0]) 240 case "KICK": 241 msg.Params[0] = dc.marshalChannel(uc, msg.Params[0]) 242 msg.Params[1] = dc.marshalNick(uc, msg.Params[1]) 243 case "TOPIC": 244 msg.Params[0] = dc.marshalChannel(uc, msg.Params[0]) 245 case "MODE": 246 msg.Params[0] = dc.marshalEntity(uc, msg.Params[0]) 247 case "QUIT": 248 // This space is intentinally left blank 231 249 default: 232 250 panic(fmt.Sprintf("unexpected %q message", msg.Command)) 233 251 } 234 252 235 dc.SendMessage(msg)253 return msg 236 254 } 237 255 … … 685 703 } 686 704 687 dc.sendFromUpstream(msg, uc) 705 // Don't replay all messages, because that would mess up client 706 // state. For instance we just sent the list of users, sending 707 // PART messages for one of these users would be incorrect. 708 ignore := true 709 switch msg.Command { 710 case "PRIVMSG", "NOTICE": 711 ignore = false 712 } 713 if ignore { 714 continue 715 } 716 717 dc.SendMessage(dc.marshalMessage(msg, uc)) 688 718 } 689 719 })
Note:
See TracChangeset
for help on using the changeset viewer.