diff options
author | Ola Bini <ola@autonomia.digital> | 2020-03-26 19:11:47 +0300 |
---|---|---|
committer | Ola Bini <ola@autonomia.digital> | 2020-03-26 19:11:47 +0300 |
commit | 495d699ec82b30187eca72cadfdd1c755798b6e5 (patch) | |
tree | 13bbe273c2be407a124cb362eed0c3defaedc6e8 | |
parent | b076a994922b0357be25848672f42e49f792b318 (diff) |
Try to authenticate using server password if user authentication hasn't happened
-rw-r--r-- | cmd/grumble/server.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd/grumble/server.go b/cmd/grumble/server.go index edc6a6f..663b791 100644 --- a/cmd/grumble/server.go +++ b/cmd/grumble/server.go @@ -256,6 +256,10 @@ func (server *Server) CheckServerPassword(password string) bool { return server.checkConfigPassword("ServerPassword", password) } +func (server *Server) hasServerPassword() bool { + return server.cfg.StringValue("ServerPassword") != "" +} + // Called by the server to initiate a new client connection. func (server *Server) handleIncomingClient(conn net.Conn) (err error) { client := new(Client) @@ -535,6 +539,13 @@ func (server *Server) handleAuthenticate(client *Client, msg *Message) { } } + if client.user == nil && server.hasServerPassword() { + if auth.Password == nil || !server.CheckServerPassword(*auth.Password) { + client.RejectAuth(mumbleproto.Reject_WrongServerPW, "Invalid server password") + return + } + } + // Setup the cryptstate for the client. err = client.crypt.GenerateKey(client.CryptoMode) if err != nil { |