sparoid 1.0.21 → 1.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: aa670db15a1fcc9faa4784c1bf568dc93d07b6bbeacabc7ce64ab0c167672f23
4
- data.tar.gz: 2c8694a91e39a2da4720b6ec48802b36a229f6a90d503065004783a6b5e10d97
3
+ metadata.gz: 71f77a00597cb908e5b898603a34ed4e9111fd7fdcd255def5ea1633089c6041
4
+ data.tar.gz: d4ba950c8fa66e6083e7bf43431618023aa8b163c1d12f6170835532c719ee03
5
5
  SHA512:
6
- metadata.gz: 248f53b8b4a2ad8f0dff46ad6ee3db3b3cce94f94c3c68ed8a38c1d2a5b97b3b2bcf912cb95da874b0079e7b8288a122d5726b7de5dacbe770fc4f4a20fc5f83
7
- data.tar.gz: c9300feaee2514fd6403b00fdc61e1a5092e02c0973f89959205c423f5f4cb0362c7aa3f091820169634950749f9ddd1f86f9ad84a0a3270c224680a5e6bcee8
6
+ metadata.gz: 3f50ca4d5ebf7c68badec3afe5f49ea3c7d23eaa932448f2f3534fd6dc594b8bcecc8ad7c9e5f4e0b4453538fdbf45884ba6c3a5ab3c645eb6feb4ed5eabbff2
7
+ data.tar.gz: 77c377f37dfa0dc257af730d25fb7600cb4cc6fe45e1e809e455c55c3fce5bce429abbbc82080cafa1a1f7fbb6dfcfe4fb5dede8d0eea2e904ee023403197d1b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.1.0] - 2023-03-03
2
+
3
+ - Allow override of public ip, open for someone else by passing `:open_for_ip` to `Sparoid.auth(..., open_for_ip:)` (#11)
4
+
5
+ ## [1.0.22] - 2023-02-01
6
+
7
+ - Fix `Addrinfo SocketError` should raise `Sparoid::ResolvError` (#10)
8
+
1
9
  ## [1.0.21] - 2022-10-12
2
10
 
3
11
  - Fix where Sparoid::Instance returned nil for public_ip
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sparoid
4
- VERSION = "1.0.21"
4
+ VERSION = "1.1.0"
5
5
  end
data/lib/sparoid.rb CHANGED
@@ -12,11 +12,10 @@ module Sparoid # rubocop:disable Metrics/ModuleLength
12
12
  SPAROID_CACHE_PATH = ENV.fetch("SPAROID_CACHE_PATH", "/tmp/.sparoid_public_ip")
13
13
 
14
14
  # Send an authorization packet
15
- def auth(key, hmac_key, host, port)
16
- addrs = Addrinfo.getaddrinfo(host, port, :INET, :DGRAM)
17
- raise(ResolvError, "Sparoid failed to resolv #{host}") if addrs.empty?
18
-
19
- msg = message(cached_public_ip)
15
+ def auth(key, hmac_key, host, port, open_for_ip: cached_public_ip)
16
+ addrs = resolve_ip_addresses(host, port)
17
+ ip = Resolv::IPv4.create(open_for_ip)
18
+ msg = message(ip)
20
19
  data = prefix_hmac(hmac_key, encrypt(key, msg))
21
20
  sendmsg(addrs, data)
22
21
 
@@ -156,6 +155,15 @@ module Sparoid # rubocop:disable Metrics/ModuleLength
156
155
  end
157
156
  end
158
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
+
159
167
  class Error < StandardError; end
160
168
 
161
169
  class ResolvError < Error; 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.21
4
+ version: 1.1.0
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: 2022-10-12 00:00:00.000000000 Z
11
+ date: 2023-03-03 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.3.7
73
+ rubygems_version: 3.4.5
74
74
  signing_key:
75
75
  specification_version: 4
76
76
  summary: Single Packet Authorisation client