sparoid 1.0.20 → 1.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/sparoid/version.rb +1 -1
- data/lib/sparoid.rb +13 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71a3d6d8370df36acaad83f5f03c0b29c6e5037856c33fcfa3e17a16c6f678ac
|
4
|
+
data.tar.gz: d1d2cd45e4c503af8e0390c5466ec113abfbbeab62a045d3edee274ac888557d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e45e3482c4c500914b12764ea4f1a16e0bde44a4de1119b3b6884a2ba29264de0ad8be169d1c24e3be5c43c8da891d55177491e13229184000fb68b284857487
|
7
|
+
data.tar.gz: c52b06c69dc47867a73a3178172bf2279840ac3228fb74ace9a3fde7159b2e0af26af39d0c86dcba423c4f6ceb2f50fd5fe511072f9a2be3a00665883899e8f3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [1.0.22] - 2023-02-01
|
2
|
+
|
3
|
+
- Fix `Addrinfo SocketError` should raise `Sparoid::ResolvError` (#10)
|
4
|
+
|
5
|
+
## [1.0.21] - 2022-10-12
|
6
|
+
|
7
|
+
- Fix where Sparoid::Instance returned nil for public_ip
|
8
|
+
|
1
9
|
## [1.0.20] - 2022-10-11
|
2
10
|
|
3
11
|
- Ignore EISCONN errors (already connected) error as BSD raises on second connect_nonblock
|
data/lib/sparoid/version.rb
CHANGED
data/lib/sparoid.rb
CHANGED
@@ -13,8 +13,7 @@ module Sparoid # rubocop:disable Metrics/ModuleLength
|
|
13
13
|
|
14
14
|
# Send an authorization packet
|
15
15
|
def auth(key, hmac_key, host, port)
|
16
|
-
addrs =
|
17
|
-
raise(ResolvError, "Sparoid failed to resolv #{host}") if addrs.empty?
|
16
|
+
addrs = resolve_ip_addresses(host, port)
|
18
17
|
|
19
18
|
msg = message(cached_public_ip)
|
20
19
|
data = prefix_hmac(hmac_key, encrypt(key, msg))
|
@@ -71,7 +70,8 @@ module Sparoid # rubocop:disable Metrics/ModuleLength
|
|
71
70
|
private
|
72
71
|
|
73
72
|
def sendmsg(addrs, data)
|
74
|
-
socket =
|
73
|
+
socket = UDPSocket.new
|
74
|
+
socket.nonblock = false
|
75
75
|
addrs.each do |addr|
|
76
76
|
socket.sendmsg data, 0, addr
|
77
77
|
rescue StandardError => e
|
@@ -155,6 +155,15 @@ module Sparoid # rubocop:disable Metrics/ModuleLength
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
+
def resolve_ip_addresses(host, port)
|
159
|
+
addresses = Addrinfo.getaddrinfo(host, port, :INET, :DGRAM)
|
160
|
+
raise(ResolvError, "Sparoid failed to resolv #{host}") if addresses.empty?
|
161
|
+
|
162
|
+
addresses
|
163
|
+
rescue SocketError
|
164
|
+
raise(ResolvError, "Sparoid failed to resolv #{host}")
|
165
|
+
end
|
166
|
+
|
158
167
|
class Error < StandardError; end
|
159
168
|
|
160
169
|
class ResolvError < Error; end
|
@@ -170,7 +179,7 @@ module Sparoid # rubocop:disable Metrics/ModuleLength
|
|
170
179
|
end
|
171
180
|
|
172
181
|
def cached_public_ip
|
173
|
-
|
182
|
+
public_ip
|
174
183
|
end
|
175
184
|
end
|
176
185
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sparoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carl Hörberg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '0'
|
72
72
|
requirements: []
|
73
|
-
rubygems_version: 3.
|
73
|
+
rubygems_version: 3.4.5
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: Single Packet Authorisation client
|