mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-14 07:59:31 +01:00
Merge pull request #1505 from slingamn/uban_sasl_followup
require-sasl uban should not kill authenticated clients
This commit is contained in:
commit
6d3dd66031
@ -131,8 +131,11 @@ func ubanHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sessionsForCIDR(server *Server, cidr flatip.IPNet, exclude *Session) (sessions []*Session, nicks []string) {
|
func sessionsForCIDR(server *Server, cidr flatip.IPNet, exclude *Session, requireSASL bool) (sessions []*Session, nicks []string) {
|
||||||
for _, client := range server.clients.AllClients() {
|
for _, client := range server.clients.AllClients() {
|
||||||
|
if requireSASL && client.Account() != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
for _, session := range client.Sessions() {
|
for _, session := range client.Sessions() {
|
||||||
seen := false
|
seen := false
|
||||||
if session != exclude && cidr.Contains(flatip.FromNetIP(session.IP())) {
|
if session != exclude && cidr.Contains(flatip.FromNetIP(session.IP())) {
|
||||||
@ -177,7 +180,7 @@ func ubanAddCIDR(client *Client, target ubanTarget, duration time.Duration, requ
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sessions, nicks := sessionsForCIDR(client.server, target.cidr, rb.session)
|
sessions, nicks := sessionsForCIDR(client.server, target.cidr, rb.session, requireSASL)
|
||||||
for _, session := range sessions {
|
for _, session := range sessions {
|
||||||
session.client.Quit("You have been banned from this server", session)
|
session.client.Quit("You have been banned from this server", session)
|
||||||
session.client.destroy(session)
|
session.client.destroy(session)
|
||||||
@ -329,7 +332,7 @@ func ubanInfoCIDR(client *Client, target ubanTarget, rb *ResponseBuffer) {
|
|||||||
rb.Notice(fmt.Sprintf(client.t("There is no active IP ban against %s"), str))
|
rb.Notice(fmt.Sprintf(client.t("There is no active IP ban against %s"), str))
|
||||||
}
|
}
|
||||||
|
|
||||||
sessions, nicks := sessionsForCIDR(client.server, target.cidr, nil)
|
sessions, nicks := sessionsForCIDR(client.server, target.cidr, nil, false)
|
||||||
if len(sessions) != 0 {
|
if len(sessions) != 0 {
|
||||||
rb.Notice(fmt.Sprintf(client.t("There are %[1]d active client(s) from %[2]s, associated with %[3]d nickname(s):"), len(sessions), target.cidr.String(), len(nicks)))
|
rb.Notice(fmt.Sprintf(client.t("There are %[1]d active client(s) from %[2]s, associated with %[3]d nickname(s):"), len(sessions), target.cidr.String(), len(nicks)))
|
||||||
for _, line := range utils.BuildTokenLines(400, nicks, " ") {
|
for _, line := range utils.BuildTokenLines(400, nicks, " ") {
|
||||||
|
Loading…
Reference in New Issue
Block a user