Module: Bitferry::Rclone
Defined Under Namespace
Classes: Copy, Decrypt, Encrypt, Encryption, Equalize, Synchronize, Task, Update
Constant Summary
collapse
- SECRET =
"\x9c\x93\x5b\x48\x73\x0a\x55\x4d\x6b\xfd\x7c\x63\xc8\x86\xa9\x2b\xd3\x90\x19\x8e\xb8\x12\x8a\xfb\xf4\xde\x16\x2b\x8b\x95\xf6\x38"
- ROUTE =
{
encrypt: Encrypt,
decrypt: Decrypt
}
Class Method Summary
collapse
Methods included from Logging
log, log, log=
Class Method Details
.exec(*args) ⇒ Object
696
697
698
699
700
701
702
703
704
705
706
|
# File 'lib/bitferry.rb', line 696
def self.exec(*args)
cmd = [executable] + args
log.debug(cmd.collect(&:shellescape).join(' '))
stdout, status = Open3.capture2e(*cmd)
unless status.success?
msg = "rclone exit code #{status.exitstatus}"
log.error(msg)
raise RuntimeError, msg
end
stdout.strip
end
|
.executable ⇒ Object
693
|
# File 'lib/bitferry.rb', line 693
def self.executable = @executable ||= (rclone = ENV['RCLONE']).nil? ? 'rclone' : rclone
|
.obscure(plain) ⇒ Object
713
714
715
716
717
718
|
# File 'lib/bitferry.rb', line 713
def self.obscure(plain)
cipher = OpenSSL::Cipher.new('AES-256-CTR')
cipher.encrypt
cipher.key = SECRET
Base64.urlsafe_encode64(cipher.random_iv + cipher.update(plain) + cipher.final, padding: false)
end
|
.reveal(token) ⇒ Object
721
722
723
724
725
726
727
728
|
# File 'lib/bitferry.rb', line 721
def self.reveal(token)
data = Base64.urlsafe_decode64(token)
cipher = OpenSSL::Cipher.new('AES-256-CTR')
cipher.decrypt
cipher.key = SECRET
cipher.iv = data[0...cipher.iv_len]
cipher.update(data[cipher.iv_len..-1]) + cipher.final
end
|