Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate new circuit every n minutes? #80

Open
tamis-laan opened this issue May 27, 2022 · 3 comments
Open

Generate new circuit every n minutes? #80

tamis-laan opened this issue May 27, 2022 · 3 comments

Comments

@tamis-laan
Copy link

It would be great if there was a setting where torproxy would generate a new circuit every n minutes. This to cycle the ip address of the exit node.

@des1redState
Copy link

des1redState commented Dec 25, 2022

You'd need a script to send the NEWNYM signal to the Tor process every n minutes. Python example:

#!/usr/bin/env python

from time import sleep
from stem import Signal
from stem.control import Controller

n = "10m"  # or whatever's desired.
tor_control_port = 9051  # Ensure this is exposed (e.g: -p 9051:9051)
tor_control_pass = "password"  # Default, might want to change it. See docs.

while True:
    with Controller.from_port(port=tor_control_port) as c:
        c.authenticate(password=tor_control_pass)
        c.signal(Signal.NEWNYM)

    sleep(n)

@byteofwood
Copy link

You could also do this as a shell command. Bash one-liner:
while :; do printf 'AUTHENTICATE "YourPassword"\r\nSIGNAL NEWNYM\r\n' | ncat 0.0.0.0 9051; sleep 600; done

@DailyPS
Copy link

DailyPS commented Jul 2, 2024

@des1redState @byteofwood
I wonder how above script works.

Using image of this repository also works? For example:

I use dperson/torproxy image with depends_on on other container like below.

services:
  simple_continer:
    image: example:latest
    depends_on:
      -torproxy
  torproxy:
    image: dperson/torproxy
    ports:
      - "8118:8118"

If I want to generate new circuit every n minutes using a python script or a shell script, how should I work with it?

Or should I clone this repository and revise torproxy.sh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants