• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    Ruby
  • License
    Other
  • Created over 15 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Redirect any TCP connection initiated by a Ruby script through a SOCKS5 proxy

Gem Version Actions Status

SOCKSify Ruby

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?

require 'socksify/http'

This adds a new class method Net::HTTP.socks_proxy which takes the host and port address of a socks proxy. Once set, all requests will be routed via socks. This is acheived by patching a private method in Net::HTTP, as sadly Ruby no longer has native socks proxy support out of the box.

Additionally, Socksify.resolve can be used to resolve hostnames to IPv4 addresses 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 (Deprecated in Ruby 3.1 onwards)

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.socks_proxy method. It is similar to Net::HTTP.Proxy from the Ruby standard library:

require 'socksify/http'

uri = URI.parse('http://ipecho.net/plain')
Net::HTTP.socks_proxy('127.0.0.1', 9050).start(uri.host, uri.port) do |http|
  req = Net::HTTP::Get.new uri
  resp = http.request(req)
  puts resp.inspect
  puts resp.body
end
# => #<Net::HTTPOK 200 OK readbody=true>
# => <A tor exit node ip address>

Note that Net::HTTP.socks_proxy never relies on TCPSocket.socks_server/socks_port. You should either set socks_proxy arguments explicitly or use Net::HTTP directly.

Resolve addresses via SOCKS

Socksify.resolve("spaceboyz.net")
# => "87.106.131.203"

Testing and Debugging

A tor proxy is required before running the tests. Install tor from your usual package manager, check it is running with pidof tor then run the tests with:

