up speedtest

pull/188/head
2dust 2019-10-17 09:41:46 +08:00
parent fe0bd5938b
commit b94d10d808
12 changed files with 49 additions and 22 deletions

View File

@ -319,16 +319,15 @@ namespace v2rayN.Forms
private void DisplayToolStatus()
{
var localIP = "127.0.0.1";
toolSslSocksPort.Text =
toolSslHttpPort.Text =
toolSslPacPort.Text = "NONE";
toolSslSocksPort.Text = $"{localIP}:{config.inbound[0].localPort}";
toolSslSocksPort.Text = $"{Global.Loopback}:{config.inbound[0].localPort}";
if (config.sysAgentEnabled)
{
toolSslHttpPort.Text = $"{localIP}:{Global.sysAgentPort}";
toolSslHttpPort.Text = $"{Global.Loopback}:{Global.sysAgentPort}";
if (config.listenerType == 2 || config.listenerType == 4)
{
if (PACServerHandle.IsRunning)
@ -607,7 +606,7 @@ namespace v2rayN.Forms
private void menuRealPingServer_Click(object sender, EventArgs e)
{
if (!config.sysAgentEnabled || config.listenerType != 1)
if (!config.sysAgentEnabled)
{
UI.Show(UIRes.I18N("NeedHttpGlobalProxy"));
return;
@ -622,7 +621,7 @@ namespace v2rayN.Forms
private void menuSpeedServer_Click(object sender, EventArgs e)
{
if (!config.sysAgentEnabled || config.listenerType != 1)
if (!config.sysAgentEnabled)
{
UI.Show(UIRes.I18N("NeedHttpGlobalProxy"));
return;

View File

@ -147,10 +147,10 @@ namespace v2rayN
/// </summary>
public const string CustomIconName = "v2rayN.ico";
public const string Loopback = "127.0.0.1";
public const string InboundAPITagName = "api";
public const string InboundProxyTagName = "proxy";
public const string Loopback = "127.0.0.1";
public const string InboundProxyTagName = "proxy";
public const string InboundAPIProtocal = "dokodemo-door";
public enum StatisticsFreshRate

View File

@ -276,6 +276,7 @@ namespace v2rayN.Handler
{
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
myHttpWebRequest.Timeout = 5000;
myHttpWebRequest.Proxy = new WebProxy(Global.Loopback, Global.sysAgentPort);
var timer = new Stopwatch();
timer.Start();

View File

@ -95,7 +95,7 @@ namespace v2rayN.Handler
{
Global.statePort = GetFreePort();
channel_ = new Channel($"127.0.0.1:{Global.statePort}", ChannelCredentials.Insecure);
channel_ = new Channel($"{Global.Loopback}:{Global.statePort}", ChannelCredentials.Insecure);
channel_.ConnectAsync();
client_ = new StatsService.StatsServiceClient(channel_);
}

View File

@ -159,7 +159,7 @@ namespace v2rayN.Handler
}
else
{
inbound.listen = "127.0.0.1";
inbound.listen = Global.Loopback;
}
//开启udp
inbound.settings.udp = config.inbound[0].udpEnabled;

View File

@ -100,12 +100,14 @@ namespace v2rayN.Handler
ServicePointManager.DefaultConnectionLimit = 256;
if (UpdateCompleted != null)
{
UpdateCompleted(this, new ResultEventArgs(false, url));
UpdateCompleted(this, new ResultEventArgs(false, "Downloading..."));
}
progressPercentage = -1;
WebClientEx ws = new WebClientEx();
ws.Proxy = new WebProxy(Global.Loopback, Global.sysAgentPort);
ws.DownloadFileCompleted += ws_DownloadFileCompleted;
ws.DownloadProgressChanged += ws_DownloadProgressChanged;
ws.DownloadFileAsync(new Uri(url), Utils.GetPath(DownloadFileName));
@ -216,6 +218,6 @@ namespace v2rayN.Handler
}
}
}
}

View File

@ -47,7 +47,7 @@ namespace v2rayN.HttpProxyHandler
{
PACServerHandle.Stop();
PACFileWatcherHandle.StopWatch();
SysProxyHandle.SetIEProxy(true, true, "127.0.0.1:" + port, null);
SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}", null);
}
else if (type == 2)
{
@ -168,8 +168,8 @@ namespace v2rayN.HttpProxyHandler
public static string GetPacUrl()
{
string pacUrl = string.Format("http://127.0.0.1:{0}/pac/?t={1}", Global.pacPort,
GetTimestamp(DateTime.Now));
string pacUrl = $"http://{Global.Loopback}:{Global.pacPort}/pac/?t={GetTimestamp(DateTime.Now)}";
return pacUrl;
}

View File

@ -46,7 +46,7 @@ namespace v2rayN.HttpProxyHandler
//{
// throw new Exception("未发现HTTP代理无法设置代理更新");
//}
WebClient http = new WebClient();
var http = new WebClientEx();
//http.Headers.Add("Connection", "Close");
//http.Proxy = new WebProxy(IPAddress.Loopback.ToString(), httpProxy.localPort);
http.DownloadStringCompleted += http_DownloadStringCompleted;

View File

@ -31,11 +31,11 @@ namespace v2rayN.HttpProxyHandler
//{
// pacPort = Global.pacPort;
//}
if (InitServer("127.0.0.1"))
if (InitServer(Global.Loopback))
{
pacPort = Global.pacPort;
}
else if (InitServerB("127.0.0.1"))
else if (InitServerB(Global.Loopback))
{
pacPort = Global.pacPort;
}

View File

@ -99,7 +99,7 @@ namespace v2rayN.HttpProxyHandler
}
else
{
privoxyConfig = privoxyConfig.Replace("__PRIVOXY_BIND_IP__", "127.0.0.1");
privoxyConfig = privoxyConfig.Replace("__PRIVOXY_BIND_IP__", Global.Loopback);
}
FileManager.ByteArrayToFile(Utils.GetTempPath(_uniqueConfigFile), Encoding.UTF8.GetBytes(privoxyConfig));

View File

@ -5,17 +5,42 @@ namespace v2rayN.HttpProxyHandler
{
class WebClientEx : WebClient
{
public int Timeout { get; set; }
public int Timeout
{
get; set;
}
public WebClientEx(int timeout = 3000)
{
Timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var request = base.GetWebRequest(address);
HttpWebRequest request;
if (address.Scheme == "https")
{
ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => { return true; };
request = (HttpWebRequest)base.GetWebRequest(address);
request.ProtocolVersion = HttpVersion.Version10;
}
else
{
request = (HttpWebRequest)base.GetWebRequest(address);
}
request.Timeout = Timeout;
request.ReadWriteTimeout = Timeout;
//request.AllowAutoRedirect = false;
//request.AllowWriteStreamBuffering = true;
request.ServicePoint.BindIPEndPointDelegate = (servicePoint, remoteEndPoint, retryCount) =>
{
if (remoteEndPoint.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
return new IPEndPoint(IPAddress.IPv6Any, 0);
else
return new IPEndPoint(IPAddress.Any, 0);
};
return request;
}
}

View File

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