Skip to content

Commit 9bd9458

Browse files
committed
Updates to the regex from feedback from Jan, the regex wizard
Signed-off-by: Matt Farina <[email protected]>
1 parent c09f01e commit 9bd9458

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/guestagent/iptables/iptables.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type Entry struct {
1717

1818
// This regex can detect a line in the iptables added by portmap to do the
1919
// forwarding. The following two are examples of lines (notice that one has the
20-
// destinateion IP and the other does not):
20+
// destination IP and the other does not):
2121
// -A CNI-DN-2e2f8d5b91929ef9fc152 -d 127.0.0.1/32 -p tcp -m tcp --dport 8081 -j DNAT --to-destination 10.4.0.7:80
2222
// -A CNI-DN-04579c7bb67f4c3f6cca0 -p tcp -m tcp --dport 8082 -j DNAT --to-destination 10.4.0.10:80
2323
// The -A on the front is to amend the rule that was already created. portmap
@@ -27,7 +27,7 @@ type Entry struct {
2727
// ipv4 IP address. We need to detect this IP.
2828
// --dport is the destination port. We need to detect this port
2929
// -j DNAT this tells us it's the line doing the port forwarding.
30-
var findPortRegex = regexp.MustCompile(`.*-A\W+CNI-DN-\w*\W+(?:-d ((?:\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}))?(?:/\d+\W+)?-p.*--dport (\d+) -j DNAT`)
30+
var findPortRegex = regexp.MustCompile(`-A\s+CNI-DN-\w*\s+(?:-d ((?:\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}))?(?:/32\s+)?-p .*--dport (\d+) -j DNAT`)
3131

3232
func GetPorts() ([]Entry, error) {
3333
// TODO: add support for ipv6

0 commit comments

Comments
 (0)