immosquare-constants 0.1.15 → 0.1.16

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: e8b740c638cc553f9e3a1bd674d3bf270cfda3832c83552fe1338a26655e14eb
4
- data.tar.gz: 87870755a5c2c463ffb7ff8741ef29ed12d770cada0b5a5a334408ab7d0dd988
3
+ metadata.gz: 97b58fa8bdcd04000abd024afae97165b9b11d0e1e38fcb36bf2233af0926895
4
+ data.tar.gz: f4e113d541371b985f6c75f58c9bc7964adc75c28880ee24c13347696c6c34c4
5
5
  SHA512:
6
- metadata.gz: d62cda99d9972a6649a0153145fbd41b704d7d98a4c8cba01ac131979ffa229ca8bee91887f9f87a5e34883fc913a539631a12bb3d01b946ac1de639ac51393c
7
- data.tar.gz: fc4e75e4f540c793235e2c10c2d52da9dcdea2e37cfef10274b723c8a183daa49f384f7efeff4d6ac402c143dd82bfa359057d268cda2b2f7e059e8888ebd04e
6
+ metadata.gz: e69deefa3385c84aeb8b666f08cb5a34fe53c114f382cd18c3dfcc2a139a28059489509ec6b3cfc2a94beb66bb34f9ea97065bc022bede2931f203f542c407f5
7
+ data.tar.gz: 72cb4e752a34f992c61ce00defa1967b8b0c3efa2092285d38b237e7e1f54a713d088fb1d4801fbab27f0e5a3e1cf8350622b9c1568e9a0433f00fde81237d67
@@ -121,30 +121,34 @@ module ImmosquareConstants
121
121
  raise("IP is localhost (127.0.0.1)") if ip == "127.0.0.1"
122
122
 
123
123
  ip
124
- rescue StandardError => e
124
+ rescue StandardError
125
125
  get_public_ip_from_aws
126
126
  end
127
127
  end
128
128
 
129
129
  ##============================================================##
130
- ## Get public IP address with fallback (for production)
130
+ ## Get public IP address with fallback
131
131
  ##============================================================##
132
132
  def get_public_ip_from_aws
133
133
  begin
134
134
  begin
135
- uri = URI.parse("https://checkip.amazonaws.com/")
136
- response = Net::HTTP.get_response(uri)
137
- raise("No IP found") unless response.is_a?(Net::HTTPSuccess)
135
+ uri = URI.parse("https://checkip.amazonaws.com/")
136
+ http = Net::HTTP.new(uri.host, uri.port)
137
+ http.use_ssl = true
138
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
139
+ response = http.get(uri.request_uri)
140
+ raise("No IP found") if !response.is_a?(Net::HTTPSuccess)
138
141
 
139
142
  response.body.strip
140
143
  rescue StandardError => e
144
+ puts("Error getting public IP from AWS: #{e.message}")
141
145
  s = Socket.ip_address_list.find(&:ipv4_private?)
142
146
  s = Socket.ip_address_list.first if s.nil?
143
147
  raise("No IP found") if s.nil?
144
148
 
145
149
  s.ip_address
146
150
  end
147
- rescue StandardError => e
151
+ rescue StandardError
148
152
  "0.0.0.0"
149
153
  end
150
154
  end
@@ -1,3 +1,3 @@
1
1
  module ImmosquareConstants
2
- VERSION = "0.1.15".freeze
2
+ VERSION = "0.1.16".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: immosquare-constants
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - immosquare
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  requirements: []
44
- rubygems_version: 3.6.9
44
+ rubygems_version: 3.7.2
45
45
  specification_version: 4
46
46
  summary: ImmosquareConstants is a comprehensive collection of constants useful for
47
47
  a variety of applications.