feat: v1.9.7
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1989,7 +1989,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tiny-encrypt"
|
name = "tiny-encrypt"
|
||||||
version = "1.9.6"
|
version = "1.9.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm-stream",
|
"aes-gcm-stream",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tiny-encrypt"
|
name = "tiny-encrypt"
|
||||||
version = "1.9.6"
|
version = "1.9.7"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "A simple and tiny file encrypt tool"
|
description = "A simple and tiny file encrypt tool"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use rust_util::util_file::resolve_file_path;
|
|||||||
use rust_util::{debugging, opt_result, simple_error, warning, XResult};
|
use rust_util::{debugging, opt_result, simple_error, warning, XResult};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::consts::{TINY_ENC_CONFIG_FILE, TINY_ENC_CONFIG_FILE_2, TINY_ENC_CONFIG_FILE_3, TINY_ENC_FILE_EXT};
|
use crate::consts::{ENV_TINY_ENC_CONFIG_FILE, TINY_ENC_CONFIG_FILE, TINY_ENC_CONFIG_FILE_2, TINY_ENC_CONFIG_FILE_3, TINY_ENC_FILE_EXT};
|
||||||
use crate::spec::TinyEncryptEnvelopType;
|
use crate::spec::TinyEncryptEnvelopType;
|
||||||
|
|
||||||
/// Config file sample:
|
/// Config file sample:
|
||||||
@@ -75,12 +75,17 @@ pub struct TinyEncryptConfigEnvelop {
|
|||||||
|
|
||||||
impl TinyEncryptConfig {
|
impl TinyEncryptConfig {
|
||||||
pub fn load_default() -> XResult<Self> {
|
pub fn load_default() -> XResult<Self> {
|
||||||
let resolved_file = resolve_file_path(TINY_ENC_CONFIG_FILE);
|
let resolved_file0 = env::var(ENV_TINY_ENC_CONFIG_FILE).ok();
|
||||||
|
let resolved_file_1 = resolve_file_path(TINY_ENC_CONFIG_FILE);
|
||||||
let resolved_file_2 = resolve_file_path(TINY_ENC_CONFIG_FILE_2);
|
let resolved_file_2 = resolve_file_path(TINY_ENC_CONFIG_FILE_2);
|
||||||
let resolved_file_3 = resolve_file_path(TINY_ENC_CONFIG_FILE_3);
|
let resolved_file_3 = resolve_file_path(TINY_ENC_CONFIG_FILE_3);
|
||||||
let config_file = if fs::metadata(&resolved_file).is_ok() {
|
if let Some(resolved_file) = resolved_file0 {
|
||||||
debugging!("Load config from: {resolved_file}");
|
debugging!("Found tiny encrypt config file: {}", &resolved_file);
|
||||||
resolved_file
|
return Self::load(&resolved_file)
|
||||||
|
}
|
||||||
|
let config_file = if fs::metadata(&resolved_file_1).is_ok() {
|
||||||
|
debugging!("Load config from: {resolved_file_1}");
|
||||||
|
resolved_file_1
|
||||||
} else if fs::metadata(&resolved_file_2).is_ok() {
|
} else if fs::metadata(&resolved_file_2).is_ok() {
|
||||||
debugging!("Load config from: {resolved_file_2}");
|
debugging!("Load config from: {resolved_file_2}");
|
||||||
resolved_file_2
|
resolved_file_2
|
||||||
@@ -88,8 +93,8 @@ impl TinyEncryptConfig {
|
|||||||
debugging!("Load config from: {resolved_file_3}");
|
debugging!("Load config from: {resolved_file_3}");
|
||||||
resolved_file_3
|
resolved_file_3
|
||||||
} else {
|
} else {
|
||||||
warning!("Cannot find config file from:\n- {resolved_file}\n- {resolved_file_2}\n- {resolved_file_3}");
|
warning!("Cannot find config file from:\n- {resolved_file_1}\n- {resolved_file_2}\n- {resolved_file_3}");
|
||||||
resolved_file
|
resolved_file_1
|
||||||
};
|
};
|
||||||
Self::load(&config_file)
|
Self::load(&config_file)
|
||||||
}
|
}
|
||||||
@@ -294,7 +299,7 @@ pub fn resolve_path_namespace(
|
|||||||
|
|
||||||
pub fn load_includes_and_merge(mut config: TinyEncryptConfig) -> TinyEncryptConfig {
|
pub fn load_includes_and_merge(mut config: TinyEncryptConfig) -> TinyEncryptConfig {
|
||||||
if let Some(includes) = &config.includes {
|
if let Some(includes) = &config.includes {
|
||||||
let sub_configs = search_include_configs(&includes);
|
let sub_configs = search_include_configs(includes);
|
||||||
debugging!(
|
debugging!(
|
||||||
"Found {} sub configs, detail {:?}",
|
"Found {} sub configs, detail {:?}",
|
||||||
sub_configs.len(),
|
sub_configs.len(),
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ pub const ENC_CHACHA20_POLY1305_KYBER1204: &str = "chacha20-poly1305-kyber1204";
|
|||||||
// Extend and config file
|
// Extend and config file
|
||||||
pub const TINY_ENC_FILE_EXT: &str = ".tinyenc";
|
pub const TINY_ENC_FILE_EXT: &str = ".tinyenc";
|
||||||
pub const TINY_ENC_PEM_FILE_EXT: &str = ".tinyenc.pem";
|
pub const TINY_ENC_PEM_FILE_EXT: &str = ".tinyenc.pem";
|
||||||
|
pub const ENV_TINY_ENC_CONFIG_FILE: &str = "TINY_ENCRYPT_CONFIG_FILE";
|
||||||
pub const TINY_ENC_CONFIG_FILE: &str = "~/.tinyencrypt/config-rs.json";
|
pub const TINY_ENC_CONFIG_FILE: &str = "~/.tinyencrypt/config-rs.json";
|
||||||
pub const TINY_ENC_CONFIG_FILE_2: &str = "~/.config/tinyencrypt-rs.json";
|
pub const TINY_ENC_CONFIG_FILE_2: &str = "~/.config/tinyencrypt-rs.json";
|
||||||
pub const TINY_ENC_CONFIG_FILE_3: &str = "/etc/tinyencrypt/config-rs.json";
|
pub const TINY_ENC_CONFIG_FILE_3: &str = "/etc/tinyencrypt/config-rs.json";
|
||||||
|
|||||||
Reference in New Issue
Block a user