{"id":17623748,"url":"https://github.com/wiseaidev/ipcap","last_synced_at":"2025-04-30T16:07:29.285Z","repository":{"id":214655541,"uuid":"737045213","full_name":"wiseaidev/ipcap","owner":"wiseaidev","description":"🌍 Perform IP lookup from the command line without internet access. (WIP)","archived":false,"fork":false,"pushed_at":"2024-05-07T12:33:27.000Z","size":35289,"stargazers_count":6,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T23:46:59.735Z","etag":null,"topics":["clap","geoip","geolocation","ip","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/ipcap","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/wiseaidev.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":"2023-12-29T16:34:25.000Z","updated_at":"2024-05-07T12:34:32.000Z","dependencies_parsed_at":"2024-05-07T13:40:44.819Z","dependency_job_id":null,"html_url":"https://github.com/wiseaidev/ipcap","commit_stats":{"total_commits":34,"total_committers":2,"mean_commits":17.0,"dds":0.1470588235294118,"last_synced_commit":"7ff53c673a6af1f1a2ed959e9f9caac2c67cbf12"},"previous_names":["wiseaidev/ipcap"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Fipcap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Fipcap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Fipcap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Fipcap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wiseaidev","download_url":"https://codeload.github.com/wiseaidev/ipcap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251738892,"owners_count":21635890,"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":["clap","geoip","geolocation","ip","rust"],"created_at":"2024-10-22T21:42:42.217Z","updated_at":"2025-04-30T16:07:29.164Z","avatar_url":"https://github.com/wiseaidev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌍 IPCap\n\n[![Crates.io](https://img.shields.io/crates/v/ipcap.svg)](https://crates.io/crates/ipcap)\n[![docs](https://docs.rs/ipcap/badge.svg)](https://docs.rs/ipcap/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\n```sh\nipcap 0.1.7\n\n ▄█     ▄███████▄  ▄████████    ▄████████    ▄███████▄ \n███    ███    ███ ███    ███   ███    ███   ███    ███ \n███▌   ███    ███ ███    █▀    ███    ███   ███    ███ \n███▌   ███    ███ ███          ███    ███   ███    ███ \n███▌ ▀█████████▀  ███        ▀███████████ ▀█████████▀  \n███    ███        ███    █▄    ███    ███   ███        \n███    ███        ███    ███   ███    ███   ███        \n█▀    ▄████▀      ████████▀    ███    █▀   ▄████▀      \n\n🌍 IPCAP CLI\n============\n\nPerform IP lookup from the command line without internet access. Retrieve information\nabout IP addresses, including details such as city, region, country, location, etc.\n```\n\n## 📖 Table of Contents\n\n- [Installation](#-installation)\n- [Features](#-features)\n- [Usage](#-usage-as-cli)\n- [Options](#-options)\n- [Contributing](#-contributing)\n- [License](#-license)\n\n## 🚀 Installation\n\nTo install `ipcap`, use the following Cargo command:\n\n```bash\ncargo install --locked ipcap --all-features\n```\n\n## 📖 Download the dataset\n\nDownload the city databases, v4 and v6 from the repository using this command:\n\n```sh\n# IPV4 database\ncurl -LS https://raw.githubusercontent.com/wiseaidev/ipcap/main/data/geo_ip_city_v4.dat --create-dirs -o ~/.local/share/ipcap/geo_ip_city_v4.dat\n\n# IPV6 database\ncurl -LS https://raw.githubusercontent.com/wiseaidev/ipcap/main/data/geo_ip_city_v6.dat --create-dirs -o ~/.local/share/ipcap/geo_ip_city_v6.dat\n```\n\nThis will download the `data/geo_ip_city_v4.dat` and or `data/geo_ip_city_v4.dat` database(s) from the repository and put it under `~/.local/share/ipcap/`.\n\nIf, for some reason, you decide to change this file location, just set this environment variable to help the CLI read this file. To set the environment variable before running your Rust program, you can do something like:\n\n```sh\n# IPV4 database\nexport IPCAP_FILE_PATH=/your/custom/path/geo_ip_city_v4.dat\n\n# IPV6 database\nexport IPCAP_FILE_PATH=/your/custom/path/geo_ip_city_v6.dat\n```\n\nReplace `/your/custom/path/geo_ip_city_v4.dat` with the desired file path. If the environment variable is not set, the program will use the default path (`/home/username/ipcap/geo_ip_city_v4.dat`).\n\n\u003e [!NOTE]\nThe default location to find the databases is `~/Library/Application Support/ipcap/` on macOS, and `C:\\Users\\Username\\AppData\\Local\\ipcap\\` on Windows.\n\n\u003e [!NOTE]\nThe databases were shamelessly taken from the fedora website at [https://src.fedoraproject.org/repo/pkgs/GeoIP-GeoLite-data/](https://src.fedoraproject.org/repo/pkgs/GeoIP-GeoLite-data/).\n\n## About the IPV4 dataset\n\nThe last 600 bytes of this dataset:\n\n```sh\n  -46   29  -75  -66   42  103   50   56    0   75  111  108  107   97\n  116   97    0   55   52   51   49   50   53    0  -31  -24   30   49\n  -13   40  103   50   56    0   67  104   97  110  100   97  110  110\n   97  103   97  114    0   55   49   50   49   51   55    0 -108  -12\n   30  124  -13   40  103   50   56    0   72  111  111  103  104  108\n  121    0   55   49   50   49   50   49    0 -100  -11   30  121  -12\n   40  103   49   49    0   66  104   97  114  109  111  117  114    0\n   49   55   54   51   49   53    0  -44  106   32  -43   36   39  103\n   49   48    0   66   97  110  119   97  115   97    0    0  -84  -23\n   31    4   38   39  103   49   49    0   68   97  100   97  104  117\n    0   49   55   51   48   50   50    0   55   35   32   -3   71   39\n  103   50   51    0   82  117  112  110   97  103   97  114    0    0\n  -32   48   32  -45   36   39  103   49   57    0   78   97  103   97\n  114    0    0  -99 -109   29 -105  -23   38  100   48   52    0   75\n  101  109   97  110  103  103  105  115   97  110    0    0   90 -123\n   26  -80  -62   43    0    0    0   71   69   79   45   53   51   51\n   76   73   84   69   32   50   48   49   54   48   52   48   53   32\n   66  117  105  108  100   32   49   32   67  111  112  121  114  105\n  103  104  116   32   40   99   41   32   50   48   49   54   32   77\n   97  120   77  105  110  100   32   73  110   99   32   65  108  108\n   32   82  105  103  104  116  115   32   82  101  115  101  114   -1\n   -1   -1    2   52  -67   41\n```\n\ncan be interpreted as follows:\n\n```sh\n^00 Shek Kip Mei       \n24 Phayakkhaphum Phisai 44110 _   6+ 70 Yala 95120 \nJt   * 05 Ban Hong   -   * 44 Bang Khla 24110      \n* 68 Ban Na   v   * 77 Amnat Charoen 37000    \nMp+ 68 Ban Phru  _z   * 68 Chana 90160  ~   \n* 46 Si Racha 20110  y   * 02 Chiang Mai 50250  \nW   * 16 Nakhon Sawan 60130      *g28 Kolkata 743125    \n1 (g28 Chandannagar 712137    | (g28 Hooghly 712121    \ny (g11 Bharmour 176315  j  $'g10 Banwasa      \u0026'g11 Dadahu 173022 \n7#  G'g23 Rupnagar   0  $'g19 Nagar       \u0026d04 Kemanggisan  Z    \n+   GEO-533LITE 20160405 Build 1 Copyright (c) 2016 MaxMind Inc All Rights Reserved    4\n```\n\nThe forth byte from the end of the file, '2', indicates the database type as the GeoLite City database `CITY_EDITION_REV1`. This dataset provides geolocation information, featuring diverse locations, numeric codes, and associated details. Place names, such as \"Shek Kip Mei\" and \"Chiang Mai,\" and numeric codes, postal codes, contribute to the dataset's geographical context. Additionally, metadata elements like \"GEO-533LITE\" and a copyright statement suggest a connection to the MaxMind geolocation database. The dataset aims to offer insights into the geographical distribution of locations and is potentially valuable for geospatial analysis, like this project.\n\n## ✨ Features\n\n- Auto detect ipv4 and ipv6.\n- IP address lookup without internet access.\n- Zero API calls for decoding IP addresses.\n- Dataset download and customizable file path.\n\n## ⌨ Usage as CLI\n\n### Perform IPV4 lookup:\n\n```sh\nipcap -t 8.8.8.8\n```\n\n### Perform IPV6 lookup:\n\n```sh\nipcap -t 2a08:1450:300f:900::1003\n```\n\n## 💻 Usage as Dep\n\n```toml\n[dependencies]\nipcap = \"0.1.7\"\n```\n\n```rust\nuse ipcap::geo_ip_reader::GeoIpReader;\nuse ipcap::utils::pretty_print_dict;\nuse std::fs::File;\n\nfn main() {\n    let mut geo_ip = GeoIpReader::\u003cFile\u003e::new(\"v4\").unwrap();\n    let mut record = geo_ip.get_record(\"8.8.8.8\");\n\n    pretty_print_dict(record);\n\n    geo_ip = GeoIpReader::\u003cFile\u003e::new(\"v6\").unwrap();\n    record = geo_ip.get_record(\"2a08:1450:300f:900::1003\");\n\n    pretty_print_dict(record);\n}\n```\n\n## 🎨 Options\n\n| Option                   | Default Value | Description                                              |\n|--------------------------|---------------|----------------------------------------------------------|\n| `--target`               | `\"\"`          | Set the IP address, v4 or v6, to lookup with the --target option. |\n  \n## 🤝 Contributing\n\nContributions and feedback are welcome! If you'd like to contribute, report an issue, or suggest an enhancement, please engage with the project on [GitHub](https://github.com/wiseaidev/ipcap).\nYour contributions help improve this CLI for the community.\n\n## 📄 License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiseaidev%2Fipcap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiseaidev%2Fipcap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiseaidev%2Fipcap/lists"}