12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/aspera/cli/plugins/console.rb', line 12
def detect(address_or_url)
address_or_url = "https://#{address_or_url}" unless address_or_url.match?(%r{^[a-z]{1,6}://})
urls = [address_or_url]
urls.push("#{address_or_url}#{STANDARD_PATH}") unless address_or_url.end_with?(STANDARD_PATH)
error = nil
urls.each do |base_url|
next unless base_url.start_with?('https://')
api = Rest.new(base_url: base_url, redirect_max: 2)
test_endpoint = 'login'
test_page = api.call(
operation: 'GET',
subpath: test_endpoint,
query: {local: true})
next unless test_page[:http].body.include?('Aspera Console')
version = 'unknown'
if (m = test_page[:http].body.match(/\(v([1-9]\..*)\)/))
version = m[1]
end
url = test_page[:http].uri.to_s
return {
version: version,
url: url[0..url.index(test_endpoint) - 2]
}
rescue StandardError => e
error = e
Log.log.debug{"detect error: #{e}"}
end
raise error if error
return nil
end
|