Move parsing of "allowed_nets" out to ConfigLoad()

This has several benefits:
- Configuration errors are caught at startup rather than upon a connection
- connectionChecker() has less work to do for each connection
This commit is contained in:
Jonathon Reinhart
2021-03-13 02:42:30 -05:00
parent 4036213dd5
commit ef3f9c8ea0
2 changed files with 20 additions and 5 deletions

View File

@@ -20,11 +20,8 @@ func connectionChecker(peer smtpd.Peer) error {
// This can't panic because we only have TCP listeners
peerIP := peer.Addr.(*net.TCPAddr).IP
nets := strings.Split(*allowedNets, " ")
for i := range nets {
_, allowedNet, _ := net.ParseCIDR(nets[i])
for _, allowedNet := range allowedNets {
if allowedNet.Contains(peerIP) {
return nil
}