Changeset 140 in code for trunk/downstream.go


Ignore:
Timestamp:
Mar 25, 2020, 8:47:26 AM (5 years ago)
Author:
delthas
Message:

Add downstream NAMES support

NAMES reply for channels currently joined will be returned from cache;
requests for channels not joined will be forwarded from upstream.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r139 r140  
    914914                        })
    915915                }
     916        case "NAMES":
     917                if len(msg.Params) == 0 {
     918                        dc.SendMessage(&irc.Message{
     919                                Prefix:  dc.srv.prefix(),
     920                                Command: irc.RPL_ENDOFNAMES,
     921                                Params:  []string{dc.nick, "*", "End of /NAMES list"},
     922                        })
     923                        return nil
     924                }
     925
     926                channels := strings.Split(msg.Params[0], ",")
     927                for _, channel := range channels {
     928                        uc, upstreamChannel, err := dc.unmarshalEntity(channel)
     929                        if err != nil {
     930                                return err
     931                        }
     932
     933                        ch, ok := uc.channels[upstreamChannel]
     934                        if ok {
     935                                sendNames(dc, ch)
     936                        } else {
     937                                // NAMES on a channel we have not joined, ask upstream
     938                                uc.SendMessage(&irc.Message{
     939                                        Command: "NAMES",
     940                                        Params:  []string{upstreamChannel},
     941                                })
     942                        }
     943                }
    916944        case "WHO":
    917945                if len(msg.Params) == 0 {
     
    920948                                Prefix:  dc.srv.prefix(),
    921949                                Command: irc.RPL_ENDOFWHO,
    922                                 Params:  []string{dc.nick, "*", "End of /WHO list."},
     950                                Params:  []string{dc.nick, "*", "End of /WHO list"},
    923951                        })
    924952                        return nil
Note: See TracChangeset for help on using the changeset viewer.