See #485. This patch allows the very basics of metasploit to work under jRuby 1.4.0. Many, many things are still broken
git-svn-id: file:///home/svn/framework3/trunk@7906 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
80fa601a2c
commit
39d37065de
|
@ -41,7 +41,9 @@ if(RUBY_PLATFORM == 'java')
|
|||
if(not s.respond_to?('bind'))
|
||||
$stderr.puts "*** JRuby will not be supported until the Socket API is complete"
|
||||
$stderr.puts "*** Information: http://jira.codehaus.org/browse/JRUBY-2739"
|
||||
exit(0)
|
||||
trap Signal::list['INT'] do
|
||||
Thread.main.raise Interrupt.new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ class Rex::Socket::Comm::Local
|
|||
# Creates an instance of a socket using the supplied parameters.
|
||||
#
|
||||
def self.create(param)
|
||||
|
||||
# Work around jRuby socket implementation issues
|
||||
if(RUBY_PLATFORM == 'java')
|
||||
return self.create_jruby(param)
|
||||
end
|
||||
|
||||
case param.proto
|
||||
when 'tcp'
|
||||
return create_by_type(param, ::Socket::SOCK_STREAM, ::Socket::IPPROTO_TCP)
|
||||
|
@ -33,6 +39,53 @@ class Rex::Socket::Comm::Local
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Creates an instance of a socket using the supplied parameters.
|
||||
# Use various hacks to make this work with jRuby
|
||||
#
|
||||
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
|
||||
|
||||
|
||||
#
|
||||
# Creates a raw IP socket using the supplied Parameter instance.
|
||||
|
|
Loading…
Reference in New Issue