check ifconfig.me return before use (#855)

This commit is contained in:
Jamil
2022-07-26 21:23:08 -07:00
committed by GitHub
parent 61c9ea5e98
commit f2c8b4b900

View File

@@ -21,8 +21,10 @@ unless node['firezone']['wireguard']['endpoint']
# Figure out a sane default endpoint IP address
egress_ip =
begin
Net::HTTP.get('ifconfig.me', '/')
rescue StandardError
# Parse to ensure we get back something usable.
URI.parse(Net::HTTP.get('ifconfig.me', '/'))
rescue StandardError => e
Chef::Log.warn(e)
nil
end
node.consume_attributes('firezone' => { 'wireguard' => { 'endpoint' => egress_ip } })