Compare commits

...

3 Commits
2.49 ... 2.51

Author SHA1 Message Date
2dust
3f1688f8b7 up stat 2019-11-25 13:22:35 +08:00
2dust
912f682359 Update AssemblyInfo.cs 2019-11-14 10:37:10 +08:00
2dust
1a84090cc7 cleanup http 2019-11-13 11:33:47 +08:00
21 changed files with 2360 additions and 2517 deletions

View File

@@ -60,12 +60,12 @@
this.menuExport2ServerConfig = new System.Windows.Forms.ToolStripMenuItem();
this.menuExport2ShareUrl = new System.Windows.Forms.ToolStripMenuItem();
this.menuExport2SubContent = new System.Windows.Forms.ToolStripMenuItem();
this.qrCodeControl = new v2rayN.Forms.QRCodeControl();
this.tsbServer = new System.Windows.Forms.ToolStripDropDownButton();
this.qrCodeControl = new v2rayN.Forms.QRCodeControl();
this.notifyMain = new System.Windows.Forms.NotifyIcon(this.components);
this.cmsMain = new System.Windows.Forms.ContextMenuStrip(this.components);
this.menuSysAgentEnabled = new System.Windows.Forms.ToolStripMenuItem();
this.menuSysAgentMode = new System.Windows.Forms.ToolStripMenuItem();
this.menuNotEnabledHttp = new System.Windows.Forms.ToolStripMenuItem();
this.menuGlobal = new System.Windows.Forms.ToolStripMenuItem();
this.menuGlobalPAC = new System.Windows.Forms.ToolStripMenuItem();
this.menuKeep = new System.Windows.Forms.ToolStripMenuItem();
@@ -355,11 +355,6 @@
resources.ApplyResources(this.menuExport2SubContent, "menuExport2SubContent");
this.menuExport2SubContent.Click += new System.EventHandler(this.menuExport2SubContent_Click);
//
// qrCodeControl
//
resources.ApplyResources(this.qrCodeControl, "qrCodeControl");
this.qrCodeControl.Name = "qrCodeControl";
//
// tsbServer
//
this.tsbServer.DropDown = this.cmsLv;
@@ -367,6 +362,11 @@
resources.ApplyResources(this.tsbServer, "tsbServer");
this.tsbServer.Name = "tsbServer";
//
// qrCodeControl
//
resources.ApplyResources(this.qrCodeControl, "qrCodeControl");
this.qrCodeControl.Name = "qrCodeControl";
//
// notifyMain
//
this.notifyMain.ContextMenuStrip = this.cmsMain;
@@ -378,7 +378,6 @@
this.cmsMain.ImageScalingSize = new System.Drawing.Size(20, 20);
resources.ApplyResources(this.cmsMain, "cmsMain");
this.cmsMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuSysAgentEnabled,
this.menuSysAgentMode,
this.menuServers,
this.menuAddServers2,
@@ -391,15 +390,10 @@
this.cmsMain.ShowCheckMargin = true;
this.cmsMain.ShowImageMargin = false;
//
// menuSysAgentEnabled
//
this.menuSysAgentEnabled.Name = "menuSysAgentEnabled";
resources.ApplyResources(this.menuSysAgentEnabled, "menuSysAgentEnabled");
this.menuSysAgentEnabled.Click += new System.EventHandler(this.menuSysAgentEnabled_Click);
//
// menuSysAgentMode
//
this.menuSysAgentMode.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuNotEnabledHttp,
this.menuGlobal,
this.menuGlobalPAC,
this.menuKeep,
@@ -407,6 +401,12 @@
this.menuSysAgentMode.Name = "menuSysAgentMode";
resources.ApplyResources(this.menuSysAgentMode, "menuSysAgentMode");
//
// menuNotEnabledHttp
//
this.menuNotEnabledHttp.Name = "menuNotEnabledHttp";
resources.ApplyResources(this.menuNotEnabledHttp, "menuNotEnabledHttp");
this.menuNotEnabledHttp.Click += new System.EventHandler(this.menuNotEnabledHttp_Click);
//
// menuGlobal
//
this.menuGlobal.Name = "menuGlobal";
@@ -818,7 +818,6 @@
private System.Windows.Forms.ToolStripMenuItem menuGlobal;
private System.Windows.Forms.ToolStripMenuItem menuGlobalPAC;
private System.Windows.Forms.ToolStripMenuItem menuKeep;
private System.Windows.Forms.ToolStripMenuItem menuSysAgentEnabled;
private System.Windows.Forms.ToolStripMenuItem menuCopyPACUrl;
private System.Windows.Forms.ToolStripMenuItem menuAddCustomServer;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
@@ -868,6 +867,7 @@
private System.Windows.Forms.ToolStripMenuItem menuRemoveDuplicateServer;
private System.Windows.Forms.ToolStripMenuItem menuTcpingServer;
private System.Windows.Forms.ToolStripMenuItem menuRealPingServer;
private System.Windows.Forms.ToolStripMenuItem menuNotEnabledHttp;
}
}

View File

@@ -35,7 +35,7 @@ namespace v2rayN.Forms
Utils.ClearTempPath();
v2rayHandler.V2rayStop();
HttpProxyHandle.Update(config, true);
HttpProxyHandle.CloseHttpAgent(config);
PACServerHandle.Stop();
@@ -197,7 +197,7 @@ namespace v2rayN.Forms
ListViewItem lvItem = null;
if (statistics != null && statistics.Enable)
{
var index = statistics.Statistic.FindIndex(item_ => item_.address == item.address);
var index = statistics.Statistic.FindIndex(item_ => item_.itemId == item.getItemId());
if (index != -1)
{
totalUp = Utils.HumanFy(statistics.Statistic[index].totalUp);
@@ -325,7 +325,7 @@ namespace v2rayN.Forms
toolSslSocksPort.Text = $"{Global.Loopback}:{config.inbound[0].localPort}";
if (config.sysAgentEnabled)
if (config.listenerType != 0)
{
toolSslHttpPort.Text = $"{Global.Loopback}:{Global.httpPort}";
if (config.listenerType == 2 || config.listenerType == 4)
@@ -340,8 +340,8 @@ namespace v2rayN.Forms
}
}
}
notifyMain.Icon = GetNotifyIcon();
notifyMain.Icon = MainFormHandler.Instance.GetNotifyIcon(config, this.Icon);
}
private void ssMain_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
@@ -351,45 +351,6 @@ namespace v2rayN.Forms
}
}
private Icon GetNotifyIcon()
{
try
{
var color = ColorTranslator.FromHtml("#3399CC");
var index = config.sysAgentEnabled ? config.listenerType : 0;
if (index > 0)
{
color = (new Color[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange })[index - 1];
//color = ColorTranslator.FromHtml(new string[] { "#CC0066", "#CC6600", "#99CC99", "#666699" }[index - 1]);
}
var width = 128;
var height = 128;
var bitmap = new Bitmap(width, height);
var graphics = Graphics.FromImage(bitmap);
var drawBrush = new SolidBrush(color);
graphics.FillEllipse(drawBrush, new Rectangle(0, 0, width, height));
var zoom = 16;
graphics.DrawImage(new Bitmap(Properties.Resources.notify, width - zoom, width - zoom), zoom / 2, zoom / 2);
bitmap.Save(Utils.GetPath("temp_icon.ico"), System.Drawing.Imaging.ImageFormat.Icon);
Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());
drawBrush.Dispose();
graphics.Dispose();
bitmap.Dispose();
return createdIcon;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
return this.Icon;
}
}
#endregion
#region v2ray
@@ -406,9 +367,9 @@ namespace v2rayN.Forms
v2rayHandler.LoadV2ray(config);
Global.reloadV2ray = false;
ConfigHandler.SaveConfig(ref config, false);
statistics?.SaveToFile();
ChangeSysAgent(config.sysAgentEnabled);
DisplayToolStatus();
ChangePACButtonStatus(config.listenerType);
}
/// <summary>
@@ -417,8 +378,9 @@ namespace v2rayN.Forms
private void CloseV2ray()
{
ConfigHandler.SaveConfig(ref config, false);
statistics?.SaveToFile();
ChangeSysAgent(false);
ChangePACButtonStatus(0);
v2rayHandler.V2rayStop();
}
@@ -635,79 +597,13 @@ namespace v2rayN.Forms
private void menuExport2ClientConfig_Click(object sender, EventArgs e)
{
int index = GetLvSelectedIndex();
if (index < 0)
{
return;
}
if (config.vmess[index].configType != (int)EConfigType.Vmess)
{
UI.Show(UIRes.I18N("NonVmessService"));
return;
}
SaveFileDialog fileDialog = new SaveFileDialog();
fileDialog.Filter = "Config|*.json";
fileDialog.FilterIndex = 2;
fileDialog.RestoreDirectory = true;
if (fileDialog.ShowDialog() != DialogResult.OK)
{
return;
}
string fileName = fileDialog.FileName;
if (Utils.IsNullOrEmpty(fileName))
{
return;
}
Config configCopy = Utils.DeepCopy<Config>(config);
configCopy.index = index;
string msg;
if (V2rayConfigHandler.Export2ClientConfig(configCopy, fileName, out msg) != 0)
{
UI.Show(msg);
}
else
{
UI.Show(string.Format(UIRes.I18N("SaveClientConfigurationIn"), fileName));
}
MainFormHandler.Instance.Export2ClientConfig(index, config);
}
private void menuExport2ServerConfig_Click(object sender, EventArgs e)
{
int index = GetLvSelectedIndex();
if (index < 0)
{
return;
}
if (config.vmess[index].configType != (int)EConfigType.Vmess)
{
UI.Show(UIRes.I18N("NonVmessService"));
return;
}
SaveFileDialog fileDialog = new SaveFileDialog();
fileDialog.Filter = "Config|*.json";
fileDialog.FilterIndex = 2;
fileDialog.RestoreDirectory = true;
if (fileDialog.ShowDialog() != DialogResult.OK)
{
return;
}
string fileName = fileDialog.FileName;
if (Utils.IsNullOrEmpty(fileName))
{
return;
}
Config configCopy = Utils.DeepCopy<Config>(config);
configCopy.index = index;
string msg;
if (V2rayConfigHandler.Export2ServerConfig(configCopy, fileName, out msg) != 0)
{
UI.Show(msg);
}
else
{
UI.Show(string.Format(UIRes.I18N("SaveServerConfigurationIn"), fileName));
}
MainFormHandler.Instance.Export2ServerConfig(index, config);
}
private void menuExport2ShareUrl_Click(object sender, EventArgs e)
@@ -962,7 +858,7 @@ namespace v2rayN.Forms
/// <param name="msg"></param>
private void ShowMsg(string msg)
{
if (txtMsgBox.Lines.Length > 500)
if (txtMsgBox.Lines.Length > 999)
{
ClearMsg();
}
@@ -1020,6 +916,7 @@ namespace v2rayN.Forms
this.Activate();
//this.notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
this.txtMsgBox.ScrollToCaret();
SetVisibleCore(true);
}
@@ -1063,51 +960,34 @@ namespace v2rayN.Forms
});
}
private void UpdateStatisticsHandler(ulong totalUp, ulong totalDown, ulong up, ulong down, List<Mode.ServerStatistics> statistics)
private void UpdateStatisticsHandler(ulong up, ulong down, List<ServerStatItem> statistics)
{
try
{
up /= (ulong)(config.statisticsFreshRate / 1000f);
down /= (ulong)(config.statisticsFreshRate / 1000f);
toolSslServerSpeed.Text = string.Format(
"{0}/s↑ | {1}/s↓",
Utils.HumanFy(up),
Utils.HumanFy(down)
);
toolSslServerSpeed.Text = string.Format("{0}/s↑ | {1}/s↓", Utils.HumanFy(up), Utils.HumanFy(down));
List<string[]> datas = new List<string[]>();
for (int i = 0; i < config.vmess.Count; i++)
{
string totalUp_ = string.Empty,
totalDown_ = string.Empty,
todayUp_ = string.Empty,
todayDown_ = string.Empty;
var index = statistics.FindIndex(item_ => Utils.IsIdenticalServer(item_, new ServerStatistics(config.vmess[i].remarks, config.vmess[i].address, config.vmess[i].port, config.vmess[i].path, config.vmess[i].requestHost, 0, 0, 0, 0)));
var index = statistics.FindIndex(item_ => item_.itemId == config.vmess[i].getItemId());
if (index != -1)
{
totalUp_ = Utils.HumanFy(statistics[index].totalUp);
totalDown_ = Utils.HumanFy(statistics[index].totalDown);
todayUp_ = Utils.HumanFy(statistics[index].todayUp);
todayDown_ = Utils.HumanFy(statistics[index].todayDown);
}
lvServers.Invoke((MethodInvoker)delegate
{
lvServers.SuspendLayout();
datas.Add(new string[] { totalUp_, totalDown_, todayUp_, todayDown_ });
var indexStart = 9;
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].totalUp);
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].totalDown);
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayUp);
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayDown);
lvServers.ResumeLayout();
});
}
}
lvServers.Invoke((MethodInvoker)delegate
{
lvServers.SuspendLayout();
for (int i = 0; i < datas.Count; i++)
{
var indexStart = 9;
lvServers.Items[i].SubItems[indexStart++].Text = datas[i][0];
lvServers.Items[i].SubItems[indexStart++].Text = datas[i][1];
lvServers.Items[i].SubItems[indexStart++].Text = datas[i][2];
lvServers.Items[i].SubItems[indexStart++].Text = datas[i][3];
}
lvServers.ResumeLayout();
});
}
catch (Exception ex)
{
@@ -1171,97 +1051,58 @@ namespace v2rayN.Forms
Utils.SetClipboardData(HttpProxyHandle.GetPacUrl());
}
private void menuSysAgentEnabled_Click(object sender, EventArgs e)
private void menuNotEnabledHttp_Click(object sender, EventArgs e)
{
bool isChecked = !config.sysAgentEnabled;
config.sysAgentEnabled = isChecked;
ChangeSysAgent(isChecked);
SetListenerType(0);
}
private void menuGlobal_Click(object sender, EventArgs e)
{
config.listenerType = 1;
ChangePACButtonStatus(config.listenerType);
SetListenerType(1);
}
private void menuGlobalPAC_Click(object sender, EventArgs e)
{
config.listenerType = 2;
ChangePACButtonStatus(config.listenerType);
SetListenerType(2);
}
private void menuKeep_Click(object sender, EventArgs e)
{
config.listenerType = 3;
ChangePACButtonStatus(config.listenerType);
SetListenerType(3);
}
private void menuKeepPAC_Click(object sender, EventArgs e)
{
config.listenerType = 4;
ChangePACButtonStatus(config.listenerType);
SetListenerType(4);
}
private void SetListenerType(int type)
{
config.listenerType = type;
ChangePACButtonStatus(type);
}
private void ChangePACButtonStatus(int type)
{
if (HttpProxyHandle.Update(config, false))
if (type != 0)
{
switch (type)
{
case 1:
menuGlobal.Checked = true;
menuGlobalPAC.Checked = false;
menuKeep.Checked = false;
menuKeepPAC.Checked = false;
break;
case 2:
menuGlobal.Checked = false;
menuGlobalPAC.Checked = true;
menuKeep.Checked = false;
menuKeepPAC.Checked = false;
break;
case 3:
menuGlobal.Checked = false;
menuGlobalPAC.Checked = false;
menuKeep.Checked = true;
menuKeepPAC.Checked = false;
break;
case 4:
menuGlobal.Checked = false;
menuGlobalPAC.Checked = false;
menuKeep.Checked = false;
menuKeepPAC.Checked = true;
break;
}
HttpProxyHandle.RestartHttpAgent(config, false);
}
else
{
HttpProxyHandle.CloseHttpAgent(config);
}
for (int k = 0; k < menuSysAgentMode.DropDownItems.Count; k++)
{
var item = ((ToolStripMenuItem)menuSysAgentMode.DropDownItems[k]);
item.Checked = (type == k);
}
ConfigHandler.SaveConfig(ref config, false);
DisplayToolStatus();
}
/// <summary>
/// 改变系统代理
/// </summary>
/// <param name="isChecked"></param>
private void ChangeSysAgent(bool isChecked)
{
if (isChecked)
{
if (HttpProxyHandle.RestartHttpAgent(config, false))
{
ChangePACButtonStatus(config.listenerType);
}
}
else
{
HttpProxyHandle.Update(config, true);
HttpProxyHandle.CloseHttpAgent(config);
}
menuSysAgentEnabled.Checked =
menuSysAgentMode.Enabled = isChecked;
DisplayToolStatus();
}
#endregion
@@ -1293,7 +1134,7 @@ namespace v2rayN.Forms
}
else
{
downloadHandle.DownloadFileAsync(config, url, null);
downloadHandle.DownloadFileAsync(config, url, null, -1);
}
}));
}
@@ -1400,7 +1241,7 @@ namespace v2rayN.Forms
private void tsbPromotion_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start($"{Global.PromotionUrl}?t={DateTime.Now.Ticks}");
System.Diagnostics.Process.Start($"{Utils.Base64Decode(Global.PromotionUrl)}?t={DateTime.Now.Ticks}");
}
#endregion
@@ -1528,9 +1369,7 @@ namespace v2rayN.Forms
Utils.RegWriteValue(Global.MyRegPath, Global.MyRegKeyLanguage, value);
}
#endregion
}
}

View File

@@ -291,7 +291,7 @@
<value>ImageAboveText</value>
</data>
<data name="cmsLv.Size" type="System.Drawing.Size, System.Drawing">
<value>448, 556</value>
<value>448, 534</value>
</data>
<data name="&gt;&gt;cmsLv.Name" xml:space="preserve">
<value>cmsLv</value>
@@ -333,7 +333,7 @@
<value>lvServers</value>
</data>
<data name="&gt;&gt;lvServers.Type" xml:space="preserve">
<value>v2rayN.Forms.ListViewFlickerFree, v2rayN, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
<value>v2rayN.Base.ListViewFlickerFree, v2rayN, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;lvServers.Parent" xml:space="preserve">
<value>splitContainer1.Panel1</value>
@@ -422,11 +422,11 @@
<data name="cmsMain.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="menuSysAgentEnabled.Size" type="System.Drawing.Size, System.Drawing">
<value>264, 22</value>
<data name="menuNotEnabledHttp.Size" type="System.Drawing.Size, System.Drawing">
<value>547, 22</value>
</data>
<data name="menuSysAgentEnabled.Text" xml:space="preserve">
<value>Enable Http proxy</value>
<data name="menuNotEnabledHttp.Text" xml:space="preserve">
<value>Not Enabled Http Proxy</value>
</data>
<data name="menuGlobal.Size" type="System.Drawing.Size, System.Drawing">
<value>547, 22</value>
@@ -456,7 +456,7 @@
<value>264, 22</value>
</data>
<data name="menuSysAgentMode.Text" xml:space="preserve">
<value>Http proxy mode</value>
<value>Http proxy</value>
</data>
<data name="menuServers.Size" type="System.Drawing.Size, System.Drawing">
<value>264, 22</value>
@@ -1118,18 +1118,18 @@
<data name="&gt;&gt;notifyMain.Type" xml:space="preserve">
<value>System.Windows.Forms.NotifyIcon, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;menuSysAgentEnabled.Name" xml:space="preserve">
<value>menuSysAgentEnabled</value>
</data>
<data name="&gt;&gt;menuSysAgentEnabled.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;menuSysAgentMode.Name" xml:space="preserve">
<value>menuSysAgentMode</value>
</data>
<data name="&gt;&gt;menuSysAgentMode.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;menuNotEnabledHttp.Name" xml:space="preserve">
<value>menuNotEnabledHttp</value>
</data>
<data name="&gt;&gt;menuNotEnabledHttp.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;menuGlobal.Name" xml:space="preserve">
<value>menuGlobal</value>
</data>

View File

