mirror of
https://github.com/jeremyd/ergo.git
synced 2026-04-30 01:19:59 -07:00
fix #455
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user