mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
f38ad0c939
commit
56375f3687
1 changed files with 1 additions and 9 deletions
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -282,14 +281,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)
|
||||
}
|
||||
|
||||
// Raw calls 'iptables' system command, passing supplied arguments.
|
||||
|
|
Loading…
Reference in a new issue