-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ipv6 ident #11
fix: ipv6 ident #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot. Can you please add a test where an IPv6 address starts with ::
. I think that should be possible in theory.
And also the (d *DNSOrIP) Set(s string)
in
Line 209 in 275b7c9
func (d *DNSOrIP) Set(s string) error { |
is still just blindly adding a
/32
. I think we just resolve that with this PR to prevent an IPv6 address from being parsed with a 32
network mask. Maybe we can use https://cs.opensource.google/go/go/+/go1.22.0:src/net/ip.go;l=494 if there is no network mask and then https://cs.opensource.google/go/go/+/go1.22.0:src/net/ip.go;l=52 to find out if it is v4 or v6 and adding the suffix accordingly. wdyt?
Also a test where we parse a complete rule that contains an IPv6 address would increase my confidence a lot. Let me know if I can help you with anything!
Yes sounds all good, will do :) |
Never mind, I totally misread the function signature of I guess we can use |
6a076a9
to
7a26f2e
Compare
I've added three more commits to implement/fix issues, however solving the one issue at hand, regarding extending |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the COMMIT
and "no counter" commits should be in separate PRs. This way we can merge the IPv6 support quickly and not block it by my slow reviews.
parser.go
Outdated
@@ -64,6 +64,12 @@ func (d Policy) String() string { | |||
return fmt.Sprintf("%s%s %s", prefix, d.Chain, d.Action) | |||
} | |||
|
|||
type Commit struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make a separate PR for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
d5dbd16
to
0e8c883
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much. I think everything is fine with me. Can you rebase from our main branch first? I see some changes in this PR, that are already in our main branch.
.github/workflows/test.yaml
Outdated
with: | ||
go-version: '1.16' | ||
- run: go test ./... | ||
fmt: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
.github/workflows/test.yaml
Outdated
go-version: '1.16' | ||
- run: go test ./... | ||
- uses: actions/checkout@main | ||
- uses: actions/setup-go@v1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we already touched this, we can update the actions/setup-go version
- uses: actions/setup-go@v1 | |
- uses: actions/setup-go@v5 |
LICENSE
Outdated
@@ -1,4 +1,4 @@ | |||
Copyright (c) 2021 Leon Löchner | |||
Copyright (c) 2022 Leon Löchner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright (c) 2022 Leon Löchner | |
Copyright (c) 2024 Leon Löchner |
README.md
Outdated
@@ -1,5 +1,7 @@ | |||
# iptables-parser | |||
|
|||
[![Documentation](https://godoc.org/github.com/kilo-io/iptables_parser?status.svg)](http://godoc.org/github.com/kilo-io/iptables_parser) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
parser.go
Outdated
@@ -371,7 +374,7 @@ func (p *Parser) Parse() (l Line, err error) { | |||
case COLON: | |||
return p.parseDefault(p.s.scanLine()) | |||
case EOF: | |||
return nil, io.EOF //ErrEOF | |||
return nil, io.EOF // ErrEOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, io.EOF // ErrEOF | |
return nil, io.EOF |
parser.go
Outdated
panic("size exceeds buffer") | ||
} | ||
p.buf.n += n | ||
} | ||
|
||
func (p *Parser) unscanIgnoreWhitespace(n int) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, we never use that. There are some comments that mention this method. I can make a follow up to remove those confusing comments.
parser_test.go
Outdated
Values: []string{"200-1000"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
err: nil, | ||
}, | ||
{ | ||
name: "parse rule with match expression statistic", | ||
s: "-A foo ! -s 192.168.178.2 ! --dst 1.1.1.1 -m statistic --mode random --probability 0.50000000000 --every 10 --packet 5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm this is a bit funny. Now, rules that have a probability of 0.5 are different from rules with 0.50.
I wonder if we can do anything about that?
parser_test.go
Outdated
} else if tc.err != err && tc.err.Error() != err.Error() { | ||
t.Errorf("%d. %s: %q error mismatch:\n\texp=%v\n\tgot=%v.", i, tc.name, tc.s, tc.err, err) | ||
} | ||
t.Run(tc.name, func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
targets.go
Outdated
@@ -29,6 +29,8 @@ func (p *Parser) parseTarget(t *Target) (state, error) { | |||
switch lit { | |||
case "DNAT": | |||
s, err = p.parseDNAT(&t.Flags) | |||
case "SNAT": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you need to rebase from our main branch. Your branch is behind
0e8c883
to
3bb8ea9
Compare
Resolves #10