{ "info": { "author": "Dusan Madar", "author_email": "madar.dusan@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Natural Language :: English", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3" ], "description": "[![Build Status](https://travis-ci.org/DusanMadar/TorIpChanger.svg?branch=master)](https://travis-ci.org/DusanMadar/TorIpChanger)\n[![Coverage Status](https://coveralls.io/repos/github/DusanMadar/TorIpChanger/badge.svg?branch=master)](https://coveralls.io/github/DusanMadar/TorIpChanger?branch=master)\n[![PyPI version](https://badge.fury.io/py/toripchanger.svg)](https://badge.fury.io/py/toripchanger)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n\n\n# TorIpChanger\nA simple workaround for [Tor IP changing behavior](https://stem.torproject.org/faq.html#how-do-i-request-a-new-identity-from-tor):\n\n> An important thing to note is that a new circuit does not necessarily mean a new IP address. Paths are randomly selected based on heuristics like speed and stability. There are only so many large exits in the Tor network, so it's not uncommon to reuse an exit you have had previously.\n\n## Installation\n```bash\npip install toripchanger\n```\n\nTorIpChanger assumes you have installed and setup Tor and Privoxy, for example following steps mentioned in these tutorials:\n\n* [A step-by-step guide how to use Python with Tor and Privoxy](https://gist.github.com/DusanMadar/8d11026b7ce0bce6a67f7dd87b999f6b)\n* [Crawling anonymously with Tor in Python](http://sacharya.com/crawling-anonymously-with-tor-in-python/)\n * [Alternative link (Gist)](https://gist.github.com/KhepryQuixote/46cf4f3b999d7f658853) for \"Crawling anonymously with Tor in Python\"\n\nOr, when using Docker, simply use https://github.com/dperson/torproxy.\n\n\n## Usage\n### Basic examples\nWith TorIpChanger you can define how often a Tor IP can be reused:\n```python\nfrom toripchanger import TorIpChanger\n\n# Tor IP reuse is prohibited.\ntor_ip_changer_0 = TorIpChanger(reuse_threshold=0)\ncurrent_ip = tor_ip_changer_0.get_new_ip()\n\n# Current Tor IP address can be reused after one other IP was used (default setting).\ntor_ip_changer_1 = TorIpChanger(local_http_proxy='127.0.0.1:8888')\ncurrent_ip = tor_ip_changer_1 .get_new_ip()\n\n# Current Tor IP address can be reused after 5 other Tor IPs were used.\ntor_ip_changer_5 = TorIpChanger(reuse_threshold=5)\ncurrent_ip = tor_ip_changer_5.get_new_ip()\n```\n\n### Remote Tor control\nSometimes, typically while using Docker, you may want to control a Tor instance\nwhich doesn't run on localhost. To do this, you have two options.\n\n#### Use `0.0.0.0` as control address\nSet `ControlPort` to `0.0.0.0:9051` in your `torrc` file and set `tor_address` when initializing TorIpChanger\n```python\nfrom toripchanger import TorIpChanger\n\ntor_ip_changer = TorIpChanger(tor_address=\"172.17.0.2\")\ncurrent_ip = tor_ip_changer.get_new_ip()\n```\n\nThough, Tor is not very happy about it (and rightly so) and will warn you\n>You have a ControlPort set to accept connections from a non-local address. This means that programs not running on your computer can reconfigure your Tor. That's pretty bad, since the controller protocol isn't encrypted! Maybe you should just listen on 127.0.0.1 and use a tool like stunnel or ssh to encrypt remote connections to your control port.\n\nAlso, you have to set either `CookieAuthentication` or `HashedControlPassword` otherwise `ControlPort` will be closed\n>You have a ControlPort set to accept unauthenticated connections from a non-local address. This means that programs not running on your computer can reconfigure your Tor, without even having to guess a password. That's so bad that I'm closing your ControlPort for you. If you need to control your Tor remotely, try enabling authentication and using a tool like stunnel or ssh to encrypt remote access.\n\nPlease note `ControlListenAddress` config is **OBSOLETE** and Tor (tested with 0.3.3.7) will ignore it and log the following message\n> ```\n> [warn] Skipping obsolete configuration option 'ControlListenAddress'\n> ```\n\nWhile the config itself is obsolte, its [documentation](https://people.torproject.org/~sysrqb/webwml/docs/tor-manual.html.en#ControlListenAddress) (**not the official documentation!**) concerning the risks related to exposing `ControlPort` on `0.0.0.0` is still valid\n> We strongly recommend that you leave this alone unless you know what you\u2019re doing, since giving attackers access to your control listener is really dangerous.\n\n#### Use `toripchanger_server`\n`toripchanger_server` script starts a simple web server which allows you to change Tor' IP remotely using an HTTP get request to `/changeip/`. The response body is always\n\n```\n{\n \"newIp\": \"1.2.3.4\",\n \"error\": \"\"\n}\n```\nwith an appropriate status (`error` is an empty string when all is good).\n\nChanging Tor' IP may not be instantaneous (especially when combined with a high `reuse_threshold`) and hence your client should use a reasonable timeout (e.g. at least 60s).\n\n`toripchanger_server` takes all arguments required to initialize `TorIpChanger` plus `--server-host` and `--server-port`, for more details see the usage below.\n\n```\nusage: toripchanger_server [-h] [--server-host SERVER_HOST]\n [--server-port SERVER_PORT]\n [--reuse-threshold REUSE_THRESHOLD]\n [--local-http-proxy LOCAL_HTTP_PROXY]\n [--tor-password TOR_PASSWORD]\n [--tor-address TOR_ADDRESS] [--tor-port TOR_PORT]\n [--new-ip-max-attempts NEW_IP_MAX_ATTEMPTS]\n\noptional arguments:\n -h, --help show this help message and exit\n --server-host SERVER_HOST\n TorIpChanger server host (default: 0.0.0.0)\n --server-port SERVER_PORT\n TorIpChanger server port (default: 8080)\n --reuse-threshold REUSE_THRESHOLD\n Number of IPs to use before reusing the current one\n (default: 1)\n --local-http-proxy LOCAL_HTTP_PROXY\n Local proxy IP and port (default: 127.0.0.1:8118)\n --tor-password TOR_PASSWORD\n Tor controller password (default: \"\")\n --tor-address TOR_ADDRESS\n IP address of the Tor controller (default: 127.0.0.1)\n --tor-port TOR_PORT Port number of the Tor controller (default: 9051)\n --new-ip-max-attempts NEW_IP_MAX_ATTEMPTS\n Get new IP attemps limit (default: 10)\n```\n\nTo be able to change Tor' IP remotely with `toripchanger_server`:\n\n 1. `pip install toripchanger[server]` in your container\n 2. start `toripchanger_server` (on the same host where Tor runs)\n 3. expose the port `toripchanger_server` runs on to Docker host (or other containers)\n 4. test changing IP works, e.g. `curl http://localhost:8080/changeip/`\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/DusanMadar/TorIpChanger", "keywords": "change tor ip", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "toripchanger", "package_url": "https://pypi.org/project/toripchanger/", "platform": "linux", "project_url": "https://pypi.org/project/toripchanger/", "project_urls": { "Homepage": "https://github.com/DusanMadar/TorIpChanger" }, "release_url": "https://pypi.org/project/toripchanger/1.1.1/", "requires_dist": [ "requests", "stem", "flask; extra == 'server'" ], "requires_python": ">=3.6", "summary": "Python powered way to get a unique Tor IP", "version": "1.1.1" }, "last_serial": 5897037, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "b492ef1ba9affea2b8dc8c5f9d9b0723", "sha256": "c97accc9a9d8ac84849eb8c752c3f363b6cc2f0f4aad27938e9d7bcc880fe422" }, "downloads": -1, "filename": "toripchanger-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b492ef1ba9affea2b8dc8c5f9d9b0723", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 6791, "upload_time": "2018-08-05T12:48:38", "url": "https://files.pythonhosted.org/packages/29/38/05c818c271545eeb4f0185cd223d404cb31e2a3d810717a83033945a98d7/toripchanger-1.0.0-py3-none-any.whl" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "98e7e1af76f3a9d71503bf0550c25e91", "sha256": "04d01fc332021aceeb2b9a22c9d921a4536e952bdadf12fbdbb097f643e71695" }, "downloads": -1, "filename": "toripchanger-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "98e7e1af76f3a9d71503bf0550c25e91", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 9804, "upload_time": "2019-02-24T22:31:09", "url": "https://files.pythonhosted.org/packages/b9/01/eae8272aabe59722ac5deb0b870214794c6847019d0e47c08b5430596d57/toripchanger-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "373131200fc28ecca751269f751b10c9", "sha256": "f82e166f613353d2f56118e71099ec62d7a976bc5911ebfc007567f0edfb7f46" }, "downloads": -1, "filename": "toripchanger-1.1.0.tar.gz", "has_sig": false, "md5_digest": "373131200fc28ecca751269f751b10c9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 8177, "upload_time": "2019-02-24T22:31:11", "url": "https://files.pythonhosted.org/packages/8f/64/19ebe2eb47c21982f7cee3d07f3848e45a68a8861c3b3afb6f97e300768e/toripchanger-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "cc716dca56a92d5cd59401a9002dd31c", "sha256": "b010f9c025679a84eaa860a9ec41f4e2890a4544a0888d52121dba0a50e59732" }, "downloads": -1, "filename": "toripchanger-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "cc716dca56a92d5cd59401a9002dd31c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 10378, "upload_time": "2019-09-27T16:42:57", "url": "https://files.pythonhosted.org/packages/de/0c/89c85485de20b0d8cb8d073a5abb221a098cb026ef0b09170168a45ef271/toripchanger-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "67a9ead4091adcbda3b25d12890457a4", "sha256": "23fa8dd2958809ecad7abe80e34c5cd770a17d459886ba8fc88091dc574d3cf4" }, "downloads": -1, "filename": "toripchanger-1.1.1.tar.gz", "has_sig": false, "md5_digest": "67a9ead4091adcbda3b25d12890457a4", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 8887, "upload_time": "2019-09-27T16:43:00", "url": "https://files.pythonhosted.org/packages/07/1a/23357f9034124ebd987b8de36084ac30d64a89b1141ac48c0d777e7d3e9e/toripchanger-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cc716dca56a92d5cd59401a9002dd31c", "sha256": "b010f9c025679a84eaa860a9ec41f4e2890a4544a0888d52121dba0a50e59732" }, "downloads": -1, "filename": "toripchanger-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "cc716dca56a92d5cd59401a9002dd31c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 10378, "upload_time": "2019-09-27T16:42:57", "url": "https://files.pythonhosted.org/packages/de/0c/89c85485de20b0d8cb8d073a5abb221a098cb026ef0b09170168a45ef271/toripchanger-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "67a9ead4091adcbda3b25d12890457a4", "sha256": "23fa8dd2958809ecad7abe80e34c5cd770a17d459886ba8fc88091dc574d3cf4" }, "downloads": -1, "filename": "toripchanger-1.1.1.tar.gz", "has_sig": false, "md5_digest": "67a9ead4091adcbda3b25d12890457a4", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 8887, "upload_time": "2019-09-27T16:43:00", "url": "https://files.pythonhosted.org/packages/07/1a/23357f9034124ebd987b8de36084ac30d64a89b1141ac48c0d777e7d3e9e/toripchanger-1.1.1.tar.gz" } ] }