{ "info": { "author": "cle-b", "author_email": "cle@tictac.pm", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# hookdns\n\nHookDNS is a library which allow you to modify a name resolution in your Python script without any modification in your hosts file or by using a fake DNS.\n\n## Usage\n\nCustom DNS resolutions are describe by a dictionnary where the keys are hostnames\nand the values the expected corresponding addresses. \n\n {\n \"hostname1\": \"addr1\",\n \"hostname2\": \"addr2\"\n }\n\nhostname and addr could be a domain name or a string representation of an IPv4/IPV6.\n\n### Example using the patch as a decorator\n\n```python\nimport requests\n\nfrom hookdns import hosts\n\n@hosts({\"example.org\": \"localhost\"})\ndef myfunc():\n ...\n r = requests.get(\"http://example.org\") # the request is sent to your local server\n ...\n```\n\n### Example using the patch as a context manager\n\n```python\nimport requests\n\nfrom hookdns import hosts\n\nwith hosts({\"example.org\": \"localhost\"}):\n ...\n r = requests.get(\"http://example.org\") # the request is sent to your local server\n ...\n```\n### Options\n\nBy default the following function calls are intercepted: *socket.gethostbyname, socket.gethostbyname_ex and socket.getaddrinfo*.\n\nYou can limit the interception to only a restricted list of function.\n\n```python\nimport socket\n\nfrom hookdns import hosts\n\nwith hosts({\"example.org\": \"localhost\"}, only=[\"gethostbyname\"]):\n ...\n addr = socket.gethostbyname(\"example.org\") # returns \"127.0.0.1\"\n print(\"gethostname returns: %s\" % addr)\n\n _, _, addr = socket.gethostbyname_ex(\"example.org\") # returns the real ip address for example.org\n print(\"gethostname_ex returns: %s\" % addr[0])\n ... \n```\n```\ngethostname returns: 127.0.0.1\ngethostname_ex returns: 93.184.216.34\n```\n\n\n## Limitation\n\nIt works only with Python 3.4 and greater for the moment.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/cle-b/hookdns", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "hookdns", "package_url": "https://pypi.org/project/hookdns/", "platform": "", "project_url": "https://pypi.org/project/hookdns/", "project_urls": { "Homepage": "https://github.com/cle-b/hookdns" }, "release_url": "https://pypi.org/project/hookdns/1.0.0/", "requires_dist": [ "mock" ], "requires_python": ">=3.4", "summary": "An easy way to customize the dns resolution", "version": "1.0.0" }, "last_serial": 4688872, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "ed9d54b913a1d59a80bcc215ec0487d5", "sha256": "0a0852a4b5f3f8fe8a2152a1d4d2eb69bdda8fc12d6cba923d71d70f74381150" }, "downloads": -1, "filename": "hookdns-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ed9d54b913a1d59a80bcc215ec0487d5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4", "size": 9309, "upload_time": "2019-01-12T17:26:13", "url": "https://files.pythonhosted.org/packages/49/af/c50c5880d5080d700ae49508e8fda4e86af210198a9f4540c3357003bfe0/hookdns-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b91a219d9e0f1ad322a6ed8cf70eb46b", "sha256": "455a223d3dbd24a957145d8c2591155d473550fab5082c70ef080f2aed209889" }, "downloads": -1, "filename": "hookdns-1.0.0.tar.gz", "has_sig": false, "md5_digest": "b91a219d9e0f1ad322a6ed8cf70eb46b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 3159, "upload_time": "2019-01-12T17:26:15", "url": "https://files.pythonhosted.org/packages/07/d3/2ea4cdc77fa363fa85be404b15161c81f9de20105230c596565d1ce4f909/hookdns-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ed9d54b913a1d59a80bcc215ec0487d5", "sha256": "0a0852a4b5f3f8fe8a2152a1d4d2eb69bdda8fc12d6cba923d71d70f74381150" }, "downloads": -1, "filename": "hookdns-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ed9d54b913a1d59a80bcc215ec0487d5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4", "size": 9309, "upload_time": "2019-01-12T17:26:13", "url": "https://files.pythonhosted.org/packages/49/af/c50c5880d5080d700ae49508e8fda4e86af210198a9f4540c3357003bfe0/hookdns-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b91a219d9e0f1ad322a6ed8cf70eb46b", "sha256": "455a223d3dbd24a957145d8c2591155d473550fab5082c70ef080f2aed209889" }, "downloads": -1, "filename": "hookdns-1.0.0.tar.gz", "has_sig": false, "md5_digest": "b91a219d9e0f1ad322a6ed8cf70eb46b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 3159, "upload_time": "2019-01-12T17:26:15", "url": "https://files.pythonhosted.org/packages/07/d3/2ea4cdc77fa363fa85be404b15161c81f9de20105230c596565d1ce4f909/hookdns-1.0.0.tar.gz" } ] }