1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-05 14:57:30 +01:00

added resolv_nbo

git-svn-id: file:///home/svn/incoming/trunk@2678 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Matt Miller 2005-07-08 14:53:12 +00:00
parent 9f7f7f0e53
commit 19e0a603ad
3 changed files with 12 additions and 0 deletions

View File

@ -1,4 +1,5 @@
require 'Rex'
require 'Rex/Logging/LogSink'
module Rex
module Logging

View File

@ -75,6 +75,13 @@ class Socket
return [ af, up.join('.'), port ]
end
#
# Resolves a host to raw network-byte order
#
def self.resolv_nbo(host)
return to_sockaddr(host, 0)[4,4]
end
##
#
# Class initialization

View File

@ -54,4 +54,8 @@ class Rex::Socket::UnitTest < Test::Unit::TestCase
assert_equal(22, port, "port = 22")
end
def test_resolv_nbo
assert_equal("\x04\x03\x02\x01", Rex::Socket.resolv_nbo("4.3.2.1"))
end
end