@@ -268,6 +268,12 @@
<data name="menuExport2SubContent.Text" xml:space="preserve">
<value>批量导出订阅内容至剪贴板(多选)</value>
</data>
<data name="tsbServer.Size" type="System.Drawing.Size, System.Drawing">
<value>73, 53</value>
</data>
<data name="tsbServer.Text" xml:space="preserve">
<value> 服务器 </value>
</data>
<data name="cmsLv.Size" type="System.Drawing.Size, System.Drawing">
<value>279, 534</value>
</data>
@@ -288,26 +294,11 @@
ZW0uRHJhd2luZy5HcmFwaGljc1VuaXQBAAAAB3ZhbHVlX18ACAMAAAADAAAACw==
</value>
</data>
<data name="tsbServer.Size" type="System.Drawing.Size, System.Drawing">
<value>73, 53</value>
<data name="menuNotEnabledHttp.Size" type="System.Drawing.Size, System.Drawing">
<value>340, 22</value>
</data>
<data name="tsbServer.Text" xml:space="preserve">
<value> 服务器 </value>
</data>
<data name="cmsMain.Size" type="System.Drawing.Size, System.Drawing">
<value>196, 164</value>
</data>
<data name="menuSysAgentEnabled.Size" type="System.Drawing.Size, System.Drawing">
<value>195, 22</value>
</data>
<data name="menuSysAgentEnabled.Text" xml:space="preserve">
<value>启用Http代理</value>
</data>
<data name="menuSysAgentMode.Size" type="System.Drawing.Size, System.Drawing">
<value>195, 22</value>
</data>
<data name="menuSysAgentMode.Text" xml:space="preserve">
<value>Http代理模式</value>
<data name="menuNotEnabledHttp.Text" xml:space="preserve">
<value>关闭Http代理</value>
</data>
<data name="menuGlobal.Size" type="System.Drawing.Size, System.Drawing">
<value>340, 22</value>
@@ -333,6 +324,12 @@
<data name="menuKeepPAC.Text" xml:space="preserve">
<value>仅开启PAC,不自动配置PAC</value>
</data>
<data name="menuSysAgentMode.Size" type="System.Drawing.Size, System.Drawing">
<value>195, 22</value>
</data>
<data name="menuSysAgentMode.Text" xml:space="preserve">
<value>Http代理</value>
</data>
<data name="menuServers.Size" type="System.Drawing.Size, System.Drawing">
<value>195, 22</value>
</data>
@@ -366,20 +363,17 @@
<data name="menuExit.Text" xml:space="preserve">
<value>退出</value>
</data>
<data name="cmsMain.Size" type="System.Drawing.Size, System.Drawing">
<value>196, 142</value>
</data>
<data name="groupBox1.Text" xml:space="preserve">
<value>服务器列表</value>
</data>
<data name="groupBox2.Text" xml:space="preserve">
<value>信息</value>
</data>
<data name="toolSslServerSpeed.Text" xml:space="preserve">
<value>网速显示未启用</value>
</data>
<data name="tsbSub.Size" type="System.Drawing.Size, System.Drawing">
<value>61, 53</value>
</data>
<data name="tsbSub.Text" xml:space="preserve">
<value> 订阅 </value>
<data name="groupBox2.Text" xml:space="preserve">
<value>信息</value>
</data>
<data name="tsbSubSetting.Size" type="System.Drawing.Size, System.Drawing">
<value>124, 22</value>
@@ -393,6 +387,12 @@
<data name="tsbSubUpdate.Text" xml:space="preserve">
<value>更新订阅</value>
</data>
<data name="tsbSub.Size" type="System.Drawing.Size, System.Drawing">
<value>61, 53</value>
</data>
<data name="tsbSub.Text" xml:space="preserve">
<value> 订阅 </value>
</data>
<data name="tsbOptionSetting.Size" type="System.Drawing.Size, System.Drawing">
<value>76, 53</value>
</data>
@@ -402,7 +402,7 @@
<data name="tsbReload.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAE3SURBVFhH7ZaBDQIhDEVvBEdwBDfQDXQER3AD3cARdAPd
YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAE3SURBVFhH7ZaBDQIhDEVvBEdwBDfQDXQER3AD3cARdAPd
QDfSDbQvuSb1AicFjJrwkxcN0FIolOuamv5VE2E+gLaPayWchEcE+hhTXVPhIoQmDcFYbKpoJtwEdX4X
jgIrXfTwnzb6dBw22BaJVdjJmWQs1/SdBRtE0U5cBXW2oSFRO0HtSEeW2FZ1wsq9sjuRdTDVAXnNuWLY
6JnAl0sYa/Q5q1dhq35ci+Bkq2HJvbZpxGeybAAuw4Fq+cnW1wPITgHFYxvBUw+qHEIL1yq1vDKhVlH3
@@ -416,12 +416,6 @@
<data name="tsbReload.Text" xml:space="preserve">
<value> 重启服务 </value>
</data>
<data name="tsbCheckUpdate.Size" type="System.Drawing.Size, System.Drawing">
<value>85, 53</value>
</data>
<data name="tsbCheckUpdate.Text" xml:space="preserve">
<value> 检查更新 </value>
</data>
<data name="tsbCheckUpdateN.Size" type="System.Drawing.Size, System.Drawing">
<value>232, 22</value>
</data>
@@ -446,15 +440,21 @@
<data name="tsbCheckClearPACList.Text" xml:space="preserve">
<value>简化PAC (请设置Core路由)</value>
</data>
<data name="tsbCheckUpdate.Size" type="System.Drawing.Size, System.Drawing">
<value>85, 53</value>
</data>
<data name="tsbCheckUpdate.Text" xml:space="preserve">
<value> 检查更新 </value>
</data>
<data name="tsbAbout.Text" xml:space="preserve">
<value>关于</value>
</data>
<data name="tsbHelp.Size" type="System.Drawing.Size, System.Drawing">
<value>69, 53</value>
</data>
<data name="tsbHelp.Text" xml:space="preserve">
<value> 帮助 </value>
</data>
<data name="tsbAbout.Text" xml:space="preserve">
<value>关于</value>
</data>
<data name="tsbPromotion.Size" type="System.Drawing.Size, System.Drawing">
<value>68, 53</value>
</data>
@@ -464,7 +464,7 @@
<data name="tsbClose.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAySURBVFhH7c6xDQAgCEVBRnVTHU2ZABuMxV3yOvJDAAA/
YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAySURBVFhH7c6xDQAgCEVBRnVTHU2ZABuMxV3yOvJDAAA/
GqfZVG6X8mg1dfUAAPBQxAZd0SJruVXHWwAAAABJRU5ErkJggg==
</value>
</data>

View File

@@ -33,6 +33,8 @@
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label16 = new System.Windows.Forms.Label();
this.cmblistenerType = new System.Windows.Forms.ComboBox();
this.chksniffingEnabled2 = new System.Windows.Forms.CheckBox();
this.chksniffingEnabled = new System.Windows.Forms.CheckBox();
this.txtremoteDNS = new System.Windows.Forms.TextBox();
@@ -60,14 +62,13 @@
this.txtUserdirect = new System.Windows.Forms.TextBox();
this.tabPage5 = new System.Windows.Forms.TabPage();
this.txtUserblock = new System.Windows.Forms.TextBox();
this.tabPage8 = new System.Windows.Forms.TabPage();
this.cmbroutingMode = new System.Windows.Forms.ComboBox();
this.panel3 = new System.Windows.Forms.Panel();
this.btnSetDefRountingRule = new System.Windows.Forms.Button();
this.labRoutingTips = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.cmbdomainStrategy = new System.Windows.Forms.ComboBox();
this.label15 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.cmbroutingMode = new System.Windows.Forms.ComboBox();
this.tabPage6 = new System.Windows.Forms.TabPage();
this.chkKcpcongestion = new System.Windows.Forms.CheckBox();
this.txtKcpwriteBufferSize = new System.Windows.Forms.TextBox();
@@ -84,9 +85,7 @@
this.label6 = new System.Windows.Forms.Label();
this.tabPage7 = new System.Windows.Forms.TabPage();
this.cbFreshrate = new System.Windows.Forms.ComboBox();
this.tbCacheDays = new System.Windows.Forms.TextBox();
this.lbFreshrate = new System.Windows.Forms.Label();
this.lbCacheDays = new System.Windows.Forms.Label();
this.chkEnableStatistics = new System.Windows.Forms.CheckBox();
this.chkAllowLANConn = new System.Windows.Forms.CheckBox();
this.txturlGFWList = new System.Windows.Forms.TextBox();
@@ -104,6 +103,7 @@
this.tabPage3.SuspendLayout();
this.tabPage4.SuspendLayout();
this.tabPage5.SuspendLayout();
this.tabPage8.SuspendLayout();
this.panel3.SuspendLayout();
this.tabPage6.SuspendLayout();
this.tabPage7.SuspendLayout();
@@ -112,32 +112,33 @@
//
// btnClose
//
resources.ApplyResources(this.btnClose, "btnClose");
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
resources.ApplyResources(this.btnClose, "btnClose");
this.btnClose.Name = "btnClose";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// tabControl1
//
resources.ApplyResources(this.tabControl1, "tabControl1");
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage6);
this.tabControl1.Controls.Add(this.tabPage7);
resources.ApplyResources(this.tabControl1, "tabControl1");
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
//
// tabPage1
//
resources.ApplyResources(this.tabPage1, "tabPage1");
this.tabPage1.Controls.Add(this.groupBox1);
resources.ApplyResources(this.tabPage1, "tabPage1");
this.tabPage1.Name = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true;
//
// groupBox1
//
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Controls.Add(this.label16);
this.groupBox1.Controls.Add(this.cmblistenerType);
this.groupBox1.Controls.Add(this.chksniffingEnabled2);
this.groupBox1.Controls.Add(this.chksniffingEnabled);
this.groupBox1.Controls.Add(this.txtremoteDNS);
@@ -156,9 +157,28 @@
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.txtlocalPort);
this.groupBox1.Controls.Add(this.label2);
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Name = "groupBox1";
this.groupBox1.TabStop = false;
//
// label16
//
resources.ApplyResources(this.label16, "label16");
this.label16.Name = "label16";
//
// cmblistenerType
//
this.cmblistenerType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmblistenerType.FormattingEnabled = true;
this.cmblistenerType.Items.AddRange(new object[] {
resources.GetString("cmblistenerType.Items"),
resources.GetString("cmblistenerType.Items1"),
resources.GetString("cmblistenerType.Items2"),
resources.GetString("cmblistenerType.Items3"),
resources.GetString("cmblistenerType.Items4")});
resources.ApplyResources(this.cmblistenerType, "cmblistenerType");
this.cmblistenerType.Name = "cmblistenerType";
//
// chksniffingEnabled2
//
resources.ApplyResources(this.chksniffingEnabled2, "chksniffingEnabled2");
@@ -202,12 +222,12 @@
//
// cmbprotocol2
//
resources.ApplyResources(this.cmbprotocol2, "cmbprotocol2");
this.cmbprotocol2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbprotocol2.FormattingEnabled = true;
this.cmbprotocol2.Items.AddRange(new object[] {
resources.GetString("cmbprotocol2.Items"),
resources.GetString("cmbprotocol2.Items1")});
resources.ApplyResources(this.cmbprotocol2, "cmbprotocol2");
this.cmbprotocol2.Name = "cmbprotocol2";
//
// label3
@@ -222,8 +242,8 @@
//
// cmbprotocol
//
resources.ApplyResources(this.cmbprotocol, "cmbprotocol");
this.cmbprotocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
resources.ApplyResources(this.cmbprotocol, "cmbprotocol");
this.cmbprotocol.FormattingEnabled = true;
this.cmbprotocol.Items.AddRange(new object[] {
resources.GetString("cmbprotocol.Items"),
@@ -249,7 +269,6 @@
//
// cmbloglevel
//
resources.ApplyResources(this.cmbloglevel, "cmbloglevel");
this.cmbloglevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbloglevel.FormattingEnabled = true;
this.cmbloglevel.Items.AddRange(new object[] {
@@ -258,6 +277,7 @@
resources.GetString("cmbloglevel.Items2"),
resources.GetString("cmbloglevel.Items3"),
resources.GetString("cmbloglevel.Items4")});
resources.ApplyResources(this.cmbloglevel, "cmbloglevel");
this.cmbloglevel.Name = "cmbloglevel";
//
// label5
@@ -277,32 +297,33 @@
//
// tabPage2
//
resources.ApplyResources(this.tabPage2, "tabPage2");
this.tabPage2.Controls.Add(this.groupBox2);
resources.ApplyResources(this.tabPage2, "tabPage2");
this.tabPage2.Name = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true;
//
// groupBox2
//
resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.Controls.Add(this.tabControl2);
this.groupBox2.Controls.Add(this.panel3);
resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.Name = "groupBox2";
this.groupBox2.TabStop = false;
//
// tabControl2
//
resources.ApplyResources(this.tabControl2, "tabControl2");
this.tabControl2.Controls.Add(this.tabPage3);
this.tabControl2.Controls.Add(this.tabPage4);
this.tabControl2.Controls.Add(this.tabPage5);
this.tabControl2.Controls.Add(this.tabPage8);
resources.ApplyResources(this.tabControl2, "tabControl2");
this.tabControl2.Name = "tabControl2";
this.tabControl2.SelectedIndex = 0;
//
// tabPage3
//
resources.ApplyResources(this.tabPage3, "tabPage3");
this.tabPage3.Controls.Add(this.txtUseragent);
resources.ApplyResources(this.tabPage3, "tabPage3");
this.tabPage3.Name = "tabPage3";
this.tabPage3.UseVisualStyleBackColor = true;
//
@@ -313,8 +334,8 @@
//
// tabPage4
//
resources.ApplyResources(this.tabPage4, "tabPage4");
this.tabPage4.Controls.Add(this.txtUserdirect);
resources.ApplyResources(this.tabPage4, "tabPage4");
this.tabPage4.Name = "tabPage4";
this.tabPage4.UseVisualStyleBackColor = true;
//
@@ -325,8 +346,8 @@
//
// tabPage5
//
resources.ApplyResources(this.tabPage5, "tabPage5");
this.tabPage5.Controls.Add(this.txtUserblock);
resources.ApplyResources(this.tabPage5, "tabPage5");
this.tabPage5.Name = "tabPage5";
this.tabPage5.UseVisualStyleBackColor = true;
//
@@ -335,16 +356,32 @@
resources.ApplyResources(this.txtUserblock, "txtUserblock");
this.txtUserblock.Name = "txtUserblock";
//
// tabPage8
//
this.tabPage8.Controls.Add(this.cmbroutingMode);
resources.ApplyResources(this.tabPage8, "tabPage8");
this.tabPage8.Name = "tabPage8";
this.tabPage8.UseVisualStyleBackColor = true;
//
// cmbroutingMode
//
this.cmbroutingMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbroutingMode.FormattingEnabled = true;
this.cmbroutingMode.Items.AddRange(new object[] {
resources.GetString("cmbroutingMode.Items"),
resources.GetString("cmbroutingMode.Items1"),
resources.GetString("cmbroutingMode.Items2"),
resources.GetString("cmbroutingMode.Items3")});
resources.ApplyResources(this.cmbroutingMode, "cmbroutingMode");
this.cmbroutingMode.Name = "cmbroutingMode";
//
// panel3
//
resources.ApplyResources(this.panel3, "panel3");
this.panel3.Controls.Add(this.btnSetDefRountingRule);
this.panel3.Controls.Add(this.labRoutingTips);
this.panel3.Controls.Add(this.label4);
this.panel3.Controls.Add(this.cmbdomainStrategy);
this.panel3.Controls.Add(this.label15);
this.panel3.Controls.Add(this.label12);
this.panel3.Controls.Add(this.cmbroutingMode);
resources.ApplyResources(this.panel3, "panel3");
this.panel3.Name = "panel3";
//
// btnSetDefRountingRule
@@ -356,25 +393,19 @@
//
// labRoutingTips
//
resources.ApplyResources(this.labRoutingTips, "labRoutingTips");
this.labRoutingTips.ForeColor = System.Drawing.Color.Brown;
resources.ApplyResources(this.labRoutingTips, "labRoutingTips");
this.labRoutingTips.Name = "labRoutingTips";
//
// label4
//
resources.ApplyResources(this.label4, "label4");
this.label4.ForeColor = System.Drawing.Color.Brown;
this.label4.Name = "label4";
//
// cmbdomainStrategy
//
resources.ApplyResources(this.cmbdomainStrategy, "cmbdomainStrategy");
this.cmbdomainStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbdomainStrategy.FormattingEnabled = true;
this.cmbdomainStrategy.Items.AddRange(new object[] {
resources.GetString("cmbdomainStrategy.Items"),
resources.GetString("cmbdomainStrategy.Items1"),
resources.GetString("cmbdomainStrategy.Items2")});
resources.ApplyResources(this.cmbdomainStrategy, "cmbdomainStrategy");
this.cmbdomainStrategy.Name = "cmbdomainStrategy";
//
// label15
@@ -382,26 +413,8 @@
resources.ApplyResources(this.label15, "label15");
this.label15.Name = "label15";
//
// label12
//
resources.ApplyResources(this.label12, "label12");
this.label12.Name = "label12";
//
// cmbroutingMode
//
resources.ApplyResources(this.cmbroutingMode, "cmbroutingMode");
this.cmbroutingMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbroutingMode.FormattingEnabled = true;
this.cmbroutingMode.Items.AddRange(new object[] {
resources.GetString("cmbroutingMode.Items"),
resources.GetString("cmbroutingMode.Items1"),
resources.GetString("cmbroutingMode.Items2"),
resources.GetString("cmbroutingMode.Items3")});
this.cmbroutingMode.Name = "cmbroutingMode";
//
// tabPage6
//
resources.ApplyResources(this.tabPage6, "tabPage6");
this.tabPage6.Controls.Add(this.chkKcpcongestion);
this.tabPage6.Controls.Add(this.txtKcpwriteBufferSize);
this.tabPage6.Controls.Add(this.label10);
@@ -415,6 +428,7 @@
this.tabPage6.Controls.Add(this.label7);
this.tabPage6.Controls.Add(this.txtKcpmtu);
this.tabPage6.Controls.Add(this.label6);
resources.ApplyResources(this.tabPage6, "tabPage6");
this.tabPage6.Name = "tabPage6";
this.tabPage6.UseVisualStyleBackColor = true;
//
@@ -486,41 +500,29 @@
//
// tabPage7
//
resources.ApplyResources(this.tabPage7, "tabPage7");
this.tabPage7.Controls.Add(this.cbFreshrate);
this.tabPage7.Controls.Add(this.tbCacheDays);
this.tabPage7.Controls.Add(this.lbFreshrate);
this.tabPage7.Controls.Add(this.lbCacheDays);
this.tabPage7.Controls.Add(this.chkEnableStatistics);
this.tabPage7.Controls.Add(this.chkAllowLANConn);
this.tabPage7.Controls.Add(this.txturlGFWList);
this.tabPage7.Controls.Add(this.label13);
this.tabPage7.Controls.Add(this.chkAutoRun);
resources.ApplyResources(this.tabPage7, "tabPage7");
this.tabPage7.Name = "tabPage7";
this.tabPage7.UseVisualStyleBackColor = true;
//
// cbFreshrate
//
resources.ApplyResources(this.cbFreshrate, "cbFreshrate");
this.cbFreshrate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbFreshrate.FormattingEnabled = true;
resources.ApplyResources(this.cbFreshrate, "cbFreshrate");
this.cbFreshrate.Name = "cbFreshrate";
//
// tbCacheDays
//
resources.ApplyResources(this.tbCacheDays, "tbCacheDays");
this.tbCacheDays.Name = "tbCacheDays";
//
// lbFreshrate
//
resources.ApplyResources(this.lbFreshrate, "lbFreshrate");
this.lbFreshrate.Name = "lbFreshrate";
//
// lbCacheDays
//
resources.ApplyResources(this.lbCacheDays, "lbCacheDays");
this.lbCacheDays.Name = "lbCacheDays";
//
// chkEnableStatistics
//
resources.ApplyResources(this.chkEnableStatistics, "chkEnableStatistics");
@@ -551,9 +553,9 @@
//
// panel2
//
resources.ApplyResources(this.panel2, "panel2");
this.panel2.Controls.Add(this.btnClose);
this.panel2.Controls.Add(this.btnOK);
resources.ApplyResources(this.panel2, "panel2");
this.panel2.Name = "panel2";
//
// btnOK
@@ -592,6 +594,7 @@
this.tabPage4.PerformLayout();
this.tabPage5.ResumeLayout(false);
this.tabPage5.PerformLayout();
this.tabPage8.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.tabPage6.ResumeLayout(false);
@@ -660,16 +663,15 @@
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.ComboBox cmbdomainStrategy;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.ComboBox cmbroutingMode;
private System.Windows.Forms.CheckBox chksniffingEnabled;
private System.Windows.Forms.CheckBox chksniffingEnabled2;
private System.Windows.Forms.Button btnSetDefRountingRule;
private System.Windows.Forms.CheckBox chkEnableStatistics;
private System.Windows.Forms.TextBox tbCacheDays;
private System.Windows.Forms.Label lbCacheDays;
private System.Windows.Forms.ComboBox cbFreshrate;
private System.Windows.Forms.Label lbFreshrate;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.ComboBox cmblistenerType;
private System.Windows.Forms.TabPage tabPage8;
}
}

