From f8a06775f584f72b80260dc4317626b8e5604e74 Mon Sep 17 00:00:00 2001 From: "." <.@.> Date: Mon, 2 May 2016 18:54:52 +1200 Subject: [PATCH] remove support for online-renaming yourself --HG-- branch : nmdc-ircfrontend --- client.go | 34 ---------------------------------- server.go | 27 ++------------------------- 2 files changed, 2 insertions(+), 59 deletions(-) diff --git a/client.go b/client.go index 3b734ac..62d4fcd 100644 --- a/client.go +++ b/client.go @@ -8,40 +8,6 @@ import ( "time" ) -func (c *Client) setNick(nick string) { - //Set up new nick - oldNick := c.nick - oldKey := c.key - c.nick = nick - c.key = strings.ToLower(c.nick) - - delete(c.server.clientMap, oldKey) - c.server.clientMap[c.key] = c - - //Update the relevant channels and notify everyone who can see us about our - //nick change - c.reply(rplNickChange, oldNick, c.nick) - visited := make(map[*Client]struct{}, 100) - for _, channel := range c.channelMap { - delete(channel.clientMap, oldKey) - - for _, client := range channel.clientMap { - if _, skip := visited[client]; skip { - continue - } - client.reply(rplNickChange, oldNick, c.nick) - visited[client] = struct{}{} - } - - //Insert the new nick after iterating through channel.clientMap to avoid - //sending a duplicate message to ourselves - channel.clientMap[c.key] = c - - channel.modeMap[c.key] = channel.modeMap[oldKey] - delete(channel.modeMap, oldKey) - } -} - func (c *Client) joinChannel(channelName string) { newChannel := false diff --git a/server.go b/server.go index b4ce0bd..0cf3a03 100644 --- a/server.go +++ b/server.go @@ -94,31 +94,8 @@ func (s *Server) handleCommand(client *Client, command string, args []string) { case "VERSION": client.reply(rplVersion, VERSION) case "NICK": - if len(args) < 1 { - client.reply(errNoNick) - return - } - - newNick := args[0] - - //Check newNick is of valid formatting (regex) - if nickRegexp.MatchString(newNick) == false { - client.reply(errInvalidNick, newNick) - return - } - - if _, exists := s.clientMap[strings.ToLower(newNick)]; exists { - client.reply(errNickInUse, newNick) - return - } - - //Protect the server name from being used - if strings.ToLower(newNick) == strings.ToLower(s.name) { - client.reply(errNickInUse, newNick) - return - } - - client.setNick(newNick) + client.reply(rplKill, "Can't change nicks on this server", "") + client.disconnect() case "USER": if client.nick == "" {