Skip to content

Commit

Permalink
remove remote_config_encoding config,always try to decode file
Browse files Browse the repository at this point in the history
  • Loading branch information
RongDuJiKsp committed Sep 18, 2024
1 parent 22b3c30 commit 8d103aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
10 changes: 0 additions & 10 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,12 @@ use serde::{Deserialize, Serialize};
pub struct Config {
pub remote_mihomo_binary_url: String,
pub remote_config_url: String,
pub remote_config_encoding: EncodingMode,
pub mihomo_binary_path: String,
pub mihomo_config_root: String,
pub user_systemd_root: String,
pub mihomo_config: MihomoConfig,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum EncodingMode {
#[serde(alias = "plain", rename(serialize = "plain"))]
Plain,
#[serde(alias = "base64", rename(serialize = "base64"))]
Base64,
}

/// `mihomo` configurations (partial).
///
/// Referenced from https://wiki.metacubex.one/config
Expand Down Expand Up @@ -84,7 +75,6 @@ impl Config {
Config {
remote_mihomo_binary_url: String::from(""),
remote_config_url: String::from(""),
remote_config_encoding: EncodingMode::Plain,
mihomo_binary_path: String::from("~/.local/bin/mihomo"),
mihomo_config_root: String::from("~/.config/mihomo"),
user_systemd_root: String::from("~/.config/systemd/user"),
Expand Down
8 changes: 3 additions & 5 deletions src/mihoro.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::cmd::ProxyCommands;
use crate::config::{apply_mihomo_override, parse_config, Config, EncodingMode};
use crate::config::{apply_mihomo_override, parse_config, Config};
use crate::proxy::{proxy_export_cmd, proxy_unset_cmd};
use crate::systemctl::Systemctl;
use crate::utils::{
Expand Down Expand Up @@ -86,10 +86,8 @@ impl Mihoro {
)
.await?;

//Try to Decode base64 config if set
if self.config.remote_config_encoding == EncodingMode::Base64 {
try_decode_base64_file_inplace(&self.mihomo_target_config_path)?;
}
// Try to decode base64 file in place if file is base64 encoding , otherwise do nothing
try_decode_base64_file_inplace(&self.mihomo_target_config_path)?;

apply_mihomo_override(&self.mihomo_target_config_path, &self.config.mihomo_config)?;

Expand Down

0 comments on commit 8d103aa

Please sign in to comment.