@@ -40,8 +40,6 @@ public partial class MainWindow : Window
40
40
41
41
private TaskbarIcon notifyIcon ;
42
42
43
- private ConfigWindow configWindow ;
44
-
45
43
46
44
public bool proxyState = false ;
47
45
public ProxyMode proxyMode = ProxyMode . manual ;
@@ -468,6 +466,10 @@ public void OverallChanged(object sender, RoutedEventArgs e)
468
466
}
469
467
this . UpdateStatusAndModeMenus ( ) ;
470
468
this . UpdatePacMenuList ( ) ;
469
+ if ( sender . GetType ( ) . Equals ( typeof ( ConfigWindow ) ) )
470
+ {
471
+ WriteSettings ( ) ;
472
+ }
471
473
}
472
474
#endregion
473
475
@@ -506,7 +508,7 @@ public void UpdateSystemProxy()
506
508
} else if ( proxyMode == ProxyMode . global )
507
509
{
508
510
registry . SetValue ( "ProxyEnable" , 1 ) ;
509
- var proxyServer = $ "http=127.0.0.1: { httpPort } ;socks= 127.0.0.1:{ localPort } ";
511
+ var proxyServer = $ "http:// 127.0.0.1:{ httpPort } ";
510
512
var proxyOverride = "<local>;localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;172.32.*;192.168.*" ;
511
513
registry . SetValue ( "ProxyServer" , proxyServer ) ;
512
514
registry . SetValue ( "ProxyOverride" , proxyOverride ) ;
@@ -780,7 +782,11 @@ private void InitializeCoreProcess()
780
782
v2rayProcess . StartInfo . FileName = AppDomain . CurrentDomain . BaseDirectory + @"v2ray-core\v2ray.exe" ;
781
783
Debug . WriteLine ( v2rayProcess . StartInfo . FileName ) ;
782
784
v2rayProcess . StartInfo . Arguments = @"-config http://127.0.0.1:18000/config.json" ;
785
+ #if DEBUG
786
+ v2rayProcess . StartInfo . WindowStyle = ProcessWindowStyle . Normal ;
787
+ #else
783
788
v2rayProcess . StartInfo . WindowStyle = ProcessWindowStyle . Hidden ;
789
+ #endif
784
790
v2rayCoreWorker . DoWork += V2rayCoreWorker_DoWork ;
785
791
v2rayCoreWorker . RunWorkerAsync ( ) ;
786
792
}
@@ -820,9 +826,9 @@ void ToggleCore()
820
826
this . UnloadV2ray ( ) ;
821
827
coreWorkerSemaphore . Release ( 1 ) ;
822
828
}
823
- #endregion
829
+ #endregion
824
830
825
- #region core config management
831
+ #region core config management
826
832
byte [ ] v2rayJsonConfig = new byte [ 0 ] ;
827
833
828
834
void CoreConfigChanged ( object sender )
@@ -848,9 +854,13 @@ byte[] GenerateConfigFile()
848
854
Dictionary < string , object > fullConfig = Utilities . configTemplate ;
849
855
fullConfig [ "log" ] = new Dictionary < string , string >
850
856
{
851
- { "loglevel" , logLevel } ,
857
+ #if DEBUG
858
+ { "loglevel" , "debug" }
859
+ #else
852
860
{ "error" , AppDomain . CurrentDomain . BaseDirectory + @"log\error.log" } ,
853
- { "access" , AppDomain . CurrentDomain . BaseDirectory + @"log\access.log" }
861
+ { "access" , AppDomain . CurrentDomain . BaseDirectory + @"log\access.log" } ,
862
+ { "loglevel" , logLevel }
863
+ #endif
854
864
} ;
855
865
var dnsList = dnsString . Split ( ',' ) ;
856
866
if ( dnsList . Count ( ) > 0 )
@@ -943,9 +953,9 @@ byte[] GenerateConfigFile()
943
953
}
944
954
return Encoding . UTF8 . GetBytes ( JsonConvert . SerializeObject ( fullConfig , Formatting . Indented ) ) ;
945
955
}
946
- #endregion
956
+ #endregion
947
957
948
- #region routingRules
958
+ #region routingRules
949
959
void UpdateRuleSetMenuList ( )
950
960
{
951
961
Debug . WriteLine ( $ "rules count = { routingRuleSets . Count } ") ;
@@ -975,12 +985,12 @@ void SwitchRoutingRuleSet(object sender, RoutedEventArgs e)
975
985
this . CoreConfigChanged ( sender ) ;
976
986
}
977
987
978
- #endregion
988
+ #endregion
979
989
980
990
981
- #region other main menu items
991
+ #region other main menu items
982
992
983
- private void QuitV2RayW ( object sender , RoutedEventArgs e )
993
+ public void QuitV2RayW ( object sender , RoutedEventArgs e )
984
994
{
985
995
notifyIcon . Icon = null ;
986
996
this . UnloadV2ray ( ) ;
@@ -1006,25 +1016,20 @@ private void ShowHelp(object sender, RoutedEventArgs e)
1006
1016
1007
1017
private void ShowConfigWindow ( object sender , RoutedEventArgs e )
1008
1018
{
1009
- if ( this . configWindow == null )
1019
+ ConfigWindow configWindow = new ConfigWindow
1010
1020
{
1011
- this . configWindow = new ConfigWindow
1012
- {
1013
- mainWindow = this
1014
- } ;
1015
-
1016
- }
1017
- this . configWindow . InitializeData ( ) ;
1018
- this . configWindow . Show ( ) ;
1019
- this . configWindow . Focus ( ) ;
1021
+ mainWindow = this
1022
+ } ;
1023
+ configWindow . InitializeData ( ) ;
1024
+ configWindow . Show ( ) ;
1020
1025
}
1021
1026
1022
1027
private void ViewCurrentConfig ( object sender , RoutedEventArgs e )
1023
1028
{
1024
1029
Process . Start ( "http://127.0.0.1:18000/config.json" ) ;
1025
1030
}
1026
1031
1027
- #endregion
1032
+ #endregion
1028
1033
1029
1034
private void ShowLogMenuItem_Click ( object sender , RoutedEventArgs e )
1030
1035
{
0 commit comments