git » spf » commit d6ae505

Simplify IP mask match logic

author Alberto Bertogli
2019-10-18 19:21:50 UTC
committer Alberto Bertogli
2019-10-18 19:21:50 UTC
parent e0c6b612444ec0453947a55842c3aa776c55efc8

Simplify IP mask match logic

This commit simplifies a bit of the IP mask matching logic, by getting
rid of an unnecesary series of if-else.

spf.go +2 -5

diff --git a/spf.go b/spf.go
index 931c38f..cca0239 100644
--- a/spf.go
+++ b/spf.go
@@ -493,12 +493,9 @@ func ipMatch(ip, tomatch net.IP, masks dualMasks) (bool, error) {
 			return false, errInvalidMask
 		}
 		return ipnet.Contains(ip), nil
-	} else {
-		if ip.Equal(tomatch) {
-			return true, nil
-		}
-		return false, nil
 	}
+
+	return ip.Equal(tomatch), nil
 }
 
 var aRegexp = regexp.MustCompile(`^[aA](:([^/]+))?(/(\w+))?(//(\w+))?$`)