| Class | Dnsruby::RR::IPSECKEY |
| In: |
lib/Dnsruby/resource/IPSECKEY.rb
|
| Parent: | RR |
| TypeValue | = | Types::IPSECKEY #:nodoc: all |
| algorithm | [RW] |
The algorithm used by this key :
0 - no key present 1 - DSA key present 2 - RSA key present |
| gateway | [RW] | The gateway. May either be a 32-bit network order IPv4 address, or a 128-bit IPv6 address, or a domain name, or may not be present. |
| gateway_type | [RW] |
Specifies the type of gateway :
0 - no gateway present 1 - 4 byte IPv4 address present 2 - 16 byte IPv6 address present 3 - wire-encoded domain name present |
| precedence | [RW] | An 8-bit precedence for this field. Lower values are preferred. |
# File lib/Dnsruby/resource/IPSECKEY.rb, line 53
53: def from_hash(hash)
54: @precedence = hash[:precedence]
55: @gateway_type = hash[:gateway_type]
56: @algorithm = hash[:algorithm]
57: @gateway = load_gateway_from_string(@gateway_type, hash[:gateway])
58: @public_key = hash[:public_key]
59: end
# File lib/Dnsruby/resource/IPSECKEY.rb, line 88
88: def from_string(input)
89: if (input.length > 0)
90: split = input.split(" ")
91:
92: @precedence = split[0].to_i
93: @gateway_type = split[1].to_i
94: @algorithm = split[2].to_i
95:
96: @gateway = load_gateway_from_string(@gateway_type, split[3])
97:
98: @public_key = public_key_from_string(split[4])
99: end
100: end
# File lib/Dnsruby/resource/IPSECKEY.rb, line 61
61: def load_gateway_from_string(gateway_type, s)
62: gateway = nil
63: if (gateway_type == 0)
64: gateway = nil
65: elsif (gateway_type == 1)
66: # Load IPv4 gateway
67: gateway = IPv4.create(s)
68: elsif (gateway_type == 2)
69: # Load IPv6 gateway
70: gateway = IPv6.create(s)
71: else
72: # Load gateway domain name
73: gateway = Name.create(s)
74: end
75: return gateway
76: end
# File lib/Dnsruby/resource/IPSECKEY.rb, line 82
82: def public_key_from_string(key_text)
83: key_text.gsub!(/\n/, "")
84: key_text.gsub!(/ /, "")
85: return key_text.unpack("m*")[0]
86: end