diff options
author | Ola Bini <ola@autonomia.digital> | 2020-03-26 18:03:05 +0300 |
---|---|---|
committer | Ola Bini <ola@autonomia.digital> | 2020-03-26 18:03:05 +0300 |
commit | b076a994922b0357be25848672f42e49f792b318 (patch) | |
tree | 55cfc997798110b51baee1f6c69ff62a3c862fa7 | |
parent | dd9b5531a3dc4ee55b7bff86ec924e56ec573be5 (diff) |
Add new methods for setting and checking a potential server password
-rw-r--r-- | cmd/grumble/server.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/cmd/grumble/server.go b/cmd/grumble/server.go index bca43aa..edc6a6f 100644 --- a/cmd/grumble/server.go +++ b/cmd/grumble/server.go @@ -197,11 +197,16 @@ func (server *Server) setConfigPassword(key, password string) { } } -// Set password as the new SuperUser password +// SetSuperUserPassword sets password as the new SuperUser password func (server *Server) SetSuperUserPassword(password string) { server.setConfigPassword("SuperUserPassword", password) } +// SetServerPassword sets password as the new Server password +func (server *Server) SetServerPassword(password string) { + server.setConfigPassword("ServerPassword", password) +} + func (server *Server) checkConfigPassword(key, password string) bool { parts := strings.Split(server.cfg.StringValue(key), "$") if len(parts) != 3 { @@ -246,6 +251,11 @@ func (server *Server) CheckSuperUserPassword(password string) bool { return server.checkConfigPassword("SuperUserPassword", password) } +// CheckServerPassword checks whether password matches the set Server password. +func (server *Server) CheckServerPassword(password string) bool { + return server.checkConfigPassword("ServerPassword", password) +} + // Called by the server to initiate a new client connection. func (server *Server) handleIncomingClient(conn net.Conn) (err error) { client := new(Client) |