-
-
Save sandro/2344327 to your computer and use it in GitHub Desktop.
ssl socket tunneling proxy; performs an ssl handshake on behalf of another socket.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
s = TCPSocket.open('localhost', 44567) | |
ss = OpenSSL::SSL::SSLSocket.new s | |
ss.sync_close = true | |
puts 'connecting...' | |
p ss.connect | |
puts 'done' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
BLOCK = 1024 * 16 * 16 | |
def read(socket) | |
puts "reading #{socket.inspect}" | |
data = socket.sysread(BLOCK) | |
p data | |
puts | |
data | |
rescue => e | |
p e.inspect | |
sleep 1 | |
retry | |
end | |
puts 'starting server' | |
server = TCPServer.new 44567 | |
google = TCPSocket.new('google.com', 443) | |
puts 'got google' | |
client = server.accept | |
puts 'got client' | |
data = read(client) | |
google.syswrite(data) | |
data = read(google) | |
client.syswrite(data) | |
data = read(google) | |
client.syswrite(data) | |
data = read(client) | |
google.syswrite(data) | |
data = read(google) | |
client.syswrite(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment