Skip to content

Commit

Permalink
added resolv_nbo
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/svn/incoming/trunk@2678 4d416f70-5f16-0410-b530-b9f4589650da
  • Loading branch information
Matt Miller committed Jul 8, 2005
1 parent 9f7f7f0 commit 19e0a60
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rex/logging/log_dispatcher.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'Rex'
require 'Rex/Logging/LogSink'

module Rex
module Logging
Expand Down
7 changes: 7 additions & 0 deletions lib/rex/socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ def self.from_sockaddr(saddr)
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
Expand Down
4 changes: 4 additions & 0 deletions lib/rex/socket.rb.ut.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ def test_from_sockaddr
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

0 comments on commit 19e0a60

Please sign in to comment.