sparoid 2.2.0 → 2.3.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 +4 -4
- data/.github/workflows/main.yml +3 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -0
- data/lib/sparoid/version.rb +1 -1
- data/lib/sparoid.rb +27 -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: 2e372cc3353dca22edcde8e70a908e425bb287ef6429529cd22fad88eb8a9dde
|
|
4
|
+
data.tar.gz: 3f624ae4466167b81010e96cdcfec142ca8a787075dc7ba66c5c86006781659b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c352924f57db09bebbcdf1be25dd96e7ef0b21ec8d12d01b057457fe73afd80c0bb3f9de5c13d6896fced17a184591ada5d3a4d81b7a75e33701d14a7ef58ff
|
|
7
|
+
data.tar.gz: 524c8c5d4920078ff22d3440e7960afd4f96a928632735208b4dd01fff07cad623ac229500cd170cd31c39f3cd6cb2f7e65b0d9a3f8a71f510704f8074b54ca5
|
data/.github/workflows/main.yml
CHANGED
|
@@ -8,10 +8,12 @@ on:
|
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
10
|
build:
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
11
13
|
strategy:
|
|
12
14
|
fail-fast: false
|
|
13
15
|
matrix:
|
|
14
|
-
ruby: [ 3.2, 3.3, 3.4, 4.0, ruby-head ]
|
|
16
|
+
ruby: [ "3.2", "3.3", "3.4", "4.0", ruby-head ]
|
|
15
17
|
runs-on: ubuntu-latest
|
|
16
18
|
steps:
|
|
17
19
|
- uses: actions/checkout@v6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [2.3.0] - 2026-10-13
|
|
2
|
+
|
|
3
|
+
- Add Sparoid::Instance#reset_public_ips to drop cached public IPs so the next knock resolves them again (#27)
|
|
4
|
+
|
|
5
|
+
## [2.2.1] - 2026-06-30
|
|
6
|
+
|
|
7
|
+
- Make Sparoid::Instance public-IP resolution thread-safe and empty-aware; raise Sparoid::PublicIPError when no public IP resolves (#25)
|
|
8
|
+
|
|
1
9
|
## [2.2.0] - 2026-05-06
|
|
2
10
|
|
|
3
11
|
- Raise when sendmsg fails for every resolved address (#23)
|
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,37 @@ 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
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
# Forget the cached public IPs so the next knock resolves them again.
|
|
286
|
+
# Call it when a connection after a knock fails, in case the public IP changed.
|
|
287
|
+
def reset_public_ips
|
|
288
|
+
@resolve_mutex.synchronize { @public_ips = [] }
|
|
266
289
|
end
|
|
267
290
|
end
|
|
268
291
|
end
|