Changeset 66 in code for trunk/upstream.go


Ignore:
Timestamp:
Feb 18, 2020, 4:07:58 PM (5 years ago)
Author:
contact
Message:

Properly handle PING messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upstream.go

    r64 r66  
    110110        switch msg.Command {
    111111        case "PING":
    112                 // TODO: handle params
     112                var from, to string
     113                if len(msg.Params) >= 1 {
     114                        from = msg.Params[0]
     115                }
     116                if len(msg.Params) >= 2 {
     117                        to = msg.Params[1]
     118                }
     119
     120                if to != "" && to != uc.srv.Hostname {
     121                        return fmt.Errorf("invalid PING destination %q", to)
     122                }
     123
     124                params := []string{uc.srv.Hostname}
     125                if from != "" {
     126                        params = append(params, from)
     127                }
    113128                uc.SendMessage(&irc.Message{
    114129                        Command: "PONG",
    115                         Params:  []string{uc.srv.Hostname},
     130                        Params:  params,
    116131                })
    117132                return nil
Note: See TracChangeset for help on using the changeset viewer.