CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/net/dns/rr/ns.rb
Views: 11784
1
# -*- coding: binary -*-
2
##
3
#
4
# Net::DNS::RR::NS
5
#
6
# $Id: NS.rb,v 1.8 2006/07/28 07:33:36 bluemonk Exp $
7
#
8
##
9
10
module Net
11
module DNS
12
13
class RR
14
15
#------------------------------------------------------------
16
# RR type NS
17
#------------------------------------------------------------
18
class NS < RR
19
attr_reader :nsdname
20
21
private
22
23
def check_name(name)
24
unless name =~ /(\w\.?)+\s*$/ and name =~ /[a-zA-Z]/
25
raise RRArgumentError, "NS Domain Name not valid: #{name}"
26
end
27
name
28
end
29
30
def build_pack
31
@nsdname_pack = pack_name(@nsdname)
32
@rdlength = @nsdname_pack.size
33
end
34
35
def set_type
36
@type = Net::DNS::RR::Types.new("NS")
37
end
38
39
def get_data
40
@nsdname_pack
41
end
42
43
def get_inspect
44
"#@nsdname"
45
end
46
47
def subclass_new_from_hash(args)
48
if args.has_key? :nsdname
49
@nsdname = check_name args[:nsdname]
50
else
51
raise RRArgumentError, ":nsdname field is mandatory but missing"
52
end
53
end
54
55
def subclass_new_from_string(str)
56
@nsdname = check_name(str)
57
end
58
59
def subclass_new_from_binary(data,offset)
60
@nsdname,offset = dn_expand(data,offset)
61
return offset
62
end
63
64
end # class NS
65
66
end # class RR
67
end # module DNS
68
end # module Net
69
70