mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-02 08:16:53 +00:00
Add support for getting country codes for ASNs.
This commit is contained in:
1 parent
f8c623074b
commit
b89de860d3
2 files changed
+22
-7
No files matched your search
@@ -30,6 +30,17 @@ class AsnTableTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void getCountryCode() throws IOException {
|
||||
try (final InputStreamReader reader = new InputStreamReader(getClass().getResourceAsStream("ip2asn-test.tsv"))) {
|
||||
final AsnTable asnTable = new AsnTable(reader);
|
||||
|
||||
assertEquals(Optional.of("US"), asnTable.getCountryCode(7922));
|
||||
assertEquals(Optional.of("VN"), asnTable.getCountryCode(7552));
|
||||
assertEquals(Optional.empty(), asnTable.getCountryCode(1234));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void ipToLong() throws UnknownHostException {
|
||||
assertEquals(0x00000000ffffffffL, AsnTable.ipToLong((Inet4Address) Inet4Address.getByName("255.255.255.255")));
|
||||
|
||||
Reference in new issue
Block a user