Metadata-Version: 2.5
Name: lupaxa-ipinfo-update
Version: 0.1.2
Summary: Download the IPinfo Lite database for local TCP wrappers and other tools.
Project-URL: Homepage, https://github.com/lupaxa-security-toolbox/ipinfo-update
Project-URL: Repository, https://github.com/lupaxa-security-toolbox/ipinfo-update
Project-URL: Issues, https://github.com/lupaxa-security-toolbox/ipinfo-update/issues
Author: The Lupaxa Project
License: MIT License
        
        Copyright (c) The Lupaxa Project
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENCE
Keywords: cli,cron,geoip,ipinfo,mmdb
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Security
Classifier: Topic :: System :: Networking
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Requires-Dist: requests>=2.32
Provides-Extra: dev
Requires-Dist: bump-my-version>=1.2.0; extra == 'dev'
Requires-Dist: hatch>=1.12.0; extra == 'dev'
Requires-Dist: mypy>=1.12.0; extra == 'dev'
Requires-Dist: pip-audit>=2.7.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Provides-Extra: test
Requires-Dist: pytest-cov>=5.0; extra == 'test'
Requires-Dist: pytest>=8.0; extra == 'test'
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://github.com/lupaxa-security-toolbox">
    <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/organisations/security-toolbox/readme-logo.png" alt="Security Toolbox" />
  </a>
</p>

<h1 align="center">IPinfo Update</h1>

Download the IPinfo Lite database for local TCP wrappers and other tools.
The PyPI name is `lupaxa-ipinfo-update`. The console script is
`ipinfo-update`.

The command line overrides the environment. Omit `--token` to use
`IPINFO_TOKEN`, and omit `--output` to use `IPINFO_DATABASE` when that
variable is set. A failed download leaves the previous database in place.

## Install

```bash
pip install lupaxa-ipinfo-update
ipinfo-update --help
```

Requires Python 3.10 or newer. You can also run
`python -m lupaxa.ipinfo_update`.

## CLI

```bash
export IPINFO_TOKEN=your-token
ipinfo-update
ipinfo-update --token your-token --quiet
```

The default path is `/var/lib/ipinfo/ipinfo_lite.mmdb`.
`IPINFO_DATABASE` replaces that default. `--output` replaces both.
If the directory does not exist, it is created. The finished file is mode `0644`.

### Flags

| Flag        | Default                                | Description                                              |
| :---------- | :------------------------------------- | :------------------------------------------------------- |
| `--token`   | `IPINFO_TOKEN`                         | IPinfo access token (`-t`)                               |
| `--output`  | `/var/lib/ipinfo/ipinfo_lite.mmdb`     | Database path (`-o`). `IPINFO_DATABASE` is the fallback  |
| `--timeout` | `60`                                   | HTTP timeout in seconds                                  |
| `--quiet`   | off                                    | Print nothing on success (`-q`)                          |
| `--version` | —                                      | Print the package version and exit                       |

`--token` and `--output` are optional. When `--output` is omitted,
`IPINFO_DATABASE` is used if that variable is set.

### Exit Codes

| Code | When                                                  |
| :--- | :---------------------------------------------------- |
| `0`  | Help, version, or the database was replaced           |
| `1`  | The token is missing, or the download or write failed |
| `2`  | Invalid arguments                                     |

## Cron

```cron
15 3 * * * IPINFO_TOKEN=your-token ipinfo-update --quiet
```

`--quiet` prints nothing when the update succeeds. Failures still go to
stderr and exit `1`, and the previous file is left unchanged.

## Development

```bash
make init
make install-dev
make check
```

<a href="https://github.com/the-lupaxa-project">
    <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/components/footer-for-child-orgs.svg" alt="The Lupaxa Project Footer" width="100%" />
</a>
