Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hidekuno/cidr-lite
country search from IP address
https://github.com/hidekuno/cidr-lite
docker fastapi mysql python3 sqlite3
Last synced: 18 days ago
JSON representation
country search from IP address
- Host: GitHub
- URL: https://github.com/hidekuno/cidr-lite
- Owner: hidekuno
- Created: 2019-10-17T23:01:10.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-06-06T09:03:06.000Z (6 months ago)
- Last Synced: 2024-06-06T10:15:00.846Z (6 months ago)
- Topics: docker, fastapi, mysql, python3, sqlite3
- Language: Python
- Homepage:
- Size: 79.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
IP address search tool
=================## Overview
- Search the CIDR format network address and country code from the IPv4 address.## Build
### Requirement
- account of maxmind.com(https://www.maxmind.com/en/account/login)
- python3 installed.
- sqlite3 installed.```
cd ${HOME}
git clone https://github.com/hidekuno/cidr-lite
cd cidr-lite
python3 cidr_create_geoip.py --token ${your_token}
sqlite3 database.cidr '.read init.sql'
sqlite3 database.cidr '.read city.sql'
```## Test
```
python3 tests/test_cidr_search.py
```## Run
```
python3 cidr_search.py
```
- type IP address![image](https://user-images.githubusercontent.com/22115777/200112280-da0396b6-d4ce-409e-af2d-d014faf19ab2.png)
## Run on docker
### Requirement
- account of maxmind.com(https://www.maxmind.com/en/account/login)
- docker is running.```
cd ${HOME}
git clone https://github.com/hidekuno/cidr-lite
cd cidr-lite/cli/docker
docker build -t ${yourid}/cidr-lite --file=Dockerfile --build-arg token=${YOUR_TOKEN_ID} .
docker run -it --name cidr-lite ${yourid}/cidr-lite python3 /root/cidr_search.py
```## fastapi
### Requirement
- fastapi installed.
- uvicorn installed.
- databases installed.
- aiosqlite installed.
- SQLAlchemy installed.
- pydantic installed.### Run
```
cd ${HOME}/cidr_lite
pip3 install "fastapi[all]"
pip3 install databases
pip3 install aiosqlitepython3 -m uvicorn cidr_api:app --reload
```### search country,ASN,city
```
curl -v http://localhost:8000/search?ipv4=23.218.95.131
```## fastapi with MySQL
### Requirement
- docker installed
- fastapi(0.111.0) installed.
- SQLAlchemy installed.
- mysql-connector-python installed.### Build
```
docker-compose up -d
```### Test
```
pytest -v tests/test_cidr_api2.py
```