{ "info": { "author": "Richard Kuesters", "author_email": "rkuesters@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Utilities" ], "description": "=================\n``sanic-ipware``\n=================\n\n\n\nThis is a fork of `django-ipware `_ to work with `Sanic `_.\n\nOverview\n--------\n\n**Best attempt** to get client's IP address while keeping it **DRY**.\n\nNotice\n------\n\nThere is no real good \"out-of-the-box\" solution against fake IP addresses, aka \"IP Address Spoofing\". You are encouraged to read the `Advanced users `_ section of this page and use ``trusted_proxies_ips`` and/or ``proxy_count`` features to match your needs, especially *if* you are planning to include ``sanic-ipware`` in any authentication, security or \"anti-fraud\" related architecture.\n\nHow to install\n--------------\n\nThe best way to install ``sanic-ipware`` would be using ``pip``:\n\n.. code-block::\n\n pip install sanic-ipware\n\nHow to use\n----------\n\nThere's basically one method that should be usable from ``sanic_ipware``, called ``get_client_ip``. The result is a ``Tuple[Optional[str], bool]`` of ``(ipaddr, routable)``.\n\n.. code-block:: python\n\n from sanic_ipware import get_client_ip\n\n @app.get(\"/some/handler\")\n async def somehandler(request):\n ip, routable = get_client_ip(request)\n if ip is not None:\n if routable:\n # we have a (probably) real, public ip address for user\n else:\n # we have ip address, but it might not be public routable\n else:\n # we don't have a ip address for the user\n\nAdvanced users\n--------------\n\n.. code-block:: python\n\n # you can provide your own meta precedence order by using the\n # request_header_order in the function call:\n ip, routable = get_client_ip(\n request,\n request_header_order=['Forwarded-For', 'X-Forwarded-For'])\n\n # if you're going to do this a lot, wrap the function somewhere with\n # functools.partial\n from functools import partial\n my_get_client_ip = partial(\n get_client_ip,\n request_header_order=['Forwarded-For', 'X-Forwarded-For'])\n ip, routable = my_get_client_ip(request)\n\n # if you plan to use sanic_ipware in any authentication, security or\n # \"anti-fraud\" related architecture, you should configure it to only\n # \"trust\" one or more \"known\" proxy server(s)), in the function call:\n ip, routable = get_client_ip(request, proxy_trusted_ips=['198.84.193.158'])\n\n # you can perform the same functools.partial trick with these trusted IPs\n\nLicense\n-------\n\nMIT, the same as ``django-ipware`` `license `_ .\n\n\nChangelog\n=========\n\nv0.1.0 on 2018-09-28\n--------------------\n\n* First release on PyPI. Not stable.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/vltr/sanic-ipware", "keywords": "sanic,request,ip", "license": "MIT license", "maintainer": "", "maintainer_email": "", "name": "sanic-ipware", "package_url": "https://pypi.org/project/sanic-ipware/", "platform": "", "project_url": "https://pypi.org/project/sanic-ipware/", "project_urls": { "Homepage": "https://github.com/vltr/sanic-ipware" }, "release_url": "https://pypi.org/project/sanic-ipware/0.1.0/", "requires_dist": null, "requires_python": "", "summary": "Retrieve your client's IP address (or try its best to)", "version": "0.1.0" }, "last_serial": 4320468, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "fc10027ce115d43441d5691cbb7140fd", "sha256": "43a1894e2ce3b68175319274afc29d817dbf9100d165705d0be0b71670eed227" }, "downloads": -1, "filename": "sanic-ipware-0.1.0.tar.gz", "has_sig": false, "md5_digest": "fc10027ce115d43441d5691cbb7140fd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14044, "upload_time": "2018-09-28T15:20:35", "url": "https://files.pythonhosted.org/packages/35/5c/ad4f2207b5ae8f7156b8fbb089591d1a2730a67dcd7eb7e7e865210c7374/sanic-ipware-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fc10027ce115d43441d5691cbb7140fd", "sha256": "43a1894e2ce3b68175319274afc29d817dbf9100d165705d0be0b71670eed227" }, "downloads": -1, "filename": "sanic-ipware-0.1.0.tar.gz", "has_sig": false, "md5_digest": "fc10027ce115d43441d5691cbb7140fd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14044, "upload_time": "2018-09-28T15:20:35", "url": "https://files.pythonhosted.org/packages/35/5c/ad4f2207b5ae8f7156b8fbb089591d1a2730a67dcd7eb7e7e865210c7374/sanic-ipware-0.1.0.tar.gz" } ] }