class SocksTunnel::Remote::Server
Public Instance Methods
post_init()
click to toggle source
# File lib/socks_tunnel/remote.rb, line 24 def post_init @coder = Coder.new @buffer = Buffer.new end
receive_data(data)
click to toggle source
# File lib/socks_tunnel/remote.rb, line 35 def receive_data(data) if @connection @buffer << data @buffer.each do |segment| @connection.send_data(@coder.decode(segment)) end else @buffer << data addr = @buffer.shift if addr addr = @coder.decode(addr) host, port = addr.split(':') port = (port.nil? || port.empty?) ? 80 : port.to_i @connection = EventMachine.connect(host, port, Connection) @connection.server = self @buffer.each do |segment| @connection.send_data(@coder.decode(segment)) end end end rescue @connection.close_connection if @connection close_connection end
send_encoded_data(data)
click to toggle source
# File lib/socks_tunnel/remote.rb, line 29 def send_encoded_data(data) return if data.nil? || data.empty? send_data(@coder.encode(data)) send_data(Config.delimiter) end
unbind()
click to toggle source
# File lib/socks_tunnel/remote.rb, line 60 def unbind @connection.close_connection if @connection end