sparoid 1.0.2 → 1.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9949f3421911f8f9d588b87ba8955407b68ac62bae5ad7f53ef5b707077ef60
4
- data.tar.gz: 06b115e1db22eb0222dd9f7a439024e18d8579255324aaff1bb1c935e35c10f4
3
+ metadata.gz: 2a97b0d586778f3f851e5c42039bffaf461bb2e8927d9fea86cd69c8cfa0e1e9
4
+ data.tar.gz: b66ff9a2c806838408c546d38c3698c7bc5334d3b11aba00d1e4de8f9e848f05
5
5
  SHA512:
6
- metadata.gz: d6ef1abb4e1c01d435f771ffbf779aeced9a04a2384a309c623fef0546d8cf8adae7ab76a86ba60b485c49ddbd386e545ecc9ce7c62efdcec465732c23cd1f59
7
- data.tar.gz: f616bb367217c07aa36865be2c1eaeeecce685c260911aaf6a97f1e8cb80f8652d906944edca1954d1f161a123bcf333945947992c40ea289be0911e40be7c29
6
+ metadata.gz: 1f2643b8599ab7c78e30b3e6927ad79e405becebfa8cfe617a0d7245e82ec4d0b11c9fcbf9cff2365403b59d2472260b4ab8b290e897991d8f3e6b1b19736e1e
7
+ data.tar.gz: '048ecd5b85d177c044626fb11cf304fbbc14b906d366566e34c7afa535ec419ba4b8a9369108ab67fc121496908e4a3ac0f42a2821db723bb7771a46ab26ab7e'
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.7] - 2021-04-27
2
+
3
+ - Get key and hmac key from ENV variables
4
+
5
+ ## [1.0.6] - 2021-04-13
6
+
7
+ - Use static IP for opendns resolver, saves one DNS lookup
8
+
9
+ ## [1.0.5] - 2021-04-12
10
+
11
+ - Prefix all logging with `Sparoid: `
12
+
13
+ ## [1.0.4] - 2021-03-25
14
+
15
+ - Only warn if config is missing when connecting with CLI
16
+
17
+ ## [1.0.3] - 2021-03-17
18
+
19
+ - Nicer error handling in CLI, remove --fdpass option
20
+
1
21
  ## [1.0.2] - 2021-03-15
2
22
 
3
23
  - `sparoid send` renamed to `sparoid auth`
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,24 +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"
11
- method_option :fdpass,
12
- type: :numeric,
13
- desc: "After sending, open a TCP connection and pass the FD back to the calling process. \
14
- For use with OpenSSH ProxyCommand and ProxyUseFdpass"
10
+ method_option :config, desc: "Path to a config file, INI format, with key and hmac-key", default: "~/.sparoid.ini"
15
11
  def auth(host, port = 8484)
16
- config = File.expand_path(options[:config] || "~/.sparoid.ini")
17
- abort "Config '#{config}' not found" unless File.exist? config
18
-
19
- key, hmac_key = get_keys(parse_ini(config))
20
- Sparoid.auth(key, hmac_key, host, port.to_i)
21
- Sparoid.fdpass(host, options[:fdpass]) if options[:fdpass]
12
+ send_auth(host, port, options[:config])
13
+ rescue Errno::ENOENT
14
+ abort "Sparoid: Config not found"
15
+ rescue StandardError => e
16
+ abort "Sparoid: #{e.message}"
22
17
  end
23
18
 
24
- desc "connect", "Send a SPA, TCP connect, and then pass the FD back to the parent"
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"
25
21
  def connect(host, port, spa_port = 8484)
26
- 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
27
27
  Sparoid.fdpass(host, port)
28
+ rescue StandardError => e
29
+ abort "Sparoid: #{e.message}"
28
30
  end
29
31
 
30
32
  desc "keygen", "Generate an encryption key and a HMAC key"
@@ -38,8 +40,15 @@ module Sparoid
38
40
 
39
41
  private
40
42
 
43
+ def send_auth(host, port, config)
44
+ key = ENV["SPAROID_KEY"]
45
+ hmac_key = ENV["SPAROID_HMAC_KEY"]
46
+ key, hmac_key = get_keys(parse_ini(config)) if config
47
+ Sparoid.auth(key, hmac_key, host, port.to_i)
48
+ end
49
+
41
50
  def parse_ini(path)
42
- File.readlines(path).map! { |l| l.split("=", 2).map!(&:strip) }.to_h
51
+ File.readlines(File.expand_path(path)).map! { |line| line.split("=", 2).map!(&:strip) }.to_h
43
52
  end
44
53
 
45
54
  def get_keys(config)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sparoid
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.7"
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.2
4
+ version: 1.0.7
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-15 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