mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-11-12 11:52:01 +01:00
Support for bidirectional pipe on windows uses a hacked up socket_pair()
git-svn-id: file:///home/svn/framework3/trunk@4291 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
8d06aad5b4
commit
6df557c8a7
@ -47,9 +47,7 @@ module StreamAbstraction
|
||||
# This method creates a streaming socket pair and initializes it.
|
||||
#
|
||||
def initialize_abstraction
|
||||
self.lsock, self.rsock = ::Socket.pair(::Socket::AF_UNIX,
|
||||
::Socket::SOCK_STREAM, 0)
|
||||
|
||||
self.lsock, self.rsock = Rex::Socket.socket_pair()
|
||||
self.lsock.extend(Rex::IO::Stream)
|
||||
self.lsock.extend(Ext)
|
||||
self.rsock.extend(Rex::IO::Stream)
|
||||
|
@ -262,6 +262,20 @@ module Socket
|
||||
end
|
||||
end
|
||||
|
||||
def self.socket_pair
|
||||
begin
|
||||
pair = ::Socket.pair(::Socket::AF_UNIX, ::Socket::SOCK_STREAM, 0)
|
||||
|
||||
# Windows does not support Socket.pair, so we emulate it
|
||||
rescue ::NotImplementedError
|
||||
srv = TCPServer.new('localhost', 0)
|
||||
rsock = TCPSocket.new(srv.addr[3], srv.addr[1])
|
||||
lsock = srv.accept
|
||||
srv.close
|
||||
[lsock, rsock]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user