rslp 0.0.2 → 0.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f495c04e7aa0fa38ebead86d3100b360d13de94d02ee3fc2f54bc41eb5b087c
4
- data.tar.gz: 88a33d40ab0aa9e71048c73c765a250c60d559eda2619f483c1800bec48d4ba7
3
+ metadata.gz: 6d18a5f649a8f64234f0ca36681d7700bc82c6f92d6f92fb7de5a15a3e0c9a75
4
+ data.tar.gz: 445016807c2bb1f53192df312f86e8da65948e2c5f634f16cb5fd91fcd49df10
5
5
  SHA512:
6
- metadata.gz: bf1356f4e184640cf4b8f13198dca65469cf653228b1a9679dfce3da82ab0de9f236f81d85e01d3b11d3fd27e8dd472345a09aebf9111df207dc233c27acecb4
7
- data.tar.gz: f67b5df2e8b5c6849b9fe826bee87b594bd4dcc351da1c640b0f3a637c106875e6160097f4e3a783abdfa9896df18b4813294dba6e94a81c914daebeb3d36f24
6
+ metadata.gz: c2150dfc89eae6d2a403151bcc6d4e1e683733225702cbd7e51cb2f6fc7d90e1e3b25504b2536d14a03fa629acb1fa4a8a093e6c45d72964feec43eac367fa94
7
+ data.tar.gz: 5051e0ec6e22438ada2b92729c64465b307201d0baf60a996627cf429efa2fbdb246ce602eeb627a29db60362bbd65944195d7ef46a7ef89880b052770572cbc
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
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
+
1
8
  ## 0.0.2 - 12-Oct-2022
2
9
  * Fixed the parse_service_url singleton method. The underlying SLPSrvURL
3
10
  struct is now a managed struct.
data/lib/rslp.rb CHANGED
@@ -11,7 +11,7 @@ module OpenSLP
11
11
  extend OpenSLP::Functions
12
12
 
13
13
  # The version of the rslp library.
14
- VERSION = '0.0.2'.freeze
14
+ VERSION = '0.1.0'.freeze
15
15
 
16
16
  # Internal error raised whenever an openslp function fails.
17
17
  class Error < StandardError; end
@@ -33,22 +33,30 @@ module OpenSLP
33
33
  # the underlying handle is set to handle asynchronous operations or not. By
34
34
  # default this value is false.
35
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
+ #
36
41
  # If a block is given, then the object itself is yielded to the block, and
37
42
  # it is automatically closed at the end of the block.
38
43
  #
39
44
  # Examples:
40
45
  #
41
- # OpenSLP::SLP.new('en-us') do |slp|
46
+ # # Block form
47
+ # OpenSLP::SLP.new(lang: 'en-us', async: false, host: 'localhost') do |slp|
42
48
  # # ... do stuff
43
49
  # end
44
50
  #
45
- # slp = OpenSLP::SLP.new('en-us')
51
+ # # Non-block form
52
+ # slp = OpenSLP::SLP.new(lang: 'en-us')
46
53
  # # Do stuff
47
54
  # slp.close
48
55
  #
49
- def initialize(lang = '', async = false)
56
+ def initialize(lang: '', async: false, host: nil)
50
57
  @lang = lang
51
58
  @async = async
59
+ @host = host
52
60
 
53
61
  ptr = FFI::MemoryPointer.new(:ulong)
54
62
 
@@ -57,6 +65,16 @@ module OpenSLP
57
65
 
58
66
  @handle = ptr.read_ulong
59
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
+
60
78
  if block_given?
61
79
  begin
62
80
  yield self
@@ -90,7 +108,7 @@ module OpenSLP
90
108
  options[:attributes] ||= ""
91
109
  options[:fresh] ||= true
92
110
 
93
- options[:callback] ||= Proc.new{ |hslp, err, cookie| }
111
+ options[:callback] ||= Proc.new{ |_hslp, err, _cookie| }
94
112
 
95
113
  if options[:attributes] && options[:attributes] != ""
96
114
  attributes = options[:attributes].map{ |k,v| "(#{k}=#{v})" }.join(',')
@@ -124,7 +142,7 @@ module OpenSLP
124
142
  # is registered and all language locales.
125
143
  #
126
144
  def deregister(url)
127
- callback = Proc.new{ |hslp, err, cookie| }
145
+ callback = Proc.new{ |_hslp, err, _cookie| }
128
146
 
129
147
  begin
130
148
  cookie = FFI::MemoryPointer.new(:void)
@@ -134,7 +152,7 @@ module OpenSLP
134
152
  cookie.free unless cookie.null?
135
153
  end
136
154
 
