Adds the Broadcast parameter to the Rex::Socket class, allows udp/ip sockets to send to broadcast addresses
git-svn-id: file:///home/svn/framework3/trunk@6778 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
3e072dd66e
commit
9068b9a133
|
@ -44,6 +44,11 @@ class Rex::Socket::Comm::Local
|
|||
sock = ::Socket.open(::Socket::PF_INET, ::Socket::SOCK_RAW, ::Socket::IPPROTO_RAW)
|
||||
sock.setsockopt(::Socket::IPPROTO_IP, ::Socket::IP_HDRINCL, 1)
|
||||
|
||||
# Configure broadcast support if the parameter is requested
|
||||
if(param.broadcast)
|
||||
sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_BROADCAST, true)
|
||||
end
|
||||
|
||||
if (param.bare? == false)
|
||||
sock.extend(::Rex::Socket::Ip)
|
||||
sock.initsock(param)
|
||||
|
@ -143,6 +148,11 @@ class Rex::Socket::Comm::Local
|
|||
end
|
||||
end
|
||||
|
||||
# Configure broadcast support if the parameter is requested
|
||||
if(param.broadcast)
|
||||
sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_BROADCAST, true)
|
||||
end
|
||||
|
||||
# If a server TCP instance is being created...
|
||||
if (param.server?)
|
||||
sock.listen(32)
|
||||
|
|
|
@ -89,6 +89,11 @@ class Rex::Socket::Parameters
|
|||
#
|
||||
# The number of seconds before a connection should time out
|
||||
#
|
||||
# Broadcast
|
||||
#
|
||||
# Specify this as true to send traffic to broadcast addresses
|
||||
#
|
||||
|
||||
def initialize(hash)
|
||||
if (hash['PeerHost'])
|
||||
self.peerhost = hash['PeerHost']
|
||||
|
@ -173,6 +178,11 @@ class Rex::Socket::Parameters
|
|||
self.timeout = 5
|
||||
end
|
||||
|
||||
# Enable sends to broadcast addresses
|
||||
if hash['Broadcast']
|
||||
self.broadcast = true
|
||||
else
|
||||
|
||||
# Whether to force IPv6 addressing
|
||||
self.v6 = hash['IPv6'] || false
|
||||
end
|
||||
|
@ -291,6 +301,10 @@ class Rex::Socket::Parameters
|
|||
#
|
||||
attr_accessor :timeout
|
||||
#
|
||||
# Whether or not to enable broadcast sends on this socket
|
||||
#
|
||||
attr_accessor :broadcast
|
||||
#
|
||||
# Whether or not this is a bare (non-extended) socket instance that should
|
||||
# be created.
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue