forked from External/ergo
fix #455
This commit is contained in:
parent
a27c46f983
commit
174115deb6
5 changed files with 40 additions and 22 deletions
|
|
@ -286,18 +286,30 @@ func (client *Client) doIdentLookup(conn net.Conn) {
|
|||
}
|
||||
}
|
||||
|
||||
func (client *Client) isAuthorized(config *Config) bool {
|
||||
type AuthOutcome uint
|
||||
|
||||
const (
|
||||
authSuccess AuthOutcome = iota
|
||||
authFailPass
|
||||
authFailTorSaslRequired
|
||||
authFailSaslRequired
|
||||
)
|
||||
|
||||
func (client *Client) isAuthorized(config *Config) AuthOutcome {
|
||||
saslSent := client.account != ""
|
||||
// PASS requirement
|
||||
if (config.Server.passwordBytes != nil) && !client.sentPassCommand && !(config.Accounts.SkipServerPassword && saslSent) {
|
||||
return false
|
||||
return authFailPass
|
||||
}
|
||||
// Tor connections may be required to authenticate with SASL
|
||||
if client.isTor && config.Server.TorListeners.RequireSasl && !saslSent {
|
||||
return false
|
||||
return authFailTorSaslRequired
|
||||
}
|
||||
// finally, enforce require-sasl
|
||||
return !config.Accounts.RequireSasl.Enabled || saslSent || utils.IPInNets(client.IP(), config.Accounts.RequireSasl.exemptedNets)
|
||||
if config.Accounts.RequireSasl.Enabled && !saslSent && !utils.IPInNets(client.IP(), config.Accounts.RequireSasl.exemptedNets) {
|
||||
return authFailSaslRequired
|
||||
}
|
||||
return authSuccess
|
||||
}
|
||||
|
||||
func (session *Session) resetFakelag() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue