-
Notifications
You must be signed in to change notification settings - Fork 105
Add LookupNetwork method #59
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
69bf5db
Update test databases
oschwald 0e92ca0
gofmt with recent version
oschwald 86e7363
Simplify conditional
oschwald 51f1e57
Clean up some linter issues in test
oschwald 939c1fe
Do not return error unnecessarily
oschwald d75558d
Remove unnecessary conversion
oschwald a6d2dee
Ignore linter on placeholders
oschwald 3975b74
Add golangci-lint to Travis build
oschwald 7648156
Improve error checks in tests
oschwald a3d3e24
Add function to get path for test file
oschwald f3bf31c
Add support for getting record network
oschwald 2e4e02d
Rename benchmark method to be more accurate
oschwald 68b0d2c
Inline error check
oschwald 557b0cb
Add bencmark for LookupNetwork
oschwald af32f0e
Improve Lookup documentation
oschwald 64ca3eb
Rename ipAddress variable to ip
oschwald 34a6159
Handle IPv6 tree without IPv4 subtree
oschwald 8dac192
Fix typo
oschwald 27395cf
Try to clarify comment on IPv4 start bit depth
oschwald 37f6024
Improve performance of node reading
oschwald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[run] | ||
deadline = "10m" | ||
tests = true | ||
|
||
[linters] | ||
disable-all = true | ||
enable = [ | ||
"deadcode", | ||
"depguard", | ||
"errcheck", | ||
"goconst", | ||
"gocyclo", | ||
"gocritic", | ||
"gofmt", | ||
"golint", | ||
"gosec", | ||
"gosimple", | ||
"ineffassign", | ||
"maligned", | ||
"misspell", | ||
"nakedret", | ||
"staticcheck", | ||
"structcheck", | ||
"typecheck", | ||
"unconvert", | ||
"unparam", | ||
"varcheck", | ||
"vet", | ||
"vetshadow", | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package maxminddb | ||
|
||
type nodeReader interface { | ||
readLeft(uint) uint | ||
readRight(uint) uint | ||
} | ||
|
||
type nodeReader24 struct { | ||
buffer []byte | ||
} | ||
|
||
func (n nodeReader24) readLeft(nodeNumber uint) uint { | ||
return (uint(n.buffer[nodeNumber]) << 16) | (uint(n.buffer[nodeNumber+1]) << 8) | uint(n.buffer[nodeNumber+2]) | ||
} | ||
|
||
func (n nodeReader24) readRight(nodeNumber uint) uint { | ||
return (uint(n.buffer[nodeNumber+3]) << 16) | (uint(n.buffer[nodeNumber+4]) << 8) | uint(n.buffer[nodeNumber+5]) | ||
} | ||
|
||
type nodeReader28 struct { | ||
buffer []byte | ||
} | ||
|
||
func (n nodeReader28) readLeft(nodeNumber uint) uint { | ||
return ((uint(n.buffer[nodeNumber+3]) & 0xF0) << 20) | (uint(n.buffer[nodeNumber]) << 16) | (uint(n.buffer[nodeNumber+1]) << 8) | uint(n.buffer[nodeNumber+2]) | ||
} | ||
|
||
func (n nodeReader28) readRight(nodeNumber uint) uint { | ||
return ((uint(n.buffer[nodeNumber+3]) & 0x0F) << 24) | (uint(n.buffer[nodeNumber+4]) << 16) | (uint(n.buffer[nodeNumber+5]) << 8) | uint(n.buffer[nodeNumber+6]) | ||
} | ||
|
||
type nodeReader32 struct { | ||
buffer []byte | ||
} | ||
|
||
func (n nodeReader32) readLeft(nodeNumber uint) uint { | ||
return (uint(n.buffer[nodeNumber]) << 24) | (uint(n.buffer[nodeNumber+1]) << 16) | (uint(n.buffer[nodeNumber+2]) << 8) | uint(n.buffer[nodeNumber+3]) | ||
} | ||
|
||
func (n nodeReader32) readRight(nodeNumber uint) uint { | ||
return (uint(n.buffer[nodeNumber+4]) << 24) | (uint(n.buffer[nodeNumber+5]) << 16) | (uint(n.buffer[nodeNumber+6]) << 8) | uint(n.buffer[nodeNumber+7]) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.