sparoid 1.0.13 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f5904f6b6c520213811268420efad5fd5a387942352d8def32b722cd14420da
4
- data.tar.gz: 6f7e19f1515979078635ff1e862bc9bcbb6fb2172ac631d94b986dd1b95984fb
3
+ metadata.gz: 8747bc66fcbc1b4f3e31d7246d2608298a882df7d5661aef6d51c7f7b99f406c
4
+ data.tar.gz: 99e0f9044333f8d17e022f406e519abcd9977c420a86003fb4d69d891ba92475
5
5
  SHA512:
6
- metadata.gz: 6043c439103ae404d9dfc6855b0273777b3e1e505d768e36b7d5bf514abc6c2a0498ecda76ddf89994d4d3fb426394fc3994566e659842e377bab643b8edfcfd
7
- data.tar.gz: d95a3908952eb8134f1c68bd22a6f13f05ca99a8f1bda888c0adf6cbc77e882f65e4097a12b3db8a28ec74c624d8cee0821827ee12e54953da567606605f1e96
6
+ metadata.gz: 16095424a1dce5589c2922191ce96a380dd0e973dcc77c1715ec0fe9af376b4caf3127645808c2d87a161797d7d929135fa80d32be8fd06e7ef14a86cefad72f
7
+ data.tar.gz: 2a56181b6d57bc511ea35e10128f9536ad4bc480fb8fae007facd5e2ee7feb8cee3a7b4aeae910b1c03c5670b20de35f7f470e495d1b5a57dd3b5a422f0cc288
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [1.0.17] - 2021-11-15
2
+
3
+ - Raise more specific error when failing to resolv hostname
4
+
5
+ ## [1.0.16] - 2021-08-23
6
+
7
+ - Resolv host IPs before generating message (in case resolving takes a lot of time)
8
+
9
+ ## [1.0.15] - 2021-08-11
10
+
11
+ - Raise an exception, don't abort, when resolving hostname fails
12
+
13
+ ## [1.0.14] - 2021-07-26
14
+
15
+ - Send UDP packets to all resolved IPs for a hostname
16
+
1
17
  ## [1.0.13] - 2021-06-30
2
18
 
3
19
  - Do not warn on empty public ip cache file
data/lib/sparoid/cli.rb CHANGED
@@ -6,6 +6,8 @@ require_relative "../sparoid"
6
6
  module Sparoid
7
7
  # CLI
8
8
  class CLI < Thor
9
+ map "-v" => :version
10
+
9
11
  desc "auth HOST [PORT]", "Send a authorization packet"
10
12
  method_option :config, desc: "Path to a config file, INI format, with key and hmac-key", default: "~/.sparoid.ini"
11
13
  def auth(host, port = 8484)
@@ -34,6 +36,11 @@ module Sparoid
34
36
  Sparoid.keygen
35
37
  end
36
38
 
39
+ desc "version", "Show version and exit"
40
+ def version
41
+ puts "#{Sparoid::VERSION} (ruby)"
42
+ end
43
+
37
44
  def self.exit_on_failure?
38
45
  true
39
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sparoid
4
- VERSION = "1.0.13"
4
+ VERSION = "1.0.17"
5
5
  end
data/lib/sparoid.rb CHANGED
@@ -13,9 +13,12 @@ module Sparoid
13
13
 
14
14
  # Send an authorization packet
15
15
  def auth(key, hmac_key, host, port)
16
+ ips = Resolv.getaddresses(host)
17
+ raise(ResolvError, "Sparoid failed to resolv #{host}") if ips.empty?
18
+
16
19
  msg = message(cached_public_ip)
17
20
  data = prefix_hmac(hmac_key, encrypt(key, msg))
18
- sendmsg(host, port, data)
21
+ sendmsg(ips, port, data)
19
22
 
20
23
  # wait some time for the server to actually open the port
21
24
  # if we don't wait the next SYN package will be dropped
@@ -41,10 +44,14 @@ module Sparoid
41
44
 
42
45
  private
43
46
 
44
- def sendmsg(host, port, data)
47
+ def sendmsg(ips, port, data)
45
48
  UDPSocket.open do |socket|
46
- socket.connect host, port
47
- socket.sendmsg data, 0
49
+ ips.each do |ip|
50
+ socket.connect ip, port
51
+ socket.sendmsg data, 0
52
+ rescue StandardError => e
53
+ warn "Sparoid error: #{e.message}"
54
+ end
48
55
  end
49
56
  end
50
57
 
@@ -124,6 +131,8 @@ module Sparoid
124
131
 
125
132
  class Error < StandardError; end
126
133
 
134
+ class ResolvError < Error; end
135
+
127
136
  # Instance of SPAroid that only resolved public_ip once
128
137
  class Instance
129
138
  include Sparoid
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.13
4
+ version: 1.0.17
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: 2021-06-30 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.1.6
72
+ rubygems_version: 3.1.4
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Single Packet Authorisation client