Skip to content

Commit

Permalink
Rename to NetworksWithin
Browse files Browse the repository at this point in the history
  • Loading branch information
faktas2 committed Nov 3, 2023
1 parent 29b5c1a commit 3563ca7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/main/java/com/maxmind/db/Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ public Networks networks(boolean skipAliasedNetworks) throws
Network ipAllV6 = new Network(ipv6, 0); // Mask 128.

if (this.getMetadata().getIpVersion() == 6) {
return this.networksWithIn(ipAllV6, skipAliasedNetworks);
return this.networksWithin(ipAllV6, skipAliasedNetworks);
}
return this.networksWithIn(ipAllV4, skipAliasedNetworks);
return this.networksWithin(ipAllV4, skipAliasedNetworks);
} catch (UnknownHostException e) {
/* This is returned by getByAddress. This should never happen
as the ipv4 and ipv6 are constants set by us. */
Expand Down Expand Up @@ -293,7 +293,7 @@ private int findIpV4StartNode(ByteBuffer buffer)
* @throws ClosedDatabaseException Exception for a closed databased.
* @throws InvalidDatabaseException Exception for an invalid database.
*/
public <T> Networks<T> networksWithIn(Network network, boolean skipAliasedNetworks)
public <T> Networks<T> networksWithin(Network network, boolean skipAliasedNetworks)
throws InvalidNetworkException, ClosedDatabaseException, InvalidDatabaseException {
InetAddress networkAddress = network.getNetworkAddress();
if (this.metadata.getIpVersion() == 4 && networkAddress instanceof Inet6Address) {
Expand All @@ -304,10 +304,10 @@ public <T> Networks<T> networksWithIn(Network network, boolean skipAliasedNetwor
int prefixLength = network.getPrefixLength();

if (this.metadata.getIpVersion() == 6 && ipBytes.length == IPV4_LEN) {
if (skipAliasedNetworks) {
ipBytes = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
ipBytes[0], ipBytes[1], ipBytes[2], ipBytes[3] };
} else {
if (skipAliasedNetworks) {
ipBytes = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
ipBytes[0], ipBytes[1], ipBytes[2], ipBytes[3] };
} else {
// Convert it to the IP address (in 16-byte from) of the IPv4 address.
ipBytes = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, -1, // -1 is for 0xff.
Expand All @@ -333,7 +333,7 @@ public <T> Networks<T> networksWithIn(Network network, boolean skipAliasedNetwor
* @param bitCount The prefix.
* @return int[]
*/
public int[] traverseTree(byte[] ip, int node, int bitCount)
private int[] traverseTree(byte[] ip, int node, int bitCount)
throws ClosedDatabaseException, InvalidDatabaseException {
int nodeCount = this.metadata.getNodeCount();
int i = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/maxmind/db/ReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public void testNetworksWithin() throws IOException, InvalidNetworkException{
InetAddress address = InetAddress.getByName(test.network);
Network network = new Network(address, test.prefix);

Networks networks = reader.networksWithIn(network, test.skipAliasedNetworks);
Networks networks = reader.networksWithin(network, test.skipAliasedNetworks);
networks.setDataClass(Map.class);

ArrayList<String> innerIPs = new ArrayList<String>();
Expand Down Expand Up @@ -376,7 +376,7 @@ public void testGeoIPNetworksWithin() throws IOException, InvalidNetworkExceptio
InetAddress address = InetAddress.getByName(test.network);
Network network = new Network(address, test.prefix);

Networks networks = reader.networksWithIn(network, test.skipAliasedNetworks);
Networks networks = reader.networksWithin(network, test.skipAliasedNetworks);
networks.setDataClass(Map.class);

ArrayList<String> innerIPs = new ArrayList<String>();
Expand Down

0 comments on commit 3563ca7

Please sign in to comment.