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 +4 -4
- data/lib/immosquare-constants/ip.rb +10 -6
- data/lib/immosquare-constants/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b58fa8bdcd04000abd024afae97165b9b11d0e1e38fcb36bf2233af0926895
|
4
|
+
data.tar.gz: f4e113d541371b985f6c75f58c9bc7964adc75c28880ee24c13347696c6c34c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
136
|
-
|
137
|
-
|
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
|
151
|
+
rescue StandardError
|
148
152
|
"0.0.0.0"
|
149
153
|
end
|
150
154
|
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.
|
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.
|
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.
|