Changeset 261 in code
- Timestamp:
- Apr 16, 2020, 3:23:35 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r260 r261 239 239 // that it's suitable for being sent on this downstream connection. Only 240 240 // messages that may appear in logs are supported. 241 func (dc *downstreamConn) marshalMessage(msg *irc.Message, uc *upstreamConn) *irc.Message {241 func (dc *downstreamConn) marshalMessage(msg *irc.Message, net *network) *irc.Message { 242 242 msg = msg.Copy() 243 msg.Prefix = dc.marshalUserPrefix( uc.network, msg.Prefix)243 msg.Prefix = dc.marshalUserPrefix(net, msg.Prefix) 244 244 245 245 switch msg.Command { 246 246 case "PRIVMSG", "NOTICE": 247 msg.Params[0] = dc.marshalEntity( uc.network, msg.Params[0])247 msg.Params[0] = dc.marshalEntity(net, msg.Params[0]) 248 248 case "NICK": 249 249 // Nick change for another user 250 msg.Params[0] = dc.marshalEntity( uc.network, msg.Params[0])250 msg.Params[0] = dc.marshalEntity(net, msg.Params[0]) 251 251 case "JOIN", "PART": 252 msg.Params[0] = dc.marshalEntity( uc.network, msg.Params[0])252 msg.Params[0] = dc.marshalEntity(net, msg.Params[0]) 253 253 case "KICK": 254 msg.Params[0] = dc.marshalEntity( uc.network, msg.Params[0])255 msg.Params[1] = dc.marshalEntity( uc.network, msg.Params[1])254 msg.Params[0] = dc.marshalEntity(net, msg.Params[0]) 255 msg.Params[1] = dc.marshalEntity(net, msg.Params[1]) 256 256 case "TOPIC": 257 msg.Params[0] = dc.marshalEntity( uc.network, msg.Params[0])257 msg.Params[0] = dc.marshalEntity(net, msg.Params[0]) 258 258 case "MODE": 259 msg.Params[0] = dc.marshalEntity( uc.network, msg.Params[0])259 msg.Params[0] = dc.marshalEntity(net, msg.Params[0]) 260 260 case "QUIT": 261 261 // This space is intentinally left blank … … 711 711 consumer := history.ring.NewConsumer(seq) 712 712 713 // TODO: this means all history is lost when trying to send it while the714 // upstream is disconnected. We need to store history differently so that715 // we don't need access to upstreamConn to forward it to a downstream716 // client.717 uc := net.upstream()718 if uc == nil {719 dc.logger.Printf("ignoring messages for upstream %q: upstream is disconnected", net.Addr)720 return721 }722 723 713 batchRef := "history" 724 714 if dc.caps["batch"] { … … 753 743 } 754 744 755 dc.SendMessage(dc.marshalMessage(msg, uc))745 dc.SendMessage(dc.marshalMessage(msg, net)) 756 746 } 757 747 -
trunk/upstream.go
r260 r261 563 563 if !me { 564 564 uc.forEachDownstream(func(dc *downstreamConn) { 565 dc.SendMessage(dc.marshalMessage(msg, uc ))565 dc.SendMessage(dc.marshalMessage(msg, uc.network)) 566 566 }) 567 567 } … … 669 669 if msg.Prefix.Name != uc.nick { 670 670 uc.forEachDownstream(func(dc *downstreamConn) { 671 dc.SendMessage(dc.marshalMessage(msg, uc ))671 dc.SendMessage(dc.marshalMessage(msg, uc.network)) 672 672 }) 673 673 } … … 1332 1332 uc.forEachDownstream(func(dc *downstreamConn) { 1333 1333 if dc != origin || dc.caps["echo-message"] { 1334 dc.SendMessage(dc.marshalMessage(msg, uc ))1334 dc.SendMessage(dc.marshalMessage(msg, uc.network)) 1335 1335 } 1336 1336 })
Note:
See TracChangeset
for help on using the changeset viewer.