tormanager 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +84 -60
- data/lib/tormanager/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ae9cd4db1d87b48b12d3c7da7f27ec8f73a03fd9
         | 
| 4 | 
            +
              data.tar.gz: bc8871a5eca69b0ab3d66b283ada7094138901c7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: bbfdd160272d2bc25b8b29e67afaffbf9ef642c233e86ad541a80d8205df2bf188d97a8a501aaa9770222cb08cab10fa1c5f18369082449cf03c8a24962296d1
         | 
| 7 | 
            +
              data.tar.gz: 6dd60fc33690fd71c64c62a8181311b81389af36f4c3d58c57689028c75b5c1abaa638b862e42e02d44aae772f951e9fda1b21acc8cea6c6f440db01899cf47b
         | 
    
        data/README.md
    CHANGED
    
    | @@ -35,11 +35,13 @@ This section shows how to start, stop and manage Tor processes. | |
| 35 35 |  | 
| 36 36 | 
             
            Start a Tor process with default settings:
         | 
| 37 37 |  | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 38 | 
            +
            ```ruby
         | 
| 39 | 
            +
            tor_process = TorManager::TorProcess.new
         | 
| 40 | 
            +
            tor_process.start
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            #you can get the control password for the Tor process if you want: 
         | 
| 43 | 
            +
            tor_process.settings[:control_password]
         | 
| 44 | 
            +
            ```
         | 
| 43 45 |  | 
| 44 46 | 
             
            By default, the Tor process will use using port `9050` and control port `50500` and
         | 
| 45 47 | 
             
            will be spawned using [Eye](https://github.com/kostya/eye) ensuring that the process remains in a healthy state. 
         | 
| @@ -55,25 +57,29 @@ More information can be found in the `TorManager::TorProcess` parameters table b | |
| 55 57 |  | 
| 56 58 | 
             
            You can also spawn a Tor process with control over parameters:
         | 
| 57 59 |  | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 60 | 
            +
            ```ruby
         | 
| 61 | 
            +
            tor_process = 
         | 
| 62 | 
            +
              TorManager::TorProcess.new tor_port: 9051, 
         | 
| 63 | 
            +
                                         control_port: 50501, 
         | 
| 64 | 
            +
                                         pid_dir: '/my/pid/dir',
         | 
| 65 | 
            +
                                         log_dir: '/my/log/dir',
         | 
| 66 | 
            +
                                         tor_data_dir: '/my/tor/datadir',
         | 
| 67 | 
            +
                                         tor_new_circuit_period: 120,
         | 
| 68 | 
            +
                                         max_tor_memory_usage_mb: 400,
         | 
| 69 | 
            +
                                         max_tor_cpu_percentage: 15,
         | 
| 70 | 
            +
                                         control_password: 'mycontrolpass',
         | 
| 71 | 
            +
                                         eye_logging: true,
         | 
| 72 | 
            +
                                         tor_logging: true
         | 
| 73 | 
            +
            tor_process.start
         | 
| 74 | 
            +
            ```
         | 
| 71 75 |  | 
| 72 76 | 
             
            See the table below for more info.	
         | 
| 73 77 |  | 
| 74 78 | 
             
            When done with the Tor process, `stop` it: 
         | 
| 75 79 |  | 
| 76 | 
            -
             | 
| 80 | 
            +
            ```ruby
         | 
| 81 | 
            +
            tor_process.stop 
         | 
| 82 | 
            +
            ```
         | 
| 77 83 |  | 
| 78 84 | 
             
            The following table describes the `TorManager::TorProcess` parameters:
         | 
| 79 85 |  | 
| @@ -98,15 +104,21 @@ The following table describes the `TorManager::TorProcess` parameters: | |
| 98 104 |  | 
| 99 105 | 
             
            To stop any Tor instances that have been previously started by Tor Manager but were not stopped (say in the event of a parent process crash) **_††_**: 
         | 
| 100 106 |  | 
| 101 | 
            -
             | 
| 107 | 
            +
            ```ruby
         | 
| 108 | 
            +
            TorManager::TorProcess.stop_obsolete_processes 
         | 
| 109 | 
            +
            ```
         | 
| 102 110 |  | 
| 103 111 | 
             
            Query whether Tor Manager has any Tor processes running on a particular port **_††_**: 
         | 
| 104 112 |  | 
| 105 | 
            -
             | 
| 113 | 
            +
            ```ruby
         | 
| 114 | 
            +
            TorManager::TorProcess.tor_running_on? port: 9050 
         | 
| 115 | 
            +
            ```
         | 
| 106 116 |  | 
| 107 117 | 
             
            Query whether Tor Manager has any Tor processes running on a particular port associated to a particular parent ruby pid **_††_**:
         | 
| 108 118 |  | 
| 109 | 
            -
             | 
| 119 | 
            +
            ```ruby
         | 
| 120 | 
            +
            TorManager::TorProcess.tor_running_on? port: 9050, parent_pid: 12345
         | 
| 121 | 
            +
            ```
         | 
| 110 122 |  | 
| 111 123 | 
             
            **_††_** Note that this command applies only to Tor processes that were started by Tor Manager. 
         | 
| 112 124 | 
             
            Tor processes that have been started external to Tor Manager will not be impacted.  
         | 
| @@ -121,20 +133,24 @@ Once you have a `TorProcess` started, you can: | |
| 121 133 |  | 
| 122 134 | 
             
            The remaining examples assume that you have instantiated a `TorProcess` ie: 
         | 
| 123 135 |  | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 136 | 
            +
            ```ruby
         | 
| 137 | 
            +
            tor_process = TorManager::TorProcess.new
         | 
| 138 | 
            +
            tor_process.start
         | 
| 139 | 
            +
            ```
         | 
| 126 140 |  | 
| 127 141 | 
             
            #### Proxy Through Tor
         | 
| 128 | 
            -
             | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 132 | 
            -
             | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 136 | 
            -
             | 
| 137 | 
            -
             | 
| 142 | 
            +
             | 
| 143 | 
            +
            ```ruby
         | 
| 144 | 
            +
            tor_proxy = TorManager::Proxy.new tor_process: tor_process 
         | 
| 145 | 
            +
            tor_proxy.proxy do 
         | 
| 146 | 
            +
              tor_ip = RestClient::Request.execute(
         | 
| 147 | 
            +
                         method: :get,
         | 
| 148 | 
            +
                         url: 'http://bot.whatismyipaddress.com').to_str
         | 
| 149 | 
            +
            end
         | 
| 150 | 
            +
            my_ip = RestClient::Request.execute(
         | 
| 151 | 
            +
                         method: :get,
         | 
| 152 | 
            +
                         url: 'http://bot.whatismyipaddress.com').to_str
         | 
| 153 | 
            +
            ```
         | 
| 138 154 |  | 
| 139 155 | 
             
            Note that in the above code the `RestClient::Request` returning `tor_ip` is routed through the Tor endpoint because it is yielded 
         | 
| 140 156 | 
             
            through the `TorManager::Proxy#proxy` block. The following request returning `my_ip` will not be routed through the Tor endpoint 
         | 
| @@ -143,47 +159,55 @@ hence returning your current IP address. | |
| 143 159 | 
             
            You could route [Capybara](https://github.com/teamcapybara/capybara) requests through the proxy (just make sure you use the `:poltergeist` driver and set the proxy 
         | 
| 144 160 | 
             
            to use the Tor socks proxy): 
         | 
| 145 161 |  | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 148 | 
            -
             | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 151 | 
            -
             | 
| 152 | 
            -
             | 
| 153 | 
            -
             | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 162 | 
            +
            ```ruby
         | 
| 163 | 
            +
            Capybara.default_driver = :poltergeist
         | 
| 164 | 
            +
            Capybara.register_driver :poltergeist do |app|
         | 
| 165 | 
            +
              Capybara::Poltergeist::Driver.new(app, {
         | 
| 166 | 
            +
                :phantomjs => Phantomjs.path,
         | 
| 167 | 
            +
                :phantomjs_options => ["--proxy-type=socks5", "--proxy=127.0.0.1:9050"]
         | 
| 168 | 
            +
              })
         | 
| 169 | 
            +
            end
         | 
| 170 | 
            +
            tor_proxy = TorManager::Proxy.new tor_process: tor_process 
         | 
| 171 | 
            +
            tor_proxy.proxy do 
         | 
| 172 | 
            +
              tor_ip = Capybara.visit('http://bot.whatismyipaddress.com').text
         | 
| 173 | 
            +
            end
         | 
| 174 | 
            +
            ```
         | 
| 157 175 |  | 
| 158 176 | 
             
            #### Query IP Address 
         | 
| 159 177 |  | 
| 160 178 | 
             
            Query the Tor endpoint for the current IP address: 
         | 
| 161 179 |  | 
| 162 | 
            -
             | 
| 163 | 
            -
             | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 166 | 
            -
             | 
| 180 | 
            +
            ```ruby
         | 
| 181 | 
            +
            tor_proxy = TorManager::Proxy.new tor_process: tor_process 	
         | 
| 182 | 
            +
            tor_ip_control = 
         | 
| 183 | 
            +
              TorManager::IpAddressControl.new tor_process: tor_process, 
         | 
| 184 | 
            +
                                               tor_proxy: tor_proxy 
         | 
| 185 | 
            +
            tor_ip_control.get_ip									   
         | 
| 186 | 
            +
            ```
         | 
| 167 187 |  | 
| 168 188 | 
             
            When the `TorManager::IpAddressControl#get_ip` method is called, the IP address is stored in instance variable: 
         | 
| 169 189 |  | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 190 | 
            +
            ```ruby
         | 
| 191 | 
            +
            tor_ip_control.ip 
         | 
| 192 | 
            +
            ```
         | 
| 172 193 |  | 
| 173 194 | 
             
            #### Change IP Address
         | 
| 174 195 |  | 
| 175 196 | 
             
            Get a new IP address: 
         | 
| 176 197 |  | 
| 177 | 
            -
             | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 198 | 
            +
            ```ruby
         | 
| 199 | 
            +
            tor_proxy = TorManager::Proxy.new tor_process: tor_process 	
         | 
| 200 | 
            +
            tor_ip_control = 
         | 
| 201 | 
            +
              TorManager::IpAddressControl.new tor_process: tor_process, 
         | 
| 202 | 
            +
                                               tor_proxy: tor_proxy 
         | 
| 203 | 
            +
            tor_ip_control.get_new_ip									   
         | 
| 204 | 
            +
            ```
         | 
| 184 205 |  | 
| 185 | 
            -
             | 
| 206 | 
            +
            When the `TorManager::IpAddressControl#get_new_ip` method is called, the IP address is stored in instance variable: 
         | 
| 186 207 |  | 
| 208 | 
            +
            ```ruby
         | 
| 209 | 
            +
            tor_ip_control.ip
         | 
| 210 | 
            +
            ```
         | 
| 187 211 |  | 
| 188 212 | 
             
            ## Contributing
         | 
| 189 213 |  | 
    
        data/lib/tormanager/version.rb
    CHANGED