sparoid 2.2.0 → 2.2.1
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 +4 -4
- data/.github/workflows/main.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -0
- data/lib/sparoid/version.rb +1 -1
- data/lib/sparoid.rb +21 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 71eaf9ec6bae245550f5134ddd360754aa3b360342551676bea056083a56ee8b
|
|
4
|
+
data.tar.gz: d97abd87405cd9c65bc96583648f6f2075867b08bab919e8871ed95de5e2e4f0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a4426c422d8c973596758cdfeed9e23a256aa697605e9beaa9c1aa6b06f14d2fbcf5712a8fd44e25d830ed97f47912e0b707e5006d52139f686efdcf288cec9
|
|
7
|
+
data.tar.gz: b7df47069061130c91155b86fa8385f8ca2c77919baf1189c7513db3f2aca7fc1bff06f8b8e8911184ef8c2014bf8092e9b1933af6692a4137a5155c1923a7d1
|
data/.github/workflows/main.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/lib/sparoid/version.rb
CHANGED
data/lib/sparoid.rb
CHANGED
|
@@ -103,6 +103,8 @@ module Sparoid # rubocop:disable Metrics/ModuleLength
|
|
|
103
103
|
ips = ips.grep_v(Resolv::IPv6)
|
|
104
104
|
ips << Resolv::IPv6.create(native_ipv6)
|
|
105
105
|
end
|
|
106
|
+
raise PublicIPError, "Sparoid could not resolve a public IP to knock from" if ips.empty?
|
|
107
|
+
|
|
106
108
|
ips.map { |i| message(i) }
|
|
107
109
|
end
|
|
108
110
|
end
|
|
@@ -253,16 +255,31 @@ module Sparoid # rubocop:disable Metrics/ModuleLength
|
|
|
253
255
|
|
|
254
256
|
class ResolvError < Error; end
|
|
255
257
|
|
|
256
|
-
|
|
258
|
+
class PublicIPError < Error; end
|
|
259
|
+
|
|
260
|
+
# Instance of SPAroid that resolves its public IP once and reuses it
|
|
257
261
|
class Instance
|
|
258
262
|
include Sparoid
|
|
259
263
|
|
|
260
|
-
def
|
|
261
|
-
@
|
|
264
|
+
def initialize
|
|
265
|
+
@resolve_mutex = Mutex.new
|
|
266
|
+
@public_ips = []
|
|
262
267
|
end
|
|
263
268
|
|
|
264
269
|
def cached_public_ips
|
|
265
|
-
public_ips
|
|
270
|
+
return @public_ips if @public_ips.any?
|
|
271
|
+
|
|
272
|
+
@resolve_mutex.synchronize do
|
|
273
|
+
return @public_ips if @public_ips.any?
|
|
274
|
+
|
|
275
|
+
ips = public_ips
|
|
276
|
+
if ips.empty?
|
|
277
|
+
warn "Sparoid: Failed to retrieve public IPs"
|
|
278
|
+
else
|
|
279
|
+
@public_ips = ips
|
|
280
|
+
end
|
|
281
|
+
ips
|
|
282
|
+
end
|
|
266
283
|
end
|
|
267
284
|
end
|
|
268
285
|
end
|