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'
|
2013-01-22 23:56:12 +08:00
|
|
|
require 'digest/md5'
|
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']
|
2013-01-24 00:49:33 +08:00
|
|
|
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-22 23:56:12 +08:00
|
|
|
doc.elements.each('response/recordings/recording/download/format/type') do |type|
|
2013-01-10 23:16:08 +08:00
|
|
|
types << type.text
|
|
|
|
end
|
2013-01-22 23:56:12 +08:00
|
|
|
doc.elements.each('response/recordings/recording/download/format/url') do |url|
|
2013-01-10 23:16:08 +08:00
|
|
|
files_url << url.text
|
|
|
|
end
|
2013-01-22 23:56:12 +08:00
|
|
|
doc.elements.each('response/recordings/recording/download/format/md5') do |md5|
|
2013-01-18 00:05:48 +08:00
|
|
|
md5_server_side << md5.text
|
|
|
|
end
|
2013-01-22 23:56:12 +08:00
|
|
|
doc.elements.each('response/recordings/recording/download/format/key') do |key|
|
2013-01-18 00:05:48 +08:00
|
|
|
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]
|
2013-01-22 23:56:12 +08:00
|
|
|
k_url = keys_url[idx]
|
|
|
|
encrypted_file = url.split("/").last
|
|
|
|
match = /(.*).dat/.match encrypted_file
|
2013-01-18 00:05:48 +08:00
|
|
|
meeting_id = match[1]
|
2013-01-22 23:56:12 +08:00
|
|
|
if not File.exist?("#{archived_dir}/#{meeting_id}.done") then
|
2013-01-18 00:05:48 +08:00
|
|
|
Dir.chdir(rawdir) do
|
|
|
|
|
2013-01-22 23:56:12 +08:00
|
|
|
writeOut = open(encrypted_file, "wb")
|
2013-01-18 00:05:48 +08:00
|
|
|
writeOut.write(open(url).read)
|
|
|
|
writeOut.close
|
2013-01-22 23:56:12 +08:00
|
|
|
|
|
|
|
md5sum = Digest::MD5.file(encrypted_file)
|
|
|
|
|
|
|
|
if (md5sum == md5_server_side[idx]) then
|
|
|
|
key_file = k_url.split("/").last
|
|
|
|
writeOut = open(key_file, "wb")
|
|
|
|
writeOut.write(open(k_url).read)
|
|
|
|
writeOut.close
|
|
|
|
|
|
|
|
puts "salvo"
|
2013-01-18 00:05:48 +08:00
|
|
|
|
2013-01-22 23:56:12 +08:00
|
|
|
command = "openssl rsautl -decrypt -inkey key.pem < #{key_file} > 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 < #{encrypted_file} > #{meeting_id}.zip"
|
|
|
|
BigBlueButton.logger.info(command)
|
|
|
|
Open3.popen3(command) do | stdin, stdout, stderr|
|
|
|
|
BigBlueButton.logger.info("commandresult2") #{$?.exitstatus}")
|
|
|
|
end
|
|
|
|
|
|
|
|
BigBlueButton::MconfProcessor.unzip(rawdir, "#{meeting_id}.zip")
|
2013-01-10 23:16:08 +08:00
|
|
|
|
|
|
|
|
2013-01-22 23:56:12 +08:00
|
|
|
archived_done = File.new("#{archived_dir}/#{meeting_id}.done", "w")
|
|
|
|
archived_done.write("Archived #{meeting_id}")
|
|
|
|
archived_done.close
|
2013-01-24 00:49:33 +08:00
|
|
|
|
|
|
|
BigBlueButton.logger.info("Removing files")
|
|
|
|
ZIPFILE = "#{meeting_id}.zip"
|
|
|
|
[encrypted_file, key_file, "key.txt", ZIPFILE].each { |file| FileUtils.rm_f(file)}
|
2013-01-22 23:56:12 +08:00
|
|
|
else
|
2013-01-24 00:49:33 +08:00
|
|
|
FileUtils.rm_f(encrypted_file)
|
2013-01-22 23:56:12 +08:00
|
|
|
end
|
|
|
|
|
2013-01-18 00:05:48 +08:00
|
|
|
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} ")
|
2013-01-22 23:56:12 +08:00
|
|
|
=begin
|
2012-12-01 00:16:42 +08:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2013-01-22 23:56:12 +08:00
|
|
|
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}")
|
2012-12-01 00:16:42 +08:00
|
|
|
end
|
2013-01-22 23:56:12 +08:00
|
|
|
=end
|