Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domains without an AAA record / that are not reacable fail further lookup tries. #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions lib/autodiscover/pox_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,13 @@ def initialize(client, **options)
# @return [Autodiscover::PoxResponse, nil]
def autodiscover
available_urls.each do |url|
begin
response = client.http.post(url, request_body, {'Content-Type' => 'text/xml; charset=utf-8'})
return PoxResponse.new(response.body) if good_response?(response)
rescue Errno::ENETUNREACH, Errno::ECONNREFUSED, HTTPClient::ConnectTimeoutError
next
rescue OpenSSL::SSL::SSLError
options[:ignore_ssl_errors] ? next : raise
end
response = client.http.post(url, request_body, {'Content-Type' => 'text/xml; charset=utf-8'})
return PoxResponse.new(response.body) if good_response?(response)
end
end


private


def good_response?(response)
response.status == 200
end
Expand All @@ -39,10 +31,14 @@ def available_urls(&block)
return to_enum(__method__) unless block_given?
formatted_https_urls.each {|url|
logger.debug "Yielding HTTPS Url #{url}"
yield url
handle_allowed_errors do
yield url
end
}
logger.debug "Yielding HTTP Redirected Url #{redirected_http_url}"
yield redirected_http_url
handle_allowed_errors do
logger.debug "Yielding HTTP Redirected Url #{redirected_http_url}"
yield redirected_http_url
end
end

def formatted_https_urls
Expand Down Expand Up @@ -71,5 +67,11 @@ def request_body
end.to_xml
end

def handle_allowed_errors
yield
rescue SocketError, Errno::EHOSTUNREACH, Errno::ENETUNREACH, Errno::ECONNREFUSED, HTTPClient::ConnectTimeoutError
rescue OpenSSL::SSL::SSLError
raise if !options[:ignore_ssl_errors]
end
end
end