Changeset 355 in code for trunk


Ignore:
Timestamp:
Jul 8, 2020, 4:21:52 PM (5 years ago)
Author:
contact
Message:

Broadcast unhandled messages to downstream connections

In case labelled-response isn't supported, broadcast unhandled messages
to all downstream connections. That's better than silently dropping the
messages.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upstream.go

    r353 r355  
    13161316                }
    13171317
    1318                 if downstreamID != 0 {
    1319                         uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) {
    1320                                 dc.SendMessage(&irc.Message{
    1321                                         Prefix:  uc.srv.prefix(),
    1322                                         Command: msg.Command,
    1323                                         Params:  []string{dc.nick, command, reason},
    1324                                 })
    1325                         })
    1326                 }
     1318                uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) {
     1319                        dc.SendMessage(&irc.Message{
     1320                                Prefix:  uc.srv.prefix(),
     1321                                Command: msg.Command,
     1322                                Params:  []string{dc.nick, command, reason},
     1323                        })
     1324                })
    13271325        case "ACK":
    13281326                // Ignore
     
    13481346        default:
    13491347                uc.logger.Printf("unhandled message: %v", msg)
    1350                 if downstreamID != 0 {
    1351                         uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) {
    1352                                 // best effort marshaling for unknown messages, replies and errors:
    1353                                 // most numerics start with the user nick, marshal it if that's the case
    1354                                 // otherwise, conservately keep the params without marshaling
    1355                                 params := msg.Params
    1356                                 if _, err := strconv.Atoi(msg.Command); err == nil { // numeric
    1357                                         if len(msg.Params) > 0 && isOurNick(uc.network, msg.Params[0]) {
    1358                                                 params[0] = dc.nick
    1359                                         }
     1348
     1349                uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) {
     1350                        // best effort marshaling for unknown messages, replies and errors:
     1351                        // most numerics start with the user nick, marshal it if that's the case
     1352                        // otherwise, conservately keep the params without marshaling
     1353                        params := msg.Params
     1354                        if _, err := strconv.Atoi(msg.Command); err == nil { // numeric
     1355                                if len(msg.Params) > 0 && isOurNick(uc.network, msg.Params[0]) {
     1356                                        params[0] = dc.nick
    13601357                                }
    1361                                 dc.SendMessage(&irc.Message{
    1362                                         Prefix:  uc.srv.prefix(),
    1363                                         Command: msg.Command,
    1364                                         Params:  params,
    1365                                 })
    1366                         })
    1367                 }
     1358                        }
     1359                        dc.SendMessage(&irc.Message{
     1360                                Prefix:  uc.srv.prefix(),
     1361                                Command: msg.Command,
     1362                                Params:  params,
     1363                        })
     1364                })
    13681365        }
    13691366        return nil
Note: See TracChangeset for help on using the changeset viewer.