2012-12-01 00:16:42 +08:00
|
|
|
# Set encoding to utf-8
|
|
|
|
# encoding: UTF-8
|
|
|
|
#
|
|
|
|
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
|
|
|
|
#
|
|
|
|
# Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify it under the
|
|
|
|
# terms of the GNU Lesser General Public License as published by the Free Software
|
|
|
|
# Foundation; either version 3.0 of the License, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
#
|
|
|
|
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
|
|
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
require '../../core/lib/recordandplayback'
|
|
|
|
require 'rubygems'
|
|
|
|
require 'yaml'
|
2013-01-10 23:16:08 +08:00
|
|
|
require 'net/http'
|
|
|
|
require 'rexml/document'
|
|
|
|
require 'open-uri'
|
2012-12-01 00:16:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
#BigBlueButton.logger = Logger.new("/var/log/bigbluebutton/uncrypt.log",'daily' )
|
|
|
|
|
|
|
|
BigBlueButton.logger = Logger.new("/var/log/bigbluebutton/uncypt.log",'daily' )
|
|
|
|
|
|
|
|
bbb_props = YAML::load(File.open('../../core/scripts/bigbluebutton.yml'))
|
|
|
|
mconf_props = YAML::load(File.open('mconf.yml'))
|
|
|
|
#private_key = mconf_props['privatekey']
|
2013-01-10 23:16:08 +08:00
|
|
|
xml_url = mconf_props['get_recordings_url']
|
2012-12-01 00:16:42 +08:00
|
|
|
recording_dir = bbb_props['recording_dir']
|
|
|
|
rawdir = "#{recording_dir}/raw"
|
2013-01-18 00:05:48 +08:00
|
|
|
archived_dir = "#{recording_dir}/status/archived"
|
2013-01-10 23:16:08 +08:00
|
|
|
|
2013-01-18 00:05:48 +08:00
|
|
|
xml_data = Net::HTTP.get_response(URI.parse(xml_url)).body
|
2013-01-10 23:16:08 +08:00
|
|
|
doc = REXML::Document.new(xml_data)
|
2013-01-18 00:05:48 +08:00
|
|
|
|
2013-01-10 23:16:08 +08:00
|
|
|
files_url = []
|
|
|
|
types = []
|
2013-01-18 00:05:48 +08:00
|
|
|
keys_url = []
|
|
|
|
md5_server_side = []
|
2013-01-10 23:16:08 +08:00
|
|
|
doc.elements.each('response/recordings/recording/playback/format/type') do |type|
|
|
|
|
types << type.text
|
|
|
|
end
|
|
|
|
doc.elements.each('response/recordings/recording/playback/format/url') do |url|
|
|
|
|
files_url << url.text
|
|
|
|
end
|
2013-01-18 00:05:48 +08:00
|
|
|
doc.elements.each('response/recordings/recording/playback/format/md5') do |md5|
|
|
|
|
md5_server_side << md5.text
|
|
|
|
end
|
|
|
|
doc.elements.each('response/recordings/recording/playback/format/key') do |key|
|
|
|
|
keys_url << key.text
|
|
|
|
end
|
2013-01-10 23:16:08 +08:00
|
|
|
|
|
|
|
types.each_with_index do |eachtype, idx|
|
2013-01-18 00:05:48 +08:00
|
|
|
if (eachtype == "encrypted") then
|
|
|
|
url = files_url[idx]
|
|
|
|
file = url.split("/").last
|
|
|
|
match = /(.*).dat/.match file
|
|
|
|
meeting_id = match[1]
|
|
|
|
if not File.exist?("#{archived_dir}/#{meeting_id}.done"
|
|
|
|
Dir.chdir(rawdir) do
|
|
|
|
|
|
|
|
|
|
|
|
puts file
|
2013-01-10 23:16:08 +08:00
|
|
|
|
2013-01-18 00:05:48 +08:00
|
|
|
writeOut = open(file, "wb")
|
|
|
|
writeOut.write(open(url).read)
|
|
|
|
writeOut.close
|
|
|
|
|
|
|
|
i = url.length
|
|
|
|
j = file.length
|
2013-01-10 23:16:08 +08:00
|
|
|
|
2013-01-18 00:05:48 +08:00
|
|
|
writeOut = open("#{file[0 .. j-5] }.enc", "wb")
|
|
|
|
writeOut.write(open("#{url[0 .. i-5]}.enc").read)
|
|
|
|
writeOut.close
|
2013-01-10 23:16:08 +08:00
|
|
|
|
2013-01-18 00:05:48 +08:00
|
|
|
archived_done = File.new("#{archived_dir}/#{meeting_id}.done", "w")
|
|
|
|
process_done.write("Archived #{meeting_id}")
|
|
|
|
process_done.close
|
|
|
|
end
|
|
|
|
end
|
2013-01-10 23:16:08 +08:00
|
|
|
|
2013-01-18 00:05:48 +08:00
|
|
|
end
|
2013-01-10 23:16:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-12-01 00:16:42 +08:00
|
|
|
#BigBlueButton.logger.info("DIR: #{recording_dir} ")
|
|
|
|
criptfiles = Dir.glob("#{recording_dir}/raw/*.dat")
|
|
|
|
criptfiles.each do |cf|
|
|
|
|
match = /(.*).dat/.match cf.sub(/.+\//, "")
|
|
|
|
meeting_id = match[1]
|
2012-12-20 20:30:40 +08:00
|
|
|
if File.exist?("#{rawdir}/#{meeting_id}.enc")
|
|
|
|
Dir.chdir(rawdir) do
|
2012-12-01 00:16:42 +08:00
|
|
|
command = "openssl rsautl -decrypt -inkey key.pem < #{meeting_id}.enc > key.txt"
|
|
|
|
BigBlueButton.logger.info(command)
|
|
|
|
Open3.popen3(command) do | stdin, stdout, stderr|
|
|
|
|
#BigBlueButton.logger.info("commandresult=") #{$?.exitstatus}")
|
|
|
|
end
|
|
|
|
command = "openssl enc -aes-256-cbc -d -pass file:key.txt < #{meeting_id}.dat > #{meeting_id}.zip"
|
|
|
|
BigBlueButton.logger.info(command)
|
|
|
|
Open3.popen3(command) do | stdin, stdout, stderr|
|
|
|
|
#BigBlueButton.logger.info("commandresult2") #{$?.exitstatus}")
|
|
|
|
end
|
|
|
|
|
2012-12-20 20:30:40 +08:00
|
|
|
BigBlueButton::MconfProcessor.unzip(rawdir, "#{meeting_id}.zip")
|
2012-12-01 00:16:42 +08:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# BigBlueButton.logger = Logger.new("/var/log/bigbluebutton/mconf/uncrypt-#{meeting_id}.log", 'daily' )
|
|
|
|
|
|
|
|
#BigBlueButton.logger.info("teste Meeting id calculated:")
|
|
|
|
# BigBlueButton.logger = Logger.new("/var/log/bigbluebutton/mconf/uncrypt.log", 'daily' )
|
|
|
|
# BigBlueButton.logger.info("Meeting id calculated: #{meeting_id}")
|
|
|
|
end
|
|
|
|
|