Skip to content

Commit

Permalink
add peer logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Oct 14, 2009
1 parent d82ad48 commit 8dabd2a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/proxymachine/client_connection.rb
Expand Up @@ -14,6 +14,14 @@ def post_init
ProxyMachine.incr
end

def peer
@peer ||=
begin
port, ip = Socket.unpack_sockaddr_in(get_peername)
"#{ip}:#{port}"
end
end

def receive_data(data)
if !@server_side
@buffer << data
Expand All @@ -28,6 +36,7 @@ def ensure_server_side_connection
@timer.cancel if @timer
unless @server_side
commands = ProxyMachine.router.call(@buffer.join)
puts "#{peer} #{commands.inspect}"
close_connection unless commands.instance_of?(Hash)
if remote = commands[:remote]
m, host, port = *remote.match(/^(.+):(.+)$/)
Expand Down

0 comments on commit 8dabd2a

Please sign in to comment.