astro / socksify-ruby

Redirect any TCP connection initiated by a Ruby script through a SOCKS5 proxy
http://socksify.rubyforge.org/
Other
165 stars 80 forks source link

threadsafe #15

Open tigris opened 12 years ago

tigris commented 12 years ago

Would love if this could be threadsafe, often want a few tcp sockets open at same time, some via socks and some not

astro commented 12 years ago

Propose an API.

Then it won't be a long shot for a commit.

musybite commented 10 years ago

@tigris socksify-ruby can do this, altough interface is ugly a bit. It's kind of undocumented feature.

require 'socksify'
addr = TCPSocket::SOCKSConnectionPeerAddress.new("<socks host>", <socks port>, "<peer host>")
s = TCPSocket.new(addr, <peer port>)
# Proceed as usual.
kornate commented 1 year ago

Something like this would be nice:

require 'socksify'

# Create a new socksified connection
socksified_connection = Socksify::Connection.new(socks_host: "<socks host>", socks_port: <socks port>, peer_host: "<peer host>", peer_port: <peer port>)

# Use the connection as a regular TCPSocket
socksified_connection.write("data")
response = socksified_connection.read
socksified_connection.close