lib/ronin/network/udp.rb in ronin-support-0.4.0 vs lib/ronin/network/udp.rb in ronin-support-0.4.1
- old
+ new
@@ -58,11 +58,11 @@
# puts socket.readlines
# end
#
# @api public
#
- def udp_connect(host,port,local_host=nil,local_port=nil)
+ def udp_connect(host,port,local_host=nil,local_port=0)
host = host.to_s
local_host = (local_host || '0.0.0.0').to_s
socket = UDPSocket.new
socket.bind(local_host,local_port) if (local_host && local_port)
@@ -100,11 +100,11 @@
# @return [UDPSocket]
# The newly created UDPSocket object.
#
# @api public
#
- def udp_connect_and_send(data,host,port,local_host=nil,local_port=nil)
+ def udp_connect_and_send(data,host,port,local_host=nil,local_port=0)
socket = udp_connect(host,port,local_host,local_port)
socket.write(data)
yield socket if block_given?
return socket
@@ -135,11 +135,11 @@
#
# @return [nil]
#
# @api public
#
- def udp_session(host,port,local_host=nil,local_port=nil)
+ def udp_session(host,port,local_host=nil,local_port=0)
socket = udp_connect(host,port,local_host,local_port)
yield socket if block_given?
socket.close
@@ -175,11 +175,11 @@
#
# @api public
#
# @since 0.4.0
#
- def udp_send(data,host,port,local_host=nil,local_port=nil)
+ def udp_send(data,host,port,local_host=nil,local_port=0)
udp_session(host,port,local_host,local_port) do |socket|
socket.write(data)
end
return true
@@ -209,11 +209,11 @@
# @return [String]
# The grabbed banner.
#
# @api public
#
- def udp_banner(host,port,local_host=nil,local_port=nil)
+ def udp_banner(host,port,local_host=nil,local_port=0)
banner = nil
udp_session(host,port,local_host,local_port) do |socket|
banner = socket.readline
end
@@ -237,11 +237,11 @@
# @example
# udp_server(1337)
#
# @api public
#
- def udp_server(port=nil,host=nil)
+ def udp_server(port=0,host=nil)
host = (host || '0.0.0.0').to_s
server = UDPSocket.new
server.bind(host,port)
@@ -272,10 +272,10 @@
# data, sender = server.recvfrom(1024)
# end
#
# @api public
#
- def udp_server_session(port=nil,host=nil,&block)
+ def udp_server_session(port=0,host=nil,&block)
server = udp_server(port,host,&block)
server.close()
return nil
end