sparoid 1.0.3 → 1.0.8

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: 594f1917e9cea3e563dcb027f0fb0ddc9fc41e4a0240a405b7fbba8445de61d9
4
- data.tar.gz: 7d39ad302157dfce633b339338e6564d407074556614422efc71b3e645272ac2
3
+ metadata.gz: 3c8737279c5f4eae1d6b5c38e14fc6d43ec3978bb445196a2873dbcb24c33146
4
+ data.tar.gz: 72b1d744ecac0c6afa993b7365f2023ba17d6306ee64d58ae5a27378d082f667
5
5
  SHA512:
6
- metadata.gz: 7c037f995e1fd41822c9b726e7d79e2fc065a75dff5697df4182b6e6294889c305f2d224bf6436bd4f26e4e790316d507cffd2dc58d7f6041cf6e4a6484e3098
7
- data.tar.gz: 2478cbdb04f16035a93c37711a1bb7eaab1cd7482a6c80418ba71f60c276d356513d1210b51615ea984167ba9b654cc1bf51c4d4899e37894a348abdfaa7e76a
6
+ metadata.gz: 671a2b3ad5df6752f29f5de76c6e3f1613088b75406d187154a4be4da514b93e1c0a9ee19b99c430133321029db3f088565d917860f9794ef15558c467ed2532
7
+ data.tar.gz: 57d624c615d9067eaa2d4fd6f23fe3d5213b953674b00738da08f995b917244fb85fb8e1bddf3ccd0013b292a5101ade4014b9da1b5155a35c2d78732ce5c7b6
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
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: ["resolver1.opendns.com"]) do |dns|
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
- config = File.expand_path(options[:config] || "~/.sparoid.ini")
13
- abort "Config '#{config}' not found" unless File.exist? config
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
- auth(host, spa_port)
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! { |l| l.split("=", 2).map!(&:strip) }.to_h
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sparoid
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.8"
5
5
  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.3
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-03-17 00:00:00.000000000 Z
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.1.4
72
+ rubygems_version: 3.2.3
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Single Packet Authorisation client