-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
skip_helo_check_for_local.go
35 lines (32 loc) · 1.09 KB
/
skip_helo_check_for_local.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package helo
import (
"net/netip"
"github.com/vodolaz095/msmtpd"
)
// SkipHeloCheckForLocal allows local clients provide anything in HELO/EHLO
func SkipHeloCheckForLocal(transaction *msmtpd.Transaction) error {
addrPort, err := netip.ParseAddrPort(transaction.Addr.String())
if err != nil {
transaction.LogError(err, "while parsing remote address "+transaction.Addr.String())
return complain
}
if addrPort.Addr().IsLoopback() {
transaction.LogInfo("Skipping HELO/EHLO checks for loopback address %s and HELO %s",
transaction.Addr.String(), transaction.HeloName,
)
transaction.SetFlag(IsLocalAddressFlagName)
}
if addrPort.Addr().IsLinkLocalUnicast() {
transaction.LogInfo("Skipping HELO/EHLO checks for local unicast address %s and HELO %s",
transaction.Addr.String(), transaction.HeloName,
)
transaction.SetFlag(IsLocalAddressFlagName)
}
if addrPort.Addr().IsPrivate() {
transaction.LogInfo("Skipping HELO/EHLO checks for private network address %s and HELO %s",
transaction.Addr.String(), transaction.HeloName,
)
transaction.SetFlag(IsLocalAddressFlagName)
}
return nil
}