diff --git a/V2RayW/App.config b/V2RayW/App.config index e7c0b41..84c6d3f 100644 --- a/V2RayW/App.config +++ b/V2RayW/App.config @@ -75,6 +75,9 @@ "concurrency": 8 } + + False + diff --git a/V2RayW/ConfigForm.Designer.cs b/V2RayW/ConfigForm.Designer.cs index fd82c3a..2e59fb9 100644 --- a/V2RayW/ConfigForm.Designer.cs +++ b/V2RayW/ConfigForm.Designer.cs @@ -62,6 +62,7 @@ private void InitializeComponent() this.label2 = new System.Windows.Forms.Label(); this.comboBoxInP = new System.Windows.Forms.ComboBox(); this.checkBoxAlarm = new System.Windows.Forms.CheckBox(); + this.checkBoxSysProxy = new System.Windows.Forms.CheckBox(); this.groupBoxServer.SuspendLayout(); this.panel1.SuspendLayout(); this.SuspendLayout(); @@ -298,12 +299,19 @@ private void InitializeComponent() this.checkBoxAlarm.Name = "checkBoxAlarm"; this.checkBoxAlarm.UseVisualStyleBackColor = true; // + // checkBoxSysProxy + // + resources.ApplyResources(this.checkBoxSysProxy, "checkBoxSysProxy"); + this.checkBoxSysProxy.Name = "checkBoxSysProxy"; + this.checkBoxSysProxy.UseVisualStyleBackColor = true; + // // ConfigForm // this.AcceptButton = this.buttonSave; resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.buttonCancel; + this.Controls.Add(this.checkBoxSysProxy); this.Controls.Add(this.checkBoxAlarm); this.Controls.Add(this.comboBoxInP); this.Controls.Add(this.label2); @@ -366,5 +374,6 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox comboBoxSecurity; private System.Windows.Forms.Label label10; private System.Windows.Forms.CheckBox checkBoxAlarm; + private System.Windows.Forms.CheckBox checkBoxSysProxy; } } \ No newline at end of file diff --git a/V2RayW/ConfigForm.cs b/V2RayW/ConfigForm.cs index 51f7e9a..6a98b31 100644 --- a/V2RayW/ConfigForm.cs +++ b/V2RayW/ConfigForm.cs @@ -53,6 +53,7 @@ private void buttonSave_Click(object sender, EventArgs e) var profileArray = Program.profiles.Select(p => Program.profileToStr(p)); Properties.Settings.Default.profilesStr = String.Join("\t", profileArray); Properties.Settings.Default.alarmUnknown = checkBoxAlarm.Checked; + Properties.Settings.Default.autoSetSysProxy = checkBoxSysProxy.Checked; Properties.Settings.Default.Save(); Program.updateSystemProxy(); @@ -69,6 +70,7 @@ private void buttonTS_Click(object sender, EventArgs e) private void ConfigForm_Load(object sender, EventArgs e) { checkBoxAlarm.Checked = Properties.Settings.Default.alarmUnknown; + checkBoxSysProxy.Checked = Properties.Settings.Default.autoSetSysProxy; this.Icon = Properties.Resources.vw256; selectedServerIndex = Program.selectedServerIndex; profiles.Clear(); @@ -239,5 +241,6 @@ private void comboBoxSecurity_SelectedIndexChanged(object sender, EventArgs e) profiles[selectedServerIndex].security = comboBoxSecurity.SelectedIndex; } } + } } diff --git a/V2RayW/ConfigForm.resx b/V2RayW/ConfigForm.resx index c9af7db..60e06ed 100644 --- a/V2RayW/ConfigForm.resx +++ b/V2RayW/ConfigForm.resx @@ -123,7 +123,7 @@ - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 231, 21 @@ -147,10 +147,10 @@ $this - 13 + 14 - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt @@ -184,13 +184,13 @@ $this - 12 + 13 True - Microsoft YaHei, 8pt + Microsoft YaHei UI, 8pt 14, 47 @@ -214,13 +214,13 @@ $this - 11 + 12 True - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 15, 88 @@ -244,13 +244,13 @@ $this - 10 + 11 True - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 17, 112 @@ -274,13 +274,13 @@ $this - 9 + 10 True - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 403, 394 @@ -307,13 +307,13 @@ $this - 8 + 9 True - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 477, 394 @@ -340,10 +340,10 @@ $this - 7 + 8 - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 272, 18 @@ -367,10 +367,10 @@ $this - 6 + 7 - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 65, 85 @@ -394,13 +394,13 @@ $this - 5 + 6 True - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 252, 394 @@ -427,7 +427,7 @@ $this - 4 + 5 buttonRemove @@ -478,7 +478,7 @@ 3 - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 13, 152 @@ -508,13 +508,13 @@ $this - 3 + 4 True - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt NoControl @@ -550,7 +550,7 @@ True - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt NoControl @@ -790,7 +790,7 @@ 14 - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 167, 28 @@ -913,7 +913,7 @@ 2 - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 80, 132 @@ -940,7 +940,7 @@ 3 - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 80, 68 @@ -967,7 +967,7 @@ 4 - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 80, 37 @@ -994,7 +994,7 @@ 5 - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 284, 6 @@ -1021,7 +1021,7 @@ 6 - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 80, 6 @@ -1288,7 +1288,7 @@ $this - 2 + 3 socks @@ -1315,7 +1315,7 @@ $this - 1 + 2 True @@ -1342,6 +1342,33 @@ $this + 1 + + + True + + + 260, 112 + + + 168, 21 + + + 17 + + + Auto set Windows Proxy + + + checkBoxSysProxy + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -1354,7 +1381,7 @@ 557, 434 - Microsoft YaHei, 9pt + Microsoft YaHei UI, 9pt 3, 4, 3, 4 diff --git a/V2RayW/Program.cs b/V2RayW/Program.cs index 8b1565d..2ca0d12 100644 --- a/V2RayW/Program.cs +++ b/V2RayW/Program.cs @@ -38,6 +38,15 @@ public static bool proxyIsOn Properties.Settings.Default.Save(); } } + public static bool setSysProxy + { + get { return Properties.Settings.Default.autoSetSysProxy; } + set + { + Properties.Settings.Default.autoSetSysProxy = value; + Properties.Settings.Default.Save(); + } + } public static int proxyMode { get { return Properties.Settings.Default.proxyMode % 3; } @@ -244,34 +253,44 @@ public static async void updateSystemProxy() public static int runSysproxy() { RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true); + if (setSysProxy) + { - bool settingsReturn, refreshReturn; + bool settingsReturn, refreshReturn; - registry.SetValue("ProxyEnable", proxyIsOn ? 1 : 0); - if (proxyIsOn) - { - registry.SetValue("ProxyServer", (Properties.Settings.Default.inProtocol == 0 ? "socks=" : "http://") + $"127.0.0.1:{Properties.Settings.Default.localPort}"); - registry.SetValue("ProxyOverride", ";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.*"); - } - var sysState = registry.GetValue("ProxyEnable").ToString() == (proxyIsOn ? "1" : "0"); - var sysServer = proxyIsOn ? registry.GetValue("ProxyServer").ToString() == (Properties.Settings.Default.inProtocol == 0 ? "socks=" : "http://") + $"127.0.0.1:{Properties.Settings.Default.localPort}" : true; - //MessageBox.Show(registry.GetValue("ProxyServer").ToString()); - var sysOverride = proxyIsOn ? registry.GetValue("ProxyOverride").ToString() == ";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.*" : true; - // They cause the OS to refresh the settings, causing IP to realy update - settingsReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0); - refreshReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0); - if (sysServer && sysState && sysOverride) - { - if (settingsReturn && refreshReturn) + registry.SetValue("ProxyEnable", proxyIsOn ? 1 : 0); + if (proxyIsOn) { - return 0; - } else + registry.SetValue("ProxyServer", (Properties.Settings.Default.inProtocol == 0 ? "socks=" : "http://") + $"127.0.0.1:{Properties.Settings.Default.localPort}"); + registry.SetValue("ProxyOverride", ";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.*"); + } + var sysState = registry.GetValue("ProxyEnable").ToString() == (proxyIsOn ? "1" : "0"); + var sysServer = proxyIsOn ? registry.GetValue("ProxyServer").ToString() == (Properties.Settings.Default.inProtocol == 0 ? "socks=" : "http://") + $"127.0.0.1:{Properties.Settings.Default.localPort}" : true; + //MessageBox.Show(registry.GetValue("ProxyServer").ToString()); + var sysOverride = proxyIsOn ? registry.GetValue("ProxyOverride").ToString() == ";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.*" : true; + // They cause the OS to refresh the settings, causing IP to realy update + settingsReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0); + refreshReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0); + if (sysServer && sysState && sysOverride) { - return 1; + if (settingsReturn && refreshReturn) + { + return 0; + } + else + { + return 1; + } } - } else + else + { + return 2; + } + } + else { - return 2; + registry.SetValue("ProxyEnable", 0); + return 0; } } @@ -467,7 +486,7 @@ public class Profile { internal string address = "1.2.3.4"; internal bool allowPassive = false; - internal int alterId = 0; + internal int alterId = 64; internal int network = 0; internal int port = 10086; internal string remark = ""; diff --git a/V2RayW/Properties/AssemblyInfo.cs b/V2RayW/Properties/AssemblyInfo.cs index 55bb50e..8af81eb 100644 --- a/V2RayW/Properties/AssemblyInfo.cs +++ b/V2RayW/Properties/AssemblyInfo.cs @@ -33,7 +33,7 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.0.6.0")] -[assembly: AssemblyFileVersion("0.0.6.0")] +[assembly: AssemblyVersion("0.0.8.1")] +[assembly: AssemblyFileVersion("0.0.8.1")] [assembly: NeutralResourcesLanguage("")] diff --git a/V2RayW/Properties/Settings.Designer.cs b/V2RayW/Properties/Settings.Designer.cs index da4c4de..2ba27a1 100644 --- a/V2RayW/Properties/Settings.Designer.cs +++ b/V2RayW/Properties/Settings.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ @@ -12,7 +12,7 @@ namespace V2RayW.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -185,5 +185,17 @@ public string mux { this["mux"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool autoSetSysProxy { + get { + return ((bool)(this["autoSetSysProxy"])); + } + set { + this["autoSetSysProxy"] = value; + } + } } } diff --git a/V2RayW/Properties/Settings.settings b/V2RayW/Properties/Settings.settings index 60f63bf..4f688d9 100644 --- a/V2RayW/Properties/Settings.settings +++ b/V2RayW/Properties/Settings.settings @@ -67,5 +67,8 @@ "concurrency": 8 } + + False + \ No newline at end of file diff --git a/V2RayW/V2RayW.csproj b/V2RayW/V2RayW.csproj index 5e85475..0170c39 100644 --- a/V2RayW/V2RayW.csproj +++ b/V2RayW/V2RayW.csproj @@ -66,8 +66,10 @@ true - true + false + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll