SOCKSify Ruby
2016-05-18 15:01
411 查看
http://socksify.rubyforge.org/
Alias
The new
Additionally,
Note that
Send patches via E-Mail.
IPv6 address support
UDP as soon as Tor supports it
Perhaps using standard exceptions for better compatibility when acting as a drop-in?
What is it?
SOCKSify Ruby redirects any TCP connection initiated by a Ruby script through a SOCKS5 proxy. It serves as a small drop-in alternative to tsocks, except that it handles Ruby programs only and doesn't leak DNS queries.How does it work?
Modifications to classTCPSocket:
Alias
initializeas
initialize_tcp
The new
initializecalls the old method to establish a TCP connection to the SOCKS proxy, sends the proxying destination and checks for errors
Additionally,
Socksify::resolvecan be used to resolve hostnames to IPv4 addresses via SOCKS. There is also
socksify/httpenabling Net::HTTP to work via SOCKS.
Installation
$ gem install socksify
Usage
Redirect all TCP connections of a Ruby program
Run a Ruby script with redirected TCP through a local Tor anonymizer:$ socksify_ruby localhost 9050 script.rb
Explicit SOCKS usage in a Ruby program
Set up SOCKS connections for a local Tor anonymizer, TCPSockets can be used as usual:require 'socksify' TCPSocket::socks_server = "127.0.0.1" TCPSocket::socks_port = 9050 rubyforge_www = TCPSocket.new("rubyforge.org", 80) # => #<TCPSocket:0x...>
Use Net::HTTP explicitly via SOCKS
Require the additional librarysocksify/httpand use the
Net::HTTP.SOCKSProxymethod. It is similar to
Net:HTTP.Proxyfrom the Ruby standard library:
require 'socksify/http' uri = URI.parse('http://rubyforge.org/') Net::HTTP.SOCKSProxy('127.0.0.1', 9050).start(uri.host, uri.port) do |http| http.get(uri.path) end # => #<Net::HTTPOK 200 OK readbody=true>
Note that
Net::HTTP.SOCKSProxynever relies on
TCPSocket::socks_server/
socks_port. You should either set
SOCKSProxyarguments explicitly or use
Net::HTTPdirectly.
Resolve addresses via SOCKS
Socksify::resolve("spaceboyz.net") # => "87.106.131.203"
Debugging
Colorful diagnostic messages can be enabled via:Socksify::debug = true
Development
The repository can be checked out with:$ git-clone git://github.com/astro/socksify-ruby.git
Send patches via E-Mail.
Further ideas
Resolvreplacement code, so that programs which resolve by themselves don't leak DNS queries
IPv6 address support
UDP as soon as Tor supports it
Perhaps using standard exceptions for better compatibility when acting as a drop-in?
Author
Stephan MakaLicense
SOCKSify Ruby is distributed under the terms of the GNU General Public License version 3 (see fileCOPYING) or the Ruby License (see file
LICENSE) at your option.
相关文章推荐
- ruby access control(public,protected,private)
- Ruby中的class_eval方法以及__FILE__和__LINE__参数
- ruby rails
- ruby关于flip-flop理解上一个注意点
- 《七天七语言》之Ruby练习1
- [Ruby] 网页添加文本编辑器 Kindeditor for Ruby on Rails
- ruby 的 require require_relative
- ruby 的initialize方法 and 实例变量是怎么样工作的
- ruby安装步骤
- 常用ruby代码(view篇)
- [Ruby] ruby 发送126邮箱邮件
- [Ruby笔记]4. ruby 读写文件 File open read write new
- [Ruby笔记]3. 语法检查ruby -cw xx.rb /代码运行 ruby xx.rb/变量约定 @ @@ $
- Ruby 元编程 第二版随笔(三)
- Windows搭建Ruby环境
- Ruby 元编程 第二版随笔(二)
- [Ruby笔记]2. ruby基础的基础: irb --simple-prompt / puts print p/ false nil
- Ruby简介
- [Ruby笔记]1. ruby ruby oh~ ruby 安装
- ruby 使用Struct场景