137
- true
155
+ url
138
156
  end
139
157
 
140
158
  # Deletes specified attributes from a registered service. The attributes
@@ -188,12 +206,15 @@ module OpenSLP
188
206
  # form of an LDAP search filter. The default is an empty string, which
189
207
  # will gather all services of the requested type.
190
208
  #
209
+ # The result is an array of hashes, with the URL as the key and its lifetime
210
+ # as the value.
211
+ #
191
212
  def find_services(type, scope = '', filter = '')
192
213
  arr = []
193
214
 
194
- callback = Proc.new{ |hslp, url, life, err, cook|
215
+ callback = Proc.new{ |_hslp, url, lifetime, err, _cookie|
195
216
  if err == SLP_OK
196
- arr << {url => life}
217
+ arr << {url => lifetime}
197
218
  true
198
219
  else
199
220
  false
@@ -225,7 +246,7 @@ module OpenSLP
225
246
  def find_service_types(auth = '*', scope = '')
226
247
  arr = []
227
248
 
228
- callback = Proc.new{ |hslp, types, err, cookie|
249
+ callback = Proc.new{ |_hslp, types, err, _cookie|
229
250
  if err == SLP_OK
230
251
  arr << types
231
252
  true
@@ -237,7 +258,7 @@ module OpenSLP
237
258
  begin
238
259
  cookie = FFI::MemoryPointer.new(:void)
239
260
  result = SLPFindSrvTypes(@handle, auth, scope, callback, cookie)
240
- raise Error, "SLPFindSrvs(): #{result}" if result != :SLP_OK
261
+ raise Error, "SLPFindSrvTypes(): #{result}" if result != :SLP_OK
241
262
  ensure
242
263
  cookie.free unless cookie.null?
243
264
  end
@@ -253,7 +274,7 @@ module OpenSLP
253
274
  def find_service_attributes(url, attrs = '', scope = '')
254
275
  arr = []
255
276
 
256
- callback = Proc.new{ |hslp, attrlist, err, cookie|
277
+ callback = Proc.new{ |_hslp, attrlist, err, _cookie|
257
278
  if err == SLP_OK
258
279
  arr << attrlist
259
280
  true
@@ -350,5 +371,17 @@ module OpenSLP
350
371
 
351
372
  str
352
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
353
386
  end
354
387
  end
data/lib/slp/functions.rb CHANGED
@@ -49,10 +49,12 @@ module OpenSLP
49
49
  callback :SLPAttrCallback, [:handle, :string, :int, :pointer], :bool
50
50
  callback :SLPRegReportCallback, [:handle, :int, :pointer], :void
51
51
 
52
+ attach_function :SLPAssociateIFList, [:handle, :string], SLPError
53
+ attach_function :SLPAssociateIP, [:handle, :string], SLPError
52
54
  attach_function :SLPClose, [:handle], :void
53
- attach_function :SLPEscape, [:string, :pointer, :bool], SLPError
54
55
  attach_function :SLPDelAttrs, [:handle, :string, :string, :SLPRegReportCallback, :pointer], SLPError
55
56
  attach_function :SLPDereg, [:handle, :string, :SLPRegReportCallback, :pointer], SLPError
57
+ attach_function :SLPEscape, [:string, :pointer, :bool], SLPError
56
58
 
57
59
  attach_function :SLPFindAttrs,
58
60
  [:handle, :string, :string, :string, :SLPAttrCallback, :pointer], SLPError
@@ -74,6 +76,7 @@ module OpenSLP
74
76
  attach_function :SLPReg,
75
77
  [:handle, :string, :ushort, :string, :string, :bool, :SLPRegReportCallback, :pointer], SLPError
76
78
 
79
+ attach_function :SLPSetAppPropertyFile, [:string], SLPError
77
80
  attach_function :SLPSetProperty, [:string, :string], :void
78
81
  attach_function :SLPUnescape, [:string, :pointer, :bool], SLPError
79
82
  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.2'
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'
data/spec/rslp_spec.rb CHANGED
@@ -9,12 +9,12 @@ require 'rslp'
9
9
  RSpec.describe OpenSLP::SLP do
10
10
  before do
11
11
  @lang = 'en-us'
12
- @slp = described_class.new(@lang, false)
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(described_class::VERSION).to eq('0.0.2')
17
+ expect(described_class::VERSION).to eq('0.1.0')
18
18
  end
19
19
  end
20
20
 
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.2
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: 2022-10-13 00:00:00.000000000 Z
38
+ date: 2022-10-20 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.3.16
134
+ rubygems_version: 3.3.7
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Interface for the OpenSLP library
metadata.gz.sig CHANGED
Binary file