Make mconf-decrypter work with HTTPS and redirects

It now works with HTTPS URLs and will follow one redirect. The redirect is
useful for when the server being requested redirects HTTP to HTTPS.
This commit is contained in:
Leonardo Crauss Daronco 2016-08-16 13:09:19 -03:00
parent f44c25f3f6
commit d860d166df

View File

@ -40,11 +40,25 @@ $recording_dir = bbb_props['recording_dir']
$raw_dir = "#{$recording_dir}/raw" $raw_dir = "#{$recording_dir}/raw"
$archived_dir = "#{$recording_dir}/status/archived" $archived_dir = "#{$recording_dir}/status/archived"
def getRequest(url)
BigBlueButton.logger.info("Fetching #{url}")
url_parsed = URI.parse(url)
http = Net::HTTP.new(url_parsed.host, url_parsed.port)
http.use_ssl = (url_parsed.scheme.downcase == "https")
http.get(url_parsed.request_uri)
end
def fetchRecordings(url) def fetchRecordings(url)
#BigBlueButton.logger.debug("Fetching #{url}")
doc = nil doc = nil
begin begin
doc = Nokogiri::XML(Net::HTTP.get_response(URI.parse(url)).body) response = getRequest(url)
# follow redirects once only
if response.kind_of?(Net::HTTPRedirection)
BigBlueButton.logger.info("Received a redirect, will make a new request")
response = getRequest(response['location'])
end
doc = Nokogiri::XML(response.body)
returncode = doc.xpath("//returncode") returncode = doc.xpath("//returncode")
if returncode.empty? or returncode.text != "SUCCESS" if returncode.empty? or returncode.text != "SUCCESS"
BigBlueButton.logger.error "getRecordings didn't return success:\n#{doc.to_xml(:indent => 2)}" BigBlueButton.logger.error "getRecordings didn't return success:\n#{doc.to_xml(:indent => 2)}"