mirror of
https://github.com/decke/smtprelay.git
synced 2025-12-26 04:12:29 -07:00
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:
5
main.go
5
main.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user