README.md (1464B)
1 # Bundled IP geolocation data 2 3 ip-country.bin is generated from the IPv4 and IPv6 user-country CIDR 4 datasets published by [sapics/ip-location-db](https://github.com/sapics/ip-location-db). 5 That dataset is dedicated to the public domain under the 6 [Open Data Commons PDDL 1.0](https://opendatacommons.org/licenses/pddl/1-0/), 7 which permits use, modification, embedding, and redistribution without an 8 attribution requirement. 9 10 Rust's include_bytes! embeds the generated database into the executable at 11 compile time. It is not a runtime file or web asset, and lookups never use the 12 network or filesystem. 13 14 Update the database from the repository root with: 15 16 ```sh 17 python3 scripts/update_geoip.py 18 ``` 19 20 For a reproducible/offline regeneration from previously downloaded archives: 21 22 ```sh 23 python3 scripts/update_geoip.py \ 24 --ipv4-csv /path/to/user-country-ipv4-cidr.csv \ 25 --ipv6-csv /path/to/user-country-ipv6-cidr.csv 26 ``` 27 28 The compact binary format starts with IUNAGEO2, followed by record counts for 29 each IPv4 and IPv6 prefix length and sorted fixed-width network-address/country 30 records. Lookup checks prefix groups from most to least specific and uses binary 31 search within each group. This provides longest-prefix-match without allocating 32 a large in-memory trie at startup. 33 34 The source-data provenance is retained here for auditability; neither the PDDL 35 nor the dataset requires it to be displayed in the application or shipped as a 36 separate runtime file.