forked from External/grumble
Add new methods for setting and checking a potential server password
This commit is contained in:
parent
dd9b5531a3
commit
b076a99492
1 changed files with 11 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue