Compare commits

...

6 Commits
5.19 ... 5.21

Author SHA1 Message Date
2dust
7ec0607fec Update AssemblyInfo.cs 2022-04-27 20:47:38 +08:00
2dust
aa41a8675e Advanced proxy settings, protocol selection (optional) 2022-04-27 20:46:07 +08:00
2dust
19f9bff6fe Support hysteria and naiveproxy subscription 2022-04-27 09:31:38 +08:00
2dust
4e65732a4e Update AssemblyInfo.cs 2022-04-26 20:06:46 +08:00
2dust
47c843bf09 Enable system proxy advanced settings, use socks protocol 2022-04-26 20:06:21 +08:00
2dust
a7741a0b7d Improve notify icon 2022-04-26 14:51:06 +08:00
20 changed files with 210 additions and 1204 deletions

View File

@@ -7,7 +7,6 @@ namespace v2rayN.Forms
public partial class BaseForm : Form
{
protected static Config config;
protected static System.Drawing.Icon icon;
public BaseForm()
{
@@ -19,16 +18,14 @@ namespace v2rayN.Forms
{
try
{
if (icon == null)
string file = Utils.GetPath(Global.CustomIconName);
if (System.IO.File.Exists(file))
{
string file = Utils.GetPath(Global.CustomIconName);
if (!System.IO.File.Exists(file))
{
return;
}
icon = new System.Drawing.Icon(file);
this.Icon = new System.Drawing.Icon(file);
return;
}
this.Icon = icon;
this.Icon = Properties.Resources.NotifyIcon1;
}
catch (Exception e)
{

File diff suppressed because it is too large Load Diff

View File

@@ -1273,7 +1273,7 @@ namespace v2rayN.Forms
mainMsgControl.DisplayToolStatus(config);
notifyMain.Icon = MainFormHandler.Instance.GetNotifyIcon(config, this.Icon);
notifyMain.Icon = this.Icon = MainFormHandler.Instance.GetNotifyIcon(config, this.Icon);
}
#endregion

View File

@@ -98,13 +98,14 @@
this.labCoreType1 = new System.Windows.Forms.Label();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label18 = new System.Windows.Forms.Label();
this.cmbSystemProxyAdvancedProtocol = new System.Windows.Forms.ComboBox();
this.label13 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.txtsystemProxyExceptions = new System.Windows.Forms.TextBox();
this.panel2 = new System.Windows.Forms.Panel();
this.btnOK = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.chkEnableSystemProxyAdvanced = new System.Windows.Forms.CheckBox();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox1.SuspendLayout();
@@ -581,7 +582,8 @@
//
// groupBox2
//
this.groupBox2.Controls.Add(this.chkEnableSystemProxyAdvanced);
this.groupBox2.Controls.Add(this.label18);
this.groupBox2.Controls.Add(this.cmbSystemProxyAdvancedProtocol);
this.groupBox2.Controls.Add(this.label13);
this.groupBox2.Controls.Add(this.label12);
this.groupBox2.Controls.Add(this.txtsystemProxyExceptions);
@@ -589,6 +591,17 @@
this.groupBox2.Name = "groupBox2";
this.groupBox2.TabStop = false;
//
// label18
//
resources.ApplyResources(this.label18, "label18");
this.label18.Name = "label18";
//
// cmbSystemProxyAdvancedProtocol
//
this.cmbSystemProxyAdvancedProtocol.FormattingEnabled = true;
resources.ApplyResources(this.cmbSystemProxyAdvancedProtocol, "cmbSystemProxyAdvancedProtocol");
this.cmbSystemProxyAdvancedProtocol.Name = "cmbSystemProxyAdvancedProtocol";
//
// label13
//
resources.ApplyResources(this.label13, "label13");
@@ -623,12 +636,6 @@
resources.ApplyResources(this.panel1, "panel1");
this.panel1.Name = "panel1";
//
// chkEnableSystemProxyAdvanced
//
resources.ApplyResources(this.chkEnableSystemProxyAdvanced, "chkEnableSystemProxyAdvanced");
this.chkEnableSystemProxyAdvanced.Name = "chkEnableSystemProxyAdvanced";
this.chkEnableSystemProxyAdvanced.UseVisualStyleBackColor = true;
//
// OptionSettingForm
//
resources.ApplyResources(this, "$this");
@@ -737,6 +744,7 @@
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txttrayMenuServersLimit;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.CheckBox chkEnableSystemProxyAdvanced;
private System.Windows.Forms.ComboBox cmbSystemProxyAdvancedProtocol;
private System.Windows.Forms.Label label18;
}
}

View File

@@ -18,6 +18,8 @@ namespace v2rayN.Forms
private void OptionSettingForm_Load(object sender, EventArgs e)
{
cmbSystemProxyAdvancedProtocol.Items.AddRange(Global.IEProxyProtocols.ToArray());
InitBase();
InitKCP();
@@ -59,7 +61,7 @@ namespace v2rayN.Forms
txtsystemProxyExceptions.Text = config.systemProxyExceptions;
chkEnableSystemProxyAdvanced.Checked = config.enableSystemProxyAdvanced;
cmbSystemProxyAdvancedProtocol.Text = config.systemProxyAdvancedProtocol;
}
@@ -255,7 +257,7 @@ namespace v2rayN.Forms
config.systemProxyExceptions = txtsystemProxyExceptions.Text.TrimEx();
config.enableSystemProxyAdvanced = chkEnableSystemProxyAdvanced.Checked;
config.systemProxyAdvancedProtocol = cmbSystemProxyAdvancedProtocol.Text.TrimEx();
return 0;
}

View File

@@ -1851,33 +1851,57 @@
<data name="&gt;&gt;tabPageCoreType.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="chkEnableSystemProxyAdvanced.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<data name="label18.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label18.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="chkEnableSystemProxyAdvanced.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 328</value>
<data name="label18.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 346</value>
</data>
<data name="chkEnableSystemProxyAdvanced.Size" type="System.Drawing.Size, System.Drawing">
<value>502, 16</value>
<data name="label18.Size" type="System.Drawing.Size, System.Drawing">
<value>329, 12</value>
</data>
<data name="chkEnableSystemProxyAdvanced.TabIndex" type="System.Int32, mscorlib">
<value>43</value>
<data name="label18.TabIndex" type="System.Int32, mscorlib">
<value>45</value>
</data>
<data name="chkEnableSystemProxyAdvanced.Text" xml:space="preserve">
<value>Enable system proxy advanced settings (http/https/ftp/socks)</value>
<data name="label18.Text" xml:space="preserve">
<value>Advanced proxy settings, protocol selection (optional)</value>
</data>
<data name="&gt;&gt;chkEnableSystemProxyAdvanced.Name" xml:space="preserve">
<value>chkEnableSystemProxyAdvanced</value>
<data name="&gt;&gt;label18.Name" xml:space="preserve">
<value>label18</value>
</data>
<data name="&gt;&gt;chkEnableSystemProxyAdvanced.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="&gt;&gt;label18.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;chkEnableSystemProxyAdvanced.Parent" xml:space="preserve">
<data name="&gt;&gt;label18.Parent" xml:space="preserve">
<value>groupBox2</value>
</data>
<data name="&gt;&gt;chkEnableSystemProxyAdvanced.ZOrder" xml:space="preserve">
<data name="&gt;&gt;label18.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="cmbSystemProxyAdvancedProtocol.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 371</value>
</data>
<data name="cmbSystemProxyAdvancedProtocol.Size" type="System.Drawing.Size, System.Drawing">
<value>638, 20</value>
</data>
<data name="cmbSystemProxyAdvancedProtocol.TabIndex" type="System.Int32, mscorlib">
<value>44</value>
</data>
<data name="&gt;&gt;cmbSystemProxyAdvancedProtocol.Name" xml:space="preserve">
<value>cmbSystemProxyAdvancedProtocol</value>
</data>
<data name="&gt;&gt;cmbSystemProxyAdvancedProtocol.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cmbSystemProxyAdvancedProtocol.Parent" xml:space="preserve">
<value>groupBox2</value>
</data>
<data name="&gt;&gt;cmbSystemProxyAdvancedProtocol.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="label13.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@@ -1906,7 +1930,7 @@
<value>groupBox2</value>
</data>
<data name="&gt;&gt;label13.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="label12.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -1936,7 +1960,7 @@
<value>groupBox2</value>
</data>
<data name="&gt;&gt;label12.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="txtsystemProxyExceptions.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 52</value>
@@ -1963,7 +1987,7 @@
<value>groupBox2</value>
</data>
<data name="&gt;&gt;txtsystemProxyExceptions.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="groupBox2.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>

View File

@@ -373,7 +373,7 @@
<data name="$this.Text" xml:space="preserve">
<value>参数设置</value>
</data>
<data name="chkEnableSystemProxyAdvanced.Text" xml:space="preserve">
<value>开启系统代理高级设置 (http/https/ftp/socks)</value>
<data name="label18.Text" xml:space="preserve">
<value>高级代理设置, 协议选择(可选)</value>
</data>
</root>

View File

@@ -199,6 +199,13 @@ namespace v2rayN
public const string StatisticLogOverall = "StatisticLogOverall.json";
public const string IEProxyExceptions = "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.*;192.168.*";
public static readonly List<string> IEProxyProtocols = new List<string> {
"{ip}:{http_port}",
"socks={ip}:{socks_port}",
"http={ip}:{http_port};https={ip}:{http_port};ftp={ip}:{http_port};socks={ip}:{socks_port}",
"http=http://{ip}:{http_port};https=http://{ip}:{http_port}",
""
};
public const string RoutingRuleComma = "<COMMA>";

View File

@@ -950,14 +950,39 @@ namespace v2rayN.Handler
vmessItem.address = fileName;
vmessItem.remarks = "clash_custom";
}
//Is hysteria configuration
else if (clipboardData.IndexOf("server") >= 0
&& clipboardData.IndexOf("up") >= 0
&& clipboardData.IndexOf("down") >= 0
&& clipboardData.IndexOf("listen") >= 0)
{
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.json");
File.WriteAllText(fileName, clipboardData);
vmessItem.coreType = ECoreType.hysteria;
vmessItem.address = fileName;
vmessItem.remarks = "hysteria_custom";
}
//Is naiveproxy configuration
else if (clipboardData.IndexOf("listen") >= 0
&& clipboardData.IndexOf("proxy") >= 0)
{
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.json");
File.WriteAllText(fileName, clipboardData);
vmessItem.coreType = ECoreType.naiveproxy;
vmessItem.address = fileName;
vmessItem.remarks = "naiveproxy_custom";
}
//Is Other configuration
else
{
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.txt");
File.WriteAllText(fileName, clipboardData);
return -1;
//var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.txt");
//File.WriteAllText(fileName, clipboardData);
vmessItem.address = fileName;
vmessItem.remarks = "other_custom";
//vmessItem.address = fileName;
//vmessItem.remarks = "other_custom";
}
if (!Utils.IsNullOrEmpty(subid))

View File

