sparoid 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/sparoid/cli.rb +16 -8
- data/lib/sparoid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bceab7682e1a59d1da6f51276f580f11c50456625ea57b1633dd8862f9045df
|
4
|
+
data.tar.gz: 97f3594df9310bd90472d6909e3a2f7ba719c43638d53cc12e5464cd2634bd8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 668b9744c1f4e4c77cf91f5f351b23444f0e7a325fb6af0c834fe7d255273afa70b21455318c0979933dca994151ea17cb63f9db4ee5cc74d9e2b146f3e745b0
|
7
|
+
data.tar.gz: 040e356d56e371eb487079d6beb286b9dec64287f57301aa235e5cdadd8b6116839b564ffca7d894b93d151f2520a3af589b46962c0592974ca796363885242d
|
data/CHANGELOG.md
CHANGED
data/lib/sparoid/cli.rb
CHANGED
@@ -7,20 +7,23 @@ 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 "Config not found"
|
17
15
|
rescue StandardError => e
|
18
16
|
abort 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 "Config not found"
|
26
|
+
end
|
24
27
|
Sparoid.fdpass(host, port)
|
25
28
|
rescue StandardError => e
|
26
29
|
abort e.message
|
@@ -37,8 +40,13 @@ 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
|
42
50
|
end
|
43
51
|
|
44
52
|
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.4
|
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-03-
|
11
|
+
date: 2021-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|