Project

sockit

0.0
No commit activity in last 3 years
No release in over 3 years
Seamlessly route all TCP traffic for you application through a SOCKS v4 or v5 server with nearly zero effort. Once required and configured all traffic leveraging the TCPSocket class will route via your configured SOCKS server.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Gem Version Build Status Coverage Status Dependency Status Code Climate

SOCKIT

Transparent SOCKS v4 and SOCKS v5 support for TCPSocket

Seamlessly route all TCP traffic for you application through a SOCKS v4 or v5 server with nearly zero effort. Once require'd and configured all traffic leveraging the TCPSocket class will route via your configured SOCKS server.

This is especially useful for many cases; here are a couple:

  • Ensure all outbound traffic from your application appears from a single IP.
  • Ensure development traffic does not give away private IP addresses.

INSTALLATION

Add this line to your application's Gemfile:

gem 'sockit'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sockit

Then run the pry console to play with it:

$ bundle exec sockit

USAGE

By loading the gem TCPSocket will get monkey patched adding seamless transparent SOCKS proxy support. I favor using SS5 for a SOCKS server, so at this point I'm uncertain of absolute compatibility with other SOCKS servers. I'm following the RFC here; so if (insert other SOCKS server flavor here) follows the RFC everything is in theory compatible.

CONFIGURATION

You can configure on the singleton class or an instance of the class. The SOCKS configuration is stored in a class variable; so it is shared across all TCPSocket instances and the singleton, thus changing the configuration in one instance will also affect all other instances. The configuration is stored in an OpenStruct; you can reference socks with a block as shown, where the configuration OpenStruct is yielded to the block; or without in which case the configuration OpenStruct itself is returned.

The defaults are as follows:

Sockit.config do |config|
  config.version = 5
  config.ignore = ["127.0.0.1"]
  config.debug = false
end

Specify your SOCKS server and port:

Sockit.config do |config|
  config.host = "127.0.0.1"
  config.port = "1080"
end

If you want to use username/password authentication:

Sockit.config do |config|
  config.username = "username"
  config.password = "password"
end

Turn on debug output:

Sockit.config do |config|
  config.debug = true
end

Ignore some more hosts:

Sockit.config do |config|
  config.ignore << "192.168.0.1"
end

Once configured you can simply do something along these lines:

socket = TCPSocket.new('github.com', '22')
data = socket.gets
puts data.inspect

And everything will be magically routed via your configured SOCKS server.

SS5

I use SS5 for my SOCKS servers. It works well and is easy to configure. It is also the server which the specs run against on Travis CI. You can see how it is compiled, configured and started as well as more the the Travis before_install script, https://github.com/zpatten/sockit/blob/master/spec/support/before_install.sh

CONTRIBUTING

I await your pull request.

RUBIES TESTED AGAINST

  • Ruby 2.0.0
  • Ruby 2.2.4
  • Ruby 2.3.0

RESOURCES

IRC:

  • #jovelabs on irc.freenode.net

Documentation:

Source:

Issues:

LICENSE

SOCKIT - Transparent SOCKS 5 support for TCPSocket

  • Author: Zachary Patten
  • Copyright: Copyright (c) Zachary Patten
  • License: Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.