Class: Net::DNS::RR::TKEY
- Inherits:
-
Net::DNS::RR
- Object
- Net::DNS::RR
- Net::DNS::RR::TKEY
- Defined in:
- lib/Net/DNS/RR/TKEY.rb
Overview
NAME
Net::DNS::RR::TKEY - DNS TKEY resource record
DESCRIPTION
Class for DNS TKEY resource records.
head1 BUGS
This code has not been extensively tested. Use with caution on production systems. See samba.org/ftp/samba/tsig-gss/ for an example usage.
head1 COPYRIGHT
Copyright © 2000 Andrew Tridgell. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
head1 ACKNOWLEDGMENT
The Net::DNS::RR::TKEY module is based on the TSIG module by Michael Fuhr and Chris Turbeville.
head1 SEE ALSO
L<perl(1)>, L<Net::DNS>, L<Net::DNS::Resolver>, L<Net::DNS::Packet>, L<Net::DNS::Header>, L<Net::DNS::Question>, L<Net::DNS::RR>, RFC 2845
Constant Summary
Constants inherited from Net::DNS::RR
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
Gets or sets the domain name that specifies the name of the algorithm.
-
#error ⇒ Object
Returns the RCODE covering TKEY processing.
-
#expiration ⇒ Object
Gets or sets the expiration time as the number of seconds since 1 Jan 1970 00:00:00 UTC.
-
#inception ⇒ Object
Gets or sets the inception time as the number of seconds since 1 Jan 1970 00:00:00 UTC.
-
#key ⇒ Object
Returns the value of attribute key.
-
#mode ⇒ Object
Sets the key mode (see rfc2930).
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#other_data ⇒ Object
Returns the Other Data.
-
#other_len ⇒ Object
Returns the length of the Other Data.
Attributes inherited from Net::DNS::RR
#name, #rdata, #rdlength, #rrclass, #ttl, #type
Instance Method Summary collapse
- #init_defaults ⇒ Object
- #new_from_data(data, offset) ⇒ Object
- #new_from_hash(values) ⇒ Object
- #new_from_string(string) ⇒ Object
- #rdatastr ⇒ Object
- #rr_rdata(packet, offset) ⇒ Object
Methods inherited from Net::DNS::RR
#_canonicalRdata, #_canonicaldata, _get_subclass, _name2wire, #_name2wire, build_regex, create, #create_rrsort_func, #data, #get_rrsort_func, #init, #init_rrsort_func, #inspect, new_from_data, new_from_hash, new_from_string, #set_rrsort_func
Instance Attribute Details
#algorithm ⇒ Object
Gets or sets the domain name that specifies the name of the algorithm. The default algorithm is gss.microsoft.com
rr.algorithm=(algorithm_name)
print "algorithm = ", rr.algorithm, "\n"
57 58 59 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 57 def algorithm @algorithm end |
#error ⇒ Object
Returns the RCODE covering TKEY processing. See RFC 2930 for details.
print "error = ", rr.error, "\n"
86 87 88 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 86 def error @error end |
#expiration ⇒ Object
Gets or sets the expiration time as the number of seconds since 1 Jan 1970 00:00:00 UTC.
The default expiration time is the current time plus 1 day.
rr.expiration=(time)
print "expiration = ", rr.expiration, "\n"
75 76 77 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 75 def expiration @expiration end |
#inception ⇒ Object
Gets or sets the inception time as the number of seconds since 1 Jan 1970 00:00:00 UTC.
The default inception time is the current time.
rr.inception=(time)
print "inception = ", rr.inception, "\n"
66 67 68 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 66 def inception @inception end |
#key ⇒ Object
Returns the value of attribute key.
50 51 52 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 50 def key @key end |
#mode ⇒ Object
Sets the key mode (see rfc2930). The default is 3 which corresponds to GSSAPI
rr.mode=(3)
print "mode = ", rr.mode, "\n"
81 82 83 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 81 def mode @mode end |
#offset ⇒ Object
Returns the value of attribute offset.
50 51 52 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 50 def offset @offset end |
#other_data ⇒ Object
Returns the Other Data. This field should be empty.
print "other data = ", rr.other_data, "\n"
96 97 98 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 96 def other_data @other_data end |
#other_len ⇒ Object
Returns the length of the Other Data. Should be zero.
print "other len = ", rr.other_len, "\n"
91 92 93 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 91 def other_len @other_len end |
Instance Method Details
#init_defaults ⇒ Object
161 162 163 164 165 166 167 168 169 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 161 def init_defaults @algorithm = "gss.microsoft.com" @inception = Time.now @expiration = Time.now + 24*60*60 @mode = 3 # GSSAPI @error = 0 @other_len = 0 @other_data = "" end |
#new_from_data(data, offset) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 98 def new_from_data(data, offset) # if we have some data then we are parsing an incoming TKEY packet # see RFC2930 for the packet format if (@rdlength > 0) @algorithm, @offset = Net::DNS::Packet::(data, offset) @inception, @expiration = data.unpack("\@#{offset} NN")[0] offset += Net::DNS::INT32SZ() + Net::DNS::INT32SZ(); @inception, @expiration = data.unpack("\@#{offset} nn")[0] offset += Net::DNS::INT16SZ + Net::DNS::INT16SZ key_len = data.unpack("\@#{offset} n")[0] offset += Net::DNS::INT16SZ @key = data[offset, key_len] offset += key_len other_len = data.unpack("\@#{offset} n")[0] offset += Net::DNS::INT16SZ @other_data = data[offset, other_len] offset += other_len end end |
#new_from_hash(values) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 122 def new_from_hash(values) init_defaults if (values.has_key?:key) @key = values[:key] end if (values.has_key?:offset) @offset = values[:offset] end if (values.has_key?:algorithm) @algorithm = values[:algorithm] end if (values.has_key?:expiration) @expiration = values[:expiration] end if (values.has_key?:inception) @inception = values[:inception] end if (values.has_key?:other_len) @other_len = values[:other_len] end if (values.has_key?:other_data) @other_data = values[:other_data] end if (values.has_key?:error) @error = values[:error] end if (values.has_key?:mode) @mode = values[:mode] end end |
#new_from_string(string) ⇒ Object
153 154 155 156 157 158 159 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 153 def new_from_string(string) if (string != nil && (string =~ /^(.*)$/)) @key = $1; end init_defaults end |
#rdatastr ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 182 def rdatastr error = @error error = "UNDEFINED" unless error!=nil rdatastr="" if (@algorithm!=nil) rdatastr = "#{@algorithm}. #{error}" if (@other_len != nil && @other_len >0 && @other_data!=nil) rdatastr += " #{@other_data}" end else rdatastr = '' end return rdatastr end |
#rr_rdata(packet, offset) ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/Net/DNS/RR/TKEY.rb', line 200 def rr_rdata(packet, offset) rdata = "" packet.compnames = Hash.new() rdata += packet.dn_comp(@algorithm, 0) rdata += [@inception].pack("N") rdata += [@expiration].pack("N") rdata += [@mode].pack("n") rdata += [0].pack("n"); # error rdata += [@key.length].pack("n") rdata += @key rdata += [@other_data.length].pack("n") rdata += @other_data return rdata end |