mirror of https://github.com/2dust/v2rayN
IDE0008-显式类型
parent
56c3c22568
commit
67b99c4c8b
|
@ -57,7 +57,7 @@ namespace v2rayN.Base
|
||||||
{
|
{
|
||||||
ThreadPool.QueueUserWorkItem((c) =>
|
ThreadPool.QueueUserWorkItem((c) =>
|
||||||
{
|
{
|
||||||
var ctx = c as HttpListenerContext;
|
HttpListenerContext ctx = c as HttpListenerContext;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string address = ctx.Request.LocalEndPoint.Address.ToString();
|
string address = ctx.Request.LocalEndPoint.Address.ToString();
|
||||||
|
|
|
@ -60,19 +60,19 @@ namespace v2rayN.Base
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var socket = obj as TcpClient;
|
TcpClient socket = obj as TcpClient;
|
||||||
|
|
||||||
var inputStream = new BufferedStream(socket.GetStream());
|
BufferedStream inputStream = new BufferedStream(socket.GetStream());
|
||||||
var outputStream = new StreamWriter(new BufferedStream(socket.GetStream()));
|
StreamWriter outputStream = new StreamWriter(new BufferedStream(socket.GetStream()));
|
||||||
if (inputStream.CanRead)
|
if (inputStream.CanRead)
|
||||||
{
|
{
|
||||||
var data = ReadStream(inputStream);
|
string data = ReadStream(inputStream);
|
||||||
|
|
||||||
if (data.Contains("/pac/"))
|
if (data.Contains("/pac/"))
|
||||||
{
|
{
|
||||||
if (_responderMethod != null)
|
if (_responderMethod != null)
|
||||||
{
|
{
|
||||||
var address = ((IPEndPoint)socket.Client.LocalEndPoint).Address.ToString();
|
string address = ((IPEndPoint)socket.Client.LocalEndPoint).Address.ToString();
|
||||||
Utils.SaveLog("WebserverB Request " + address);
|
Utils.SaveLog("WebserverB Request " + address);
|
||||||
string pac = _responderMethod(address);
|
string pac = _responderMethod(address);
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ namespace v2rayN.Base
|
||||||
|
|
||||||
private void WriteStream(StreamWriter outputStream, string pac)
|
private void WriteStream(StreamWriter outputStream, string pac)
|
||||||
{
|
{
|
||||||
var content_type = "application/x-ns-proxy-autoconfig";
|
string content_type = "application/x-ns-proxy-autoconfig";
|
||||||
outputStream.WriteLine("HTTP/1.1 200 OK");
|
outputStream.WriteLine("HTTP/1.1 200 OK");
|
||||||
outputStream.WriteLine(String.Format("Content-Type:{0}", content_type));
|
outputStream.WriteLine(String.Format("Content-Type:{0}", content_type));
|
||||||
outputStream.WriteLine("Connection: close");
|
outputStream.WriteLine("Connection: close");
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace v2rayN.Base
|
||||||
|
|
||||||
public static bool IsWhiteSpace(this string value)
|
public static bool IsWhiteSpace(this string value)
|
||||||
{
|
{
|
||||||
foreach (var c in value)
|
foreach (char c in value)
|
||||||
{
|
{
|
||||||
if (char.IsWhiteSpace(c)) continue;
|
if (char.IsWhiteSpace(c)) continue;
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@ namespace v2rayN.Forms
|
||||||
ListViewItem lvItem = null;
|
ListViewItem lvItem = null;
|
||||||
if (statistics != null && statistics.Enable)
|
if (statistics != null && statistics.Enable)
|
||||||
{
|
{
|
||||||
var sItem = statistics.Statistic.Find(item_ => item_.itemId == item.getItemId());
|
ServerStatItem sItem = statistics.Statistic.Find(item_ => item_.itemId == item.getItemId());
|
||||||
if (sItem != null)
|
if (sItem != null)
|
||||||
{
|
{
|
||||||
totalUp = Utils.HumanFy(sItem.totalUp);
|
totalUp = Utils.HumanFy(sItem.totalUp);
|
||||||
|
@ -424,7 +424,7 @@ namespace v2rayN.Forms
|
||||||
|
|
||||||
if (config.vmess[index].configType == (int)EConfigType.Vmess)
|
if (config.vmess[index].configType == (int)EConfigType.Vmess)
|
||||||
{
|
{
|
||||||
var fm = new AddServerForm
|
AddServerForm fm = new AddServerForm
|
||||||
{
|
{
|
||||||
EditIndex = index
|
EditIndex = index
|
||||||
};
|
};
|
||||||
|
@ -437,7 +437,7 @@ namespace v2rayN.Forms
|
||||||
}
|
}
|
||||||
else if (config.vmess[index].configType == (int)EConfigType.Shadowsocks)
|
else if (config.vmess[index].configType == (int)EConfigType.Shadowsocks)
|
||||||
{
|
{
|
||||||
var fm = new AddServer3Form
|
AddServer3Form fm = new AddServer3Form
|
||||||
{
|
{
|
||||||
EditIndex = index
|
EditIndex = index
|
||||||
};
|
};
|
||||||
|
@ -449,7 +449,7 @@ namespace v2rayN.Forms
|
||||||
}
|
}
|
||||||
else if (config.vmess[index].configType == (int)EConfigType.Socks)
|
else if (config.vmess[index].configType == (int)EConfigType.Socks)
|
||||||
{
|
{
|
||||||
var fm = new AddServer4Form
|
AddServer4Form fm = new AddServer4Form
|
||||||
{
|
{
|
||||||
EditIndex = index
|
EditIndex = index
|
||||||
};
|
};
|
||||||
|
@ -461,7 +461,7 @@ namespace v2rayN.Forms
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var fm2 = new AddServer2Form
|
AddServer2Form fm2 = new AddServer2Form
|
||||||
{
|
{
|
||||||
EditIndex = index
|
EditIndex = index
|
||||||
};
|
};
|
||||||
|
@ -646,7 +646,7 @@ namespace v2rayN.Forms
|
||||||
{
|
{
|
||||||
GetLvSelectedIndex();
|
GetLvSelectedIndex();
|
||||||
ClearTestResult();
|
ClearTestResult();
|
||||||
var statistics = new SpeedtestHandler(ref config, ref v2rayHandler, lvSelecteds, actionType, UpdateSpeedtestHandler);
|
SpeedtestHandler statistics = new SpeedtestHandler(ref config, ref v2rayHandler, lvSelecteds, actionType, UpdateSpeedtestHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void menuExport2ClientConfig_Click(object sender, EventArgs e)
|
private void menuExport2ClientConfig_Click(object sender, EventArgs e)
|
||||||
|
@ -814,7 +814,7 @@ namespace v2rayN.Forms
|
||||||
|
|
||||||
private void menuAddShadowsocksServer_Click(object sender, EventArgs e)
|
private void menuAddShadowsocksServer_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var fm = new AddServer3Form
|
AddServer3Form fm = new AddServer3Form
|
||||||
{
|
{
|
||||||
EditIndex = -1
|
EditIndex = -1
|
||||||
};
|
};
|
||||||
|
@ -829,7 +829,7 @@ namespace v2rayN.Forms
|
||||||
|
|
||||||
private void menuAddSocksServer_Click(object sender, EventArgs e)
|
private void menuAddSocksServer_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var fm = new AddServer4Form
|
AddServer4Form fm = new AddServer4Form
|
||||||
{
|
{
|
||||||
EditIndex = -1
|
EditIndex = -1
|
||||||
};
|
};
|
||||||
|
@ -1038,14 +1038,14 @@ namespace v2rayN.Forms
|
||||||
List<string[]> datas = new List<string[]>();
|
List<string[]> datas = new List<string[]>();
|
||||||
for (int i = 0; i < config.vmess.Count; i++)
|
for (int i = 0; i < config.vmess.Count; i++)
|
||||||
{
|
{
|
||||||
var index = statistics.FindIndex(item_ => item_.itemId == config.vmess[i].getItemId());
|
int index = statistics.FindIndex(item_ => item_.itemId == config.vmess[i].getItemId());
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
lvServers.Invoke((MethodInvoker)delegate
|
lvServers.Invoke((MethodInvoker)delegate
|
||||||
{
|
{
|
||||||
lvServers.SuspendLayout();
|
lvServers.SuspendLayout();
|
||||||
|
|
||||||
var indexStart = 9;
|
int indexStart = 9;
|
||||||
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayDown);
|
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayDown);
|
||||||
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayUp);
|
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayUp);
|
||||||
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].totalDown);
|
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].totalDown);
|
||||||
|
@ -1165,7 +1165,7 @@ namespace v2rayN.Forms
|
||||||
|
|
||||||
for (int k = 0; k < menuSysAgentMode.DropDownItems.Count; k++)
|
for (int k = 0; k < menuSysAgentMode.DropDownItems.Count; k++)
|
||||||
{
|
{
|
||||||
var item = ((ToolStripMenuItem)menuSysAgentMode.DropDownItems[k]);
|
ToolStripMenuItem item = ((ToolStripMenuItem)menuSysAgentMode.DropDownItems[k]);
|
||||||
item.Checked = (type == k);
|
item.Checked = (type == k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,8 +1218,8 @@ namespace v2rayN.Forms
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fileName = Utils.GetPath(downloadHandle.DownloadFileName);
|
string fileName = Utils.GetPath(downloadHandle.DownloadFileName);
|
||||||
var process = Process.Start("v2rayUpgrade.exe", fileName);
|
Process process = Process.Start("v2rayUpgrade.exe", fileName);
|
||||||
if (process.Id > 0)
|
if (process.Id > 0)
|
||||||
{
|
{
|
||||||
menuExit_Click(null, null);
|
menuExit_Click(null, null);
|
||||||
|
@ -1328,7 +1328,7 @@ namespace v2rayN.Forms
|
||||||
{
|
{
|
||||||
if (args.Success)
|
if (args.Success)
|
||||||
{
|
{
|
||||||
var result = args.Msg;
|
string result = args.Msg;
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (Utils.IsNullOrEmpty(result))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -1449,7 +1449,7 @@ namespace v2rayN.Forms
|
||||||
if (args.Success)
|
if (args.Success)
|
||||||
{
|
{
|
||||||
AppendText(false, $"{hashCode}{UIRes.I18N("MsgGetSubscriptionSuccessfully")}");
|
AppendText(false, $"{hashCode}{UIRes.I18N("MsgGetSubscriptionSuccessfully")}");
|
||||||
var result = Utils.Base64Decode(args.Msg);
|
string result = Utils.Base64Decode(args.Msg);
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (Utils.IsNullOrEmpty(result))
|
||||||
{
|
{
|
||||||
AppendText(false, $"{hashCode}{UIRes.I18N("MsgSubscriptionDecodingFailed")}");
|
AppendText(false, $"{hashCode}{UIRes.I18N("MsgSubscriptionDecodingFailed")}");
|
||||||
|
|
|
@ -118,7 +118,7 @@ namespace v2rayN.Forms
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var cbSource = new ComboItem[]
|
ComboItem[] cbSource = new ComboItem[]
|
||||||
{
|
{
|
||||||
new ComboItem{ID = (int)Global.StatisticsFreshRate.quick, Text = UIRes.I18N("QuickFresh")},
|
new ComboItem{ID = (int)Global.StatisticsFreshRate.quick, Text = UIRes.I18N("QuickFresh")},
|
||||||
new ComboItem{ID = (int)Global.StatisticsFreshRate.medium, Text = UIRes.I18N("MediumFresh")},
|
new ComboItem{ID = (int)Global.StatisticsFreshRate.medium, Text = UIRes.I18N("MediumFresh")},
|
||||||
|
@ -340,7 +340,7 @@ namespace v2rayN.Forms
|
||||||
|
|
||||||
config.allowLANConn = chkAllowLANConn.Checked;
|
config.allowLANConn = chkAllowLANConn.Checked;
|
||||||
|
|
||||||
var lastEnableStatistics = config.enableStatistics;
|
bool lastEnableStatistics = config.enableStatistics;
|
||||||
config.enableStatistics = chkEnableStatistics.Checked;
|
config.enableStatistics = chkEnableStatistics.Checked;
|
||||||
config.statisticsFreshRate = (int)cbFreshrate.SelectedValue;
|
config.statisticsFreshRate = (int)cbFreshrate.SelectedValue;
|
||||||
config.keepOlderDedupl = chkKeepOlderDedupl.Checked;
|
config.keepOlderDedupl = chkKeepOlderDedupl.Checked;
|
||||||
|
@ -390,25 +390,25 @@ namespace v2rayN.Forms
|
||||||
txtUserblock.Text = Utils.GetEmbedText(Global.CustomRoutingFileName + Global.blockTag);
|
txtUserblock.Text = Utils.GetEmbedText(Global.CustomRoutingFileName + Global.blockTag);
|
||||||
cmbroutingMode.SelectedIndex = 3;
|
cmbroutingMode.SelectedIndex = 3;
|
||||||
|
|
||||||
var lstUrl = new List<string>();
|
List<string> lstUrl = new List<string>();
|
||||||
lstUrl.Add(Global.CustomRoutingListUrl + Global.agentTag);
|
lstUrl.Add(Global.CustomRoutingListUrl + Global.agentTag);
|
||||||
lstUrl.Add(Global.CustomRoutingListUrl + Global.directTag);
|
lstUrl.Add(Global.CustomRoutingListUrl + Global.directTag);
|
||||||
lstUrl.Add(Global.CustomRoutingListUrl + Global.blockTag);
|
lstUrl.Add(Global.CustomRoutingListUrl + Global.blockTag);
|
||||||
|
|
||||||
var lstTxt = new List<TextBox>();
|
List<TextBox> lstTxt = new List<TextBox>();
|
||||||
lstTxt.Add(txtUseragent);
|
lstTxt.Add(txtUseragent);
|
||||||
lstTxt.Add(txtUserdirect);
|
lstTxt.Add(txtUserdirect);
|
||||||
lstTxt.Add(txtUserblock);
|
lstTxt.Add(txtUserblock);
|
||||||
|
|
||||||
for (int k = 0; k < lstUrl.Count; k++)
|
for (int k = 0; k < lstUrl.Count; k++)
|
||||||
{
|
{
|
||||||
var txt = lstTxt[k];
|
TextBox txt = lstTxt[k];
|
||||||
DownloadHandle downloadHandle = new DownloadHandle();
|
DownloadHandle downloadHandle = new DownloadHandle();
|
||||||
downloadHandle.UpdateCompleted += (sender2, args) =>
|
downloadHandle.UpdateCompleted += (sender2, args) =>
|
||||||
{
|
{
|
||||||
if (args.Success)
|
if (args.Success)
|
||||||
{
|
{
|
||||||
var result = args.Msg;
|
string result = args.Msg;
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (Utils.IsNullOrEmpty(result))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace v2rayN.Forms
|
||||||
|
|
||||||
for (int k = config.subItem.Count - 1; k >= 0; k--)
|
for (int k = config.subItem.Count - 1; k >= 0; k--)
|
||||||
{
|
{
|
||||||
var item = config.subItem[k];
|
SubItem item = config.subItem[k];
|
||||||
if (Utils.IsNullOrEmpty(item.remarks)
|
if (Utils.IsNullOrEmpty(item.remarks)
|
||||||
&& Utils.IsNullOrEmpty(item.url))
|
&& Utils.IsNullOrEmpty(item.url))
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ namespace v2rayN.Forms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var item in config.subItem)
|
foreach (SubItem item in config.subItem)
|
||||||
{
|
{
|
||||||
SubSettingControl control = new SubSettingControl();
|
SubSettingControl control = new SubSettingControl();
|
||||||
control.OnButtonClicked += Control_OnButtonClicked;
|
control.OnButtonClicked += Control_OnButtonClicked;
|
||||||
|
@ -98,7 +98,7 @@ namespace v2rayN.Forms
|
||||||
|
|
||||||
private void AddSub()
|
private void AddSub()
|
||||||
{
|
{
|
||||||
var subItem = new SubItem
|
SubItem subItem = new SubItem
|
||||||
{
|
{
|
||||||
id = string.Empty,
|
id = string.Empty,
|
||||||
remarks = "remarks",
|
remarks = "remarks",
|
||||||
|
|
|
@ -375,7 +375,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else if (vmessItem.configType == (int)EConfigType.Shadowsocks)
|
else if (vmessItem.configType == (int)EConfigType.Shadowsocks)
|
||||||
{
|
{
|
||||||
var remark = string.Empty;
|
string remark = string.Empty;
|
||||||
if (!Utils.IsNullOrEmpty(vmessItem.remarks))
|
if (!Utils.IsNullOrEmpty(vmessItem.remarks))
|
||||||
{
|
{
|
||||||
remark = "#" + WebUtility.UrlEncode(vmessItem.remarks);
|
remark = "#" + WebUtility.UrlEncode(vmessItem.remarks);
|
||||||
|
@ -390,7 +390,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else if (vmessItem.configType == (int)EConfigType.Socks)
|
else if (vmessItem.configType == (int)EConfigType.Socks)
|
||||||
{
|
{
|
||||||
var remark = string.Empty;
|
string remark = string.Empty;
|
||||||
if (!Utils.IsNullOrEmpty(vmessItem.remarks))
|
if (!Utils.IsNullOrEmpty(vmessItem.remarks))
|
||||||
{
|
{
|
||||||
remark = "#" + WebUtility.UrlEncode(vmessItem.remarks);
|
remark = "#" + WebUtility.UrlEncode(vmessItem.remarks);
|
||||||
|
@ -803,7 +803,7 @@ namespace v2rayN.Handler
|
||||||
public static int AddSubItem(ref Config config, string url)
|
public static int AddSubItem(ref Config config, string url)
|
||||||
{
|
{
|
||||||
//already exists
|
//already exists
|
||||||
foreach (var sub in config.subItem)
|
foreach (SubItem sub in config.subItem)
|
||||||
{
|
{
|
||||||
if (url == sub.url)
|
if (url == sub.url)
|
||||||
{
|
{
|
||||||
|
@ -811,7 +811,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var subItem = new SubItem
|
SubItem subItem = new SubItem
|
||||||
{
|
{
|
||||||
id = string.Empty,
|
id = string.Empty,
|
||||||
remarks = "import sub",
|
remarks = "import sub",
|
||||||
|
|
|
@ -339,9 +339,9 @@ namespace v2rayN.Handler
|
||||||
byte[] bytes = Convert.FromBase64String(response);
|
byte[] bytes = Convert.FromBase64String(response);
|
||||||
string content = Encoding.UTF8.GetString(bytes);
|
string content = Encoding.UTF8.GetString(bytes);
|
||||||
List<string> valid_lines = new List<string>();
|
List<string> valid_lines = new List<string>();
|
||||||
using (var sr = new StringReader(content))
|
using (StringReader sr = new StringReader(content))
|
||||||
{
|
{
|
||||||
foreach (var line in sr.NonWhiteSpaceLines())
|
foreach (string line in sr.NonWhiteSpaceLines())
|
||||||
{
|
{
|
||||||
if (line.BeginWithAny(IgnoredLineBegins))
|
if (line.BeginWithAny(IgnoredLineBegins))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -38,23 +38,23 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var color = ColorTranslator.FromHtml("#3399CC");
|
Color color = ColorTranslator.FromHtml("#3399CC");
|
||||||
var index = config.listenerType;
|
int index = config.listenerType;
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
{
|
{
|
||||||
color = (new Color[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange, Color.DarkSlateBlue, Color.RoyalBlue })[index - 1];
|
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]);
|
//color = ColorTranslator.FromHtml(new string[] { "#CC0066", "#CC6600", "#99CC99", "#666699" }[index - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var width = 128;
|
int width = 128;
|
||||||
var height = 128;
|
int height = 128;
|
||||||
|
|
||||||
var bitmap = new Bitmap(width, height);
|
Bitmap bitmap = new Bitmap(width, height);
|
||||||
var graphics = Graphics.FromImage(bitmap);
|
Graphics graphics = Graphics.FromImage(bitmap);
|
||||||
var drawBrush = new SolidBrush(color);
|
SolidBrush drawBrush = new SolidBrush(color);
|
||||||
|
|
||||||
graphics.FillEllipse(drawBrush, new Rectangle(0, 0, width, height));
|
graphics.FillEllipse(drawBrush, new Rectangle(0, 0, width, height));
|
||||||
var zoom = 16;
|
int zoom = 16;
|
||||||
graphics.DrawImage(new Bitmap(Properties.Resources.notify, width - zoom, width - zoom), zoom / 2, zoom / 2);
|
graphics.DrawImage(new Bitmap(Properties.Resources.notify, width - zoom, width - zoom), zoom / 2, zoom / 2);
|
||||||
|
|
||||||
Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());
|
Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace v2rayN.Handler
|
||||||
_v2rayHandler.LoadV2ray(_config, _selecteds);
|
_v2rayHandler.LoadV2ray(_config, _selecteds);
|
||||||
|
|
||||||
Thread.Sleep(5000);
|
Thread.Sleep(5000);
|
||||||
var httpPort = _config.GetLocalPort("speedtest");
|
int httpPort = _config.GetLocalPort("speedtest");
|
||||||
Task[] tasks = new Task[_selecteds.Count];
|
Task[] tasks = new Task[_selecteds.Count];
|
||||||
int i = -1;
|
int i = -1;
|
||||||
foreach (int itemIndex in _selecteds)
|
foreach (int itemIndex in _selecteds)
|
||||||
|
@ -124,7 +124,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + itemIndex);
|
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + itemIndex);
|
||||||
int responseTime = -1;
|
int responseTime = -1;
|
||||||
var status = GetRealPingTime(Global.SpeedPingTestUrl, webProxy, out responseTime);
|
string status = GetRealPingTime(Global.SpeedPingTestUrl, webProxy, out responseTime);
|
||||||
string output = Utils.IsNullOrEmpty(status) ? string.Format("{0}ms", responseTime) : string.Format("{0}", status);
|
string output = Utils.IsNullOrEmpty(status) ? string.Format("{0}ms", responseTime) : string.Format("{0}", status);
|
||||||
_updateFunc(itemIndex, output);
|
_updateFunc(itemIndex, output);
|
||||||
}
|
}
|
||||||
|
@ -205,11 +205,11 @@ namespace v2rayN.Handler
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var httpPort = _config.GetLocalPort("speedtest");
|
int httpPort = _config.GetLocalPort("speedtest");
|
||||||
index = _selecteds[index];
|
index = _selecteds[index];
|
||||||
|
|
||||||
testCounter++;
|
testCounter++;
|
||||||
var webProxy = new WebProxy(Global.Loopback, httpPort + index);
|
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + index);
|
||||||
downloadHandle2.DownloadFileAsync(_config, url, webProxy, 20);
|
downloadHandle2.DownloadFileAsync(_config, url, webProxy, 20);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -217,7 +217,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
private int GetTcpingTime(string url, int port)
|
private int GetTcpingTime(string url, int port)
|
||||||
{
|
{
|
||||||
var responseTime = -1;
|
int responseTime = -1;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -228,10 +228,10 @@ namespace v2rayN.Handler
|
||||||
ipAddress = ipHostInfo.AddressList[0];
|
ipAddress = ipHostInfo.AddressList[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
var timer = new Stopwatch();
|
Stopwatch timer = new Stopwatch();
|
||||||
timer.Start();
|
timer.Start();
|
||||||
|
|
||||||
var endPoint = new IPEndPoint(ipAddress, port);
|
IPEndPoint endPoint = new IPEndPoint(ipAddress, port);
|
||||||
Socket clientSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
Socket clientSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
|
||||||
IAsyncResult result = clientSocket.BeginConnect(endPoint, null, null);
|
IAsyncResult result = clientSocket.BeginConnect(endPoint, null, null);
|
||||||
|
@ -260,7 +260,7 @@ namespace v2rayN.Handler
|
||||||
myHttpWebRequest.Timeout = 5000;
|
myHttpWebRequest.Timeout = 5000;
|
||||||
myHttpWebRequest.Proxy = webProxy;//new WebProxy(Global.Loopback, Global.httpPort);
|
myHttpWebRequest.Proxy = webProxy;//new WebProxy(Global.Loopback, Global.httpPort);
|
||||||
|
|
||||||
var timer = new Stopwatch();
|
Stopwatch timer = new Stopwatch();
|
||||||
timer.Start();
|
timer.Start();
|
||||||
|
|
||||||
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
|
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
|
||||||
|
|
|
@ -118,8 +118,8 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
if (res != null)
|
if (res != null)
|
||||||
{
|
{
|
||||||
var itemId = config_.getItemId();
|
string itemId = config_.getItemId();
|
||||||
var serverStatItem = GetServerStatItem(itemId);
|
ServerStatItem serverStatItem = GetServerStatItem(itemId);
|
||||||
ulong up = 0,
|
ulong up = 0,
|
||||||
down = 0;
|
down = 0;
|
||||||
|
|
||||||
|
@ -167,8 +167,8 @@ namespace v2rayN.Handler
|
||||||
serverStatistics_.server = new List<ServerStatItem>();
|
serverStatistics_.server = new List<ServerStatItem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var ticks = DateTime.Now.Date.Ticks;
|
long ticks = DateTime.Now.Date.Ticks;
|
||||||
foreach (var item in serverStatistics_.server)
|
foreach (ServerStatItem item in serverStatistics_.server)
|
||||||
{
|
{
|
||||||
if (item.dateNow != ticks)
|
if (item.dateNow != ticks)
|
||||||
{
|
{
|
||||||
|
@ -198,8 +198,8 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
private ServerStatItem GetServerStatItem(string itemId)
|
private ServerStatItem GetServerStatItem(string itemId)
|
||||||
{
|
{
|
||||||
var ticks = DateTime.Now.Date.Ticks;
|
long ticks = DateTime.Now.Date.Ticks;
|
||||||
var cur = Statistic.FindIndex(item => item.itemId == itemId);
|
int cur = Statistic.FindIndex(item => item.itemId == itemId);
|
||||||
if (cur < 0)
|
if (cur < 0)
|
||||||
{
|
{
|
||||||
Statistic.Add(new ServerStatItem
|
Statistic.Add(new ServerStatItem
|
||||||
|
@ -229,12 +229,12 @@ namespace v2rayN.Handler
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (var stat in source)
|
foreach (Stat stat in source)
|
||||||
{
|
{
|
||||||
var name = stat.Name;
|
string name = stat.Name;
|
||||||
var value = stat.Value;
|
long value = stat.Value;
|
||||||
var nStr = name.Split(">>>".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
string[] nStr = name.Split(">>>".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||||
var type = "";
|
string type = "";
|
||||||
|
|
||||||
name = name.Trim();
|
name = name.Trim();
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ namespace v2rayN.Handler
|
||||||
// TCP stack please do me a favor
|
// TCP stack please do me a favor
|
||||||
TcpListener l = new TcpListener(IPAddress.Loopback, 0);
|
TcpListener l = new TcpListener(IPAddress.Loopback, 0);
|
||||||
l.Start();
|
l.Start();
|
||||||
var port = ((IPEndPoint)l.LocalEndpoint).Port;
|
int port = ((IPEndPoint)l.LocalEndpoint).Port;
|
||||||
l.Stop();
|
l.Stop();
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var inbound = v2rayConfig.inbounds[0];
|
Inbounds inbound = v2rayConfig.inbounds[0];
|
||||||
//端口
|
//端口
|
||||||
inbound.port = config.inbound[0].localPort;
|
inbound.port = config.inbound[0].localPort;
|
||||||
inbound.protocol = config.inbound[0].protocol;
|
inbound.protocol = config.inbound[0].protocol;
|
||||||
|
@ -327,7 +327,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var outbound = v2rayConfig.outbounds[0];
|
Outbounds outbound = v2rayConfig.outbounds[0];
|
||||||
if (config.configType() == (int)EConfigType.Vmess)
|
if (config.configType() == (int)EConfigType.Vmess)
|
||||||
{
|
{
|
||||||
VnextItem vnextItem;
|
VnextItem vnextItem;
|
||||||
|
@ -420,7 +420,7 @@ namespace v2rayN.Handler
|
||||||
if (!Utils.IsNullOrEmpty(config.security())
|
if (!Utils.IsNullOrEmpty(config.security())
|
||||||
&& !Utils.IsNullOrEmpty(config.id()))
|
&& !Utils.IsNullOrEmpty(config.id()))
|
||||||
{
|
{
|
||||||
var socksUsersItem = new SocksUsersItem
|
SocksUsersItem socksUsersItem = new SocksUsersItem
|
||||||
{
|
{
|
||||||
user = config.security(),
|
user = config.security(),
|
||||||
pass = config.id(),
|
pass = config.id(),
|
||||||
|
@ -456,7 +456,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
//远程服务器底层传输配置
|
//远程服务器底层传输配置
|
||||||
streamSettings.network = config.network();
|
streamSettings.network = config.network();
|
||||||
var host = config.requestHost();
|
string host = config.requestHost();
|
||||||
//if tls
|
//if tls
|
||||||
if (config.streamSecurity() == Global.StreamSecurity)
|
if (config.streamSecurity() == Global.StreamSecurity)
|
||||||
{
|
{
|
||||||
|
@ -659,10 +659,10 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
if (config.enableStatistics)
|
if (config.enableStatistics)
|
||||||
{
|
{
|
||||||
var tag = Global.InboundAPITagName;
|
string tag = Global.InboundAPITagName;
|
||||||
var apiObj = new API();
|
API apiObj = new API();
|
||||||
var policyObj = new Policy();
|
Policy policyObj = new Policy();
|
||||||
var policySystemSetting = new SystemPolicy();
|
SystemPolicy policySystemSetting = new SystemPolicy();
|
||||||
|
|
||||||
string[] services = { "StatsService" };
|
string[] services = { "StatsService" };
|
||||||
|
|
||||||
|
@ -679,8 +679,8 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
if (!v2rayConfig.inbounds.Exists(item => { return item.tag == tag; }))
|
if (!v2rayConfig.inbounds.Exists(item => { return item.tag == tag; }))
|
||||||
{
|
{
|
||||||
var apiInbound = new Inbounds();
|
Inbounds apiInbound = new Inbounds();
|
||||||
var apiInboundSettings = new Inboundsettings();
|
Inboundsettings apiInboundSettings = new Inboundsettings();
|
||||||
apiInbound.tag = tag;
|
apiInbound.tag = tag;
|
||||||
apiInbound.listen = Global.Loopback;
|
apiInbound.listen = Global.Loopback;
|
||||||
apiInbound.port = Global.statePort;
|
apiInbound.port = Global.statePort;
|
||||||
|
@ -692,7 +692,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
if (!v2rayConfig.routing.rules.Exists(item => { return item.outboundTag == tag; }))
|
if (!v2rayConfig.routing.rules.Exists(item => { return item.outboundTag == tag; }))
|
||||||
{
|
{
|
||||||
var apiRoutingRule = new RulesItem
|
RulesItem apiRoutingRule = new RulesItem
|
||||||
{
|
{
|
||||||
inboundTag = new List<string> { tag },
|
inboundTag = new List<string> { tag },
|
||||||
outboundTag = tag,
|
outboundTag = tag,
|
||||||
|
@ -832,7 +832,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var inbound = v2rayConfig.inbounds[0];
|
Inbounds inbound = v2rayConfig.inbounds[0];
|
||||||
UsersItem usersItem;
|
UsersItem usersItem;
|
||||||
if (inbound.settings.clients.Count <= 0)
|
if (inbound.settings.clients.Count <= 0)
|
||||||
{
|
{
|
||||||
|
@ -921,7 +921,7 @@ namespace v2rayN.Handler
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var outbound = v2rayConfig.outbounds[0];
|
Outbounds outbound = v2rayConfig.outbounds[0];
|
||||||
if (outbound == null
|
if (outbound == null
|
||||||
|| Utils.IsNullOrEmpty(outbound.protocol)
|
|| Utils.IsNullOrEmpty(outbound.protocol)
|
||||||
|| outbound.protocol != "vmess"
|
|| outbound.protocol != "vmess"
|
||||||
|
@ -1067,7 +1067,7 @@ namespace v2rayN.Handler
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var inbound = v2rayConfig.inbounds[0];
|
Inbounds inbound = v2rayConfig.inbounds[0];
|
||||||
if (inbound == null
|
if (inbound == null
|
||||||
|| Utils.IsNullOrEmpty(inbound.protocol)
|
|| Utils.IsNullOrEmpty(inbound.protocol)
|
||||||
|| inbound.protocol != "vmess"
|
|| inbound.protocol != "vmess"
|
||||||
|
@ -1458,7 +1458,7 @@ namespace v2rayN.Handler
|
||||||
dns(configCopy, ref v2rayConfig);
|
dns(configCopy, ref v2rayConfig);
|
||||||
|
|
||||||
|
|
||||||
var httpPort = configCopy.GetLocalPort("speedtest");
|
int httpPort = configCopy.GetLocalPort("speedtest");
|
||||||
foreach (int index in selecteds)
|
foreach (int index in selecteds)
|
||||||
{
|
{
|
||||||
if (configCopy.vmess[index].configType == (int)EConfigType.Custom)
|
if (configCopy.vmess[index].configType == (int)EConfigType.Custom)
|
||||||
|
@ -1468,7 +1468,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
configCopy.index = index;
|
configCopy.index = index;
|
||||||
|
|
||||||
var inbound = new Inbounds
|
Inbounds inbound = new Inbounds
|
||||||
{
|
{
|
||||||
listen = Global.Loopback,
|
listen = Global.Loopback,
|
||||||
port = httpPort + index,
|
port = httpPort + index,
|
||||||
|
@ -1478,12 +1478,12 @@ namespace v2rayN.Handler
|
||||||
v2rayConfig.inbounds.Add(inbound);
|
v2rayConfig.inbounds.Add(inbound);
|
||||||
|
|
||||||
|
|
||||||
var v2rayConfigCopy = Utils.FromJson<V2rayConfig>(result);
|
V2rayConfig v2rayConfigCopy = Utils.FromJson<V2rayConfig>(result);
|
||||||
outbound(configCopy, ref v2rayConfigCopy);
|
outbound(configCopy, ref v2rayConfigCopy);
|
||||||
v2rayConfigCopy.outbounds[0].tag = Global.agentTag + inbound.port.ToString();
|
v2rayConfigCopy.outbounds[0].tag = Global.agentTag + inbound.port.ToString();
|
||||||
v2rayConfig.outbounds.Add(v2rayConfigCopy.outbounds[0]);
|
v2rayConfig.outbounds.Add(v2rayConfigCopy.outbounds[0]);
|
||||||
|
|
||||||
var rule = new RulesItem
|
RulesItem rule = new RulesItem
|
||||||
{
|
{
|
||||||
inboundTag = new List<string> { inbound.tag },
|
inboundTag = new List<string> { inbound.tag },
|
||||||
outboundTag = v2rayConfigCopy.outbounds[0].tag,
|
outboundTag = v2rayConfigCopy.outbounds[0].tag,
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace v2rayN.Handler
|
||||||
Process[] existing = Process.GetProcessesByName(vName);
|
Process[] existing = Process.GetProcessesByName(vName);
|
||||||
foreach (Process p in existing)
|
foreach (Process p in existing)
|
||||||
{
|
{
|
||||||
var path = p.MainModule.FileName;
|
string path = p.MainModule.FileName;
|
||||||
if (path == $"{Utils.GetPath(vName)}.exe")
|
if (path == $"{Utils.GetPath(vName)}.exe")
|
||||||
{
|
{
|
||||||
KillProcess(p);
|
KillProcess(p);
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace v2rayN.HttpProxyHandler
|
||||||
{
|
{
|
||||||
if (type != 0)
|
if (type != 0)
|
||||||
{
|
{
|
||||||
var port = Global.httpPort;
|
int port = Global.httpPort;
|
||||||
if (port <= 0)
|
if (port <= 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -114,7 +114,7 @@ namespace v2rayN.HttpProxyHandler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pac = GetPacList(address);
|
string pac = GetPacList(address);
|
||||||
return pac;
|
return pac;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -165,7 +165,7 @@ namespace v2rayN.HttpProxyHandler
|
||||||
|
|
||||||
private static string GetPacList(string address)
|
private static string GetPacList(string address)
|
||||||
{
|
{
|
||||||
var port = Global.httpPort;
|
int port = Global.httpPort;
|
||||||
if (port <= 0)
|
if (port <= 0)
|
||||||
{
|
{
|
||||||
return "No port";
|
return "No port";
|
||||||
|
@ -174,22 +174,22 @@ namespace v2rayN.HttpProxyHandler
|
||||||
{
|
{
|
||||||
List<string> lstProxy = new List<string>();
|
List<string> lstProxy = new List<string>();
|
||||||
lstProxy.Add(string.Format("PROXY {0}:{1};", address, port));
|
lstProxy.Add(string.Format("PROXY {0}:{1};", address, port));
|
||||||
var proxy = string.Join("", lstProxy.ToArray());
|
string proxy = string.Join("", lstProxy.ToArray());
|
||||||
|
|
||||||
string strPacfile = Utils.GetPath(Global.pacFILE);
|
string strPacfile = Utils.GetPath(Global.pacFILE);
|
||||||
if (!File.Exists(strPacfile))
|
if (!File.Exists(strPacfile))
|
||||||
{
|
{
|
||||||
FileManager.UncompressFile(strPacfile, Resources.pac_txt);
|
FileManager.UncompressFile(strPacfile, Resources.pac_txt);
|
||||||
}
|
}
|
||||||
var pac = File.ReadAllText(strPacfile, Encoding.UTF8);
|
string pac = File.ReadAllText(strPacfile, Encoding.UTF8);
|
||||||
pac = pac.Replace("__PROXY__", proxy);
|
pac = pac.Replace("__PROXY__", proxy);
|
||||||
|
|
||||||
if (_config.userPacRule.Count > 0)
|
if (_config.userPacRule.Count > 0)
|
||||||
{
|
{
|
||||||
var keyWords = "var rules = [";
|
string keyWords = "var rules = [";
|
||||||
if (pac.IndexOf(keyWords) >= 0)
|
if (pac.IndexOf(keyWords) >= 0)
|
||||||
{
|
{
|
||||||
var userPac = string.Join($"\",{Environment.NewLine}\"", _config.userPacRule.ToArray());
|
string userPac = string.Join($"\",{Environment.NewLine}\"", _config.userPacRule.ToArray());
|
||||||
userPac = string.Format("\"{0}\",", userPac);
|
userPac = string.Format("\"{0}\",", userPac);
|
||||||
pac = pac.Replace(keyWords, keyWords + userPac);
|
pac = pac.Replace(keyWords, keyWords + userPac);
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ namespace v2rayN.HttpProxyHandler
|
||||||
/*
|
/*
|
||||||
* Under PortableMode, we could identify it by the path of v2ray_privoxy.exe.
|
* Under PortableMode, we could identify it by the path of v2ray_privoxy.exe.
|
||||||
*/
|
*/
|
||||||
var path = process.MainModule.FileName;
|
string path = process.MainModule.FileName;
|
||||||
|
|
||||||
return Utils.GetTempPath($"{_privoxyName}.exe").Equals(path);
|
return Utils.GetTempPath($"{_privoxyName}.exe").Equals(path);
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,10 @@ namespace v2rayN.HttpProxyHandler
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// restore user settings
|
// restore user settings
|
||||||
var flags = _userSettings.Flags;
|
string flags = _userSettings.Flags;
|
||||||
var proxy_server = _userSettings.ProxyServer ?? "-";
|
string proxy_server = _userSettings.ProxyServer ?? "-";
|
||||||
var bypass_list = _userSettings.BypassList ?? "-";
|
string bypass_list = _userSettings.BypassList ?? "-";
|
||||||
var pac_url = _userSettings.PacUrl ?? "-";
|
string pac_url = _userSettings.PacUrl ?? "-";
|
||||||
arguments = $"set {flags} {proxy_server} {bypass_list} {pac_url}";
|
arguments = $"set {flags} {proxy_server} {bypass_list} {pac_url}";
|
||||||
|
|
||||||
// have to get new settings
|
// have to get new settings
|
||||||
|
@ -110,7 +110,7 @@ namespace v2rayN.HttpProxyHandler
|
||||||
using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false))
|
using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false))
|
||||||
using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false))
|
using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false))
|
||||||
{
|
{
|
||||||
using (var process = new Process())
|
using (Process process = new Process())
|
||||||
{
|
{
|
||||||
// Configure the process using the StartInfo properties.
|
// Configure the process using the StartInfo properties.
|
||||||
process.StartInfo.FileName = Utils.GetTempPath("sysproxy.exe");
|
process.StartInfo.FileName = Utils.GetTempPath("sysproxy.exe");
|
||||||
|
@ -167,10 +167,10 @@ namespace v2rayN.HttpProxyHandler
|
||||||
// log the arguments
|
// log the arguments
|
||||||
throw new Exception(process.StartInfo.Arguments);
|
throw new Exception(process.StartInfo.Arguments);
|
||||||
}
|
}
|
||||||
var stderr = error.ToString();
|
string stderr = error.ToString();
|
||||||
var stdout = output.ToString();
|
string stdout = output.ToString();
|
||||||
|
|
||||||
var exitCode = process.ExitCode;
|
int exitCode = process.ExitCode;
|
||||||
if (exitCode != (int)RET_ERRORS.RET_NO_ERROR)
|
if (exitCode != (int)RET_ERRORS.RET_NO_ERROR)
|
||||||
{
|
{
|
||||||
throw new Exception(stderr);
|
throw new Exception(stderr);
|
||||||
|
|
|
@ -427,7 +427,7 @@ namespace v2rayN.Mode
|
||||||
|
|
||||||
public string getItemId()
|
public string getItemId()
|
||||||
{
|
{
|
||||||
var itemId = $"{address}{port}{requestHost}{path}";
|
string itemId = $"{address}{port}{requestHost}{path}";
|
||||||
itemId = Utils.Base64Encode(itemId);
|
itemId = Utils.Base64Encode(itemId);
|
||||||
return itemId;
|
return itemId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ namespace v2rayN
|
||||||
|
|
||||||
static bool UnzipLibs()
|
static bool UnzipLibs()
|
||||||
{
|
{
|
||||||
var fileName = Utils.GetPath("libs.zip");
|
string fileName = Utils.GetPath("libs.zip");
|
||||||
if (!FileManager.ByteArrayToFile(fileName, Resources.libs))
|
if (!FileManager.ByteArrayToFile(fileName, Resources.libs))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace v2rayN.Tool
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
|
using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
|
||||||
fs.Write(content, 0, content.Length);
|
fs.Write(content, 0, content.Length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,8 @@ namespace v2rayN.Tool
|
||||||
byte[] buffer = new byte[4096];
|
byte[] buffer = new byte[4096];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
using (var fs = File.Create(fileName))
|
using (FileStream fs = File.Create(fileName))
|
||||||
using (var input = new GZipStream(new MemoryStream(content),
|
using (GZipStream input = new GZipStream(new MemoryStream(content),
|
||||||
CompressionMode.Decompress, false))
|
CompressionMode.Decompress, false))
|
||||||
{
|
{
|
||||||
while ((n = input.Read(buffer, 0, buffer.Length)) > 0)
|
while ((n = input.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
|
@ -56,8 +56,8 @@ namespace v2rayN.Tool
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
using (var sr = new StreamReader(fs, encoding))
|
using (StreamReader sr = new StreamReader(fs, encoding))
|
||||||
{
|
{
|
||||||
return sr.ReadToEnd();
|
return sr.ReadToEnd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,13 @@ namespace v2rayN
|
||||||
public Job()
|
public Job()
|
||||||
{
|
{
|
||||||
handle = CreateJobObject(IntPtr.Zero, null);
|
handle = CreateJobObject(IntPtr.Zero, null);
|
||||||
var extendedInfoPtr = IntPtr.Zero;
|
IntPtr extendedInfoPtr = IntPtr.Zero;
|
||||||
var info = new JOBOBJECT_BASIC_LIMIT_INFORMATION
|
JOBOBJECT_BASIC_LIMIT_INFORMATION info = new JOBOBJECT_BASIC_LIMIT_INFORMATION
|
||||||
{
|
{
|
||||||
LimitFlags = 0x2000
|
LimitFlags = 0x2000
|
||||||
};
|
};
|
||||||
|
|
||||||
var extendedInfo = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION
|
JOBOBJECT_EXTENDED_LIMIT_INFORMATION extendedInfo = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION
|
||||||
{
|
{
|
||||||
BasicLimitInformation = info
|
BasicLimitInformation = info
|
||||||
};
|
};
|
||||||
|
@ -50,7 +50,7 @@ namespace v2rayN
|
||||||
|
|
||||||
public bool AddProcess(IntPtr processHandle)
|
public bool AddProcess(IntPtr processHandle)
|
||||||
{
|
{
|
||||||
var succ = AssignProcessToJobObject(handle, processHandle);
|
bool succ = AssignProcessToJobObject(handle, processHandle);
|
||||||
|
|
||||||
if (!succ)
|
if (!succ)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace v2rayN
|
||||||
|
|
||||||
static string LoadString(ResourceManager resMgr, string key)
|
static string LoadString(ResourceManager resMgr, string key)
|
||||||
{
|
{
|
||||||
var value = resMgr.GetString(key);
|
string value = resMgr.GetString(key);
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
{
|
||||||
throw new KeyNotFoundException($"key: {key}");
|
throw new KeyNotFoundException($"key: {key}");
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace v2rayN
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var assembly = Assembly.GetExecutingAssembly();
|
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||||
using (Stream stream = assembly.GetManifestResourceStream(res))
|
using (Stream stream = assembly.GetManifestResourceStream(res))
|
||||||
using (StreamReader reader = new StreamReader(stream))
|
using (StreamReader reader = new StreamReader(stream))
|
||||||
{
|
{
|
||||||
|
@ -194,7 +194,7 @@ namespace v2rayN
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
|
byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
|
||||||
return Convert.ToBase64String(plainTextBytes);
|
return Convert.ToBase64String(plainTextBytes);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -272,20 +272,20 @@ namespace v2rayN
|
||||||
/// <param name="unit">单位</param>
|
/// <param name="unit">单位</param>
|
||||||
public static void ToHumanReadable(ulong amount, out double result, out string unit)
|
public static void ToHumanReadable(ulong amount, out double result, out string unit)
|
||||||
{
|
{
|
||||||
var factor = 1024u;
|
uint factor = 1024u;
|
||||||
var KBs = amount / factor;
|
ulong KBs = amount / factor;
|
||||||
if (KBs > 0)
|
if (KBs > 0)
|
||||||
{
|
{
|
||||||
// multi KB
|
// multi KB
|
||||||
var MBs = KBs / factor;
|
ulong MBs = KBs / factor;
|
||||||
if (MBs > 0)
|
if (MBs > 0)
|
||||||
{
|
{
|
||||||
// multi MB
|
// multi MB
|
||||||
var GBs = MBs / factor;
|
ulong GBs = MBs / factor;
|
||||||
if (GBs > 0)
|
if (GBs > 0)
|
||||||
{
|
{
|
||||||
// multi GB
|
// multi GB
|
||||||
var TBs = GBs / factor;
|
ulong TBs = GBs / factor;
|
||||||
if (TBs > 0)
|
if (TBs > 0)
|
||||||
{
|
{
|
||||||
// 你是魔鬼吗? 用这么多流量
|
// 你是魔鬼吗? 用这么多流量
|
||||||
|
@ -322,7 +322,7 @@ namespace v2rayN
|
||||||
|
|
||||||
public static void DedupServerList(List<Mode.VmessItem> source, out List<Mode.VmessItem> result, bool keepOlder)
|
public static void DedupServerList(List<Mode.VmessItem> source, out List<Mode.VmessItem> result, bool keepOlder)
|
||||||
{
|
{
|
||||||
var list = new List<Mode.VmessItem>();
|
List<Mode.VmessItem> list = new List<Mode.VmessItem>();
|
||||||
if (!keepOlder) source.Reverse(); // Remove the early items first
|
if (!keepOlder) source.Reverse(); // Remove the early items first
|
||||||
|
|
||||||
bool _isAdded(Mode.VmessItem o, Mode.VmessItem n)
|
bool _isAdded(Mode.VmessItem o, Mode.VmessItem n)
|
||||||
|
@ -341,7 +341,7 @@ namespace v2rayN
|
||||||
o.streamSecurity == n.streamSecurity;
|
o.streamSecurity == n.streamSecurity;
|
||||||
// skip (will remove) different remarks
|
// skip (will remove) different remarks
|
||||||
}
|
}
|
||||||
foreach (var item in source)
|
foreach (Mode.VmessItem item in source)
|
||||||
{
|
{
|
||||||
if (!list.Exists(i => _isAdded(i, item)))
|
if (!list.Exists(i => _isAdded(i, item)))
|
||||||
{
|
{
|
||||||
|
@ -410,7 +410,7 @@ namespace v2rayN
|
||||||
//可能是CIDR
|
//可能是CIDR
|
||||||
if (ip.IndexOf(@"/") > 0)
|
if (ip.IndexOf(@"/") > 0)
|
||||||
{
|
{
|
||||||
var cidr = ip.Split('/');
|
string[] cidr = ip.Split('/');
|
||||||
if (cidr.Length == 2)
|
if (cidr.Length == 2)
|
||||||
{
|
{
|
||||||
if (!IsNumberic(cidr[0]))
|
if (!IsNumberic(cidr[0]))
|
||||||
|
@ -515,7 +515,7 @@ namespace v2rayN
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var value = RegReadValue(autoRunRegPath, autoRunName, "");
|
string value = RegReadValue(autoRunRegPath, autoRunName, "");
|
||||||
string exePath = GetExePath();
|
string exePath = GetExePath();
|
||||||
if (value?.Equals(exePath) == true)
|
if (value?.Equals(exePath) == true)
|
||||||
{
|
{
|
||||||
|
@ -917,10 +917,10 @@ namespace v2rayN
|
||||||
GraphicsUnit.Pixel);
|
GraphicsUnit.Pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
var source = new BitmapLuminanceSource(target);
|
BitmapLuminanceSource source = new BitmapLuminanceSource(target);
|
||||||
var bitmap = new BinaryBitmap(new HybridBinarizer(source));
|
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
|
||||||
QRCodeReader reader = new QRCodeReader();
|
QRCodeReader reader = new QRCodeReader();
|
||||||
var result = reader.decode(bitmap);
|
Result result = reader.decode(bitmap);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
ret = result.Text;
|
ret = result.Text;
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace v2rayUpgrade
|
||||||
Process[] existing = Process.GetProcessesByName("v2rayN");
|
Process[] existing = Process.GetProcessesByName("v2rayN");
|
||||||
foreach (Process p in existing)
|
foreach (Process p in existing)
|
||||||
{
|
{
|
||||||
var path = p.MainModule.FileName;
|
string path = p.MainModule.FileName;
|
||||||
if (path == GetPath("v2rayN.exe"))
|
if (path == GetPath("v2rayN.exe"))
|
||||||
{
|
{
|
||||||
p.Kill();
|
p.Kill();
|
||||||
|
@ -49,7 +49,7 @@ namespace v2rayUpgrade
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileName = GetPath(_tempFileName);
|
string fileName = GetPath(_tempFileName);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Delete(fileName);
|
File.Delete(fileName);
|
||||||
|
@ -60,7 +60,7 @@ namespace v2rayUpgrade
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var startKey = "v2rayN/";
|
string startKey = "v2rayN/";
|
||||||
|
|
||||||
using (ZipArchive archive = ZipFile.OpenRead(fileName))
|
using (ZipArchive archive = ZipFile.OpenRead(fileName))
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ namespace v2rayUpgrade
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var fullName = entry.FullName;
|
string fullName = entry.FullName;
|
||||||
if (fullName.StartsWith(startKey))
|
if (fullName.StartsWith(startKey))
|
||||||
{
|
{
|
||||||
fullName = fullName.Substring(startKey.Length, fullName.Length - startKey.Length);
|
fullName = fullName.Substring(startKey.Length, fullName.Length - startKey.Length);
|
||||||
|
|
Loading…
Reference in New Issue