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 +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/sparoid/cli.rb +7 -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: 8747bc66fcbc1b4f3e31d7246d2608298a882df7d5661aef6d51c7f7b99f406c
|
4
|
+
data.tar.gz: 99e0f9044333f8d17e022f406e519abcd9977c420a86003fb4d69d891ba92475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/sparoid/version.rb
CHANGED
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(
|
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(
|
47
|
+
def sendmsg(ips, port, data)
|
45
48
|
UDPSocket.open do |socket|
|
46
|
-
|
47
|
-
|
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.
|
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-
|
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.
|
72
|
+
rubygems_version: 3.1.4
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Single Packet Authorisation client
|