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 ...
随机推荐
- safeseh+dep保护绕过
[文章作者] :h_one [漏洞程序名称]:mplayer.exe [漏洞类型] :缓冲区溢出 [保护方式] :safeseh+dep [操作平台] ...
- 在线运行HTML代码器
在线运行HTML代码器(二)和前面的(一)大同小异,关键部分为JS代码,这次是把运行器所有的JS功能集中放在一起.以下为HTML代码: <!DOCTYPE html PUBLIC "- ...
- 解决IE不支持position:fixed问题
#box { /* 非IE6浏览器使用固定元素 */ position:fixed; top:0; left:0; /* IE6改为绝对定位,并通过css表达式根据滚动位置更改top的值 */ _po ...
- Razor视图引擎 语法学习(二)
下面就和大家分享下我在asp.net官网看到的资料,学习到的点语法.1.通过使用@符号,可以直接在html页面中写C#或者VB代码:运行后: 2.页面中的C#或者VB代码都放在大括号中.运行后: 3. ...
- Combination Sum III
https://leetcode.com/problems/combination-sum-iii/ Find all possible combinations of k numbers that ...
- SQL Server 2008管理工具出现 远程过程调用失败0x800706be解决方法
解决方法 出现此问题是因为在安装 Visual Studio 2012(VS2012) 时,会自动安装 "Microsoft SQL Server 2012 Express LocalDB& ...
- 线段树(区间合并) POJ 3667 Hotel
题目传送门 /* 题意:输入 1 a:询问是不是有连续长度为a的空房间,有的话住进最左边 输入 2 a b:将[a,a+b-1]的房间清空 线段树(区间合并):lsum[]统计从左端点起最长连续空房间 ...
- hdu2021(很闲~~)
http://acm.hdu.edu.cn/showproblem.php?pid=2021 water~~~ #include<iostream> #include<stdio.h ...
- webmatrix
http://www.microsoft.com/web/webmatrix/ WebMatrix is a free, lightweight, cloud-connected web develo ...
- lintcode:数字组合 II
数字组合 II 给出一组候选数字(C)和目标数字(T),找出C中所有的组合,使组合中数字的和为T.C中每个数字在每个组合中只能使用一次. 注意事项 所有的数字(包括目标数字)均为正整数. 元素组合(a ...