I want to create a browser bundle that supports the following things:

there is a standalone tor process that i launch it using the controller connection from the stem library and i manually connect tor-browser to this standalone process by specifying the related environment variables and i have a add-on written using web-extension API that use native messaging for communicating between the native application and the web extension.

is this method the proper way to have our own customized tor browser bundle?

my main point is to generate circuit's that are static during the lifetime of the browser and give our clients functionality to select their desired country for entry and middle and exit relays. for these purpose's i am launching the tor process using a specific config(for static circuits) and using stem to prevent tor from attaching streams to circuits by itself and i do it manually(for using our custom generated circuits). the first problem i have is that attaching streams to circuits manually is not a stable and reliable solution according to my experiment. the suggested code for this according to the stem documentation:

circuit_id = controller.new_circuit(path, await_build = True)

def attach_stream(stream): if stream.status == 'NEW': controller.attach_stream(stream.id, circuit_id)

controller.add_event_listener(attach_stream, stem.control.EventType.STREAM)

the second problem is that i need my circuit's to be static and for that i am using these command-line options to launch my tor process:

config = { 'SocksPort': str(SOCKS_PORT)+' '+'IsolateSOCKSAuth'+' '+'KeepAliveIsolateSOCKSAuth', 'ControlPort': str(CONTROL_PORT), 'CircuitsAvailableTimeout':'86400', 'NewCircuitPeriod':'86400', 'MaxCircuitDirtiness':'86400', 'DirAuthorityFallbackRate':'0', 'KeepalivePeriod':'60' },

from my point of knowledge this config should make my circuits to be available for 24 hours, but the actual period that my circuit is available is far far less than idle(something about 10 minutes or less).

i really appreciate if you guys help me to fix these issues, especially the second one. thank u

  • 1
    Why do you want to keep circuits open for 24 hours? Tor Browser already keeps circuits open for as long as they're actively used. i.e. at least once per 10 minutes.
    – cacahuatl
    Apr 18, 2018 at 21:39
  • the main reason is that i don't want my ip to get changed and let the clients choose their own path through the tor network manually.
    – pouya
    Apr 19, 2018 at 12:17
  • 1
    Sounds like a terrible idea. Good luck.
    – cacahuatl
    Apr 19, 2018 at 21:50
  • I know my work flow is not right, but we have educational purposes for doing this.
    – pouya
    May 10, 2018 at 7:39

1 Answer 1


There is a project named: torflow and one of the plugins named OP-addon is a good solution for tor path generation and circuit handling with lots of measurements and analyzing goodies. from the documentation of OP-addon:

By making use of the Tor control protocol, it replaces Tor's
default path selection and circuit management by highly configurable and customizable mechanisms. Users can freely configure the method of path selection that is to be used, while the created circuits can either be evaluated regarding their performance, or specifically be used to handle user streams, e.g. for browsing the web. Additionally, the add-on can be used to run simulations that can be useful to determine a degree of anonymity a certain method of path selection can provide, when using the current network status

check it out!! OP-addon

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .