From 19e0a603ad88533702ed0c4048746f2ba9ebf2c2 Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Fri, 8 Jul 2005 14:53:12 +0000 Subject: [PATCH] added resolv_nbo git-svn-id: file:///home/svn/incoming/trunk@2678 4d416f70-5f16-0410-b530-b9f4589650da --- lib/rex/logging/log_dispatcher.rb | 1 + lib/rex/socket.rb | 7 +++++++ lib/rex/socket.rb.ut.rb | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/lib/rex/logging/log_dispatcher.rb b/lib/rex/logging/log_dispatcher.rb index 01c6b7e479..2d811f0e92 100644 --- a/lib/rex/logging/log_dispatcher.rb +++ b/lib/rex/logging/log_dispatcher.rb @@ -1,4 +1,5 @@ require 'Rex' +require 'Rex/Logging/LogSink' module Rex module Logging diff --git a/lib/rex/socket.rb b/lib/rex/socket.rb index 722ba7de4c..5f00273dcc 100644 --- a/lib/rex/socket.rb +++ b/lib/rex/socket.rb @@ -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 diff --git a/lib/rex/socket.rb.ut.rb b/lib/rex/socket.rb.ut.rb index cc5f89c554..6336d6993a 100644 --- a/lib/rex/socket.rb.ut.rb +++ b/lib/rex/socket.rb.ut.rb @@ -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