sparoid 1.0.12 → 1.0.13
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/CHANGELOG.md +6 -1
- data/Gemfile +2 -5
- data/lib/sparoid.rb +9 -3
- 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: 1f5904f6b6c520213811268420efad5fd5a387942352d8def32b722cd14420da
|
4
|
+
data.tar.gz: 6f7e19f1515979078635ff1e862bc9bcbb6fb2172ac631d94b986dd1b95984fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6043c439103ae404d9dfc6855b0273777b3e1e505d768e36b7d5bf514abc6c2a0498ecda76ddf89994d4d3fb426394fc3994566e659842e377bab643b8edfcfd
|
7
|
+
data.tar.gz: d95a3908952eb8134f1c68bd22a6f13f05ca99a8f1bda888c0adf6cbc77e882f65e4097a12b3db8a28ec74c624d8cee0821827ee12e54953da567606605f1e96
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [1.0.13] - 2021-06-30
|
2
|
+
|
3
|
+
- Do not warn on empty public ip cache file
|
4
|
+
- The public ip cache file path can be controlled using the `SPAROID_CACHE_PATH` environment variable
|
5
|
+
|
1
6
|
## [1.0.12] - 2021-06-14
|
2
7
|
|
3
8
|
- Use file locking to prevent multiple processes/threads to write to the public ip cache file
|
@@ -8,7 +13,7 @@
|
|
8
13
|
|
9
14
|
## [1.0.10] - 2021-06-09
|
10
15
|
|
11
|
-
- Cache public IP in
|
16
|
+
- Cache public IP in `/tmp/.sparoid_public_ip` for 1 min
|
12
17
|
|
13
18
|
## [1.0.9] - 2021-05-23
|
14
19
|
|
data/Gemfile
CHANGED
@@ -5,12 +5,9 @@ source "https://rubygems.org"
|
|
5
5
|
# Specify your gem's dependencies in sparoid.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem "rake", "~> 13.0"
|
9
|
-
|
10
8
|
gem "minitest", "~> 5.0"
|
11
|
-
|
9
|
+
gem "minitest-stub-const"
|
10
|
+
gem "rake", "~> 13.0"
|
12
11
|
gem "rubocop", "~> 1.7"
|
13
|
-
|
14
12
|
gem "rubocop-minitest", require: false
|
15
|
-
|
16
13
|
gem "rubocop-rake", require: false
|
data/lib/sparoid.rb
CHANGED
@@ -9,6 +9,8 @@ require "resolv"
|
|
9
9
|
module Sparoid
|
10
10
|
extend self
|
11
11
|
|
12
|
+
SPAROID_CACHE_PATH = ENV.fetch("SPAROID_CACHE_PATH", "/tmp/.sparoid_public_ip")
|
13
|
+
|
12
14
|
# Send an authorization packet
|
13
15
|
def auth(key, hmac_key, host, port)
|
14
16
|
msg = message(cached_public_ip)
|
@@ -87,21 +89,25 @@ module Sparoid
|
|
87
89
|
end
|
88
90
|
|
89
91
|
def up_to_date_cache?
|
90
|
-
mtime = File.mtime(
|
92
|
+
mtime = File.mtime(SPAROID_CACHE_PATH)
|
91
93
|
(Time.now - mtime) <= 60 # cache is valid for 1 min
|
92
94
|
rescue Errno::ENOENT
|
93
95
|
false
|
94
96
|
end
|
95
97
|
|
96
98
|
def read_cache
|
97
|
-
File.open(
|
99
|
+
File.open(SPAROID_CACHE_PATH, "r") do |f|
|
98
100
|
f.flock(File::LOCK_SH)
|
99
101
|
Resolv::IPv4.create f.read
|
100
102
|
end
|
103
|
+
rescue ArgumentError => e
|
104
|
+
return write_cache if e.message =~ /cannot interpret as IPv4 address/
|
105
|
+
|
106
|
+
raise e
|
101
107
|
end
|
102
108
|
|
103
109
|
def write_cache
|
104
|
-
File.open(
|
110
|
+
File.open(SPAROID_CACHE_PATH, File::WRONLY | File::CREAT, 0o0644) do |f|
|
105
111
|
f.flock(File::LOCK_EX)
|
106
112
|
ip = public_ip
|
107
113
|
f.truncate(0)
|
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.13
|
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-06-
|
11
|
+
date: 2021-06-30 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.1.6
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Single Packet Authorisation client
|