Class: Selenium::WebDriver::Tor::Driver
- Inherits:
-
DriverDelegate
- Object
- Firefox::Driver
- DriverDelegate
- Selenium::WebDriver::Tor::Driver
- Extended by:
- LibxulPatchable
- Defined in:
- lib/tor/driver.rb
Overview
tor driver
Constant Summary collapse
- TORRC =
'torrc'- PREF_BROWSER_SECURITY_LEVEL =
'browser.security_level.security_slider'- PREF_TORRC_PATH =
'extensions.torlauncher.torrc_path'- PREF_SOCKS_PORT =
'network.proxy.socks_port'- PREF_CONTROL_PORT =
'extensions.torlauncher.control_port'- DOMAIN_ISOLATOR_URI =
ES6 module URI
'moz-src:///toolkit/components/tor-launcher/TorDomainIsolator'- DOMAIN_ISOLATOR_OLD_URI =
ES6 module URI
'resource://gre/modules/TorDomainIsolator'- NEW_CIRCUIT =
js function
'newCircuitForDomain'- TB_SEC_LEVELS =
{ 'standard' => 4, 'safer' => 2, 'safest' => 1 }.freeze
- LOCALHOST_PORT_REGEXP =
/127\.0\.0\.1:(\d+)/
Constants included from LibxulPatchable
LibxulPatchable::INVALID, LibxulPatchable::ISSUES_URL, LibxulPatchable::LIBXUL_CHECKSUMS_FILE, LibxulPatchable::NO_PATCH_MSG, LibxulPatchable::PATCH_REPO_PATCHES_URL, LibxulPatchable::PATCH_REPO_URL, LibxulPatchable::REPO_LIBXUL_CHECKSUMS, LibxulPatchable::THIS_REPO
Instance Attribute Summary collapse
-
#tor_process ⇒ Object
readonly
Returns the value of attribute tor_process.
Instance Method Summary collapse
- #browser ⇒ Object
-
#initialize(options: nil) ⇒ Driver
constructor
A new instance of Driver.
-
#new_circuit_for_site ⇒ Object
(also: #new_circuit_for_page)
pref = int end.
- #quit ⇒ Object
- #security_level ⇒ Object
Methods included from LibxulPatchable
libxul_patched?, patch_libxul, unpatch_libxul
Methods included from Firefox::FirefoxPrefs
Methods included from Firefox::FirefoxJsHelpers
#es6_const_call, #es6_function_call, #execute_script_in_chrome_context
Constructor Details
#initialize(options: nil) ⇒ Driver
Returns a new instance of Driver.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/tor/driver.rb', line 40 def initialize(options: nil, **) @data_dir = Dir.mktmpdir @options = || Options.new # fix for issue #11, 'tis a puzzlement @options.add_argument '-remote-allow-system-access' # FF 138+ create_tor_process_and_start_tor(@options.tor_opts) # sets @tor_process add_ports_to_option_prefs @instance = while_in_tbb_browser_directory { DriverDelegate.new(options: @options, **) } # fixes #22 install_extensions @instance super(@instance) end |
Instance Attribute Details
#tor_process ⇒ Object (readonly)
Returns the value of attribute tor_process.
38 39 40 |
# File 'lib/tor/driver.rb', line 38 def tor_process @tor_process end |
Instance Method Details
#browser ⇒ Object
52 53 54 |
# File 'lib/tor/driver.rb', line 52 def browser :tor # overides :firefox end |
#new_circuit_for_site ⇒ Object Also known as: new_circuit_for_page
pref = int end
74 75 76 77 78 |
# File 'lib/tor/driver.rb', line 74 def new_circuit_for_site uri = DOMAIN_ISOLATOR_URI uri = DOMAIN_ISOLATOR_OLD_URI if Gem::Version.new(Tor::TBB_VERSION) < '16.0a6' # DEPRECATE when 16 stable execute_script_in_chrome_context es6_function_call(es6_uri: uri, func: NEW_CIRCUIT, args: domain) end |
#quit ⇒ Object
56 57 58 59 60 61 |
# File 'lib/tor/driver.rb', line 56 def quit super # 16.0a6 on; popup dialog blocks quit unless tor process (& control port) closed *after* browser ensure @tor_process&.stop_tor FileUtils.rm_rf @data_dir end |
#security_level ⇒ Object
63 64 65 |
# File 'lib/tor/driver.rb', line 63 def security_level pref[PREF_BROWSER_SECURITY_LEVEL] end |