Skip to content

Commit

Permalink
[Bug]: utils.IsIPv4 and net.ParseIP have inconsistent results gofiber…
Browse files Browse the repository at this point in the history
  • Loading branch information
itswcg committed Nov 21, 2023
1 parent 2374cad commit e68e770
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion utils/ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func IsIPv4(s string) bool {

for ci = 0; ci < len(s) && '0' <= s[ci] && s[ci] <= '9'; ci++ {
n = n*10 + int(s[ci]-'0')
if n >= 0xFF {
if n > 0xFF {
return false
}
}
Expand Down
1 change: 1 addition & 0 deletions utils/ips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func Test_IsIPv4(t *testing.T) {

AssertEqual(t, true, IsIPv4("174.23.33.100"))
AssertEqual(t, true, IsIPv4("127.0.0.1"))
AssertEqual(t, true, IsIPv4("127.255.255.255"))
AssertEqual(t, true, IsIPv4("0.0.0.0"))

AssertEqual(t, false, IsIPv4(".0.0.0"))
Expand Down

0 comments on commit e68e770

Please sign in to comment.