A small server which checks if user's IP is in a trusted Fenix network.
Project description
fenix-checker
A small server which checks if user's IP is in a trusted Fenix network. Used by ipv6widget
and standard-konektivity.cz.
Dependencies
- Python >= 3.6
- pyaml >= 17
- psycopg2 >= 2.7.4
Installation
$ virtualenv -p `which python3.6` .venv
$ source .venv/bin/activate
$ pip install fenix_checker
$ cp config.example.yml config.yml
$ $EDITOR config.yml # set DB credentials
Running in production
uWSGI:
$ uwsgi --master --single-interpreter --threads 2 --http :5000 -H .venv -w fenix_checker.server
GUnicorn:
$ gunicorn -w 2 -k gevent --timeout 160 -n netmetr-proxy fenix_checker:server:app
Usage
GET /
-> 200
{"result": 1}
Result is:
0
for non-Fenix networks>= 1
for Fenix networks
IP is validated with Python's ipaddress
module before passing it to DB:
GET / # with client IP somehow spoofed to eg. "127.0.0.1'); DROP TABLE networks;"
-> 400
{"error": "Invalid IP"}
Development
Starting server with auto reload on file changes:
$ FLASK_APP=fenix_checker/server.py FLASK_DEBUG=1 flask run
Linting Python code:
$ flake8 --config=.flake8rc *py
License
GPLv3
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fenix-checker-0.1.3.tar.gz
(16.5 kB
view details)
File details
Details for the file fenix-checker-0.1.3.tar.gz
.
File metadata
- Download URL: fenix-checker-0.1.3.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22f8b8f91ee015e1acf4321994e6c4be8cd6a58517fcff60d4d9dd9145f86b97 |
|
MD5 | b77ec0d9aacfceb00f0d22d801085ef3 |
|
BLAKE2b-256 | e1a500e7a819a78099c4d672f317c2daf77cddbe9731f534a19fae1ba42c61d0 |