ruby test/test_socksify.rb (uses minitest, gem install minitest if you don't have it)

Colorful diagnostic messages are enabled by default via:

Socksify::debug = true`

Development

The repository can be checked out with:

$ git-clone [email protected]:astro/socksify-ruby.git

Send patches via pull requests. Please run rubcop & correct any errors first.

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.

More Repositories

1

microvm.nix

NixOS MicroVMs
Nix
1,182
star
2

gitpop

More popular than Git*ub
JavaScript
583
star
3

deadnix

Scan Nix files for dead code
Rust
451
star
4

skyflake

NixOS Hyperconverged Infrastructure on Nomad/NixOS
Nix
185
star
5

nix-openwrt-imagebuilder

Build OpenWRT images in Nix derivations
Nix
121
star
6

bitford

BitTorrent Client in a Chrome Packaged App
JavaScript
97
star
7

prittorrent

BitTorrent Content Distribution for Podcasts
Erlang
92
star
8

buzzrelay

Source to relay.fedi.buzz: relay the streaming API of Mastodon instances
Rust
70
star
9

remcached

Ruby EventMachine memcached client
Ruby
50
star
10

erlang-collectd

Send collectd statistics from your Erlang applications
Erlang
49
star
11

node-oembed

oEmbed consumer library for node.js & tools
JavaScript
37
star
12

em-dns

tmm1's em/dns_cache for asynchronous DNS resolving from EventMachine
Ruby
35
star
13

chaosbay

BitTorrent Tracker with upload & browsing, written on the 25th Chaos Communication Congress
Erlang
34
star
14

bitlove-ui

Bitlove.org on Yesod
JavaScript
31
star
15

noattach

Instant Personal Temporary File Sharing
JavaScript
19
star
16

firetail

HTTP REST to XMPP PubSub with node.js
JavaScript
18
star
17

rexml-dropin

Drop-in replacement for REXML using libxml-ruby and libxml-parser-ruby (expat binding)
Ruby
17
star
18

deadnix-action

Workflow to find and delete dead nix code
16
star
19

harvester

Web-based feed aggregator in Ruby
Ruby
13
star
20

norrent

Norrent is going to be a BitTorrent toolkit for node.js
JavaScript
13
star
21

collectd

Some personal modifications to collectd, the kick-ass data collector
C
13
star
22

lxc-top

Bird's eye view of Linux Containers
Ruby
13
star
23

ruby-sasl

Simple Authentication and Security Layer (RFC 4422) for Ruby
Ruby
12
star
24

ifdyndnsd

Watch netlink for interface address updates to do DynDNS just like nsupdate does (RFC2136 + RFC2845)
Rust
12
star
25

irssi-xmpp

Modifications to irssi-plugin-xmpp from CVS
C
12
star
26

hashvortex

Playing with the BitTorrent DHT in Haskell
Haskell
11
star
27

libxml-ruby

Make LibXML-Ruby's SAX parser a SAX push parser
11
star
28

em-asyncns

Resolve domain names from EventMachine with libasyncns
Ruby
11
star
29

s3erl

Erlang bindings for Amazon S3 storage web service
Erlang
11
star
30

utf8cleaner

Efficiently clean your UTF8 for Ruby in C
C
11
star
31

tokio-xmpp

XMPP with Rust and Tokio [MOVED]
10
star
32

spacesocket

WebSocket server for Node.js not invented here
JavaScript
9
star
33

superhighway

Superfeedr.com-powered feed reader webapp for standalone installation
JavaScript
9
star
34

tigger

XMPP Multi-User Chat Bot
Nix
9
star
35

rad1o-rust

Run Rust on the rad1o embedded hardware from Chaos Communication Camp 2015
Rust
8
star
36

faucheuse

Feed Aggregator (Harvester rewrite in Erlang)
Erlang
8
star
37

rust-waveshare-4inch-tft-touch-shield

Embedded Rust implementation of display+touchscreen drivers for STM32F429
Rust
8
star
38

node-vnc-client

VNC client implementation in JavaScript for node.js
JavaScript
8
star
39

dat-osm-import

Import OpenStreetMap data into dat
JavaScript
7
star
40

libpulse-sys

**Outdated!** Replaced by https://github.com/jnqnfe/pulse-binding-rust
Rust
7
star
41

rust-pulse-simple

Simple Pulseaudio crate for the Rust language
Rust
7
star
42

pile

Programmatically Illuminated Lightening Environment
Rust
7
star
43

b-runner

JavaScript
7
star
44

sawrocket

Portable Raw Socket API for Firefox OS & Chrome Packaged Apps
JavaScript
7
star
45

sigh

HTTP signatures for ActivityPub in Rust
Rust
7
star
46

dat-elasticsearch-upload

Upload from dat into ElasticSearch
JavaScript
7
star
47

sub2text

XMPP PubSub bridge in Erlang
Erlang
7
star
48

node-collectdout

Periodically send values out to a Collectd server for statistics
JavaScript
6
star
49

superradar

Persistent Web Feed Reader powered by Superfeedr
JavaScript
6
star
50

rust-lpc43xx

Register definitions for the NXP LPC43xx microcontroller platform, generated through svd2rust
Rust
6
star
51

feedmonster

Push Parsing XML in Ruby
Ruby
5
star
52

microvm-solo5-spt

Run a Unikernel on microvm.nix host
Nix
5
star
53

ceilingled

Yet another hackerspace illumination
CoffeeScript
5
star
54

atomstreamr

Ruby interface to http://updates.sixapart.com/atom-stream.xml
4
star
55

rust-kenburns

Ken Burns effect slideshow with Glium in Rust
Rust
4
star
56

erlxslt

Dirty little libxslt Port for Erlang
Erlang
4
star
57

nix-cache-cut

Trim Nix binary caches according to GC roots
Rust
4
star
58

bitorama

A BitTorrent gadget on node.js
JavaScript
4
star
59

channels-xep

Condensing the Buddycloud channels protocol into a single document
4
star
60

jerry

The incredibly simple Jabber MUC client to run in screens
Ruby
3
star
61

ejabberd

Clone of Proccess One's Erlang jabber implementation from SVN.
Erlang
3
star
62

youtube_to_feed

Free my content for Podcast feeds!
JavaScript
3
star
63

rust-protobuf-iter

Iterate over Protobuf messages while decoding on the fly
Rust
3
star
64

rust-sgtl5000

I2S/I2C sound output driver. Does not work.
Rust
3
star
65

spacemsg

Connecting sensors with 0mq
Haskell
3
star
66

network-protocol-xmpp

My branch of Network.Protocol.XMPP for Haskell
Haskell
3
star
67

exif-annex

node.js script to put EXIF metadata into git-annex using ffmpeg's ffprobe
JavaScript
3
star
68

superfeedr.github.com

Superfeedr's Blog
2
star
69

rust-r0ket

Embedded Rust on the CCCamp2011 r0ket badge
Rust
2
star
70

mcbench

memcached benchmark
Haskell
2
star
71

sharing2

Sharing Is Caring reimplemented
Haskell
2
star
72

h3c

Program β€œDie Drei C” in Haskell
Haskell
2
star
73

rust-osm-pbf-iter

Parse OpenStreetMap .pbf dumps while trying to avoid copying
Rust
2
star
74

osm-poi-db

Extract POIs from OSM PBFs and put them into LevelDB, ready for nearby query
JavaScript
2
star
75

dresden-haushalt

Visuallizing Public Data
JavaScript
2
star
76

democropticon

My Open Data Playground
JavaScript
2
star
77

openarena-distro

I accidently the whole OpenArena
2
star
78

underpass-turbo

[WIP] OSM query engine with zero runtime dependencies
Rust
2
star
79

HTTPbis

Clone of the Haskell HTTP package
Haskell
2
star
80

rust-lpc13xx

Peripheral access API for NXP LPC13xx microcontrollers generated through svd2rust
Rust
2
star
81

lazy_bencoding

Lazy BEncoding parser that gives you iterators over byte slices
Rust
2
star
82

ruby-feed-parser-benchmark

Ever wanted to know what was the most effiscient Ruby Library to parse feed, check this benchmark.
Ruby
2
star
83

luft-heatmap

Luftdaten.info visualisiert
CSS
1
star
84

rust-hash2hwaddr

Hashes anything to a private MAC address
Rust
1
star
85

moers-haushalt

Converts some XML to CSV
JavaScript
1
star
86

prittorrent2

Next-gen Bitlove.org backend
JavaScript
1
star
87

dht22-rs

Rust implementation for reading from DHT22 1-wire humidity/temperature sensor
Rust
1
star
88

remind2ics

Remind to iCalendar converter
Haskell
1
star
89

petze

Service monitoring not invented here
CoffeeScript
1
star
90

yammat

Yet Another MateMAT
Haskell
1
star
91

strom

STream Real-time Online Media
Rust
1
star
92

srtsplit

Split SRT subtitle files with too long lines
Rust
1
star
93

hashimi

Hash Torrents in da Browser
JavaScript
1
star
94

podleech

Download Podcast Enclosures
Shell
1
star
95

osm-pbf-parser

streaming open street maps protocol buffer parser
JavaScript
1
star
96

t1mel1ne

Who has got the longest Github profile timeline?
1
star