Method: Rex::Socket::Comm::Local.create_jruby
- Defined in:
- lib/rex/socket/comm/local.rb
.create_jruby(param) ⇒ Object
Creates an instance of a socket using the supplied parameters. Use various hacks to make this work with jRuby
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rex/socket/comm/local.rb', line 47 def self.create_jruby(param) sock = nil # Notify handlers of the before socket create event. self.instance.notify_before_socket_create(self, param) case param.proto when 'tcp' if param.server? sock = TCPServer.new(param.localport, param.localhost) klass = Rex::Socket::TcpServer if param.ssl klass = Rex::Socket::SslTcpServer end sock.extend(klass) else sock = TCPSocket.new(param.peerhost, param.peerport) klass = Rex::Socket::Tcp if param.ssl klass = Rex::Socket::SslTcp end sock.extend(klass) end when 'udp' if param.server? sock = UDPServer.new(param.localport, param.localhost) klass = Rex::Socket::UdpServer sock.extend(klass) else sock = UDPSocket.new(param.peerhost, param.peerport) klass = Rex::Socket::Udp sock.extend(klass) end else raise Rex::UnsupportedProtocol.new(param.proto), caller end sock.initsock(param) self.instance.notify_socket_created(self, sock, param) return sock end |