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/cname.rb
Views: 11784
1
# -*- coding: binary -*-
2
##
3
#
4
# Net::DNS::RR::CNAME
5
#
6
# $Id: CNAME.rb,v 1.7 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 CNAME
17
#------------------------------------------------------------
18
class CNAME < RR
19
attr_reader :cname
20
21
private
22
23
def check_name(name)
24
unless name =~ /(\w\.?)+\s*$/ and name =~ /[a-zA-Z]/
25
raise RRArgumentError, "Canonical Name not valid: #{name}"
26
end
27
name
28
end
29
30
def build_pack
31
@cname_pack = pack_name(@cname)
32
@rdlength = @cname_pack.size
33
end
34
35
def set_type
36
@type = Net::DNS::RR::Types.new("CNAME")
37
end
38
39
def get_data
40
@cname_pack
41
end
42
43
def get_inspect
44
"#@cname"
45
end
46
47
def subclass_new_from_hash(args)
48
if args.has_key? :cname
49
@cname = check_name args[:cname]
50
else
51
raise RRArgumentError, ":cname field is mandatory but missing"
52
end
53
end
54
55
def subclass_new_from_string(str)
56
@cname = check_name(str)
57
end
58
59
def subclass_new_from_binary(data,offset)
60
@cname,offset = dn_expand(data,offset)
61
return offset
62
end
63
64
end # class CNAME
65
66
end # class RR
67
end # module DNS
68
end # module Net
69
70