Class: Dnsruby::RR::TKEY

Inherits:
Dnsruby::RR show all
Defined in:
lib/dnsruby/resource/TKEY.rb

Overview

RFC2930

Constant Summary collapse

TypeValue =

:nodoc: all

Types::TKEY
ClassValue =

:nodoc: all

nil

Constants inherited from Dnsruby::RR

ClassInsensitiveTypes

Instance Attribute Summary collapse

Attributes inherited from Dnsruby::RR

#klass, #name, #rdata, #ttl, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Dnsruby::RR

#<=>, #==, #clone, create, #eql?, find_class, get_class, get_num, #hash, implemented_rrs, #init_defaults, new_from_data, new_from_hash, new_from_string, #rdlength, #sameRRset, #to_s

Constructor Details

#initializeTKEY

Returns a new instance of TKEY.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/dnsruby/resource/TKEY.rb', line 97

def initialize
  @algorithm   = "gss.microsoft.com"
  @inception   = Time.now
  @expiration  = Time.now + 24*60*60
  @mode        = Modes.GSSAPI
  @error       = 0
  @other_size   = 0
  @other_data  = ""

  #  RFC 2845 Section 2.3
  @klass = Classes.ANY
  #  RFC 2845 Section 2.3
  @ttl = 0
end

Instance Attribute Details

#algorithmObject

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"


51
52
53
# File 'lib/dnsruby/resource/TKEY.rb', line 51

def algorithm
  @algorithm
end

#errorObject

Returns the RCODE covering TKEY processing. See RFC 2930 for details.

print "error = ", rr.error, "\n"


80
81
82
# File 'lib/dnsruby/resource/TKEY.rb', line 80

def error
  @error
end

#expirationObject

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"


69
70
71
# File 'lib/dnsruby/resource/TKEY.rb', line 69

def expiration
  @expiration
end

#inceptionObject

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"


60
61
62
# File 'lib/dnsruby/resource/TKEY.rb', line 60

def inception
  @inception
end

#keyObject

Returns the value of attribute key.



44
45
46
# File 'lib/dnsruby/resource/TKEY.rb', line 44

def key
  @key
end

#key_sizeObject (readonly)

Returns the value of attribute key_size.



43
44
45
# File 'lib/dnsruby/resource/TKEY.rb', line 43

def key_size
  @key_size
end

#modeObject

Sets the key mode (see rfc2930). The default is 3 which corresponds to GSSAPI

rr.mode=(3)
print "mode = ", rr.mode, "\n"


75
76
77
# File 'lib/dnsruby/resource/TKEY.rb', line 75

def mode
  @mode
end

#other_dataObject

Returns the Other Data. This field should be empty.

print "other data = ", rr.other_data, "\n"


90
91
92
# File 'lib/dnsruby/resource/TKEY.rb', line 90

def other_data
  @other_data
end

#other_sizeObject (readonly)

Returns the length of the Other Data. Should be zero.

print "other size = ", rr.other_size, "\n"


85
86
87
# File 'lib/dnsruby/resource/TKEY.rb', line 85

def other_size
  @other_size
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



152
153
154
155
156
157
158
159
160
# File 'lib/dnsruby/resource/TKEY.rb', line 152

def self.decode_rdata(msg) #:nodoc: all
  alg=msg.get_name
  inc, exp, mode, error  = msg.get_unpack("NNnn")
  key_size, =msg.get_unpack("n")
  key=msg.get_bytes(key_size)
  other_size, =msg.get_unpack("n")
  other=msg.get_bytes(other_size)
  return self.new([alg, inc, exp, mode, error, key_size, key, other_size, other])
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



143
144
145
146
147
148
149
150
# File 'lib/dnsruby/resource/TKEY.rb', line 143

def encode_rdata(msg, canonical=false) #:nodoc: all
  msg.put_name(@algorithm, canonical)
  msg.put_pack("NNnn", @inception, @expiration, @mode, @error)
  msg.put_pack("n", @key.length)
  msg.put_bytes(@key)
  msg.put_pack("n", @other_data.length)
  msg.put_bytes(@other_data)
end

#from_data(data) ⇒ Object

:nodoc: all



119
120
121
# File 'lib/dnsruby/resource/TKEY.rb', line 119

def from_data(data) #:nodoc: all
  @algorithm, @inception, @expiration, @mode, @error, @key_size, @key, @other_size, @other_data = data
end

#from_hash(hash) ⇒ Object



112
113
114
115
116
117
# File 'lib/dnsruby/resource/TKEY.rb', line 112

def from_hash(hash)
  super(hash)
  if (algorithm)
  @algorithm = Name.create(hash[:algorithm])
  end
end

#from_string(string) ⇒ Object

Create the RR from a standard string



124
125
126
# File 'lib/dnsruby/resource/TKEY.rb', line 124

def from_string(string) #:nodoc: all
  Dnsruby.log.error("Dnsruby::RR::TKEY#from_string called, but no text format defined for TKEY")
end

#rdata_to_stringObject



128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/dnsruby/resource/TKEY.rb', line 128

def rdata_to_string
  rdatastr=""

  if (@algorithm!=nil)
    error = @error
    error = "UNDEFINED" unless error!=nil
    rdatastr = "#{@algorithm.to_s(true)} #{error}"
    if (@other_size != nil && @other_size >0 && @other_data!=nil)
      rdatastr += " #{@other_data}"
    end
  end

  return rdatastr
end