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/ptr.rb
Views: 11784
1
# -*- coding: binary -*-
2
##
3
#
4
# Net::DNS::RR::PTR
5
#
6
# $Id: PTR.rb,v 1.5 2006/07/28 07:33:36 bluemonk Exp $
7
#
8
##
9
10
module Net
11
module DNS
12
class RR
13
14
#------------------------------------------------------------
15
# RR type PTR
16
#------------------------------------------------------------
17
class PTR < RR
18
19
# Getter for PTR resource
20
def ptr
21
@ptrdname.to_s
22
end
23
alias_method :ptrdname, :ptr
24
25
private
26
27
def check_ptr(str)
28
IPAddr.new str
29
rescue
30
raise RRArgumentError, "PTR section not valid"
31
end
32
33
def build_pack
34
@ptrdname_pack = pack_name(@ptrdname)
35
@rdlength = @ptrdname_pack.size
36
end
37
38
def set_type
39
@type = Net::DNS::RR::Types.new("PTR")
40
end
41
42
def get_data
43
@ptrdname_pack
44
end
45
46
def get_inspect
47
"#@ptrdname"
48
end
49
50
def subclass_new_from_hash(args)
51
if args.has_key? :ptrdname or args.has_key? :ptr
52
@ptrdname = args[0][:ptrdname]
53
else
54
raise RRArgumentError, ":ptrdname or :ptr field is mandatory but missing"
55
end
56
end
57
58
def subclass_new_from_string(str)
59
@ptrdname = check_ptr(str)
60
end
61
62
def subclass_new_from_binary(data,offset)
63
@ptrdname,offset = dn_expand(data,offset)
64
return offset
65
end
66
67
end # class PTR
68
69
end # class RR
70
end # module DNS
71
end # module Net
72
73