View File

@@ -64,6 +64,8 @@ namespace v2rayN.Forms
//remoteDNS
txtremoteDNS.Text = config.remoteDNS;
cmblistenerType.SelectedIndex = config.listenerType;
}
/// <summary>
@@ -113,8 +115,6 @@ namespace v2rayN.Forms
var enableStatistics = config.enableStatistics;
chkEnableStatistics.Checked = enableStatistics;
tbCacheDays.Text = config.CacheDays.ToString();
var cbSource = new ComboItem[]
{
@@ -250,7 +250,8 @@ namespace v2rayN.Forms
//remoteDNS
config.remoteDNS = txtremoteDNS.Text.TrimEx();
config.listenerType = cmblistenerType.SelectedIndex;
return 0;
}
@@ -329,13 +330,6 @@ namespace v2rayN.Forms
var lastEnableStatistics = config.enableStatistics;
config.enableStatistics = chkEnableStatistics.Checked;
uint days = 0;
var valid = uint.TryParse(tbCacheDays.Text, out days);
if (!valid)
days = 7;
config.CacheDays = days;
config.statisticsFreshRate = (int)cbFreshrate.SelectedValue;
//if(lastEnableStatistics != config.enableStatistics)
@@ -372,6 +366,7 @@ namespace v2rayN.Forms
txtUseragent.Text = Utils.GetEmbedText(Global.CustomRoutingFileName + Global.agentTag);
txtUserdirect.Text = Utils.GetEmbedText(Global.CustomRoutingFileName + Global.directTag);
txtUserblock.Text = Utils.GetEmbedText(Global.CustomRoutingFileName + Global.blockTag);
cmbroutingMode.SelectedIndex = 3;
var lstUrl = new List<string>();
lstUrl.Add(Global.CustomRoutingListUrl + Global.agentTag);

File diff suppressed because it is too large Load Diff

View File

@@ -120,7 +120,31 @@
<data name="btnClose.Text" xml:space="preserve">
<value>取消(&amp;C)</value>
</data>
<data name="tabPage1.Text" xml:space="preserve">
<value> Core:基础设置 </value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="label16.Size" type="System.Drawing.Size, System.Drawing">
<value>53, 12</value>
</data>
<data name="label16.Text" xml:space="preserve">
<value>Http代理</value>
</data>
<data name="cmblistenerType.Items" xml:space="preserve">
<value>关闭Http代理</value>
</data>
<data name="cmblistenerType.Items1" xml:space="preserve">
<value>开启Http代理,并自动配置代理服务器(全局模式)</value>
</data>
<data name="cmblistenerType.Items2" xml:space="preserve">
<value>开启PAC,并自动配置PAC(PAC模式)</value>
</data>
<data name="cmblistenerType.Items3" xml:space="preserve">
<value>仅开启Http代理,不自动配置代理服务器(直连模式)</value>
</data>
<data name="cmblistenerType.Items4" xml:space="preserve">
<value>仅开启PAC,不自动配置PAC</value>
</data>
<data name="chksniffingEnabled2.Size" type="System.Drawing.Size, System.Drawing">
<value>96, 16</value>
</data>
@@ -190,79 +214,47 @@
<data name="label2.Text" xml:space="preserve">
<value>本地监听端口</value>
</data>
<data name="tabPage1.Text" xml:space="preserve">
<value> Core:基础设置 </value>
<data name="tabPage2.Text" xml:space="preserve">
<value> Core:路由设置 </value>
</data>
<data name="tabControl2.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 89</value>
</data>
<data name="tabControl2.Size" type="System.Drawing.Size, System.Drawing">
<value>642, 481</value>
</data>
<data name="tabPage3.Size" type="System.Drawing.Size, System.Drawing">
<value>634, 455</value>
</data>
<data name="tabPage3.Text" xml:space="preserve">
<value> 代理的Domain或IP </value>
<value> 1.代理的Domain或IP </value>
</data>
<data name="txtUserdirect.Size" type="System.Drawing.Size, System.Drawing">
<value>628, 404</value>
<data name="txtUseragent.Size" type="System.Drawing.Size, System.Drawing">
<value>628, 449</value>
</data>
<data name="tabPage4.Size" type="System.Drawing.Size, System.Drawing">
<value>634, 410</value>
<value>634, 455</value>
</data>
<data name="tabPage4.Text" xml:space="preserve">
<value> 直连的Domain或IP </value>
<value> 2.直连的Domain或IP </value>
</data>
<data name="txtUserblock.Size" type="System.Drawing.Size, System.Drawing">
<value>628, 404</value>
<data name="txtUserdirect.Size" type="System.Drawing.Size, System.Drawing">
<value>628, 449</value>
</data>
<data name="tabPage5.Size" type="System.Drawing.Size, System.Drawing">
<value>634, 410</value>
<value>634, 455</value>
</data>
<data name="tabPage5.Text" xml:space="preserve">
<value> 阻止的Domain或IP </value>
<value> 3.阻止的Domain或IP </value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="btnSetDefRountingRule.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
<data name="txtUserblock.Size" type="System.Drawing.Size, System.Drawing">
<value>628, 449</value>
</data>
<data name="btnSetDefRountingRule.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 60</value>
<data name="tabPage8.Size" type="System.Drawing.Size, System.Drawing">
<value>634, 455</value>
</data>
<data name="btnSetDefRountingRule.Size" type="System.Drawing.Size, System.Drawing">
<value>201, 23</value>
</data>
<data name="btnSetDefRountingRule.Text" xml:space="preserve">
<value>一键设置默认自定义路由规则</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="labRoutingTips.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labRoutingTips.Location" type="System.Drawing.Point, System.Drawing">
<value>5, 96</value>
</data>
<data name="labRoutingTips.Size" type="System.Drawing.Size, System.Drawing">
<value>383, 12</value>
</data>
<data name="labRoutingTips.Text" xml:space="preserve">
<value>*设置的规则,用逗号(,)隔开;支持Domain(纯字符串/正则/子域名)和IP</value>
</data>
<data name="label4.Text" xml:space="preserve">
<value>规则加载次序:自定义的代理/直连/阻止,选择的路由模式</value>
</data>
<data name="cmbdomainStrategy.Location" type="System.Drawing.Point, System.Drawing">
<value>81, 30</value>
</data>
<data name="cmbdomainStrategy.Size" type="System.Drawing.Size, System.Drawing">
<value>186, 20</value>
</data>
<data name="label15.Size" type="System.Drawing.Size, System.Drawing">
<value>53, 12</value>
</data>
<data name="label15.Text" xml:space="preserve">
<value>域名策略</value>
</data>
<data name="label12.Location" type="System.Drawing.Point, System.Drawing">
<value>295, 34</value>
</data>
<data name="label12.Size" type="System.Drawing.Size, System.Drawing">
<value>53, 12</value>
</data>
<data name="label12.Text" xml:space="preserve">
<value>路由模式</value>
<data name="tabPage8.Text" xml:space="preserve">
<value> 4.预定义规则 </value>
</data>
<data name="cmbroutingMode.Items" xml:space="preserve">
<value>全局</value>
@@ -277,17 +269,58 @@
<value>绕过局域网及大陆地址</value>
</data>
<data name="cmbroutingMode.Location" type="System.Drawing.Point, System.Drawing">
<value>372, 30</value>
<value>19, 26</value>
</data>
<data name="cmbroutingMode.Size" type="System.Drawing.Size, System.Drawing">
<value>244, 20</value>
</data>
<data name="tabPage2.Text" xml:space="preserve">
<value> Core:路由设置 </value>
<data name="panel3.Size" type="System.Drawing.Size, System.Drawing">
<value>642, 72</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="btnSetDefRountingRule.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="btnSetDefRountingRule.Location" type="System.Drawing.Point, System.Drawing">
<value>351, 14</value>
</data>
<data name="btnSetDefRountingRule.Size" type="System.Drawing.Size, System.Drawing">
<value>201, 23</value>
</data>
<data name="btnSetDefRountingRule.Text" xml:space="preserve">
<value>一键设置默认自定义路由规则</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="labRoutingTips.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labRoutingTips.Location" type="System.Drawing.Point, System.Drawing">
<value>5, 49</value>
</data>
<data name="labRoutingTips.Size" type="System.Drawing.Size, System.Drawing">
<value>383, 12</value>
</data>
<data name="labRoutingTips.Text" xml:space="preserve">
<value>*设置的规则,用逗号(,)隔开;支持Domain(纯字符串/正则/子域名)和IP</value>
</data>
<data name="cmbdomainStrategy.Location" type="System.Drawing.Point, System.Drawing">
<value>81, 14</value>
</data>
<data name="cmbdomainStrategy.Size" type="System.Drawing.Size, System.Drawing">
<value>186, 20</value>
</data>
<data name="label15.Size" type="System.Drawing.Size, System.Drawing">
<value>53, 12</value>
</data>
<data name="label15.Text" xml:space="preserve">
<value>域名策略</value>
</data>
<data name="tabPage6.Text" xml:space="preserve">
<value> Core:KCP设置 </value>
</data>
<data name="tabPage7.Text" xml:space="preserve">
<value> v2rayN设置 </value>
</data>
<data name="lbFreshrate.Size" type="System.Drawing.Size, System.Drawing">
<value>77, 12</value>
</data>
@@ -324,9 +357,6 @@
<data name="chkAutoRun.Text" xml:space="preserve">
<value>开机自动启动(可能会不成功)</value>
</data>
<data name="tabPage7.Text" xml:space="preserve">
<value> v2rayN设置 </value>
</data>
<data name="btnOK.Text" xml:space="preserve">
<value>确定(&amp;O)</value>
</data>

