SOCKSify Ruby
http://socksify.rubyforge.org/
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 class TCPSocket
:
- Alias
initialize
asinitialize_tcp
- The new
initialize
calls the old method to establish a TCP connection to the SOCKS proxy, sends the proxying destination and checks for errors
Additionally, Socksify::resolve
can be used to resolve hostnames to IPv4 addresses via SOCKS. There is alsosocksify/http
enabling 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 library socksify/http
and use the Net::HTTP.SOCKSProxy
method. It is similar to Net:HTTP.Proxy
from 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.SOCKSProxy
never relies on TCPSocket::socks_server
/socks_port
. You should either setSOCKSProxy
arguments explicitly or use Net::HTTP
directly.
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
Resolv
replacement 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
License
SOCKSify Ruby is distributed under the terms of the GNU General Public License version 3 (see file COPYING
) or the Ruby License (see file LICENSE
) at your option.
SOCKSify Ruby的更多相关文章
- 安装cocoapods遇到两大坑-Ruby版本升级和Podfile的配置
今天安装cocoapods #移除原有ruby源 $ gem sources --remove https://rubygems.org/ #使用可用的淘宝网 $ gem sources -a htt ...
- Unable to download data from http://ruby.taobao.org/ & don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
安装cocoapods,记录两个问题! 1.镜像已经替换成了 http://ruby.taobao.org/, 还是不能不能安装cocoapods, 报错:Unable to download dat ...
- 安装了ruby后怎么安装sass
在命令行中输入 ruby -v 查看版本号 先移除默认的https://rubygems.org源,命令为gem sources --remove https://rubygems.org/,按回车 ...
- ruby 基础知识(一)
突然今天发现一大神的博客:http://www.cnblogs.com/jackluo/archive/2013/01/22/2871655.html 相信初学者会受益颇多 ruby 参考文档 ...
- ruby 基础知识(二)
ruby 中的动态方法 http://singleant.iteye.com/blog/1680382 Rails 大量使用了符号(symbol).符号看上去很像变量名,不过以冒号作为前缀.符号的例 ...
- Ruby安装Scss
Ruby安装Scss 引言 已经许久不写HTML了,今天有点以前的东西要改.但是刚装的Windows10,已经没有以前的Web开发环境了.只好重新安装. 结果Webstorm装好后配置Scss出现错误 ...
- fzf by ruby
fzf by ruby */--> fzf by ruby 1 github地址 https://github.com/junegunn/fzf 2 简介 软件通过匿名管道和grep扩展了bas ...
- The Safe Navigation Operator (&.) in Ruby
The most interesting addition to Ruby 2.3.0 is the Safe Navigation Operator(&.). A similar opera ...
- Ruby on Rails 创建https应用
1. 创建证书请求文件条件:私钥+证书签名请求+opensslyum install -y opensslmkdir /root/ssl/ && cd /root/ssl/openss ...
随机推荐
- Android 4.4 KitKat, the browser and the Chrome WebView
Having V8 as the JavaScript engine for the new web view, the JavaScript performance if much better, ...
- hadoop开发环境-----eclipse
1.eclipse下载 http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/lunasr1 2.hadoo ...
- 利用Openvswitch实现不同物理机中的Docker容器互连
1. 测试环境 75机(10.11.150.75):Red Hat Enterprise Linux Server 7.0,无外网访问权限,已安装Docker Server 74机(10.11.150 ...
- linux权威指南 简记
/proc 目录,linxu系统以文件形式存放进程信息,这是一个虚拟的文件系统,不占有任何磁盘空间,当读取该文件系统时,系统内核会拦截动作,并动态产生文件与目录的内容 查看该文件夹,会发现很多已数字命 ...
- (转)Maximum subarray problem--Kadane’s Algorithm
转自:http://kartikkukreja.wordpress.com/2013/06/17/kadanes-algorithm/ 本来打算自己写的,后来看到上述链接的博客已经说得很清楚了,就不重 ...
- 行列有序矩阵求第k大元素
问题来源:http://www.careercup.com/question?id=6335704 问题描述: Given a N*N Matrix. All rows are sorted, and ...
- Android 内存剖析 – 发现潜在问题
简介 移动平台上的开发和内存管理紧密相关.尽管随着科技的进步,现今移动设备上的内存大小已经达到了低端桌面设备的水平,但是现今开发的应用程序对内存的需求也在同步增长.主要问题出在设备的屏幕尺寸上-分辨率 ...
- javascript中onclick事件能调用多个方法吗
Q: javascript中onclick事件能调用多个方法吗? A: 可以的,方法如下onclick="aa();bb();cc();"每个方法用“;”分号隔开就行了
- ***RESTful API 设计指南(阮一峰)
网络应用程序,分为前端和后端两个部分.当前的发展趋势,就是前端设备层出不穷(手机.平板.桌面电脑.其他专用设备......). 因此,必须有一种统一的机制,方便不同的前端设备与后端进行通信.这导致AP ...
- ExtJs之工具栏及菜单栏
先培养一下大概的感觉吧. 基本按书上都弄出来了. <!DOCTYPE html> <html> <head> <title>ExtJs</titl ...