Class: UDPProxy::Server

Inherits:
EM::Connection
  • Object
show all
Defined in:
lib/udp_proxy/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(address, relay_ip, relay_port) ⇒ Server

Returns a new instance of Server.



3
4
5
6
# File 'lib/udp_proxy/server.rb', line 3

def initialize(address, relay_ip, relay_port)
  @relay_ip, @relay_port = relay_ip, relay_port
  @clients = Clients.new(self, address)
end

Instance Method Details

#receive_data(data) ⇒ Object



8
9
10
11
12
# File 'lib/udp_proxy/server.rb', line 8

def receive_data(data)
  port, ip = Socket.unpack_sockaddr_in(get_peername)
  client = @clients.client(ip, port)
  client.send_datagram(data, @relay_ip, @relay_port)
end