3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 21:39:25 +01:00

Merge pull request #1268 from slingamn/saslmessage

pass the require-sasl message through from the script
This commit is contained in:
Shivaram Lingamneni 2020-09-14 05:45:58 -07:00 committed by GitHub
commit 36ea93cc9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -101,6 +101,7 @@ type Client struct {
cloakedHostname string
realname string
realIP net.IP
requireSASLMessage string
requireSASL bool
registered bool
registrationTimer *time.Timer
@ -353,6 +354,9 @@ func (server *Server) RunClient(conn IRCConn) {
proxiedIP: proxiedIP,
requireSASL: requireSASL,
}
if requireSASL {
client.requireSASLMessage = banMsg
}
client.writerSemaphore.Initialize(1)
client.history.Initialize(config.History.ClientLength, time.Duration(config.History.AutoresizeWindow))
client.brbTimer.Initialize(client)

View File

@ -82,6 +82,9 @@ func (client *Client) ApplyProxiedIP(session *Session, proxiedIP net.IP, tls boo
return errBanned, banMsg
}
client.requireSASL = requireSASL
if requireSASL {
client.requireSASLMessage = banMsg
}
// successfully added a limiter entry for the proxied IP;
// remove the entry for the real IP if applicable (#197)
client.server.connectionLimiter.RemoveClient(session.realIP)

View File

@ -213,7 +213,7 @@ func (server *Server) checkBans(config *Config, ipaddr net.IP, checkScripts bool
return true, false, output.BanMessage
} else if output.Result == IPRequireSASL {
server.logger.Info("connect-ip", "Requiring SASL from client due to ip-check-script", ipaddr.String())
return false, true, ""
return false, true, output.BanMessage
}
}
@ -270,13 +270,17 @@ func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) {
quitMessage = c.t("Password incorrect")
c.Send(nil, server.name, ERR_PASSWDMISMATCH, "*", quitMessage)
case authFailSaslRequired, authFailTorSaslRequired:
quitMessage = c.t("You must log in with SASL to join this server")
quitMessage = c.requireSASLMessage
if quitMessage == "" {
quitMessage = c.t("You must log in with SASL to join this server")
}
c.Send(nil, c.server.name, "FAIL", "*", "ACCOUNT_REQUIRED", quitMessage)
}
if authOutcome != authSuccess {
c.Quit(quitMessage, nil)
return true
}
c.requireSASLMessage = ""
rb := NewResponseBuffer(session)
nickError := performNickChange(server, c, c, session, c.preregNick, rb)