mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-09 06:47:59 -06:00
Fix unshell_obfuscate error. remove default encryption key error when there isn't any encryption
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ chrono = { workspace = true }
|
|||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
|
|
||||||
unshell-obfuscate = {path = "./unshell-obfuscate"}
|
unshell-obfuscate = { path = "./unshell-obfuscate" }
|
||||||
# unshell-crypt = {path = "./unshell-crypt"}
|
# unshell-crypt = {path = "./unshell-crypt"}
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use serde_json::{Value, json};
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::config::ConfigStructField;
|
use crate::config::ConfigStructField;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! debug {
|
macro_rules! debug {
|
||||||
($fmt:tt) => {{
|
($fmt:tt) => {{
|
||||||
|
use $crate::unshell_obfuscate;
|
||||||
let log_result = unshell_obfuscate::format_obs!($fmt);
|
let log_result = unshell_obfuscate::format_obs!($fmt);
|
||||||
|
|
||||||
$crate::logger::add_record(
|
$crate::logger::add_record(
|
||||||
@@ -17,6 +18,7 @@ macro_rules! debug {
|
|||||||
);
|
);
|
||||||
}};
|
}};
|
||||||
($fmt:tt, $($arg:expr),*) => {{
|
($fmt:tt, $($arg:expr),*) => {{
|
||||||
|
use $crate::unshell_obfuscate;
|
||||||
let log_result = unshell_obfuscate::format_obs!($fmt, $($arg),*);
|
let log_result = unshell_obfuscate::format_obs!($fmt, $($arg),*);
|
||||||
|
|
||||||
$crate::logger::add_record(
|
$crate::logger::add_record(
|
||||||
@@ -48,6 +50,7 @@ macro_rules! debug {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! info {
|
macro_rules! info {
|
||||||
($fmt:tt) => {{
|
($fmt:tt) => {{
|
||||||
|
use $crate::unshell_obfuscate;
|
||||||
let log_result = unshell_obfuscate::format_obs!($fmt);
|
let log_result = unshell_obfuscate::format_obs!($fmt);
|
||||||
|
|
||||||
$crate::logger::add_record(
|
$crate::logger::add_record(
|
||||||
@@ -63,6 +66,7 @@ macro_rules! info {
|
|||||||
);
|
);
|
||||||
}};
|
}};
|
||||||
($fmt:tt, $($arg:expr),*) => {{
|
($fmt:tt, $($arg:expr),*) => {{
|
||||||
|
use $crate::unshell_obfuscate;
|
||||||
let log_result = unshell_obfuscate::format_obs!($fmt, $($arg),*);
|
let log_result = unshell_obfuscate::format_obs!($fmt, $($arg),*);
|
||||||
|
|
||||||
$crate::logger::add_record(
|
$crate::logger::add_record(
|
||||||
@@ -82,6 +86,8 @@ macro_rules! info {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! warn {
|
macro_rules! warn {
|
||||||
($fmt:tt) => {{
|
($fmt:tt) => {{
|
||||||
|
use $crate::unshell_obfuscate;
|
||||||
|
|
||||||
let log_result = unshell_obfuscate::format_obs!($fmt);
|
let log_result = unshell_obfuscate::format_obs!($fmt);
|
||||||
|
|
||||||
$crate::logger::add_record(
|
$crate::logger::add_record(
|
||||||
@@ -97,6 +103,8 @@ macro_rules! warn {
|
|||||||
);
|
);
|
||||||
}};
|
}};
|
||||||
($fmt:tt, $($arg:expr),*) => {{
|
($fmt:tt, $($arg:expr),*) => {{
|
||||||
|
use $crate::unshell_obfuscate;
|
||||||
|
|
||||||
let log_result = unshell_obfuscate::format_obs!($fmt, $($arg),*);
|
let log_result = unshell_obfuscate::format_obs!($fmt, $($arg),*);
|
||||||
|
|
||||||
$crate::logger::add_record(
|
$crate::logger::add_record(
|
||||||
@@ -131,6 +139,7 @@ macro_rules! error {
|
|||||||
);
|
);
|
||||||
}};
|
}};
|
||||||
($fmt:tt, $($arg:expr),*) => {{
|
($fmt:tt, $($arg:expr),*) => {{
|
||||||
|
use $crate::unshell_obfuscate;
|
||||||
let log_result = unshell_obfuscate::format_obs!($fmt, $($arg),*);
|
let log_result = unshell_obfuscate::format_obs!($fmt, $($arg),*);
|
||||||
|
|
||||||
$crate::logger::add_record(
|
$crate::logger::add_record(
|
||||||
|
|||||||
@@ -4,13 +4,10 @@ edition = "2024"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
log = ["unshell/log"]
|
log = ["unshell/log"]
|
||||||
log_debug = ["log", "unshell/log_debug"]
|
log_debug = ["unshell/log_debug"]
|
||||||
|
|
||||||
obfuscate = ["unshell/obfuscate"]
|
obfuscate = ["unshell/obfuscate"]
|
||||||
|
|
||||||
# client = ["unshell-lib/client"]
|
|
||||||
# server = ["unshell-lib/server"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
unshell = {path = "../", default-features = false}
|
unshell = {path = "../", default-features = false}
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,20 @@ use quote::quote;
|
|||||||
use syn::{ItemFn, LitStr, parse_macro_input};
|
use syn::{ItemFn, LitStr, parse_macro_input};
|
||||||
use unshell_crypt::{BACKUP_ENV_KEY, ENV_KEY_NAME, STATIC_IV, aes::encrypt_aes_lines, fill};
|
use unshell_crypt::{BACKUP_ENV_KEY, ENV_KEY_NAME, STATIC_IV, aes::encrypt_aes_lines, fill};
|
||||||
|
|
||||||
|
#[cfg(feature = "obfuscate")]
|
||||||
#[static_init::dynamic]
|
#[static_init::dynamic]
|
||||||
static KEY: String = {
|
static KEY: String = {
|
||||||
std::env::var(ENV_KEY_NAME).unwrap_or({
|
std::env::var(ENV_KEY_NAME).unwrap_or({
|
||||||
// Diagnostic::new(proc_macro::Level::Warning, "Using default encryption key!").emit();
|
|
||||||
|
|
||||||
println!("Using default encryption key!");
|
println!("Using default encryption key!");
|
||||||
|
|
||||||
BACKUP_ENV_KEY.to_owned()
|
BACKUP_ENV_KEY.to_owned()
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If there isn't any encryption
|
||||||
|
#[cfg(not(feature = "obfuscate"))]
|
||||||
|
#[static_init::dynamic]
|
||||||
|
static KEY: String = "".to_string();
|
||||||
|
|
||||||
pub fn obfuscated_symbol(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
pub fn obfuscated_symbol(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
// Parse the input function
|
// Parse the input function
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ name = "unshell-server"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = ["log_debug"]
|
||||||
log = ["unshell/log", "unshell-manager/log"]
|
log = ["unshell/log", "unshell-manager/log"]
|
||||||
log_debug = ["log", "unshell/log_debug", "unshell-manager/log_debug"]
|
log_debug = ["unshell/log_debug", "unshell-manager/log_debug"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
unshell = { path = "../" }
|
unshell = { path = "../" }
|
||||||
|
|||||||
@@ -31,7 +31,25 @@ use jsonwebtoken::{DecodingKey, EncodingKey};
|
|||||||
static EXPIRE_DURATION: Duration = Duration::hours(12);
|
static EXPIRE_DURATION: Duration = Duration::hours(12);
|
||||||
|
|
||||||
#[dynamic]
|
#[dynamic]
|
||||||
static JWT_SECRET: String = std::env::var("JWT_SECRET").expect("JWT_SECRET must be set");
|
|
||||||
|
static JWT_SECRET: String = {
|
||||||
|
if let Ok(env_secret) = std::env::var("JWT_SECRET") {
|
||||||
|
env_secret
|
||||||
|
} else {
|
||||||
|
println!(
|
||||||
|
r#"
|
||||||
|
##############
|
||||||
|
# WARNING: You are using the default JWT secret, used for creating user sessions
|
||||||
|
# With this default key, anyone can login as any user.
|
||||||
|
##############"#
|
||||||
|
);
|
||||||
|
"DEFAULT_SECRET".to_string()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// std::env::var("JWT_SECRET").unwrap_or(|| -> String {
|
||||||
|
// return "TEST".to_string();
|
||||||
|
// }());
|
||||||
|
|
||||||
#[dynamic]
|
#[dynamic]
|
||||||
static JWT_ENCODING_KEY: EncodingKey = EncodingKey::from_secret(JWT_SECRET.as_bytes());
|
static JWT_ENCODING_KEY: EncodingKey = EncodingKey::from_secret(JWT_SECRET.as_bytes());
|
||||||
|
|||||||
Reference in New Issue
Block a user