selenium_tor 0.2.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -0
- data/CHANGELOG.md +17 -0
- data/README.md +39 -15
- data/Rakefile +1 -1
- data/fonts/000_README.txt +7 -0
- data/lib/string_extensions.rb +12 -0
- data/lib/tor/driver.rb +31 -23
- data/lib/tor/options.rb +17 -2
- data/lib/tor/system_tor.rb +17 -0
- data/lib/tor/tor_prefs.rb +2 -1
- data/lib/tor/tor_process.rb +78 -0
- data/lib/tor/torrc.rb +74 -0
- data/lib/tor/version.rb +1 -1
- metadata +8 -5
- data/CODE_OF_CONDUCT.md +0 -84
- data/lib/tor/driver_not_yet_connected_to_tor_network.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99d3e4260b0873513c67db620d3057d61078b4c1cbae7b5c8c7b3e4cfdbbfbec
|
4
|
+
data.tar.gz: bb02cb9d07024a4798723185f4103246dac9b4c008e3f20abec5f710426a26a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 654db110ca016a71d04b6def25d4befb86efc27cd2c0cce1ed7874834921d309262bc537b6b23bf8b77603b4d29960c88a10d83c8508ce6398b1d44a13577df1
|
7
|
+
data.tar.gz: 7d7369f8055ca42c229079d8732ab49d8d1467af49d35c547528dd792f1208101abcd123a6f05873b9fee4b704863a364708fc9148850f798635b9f3f6b3b8da
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
## master (unreleased)
|
2
2
|
|
3
|
+
## [1.1.0] - 2024-07-28
|
4
|
+
|
5
|
+
### Bug fixes
|
6
|
+
|
7
|
+
* [#9](https://gitlab.com/matzfan/selenium-tor/-/issues/9)
|
8
|
+
|
9
|
+
### New features
|
10
|
+
|
11
|
+
* deprecate SystemTor options IFO tor_opts
|
12
|
+
|
13
|
+
## [1.0.0] - 2024-07-15
|
14
|
+
|
15
|
+
### New features
|
16
|
+
|
17
|
+
* add ability to use system tor
|
18
|
+
* add ability to run multiple driver instances simultaneously (fixes [#6](https://gitlab.com/matzfan/selenium-tor/-/issues/6))
|
19
|
+
|
3
20
|
## [0.2.0] - 2024-07-10
|
4
21
|
|
5
22
|
### Breaking changes
|
data/README.md
CHANGED
@@ -30,8 +30,10 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
30
30
|
$ gem install selenium_tor
|
31
31
|
|
32
32
|
## Usage
|
33
|
-
|
34
|
-
|
33
|
+
```ruby
|
34
|
+
require 'selenium_tor'
|
35
|
+
```
|
36
|
+
Tor Browser is based on Firefox, so for usage please read the Selenium [docs](https://www.selenium.dev/documentation/webdriver/browsers/firefox) for Firefox browser.
|
35
37
|
|
36
38
|
A driver is instantiated like this:
|
37
39
|
```ruby
|
@@ -42,11 +44,39 @@ options = Selenium::WebDriver::Tor::Options.new
|
|
42
44
|
@driver.title # => Congratulations. This browser is configured to use Tor.
|
43
45
|
@driver.quit
|
44
46
|
```
|
45
|
-
|
47
|
+
If the network is inaccessible for any reason a `TorNetworkError` will result.
|
48
|
+
|
49
|
+
### Multiple driver instances
|
50
|
+
|
51
|
+
Running multiple `tor` processes requires that each uses different ports for SocksPort and ControlPort. These and other valid tor options can be passed using the `:tor_opts` key. Recognized options are snake_case equivalents of the camel case options reconized by tor. For a list see `man tor`. An example using the [Parallel gem](https://rubygems.org/gems/parallel):
|
52
|
+
```ruby
|
53
|
+
require 'parallel'
|
54
|
+
|
55
|
+
socks_port = 9150
|
56
|
+
control_port = 9151
|
57
|
+
|
58
|
+
def driver(socks_p, control_p)
|
59
|
+
options = Selenium::WebDriver::Tor::Options.new tor_opts: { socks_port: socks_p, control_port: control_p }
|
60
|
+
Selenium::WebDriver.for :tor, options: options # new tor process started with tor_opts
|
61
|
+
end
|
46
62
|
|
47
|
-
|
63
|
+
driver1 = driver(socks_port, control_port)
|
64
|
+
driver2 = driver(socks_port += 2, control_port += 2)
|
48
65
|
|
49
|
-
|
66
|
+
title = 'Congratulations. This browser is configured to use Tor.'
|
67
|
+
|
68
|
+
Parallel.all?([driver1, driver2], in_threads: 2) do |driver|
|
69
|
+
driver.get 'https://check.torproject.org'
|
70
|
+
driver.title == title
|
71
|
+
end
|
72
|
+
# => true
|
73
|
+
|
74
|
+
driver1&.quit
|
75
|
+
driver2&.quit
|
76
|
+
```
|
77
|
+
The `Selenium::WebDriver::Tor` namespace is used for `Driver`, `Options`, `Profile` and all tor-specific classes. Otherwise Selenium's `Selenium::WebDriver::Firefox` namespace is used.
|
78
|
+
|
79
|
+
Remote functionality is not tested, but may be if a suitable Tor Browser Docker container becomes available.
|
50
80
|
|
51
81
|
A number of constants are set during driver initialization based upon values found in the Tor Browser Bundle (TBB) root directory - see below. These include:
|
52
82
|
```ruby
|
@@ -76,17 +106,17 @@ Tor Selenium is tested on **Linux only** right now.
|
|
76
106
|
|
77
107
|
## Testing
|
78
108
|
|
79
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
109
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
80
110
|
|
81
|
-
Tests are run in the display set by the `DISPLAY` env var, :0 by default. To run headless tests, set it to another value:
|
111
|
+
Tests are run in the display set by the `DISPLAY` env var, usually :0 by default. To run headless tests, set it to another value:
|
82
112
|
|
83
113
|
$ DISPLAY=:99 bundle exec rake
|
84
114
|
|
85
115
|
If you find tests are failing with `TorNetworkError` and a timeout message, check you have no other Tor Browser processes running. The processes to look for are either "firefox.real" or "firefox-esr". The latter may be legitimate if you are also running Firefox browser. You may also want to check the Tor network is actually up, it isn't always..
|
86
116
|
|
87
|
-
If you wish run the `vglrun` WebGL fingerprint test
|
117
|
+
If you wish run the `vglrun` WebGL fingerprint test install VirtualGL (see above, assumes you have the relevent drivers installed) and run the following command:
|
88
118
|
|
89
|
-
$ DISPLAY=:99 vglrun bundle exec ruby test/features/fingerprinting/
|
119
|
+
$ DISPLAY=:99 vglrun bundle exec ruby test/features/fingerprinting/vglrun_test_fingerprintjs.rb
|
90
120
|
|
91
121
|
## Development
|
92
122
|
|
@@ -98,12 +128,6 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
98
128
|
|
99
129
|
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/matzfan/selenium-tor. For a pull request please checkout a suitably named feature branch before making and submitting changes.
|
100
130
|
|
101
|
-
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://gitlab.com/matzfan/selenium-tor/CODE_OF_CONDUCT.md).
|
102
|
-
|
103
131
|
## License
|
104
132
|
|
105
133
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
106
|
-
|
107
|
-
## Code of Conduct
|
108
|
-
|
109
|
-
Everyone interacting in the Selenium Tor project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/matzfan/selenium-tor/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'rake/testtask'
|
|
6
6
|
Rake::TestTask.new(:test) do |t|
|
7
7
|
t.libs << 'test'
|
8
8
|
t.libs << 'lib'
|
9
|
-
t.test_files = FileList['test/**/test_*.rb']
|
9
|
+
t.test_files = FileList['test/**/test_*.rb']
|
10
10
|
# t.warning = false
|
11
11
|
end
|
12
12
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
DO NOT MODIFY THE CONTENTS OF THIS DIRECTORY
|
2
|
+
|
3
|
+
Any adjustment to bundled fonts will result in an altered fingerprint. Font
|
4
|
+
fingerprinting is more than just detecting what fonts you have, it also includes
|
5
|
+
font fallbacks and characters (unicode code points) and any change in those can
|
6
|
+
be measured.
|
7
|
+
|
data/lib/tor/driver.rb
CHANGED
@@ -1,47 +1,55 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'open-uri'
|
4
|
-
require_relative '
|
4
|
+
require_relative '../service'
|
5
|
+
require_relative '../options'
|
6
|
+
require_relative 'profile'
|
7
|
+
require_relative 'tor_process'
|
5
8
|
|
6
9
|
module Selenium
|
7
10
|
module WebDriver
|
8
11
|
module Tor
|
12
|
+
# delegate class so extensions can be added & connection to tor made
|
13
|
+
class DriverNotYetConnectedToTorNetwork < Firefox::Driver; end
|
14
|
+
|
9
15
|
# tor driver
|
10
16
|
class Driver < DelegateClass(DriverNotYetConnectedToTorNetwork)
|
11
17
|
class TorNetworkError < StandardError; end
|
12
18
|
|
13
|
-
|
14
|
-
|
19
|
+
def initialize(options: nil, **)
|
20
|
+
@data_dir = Dir.mktmpdir
|
21
|
+
add_torrc_path_to_options options
|
22
|
+
@instance = DriverNotYetConnectedToTorNetwork.new(options: options, **)
|
23
|
+
super(@instance)
|
24
|
+
install_extensions(@instance)
|
25
|
+
create_tor_process_and_start_tor options&.tor_opts
|
26
|
+
end
|
15
27
|
|
16
|
-
|
28
|
+
def browser
|
29
|
+
:tor # overides :firefox
|
30
|
+
end
|
17
31
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
install_extensions
|
32
|
+
def quit
|
33
|
+
@tor_process&.stop_tor
|
34
|
+
FileUtils.rm_rf @data_dir
|
35
|
+
super
|
23
36
|
end
|
24
37
|
|
25
38
|
private
|
26
39
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
ensure
|
32
|
-
FileUtils.cd cwd
|
40
|
+
def add_torrc_path_to_options(options)
|
41
|
+
return unless options
|
42
|
+
|
43
|
+
options.prefs['extensions.torlauncher.torrc_path'] = File.join(@data_dir, 'torrc')
|
33
44
|
end
|
34
45
|
|
35
|
-
def
|
36
|
-
|
37
|
-
Wait.new(timeout: 10).until { !@instance.find_element(:id, CONNECT_BUTTON_ID).displayed? }
|
38
|
-
rescue Selenium::WebDriver::Error::TimeoutError => e
|
39
|
-
@instance.quit # abort initialization
|
40
|
-
raise TorNetworkError, "Cannot connect to Tor network: #{e.message}"
|
46
|
+
def install_extensions(instance)
|
47
|
+
Pathname.new(TBB_EXTENSIONS_DIR).children.each { |xpi_path| instance.install_addon xpi_path }
|
41
48
|
end
|
42
49
|
|
43
|
-
def
|
44
|
-
|
50
|
+
def create_tor_process_and_start_tor(opts)
|
51
|
+
@tor_process = TorProcess.new(@data_dir, opts || {})
|
52
|
+
@tor_process.start_tor
|
45
53
|
end
|
46
54
|
end
|
47
55
|
end
|
data/lib/tor/options.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'tor_prefs'
|
4
|
+
require_relative 'system_tor'
|
4
5
|
require 'selenium-webdriver'
|
5
6
|
|
6
7
|
module Selenium
|
@@ -8,17 +9,26 @@ module Selenium
|
|
8
9
|
module Tor
|
9
10
|
# tor options
|
10
11
|
class Options < Firefox::Options
|
12
|
+
CAPABILITIES = CAPABILITIES.merge(tor_opts: 'tor_opts')
|
13
|
+
CAPABILITIES[:system_tor] = 'system_tor' # DEPRECATED 2.0
|
11
14
|
DEFAULT_TBB_DIR = File.join Dir.home, 'tor-browser'
|
15
|
+
|
12
16
|
Tor::TBB_DIR = ENV.fetch('TOR_BROWSER_ROOT_DIR', nil) || DEFAULT_TBB_DIR
|
13
17
|
Tor::TBB_BROWSER_DIR = File.join Tor::TBB_DIR, 'Browser'
|
14
18
|
Tor::TBB_BINARY_PATH = File.join Tor::TBB_BROWSER_DIR, 'firefox'
|
19
|
+
Tor::TBB_TOR_BINARY_PATH = File.join Tor::TBB_BROWSER_DIR, *%w[TorBrowser Tor tor]
|
15
20
|
Tor::TBB_PROFILE_DIR = File.join Tor::TBB_BROWSER_DIR, *%w[TorBrowser Data Browser profile.default]
|
16
21
|
Tor::TBB_EXTENSIONS_DIR = File.join Tor::TBB_PROFILE_DIR, 'extensions'
|
17
22
|
Tor::TBB_VERSION = JSON.parse(File.read(File.join(Tor::TBB_BROWSER_DIR, 'tbb_version.json')))['version']
|
18
23
|
|
24
|
+
attr_reader :tor_opts
|
25
|
+
|
19
26
|
def initialize(log_level: nil, **opts)
|
27
|
+
opts[:tor_opts] = opts.delete(:system_tor).opts if opts[:system_tor] # DEPRECATED 2.0
|
28
|
+
@tor_opts = opts[:tor_opts] ? opts.delete(:tor_opts) : {} # must be deleted before call to super
|
20
29
|
super(log_level: log_level, **tor_options(opts.delete(:prefs)).merge(opts))
|
21
30
|
do_start_tor_browser_script_stuff # stuff the start-tor-browser script in TBB does
|
31
|
+
copy_fonts # so we don't have to change dir before executing TB binary #2 and #9
|
22
32
|
end
|
23
33
|
|
24
34
|
private
|
@@ -30,11 +40,16 @@ module Selenium
|
|
30
40
|
def do_start_tor_browser_script_stuff
|
31
41
|
ENV['SESSION_MANAGER'] = nil
|
32
42
|
ENV['XAUTHORITY'] = File.join(Dir.home, '.Xauthority') unless ENV.fetch('XAUTHORITY', nil)
|
33
|
-
ENV['FONTCONFIG_PATH'] = File.join
|
43
|
+
ENV['FONTCONFIG_PATH'] = File.join TBB_BROWSER_DIR, 'fontconfig'
|
34
44
|
ENV['FONTCONFIG_FILE'] = 'fonts.conf'
|
35
45
|
FileUtils.rm_rf File.join(Tor::TBB_BROWSER_DIR, *%w[TorBrowser Data fontconfig])
|
36
46
|
ENV['GSETTINGS_BACKEND'] = 'memory'
|
37
|
-
|
47
|
+
end
|
48
|
+
|
49
|
+
def copy_fonts
|
50
|
+
return unless Dir[File.join('fonts', '*')].size == 1 # README checked into git
|
51
|
+
|
52
|
+
FileUtils.cp(Dir[File.join(Tor::TBB_BROWSER_DIR, 'fonts', '*')], File.expand_path('fonts'))
|
38
53
|
end
|
39
54
|
end
|
40
55
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Selenium
|
4
|
+
module WebDriver
|
5
|
+
module Tor
|
6
|
+
# DEPRECATED
|
7
|
+
class SystemTor
|
8
|
+
attr_reader :opts
|
9
|
+
|
10
|
+
def initialize(opts = {})
|
11
|
+
warn '[DEPRECATION] `SystemTor` options are deprecated in `selenium_tor` 2.0. Use `tor_opts` instead.'
|
12
|
+
@opts = opts
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/tor/tor_prefs.rb
CHANGED
@@ -17,7 +17,8 @@ module Selenium
|
|
17
17
|
|
18
18
|
OTHER_PREFS = {
|
19
19
|
'intl.language_notification.shown' => true, # affects font fingerprint (viewport size)
|
20
|
-
'remote.active-protocols' => 3 #
|
20
|
+
'remote.active-protocols' => 3, # CDP & BiDi future support
|
21
|
+
'extensions.torlauncher.start_tor' => false
|
21
22
|
}.freeze
|
22
23
|
|
23
24
|
TOR_PREFS = FIRST_CONNECTION_PREFS.merge OTHER_PREFS
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'timeout'
|
4
|
+
require_relative 'torrc'
|
5
|
+
require_relative '../string_extensions'
|
6
|
+
|
7
|
+
module Selenium
|
8
|
+
module WebDriver
|
9
|
+
module Tor
|
10
|
+
# Respresentation of a tor process
|
11
|
+
class TorProcess
|
12
|
+
include StringExtensions
|
13
|
+
|
14
|
+
class TorProcessError < StandardError; end
|
15
|
+
|
16
|
+
BOOTSTRAP_SUCCESS_REGEX = /Bootstrapped 100% \(done\): Done$/
|
17
|
+
BOOTSTRAP_FAIL_REGEX = /^[A-Z][a-z]{2} \d{1,2} \d{2}:\d{2}:\d{2}\.\d{3} \[err\] .*/
|
18
|
+
# BOOTSTRAP_TIMEOUT_REGEX = /^[A-Z][a-z]{2} \d{1,2} \d{2}:\d{2}:\d{2}\.\d{3} \[err\] .*/
|
19
|
+
|
20
|
+
attr_reader :pid, :config
|
21
|
+
|
22
|
+
def initialize(data_dir, opts = {})
|
23
|
+
valid_data_dir?(data_dir)
|
24
|
+
raise ArgumentError, 'TorProcess.new takes an options hash' unless opts.is_a? Hash
|
25
|
+
|
26
|
+
@data_dir = data_dir # each tor process needs a separate data directory
|
27
|
+
@opts = map_opts_to_torrc_keys opts
|
28
|
+
@torrc = Torrc.new(@data_dir)
|
29
|
+
@config ||= setup_config # Hash to store torrc config
|
30
|
+
end
|
31
|
+
|
32
|
+
def start_tor
|
33
|
+
r, io = IO.pipe
|
34
|
+
pid = Process.spawn "#{TBB_TOR_BINARY_PATH} -f #{@torrc.path}", out: io, err: :out
|
35
|
+
io.close
|
36
|
+
errors = parse_tor_bootstrap_errors r
|
37
|
+
errors.empty? ? @pid = pid : raise(TorProcessError, "Tor failed to start with errors:\n\n#{errors}")
|
38
|
+
ensure
|
39
|
+
r.close
|
40
|
+
end
|
41
|
+
|
42
|
+
def stop_tor
|
43
|
+
Process.kill 'KILL', pid if pid
|
44
|
+
FileUtils.rm_rf @data_dir if @data_dir
|
45
|
+
@pid = nil
|
46
|
+
end
|
47
|
+
|
48
|
+
# private
|
49
|
+
|
50
|
+
def valid_data_dir?(dir)
|
51
|
+
msg = 'data_dir must exist and be a dir'
|
52
|
+
raise ArgumentError, msg unless Pathname.new(dir.to_s).directory? && Pathname.new(dir.to_s).empty?
|
53
|
+
end
|
54
|
+
|
55
|
+
def map_opts_to_torrc_keys(opts)
|
56
|
+
raise TorProcessError, 'Options keys must be snake case' unless opts.keys.map!(&:to_s).all?(&:snake_case?)
|
57
|
+
|
58
|
+
opts.transform_keys { |k| k.to_s.split('_').map(&:capitalize).join }
|
59
|
+
end
|
60
|
+
|
61
|
+
def setup_config
|
62
|
+
@torrc.write_to_config @opts
|
63
|
+
@torrc.config
|
64
|
+
end
|
65
|
+
|
66
|
+
def parse_tor_bootstrap_errors(io)
|
67
|
+
lines = []
|
68
|
+
io.each_line do |line|
|
69
|
+
lines << line
|
70
|
+
break lines.join if line.match BOOTSTRAP_FAIL_REGEX
|
71
|
+
break '' if line.match BOOTSTRAP_SUCCESS_REGEX
|
72
|
+
# break false if line.match BOOTSTRAP_TIMEOUT_REGEX
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/tor/torrc.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'options' # for Tor::TBB_TOR_BINARY_PATH
|
4
|
+
|
5
|
+
module Selenium
|
6
|
+
module WebDriver
|
7
|
+
module Tor
|
8
|
+
# Respresentation of a torrc file
|
9
|
+
class Torrc
|
10
|
+
class TorrcError < StandardError; end
|
11
|
+
|
12
|
+
DEFAULT_PORTS = { 'SocksPort' => 9150, 'ControlPort' => 9151 }.freeze
|
13
|
+
INVALID_OPTION_REGEX = %r{\[warn\] Failed to parse/validate config: (.*).$}
|
14
|
+
|
15
|
+
attr_reader :path
|
16
|
+
|
17
|
+
def initialize(data_dir)
|
18
|
+
@data_dir = data_dir
|
19
|
+
@torrc_file = File.new File.join(@data_dir, 'torrc'), 'w'
|
20
|
+
@path = @torrc_file.path
|
21
|
+
write_default_config
|
22
|
+
end
|
23
|
+
|
24
|
+
def config
|
25
|
+
parse_config
|
26
|
+
end
|
27
|
+
|
28
|
+
def write_to_config(hash)
|
29
|
+
raise ArgumentError, 'Torrc#write_to_config takes a hash as argument' unless hash.is_a? Hash
|
30
|
+
|
31
|
+
validate_torrc_options hash
|
32
|
+
@torrc_file.write hash_to_config_string(config.merge(hash))
|
33
|
+
@torrc_file.rewind
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def write_default_config
|
39
|
+
write_to_config DEFAULT_PORTS.merge('DataDirectory' => @data_dir)
|
40
|
+
end
|
41
|
+
|
42
|
+
def validate_torrc_options(hash)
|
43
|
+
tmp = Tempfile.new
|
44
|
+
tmp.write hash_to_config_string(hash)
|
45
|
+
tmp.rewind
|
46
|
+
invalid_opts = parse_invalid_opts `#{TBB_TOR_BINARY_PATH} -f #{tmp.path} --verify-config`
|
47
|
+
raise TorrcError, "Invalid torrc opts: #{invalid_opts}" unless invalid_opts.empty?
|
48
|
+
ensure
|
49
|
+
tmp.unlink
|
50
|
+
end
|
51
|
+
|
52
|
+
def parse_invalid_opts(tor_output_string)
|
53
|
+
tor_output_string.split("\n").filter_map { |line| line[INVALID_OPTION_REGEX, 1] }
|
54
|
+
end
|
55
|
+
|
56
|
+
def hash_to_config_string(hash)
|
57
|
+
hash.map { |k, v| "#{k} #{v}" }.join("\n")
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse_config
|
61
|
+
File.readlines(@torrc_file).inject({}) do |memo, line|
|
62
|
+
arr = line.chomp.split
|
63
|
+
arr << '' if arr.size == 1 # deal with keys with no value
|
64
|
+
memo.merge coerce_hash_int_values_to_int(Hash[*arr])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def coerce_hash_int_values_to_int(hash)
|
69
|
+
hash.transform_values { |v| v.to_i.to_s == v ? v.to_i : v }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/tor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium_tor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MatzFan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|
@@ -35,20 +35,23 @@ files:
|
|
35
35
|
- ".ruby-version"
|
36
36
|
- ".yamllint"
|
37
37
|
- CHANGELOG.md
|
38
|
-
- CODE_OF_CONDUCT.md
|
39
38
|
- Guardfile
|
40
39
|
- LICENSE.txt
|
41
40
|
- README.md
|
42
41
|
- Rakefile
|
42
|
+
- fonts/000_README.txt
|
43
43
|
- lib/driver.rb
|
44
44
|
- lib/options.rb
|
45
45
|
- lib/selenium_tor.rb
|
46
46
|
- lib/service.rb
|
47
|
+
- lib/string_extensions.rb
|
47
48
|
- lib/tor/driver.rb
|
48
|
-
- lib/tor/driver_not_yet_connected_to_tor_network.rb
|
49
49
|
- lib/tor/options.rb
|
50
50
|
- lib/tor/profile.rb
|
51
|
+
- lib/tor/system_tor.rb
|
51
52
|
- lib/tor/tor_prefs.rb
|
53
|
+
- lib/tor/tor_process.rb
|
54
|
+
- lib/tor/torrc.rb
|
52
55
|
- lib/tor/version.rb
|
53
56
|
- selenium_tor.gemspec
|
54
57
|
- sig/tor.rbs
|
@@ -75,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
78
|
- !ruby/object:Gem::Version
|
76
79
|
version: '0'
|
77
80
|
requirements: []
|
78
|
-
rubygems_version: 3.5.
|
81
|
+
rubygems_version: 3.5.16
|
79
82
|
signing_key:
|
80
83
|
specification_version: 4
|
81
84
|
summary: Selenium extension for Tor Browser
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
-
|
7
|
-
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
-
|
9
|
-
## Our Standards
|
10
|
-
|
11
|
-
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
-
|
13
|
-
* Demonstrating empathy and kindness toward other people
|
14
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
-
* Giving and gracefully accepting constructive feedback
|
16
|
-
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
-
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
-
|
19
|
-
Examples of unacceptable behavior include:
|
20
|
-
|
21
|
-
* The use of sexualized language or imagery, and sexual attention or
|
22
|
-
advances of any kind
|
23
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
-
* Public or private harassment
|
25
|
-
* Publishing others' private information, such as a physical or email
|
26
|
-
address, without their explicit permission
|
27
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
-
professional setting
|
29
|
-
|
30
|
-
## Enforcement Responsibilities
|
31
|
-
|
32
|
-
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
-
|
34
|
-
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
-
|
36
|
-
## Scope
|
37
|
-
|
38
|
-
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
-
|
40
|
-
## Enforcement
|
41
|
-
|
42
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at matzfan@mailinator.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
-
|
44
|
-
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
-
|
46
|
-
## Enforcement Guidelines
|
47
|
-
|
48
|
-
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
-
|
50
|
-
### 1. Correction
|
51
|
-
|
52
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
-
|
54
|
-
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
-
|
56
|
-
### 2. Warning
|
57
|
-
|
58
|
-
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
-
|
60
|
-
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
-
|
62
|
-
### 3. Temporary Ban
|
63
|
-
|
64
|
-
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
-
|
66
|
-
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
-
|
68
|
-
### 4. Permanent Ban
|
69
|
-
|
70
|
-
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
-
|
72
|
-
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
-
|
74
|
-
## Attribution
|
75
|
-
|
76
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
-
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
-
|
79
|
-
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
-
|
81
|
-
[homepage]: https://www.contributor-covenant.org
|
82
|
-
|
83
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
-
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../service'
|
4
|
-
require_relative '../options'
|
5
|
-
require_relative '../tor/profile'
|
6
|
-
|
7
|
-
module Selenium
|
8
|
-
module WebDriver
|
9
|
-
module Tor
|
10
|
-
# subclass - doesn't wait to be connected to tor network
|
11
|
-
class DriverNotYetConnectedToTorNetwork < Firefox::Driver
|
12
|
-
def browser
|
13
|
-
:tor # overides :firefox
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|