From d35f2c27a19648d906007d4c7f52daa901776ba6 Mon Sep 17 00:00:00 2001 From: Mingzhen Feng Date: Thu, 16 Apr 2015 15:09:36 +0800 Subject: [PATCH] Removal of the regex to replace ips Signed-off-by: Mingzhen Feng --- iptables/iptables.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/iptables/iptables.go b/iptables/iptables.go index f772a33..9cf1bbf 100644 --- a/iptables/iptables.go +++ b/iptables/iptables.go @@ -5,7 +5,6 @@ import ( "fmt" "net" "os/exec" - "regexp" "strconv" "strings" "sync" @@ -267,14 +266,7 @@ func Exists(table Table, chain string, rule ...string) bool { ruleString := strings.Join(rule, " ") existingRules, _ := exec.Command(iptablesPath, "-t", string(table), "-S", chain).Output() - // regex to replace ips in rule - // because MASQUERADE rule will not be exactly what was passed - re := regexp.MustCompile(`[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\/[0-9]{1,2}`) - - return strings.Contains( - re.ReplaceAllString(string(existingRules), "?"), - re.ReplaceAllString(ruleString, "?"), - ) + return strings.Contains(string(existingRules), ruleString) } // Call 'iptables' system command, passing supplied arguments