View File

@@ -5,19 +5,15 @@ namespace v2rayN
{
#region
/// <summary>
/// 更新链接
/// </summary>
public const string UpdateUrl = @"https://github.com/2dust/v2rayN/releases";
/// <summary>
/// 关于链接
/// </summary>
public const string AboutUrl = @"https://github.com/2dust/v2rayN";
public const string UpdateUrl = AboutUrl + @"/releases";
/// <summary>
/// SpeedTestUrl
/// </summary>
public const string SpeedTestUrl = @"http://speedtest-sfo2.digitalocean.com/10mb.test";
public const string SpeedTestUrl = @"http://speedtest-sgp1.digitalocean.com/10mb.test";
public const string SpeedPingTestUrl = @"https://www.google.com/generate_204";
/// <summary>
@@ -30,7 +26,7 @@ namespace v2rayN
/// <summary>
/// PromotionUrl
/// </summary>
public const string PromotionUrl = @"https://1.2345345.xyz/ads.html";
public const string PromotionUrl = @"aHR0cHM6Ly8xLjIzNDQ1Ni54eXovYWRzLmh0bWw=";
/// <summary>
/// 本软件配置文件名
@@ -164,8 +160,7 @@ namespace v2rayN
medium = 2000,
slow = 3000
}
public const string StatisticLogDirectory = "Statistics";
public const string StatisticLogOverall = "overall.txt";
public const string StatisticLogOverall = "StatisticLogOverall.json";
#endregion

View File

@@ -41,10 +41,7 @@ namespace v2rayN.Handler
////默认监听端口
//config.pacPort = 8888;
// 默认缓存七天
config.CacheDays = 7;
// 默认不开启统计
config.enableStatistics = false;
@@ -125,6 +122,10 @@ namespace v2rayN.Handler
{
config.urlGFWList = Global.GFWLIST_URL;
}
if (Utils.IsNullOrEmpty(config.remoteDNS))
{
config.remoteDNS = "1.1.1.1";
}
if (config.subItem == null)
{

View File

@@ -40,15 +40,13 @@ namespace v2rayN.Handler
private string latestUrl = "https://github.com/v2ray/v2ray-core/releases/latest";
private const string coreURL = "https://github.com/v2ray/v2ray-core/releases/download/{0}/v2ray-windows-{1}.zip";
private int progressPercentage = -1;
private bool blFirst = true;
private long totalBytesToReceive = 0;
private DateTime totalDatetime = new DateTime();
private int DownloadTimeout = -1;
public void AbsoluteV2rayCore(Config config)
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //TLS 1.2
ServicePointManager.DefaultConnectionLimit = 256;
SetSecurityProtocol();
WebRequest request = WebRequest.Create(latestUrl);
request.BeginGetResponse(new AsyncCallback(OnResponseV2rayCore), request);
}
@@ -87,12 +85,11 @@ namespace v2rayN.Handler
}
public void DownloadFileAsync(Config config, string url, WebProxy webProxy)
public void DownloadFileAsync(Config config, string url, WebProxy webProxy, int downloadTimeout)
{
try
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //TLS 1.2
ServicePointManager.DefaultConnectionLimit = 256;
SetSecurityProtocol();
if (UpdateCompleted != null)
{
UpdateCompleted(this, new ResultEventArgs(false, "Downloading..."));
@@ -101,6 +98,7 @@ namespace v2rayN.Handler
progressPercentage = -1;
WebClientEx ws = new WebClientEx();
DownloadTimeout = downloadTimeout;
if (webProxy != null)
{
ws.Proxy = webProxy;// new WebProxy(Global.Loopback, Global.httpPort);
@@ -109,7 +107,7 @@ namespace v2rayN.Handler
ws.DownloadFileCompleted += ws_DownloadFileCompleted;
ws.DownloadProgressChanged += ws_DownloadProgressChanged;
ws.DownloadFileAsync(new Uri(url), Utils.GetPath(DownloadFileName));
blFirst = true;
totalBytesToReceive = 0;
}
catch (Exception ex)
{
@@ -122,14 +120,24 @@ namespace v2rayN.Handler
void ws_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
if (blFirst)
{
totalBytesToReceive = e.TotalBytesToReceive - e.BytesReceived;
totalDatetime = DateTime.Now;
blFirst = false;
}
if (UpdateCompleted != null)
{
if (DownloadTimeout != -1)
{
if ((DateTime.Now - totalDatetime).TotalSeconds > DownloadTimeout)
{
((WebClientEx)sender).CancelAsync();
}
}
if (totalBytesToReceive == 0)
{
totalDatetime = DateTime.Now;
totalBytesToReceive = e.BytesReceived;
return;
}
totalBytesToReceive = e.BytesReceived;
if (progressPercentage != e.ProgressPercentage && e.ProgressPercentage % 10 == 0)
{
progressPercentage = e.ProgressPercentage;
@@ -143,19 +151,29 @@ namespace v2rayN.Handler
{
try
{
if (e.Error == null
|| Utils.IsNullOrEmpty(e.Error.ToString()))
if (UpdateCompleted != null)
{
if (UpdateCompleted != null)
if (e.Cancelled)
{
((WebClientEx)sender).Dispose();
TimeSpan ts = (DateTime.Now - totalDatetime);
string speed = string.Format("<{0} M/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.##"));
UpdateCompleted(this, new ResultEventArgs(true, speed));
return;
}
if (e.Error == null
|| Utils.IsNullOrEmpty(e.Error.ToString()))
{
TimeSpan ts = (DateTime.Now - totalDatetime);
string speed = string.Format("{0} M/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.##"));
UpdateCompleted(this, new ResultEventArgs(true, speed));
}
}
else
{
throw e.Error;
else
{
throw e.Error;
}
}
}
catch (Exception ex)
@@ -176,8 +194,7 @@ namespace v2rayN.Handler
string source = string.Empty;
try
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //TLS 1.2
ServicePointManager.DefaultConnectionLimit = 256;
SetSecurityProtocol();
WebClientEx ws = new WebClientEx();
ws.DownloadStringCompleted += Ws_DownloadStringCompleted;
@@ -216,6 +233,13 @@ namespace v2rayN.Handler
}
}
private void SetSecurityProtocol()
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
| SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12;
ServicePointManager.DefaultConnectionLimit = 256;
}
}
}

View File

@@ -0,0 +1,155 @@
using Grpc.Core;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Windows.Forms;
using v2rayN.Base;
using v2rayN.Mode;
namespace v2rayN.Handler
{
class MainFormHandler
{
private static MainFormHandler instance;
//private DownloadHandle downloadHandle2;
//private Config _config;
//private V2rayHandler _v2rayHandler;
//private List<int> _selecteds;
//private Thread _workThread;
//Action<int, string> _updateFunc;
public static MainFormHandler Instance
{
get
{
if (instance == null)
{
instance = new MainFormHandler();
}
return instance;
}
}
public Icon GetNotifyIcon(Config config, Icon def)
{
try
{
var color = ColorTranslator.FromHtml("#3399CC");
var index = config.listenerType;
if (index > 0)
{
color = (new Color[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange })[index - 1];
//color = ColorTranslator.FromHtml(new string[] { "#CC0066", "#CC6600", "#99CC99", "#666699" }[index - 1]);
}
var width = 128;
var height = 128;
var bitmap = new Bitmap(width, height);
var graphics = Graphics.FromImage(bitmap);
var drawBrush = new SolidBrush(color);
graphics.FillEllipse(drawBrush, new Rectangle(0, 0, width, height));
var zoom = 16;
graphics.DrawImage(new Bitmap(Properties.Resources.notify, width - zoom, width - zoom), zoom / 2, zoom / 2);
Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());
drawBrush.Dispose();
graphics.Dispose();
bitmap.Dispose();
return createdIcon;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
return def;
}
}
public void Export2ClientConfig(int index, Config config)
{
//int index = GetLvSelectedIndex();
if (index < 0)
{
return;
}
if (config.vmess[index].configType != (int)EConfigType.Vmess)
{
UI.Show(UIRes.I18N("NonVmessService"));
return;
}
SaveFileDialog fileDialog = new SaveFileDialog();
fileDialog.Filter = "Config|*.json";
fileDialog.FilterIndex = 2;
fileDialog.RestoreDirectory = true;
if (fileDialog.ShowDialog() != DialogResult.OK)
{
return;
}
string fileName = fileDialog.FileName;
if (Utils.IsNullOrEmpty(fileName))
{
return;
}
Config configCopy = Utils.DeepCopy<Config>(config);
configCopy.index = index;
string msg;
if (V2rayConfigHandler.Export2ClientConfig(configCopy, fileName, out msg) != 0)
{
UI.Show(msg);
}
else
{
UI.Show(string.Format(UIRes.I18N("SaveClientConfigurationIn"), fileName));
}
}
public void Export2ServerConfig(int index, Config config)
{
//int index = GetLvSelectedIndex();
if (index < 0)
{
return;
}
if (config.vmess[index].configType != (int)EConfigType.Vmess)
{
UI.Show(UIRes.I18N("NonVmessService"));
return;
}
SaveFileDialog fileDialog = new SaveFileDialog();
fileDialog.Filter = "Config|*.json";
fileDialog.FilterIndex = 2;
fileDialog.RestoreDirectory = true;
if (fileDialog.ShowDialog() != DialogResult.OK)
{
return;
}
string fileName = fileDialog.FileName;
if (Utils.IsNullOrEmpty(fileName))
{
return;
}
Config configCopy = Utils.DeepCopy<Config>(config);
configCopy.index = index;
string msg;
if (V2rayConfigHandler.Export2ServerConfig(configCopy, fileName, out msg) != 0)
{
UI.Show(msg);
}
else
{
UI.Show(string.Format(UIRes.I18N("SaveServerConfigurationIn"), fileName));
}
}
}
}

