Refactor acquire_tor_conn -> acquire_tor_identity

Also updated travis CI to set up tor
This commit is contained in:
Ben Busby 2020-10-25 18:33:45 -04:00
parent bd1d236923
commit d7442a18a5
2 changed files with 6 additions and 4 deletions

View File

@ -1,7 +1,9 @@
language: python
python: 3.6
before_install:
- sudo apt-get -y install libgnutls28-dev
- sudo apt-get -y install libgnutls28-dev tor
- sudo cat rc/torrc > /etc/tor/torrc
- sudo systemctl tor start
install:
- pip install -r requirements.txt
script:

View File

@ -19,7 +19,7 @@ DESKTOP_UA = '{}/5.0 (X11; {} x86_64; rv:75.0) Gecko/20100101 {}/75.0'
VALID_PARAMS = ['tbs', 'tbm', 'start', 'near', 'source', 'nfpr']
def acquire_tor_conn():
def acquire_tor_identity():
with Controller.from_port(port=9051) as c:
c.authenticate()
c.signal(Signal.NEWNYM)
@ -151,10 +151,10 @@ class Request:
attempt += 1
if attempt > 5:
return requests.get(self.root_path + 'tor-reject?q=' + query)
acquire_tor_conn()
acquire_tor_identity()
return self.send(base_url, query, attempt)
return response
acquire_tor_conn()
acquire_tor_identity()