lib/shadowsocks/local.rb in shadowsocks-0.3 vs lib/shadowsocks/local.rb in shadowsocks-0.4

- old
+ new

@@ -3,19 +3,19 @@ class ServerConnector < ::Shadowsocks::Tunnel def post_init p "connecting #{server.remote_addr[3..-1]} via #{server.config.server}" addr_to_send = server.addr_to_send.clone - send_data encrypt(table[:encrypt_table], addr_to_send) - server.cached_pieces.each { |piece| send_data encrypt(table[:encrypt_table], piece) } + send_data encrypt(addr_to_send) + server.cached_pieces.each { |piece| send_data encrypt(piece) } server.cached_pieces = [] server.stage = 5 end def receive_data data - server.send_data encrypt(table[:decrypt_table], data) + server.send_data decrypt(data) outbound_checker end end class LocalListener < ::Shadowsocks::Listener @@ -29,11 +29,11 @@ when 1 fireup_tunnel data when 4 cached_pieces.push data when 5 - connector.send_data(encrypt(table[:encrypt_table], data)) and return + connector.send_data(encrypt(data)) and return end end def fireup_tunnel(data) begin @@ -47,10 +47,10 @@ resolve_addrtype data send_data "\x05\x00\x00\x01\x00\x00\x00\x00" + [config.server_port].pack('s>') @stage = 4 - @connector = EventMachine.connect config.server, config.server_port, ServerConnector, self, @table + @connector = EventMachine.connect config.server, config.server_port, ServerConnector, self, crypto if data.size > header_length cached_pieces.push data[header_length, data.size] end rescue Exception => e