sparoid 1.0.3 → 1.0.8
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/.gitignore +1 -0
- data/CHANGELOG.md +20 -0
- data/lib/sparoid.rb +1 -1
- data/lib/sparoid/cli.rb +23 -10
- data/lib/sparoid/version.rb +1 -1
- 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: 3c8737279c5f4eae1d6b5c38e14fc6d43ec3978bb445196a2873dbcb24c33146
|
4
|
+
data.tar.gz: 72b1d744ecac0c6afa993b7365f2023ba17d6306ee64d58ae5a27378d082f667
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 671a2b3ad5df6752f29f5de76c6e3f1613088b75406d187154a4be4da514b93e1c0a9ee19b99c430133321029db3f088565d917860f9794ef15558c467ed2532
|
7
|
+
data.tar.gz: 57d624c615d9067eaa2d4fd6f23fe3d5213b953674b00738da08f995b917244fb85fb8e1bddf3ccd0013b292a5101ade4014b9da1b5155a35c2d78732ce5c7b6
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## [1.0.8] - 2021-04-27
|
2
|
+
|
3
|
+
- Get ENV variables if config file is missing
|
4
|
+
|
5
|
+
## [1.0.7] - 2021-04-27
|
6
|
+
|
7
|
+
- Get key and hmac key from ENV variables
|
8
|
+
|
9
|
+
## [1.0.6] - 2021-04-13
|
10
|
+
|
11
|
+
- Use static IP for opendns resolver, saves one DNS lookup
|
12
|
+
|
13
|
+
## [1.0.5] - 2021-04-12
|
14
|
+
|
15
|
+
- Prefix all logging with `Sparoid: `
|
16
|
+
|
17
|
+
## [1.0.4] - 2021-03-25
|
18
|
+
|
19
|
+
- Only warn if config is missing when connecting with CLI
|
20
|
+
|
1
21
|
## [1.0.3] - 2021-03-17
|
2
22
|
|
3
23
|
- Nicer error handling in CLI, remove --fdpass option
|
data/lib/sparoid.rb
CHANGED
@@ -71,7 +71,7 @@ module Sparoid
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def public_ip
|
74
|
-
Resolv::DNS.open(nameserver: ["
|
74
|
+
Resolv::DNS.open(nameserver: ["208.67.222.222", "208.67.220.220"]) do |dns|
|
75
75
|
dns.getresource("myip.opendns.com", Resolv::DNS::Resource::IN::A).address
|
76
76
|
end
|
77
77
|
end
|
data/lib/sparoid/cli.rb
CHANGED
@@ -7,23 +7,26 @@ module Sparoid
|
|
7
7
|
# CLI
|
8
8
|
class CLI < Thor
|
9
9
|
desc "auth HOST [PORT]", "Send a authorization packet"
|
10
|
-
method_option :config, desc: "Path to a config file, INI format, with key and hmac-key"
|
10
|
+
method_option :config, desc: "Path to a config file, INI format, with key and hmac-key", default: "~/.sparoid.ini"
|
11
11
|
def auth(host, port = 8484)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
key, hmac_key = get_keys(parse_ini(config))
|
16
|
-
Sparoid.auth(key, hmac_key, host, port.to_i)
|
12
|
+
send_auth(host, port, options[:config])
|
13
|
+
rescue Errno::ENOENT
|
14
|
+
abort "Sparoid: Config not found"
|
17
15
|
rescue StandardError => e
|
18
|
-
abort e.message
|
16
|
+
abort "Sparoid: #{e.message}"
|
19
17
|
end
|
20
18
|
|
21
19
|
desc "connect HOST PORT [SPA-PORT]", "Send a SPA, TCP connect, and then pass the FD back to the parent"
|
20
|
+
method_option :config, desc: "Path to a config file, INI format, with key and hmac-key", default: "~/.sparoid.ini"
|
22
21
|
def connect(host, port, spa_port = 8484)
|
23
|
-
|
22
|
+
begin
|
23
|
+
send_auth(host, spa_port, options[:config])
|
24
|
+
rescue Errno::ENOENT
|
25
|
+
warn "Sparoid: Config not found"
|
26
|
+
end
|
24
27
|
Sparoid.fdpass(host, port)
|
25
28
|
rescue StandardError => e
|
26
|
-
abort e.message
|
29
|
+
abort "Sparoid: #{e.message}"
|
27
30
|
end
|
28
31
|
|
29
32
|
desc "keygen", "Generate an encryption key and a HMAC key"
|
@@ -37,8 +40,18 @@ module Sparoid
|
|
37
40
|
|
38
41
|
private
|
39
42
|
|
43
|
+
def send_auth(host, port, config)
|
44
|
+
key, hmac_key = get_keys(parse_ini(config))
|
45
|
+
Sparoid.auth(key, hmac_key, host, port.to_i)
|
46
|
+
end
|
47
|
+
|
40
48
|
def parse_ini(path)
|
41
|
-
File.readlines(path).map! { |
|
49
|
+
File.readlines(File.expand_path(path)).map! { |line| line.split("=", 2).map!(&:strip) }.to_h
|
50
|
+
rescue Errno::ENOENT
|
51
|
+
{
|
52
|
+
"key" => ENV["SPAROID_KEY"],
|
53
|
+
"hmac-key" => ENV["SPAROID_HMAC_KEY"]
|
54
|
+
}
|
42
55
|
end
|
43
56
|
|
44
57
|
def get_keys(config)
|
data/lib/sparoid/version.rb
CHANGED
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.8
|
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-04-27 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.
|
72
|
+
rubygems_version: 3.2.3
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Single Packet Authorisation client
|