@@ -435,7 +435,9 @@ impl Proxy {
435435 }
436436
437437 #[ cfg( target_os = "linux" ) ]
438- pub fn switch_auto_start ( & self , current_state : bool ) -> HunterResult < ( ) > {
438+ pub async fn switch_auto_start ( & self , current_state : bool ) -> HunterResult < ( ) > {
439+ let trojan_config_path = get_or_init_config_manager ( ) . await . trojan_config_path ( ) ;
440+
439441 if current_state {
440442 debug ! ( "delete auto start script" ) ;
441443 fs:: remove_file ( & self . auto_start_desktop ) . map_err ( |e| {
@@ -458,7 +460,7 @@ Type=Application
458460X-KDE-AutostartScript=true
459461"# ,
460462 self . executable_file. to_string_lossy( ) ,
461- TROJAN_CONFIG_FILE_PATH . to_string_lossy( )
463+ trojan_config_path . to_string_lossy( )
462464 ) ;
463465
464466 debug ! ( "add auto start script" ) ;
@@ -494,7 +496,7 @@ ws.Run "{} -config {}",0"#,
494496 }
495497
496498 #[ cfg( target_os = "macos" ) ]
497- pub fn switch_auto_start ( & self , current_state : bool ) -> HunterResult < ( ) > {
499+ pub async fn switch_auto_start ( & self , current_state : bool ) -> HunterResult < ( ) > {
498500 if current_state {
499501 debug ! ( "删除开机启动脚本" ) ;
500502 return fs:: remove_file ( & self . auto_start_plist ) . map_err ( |e| {
@@ -503,6 +505,8 @@ ws.Run "{} -config {}",0"#,
503505 } ) ;
504506 }
505507
508+ let trojan_config_path = get_or_init_config_manager ( ) . await . trojan_config_path ( ) ;
509+
506510 let content = format ! (
507511 r#"<?xml version="1.0" encoding="UTF-8"?>
508512<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -522,7 +526,7 @@ ws.Run "{} -config {}",0"#,
522526</plist>
523527"# ,
524528 self . executable_file. to_string_lossy( ) ,
525- TROJAN_CONFIG_FILE_PATH . to_str( ) . unwrap( )
529+ trojan_config_path . to_str( ) . unwrap( )
526530 ) ;
527531
528532 debug ! ( "添加开机启动脚本" ) ;
0 commit comments