https://github.com/mtarnovan/tor_proxy
Simple Tor Proxy
https://github.com/mtarnovan/tor_proxy
Last synced: about 2 months ago
JSON representation
Simple Tor Proxy
- Host: GitHub
- URL: https://github.com/mtarnovan/tor_proxy
- Owner: mtarnovan
- License: mit
- Created: 2016-04-18T11:10:48.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-18T11:10:52.000Z (about 10 years ago)
- Last Synced: 2025-03-14T02:28:29.038Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# TorProxy
## Requirements
This gem needs the `tor` executable in $PATH. (`brew install tor` etc.)
## Usage
```ruby
require 'tor_proxy'
uri = URI('https://api.ipify.org/?format=text')
proxy = TorProxy.instance(logger: Logger.new(STDOUT))
proxy.with_proxy(uri) { |proxy| proxy.request(Net::HTTP::Get.new(uri)).read_body.chomp }
# => some IP (of the current Tor exit node)
proxy.request_new_ip
proxy.with_proxy(uri) { |proxy| proxy.request(Net::HTTP::Get.new(uri)).read_body.chomp }
# => some other IP (of the current Tor exit node)
proxy.stop!
```
## Notes
When the singleton instance is initialized, Tor will be started with a random SOCKS port, a random control port and a temp dir is used as its data dir (removed automatically when you call `stop!`).
The `Kernel#at_exit` hook is used to call `stop!` (unless it was previously invoked manually).
SSL connections are *not* verified (`OpenSSL::SSL::VERIFY_NONE`)
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).