From 37d61b3193efeb7c6e8085bb14aa6ffd30f68bc2 Mon Sep 17 00:00:00 2001 From: "." <.@.> Date: Mon, 2 May 2016 19:16:25 +1200 Subject: [PATCH] remove server's operatorMap, stub out code for requesting to op ourselves --HG-- branch : nmdc-ircfrontend --- server.go | 30 +++++++++++++----------------- typedefs.go | 13 ++++++------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/server.go b/server.go index 87754dc..1476a66 100644 --- a/server.go +++ b/server.go @@ -6,8 +6,6 @@ import ( "net" "regexp" "strings" - - "golang.org/x/crypto/bcrypt" ) var ( @@ -17,11 +15,10 @@ var ( func NewServer() *Server { return &Server{eventChan: make(chan Event), - name: "", - clientMap: make(map[string]*Client), - channelMap: make(map[string]*Channel), - operatorMap: make(map[string][]byte), - motd: "", + name: "", + clientMap: make(map[string]*Client), + channelMap: make(map[string]*Channel), + motd: "", } } @@ -240,18 +237,17 @@ func (s *Server) handleCommand(client *Client, command string, args []string) { return } - username := args[0] - password := args[1] + //username := args[0] + //password := args[1] + + if false { // op the user + client.operator = true + client.reply(rplOper) + return + } else { + client.reply(errPassword) - if hashedPassword, exists := s.operatorMap[username]; exists { - //nil means the passwords matched - if err := bcrypt.CompareHashAndPassword(hashedPassword, []byte(password)); err == nil { - client.operator = true - client.reply(rplOper) - return - } } - client.reply(errPassword) case "KILL": if client.registered == false { diff --git a/typedefs.go b/typedefs.go index 4504d48..f87321c 100644 --- a/typedefs.go +++ b/typedefs.go @@ -9,13 +9,12 @@ const ( ) type Server struct { - eventChan chan Event - running bool - name string - clientMap map[string]*Client //Map of nicks → clients - channelMap map[string]*Channel //Map of channel names → channels - operatorMap map[string][]byte //Map of usernames → bcrypt hashed passwords - motd string + eventChan chan Event + running bool + name string + clientMap map[string]*Client //Map of nicks → clients + channelMap map[string]*Channel //Map of channel names → channels + motd string } type Client struct {