{"id":19045434,"url":"https://github.com/marirs/rust-ip2location","last_synced_at":"2025-04-05T20:07:57.778Z","repository":{"id":62441063,"uuid":"326622554","full_name":"marirs/rust-ip2location","owner":"marirs","description":"IP2Location DB Reader","archived":false,"fork":false,"pushed_at":"2024-12-16T17:00:38.000Z","size":22433,"stargazers_count":29,"open_issues_count":1,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T19:06:43.797Z","etag":null,"topics":["database","db","geolocation","ip2location","ip2location-bin-database","ip2proxy","ip2proxy-bin-database","rust","rust-crate","rust-lang","rust-library"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marirs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-01-04T08:50:28.000Z","updated_at":"2025-02-22T22:10:09.000Z","dependencies_parsed_at":"2025-01-06T11:35:40.010Z","dependency_job_id":null,"html_url":"https://github.com/marirs/rust-ip2location","commit_stats":{"total_commits":60,"total_committers":5,"mean_commits":12.0,"dds":"0.43333333333333335","last_synced_commit":"e9bbb0c2cba3ce197fdc8f5000e1cc3bc9c297a0"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Frust-ip2location","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Frust-ip2location/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Frust-ip2location/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Frust-ip2location/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marirs","download_url":"https://codeload.github.com/marirs/rust-ip2location/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393570,"owners_count":20931812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["database","db","geolocation","ip2location","ip2location-bin-database","ip2proxy","ip2proxy-bin-database","rust","rust-crate","rust-lang","rust-library"],"created_at":"2024-11-08T22:50:12.053Z","updated_at":"2025-04-05T20:07:57.759Z","avatar_url":"https://github.com/marirs.png","language":"Rust","readme":"# IP2Location \u0026 IP2Proxy\n\n[![Crates.io](https://img.shields.io/crates/v/ip2location)](https://crates.io/crates/ip2location)\n[![Documentation](https://docs.rs/ip2location/badge.svg)](https://docs.rs/ip2location/)\n\n[![Linux Arm7](https://github.com/marirs/rust-ip2location/actions/workflows/linux_arm.yml/badge.svg)](https://github.com/marirs/rust-ip2location/actions/workflows/linux_arm.yml)\n[![Linux x86_64](https://github.com/marirs/rust-ip2location/actions/workflows/linux_x86_64.yml/badge.svg)](https://github.com/marirs/rust-ip2location/actions/workflows/linux_x86_64.yml)\n[![macOS x86_64](https://github.com/marirs/rust-ip2location/actions/workflows/macos.yml/badge.svg)](https://github.com/marirs/rust-ip2location/actions/workflows/macos.yml)\n[![Windows x86_64](https://github.com/marirs/rust-ip2location/actions/workflows/windows.yml/badge.svg)](https://github.com/marirs/rust-ip2location/actions/workflows/windows.yml)\n\n\nThis library reads the IP2Location DB format for both IP2Location and IP2Proxy and returns geo information for the given IP.\n\n### Requirements\n- `Rust 1.60.0` and above (edition 2021)\n\n### Building\n- debug\n```bash\ncargo b\n```\n- release\n```bash\ncargo b --release\n```\n\n### Testing\n```bash\ncargo t -v\n```\n\n### Usage\n```toml\n[dependencies]\nip2location = \"0.5.4\"\n```\n\n### Example\n```rust\nuse ip2location::{error, Record, DB};\n\nconst IPV4BIN: \u0026str = \"data/IP2LOCATION-LITE-DB1.BIN\";\nconst IPV6BIN: \u0026str = \"data/IP2LOCATION-LITE-DB1.IPV6.BIN\";\nconst IP2PROXYBIN: \u0026str = \"data/IP2PROXY-IP-COUNTRY.BIN\";\n\n// Lookup an IP v4 in the IP2Location V6 BIN Database\nfn ip_lookup_in_ipv6bin() -\u003e Result\u003c(), error::Error\u003e {\n    let mut db = DB::from_file(IPV6BIN)?;\n    let record = db.ip_lookup(\"43.224.159.155\".parse().unwrap())?;\n    let record = if let Record::LocationDb(rec) = record {\n        Some(rec)\n    } else {\n        None\n    };\n    assert!(record.is_some());\n    let record = record.unwrap();\n    assert!(!record.country.is_none());\n    assert_eq!(record.country.clone().unwrap().short_name, \"IN\");\n    assert_eq!(record.country.unwrap().long_name, \"India\");\n    Ok(())\n}\n\n// Lookup an IP v4 in the IP2Location V4 BIN Database\nfn ip_lookup_in_ipv4bin() -\u003e Result\u003c(), error::Error\u003e {\n    let mut db = DB::from_file(IPV4BIN)?;\n    let record = db.ip_lookup(\"43.224.159.155\".parse().unwrap())?;\n    let record = if let Record::LocationDb(rec) = record {\n        Some(rec)\n    } else {\n        None\n    };\n    assert!(record.is_some());\n    let record = record.unwrap();\n    assert!(!record.country.is_none());\n    assert_eq!(record.country.clone().unwrap().short_name, \"IN\");\n    assert_eq!(record.country.unwrap().long_name, \"India\");\n    Ok(())\n}\n\n// Lookup an IP in the Proxy Database\nfn ip_lookup_in_proxy_bin() -\u003e Result\u003c(), error::Error\u003e {\n    let mut db = DB::from_file(IP2PROXYBIN)?;\n    let record = db.ip_lookup(\"1.1.1.1\".parse().unwrap())?;\n    let record = if let Record::ProxyDb(rec) = record {\n        Some(rec)\n    } else {\n        None\n    };\n    assert!(record.is_some());\n    let record = record.unwrap();\n    assert!(!record.country.is_none());\n    Ok(())\n}\n```\n\n### Executing the Example\n```bash\ncargo b --example\n\n# IP2Lcoation Example\n\n./target/debug/examples/lookup data/IP2LOCATION-LITE-DB1.IPV6.BIN 2a01:cb08:8d14::\nDb Path: data/IP2LOCATION-LITE-DB1.IPV6.BIN\n |- Db Type: 1\n |- Db Column: 2\n |- Db Date (YY/MM/DD): 20/12/28\n\nOk(\n    Record {\n        ip: \"2a01:cb08:8d14::\",\n        latitude: None,\n        longitude: None,\n        country: Some(\n            Country {\n                short_name: \"FR\",\n                long_name: \"France\",\n            },\n        ),\n        region: None,\n        city: None,\n        isp: None,\n        domain: None,\n        zip_code: None,\n        time_zone: None,\n        net_speed: None,\n        idd_code: None,\n        area_code: None,\n        weather_station_code: None,\n        weather_station_name: None,\n        mcc: None,\n        mnc: None,\n        mobile_brand: None,\n        elevation: None,\n        usage_type: None,\n        address_type: None,\n        category: None,\n        district: None,\n        asn: None,\n        as_name: None,\n    },\n)\n\n# IP2Proxy Example \n \n./target/debug/examples/lookup data/sample.bin.px11/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN 194.59.249.19\nDb Path: data/sample.bin.px11/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN\n |- Db Type: 11\n |- Db Column: 13\n |- Db Date (YY/MM/DD): 21/5/28\n\nProxyDb(\n    ProxyRecord {\n        ip: 1.1.1.1,\n        country: Some(\n            Country {\n                short_name: \"US\",\n                long_name: \"United States of America\",\n            },\n        ),\n        region: Some(\n            \"California\",\n        ),\n        city: Some(\n            \"Los Angeles\",\n        ),\n        isp: Some(\n            \"APNIC and CloudFlare DNS Resolver Project\",\n        ),\n        domain: Some(\n            \"cloudflare.com\",\n        ),\n        is_proxy: Some(\n            IsAProxy,\n        ),\n        proxy_type: Some(\n            \"DCH\",\n        ),\n        asn: Some(\n            \"13335\",\n        ),\n        as_: Some(\n            \"CloudFlare Inc\",\n        ),\n        last_seen: Some(\n            \"27\",\n        ),\n        threat: Some(\n            \"-\",\n        ),\n        provider: Some(\n            \"-\",\n        ),\n        usage_type: Some(\n            \"CDN\",\n        ),\n    },\n)\n```\n\n### License\nThis is free software, licensed under the MIT license.\n\n### Ip2Location Databases:\n- Lite free version: [Free](https://lite.ip2location.com/)\n- Ip2Location / Ip2Proxy: [Commercial](https://ip2location.com/database/)\n\n---\nSriram\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarirs%2Frust-ip2location","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarirs%2Frust-ip2location","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarirs%2Frust-ip2location/lists"}