@@ -32,12 +32,59 @@ namespace v2rayN.Handler
{
try
{
int index = (int)config.sysProxyType;
//Load from routing setting
var createdIcon = GetNotifyIcon4Routing(config);
if (createdIcon != null)
{
return createdIcon;
}
//Load from local file
var fileName = Utils.GetPath($"NotifyIcon{index + 1}.ico");
if (File.Exists(fileName))
{
return new Icon(fileName);
}
switch (index)
{
case 0:
return Properties.Resources.NotifyIcon1;
case 1:
return Properties.Resources.NotifyIcon2;
case 2:
return Properties.Resources.NotifyIcon3;
}
return Properties.Resources.NotifyIcon1;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
return def;
}
}
private Icon GetNotifyIcon4Routing(Config config)
{
try
{
if (!config.enableRoutingAdvanced)
{
return null;
}
var item = config.routings[config.routingIndex];
if (Utils.IsNullOrEmpty(item.customIcon) || !File.Exists(item.customIcon))
{
return null;
}
Color color = ColorTranslator.FromHtml("#3399CC");
int index = (int)config.sysProxyType;
if (index > 0)
{
color = (new Color[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange, Color.DarkSlateBlue, Color.RoyalBlue })[index - 1];
//color = ColorTranslator.FromHtml(new string[] { "#CC0066", "#CC6600", "#99CC99", "#666699" }[index - 1]);
}
int width = 128;
@@ -47,24 +94,8 @@ namespace v2rayN.Handler
Graphics graphics = Graphics.FromImage(bitmap);
SolidBrush drawBrush = new SolidBrush(color);
var customIcon = false;
if (config.enableRoutingAdvanced)
{
var item = config.routings[config.routingIndex];
if (!Utils.IsNullOrEmpty(item.customIcon) && File.Exists(item.customIcon))
{
graphics.FillRectangle(drawBrush, new Rectangle(0, 0, width, height));
graphics.DrawImage(new Bitmap(item.customIcon), 0, 0, width, height);
customIcon = true;
}
}
if (!customIcon)
{
graphics.FillEllipse(drawBrush, new Rectangle(0, 0, width, height));
int zoom = 16;
graphics.DrawImage(new Bitmap(Properties.Resources.notify, width - zoom, width - zoom), zoom / 2, zoom / 2);
}
graphics.FillRectangle(drawBrush, new Rectangle(0, 0, width, height));
graphics.DrawImage(new Bitmap(item.customIcon), 0, 0, width, height);
Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());
drawBrush.Dispose();
@@ -76,7 +107,7 @@ namespace v2rayN.Handler
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
return def;
return null;
}
}

View File

@@ -70,13 +70,16 @@ namespace v2rayN.Handler
var strExceptions = $"{config.constItem.defIEProxyExceptions};{config.systemProxyExceptions}";
var strProxy = string.Empty;
if (config.enableSystemProxyAdvanced)
if (Utils.IsNullOrEmpty(config.systemProxyAdvancedProtocol))
{
strProxy = string.Format("http={0}:{1};https={0}:{1};ftp={0}:{1};socks={0}:{2}", Global.Loopback, port, portSocks);
strProxy = $"{Global.Loopback}:{port}";
}
else
{
strProxy = $"{Global.Loopback}:{port}";
strProxy = config.systemProxyAdvancedProtocol
.Replace("{ip}", Global.Loopback)
.Replace("{http_port}", port.ToString())
.Replace("{socks_port}", portSocks.ToString());
}
SetIEProxy(true, strProxy, strExceptions);
}

View File

@@ -124,8 +124,8 @@ namespace v2rayN.Mode
{
get; set;
}
public bool enableSystemProxyAdvanced { get; set; }
public string systemProxyAdvancedProtocol { get; set; }
public int autoUpdateInterval { get; set; } = 0;
public int autoUpdateSubInterval { get; set; } = 0;

View File

@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
// 方法是按如下所示使用“*”:
//[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("5.19")]
[assembly: AssemblyFileVersion("5.21")]

View File

@@ -110,6 +110,36 @@ namespace v2rayN.Properties {
}
}
/// <summary>
/// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
/// </summary>
internal static System.Drawing.Icon NotifyIcon1 {
get {
object obj = ResourceManager.GetObject("NotifyIcon1", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
/// </summary>
internal static System.Drawing.Icon NotifyIcon2 {
get {
object obj = ResourceManager.GetObject("NotifyIcon2", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
/// </summary>
internal static System.Drawing.Icon NotifyIcon3 {
get {
object obj = ResourceManager.GetObject("NotifyIcon3", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>

View File

@@ -157,4 +157,13 @@
<data name="share" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\share.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="NotifyIcon1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NotifyIcon1.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="NotifyIcon2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NotifyIcon2.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="NotifyIcon3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NotifyIcon3.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@@ -474,6 +474,9 @@
<None Include="Resources\minimize.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Resources\NotifyIcon1.ico" />
<Content Include="Resources\NotifyIcon2.ico" />
<Content Include="Resources\NotifyIcon3.ico" />
<EmbeddedResource Include="Sample\SampleInbound.txt" />
<None Include="Resources\share.png" />
<None Include="Resources\promotion.png" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 60 KiB