View File

@@ -1,5 +1,4 @@
using Grpc.Core;
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
@@ -69,7 +68,7 @@ namespace v2rayN.Handler
}
}
public void RunPing()
private void RunPing()
{
try
{
@@ -100,7 +99,7 @@ namespace v2rayN.Handler
}
}
public void RunTcping()
private void RunTcping()
{
try
{
@@ -131,7 +130,7 @@ namespace v2rayN.Handler
}
}
public void RunRealPing()
private void RunRealPing()
{
try
{
@@ -245,7 +244,7 @@ namespace v2rayN.Handler
testCounter++;
var webProxy = new WebProxy(Global.Loopback, httpPort + index);
downloadHandle2.DownloadFileAsync(_config, url, webProxy);
downloadHandle2.DownloadFileAsync(_config, url, webProxy, 30);
return 0;
}
@@ -308,7 +307,5 @@ namespace v2rayN.Handler
return msg;
}
}
}

View File

@@ -15,58 +15,33 @@ namespace v2rayN.Handler
class StatisticsHandler
{
private Mode.Config config_;
private ServerStatistics serverStatistics_;
private Channel channel_;
private StatsService.StatsServiceClient client_;
private Thread workThread_;
private bool exitFlag_;
Action<ulong, ulong, ulong, ulong, List<Mode.ServerStatistics>> updateFunc_;
Action<ulong, ulong, List<ServerStatItem>> updateFunc_;
private bool enabled_;
public bool Enable
{
get
{
return enabled_;
}
set
{
enabled_ = value;
}
}
public bool UpdateUI;
public ulong TotalUp
{
get; private set;
}
public ulong TotalDown
{
get; private set;
}
public List<Mode.ServerStatistics> Statistic
{
get; set;
}
public ulong Up
public bool UpdateUI
{
get; private set;
get; set;
}
public ulong Down
public List<ServerStatItem> Statistic
{
get; private set;
get
{
return serverStatistics_.server;
}
}
private string logPath_;
private bool exitFlag_; // true to close workThread_
public StatisticsHandler(Mode.Config config, Action<ulong, ulong, ulong, ulong, List<Mode.ServerStatistics>> update)
public StatisticsHandler(Mode.Config config, Action<ulong, ulong, List<ServerStatItem>> update)
{
try
{
@@ -86,20 +61,11 @@ namespace v2rayN.Handler
}
config_ = config;
enabled_ = config.enableStatistics;
Enable = config.enableStatistics;
UpdateUI = false;
updateFunc_ = update;
logPath_ = Utils.GetPath(Global.StatisticLogDirectory);
Statistic = new List<Mode.ServerStatistics>();
exitFlag_ = false;
DeleteExpiredLog();
foreach (var server in config.vmess)
{
var statistic = new ServerStatistics(server.remarks, server.address, server.port, server.path, server.requestHost, 0, 0, 0, 0);
Statistic.Add(statistic);
}
LoadFromFile();
GrpcInit();
@@ -125,7 +91,6 @@ namespace v2rayN.Handler
{
try
{
exitFlag_ = true;
channel_.ShutdownAsync();
}
@@ -141,7 +106,7 @@ namespace v2rayN.Handler
{
try
{
if (enabled_ && channel_.State == ChannelState.Ready)
if (Enable && channel_.State == ChannelState.Ready)
{
QueryStatsResponse res = null;
try
@@ -155,32 +120,23 @@ namespace v2rayN.Handler
if (res != null)
{
var addr = config_.address();
var port = config_.port();
var path = config_.path();
var cur = Statistic.FindIndex(item => item.address == addr && item.port == port && item.path == path);
var itemId = config_.getItemId();
var serverStatItem = GetServerStatItem(itemId);
ulong up = 0,
down = 0;
//TODO: parse output
ParseOutput(res.Stat, out up, out down);
Up = up;
Down = down;
TotalUp += up;
TotalDown += down;
if (cur != -1)
{
Statistic[cur].todayUp += up;
Statistic[cur].todayDown += down;
Statistic[cur].totalUp += up;
Statistic[cur].totalDown += down;
}
serverStatItem.todayUp += up;
serverStatItem.todayDown += down;
serverStatItem.totalUp += up;
serverStatItem.totalDown += down;
if (UpdateUI)
updateFunc_(TotalUp, TotalDown, Up, Down, Statistic);
{
updateFunc_(up, down, new List<ServerStatItem> { serverStatItem });
}
}
}
Thread.Sleep(config_.statisticsFreshRate);
@@ -193,7 +149,82 @@ namespace v2rayN.Handler
}
}
public void ParseOutput(Google.Protobuf.Collections.RepeatedField<Stat> source, out ulong up, out ulong down)
public void LoadFromFile()
{
try
{
string result = Utils.LoadResource(Utils.GetPath(Global.StatisticLogOverall));
if (!Utils.IsNullOrEmpty(result))
{
//转成Json
serverStatistics_ = Utils.FromJson<ServerStatistics>(result);
}
if (serverStatistics_ == null)
{
serverStatistics_ = new ServerStatistics();
}
if (serverStatistics_.server == null)
{
serverStatistics_.server = new List<ServerStatItem>();
}
var ticks = DateTime.Now.Date.Ticks;
foreach (var item in serverStatistics_.server)
{
if (item.dateNow != ticks)
{
item.todayUp = 0;
item.todayDown = 0;
item.dateNow = ticks;
}
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
public void SaveToFile()
{
try
{
Utils.ToJsonFile(serverStatistics_, Utils.GetPath(Global.StatisticLogOverall));
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
private ServerStatItem GetServerStatItem(string itemId)
{
var ticks = DateTime.Now.Date.Ticks;
var cur = Statistic.FindIndex(item => item.itemId == itemId);
if (cur < 0)
{
Statistic.Add(new ServerStatItem
{
itemId = itemId,
totalUp = 0,
totalDown = 0,
todayUp = 0,
todayDown = 0,
dateNow = ticks
});
cur = Statistic.Count - 1;
}
if (Statistic[cur].dateNow != ticks)
{
Statistic[cur].todayUp = 0;
Statistic[cur].todayDown = 0;
Statistic[cur].dateNow = ticks;
}
return Statistic[cur];
}
private void ParseOutput(Google.Protobuf.Collections.RepeatedField<Stat> source, out ulong up, out ulong down)
{
up = 0; down = 0;
@@ -231,218 +262,6 @@ namespace v2rayN.Handler
}
}
public void SaveToFile()
{
if (!Directory.Exists(logPath_))
{
Directory.CreateDirectory(logPath_);
}
// 总流量统计文件
var overallPath = Path.Combine(logPath_, Global.StatisticLogOverall);
if (!File.Exists(overallPath))
{
File.Create(overallPath);
}
try
{
using (var overallWriter = new StreamWriter(overallPath))
{
double up_amount, down_amount;
string up_unit, down_unit;
Utils.ToHumanReadable(TotalUp, out up_amount, out up_unit);
Utils.ToHumanReadable(TotalDown, out down_amount, out down_unit);
overallWriter.WriteLine($"LastUpdate {DateTime.Now.ToString("yyyy-MM-dd")} {DateTime.Now.ToLongTimeString()}");
overallWriter.WriteLine($"UP {string.Format("{0:f2}", up_amount)}{up_unit} {TotalUp}");
overallWriter.WriteLine($"DOWN {string.Format("{0:f2}", down_amount)}{down_unit} {TotalDown}");
foreach (var s in Statistic)
{
overallWriter.WriteLine($"* {s.name} {s.address} {s.port} {s.path} {s.host} {s.totalUp} {s.totalDown}");
}
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
// 当天流量记录文件
var dailyPath = Path.Combine(logPath_, $"{DateTime.Now.ToString("yyyy-MM-dd")}.txt");
if (!File.Exists(dailyPath))
{
File.Create(dailyPath);
}
try
{
using (var dailyWriter = new StreamWriter(dailyPath))
{
dailyWriter.WriteLine($"LastUpdate {DateTime.Now.ToString("yyyy-MM-dd")} {DateTime.Now.ToLongTimeString()}");
foreach (var s in Statistic)
{
dailyWriter.WriteLine($"* {s.name} {s.address} {s.port} {s.path} {s.host} {s.todayUp} {s.todayDown}");
}
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
public void LoadFromFile()
{
if (!Directory.Exists(logPath_)) return;
// 总流量统计文件
///
/// 文件结构
/// LastUpdate [date] [time]
/// UP [readable string] [amount]
/// DOWN [readable string] [amount]
/// 每行每个数据空格分隔
try
{
Utils.SaveLog(logPath_ + Global.StatisticLogOverall);
var overallPath = Path.Combine(logPath_, Global.StatisticLogOverall);
if (File.Exists(overallPath))
{
using (var overallReader = new StreamReader(overallPath))
{
while (!overallReader.EndOfStream)
{
var line = overallReader.ReadLine();
if (line.StartsWith("LastUpdate"))
{
}
else if (line.StartsWith("UP"))
{
var datas = line.Split(' ');
if (datas.Length < 3) return;
TotalUp = ulong.Parse(datas[2]);
}
else if (line.StartsWith("DOWN"))
{
var datas = line.Split(' ');
if (datas.Length < 3) return;
TotalDown = ulong.Parse(datas[2]);
}
else if (line.StartsWith("*"))
{
var datas = line.Split(' ');
if (datas.Length < 8) return;
var name = datas[1];
var address = datas[2];
var port = int.Parse(datas[3]);
var path = datas[4];
var host = datas[5];
var totalUp = ulong.Parse(datas[6]);
var totalDown = ulong.Parse(datas[7]);
var temp = new ServerStatistics(name, address, port, path, host, 0, 0, 0, 0);
var index = Statistic.FindIndex(item => Utils.IsIdenticalServer(item, temp));
if (index != -1)
{
Statistic[index].totalUp = totalUp;
Statistic[index].totalDown = totalDown;
}
else
{
var s = new Mode.ServerStatistics(name, address, port, path, host, totalUp, totalDown, 0, 0);
Statistic.Add(s);
}
}
}
}
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
try
{
Utils.SaveLog(logPath_ + $"{DateTime.Now.ToString("yyyy-MM-dd")}.txt");
var dailyPath = Path.Combine(logPath_, $"{DateTime.Now.ToString("yyyy-MM-dd")}.txt");
if (File.Exists(dailyPath))
{
using (var dailyReader = new StreamReader(dailyPath))
{
while (!dailyReader.EndOfStream)
{
var line = dailyReader.ReadLine();
if (line.StartsWith("LastUpdate"))
{
}
else if (line.StartsWith("*"))
{
var datas = line.Split(' ');
if (datas.Length < 8) return;
var name = datas[1];
var address = datas[2];
var port = int.Parse(datas[3]);
var path = datas[4];
var host = datas[5];
var todayUp = ulong.Parse(datas[6]);
var todayDown = ulong.Parse(datas[7]);
var temp = new ServerStatistics(name, address, port, path, host, 0, 0, 0, 0);
var index = Statistic.FindIndex(item => Utils.IsIdenticalServer(item, temp));
if (index != -1)
{
Statistic[index].todayUp = todayUp;
Statistic[index].todayDown = todayDown;
}
else
{
var s = new Mode.ServerStatistics(name, address, port, path, host, 0, 0, todayUp, todayDown);
Statistic.Add(s);
}
}
}
}
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
private void DeleteExpiredLog()
{
try
{
if (!Directory.Exists(logPath_)) return;
var dirInfo = new DirectoryInfo(logPath_);
var files = dirInfo.GetFiles();
foreach (var file in files)
{
if (file.Name == "overall.txt") continue;
var name = file.Name.Split('.')[0];
var ft = DateTime.Parse(name);
var ct = DateTime.Now;
var dur = ct - ft;
if (dur.Days > config_.CacheDays)
{
file.Delete();
}
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
private int GetFreePort()
{
int defaultPort = 28123;

View File

@@ -10,7 +10,7 @@ namespace v2rayN.HttpProxyHandler
/// </summary>
class HttpProxyHandle
{
public static bool Update(Config config, bool forceDisable)
private static bool Update(Config config, bool forceDisable)
{
int type = config.listenerType;
@@ -70,7 +70,7 @@ namespace v2rayN.HttpProxyHandler
/// 启用系统代理(http)
/// </summary>
/// <param name="config"></param>
public static void StartHttpAgent(Config config)
private static void StartHttpAgent(Config config)
{
try
{
@@ -100,11 +100,13 @@ namespace v2rayN.HttpProxyHandler
{
try
{
Update(config, true);
PrivoxyHandler.Instance.Stop();
Global.sysAgent = false;
Global.socksPort = 0;
Global.httpPort = 0;
Global.httpPort = 0;
}
catch
{
@@ -116,7 +118,7 @@ namespace v2rayN.HttpProxyHandler
/// </summary>
/// <param name="config"></param>
/// <param name="forced"></param>
public static bool RestartHttpAgent(Config config, bool forced)
public static void RestartHttpAgent(Config config, bool forced)
{
bool isRestart = false;
//强制重启或者socks端口变化
@@ -136,9 +138,8 @@ namespace v2rayN.HttpProxyHandler
{
CloseHttpAgent(config);
StartHttpAgent(config);
return true;
}
return false;
Update(config, false);
}
public static string GetPacUrl()

View File

@@ -68,31 +68,33 @@ namespace v2rayN.HttpProxyHandler
public void Start(int localPort, Config config)
{
if (_process == null)
try
{
Process[] existingPrivoxy = Process.GetProcessesByName("v2ray_privoxy");
foreach (Process p in existingPrivoxy.Where(IsChildProcess))
if (_process == null)
{
KillProcess(p);
}
string privoxyConfig = Resources.privoxy_conf;
RunningPort = config.GetLocalPort(Global.InboundHttp);
privoxyConfig = privoxyConfig.Replace("__SOCKS_PORT__", localPort.ToString());
privoxyConfig = privoxyConfig.Replace("__PRIVOXY_BIND_PORT__", RunningPort.ToString());
if (config.allowLANConn)
{
privoxyConfig = privoxyConfig.Replace("__PRIVOXY_BIND_IP__", "0.0.0.0");
}
else
{
privoxyConfig = privoxyConfig.Replace("__PRIVOXY_BIND_IP__", Global.Loopback);
}
FileManager.ByteArrayToFile(Utils.GetTempPath(_uniqueConfigFile), Encoding.UTF8.GetBytes(privoxyConfig));
Process[] existingPrivoxy = Process.GetProcessesByName("v2ray_privoxy");
foreach (Process p in existingPrivoxy.Where(IsChildProcess))
{
KillProcess(p);
}
string privoxyConfig = Resources.privoxy_conf;
RunningPort = config.GetLocalPort(Global.InboundHttp);
privoxyConfig = privoxyConfig.Replace("__SOCKS_PORT__", localPort.ToString());
privoxyConfig = privoxyConfig.Replace("__PRIVOXY_BIND_PORT__", RunningPort.ToString());
if (config.allowLANConn)
{
privoxyConfig = privoxyConfig.Replace("__PRIVOXY_BIND_IP__", "0.0.0.0");
}
else
{
privoxyConfig = privoxyConfig.Replace("__PRIVOXY_BIND_IP__", Global.Loopback);
}
FileManager.ByteArrayToFile(Utils.GetTempPath(_uniqueConfigFile), Encoding.UTF8.GetBytes(privoxyConfig));
_process = new Process
{
// Configure the process using the StartInfo properties.
StartInfo =
_process = new Process
{
// Configure the process using the StartInfo properties.
StartInfo =
{
FileName = "v2ray_privoxy.exe",
Arguments = _uniqueConfigFile,
@@ -101,15 +103,20 @@ namespace v2rayN.HttpProxyHandler
UseShellExecute = true,
CreateNoWindow = true
}
};
_process.Start();
};
_process.Start();
/*
* Add this process to job obj associated with this ss process, so that
* when ss exit unexpectedly, this process will be forced killed by system.
*/
_privoxyJob.AddProcess(_process.Handle);
/*
* Add this process to job obj associated with this ss process, so that
* when ss exit unexpectedly, this process will be forced killed by system.
*/
_privoxyJob.AddProcess(_process.Handle);
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}

View File

@@ -106,17 +106,8 @@ namespace v2rayN.Mode
get; set;
}
/// <summary>
/// 启用Http代理
/// </summary>
public bool sysAgentEnabled
{
get; set;
}
/// <summary>
/// 监听状态 0-不改变 1-全局 2-PAC
/// 监听状态 0-not 1-http 2-PAC
/// </summary>
public int listenerType
{
@@ -154,26 +145,7 @@ namespace v2rayN.Mode
{
get; set;
}
/// <summary>
/// 统计数据缓存天数 [0, 30]
/// * 0 关闭单独每天使用流量的缓存
/// * 无论如何不会关闭总流量的缓存
/// </summary>
private uint cacheDays;
public uint CacheDays
{
get
{
return cacheDays;
}
set
{
if (value < 0) cacheDays = 0;
else if (value > 30) cacheDays = 30;
else cacheDays = value;
}
}
/// <summary>
/// 自定义远程DNS
@@ -346,6 +318,16 @@ namespace v2rayN.Mode
return vmess[index].getSummary();
}
public string getItemId()
{
if (index < 0)
{
return string.Empty;
}
return vmess[index].getItemId();
}
#endregion
}
@@ -429,6 +411,14 @@ namespace v2rayN.Mode
}
return subid.Substring(0, 4);
}
public string getItemId()
{
var itemId = $"{address}{port}{requestHost}{path}";
itemId = Utils.Base64Encode(itemId);
return itemId;
}
/// <summary>
/// 版本(现在=2)
/// </summary>

View File

@@ -1,35 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace v2rayN.Mode
{
class ServerStatistics
[Serializable]
public class ServerStatistics
{
public string name;
public string address;
public int port;
public string path;
public string host;
public ulong totalUp;
public ulong totalDown;
public ulong todayUp;
public ulong todayDown;
public ServerStatistics() { }
public ServerStatistics(string name, string addr, int port, string path, string host, ulong totalUp, ulong totalDown, ulong todayUp, ulong todayDown)
public List<ServerStatItem> server
{
this.name = name;
this.address = addr;
this.port = port;
this.path = path;
this.host = host;
this.totalUp = totalUp;
this.totalDown = totalDown;
this.todayUp = todayUp;
this.todayDown = todayDown;
get; set;
}
}
[Serializable]
public class ServerStatItem
{
public string itemId
{
get; set;
}
public ulong totalUp
{
get; set;
}
public ulong totalDown
{
get; set;
}
public ulong todayUp
{
get; set;
}
public ulong todayDown
{
get; set;
}
public long dateNow
{
get; set;
}
}
}

View File

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

View File

@@ -443,15 +443,6 @@ namespace v2rayN
return Regex.IsMatch(input, pattern, RegexOptions.IgnoreCase);
}
public static bool IsIdenticalServer(Mode.ServerStatistics a, Mode.ServerStatistics b)
{
return (a.address == b.address
&& a.port == b.port
&& a.path == b.path
&& a.host == b.host
);
}
#endregion
#region

View File

@@ -150,12 +150,6 @@
<Compile Include="Forms\MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\RoutingRuleSettingForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\RoutingRuleSettingForm.Designer.cs">
<DependentUpon>RoutingRuleSettingForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\SubSettingForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -186,6 +180,7 @@
<Compile Include="Forms\SubSettingControl.Designer.cs">
<DependentUpon>SubSettingControl.cs</DependentUpon>
</Compile>
<Compile Include="Handler\MainFormHandler.cs" />
<Compile Include="Handler\SpeedtestHandler.cs" />
<Compile Include="Handler\StatisticsHandler.cs" />
<Compile Include="Handler\DownloadHandle.cs" />
@@ -292,9 +287,6 @@
<DependentUpon>QRCodeControl.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\RoutingRuleSettingForm.resx">
<DependentUpon>RoutingRuleSettingForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SubSettingControl.resx">
<DependentUpon>SubSettingControl.cs</DependentUpon>
</EmbeddedResource>