sparoid 1.0.4 → 1.0.9

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: 6bceab7682e1a59d1da6f51276f580f11c50456625ea57b1633dd8862f9045df
4
- data.tar.gz: 97f3594df9310bd90472d6909e3a2f7ba719c43638d53cc12e5464cd2634bd8f
3
+ metadata.gz: 3e5d9f60a2c48147b21a1bd2970f9b495b8f28d6627b3783e27870fd7572e87e
4
+ data.tar.gz: 5448587233f343935ea5bd5ccc0484f24f852b90d129a0192627847b32c14032
5
5
  SHA512:
6
- metadata.gz: 668b9744c1f4e4c77cf91f5f351b23444f0e7a325fb6af0c834fe7d255273afa70b21455318c0979933dca994151ea17cb63f9db4ee5cc74d9e2b146f3e745b0
7
- data.tar.gz: 040e356d56e371eb487079d6beb286b9dec64287f57301aa235e5cdadd8b6116839b564ffca7d894b93d151f2520a3af589b46962c0592974ca796363885242d
6
+ metadata.gz: ba3a127fc5d7ec9cd6c5e859a467e65428a4597eb5069f32c06e69504aca2aeecdb7fcab691c781d07fd7c1c00df0dd04555780f51f5da7678626fa41bf87f33
7
+ data.tar.gz: b7f356bb8018f0a653263103adbd22da116b4f0ea6bd03a646ecd43c3b61f79429b38e7597e20b9d0ea7401074f6043ad3fa9c122dda0a9af3ba0c285952201c
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,24 @@
1
+ ## [1.0.9] - 2021-05-23
2
+
3
+ - Exit gracefully on abort (ctrl-c) instead of dumping huge stacktrace
4
+ - Sleep 20ms aftering sending UDP package to allow for remote host to open its firewall
5
+
6
+ ## [1.0.8] - 2021-04-27
7
+
8
+ - Get ENV variables if config file is missing
9
+
10
+ ## [1.0.7] - 2021-04-27
11
+
12
+ - Get key and hmac key from ENV variables
13
+
14
+ ## [1.0.6] - 2021-04-13
15
+
16
+ - Use static IP for opendns resolver, saves one DNS lookup
17
+
18
+ ## [1.0.5] - 2021-04-12
19
+
20
+ - Prefix all logging with `Sparoid: `
21
+
1
22
  ## [1.0.4] - 2021-03-25
2
23
 
3
24
  - Only warn if config is missing when connecting with CLI
data/README.md CHANGED
@@ -26,7 +26,7 @@ Can be used with OpenSSH's ProxyCommand/ProxyUseFdpass to send the packet before
26
26
 
27
27
  ```
28
28
  Host *.example.com
29
- ProxyCommand sparoid send %h --passfd %p
29
+ ProxyCommand sparoid connect %h %p
30
30
  ProxyUseFdpass yes
31
31
  ```
32
32
 
data/exe/sparoid CHANGED
@@ -1,5 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative "../lib/sparoid/cli"
5
- Sparoid::CLI.start
4
+ begin
5
+ require_relative "../lib/sparoid/cli"
6
+ Sparoid::CLI.start
7
+ rescue Interrupt
8
+ exit 1
9
+ end
data/lib/sparoid.rb CHANGED
@@ -14,6 +14,11 @@ module Sparoid
14
14
  msg = message(public_ip)
15
15
  data = prefix_hmac(hmac_key, encrypt(key, msg))
16
16
  sendmsg(host, port, data)
17
+
18
+ # wait some time for the server to actually open the port
19
+ # if we don't wait the next SYN package will be dropped
20
+ # and it have to be redelivered, adding 1 second delay
21
+ sleep 0.02
17
22
  end
18
23
 
19
24
  # Generate new aes and hmac keys, print to stdout
@@ -71,7 +76,7 @@ module Sparoid
71
76
  end
72
77
 
73
78
  def public_ip
74
- Resolv::DNS.open(nameserver: ["resolver1.opendns.com"]) do |dns|
79
+ Resolv::DNS.open(nameserver: ["208.67.222.222", "208.67.220.220"]) do |dns|
75
80
  dns.getresource("myip.opendns.com", Resolv::DNS::Resource::IN::A).address
76
81
  end
77
82
  end
data/lib/sparoid/cli.rb CHANGED
@@ -11,9 +11,9 @@ module Sparoid
11
11
  def auth(host, port = 8484)
12
12
  send_auth(host, port, options[:config])
13
13
  rescue Errno::ENOENT
14
- abort "Config not found"
14
+ abort "Sparoid: Config not found"
15
15
  rescue StandardError => e
16
- abort e.message
16
+ abort "Sparoid: #{e.message}"
17
17
  end
18
18
 
19
19
  desc "connect HOST PORT [SPA-PORT]", "Send a SPA, TCP connect, and then pass the FD back to the parent"
@@ -22,11 +22,11 @@ module Sparoid
22
22
  begin
23
23
  send_auth(host, spa_port, options[:config])
24
24
  rescue Errno::ENOENT
25
- warn "Config not found"
25
+ warn "Sparoid: Config not found"
26
26
  end
27
27
  Sparoid.fdpass(host, port)
28
28
  rescue StandardError => e
29
- abort e.message
29
+ abort "Sparoid: #{e.message}"
30
30
  end
31
31
 
32
32
  desc "keygen", "Generate an encryption key and a HMAC key"
@@ -47,6 +47,11 @@ module Sparoid
47
47
 
48
48
  def parse_ini(path)
49
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
+ }
50
55
  end
51
56
 
52
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.4"
4
+ VERSION = "1.0.9"
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.4
4
+ version: 1.0.9
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-25 00:00:00.000000000 Z
11
+ date: 2021-05-23 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.15
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Single Packet Authorisation client