{"id":17654449,"url":"https://github.com/tbu-/libloc-rs","last_synced_at":"2026-06-09T04:32:48.659Z","repository":{"id":221263596,"uuid":"753891607","full_name":"tbu-/libloc-rs","owner":"tbu-","description":"Read location databases in libloc format","archived":false,"fork":false,"pushed_at":"2024-07-02T01:39:36.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-27T16:12:55.938Z","etag":null,"topics":["geoip","libloc"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tbu-.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-07T01:26:46.000Z","updated_at":"2024-07-29T11:20:33.000Z","dependencies_parsed_at":"2025-02-27T12:55:49.615Z","dependency_job_id":"069f5fba-0f6b-4f51-9aaf-35e17d5e0ef6","html_url":"https://github.com/tbu-/libloc-rs","commit_stats":null,"previous_names":["tbu-/libloc-rs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tbu-/libloc-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbu-%2Flibloc-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbu-%2Flibloc-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbu-%2Flibloc-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbu-%2Flibloc-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tbu-","download_url":"https://codeload.github.com/tbu-/libloc-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbu-%2Flibloc-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34092260,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geoip","libloc"],"created_at":"2024-10-23T12:14:12.437Z","updated_at":"2026-06-09T04:32:48.650Z","avatar_url":"https://github.com/tbu-.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Read location databases in [libloc] format.\n\nIt features constant-time lookups of IPv6/IPv4 addresses to [ASN] and country\ndata ([\"GeoIP\"]). The database also contains names of [AS] and countries.\n\n**The main struct of this crate is [`Locations`]**. First, you'll need a\ndatabase. A recent version of the official IPFire database can be obtained from\n\u003chttps://location.ipfire.org/databases/1/location.db.xz\u003e, xz-compressed. Then\nyou can start from [`Locations::open`] and use [`Locations::lookup`] to look up\ninformation on a particular IP address.\n\nA short overview about the internals of the database format can be found at\n\u003chttps://www.ipfire.org/blog/libloc-or-what-is-working-inside-it\u003e. A Kaitai\nstruct implementation `ipfire_libloc_db_v1.ksy` can be found in this\nrepository.\n\n# Examples\n\n```rust\nuse libloc::Locations;\n\nlet locations = Locations::open(\"example-location.db\")?;\n\nlet network: libloc::Network = locations.lookup(\"2a07:1c44:5800::1\".parse().unwrap()).unwrap();\nassert_eq!(network.country_code(), \"DE\");\nassert_eq!(network.asn(), 204867);\nassert_eq!(network.is_anonymous_proxy(), false);\nassert_eq!(network.addrs().to_string(), \"2a07:1c44:5800::/40\");\n\nlet country: libloc::Country = locations.country(\"DE\").unwrap();\nassert_eq!(country.continent_code(), \"EU\");\nassert_eq!(country.name(), \"Germany\");\n\nlet as_: libloc::As = locations.as_(204867).unwrap();\nassert_eq!(as_.name(), \"Lightning Wire Labs GmbH\");\n\n# Ok::\u003c(), libloc::OpenError\u003e(())\n```\n\n# Panics\n\nAny function from this library might panic if the database is corrupt.\n\n# Benches\n\nThis library was written for fun. It's still a lot faster than the original\n[libloc], even though it wasn't optimized for speed.\n\n```text\n     Running benches/locations.rs\n\nrunning 4 tests\ntest lookup    ... bench:          87 ns/iter (+/- 15)\ntest lookup_v4 ... bench:          61 ns/iter (+/- 5)\ntest lookup_v6 ... bench:         396 ns/iter (+/- 22)\ntest open      ... bench:      64,012 ns/iter (+/- 4,592)\n\ntest result: ok. 0 passed; 0 failed; 0 ignored; 4 measured\n\n     Running benches/native.rs\n\nrunning 2 tests\ntest lookup_v6 ... bench:       1,019 ns/iter (+/- 128)\ntest open      ... bench:     234,420 ns/iter (+/- 19,638)\n\ntest result: ok. 0 passed; 0 failed; 0 ignored; 2 measured\n```\n\nIt's looking up IPv6 addresses roughly 2.5x as fast, it has special handling\nfor IPv4 addresses which makes it \u003e10x as fast.\n\n\n[\"GeoIP\"]: https://en.wikipedia.org/wiki/Internet_geolocation\n[ASN]: https://en.wikipedia.org/wiki/Autonomous_system_(Internet)\n[AS]: https://en.wikipedia.org/wiki/Autonomous_system_(Internet)\n[libloc]: https://www.ipfire.org/projects/location/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbu-%2Flibloc-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftbu-%2Flibloc-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbu-%2Flibloc-rs/lists"}