From 482285416be1af7a6ca32b0f2a2df03f46c93ee4 Mon Sep 17 00:00:00 2001 From: scuty2000 Date: Wed, 8 Sep 2021 15:16:24 +0200 Subject: [PATCH 1/4] Fix identity change (session renewal) and HTTPs proxies not using tor --- torrequest.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/torrequest.py b/torrequest.py index eab1a2d..a4f68b2 100644 --- a/torrequest.py +++ b/torrequest.py @@ -29,6 +29,10 @@ def __init__(self, 'https': 'socks5://localhost:%d' % self.proxy_port, }) + self.session.proxies.update({ + 'https': 'socks5h://localhost:%d' % self.proxy_port, + }) + def _tor_process_exists(self): try: ctrl = Controller.from_port(port=self.ctrl_port) @@ -60,7 +64,15 @@ def close(self): def reset_identity_async(self): self.ctrl.signal(stem.Signal.NEWNYM) + def _reset_session(self): + self.session = requests.Session() + self.session.proxies.update({ + 'http': 'socks5://localhost:%d' % self.proxy_port, + 'https': 'socks5://localhost:%d' % self.proxy_port, + }) + def reset_identity(self): + self._reset_session() self.reset_identity_async() time.sleep(self.ctrl.get_newnym_wait()) From 42431fbcc9c92b8ed048d7b1047cd79d48e9e743 Mon Sep 17 00:00:00 2001 From: Luca Scutigliani Date: Wed, 8 Sep 2021 15:22:23 +0200 Subject: [PATCH 2/4] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..924437a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Luca Scutigliani + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From f9cf05dfa6fbc1b1869aa9260c0ba4b4fb100317 Mon Sep 17 00:00:00 2001 From: Luca Scutigliani Date: Wed, 8 Sep 2021 15:24:59 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b0c2d8e..0385a2d 100644 --- a/README.md +++ b/README.md @@ -68,3 +68,6 @@ with TorRequest(proxy_port=9050, ctrl_port=9051, password=None) as tr: ## License MIT +## Credits +Erdiaker - [Original torrequest repo](https://github.com/erdiaker/torrequest) + From c1fa6de221495692edcfd0f2e4678739132ab0df Mon Sep 17 00:00:00 2001 From: Luca Scutigliani Date: Wed, 8 Sep 2021 15:30:23 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0385a2d..a082ee3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ TorRequest A simple Python interface for HTTP(s) requests over [Tor](https://www.torproject.org). ```python -from torrequest import TorRequest +from torrequest-reborn import TorRequest with TorRequest() as tr: response = tr.get('http://ipecho.net/plain') @@ -19,6 +19,11 @@ You need Tor. It's available via Homebrew. ```sh brew install tor ``` +Or if you're on linux: +```sh +sudo apt update +sudo apt install tor +``` After installation, you may want to configure Tor by creating a `.torrc` file in your `$HOME` directory. More information is available on [Tor documentation](https://www.torproject.org/docs/tor-manual.html.en). @@ -26,12 +31,12 @@ documentation](https://www.torproject.org/docs/tor-manual.html.en). ## Installation After installing dependencies, you can install `torrequest` via PyPI: ```sh -pip install torrequest +pip install torrequest-reborn ``` ## Examples ```python -from torrequest import TorRequest +from torrequest-reborn import TorRequest # Choose a proxy port, a control port, and a password. # Defaults are 9050, 9051, and None respectively.