#8365 recovery after vscode revert error
This commit is contained in:
parent
e062db2439
commit
63c74e2aa9
|
@ -1,7 +1,7 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tncm_queue`
|
||||
ADD COLUMN `id_agent_data` INT NOT NULL DEFAULT 0 AFTER `id_script`;
|
||||
ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`,
|
||||
ADD CONSTRAINT `fk_tncm_queue_tncm_agent_data` FOREIGN KEY (`id_agent_data`) REFERENCES `tncm_agent_data`(`id`) ON UPDATE CASCADE ON DELETE SET NULL;
|
||||
|
||||
|
||||
COMMIT;
|
||||
COMMIT;
|
||||
|
|
|
@ -4240,10 +4240,12 @@ CREATE TABLE IF NOT EXISTS `tncm_queue` (
|
|||
`id` SERIAL,
|
||||
`id_agent` INT UNSIGNED NOT NULL,
|
||||
`id_script` BIGINT UNSIGNED NOT NULL,
|
||||
`id_agent_data` bigint unsigned,
|
||||
`utimestamp` INT UNSIGNED NOT NULL,
|
||||
`scheduled` INT UNSIGNED DEFAULT NULL,
|
||||
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_agent_data`) REFERENCES `tncm_agent_data`(`id`) ON UPDATE CASCADE ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
|
|
|
@ -30,6 +30,9 @@ use Scalar::Util qw(looks_like_number);
|
|||
use LWP::UserAgent;
|
||||
use threads;
|
||||
use threads::shared;
|
||||
use MIME::Base64;
|
||||
use Crypt::CBC;
|
||||
use Digest::SHA qw(hmac_sha256_base64);
|
||||
|
||||
use JSON;
|
||||
use Encode qw/decode_utf8 encode_utf8/;
|
||||
|
@ -181,6 +184,7 @@ our @EXPORT = qw(
|
|||
check_cron_value
|
||||
check_cron_element
|
||||
cron_check
|
||||
decrypt_AES
|
||||
);
|
||||
|
||||
# ID of the different servers
|
||||
|
@ -2983,6 +2987,63 @@ sub get_server_name {
|
|||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Encrypt with AES cypher
|
||||
###############################################################################
|
||||
sub encrypt_AES {
|
||||
my ($str_to_encrypt, $password) = @_;
|
||||
|
||||
if (!defined($password)) {
|
||||
$password = "default_salt";
|
||||
}
|
||||
my $cipher = _get_cipher($password);
|
||||
|
||||
my $cipher_text = $cipher->encrypt($str_to_encrypt);
|
||||
my $b64str = encode_base64($cipher_text, '');
|
||||
|
||||
return $b64str;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Decrypt with AES cypher
|
||||
###############################################################################
|
||||
sub decrypt_AES {
|
||||
my ($str_to_decrypt, $password) = @_;
|
||||
|
||||
if (!defined($password)) {
|
||||
$password = "default_salt";
|
||||
}
|
||||
my $cipher = _get_cipher($password);
|
||||
|
||||
my $cipher_text = decode_base64($str_to_decrypt);
|
||||
my $decrypted_str = $cipher->decrypt($cipher_text);
|
||||
|
||||
return $decrypted_str;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Get cipher for AES encrypt and decrypt
|
||||
###############################################################################
|
||||
sub _get_cipher {
|
||||
my ($password) = @_;
|
||||
|
||||
my $hash_base64 = substr(Digest::SHA::hmac_sha256_base64($password,''), 0, 16);
|
||||
|
||||
my $iv = '0000000000000000';
|
||||
|
||||
my $cipher = Crypt::CBC->new(
|
||||
-key => $hash_base64,
|
||||
-cipher => 'Cipher::AES',
|
||||
-iv => $iv,
|
||||
-header => 'none',
|
||||
-padding => 'standard', # PKCS7 padding
|
||||
-keysize => 16,
|
||||
-literal_key => 1
|
||||
);
|
||||
|
||||
return $cipher;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
|
Loading…
Reference in New Issue