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 ...
随机推荐
- LAMP一键安装包-CentOS 5/6下自动编译安装Apache,MySQL,PHP
http://www.centos.bz/lamp/ 此安装包已经不再维护,请使用新版http://www.centos.bz/ezhttp/. 适用环境: 系统支持:CentOS-5 (32bit/ ...
- 负MARGIN之讲解
css中的负边距(negative margin)是布局中的一个常用技巧,只要运用得合理常常会有意想不到的效果.很多特殊的css布局方法都依赖于负边距,所以掌握它的用法对于前端的同学来说,那是必须的. ...
- 十个实用但IE不支持的CSS属性
对IE浏览器尤其是IE6的抱怨基本已进入麻痹状态,偶尔甚至产生非常消极的想法:这个世界只有一个浏览器就好了,哪怕这唯一的浏览器就是IE6.当然,这样的想法是非常病态的,马上打消.本文里面,介绍了10个 ...
- DevExpress GridControl 复合表头/表头分层设计.
首先创建一个窗体,将GridControl控件拖到窗体中. 然后 Click here to change view -> Convert to -> BandedGridView ...
- POJ 3034 Whac-a-Mole(DP)
题目链接 题意 : 在一个二维直角坐标系中,有n×n个洞,每个洞的坐标为(x,y), 0 ≤ x, y < n,给你一把锤子可以打到地鼠,最开始的时候,你可以把锤子放在任何地方,如果你上一秒在( ...
- 未能正确加载“Microsoft.VisualStudio.Editor.Implementation.EditorPackage”
VS2012启动/加载项目出问题 未能正确加载“Microsoft.VisualStudio.Editor.Implementation.EditorPackage, Microsoft.Visual ...
- Android核心分析 之十Android GWES之基本原理篇
Android GWES基本框架篇 我这里的GWES这个术语实际上从Microsoft 的Window上移植过来的,用GWES来表示Android的窗口事件系统不是那么准确,在Android中Wind ...
- 一步步来配置安卓开发环境ADTBundle
前提 安装JDK,并且要正确配置环境变量. 特别要注意安装配置完后,CMD命令行窗口里输入 java 和 javac 查看是否有内容输出,若提示找不到命令就是你JDK配置错误了 至于如何配置JDK看这 ...
- PHP中global全局变量的使用
在方法里面想用外面的变量,可以声明这个变量为全局变量. $a=1; $b=2; test_global(); function test_global() { global $a,$b; echo $ ...
- AndroidManifest.xml 配置权限大全
问登记属性 android.permission.ACCESS_CHECKIN_PROPERTIES ,读取或写入登记check-in数据库属性表的权限 获取错略位置 android.permissi ...