add pm banlist:auth and pm banlist:auto

This commit is contained in:
Aine
2023-09-25 21:59:23 +03:00
parent b413e5871a
commit 18f1113d33
7 changed files with 136 additions and 7 deletions

View File

@@ -64,7 +64,8 @@ type matrixbot interface {
IsGreylisted(net.Addr) bool
IsBanned(net.Addr) bool
IsTrusted(net.Addr) bool
Ban(net.Addr)
BanAuto(net.Addr)
BanAuth(net.Addr)
GetMapping(string) (id.RoomID, bool)
GetIFOptions(id.RoomID) email.IncomingFilteringOptions
IncomingEmail(context.Context, *email.Email) error

View File

@@ -41,14 +41,14 @@ func (m *mailServer) Login(state *smtp.ConnectionState, username, password strin
if !email.AddressValid(username) {
m.log.Debug().Str("address", username).Msg("address is invalid")
m.bot.Ban(state.RemoteAddr)
m.bot.BanAuth(state.RemoteAddr)
return nil, ErrBanned
}
roomID, allow := m.bot.AllowAuth(username, password)
if !allow {
m.log.Debug().Str("username", username).Msg("username or password is invalid")
m.bot.Ban(state.RemoteAddr)
m.bot.BanAuth(state.RemoteAddr)
return nil, ErrBanned
}
@@ -77,7 +77,7 @@ func (m *mailServer) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session,
getRoomID: m.bot.GetMapping,
getFilters: m.bot.GetIFOptions,
receiveEmail: m.ReceiveEmail,
ban: m.bot.Ban,
ban: m.bot.BanAuto,
greylisted: m.bot.IsGreylisted,
trusted: m.bot.IsTrusted,
log: m.log,