Changeset 68 in code


Ignore:
Timestamp:
Feb 18, 2020, 7:40:32 PM (5 years ago)
Author:
contact
Message:

Fix PING handlers, again

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r66 r68  
    196196                return dc.Close()
    197197        case "PING":
    198                 var from, to string
    199                 if len(msg.Params) >= 1 {
    200                         from = msg.Params[0]
    201                 }
    202                 if len(msg.Params) >= 2 {
    203                         to = msg.Params[1]
    204                 }
    205 
    206                 if to != "" && to != dc.srv.Hostname {
    207                         return ircError{&irc.Message{
    208                                 Command: irc.ERR_NOSUCHSERVER,
    209                                 Params:  []string{to, "No such server"},
    210                         }}
    211                 }
    212 
    213                 params := []string{dc.srv.Hostname}
    214                 if from != "" {
    215                         params = append(params, from)
    216                 }
    217198                dc.SendMessage(&irc.Message{
    218199                        Prefix:  dc.srv.prefix(),
    219200                        Command: "PONG",
    220                         Params:  params,
     201                        Params:  msg.Params,
    221202                })
    222203                return nil
  • trunk/upstream.go

    r67 r68  
    112112        switch msg.Command {
    113113        case "PING":
    114                 var from, to string
    115                 if len(msg.Params) >= 1 {
    116                         from = msg.Params[0]
    117                 }
    118                 if len(msg.Params) >= 2 {
    119                         to = msg.Params[1]
    120                 }
    121 
    122                 if to != "" && to != uc.srv.Hostname {
    123                         return fmt.Errorf("invalid PING destination %q", to)
    124                 }
    125 
    126                 params := []string{uc.srv.Hostname}
    127                 if from != "" {
    128                         params = append(params, from)
    129                 }
    130114                uc.SendMessage(&irc.Message{
    131115                        Command: "PONG",
    132                         Params:  params,
     116                        Params:  msg.Params,
    133117                })
    134118                return nil
Note: See TracChangeset for help on using the changeset viewer.