trisulrp 1.5.7 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/trisulrp/guids.rb +11 -11
- data/lib/trisulrp/keys.rb +271 -269
- data/lib/trisulrp/protocol.rb +296 -292
- data/lib/trisulrp/trp.pb.rb +10 -1
- data/lib/trisulrp/trp.proto +11 -2
- data/lib/trisulrp/utils.rb +111 -111
- data/trisulrp.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.8
|
data/lib/trisulrp/guids.rb
CHANGED
@@ -9,8 +9,8 @@ module TrisulRP::Guids
|
|
9
9
|
CG_EXTERNAL_HOST = "{00AA77BB-0063-11A5-8380-FEBDBABBDBEA}" # Hosts outside HOME NETWORK
|
10
10
|
CG_INTERNAL_HOST = "{889900CC-0063-11A5-8380-FEBDBABBDBEA}" # Hosts in HOME NETWORK
|
11
11
|
CG_WEB_HOST = "{EEF95297-0C8D-4673-AD6B-F4BD2345FD69}" # Hosts talking HTTP/HTTPS
|
12
|
-
CG_EMAIL_HOST
|
13
|
-
CG_SSH_HOST
|
12
|
+
CG_EMAIL_HOST = "{22D4082E-B8BA-40D0-A287-1F524DF8DA7B}" # Hosts with Email traffic
|
13
|
+
CG_SSH_HOST = "{439002E4-3758-4E88-9438-8034FE1616AF}" # Hosts with SSH traffic
|
14
14
|
CG_UNUSUAL_TRAFFIC_HOSTS = "{AE3A1449-5663-41A5-A028-FDE61DBB7EFA}" # Hosts with Unusual traffic
|
15
15
|
CG_SUBNET = "{429B65AD-CDA4-452E-A852-24D8A3D0FBB3}" # Stats for configured IP Subnets
|
16
16
|
CG_INTERFACE = "{8AC478BC-8891-0009-5F31-80774B010086}" # Per interface statistics
|
@@ -20,18 +20,18 @@ module TrisulRP::Guids
|
|
20
20
|
CG_META_COUNTER_GROUP = "{4D88CC23-2883-4DEA-A313-A23B60FE8BDA}" # Second order stats for counters
|
21
21
|
CG_META_SESSION_GROUP = "{594606BD-EEB2-4E0B-BAC4-84B7057088C8}" # Second order stats for flow activity
|
22
22
|
CG_FLOWGENS = "{2314BB8E-2BCC-4B86-8AA2-677E5554C0FE}" # Flow generator traffic
|
23
|
-
CG_FLOWINTFS
|
24
|
-
CG_HTTP_HOSTS
|
23
|
+
CG_FLOWINTFS = "{C0B04CA7-95FA-44EF-8475-3835F3314761}" # Flow interface traffic
|
24
|
+
CG_HTTP_HOSTS = "{D2AAD7C6-E129-4366-A2AD-A8CB9AA4C2F4}" # Traffic by HTTP Host Headers
|
25
25
|
CG_HTTP_CONTENT_TYPES = "{C0C9757F-2005-4CC5-BB96-D72F607E6188}" # Traffic by HTTP Content Types
|
26
|
-
CG_MAC
|
26
|
+
CG_MAC = "{4B09BD22-3B99-40FC-8215-94A430EA0A35}" # Traffic per Ethernet MAC
|
27
27
|
CG_LINKLAYERSTATS = "{9F5AD3A9-C74D-46D8-A8A8-DCDD773730BA}" # Breakdown of activity at link layer
|
28
28
|
CG_NETWORKLAYERSTATS = "{E89BCD56-30AD-40F5-B1C8-8B7683F440BD}" # Breakdown of activity at network layer
|
29
|
-
CG_VSAT
|
30
|
-
CG_VLANSTATS
|
31
|
-
CG_HOSTSIPV6
|
32
|
-
CG_TLSORG
|
33
|
-
CG_TLSCIPHER
|
34
|
-
CG_TLSCA
|
29
|
+
CG_VSAT = "{A8776788-B8E3-4108-AD24-0E3927D9364B}" # Traffic per VSAT
|
30
|
+
CG_VLANSTATS = "{0EC72E9E-3AD2-43FD-8173-74693EEA08D0}" # Per VLAN Activity Monitor
|
31
|
+
CG_HOSTSIPV6 = "{6CD742B1-C1CA-4708-BE78-0FCA2EB01A86}" # Stats for each IPv6 Host
|
32
|
+
CG_TLSORG = "{432D7552-0363-4640-9CC5-23E4CA8410EA}" # TLS Organization
|
33
|
+
CG_TLSCIPHER = "{5B64A573-623F-4F5B-8865-78C62BF466A7}" # TLS Ciphersuite
|
34
|
+
CG_TLSCA = "{15856A98-7F87-46D7-84D2-18DD549F8A6F}" # TLS Cert Authority
|
35
35
|
|
36
36
|
|
37
37
|
AG_IDS = "{9AFD8C08-07EB-47E0-BF05-28B4A7AE8DC9}" # Track IDS Alerts
|
data/lib/trisulrp/keys.rb
CHANGED
@@ -3,305 +3,307 @@
|
|
3
3
|
module TrisulRP::Keys
|
4
4
|
|
5
5
|
class Null
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def self.xform(kstring)
|
7
|
+
yield kstring if block_given?
|
8
|
+
kstring
|
9
|
+
end
|
10
10
|
end
|
11
11
|
|
12
12
|
class HNumber
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
13
|
+
# key to human string
|
14
|
+
# => width unused
|
15
|
+
# => kstring = hex number like A011
|
16
|
+
# output is a decimal number
|
17
|
+
def self.xform(kstring)
|
18
|
+
ret = kstring.hex.to_s
|
19
|
+
yield ret if block_given?
|
20
|
+
ret
|
21
|
+
end
|
22
|
+
|
23
|
+
# human string to key
|
24
|
+
# => width padding eg to output 000B when input = 11 and field is a 2 byte
|
25
|
+
# => dstring input decimal
|
26
|
+
def self.invert_xform(width,dstring)
|
27
|
+
ret = dstring.to_i.to_s(16).rjust(width,"0").upcase
|
28
|
+
yield ret if block_given?
|
29
|
+
ret
|
30
|
+
end
|
31
|
+
|
32
|
+
# is_key_pattern?
|
33
|
+
def self.is_key_form? patt
|
34
|
+
return false if patt.nil?
|
35
|
+
[2,4,8].member? patt.length and patt =~ /(\d|[a-f]|[A-F])+/
|
36
|
+
end
|
37
|
+
|
38
|
+
# is_human_pattern?
|
39
|
+
def self.is_human_form? patt
|
40
|
+
patt.to_i > 0 or patt.squeeze("0") == "0"
|
41
|
+
end
|
42
42
|
end
|
43
43
|
|
44
44
|
|
45
45
|
class Host
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
46
|
+
# key to human string
|
47
|
+
def self.xform(kstring)
|
48
|
+
ret = kstring.split('.').collect { |hexbyte| hexbyte.hex.to_s }.join('.')
|
49
|
+
yield ret if block_given?
|
50
|
+
ret
|
51
|
+
end
|
52
|
+
|
53
|
+
# human string to key
|
54
|
+
def self.invert_xform(dstring)
|
55
|
+
ret = dstring.split('.').collect { |decbyte| decbyte.to_i.to_s(16).rjust(2,"00").upcase}.join('.')
|
56
|
+
yield ret if block_given?
|
57
|
+
ret
|
58
|
+
end
|
59
|
+
|
60
|
+
# is_key_pattern?
|
61
|
+
def self.is_key_form? patt
|
62
|
+
return false if patt.nil?
|
63
|
+
patt.length == 11 and (patt[2] == "." || patt[5] == "." || patt[8] == ".")
|
64
|
+
end
|
65
|
+
|
66
|
+
# is_human_pattern?
|
67
|
+
def self.is_human_form? patt
|
68
|
+
patt.split('.').select { |szbyte| (1..255).cover?(szbyte.to_i) or szbyte.squeeze("0") == "0" }.size == 4
|
69
|
+
end
|
70
70
|
end
|
71
71
|
|
72
72
|
# UDP/TCP port a 2 byte number
|
73
73
|
class Port
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# is_key_form?
|
96
|
-
def self.is_key_form? patt
|
97
|
-
return false if patt.nil?
|
98
|
-
patt.length == 6 and patt[0] == 'p' and patt[1] == '-'
|
99
|
-
end
|
100
|
-
|
101
|
-
# is_human_form?
|
102
|
-
def self.is_human_form? patt
|
103
|
-
patt[0..4].upcase == "PORT-" and ((1..65535).include? patt[5..-1].to_i)
|
75
|
+
# key to human string
|
76
|
+
def self.xform(kstring)
|
77
|
+
s = "Port-" + kstring[2..-1].hex.to_s
|
78
|
+
yield s if block_given?
|
79
|
+
return s
|
80
|
+
end
|
81
|
+
|
82
|
+
# human string to key
|
83
|
+
# handles formats
|
84
|
+
# => Port-80
|
85
|
+
# => port-80
|
86
|
+
# => 80
|
87
|
+
def self.invert_xform(dstring)
|
88
|
+
if dstring.size > 5 and dstring[0..4].upcase == "PORT-"
|
89
|
+
return "p-"+dstring.slice(5..-1).to_i.to_s(16).rjust(4,"0000").upcase
|
90
|
+
else
|
91
|
+
return "p-"+dstring.to_i.to_s(16).rjust(4,"0000").upcase
|
104
92
|
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# is_key_form?
|
96
|
+
def self.is_key_form? patt
|
97
|
+
return false if patt.nil?
|
98
|
+
patt.length == 6 and patt[0] == 'p' and patt[1] == '-'
|
99
|
+
end
|
100
|
+
|
101
|
+
# is_human_form?
|
102
|
+
def self.is_human_form? patt
|
103
|
+
patt[0..4].upcase == "PORT-" and ((1..65535).include? patt[5..-1].to_i)
|
104
|
+
end
|
105
105
|
end
|
106
106
|
|
107
107
|
class Subnet
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
108
|
+
# key to human string
|
109
|
+
# => key - 00.00.00.00_8888
|
110
|
+
def self.xform(kstring)
|
111
|
+
parts=kstring.split('/')
|
112
|
+
ret = Host.xform(parts[0]) + "/" + HNumber.xform(parts[1])
|
113
|
+
yield ret if block_given?
|
114
|
+
ret
|
115
|
+
end
|
116
|
+
|
117
|
+
# human string to key
|
118
|
+
def self.invert_xform(dstring)
|
119
|
+
parts=dstring.split('/')
|
120
|
+
ret = Host.invert_xform(parts[0]) + "/" + HNumber.invert_xform(2,parts[1])
|
121
|
+
yield ret if block_given?
|
122
|
+
ret
|
123
|
+
end
|
124
|
+
|
125
|
+
# is_key_pattern?
|
126
|
+
def self.is_key_form? patt
|
127
|
+
return false if patt.nil?
|
128
|
+
parts = patt.split('/')
|
129
|
+
parts.size == 2 and Host.is_key_form?(parts[0]) and HNumber.is_key_form?(parts[1])
|
130
|
+
end
|
131
|
+
|
132
|
+
# is_human_pattern?
|
133
|
+
def self.is_human_form? patt
|
134
|
+
parts = patt.split('/')
|
135
|
+
parts.size == 2 and Host.is_human_form?(parts[0]) and HNumber.is_human_form?(parts[1])
|
136
|
+
end
|
137
137
|
end
|
138
138
|
|
139
139
|
|
140
140
|
class HostInterface
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
141
|
+
# key to human string
|
142
|
+
# => key - 00.00.00.00/10
|
143
|
+
def self.xform(kstring)
|
144
|
+
parts=kstring.split('_')
|
145
|
+
ret = Host.xform(parts[0]) + "_" + HNumber.xform(parts[1])
|
146
|
+
yield ret if block_given?
|
147
|
+
ret
|
148
|
+
end
|
149
|
+
|
150
|
+
# human string to key
|
151
|
+
def self.invert_xform(dstring)
|
152
|
+
parts=dstring.split('_')
|
153
|
+
ret = Host.invert_xform(parts[0]) + "_" + HNumber.invert_xform(4,parts[1])
|
154
|
+
yield ret if block_given?
|
155
|
+
ret
|
156
|
+
end
|
157
|
+
|
158
|
+
# is_key_pattern?
|
159
|
+
def self.is_key_form? patt
|
160
|
+
return false if patt.nil?
|
161
|
+
parts = patt.split('_')
|
162
|
+
parts.size == 2 and Host.is_key_form?(parts[0]) and HNumber.is_key_form?(parts[1])
|
163
|
+
end
|
164
|
+
|
165
|
+
# is_human_pattern?
|
166
|
+
def self.is_human_form? patt
|
167
|
+
parts = patt.split('_')
|
168
|
+
parts.size == 2 and Host.is_human_form?(parts[0]) and HNumber.is_human_form?(parts[1])
|
169
|
+
end
|
170
170
|
end
|
171
171
|
|
172
172
|
# key and human form are same
|
173
173
|
class ASNumber
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
174
|
+
# key to human string
|
175
|
+
# => key - ASnnn
|
176
|
+
def self.xform(kstring)
|
177
|
+
yield kstring if block_given?
|
178
|
+
kstring
|
179
|
+
end
|
180
|
+
|
181
|
+
# human string to key
|
182
|
+
def self.invert_xform(dstring)
|
183
|
+
yield dstring if block_given?
|
184
|
+
dstring
|
185
|
+
end
|
186
|
+
|
187
|
+
# is_key_pattern?
|
188
|
+
def self.is_key_form? patt
|
189
|
+
return false if patt.nil?
|
190
|
+
patt[0..1]=="AS"
|
191
|
+
end
|
192
|
+
|
193
|
+
# is_human_pattern?
|
194
|
+
def self.is_human_form? patt
|
195
|
+
return false if patt.nil?
|
196
|
+
patt[0..1]=="AS"
|
197
|
+
end
|
198
|
+
end
|
186
199
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
200
|
+
# convert a trisul key format into a human readable key
|
201
|
+
# [keyform] the key form
|
202
|
+
#
|
203
|
+
# ==== Typical use
|
204
|
+
#
|
205
|
+
# Used to convert an IP / Port or any other trisul key into a readable form
|
206
|
+
#
|
207
|
+
# <code>
|
208
|
+
#
|
209
|
+
# make_readable("C0.A8.0C.A0") => "192.168.12.160"
|
210
|
+
#
|
211
|
+
# make_readable("p-0016") => "Port-22"
|
212
|
+
#
|
213
|
+
# </code>
|
214
|
+
#
|
215
|
+
#
|
216
|
+
#
|
217
|
+
# Also see TrisulRP::Protocol::get_labels_for_keys to obtain a text name for the key
|
218
|
+
#
|
219
|
+
# Also see the inverse of this method make_key which convert a readable string into a key
|
220
|
+
# suitable for use in TRP request messages.
|
221
|
+
#
|
222
|
+
# If key type cannot be accurately guessed it returns the input
|
223
|
+
#
|
224
|
+
def make_readable(keyform)
|
225
|
+
[ TrisulRP::Keys::Port,
|
226
|
+
TrisulRP::Keys::Host,
|
227
|
+
TrisulRP::Keys::HostInterface,
|
228
|
+
TrisulRP::Keys::Subnet,
|
229
|
+
TrisulRP::Keys::ASNumber
|
230
|
+
].each do |kls|
|
231
|
+
return kls.xform(keyform) if kls.is_key_form?(keyform)
|
191
232
|
end
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
233
|
+
return keyform
|
234
|
+
end
|
235
|
+
|
236
|
+
|
237
|
+
# convert a key in human form into trisul key format
|
238
|
+
#
|
239
|
+
# [humanform] the human form of the key
|
240
|
+
#
|
241
|
+
# ==== Typical use
|
242
|
+
#
|
243
|
+
# Used to convert a human form key into a Trisul Key format suitable for use with TRP requests
|
244
|
+
#
|
245
|
+
#
|
246
|
+
# <code>
|
247
|
+
#
|
248
|
+
# make_key("192.168.1.1") => "C0.A8.01.01"
|
249
|
+
#
|
250
|
+
# </code>
|
251
|
+
#
|
252
|
+
#
|
253
|
+
# Also see the inverse of this method make_readable
|
254
|
+
#
|
255
|
+
#
|
256
|
+
def make_key(readable)
|
257
|
+
[ TrisulRP::Keys::Port,
|
258
|
+
TrisulRP::Keys::Host,
|
259
|
+
TrisulRP::Keys::HostInterface,
|
260
|
+
TrisulRP::Keys::Subnet,
|
261
|
+
TrisulRP::Keys::ASNumber
|
262
|
+
].each do |kls|
|
263
|
+
return kls.invert_xform(readable) if kls.is_human_form?(readable)
|
197
264
|
end
|
198
|
-
|
199
|
-
|
200
|
-
# convert a trisul key format into a human readable key
|
201
|
-
# [keyform] the key form
|
202
|
-
#
|
203
|
-
# ==== Typical use
|
204
|
-
#
|
205
|
-
# Used to convert an IP / Port or any other trisul key into a readable form
|
206
|
-
#
|
207
|
-
# <code>
|
208
|
-
#
|
209
|
-
# make_readable("C0.A8.0C.A0") => "192.168.12.160"
|
210
|
-
#
|
211
|
-
# make_readable("p-0016") => "Port-22"
|
212
|
-
#
|
213
|
-
# </code>
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
217
|
-
# Also see TrisulRP::Protocol::get_labels_for_keys to obtain a text name for the key
|
218
|
-
#
|
219
|
-
# Also see the inverse of this method make_key which convert a readable string into a key
|
220
|
-
# suitable for use in TRP request messages.
|
221
|
-
#
|
222
|
-
# If key type cannot be accurately guessed it returns the input
|
223
|
-
#
|
224
|
-
def make_readable(keyform)
|
225
|
-
[ TrisulRP::Keys::Port,
|
226
|
-
TrisulRP::Keys::Host,
|
227
|
-
TrisulRP::Keys::HostInterface,
|
228
|
-
TrisulRP::Keys::Subnet,
|
229
|
-
TrisulRP::Keys::ASNumber
|
230
|
-
].each do |kls|
|
231
|
-
return kls.xform(keyform) if kls.is_key_form?(keyform)
|
232
|
-
end
|
233
|
-
return keyform
|
234
|
-
end
|
235
|
-
|
236
|
-
|
237
|
-
# convert a key in human form into trisul key format
|
238
|
-
#
|
239
|
-
# [humanform] the human form of the key
|
240
|
-
#
|
241
|
-
# ==== Typical use
|
242
|
-
#
|
243
|
-
# Used to convert a human form key into a Trisul Key format suitable for use with TRP requests
|
244
|
-
#
|
245
|
-
#
|
246
|
-
# <code>
|
247
|
-
#
|
248
|
-
# make_key("192.168.1.1") => "C0.A8.01.01"
|
249
|
-
#
|
250
|
-
# </code>
|
251
|
-
#
|
252
|
-
#
|
253
|
-
# Also see the inverse of this method make_readable
|
254
|
-
#
|
255
|
-
#
|
256
|
-
def make_key(readable)
|
257
|
-
[ TrisulRP::Keys::Port,
|
258
|
-
TrisulRP::Keys::Host,
|
259
|
-
TrisulRP::Keys::HostInterface,
|
260
|
-
TrisulRP::Keys::Subnet,
|
261
|
-
TrisulRP::Keys::ASNumber
|
262
|
-
].each do |kls|
|
263
|
-
return kls.invert_xform(readable) if kls.is_human_form?(readable)
|
264
|
-
end
|
265
|
-
return readable
|
266
|
-
end
|
265
|
+
return readable
|
266
|
+
end
|
267
267
|
|
268
268
|
|
269
269
|
# convert a set of keys into labels
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
270
|
+
#
|
271
|
+
# This method accepts an array of keys (which are references to counter items in Trisul) and sends
|
272
|
+
# a key lookup request to Trisul. Trisul responds with labels for those keys that had labels. Finally a
|
273
|
+
# ready to use map is constructed and returned to the caller.
|
274
|
+
#
|
275
|
+
# [conn] a TRP connection opened earlier via connect(..)
|
276
|
+
# [cgguid] a counter group id. See TrisulRP::Guids for a list of common guids
|
277
|
+
# [key_arr] an array of keys, possibly obtained as a result of an earlier command
|
278
|
+
#
|
279
|
+
# ==== Returns
|
280
|
+
# a hash of Key => Label. All keys in the incoming array will have a hash entry. If Trisul could not
|
281
|
+
# find a label for a key, it will store the key itself as the hash value.
|
282
|
+
#
|
283
|
+
# ==== Typical usage
|
284
|
+
#
|
285
|
+
# You use this method as a bulk resolving mechanism.
|
286
|
+
# <code>
|
287
|
+
#
|
288
|
+
# host_keys = ["0A.0A.18.E0", "B1.01.8F.01",...]
|
289
289
|
# host_names = TrisulRP::Protocol.get_labels_for_keys(conn,
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
290
|
+
# TrisulRP::Guids::CG_HOSTS, host_keys)
|
291
|
+
#
|
292
|
+
# host_names["0A.0A.18.E0"] = "demo.trisul.org" # ok
|
293
|
+
# host_names["B1.01.8F.01"] = "B1.01.8F.01" # no label for this key
|
294
|
+
#
|
295
|
+
# </code>
|
296
|
+
#
|
297
|
+
def get_labels_for_keys(conn, cgguid, key_arr)
|
298
|
+
req = mk_request(TRP::Message::Command::KEY_LOOKUP_REQUEST,
|
299
|
+
:counter_group => cgguid,
|
300
|
+
:keys => key_arr.uniq )
|
301
|
+
|
302
|
+
h = key_arr.inject({}) { |m,i| m.store(i,make_readable(i)); m }
|
303
|
+
get_response(conn,req) do |resp|
|
304
|
+
resp.key_details.each { |d| h.store(d.key,d.label) }
|
305
|
+
end
|
306
|
+
return h
|
307
|
+
end
|
306
308
|
|
307
309
|
end
|