rslp 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +16 -0
- data/Gemfile +2 -3
- data/README.md +11 -6
- data/lib/rslp.rb +110 -69
- data/lib/slp/functions.rb +40 -11
- data/lib/slp/structs.rb +28 -2
- data/rslp.gemspec +8 -7
- data/spec/rslp_spec.rb +66 -23
- data.tar.gz.sig +0 -0
- metadata +4 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d18a5f649a8f64234f0ca36681d7700bc82c6f92d6f92fb7de5a15a3e0c9a75
|
4
|
+
data.tar.gz: 445016807c2bb1f53192df312f86e8da65948e2c5f634f16cb5fd91fcd49df10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2150dfc89eae6d2a403151bcc6d4e1e683733225702cbd7e51cb2f6fc7d90e1e3b25504b2536d14a03fa629acb1fa4a8a093e6c45d72964feec43eac367fa94
|
7
|
+
data.tar.gz: 5051e0ec6e22438ada2b92729c64465b307201d0baf60a996627cf429efa2fbdb246ce602eeb627a29db60362bbd65944195d7ef46a7ef89880b052770572cbc
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
CHANGED
@@ -1,2 +1,18 @@
|
|
1
|
+
## 0.1.0 - 19-Oct-2022
|
2
|
+
* Updated the constructor, now uses keyword arguments.
|
3
|
+
* Constructor now accepts a hostname, or a comma separate lists of hosts.
|
4
|
+
* Added the set_app_property_file singleton method.
|
5
|
+
* Changed the deregister method to return the url.
|
6
|
+
* Minor refactoring of callback procs.
|
7
|
+
|
8
|
+
## 0.0.2 - 12-Oct-2022
|
9
|
+
* Fixed the parse_service_url singleton method. The underlying SLPSrvURL
|
10
|
+
struct is now a managed struct.
|
11
|
+
* Added some nicer method aliases to the SLPSrvURL struct.
|
12
|
+
* Refactored the underlying C function wrappers to return an SLPError enum
|
13
|
+
to more closely align with the API.
|
14
|
+
* Any internal function failures now raise an OpenSLP::SLP::Error instead
|
15
|
+
of a SystemCallError. The error message has also been improved.
|
16
|
+
|
1
17
|
## 0.0.1 - 2-Jul-2021
|
2
18
|
* Initial release
|
data/Gemfile
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
end
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gemspec
|
data/README.md
CHANGED
@@ -4,14 +4,18 @@ A Ruby wrapper for OpenSLP using FFI.
|
|
4
4
|
## Installation
|
5
5
|
`gem install rslp`
|
6
6
|
|
7
|
+
## Adding the trusted cert
|
8
|
+
`gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/rslp/main/certs/djberg96_pub.pem)`
|
9
|
+
|
7
10
|
## Synopsis
|
8
11
|
```ruby
|
9
12
|
require 'rslp'
|
10
13
|
|
14
|
+
# See docs for more methods
|
11
15
|
OpenSLP::SLP.new do |slp|
|
12
|
-
|
13
|
-
p slp.find_services
|
16
|
+
p slp.find_services('myservice:myorg')
|
14
17
|
p slp.find_scopes
|
18
|
+
p slp.find_service_types
|
15
19
|
end
|
16
20
|
```
|
17
21
|
|
@@ -25,18 +29,19 @@ None at this time.
|
|
25
29
|
|
26
30
|
## Maintenance
|
27
31
|
Please contact me about taking over maintenance of this library if you are
|
28
|
-
interested. I'm not actually using it myself,
|
29
|
-
|
32
|
+
interested. I'm not actually using it myself, so maintenance and releases
|
33
|
+
will be sporadic at best.
|
30
34
|
|
31
35
|
Why then? I originally wrote most of this when I thought we might need it
|
32
36
|
for a project at work. That never materialized, but I hated to let it go to
|
33
|
-
waste, so I've published what I completed
|
37
|
+
waste, so I've published what I completed and may occasionally tinker with
|
38
|
+
it from time to time.
|
34
39
|
|
35
40
|
## License
|
36
41
|
Apache-2.0
|
37
42
|
|
38
43
|
## Copyright
|
39
|
-
(C) 2003-
|
44
|
+
(C) 2003-2022 Daniel J. Berger, All Rights Reserved
|
40
45
|
|
41
46
|
## Warranty
|
42
47
|
This package is provided "as is" and without any express or
|
data/lib/rslp.rb
CHANGED
@@ -11,7 +11,10 @@ module OpenSLP
|
|
11
11
|
extend OpenSLP::Functions
|
12
12
|
|
13
13
|
# The version of the rslp library.
|
14
|
-
VERSION = '0.0
|
14
|
+
VERSION = '0.1.0'.freeze
|
15
|
+
|
16
|
+
# Internal error raised whenever an openslp function fails.
|
17
|
+
class Error < StandardError; end
|
15
18
|
|
16
19
|
# The language tag for requests.
|
17
20
|
attr_reader :lang
|
@@ -27,34 +30,51 @@ module OpenSLP
|
|
27
30
|
# machine's locale.
|
28
31
|
#
|
29
32
|
# The +async+ argument may be set to true or false and establishes whether
|
30
|
-
# the underlying handle is set to
|
33
|
+
# the underlying handle is set to handle asynchronous operations or not. By
|
31
34
|
# default this value is false.
|
32
35
|
#
|
36
|
+
# The +host+ argument, if present, will associate the Host/IP with the OpenSLP
|
37
|
+
# handle. This is the Hostname/IP address of the Service Agent / Directory Agent
|
38
|
+
# from # which service is requested. For multicast, use a comma separated list of
|
39
|
+
# Hostnames/IP addresses.
|
40
|
+
#
|
33
41
|
# If a block is given, then the object itself is yielded to the block, and
|
34
42
|
# it is automatically closed at the end of the block.
|
35
43
|
#
|
36
44
|
# Examples:
|
37
45
|
#
|
38
|
-
#
|
46
|
+
# # Block form
|
47
|
+
# OpenSLP::SLP.new(lang: 'en-us', async: false, host: 'localhost') do |slp|
|
39
48
|
# # ... do stuff
|
40
49
|
# end
|
41
50
|
#
|
42
|
-
#
|
51
|
+
# # Non-block form
|
52
|
+
# slp = OpenSLP::SLP.new(lang: 'en-us')
|
43
53
|
# # Do stuff
|
44
54
|
# slp.close
|
45
55
|
#
|
46
|
-
def initialize(lang
|
56
|
+
def initialize(lang: '', async: false, host: nil)
|
47
57
|
@lang = lang
|
48
58
|
@async = async
|
59
|
+
@host = host
|
49
60
|
|
50
61
|
ptr = FFI::MemoryPointer.new(:ulong)
|
51
62
|
|
52
|
-
|
53
|
-
|
54
|
-
end
|
63
|
+
result = SLPOpen(lang, async, ptr)
|
64
|
+
raise Error, "SLPOpen(): #{result}" if result != :SLP_OK
|
55
65
|
|
56
66
|
@handle = ptr.read_ulong
|
57
67
|
|
68
|
+
if @host
|
69
|
+
if @host.split(',').size > 1
|
70
|
+
result = SLPAssociateIFList(@handle, @host)
|
71
|
+
raise Error, "SLPAssociateIFList(): #{result}" if result != :SLP_OK
|
72
|
+
else
|
73
|
+
result = SLPAssociateIP(@handle, @host)
|
74
|
+
raise Error, "SLPAssociateIP(): #{result}" if result != :SLP_OK
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
58
78
|
if block_given?
|
59
79
|
begin
|
60
80
|
yield self
|
@@ -88,7 +108,7 @@ module OpenSLP
|
|
88
108
|
options[:attributes] ||= ""
|
89
109
|
options[:fresh] ||= true
|
90
110
|
|
91
|
-
options[:callback] ||= Proc.new{ |
|
111
|
+
options[:callback] ||= Proc.new{ |_hslp, err, _cookie| }
|
92
112
|
|
93
113
|
if options[:attributes] && options[:attributes] != ""
|
94
114
|
attributes = options[:attributes].map{ |k,v| "(#{k}=#{v})" }.join(',')
|
@@ -96,20 +116,24 @@ module OpenSLP
|
|
96
116
|
attributes = ""
|
97
117
|
end
|
98
118
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
119
|
+
begin
|
120
|
+
cookie = FFI::MemoryPointer.new(:void)
|
121
|
+
|
122
|
+
result = SLPReg(
|
123
|
+
@handle,
|
124
|
+
options[:url],
|
125
|
+
options[:lifetime],
|
126
|
+
nil,
|
127
|
+
attributes,
|
128
|
+
options[:fresh],
|
129
|
+
options[:callback],
|
130
|
+
cookie
|
131
|
+
)
|
132
|
+
|
133
|
+
raise Error, "SLPReg(): #{result}" if result != :SLP_OK
|
134
|
+
ensure
|
135
|
+
cookie.free unless cookie.null?
|
136
|
+
end
|
113
137
|
|
114
138
|
options[:url]
|
115
139
|
end
|
@@ -118,13 +142,17 @@ module OpenSLP
|
|
118
142
|
# is registered and all language locales.
|
119
143
|
#
|
120
144
|
def deregister(url)
|
121
|
-
callback = Proc.new{ |
|
122
|
-
cookie = FFI::MemoryPointer.new(:void)
|
145
|
+
callback = Proc.new{ |_hslp, err, _cookie| }
|
123
146
|
|
124
|
-
|
125
|
-
|
147
|
+
begin
|
148
|
+
cookie = FFI::MemoryPointer.new(:void)
|
149
|
+
result = SLPDereg(@handle, url, callback, cookie)
|
150
|
+
raise Error, "SLPDereg(): #{result}" if result != :SLP_OK
|
151
|
+
ensure
|
152
|
+
cookie.free unless cookie.null?
|
153
|
+
end
|
126
154
|
|
127
|
-
|
155
|
+
url
|
128
156
|
end
|
129
157
|
|
130
158
|
# Deletes specified attributes from a registered service. The attributes
|
@@ -135,10 +163,14 @@ module OpenSLP
|
|
135
163
|
#
|
136
164
|
def delete_service_attributes(url, attributes)
|
137
165
|
callback = Proc.new{ |hslp, err, cookie| }
|
138
|
-
cookie = FFI::MemoryPointer.new(:void)
|
139
166
|
|
140
|
-
|
141
|
-
|
167
|
+
begin
|
168
|
+
cookie = FFI::MemoryPointer.new(:void)
|
169
|
+
result = SLPDelAttrs(@handle, url, attributes, callback, cookie)
|
170
|
+
raise Error, "SLPDelAttrs(): #{result}" if result != :SLP_OK
|
171
|
+
ensure
|
172
|
+
cookie.free unless cookie.null?
|
173
|
+
end
|
142
174
|
|
143
175
|
attributes
|
144
176
|
end
|
@@ -150,16 +182,13 @@ module OpenSLP
|
|
150
182
|
begin
|
151
183
|
pptr = FFI::MemoryPointer.new(:pointer, 128)
|
152
184
|
|
153
|
-
|
154
|
-
|
155
|
-
if rv != SLP_OK
|
156
|
-
raise SystemCallError.new('SLPFindScopes', rv)
|
157
|
-
end
|
185
|
+
result = SLPFindScopes(@handle, pptr)
|
186
|
+
raise Error, "SLPFindScopes(): #{result}" if result != :SLP_OK
|
158
187
|
|
159
188
|
arr = pptr.read_array_of_string
|
160
189
|
ensure
|
161
190
|
SLPFree(pptr.read_pointer)
|
162
|
-
pptr.free
|
191
|
+
pptr.free unless pptr.null?
|
163
192
|
end
|
164
193
|
|
165
194
|
arr
|
@@ -177,24 +206,27 @@ module OpenSLP
|
|
177
206
|
# form of an LDAP search filter. The default is an empty string, which
|
178
207
|
# will gather all services of the requested type.
|
179
208
|
#
|
209
|
+
# The result is an array of hashes, with the URL as the key and its lifetime
|
210
|
+
# as the value.
|
211
|
+
#
|
180
212
|
def find_services(type, scope = '', filter = '')
|
181
213
|
arr = []
|
182
214
|
|
183
|
-
callback = Proc.new{ |
|
215
|
+
callback = Proc.new{ |_hslp, url, lifetime, err, _cookie|
|
184
216
|
if err == SLP_OK
|
185
|
-
arr << {url =>
|
217
|
+
arr << {url => lifetime}
|
186
218
|
true
|
187
219
|
else
|
188
220
|
false
|
189
221
|
end
|
190
222
|
}
|
191
223
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
224
|
+
begin
|
225
|
+
cookie = FFI::MemoryPointer.new(:void)
|
226
|
+
result = SLPFindSrvs(@handle, type, scope, filter, callback, cookie)
|
227
|
+
raise Error, "SLPFindSrvs(): #{result}" if result != :SLP_OK
|
228
|
+
ensure
|
229
|
+
cookie.free unless cookie.null?
|
198
230
|
end
|
199
231
|
|
200
232
|
arr
|
@@ -214,7 +246,7 @@ module OpenSLP
|
|
214
246
|
def find_service_types(auth = '*', scope = '')
|
215
247
|
arr = []
|
216
248
|
|
217
|
-
callback = Proc.new{ |
|
249
|
+
callback = Proc.new{ |_hslp, types, err, _cookie|
|
218
250
|
if err == SLP_OK
|
219
251
|
arr << types
|
220
252
|
true
|
@@ -223,12 +255,12 @@ module OpenSLP
|
|
223
255
|
end
|
224
256
|
}
|
225
257
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
258
|
+
begin
|
259
|
+
cookie = FFI::MemoryPointer.new(:void)
|
260
|
+
result = SLPFindSrvTypes(@handle, auth, scope, callback, cookie)
|
261
|
+
raise Error, "SLPFindSrvTypes(): #{result}" if result != :SLP_OK
|
262
|
+
ensure
|
263
|
+
cookie.free unless cookie.null?
|
232
264
|
end
|
233
265
|
|
234
266
|
arr
|
@@ -242,7 +274,7 @@ module OpenSLP
|
|
242
274
|
def find_service_attributes(url, attrs = '', scope = '')
|
243
275
|
arr = []
|
244
276
|
|
245
|
-
callback = Proc.new{ |
|
277
|
+
callback = Proc.new{ |_hslp, attrlist, err, _cookie|
|
246
278
|
if err == SLP_OK
|
247
279
|
arr << attrlist
|
248
280
|
true
|
@@ -251,12 +283,12 @@ module OpenSLP
|
|
251
283
|
end
|
252
284
|
}
|
253
285
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
286
|
+
begin
|
287
|
+
cookie = FFI::MemoryPointer.new(:void)
|
288
|
+
result = SLPFindAttrs(@handle, url, scope, attrs, callback, cookie)
|
289
|
+
raise Error, "SLPFindAttrs(): #{result}" if result != :SLP_OK
|
290
|
+
ensure
|
291
|
+
cookie.free unless cookie.null?
|
260
292
|
end
|
261
293
|
|
262
294
|
arr
|
@@ -292,14 +324,13 @@ module OpenSLP
|
|
292
324
|
begin
|
293
325
|
pptr = FFI::MemoryPointer.new(SLPSrvURL)
|
294
326
|
|
295
|
-
|
296
|
-
|
297
|
-
end
|
327
|
+
result = SLPParseSrvURL(url, pptr)
|
328
|
+
raise Error, "SLPParseSrvURL(): #{result}" if result != :SLP_OK
|
298
329
|
|
299
330
|
ptr = pptr.read_pointer
|
300
331
|
struct = SLPSrvURL.new(ptr)
|
301
332
|
ensure
|
302
|
-
|
333
|
+
pptr.free unless pptr.null?
|
303
334
|
end
|
304
335
|
|
305
336
|
struct
|
@@ -312,9 +343,8 @@ module OpenSLP
|
|
312
343
|
begin
|
313
344
|
pptr = FFI::MemoryPointer.new(:pointer)
|
314
345
|
|
315
|
-
|
316
|
-
|
317
|
-
end
|
346
|
+
result = SLPEscape(string, pptr, istag)
|
347
|
+
raise Error, "SLPEscape(): #{result}" if result != :SLP_OK
|
318
348
|
|
319
349
|
str = pptr.read_pointer.read_string
|
320
350
|
ensure
|
@@ -331,9 +361,8 @@ module OpenSLP
|
|
331
361
|
begin
|
332
362
|
pptr = FFI::MemoryPointer.new(:pointer)
|
333
363
|
|
334
|
-
|
335
|
-
|
336
|
-
end
|
364
|
+
result = SLPUnescape(string, pptr, istag)
|
365
|
+
raise Error, "SLPUnescape(): #{result}" if result != :SLP_OK
|
337
366
|
|
338
367
|
str = pptr.read_pointer.read_string
|
339
368
|
ensure
|
@@ -342,5 +371,17 @@ module OpenSLP
|
|
342
371
|
|
343
372
|
str
|
344
373
|
end
|
374
|
+
|
375
|
+
# Set the application-specific configuration file full path name.
|
376
|
+
#
|
377
|
+
# The contents of this property file will override the contents of the
|
378
|
+
# default or global UA configuration file (usually /etc/slp.conf or
|
379
|
+
# C:\windows\slp.conf).
|
380
|
+
#
|
381
|
+
def self.set_app_property_file(path)
|
382
|
+
result = SLPSetAppPropertyFile(string)
|
383
|
+
raise Error, "SLPSetAppPropertyFile(): #{result}" if result != :SLP_OK
|
384
|
+
path
|
385
|
+
end
|
345
386
|
end
|
346
387
|
end
|
data/lib/slp/functions.rb
CHANGED
@@ -19,6 +19,29 @@ module OpenSLP
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
SLPError = enum(
|
23
|
+
:SLP_LAST_CALL, 1,
|
24
|
+
:SLP_OK, 0,
|
25
|
+
:SLP_LANGUAGE_NOT_SUPPORTED, -1,
|
26
|
+
:SLP_PARSE_ERROR, -2,
|
27
|
+
:SLP_INVALID_REGISTRATION, -3,
|
28
|
+
:SLP_SCOPE_NOT_SUPPORTED, -4,
|
29
|
+
:SLP_AUTHENTICATION_ABSENT, -6,
|
30
|
+
:SLP_AUTHENTICATION_FAILED, -7,
|
31
|
+
:SLP_INVALID_UPDATE, -13,
|
32
|
+
:SLP_REFRESH_REJECTED, -15,
|
33
|
+
:SLP_NOT_IMPLEMENTED, -17,
|
34
|
+
:SLP_BUFFER_OVERFLOW, -18,
|
35
|
+
:SLP_NETWORK_TIMED_OUT, -19,
|
36
|
+
:SLP_NETWORK_INIT_FAILED, -20,
|
37
|
+
:SLP_MEMORY_ALLOC_FAILED, -21,
|
38
|
+
:SLP_PARAMETER_BAD, -22,
|
39
|
+
:SLP_NETWORK_ERROR, -23,
|
40
|
+
:SLP_INTERNAL_SYSTEM_ERROR, -24,
|
41
|
+
:SLP_HANDLE_IN_USE, -25,
|
42
|
+
:SLP_TYPE_ERROR, -26
|
43
|
+
)
|
44
|
+
|
22
45
|
typedef :ulong, :handle
|
23
46
|
|
24
47
|
callback :SLPSrvURLCallback, [:handle, :string, :ushort, :int, :pointer], :bool
|
@@ -26,29 +49,35 @@ module OpenSLP
|
|
26
49
|
callback :SLPAttrCallback, [:handle, :string, :int, :pointer], :bool
|
27
50
|
callback :SLPRegReportCallback, [:handle, :int, :pointer], :void
|
28
51
|
|
52
|
+
attach_function :SLPAssociateIFList, [:handle, :string], SLPError
|
53
|
+
attach_function :SLPAssociateIP, [:handle, :string], SLPError
|
29
54
|
attach_function :SLPClose, [:handle], :void
|
30
|
-
attach_function :
|
31
|
-
attach_function :
|
32
|
-
attach_function :
|
55
|
+
attach_function :SLPDelAttrs, [:handle, :string, :string, :SLPRegReportCallback, :pointer], SLPError
|
56
|
+
attach_function :SLPDereg, [:handle, :string, :SLPRegReportCallback, :pointer], SLPError
|
57
|
+
attach_function :SLPEscape, [:string, :pointer, :bool], SLPError
|
33
58
|
|
34
59
|
attach_function :SLPFindAttrs,
|
35
|
-
[:handle, :string, :string, :string, :SLPAttrCallback, :pointer],
|
60
|
+
[:handle, :string, :string, :string, :SLPAttrCallback, :pointer], SLPError
|
36
61
|
|
37
|
-
attach_function :SLPFindScopes, [:handle, :pointer],
|
62
|
+
attach_function :SLPFindScopes, [:handle, :pointer], SLPError
|
38
63
|
|
39
64
|
attach_function :SLPFindSrvs,
|
40
|
-
[:handle, :string, :string, :string, :SLPSrvURLCallback, :pointer],
|
65
|
+
[:handle, :string, :string, :string, :SLPSrvURLCallback, :pointer], SLPError
|
41
66
|
|
42
67
|
attach_function :SLPFindSrvTypes,
|
43
|
-
[:handle, :string, :string, :SLPSrvTypeCallback, :pointer],
|
68
|
+
[:handle, :string, :string, :SLPSrvTypeCallback, :pointer], SLPError
|
44
69
|
|
45
70
|
attach_function :SLPFree, [:pointer], :void
|
46
71
|
attach_function :SLPGetProperty, [:string], :string
|
47
72
|
attach_function :SLPGetRefreshInterval, [], :uint
|
48
|
-
attach_function :SLPOpen, [:string, :bool, :pointer],
|
49
|
-
attach_function :SLPParseSrvURL, [:string, :pointer],
|
50
|
-
|
73
|
+
attach_function :SLPOpen, [:string, :bool, :pointer], SLPError
|
74
|
+
attach_function :SLPParseSrvURL, [:string, :pointer], SLPError
|
75
|
+
|
76
|
+
attach_function :SLPReg,
|
77
|
+
[:handle, :string, :ushort, :string, :string, :bool, :SLPRegReportCallback, :pointer], SLPError
|
78
|
+
|
79
|
+
attach_function :SLPSetAppPropertyFile, [:string], SLPError
|
51
80
|
attach_function :SLPSetProperty, [:string, :string], :void
|
52
|
-
attach_function :SLPUnescape, [:string, :pointer, :bool],
|
81
|
+
attach_function :SLPUnescape, [:string, :pointer, :bool], SLPError
|
53
82
|
end
|
54
83
|
end
|
data/lib/slp/structs.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
require_relative 'functions'
|
2
2
|
|
3
3
|
module OpenSLP
|
4
4
|
module Structs
|
5
|
-
class SLPSrvURL < FFI::
|
5
|
+
class SLPSrvURL < FFI::ManagedStruct
|
6
|
+
extend OpenSLP::Functions
|
7
|
+
|
6
8
|
layout(
|
7
9
|
:s_pcSrvType, :string,
|
8
10
|
:s_pcHost, :string,
|
@@ -10,6 +12,30 @@ module OpenSLP
|
|
10
12
|
:s_pcNetFamily, :string,
|
11
13
|
:s_pcSrvPart, :string
|
12
14
|
)
|
15
|
+
|
16
|
+
def self.release(pointer)
|
17
|
+
SLPFree(pointer) unless pointer.null?
|
18
|
+
end
|
19
|
+
|
20
|
+
def service_type
|
21
|
+
self[:s_pcSrvType]
|
22
|
+
end
|
23
|
+
|
24
|
+
def host
|
25
|
+
self[:s_pcHost]
|
26
|
+
end
|
27
|
+
|
28
|
+
def port
|
29
|
+
self[:s_iPort]
|
30
|
+
end
|
31
|
+
|
32
|
+
def net_family
|
33
|
+
self[:s_pcNetFamily]
|
34
|
+
end
|
35
|
+
|
36
|
+
def url_remainder
|
37
|
+
self[:s_pcSrvPart]
|
38
|
+
end
|
13
39
|
end
|
14
40
|
end
|
15
41
|
end
|
data/rslp.gemspec
CHANGED
@@ -3,7 +3,7 @@ require 'rbconfig'
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'rslp'
|
6
|
-
spec.version = '0.0
|
6
|
+
spec.version = '0.1.0'
|
7
7
|
spec.license = 'Apache-2.0'
|
8
8
|
spec.author = 'Daniel J. Berger'
|
9
9
|
spec.email = 'djberg96@gmail.com'
|
@@ -21,12 +21,13 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency('rspec', "~> 3.9")
|
22
22
|
|
23
23
|
spec.metadata = {
|
24
|
-
'homepage_uri'
|
25
|
-
'bug_tracker_uri'
|
26
|
-
'changelog_uri'
|
27
|
-
'documentation_uri'
|
28
|
-
'source_code_uri'
|
29
|
-
'wiki_uri'
|
24
|
+
'homepage_uri' => 'https://github.com/djberg96/rslp',
|
25
|
+
'bug_tracker_uri' => 'https://github.com/djberg96/rslp/issues',
|
26
|
+
'changelog_uri' => 'https://github.com/djberg96/rslp/blob/main/CHANGES.md',
|
27
|
+
'documentation_uri' => 'https://github.com/djberg96/rslp/wiki',
|
28
|
+
'source_code_uri' => 'https://github.com/djberg96/rslp',
|
29
|
+
'wiki_uri' => 'https://github.com/djberg96/rslp/wiki',
|
30
|
+
'rubygems_mfa_required' => 'true'
|
30
31
|
}
|
31
32
|
|
32
33
|
spec.description = <<-EOF
|
data/spec/rslp_spec.rb
CHANGED
@@ -6,25 +6,25 @@
|
|
6
6
|
require 'rspec'
|
7
7
|
require 'rslp'
|
8
8
|
|
9
|
-
describe OpenSLP::SLP do
|
9
|
+
RSpec.describe OpenSLP::SLP do
|
10
10
|
before do
|
11
11
|
@lang = 'en-us'
|
12
|
-
@slp =
|
12
|
+
@slp = described_class.new(lang: @lang, async: false, host: 'localhost')
|
13
13
|
end
|
14
14
|
|
15
15
|
context "version" do
|
16
16
|
example "version is set to the expected value" do
|
17
|
-
expect(
|
17
|
+
expect(described_class::VERSION).to eq('0.1.0')
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
context "constructor" do
|
22
22
|
example "defaults to an empty string if no lang is provided" do
|
23
|
-
expect(
|
23
|
+
expect(described_class.new.lang).to eq('')
|
24
24
|
end
|
25
25
|
|
26
26
|
example "defaults to a false async value if no value is provided" do
|
27
|
-
expect(
|
27
|
+
expect(described_class.new.async).to be false
|
28
28
|
end
|
29
29
|
|
30
30
|
example "sets attributes to expected values" do
|
@@ -33,38 +33,81 @@ describe OpenSLP::SLP do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
describe "singleton methods" do
|
37
|
+
context "refresh_interval" do
|
38
|
+
example "defines a refresh_interval method" do
|
39
|
+
expect(described_class).to respond_to(:refresh_interval)
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
42
|
+
example "returns the expected value for refresh_interval" do
|
43
|
+
expect(described_class.refresh_interval).to eq(0)
|
44
|
+
end
|
43
45
|
end
|
44
46
|
|
45
47
|
example "defines a get_property method" do
|
46
|
-
expect(
|
48
|
+
expect(described_class).to respond_to(:get_property)
|
47
49
|
end
|
48
50
|
|
49
51
|
example "defines a set_property method" do
|
50
|
-
expect(
|
52
|
+
expect(described_class).to respond_to(:set_property)
|
51
53
|
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
context "parse_service_url" do
|
56
|
+
let(:valid_url) { "service:test.openslp://192.168.100.1:3003,en,65535" }
|
57
|
+
|
58
|
+
before do
|
59
|
+
@struct = described_class.parse_service_url(valid_url)
|
60
|
+
end
|
61
|
+
|
62
|
+
example "defines a parse_service_url method" do
|
63
|
+
expect(described_class).to respond_to(:parse_service_url)
|
64
|
+
end
|
65
|
+
|
66
|
+
example "does not raise an error if the url is valid" do
|
67
|
+
expect{ described_class.parse_service_url(valid_url) }.not_to raise_error
|
68
|
+
end
|
69
|
+
|
70
|
+
example "returns a struct with the expected service type" do
|
71
|
+
expect(@struct.service_type).to eq("service:test.openslp")
|
72
|
+
end
|
56
73
|
|
57
|
-
|
58
|
-
|
74
|
+
example "returns a struct with the expected host" do
|
75
|
+
expect(@struct.host).to eq("192.168.100.1")
|
76
|
+
end
|
77
|
+
|
78
|
+
example "returns a struct with the expected port" do
|
79
|
+
expect(@struct.port).to eq(3003)
|
80
|
+
end
|
81
|
+
|
82
|
+
example "returns a struct with the expected net family" do
|
83
|
+
expect(@struct.net_family).to eq("")
|
84
|
+
end
|
85
|
+
|
86
|
+
example "returns a struct with the expected url remainder" do
|
87
|
+
expect(@struct.url_remainder).to eq("")
|
88
|
+
end
|
59
89
|
end
|
60
90
|
|
61
|
-
|
62
|
-
|
63
|
-
|
91
|
+
context "escape_reserved" do
|
92
|
+
example "defines a escape_reserved method" do
|
93
|
+
expect(described_class).to respond_to(:escape_reserved)
|
94
|
+
end
|
95
|
+
|
96
|
+
example "returns the expected value for the escape_reserved method" do
|
97
|
+
expected = "\\2Ctag-example\\2C"
|
98
|
+
expect(described_class.escape_reserved(",tag-example,")).to eq(expected)
|
99
|
+
end
|
64
100
|
end
|
65
101
|
|
66
|
-
|
67
|
-
|
102
|
+
context "unescape_reserved" do
|
103
|
+
example "defines a unescape_reserved method" do
|
104
|
+
expect(described_class).to respond_to(:unescape_reserved)
|
105
|
+
end
|
106
|
+
|
107
|
+
example "returns the expected value for the unescape_reserved method" do
|
108
|
+
expected = ",tag-example,"
|
109
|
+
expect(described_class.unescape_reserved("\\2Ctag-example\\2C")).to eq(expected)
|
110
|
+
end
|
68
111
|
end
|
69
112
|
end
|
70
113
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rslp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
36
36
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-10-20 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: ffi
|
@@ -115,6 +115,7 @@ metadata:
|
|
115
115
|
documentation_uri: https://github.com/djberg96/rslp/wiki
|
116
116
|
source_code_uri: https://github.com/djberg96/rslp
|
117
117
|
wiki_uri: https://github.com/djberg96/rslp/wiki
|
118
|
+
rubygems_mfa_required: 'true'
|
118
119
|
post_install_message:
|
119
120
|
rdoc_options: []
|
120
121
|
require_paths:
|
@@ -130,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
131
|
- !ruby/object:Gem::Version
|
131
132
|
version: '0'
|
132
133
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
134
|
+
rubygems_version: 3.3.7
|
134
135
|
signing_key:
|
135
136
|
specification_version: 4
|
136
137
|
summary: Interface for the OpenSLP library
|
metadata.gz.sig
CHANGED
Binary file
|