sparoid 1.1.0 → 1.2.0

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: 71f77a00597cb908e5b898603a34ed4e9111fd7fdcd255def5ea1633089c6041
4
- data.tar.gz: d4ba950c8fa66e6083e7bf43431618023aa8b163c1d12f6170835532c719ee03
3
+ metadata.gz: c24825e92fdb072067eb45465af26badb031dae413445c2acb4ec979bfe4afaf
4
+ data.tar.gz: e77fe5c9f7ad1c014534a51420bd9d1144f8f5fadbbcc1f28fcc8d4c0d52cf2c
5
5
  SHA512:
6
- metadata.gz: 3f50ca4d5ebf7c68badec3afe5f49ea3c7d23eaa932448f2f3534fd6dc594b8bcecc8ad7c9e5f4e0b4453538fdbf45884ba6c3a5ab3c645eb6feb4ed5eabbff2
7
- data.tar.gz: 77c377f37dfa0dc257af730d25fb7600cb4cc6fe45e1e809e455c55c3fce5bce429abbbc82080cafa1a1f7fbb6dfcfe4fb5dede8d0eea2e904ee023403197d1b
6
+ metadata.gz: 8ded4f653d9e8526b3dc4cfe6391deb2df878dd004f7e5c7c694514f251efc865e992f6a0779fa50be7cfeeb88d92b82a982f3de98a89e020e8062b7fcd8b77a
7
+ data.tar.gz: eb545dc80266d74df92a228b09266f33edf0a9612715196d82282a6bb506ece3bf62cb361a0523516a5e7d1af9e989c1ee606e3212d7471c0b8f9daea318571e
@@ -1,18 +1,22 @@
1
1
  name: Ruby
2
2
 
3
- on: [push,pull_request]
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
4
8
 
5
9
  jobs:
6
10
  build:
7
11
  strategy:
8
12
  fail-fast: false
9
13
  matrix:
10
- ruby: [ 2.7, '3.0', 3.1, ruby-head ]
14
+ ruby: [ 2.7, 3.1, 3.2, 3.3, ruby-head ]
11
15
  runs-on: ubuntu-latest
12
16
  steps:
13
- - uses: actions/checkout@v3
17
+ - uses: actions/checkout@v4
14
18
  - uses: ruby/setup-ruby@v1
15
19
  with:
16
20
  ruby-version: ${{ matrix.ruby }}
17
- - run: bundle install
21
+ bundler-cache: true
18
22
  - run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.2.0] - 2024-07-24
2
+
3
+ - Lookup public IP using http://checkip.amazonaws.com, as it's more reliable for IPv6 connections than the DNS method
4
+
1
5
  ## [1.1.0] - 2023-03-03
2
6
 
3
7
  - Allow override of public ip, open for someone else by passing `:open_for_ip` to `Sparoid.auth(..., open_for_ip:)` (#11)
data/CODEOWNERS ADDED
@@ -0,0 +1 @@
1
+ * @84codes/server
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sparoid
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
data/lib/sparoid.rb CHANGED
@@ -149,9 +149,21 @@ module Sparoid # rubocop:disable Metrics/ModuleLength
149
149
  end
150
150
  end
151
151
 
152
- def public_ip
153
- Resolv::DNS.open(nameserver: ["208.67.222.222", "208.67.220.220"]) do |dns|
154
- dns.getresource("myip.opendns.com", Resolv::DNS::Resource::IN::A).address
152
+ def public_ip(host = "checkip.amazonaws.com", port = 80) # rubocop:disable Metrics/MethodLength
153
+ Socket.tcp(host, port, connect_timeout: 3) do |sock|
154
+ sock.sync = true
155
+ sock.print "GET / HTTP/1.1\r\nHost: #{host}\r\nConnection: close\r\n\r\n"
156
+ status = sock.readline(chomp: true)
157
+ raise(ResolvError, "#{host}:#{port} response: #{status}") unless status.start_with? "HTTP/1.1 200 "
158
+
159
+ content_length = 0
160
+ until (header = sock.readline(chomp: true)).empty?
161
+ if (m = header.match(/^Content-Length: (\d+)/))
162
+ content_length = m[1].to_i
163
+ end
164
+ end
165
+ ip = sock.read(content_length).chomp
166
+ Resolv::IPv4.create ip
155
167
  end
156
168
  end
157
169
 
@@ -172,9 +184,7 @@ module Sparoid # rubocop:disable Metrics/ModuleLength
172
184
  class Instance
173
185
  include Sparoid
174
186
 
175
- private
176
-
177
- def public_ip
187
+ def public_ip(*args)
178
188
  @public_ip ||= super
179
189
  end
180
190
 
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.1.0
4
+ version: 1.2.0
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: 2023-03-03 00:00:00.000000000 Z
11
+ date: 2024-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -36,6 +36,7 @@ files:
36
36
  - ".gitignore"
37
37
  - ".rubocop.yml"
38
38
  - CHANGELOG.md
39
+ - CODEOWNERS
39
40
  - Gemfile
40
41
  - LICENSE.txt
41
42
  - README.md
@@ -70,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
71
  - !ruby/object:Gem::Version
71
72
  version: '0'
72
73
  requirements: []
73
- rubygems_version: 3.4.5
74
+ rubygems_version: 3.5.11
74
75
  signing_key:
75
76
  specification_version: 4
76
77
  summary: Single Packet Authorisation client