File: nresolv.rb

package info (click to toggle)
zonecheck 2.0.4-13lenny1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,424 kB
  • ctags: 1,177
  • sloc: ruby: 9,582; xml: 731; sh: 574; makefile: 66
file content (53 lines) | stat: -rw-r--r-- 1,260 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# $Id: nresolv.rb,v 1.10 2003/04/29 17:18:29 sdalu Exp $

# 
# AUTHOR   : Stephane D'Alu <sdalu@nic.fr>
# CREATED  : 2002/08/02 13:58:17
#
# COPYRIGHT: AFNIC (c) 2003
# LICENSE  : RUBY
# CONTACT  : 
#
# $Revision: 1.10 $ 
# $Date: 2003/04/29 17:18:29 $
#
# INSPIRED BY:
#   - the ruby file: resolv.rb 
#
# CONTRIBUTORS: (see also CREDITS file)
#
#

require 'nresolv/constants'
require 'nresolv/dns'
require 'nresolv/wire'
require 'nresolv/transport'
require 'nresolv/config'
require 'nresolv/resolver'
require 'nresolv/dig_output'
require 'nresolv/compatibility'

require 'address'

class NResolv
    # 
    # Ensure that 'arg' will be an Address or a DNS Name object,
    # raise the ArgumentError exception if conversion failed
    def self.to_addrname(arg)
        case arg
        when Address::IPv4, Address::IPv6, NResolv::DNS::Name
            arg
        when String
            begin
                Address::create(arg)
            rescue Address::InvalidAddress
                unless arg[-1] == ?.
                    $stderr.puts "WARNING: #{arg} is not fully qualified"
                end
                DNS::Name::create(arg)
            end
        else
            raise ArgumentError, "address or DNS Name expected"
        end
    end
end