mirror of
				https://github.com/2dust/v2rayN.git
				synced 2025-11-03 22:12:52 +00:00 
			
		
		
		
	up speedtest
This commit is contained in:
		
							parent
							
								
									fe0bd5938b
								
							
						
					
					
						commit
						b94d10d808
					
				
					 12 changed files with 49 additions and 22 deletions
				
			
		| 
						 | 
					@ -319,16 +319,15 @@ namespace v2rayN.Forms
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void DisplayToolStatus()
 | 
					        private void DisplayToolStatus()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var localIP = "127.0.0.1";
 | 
					 | 
				
			||||||
            toolSslSocksPort.Text =
 | 
					            toolSslSocksPort.Text =
 | 
				
			||||||
            toolSslHttpPort.Text =
 | 
					            toolSslHttpPort.Text =
 | 
				
			||||||
            toolSslPacPort.Text = "NONE";
 | 
					            toolSslPacPort.Text = "NONE";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            toolSslSocksPort.Text = $"{localIP}:{config.inbound[0].localPort}";
 | 
					            toolSslSocksPort.Text = $"{Global.Loopback}:{config.inbound[0].localPort}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (config.sysAgentEnabled)
 | 
					            if (config.sysAgentEnabled)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                toolSslHttpPort.Text = $"{localIP}:{Global.sysAgentPort}";
 | 
					                toolSslHttpPort.Text = $"{Global.Loopback}:{Global.sysAgentPort}";
 | 
				
			||||||
                if (config.listenerType == 2 || config.listenerType == 4)
 | 
					                if (config.listenerType == 2 || config.listenerType == 4)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (PACServerHandle.IsRunning)
 | 
					                    if (PACServerHandle.IsRunning)
 | 
				
			||||||
| 
						 | 
					@ -607,7 +606,7 @@ namespace v2rayN.Forms
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void menuRealPingServer_Click(object sender, EventArgs e)
 | 
					        private void menuRealPingServer_Click(object sender, EventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!config.sysAgentEnabled || config.listenerType != 1)
 | 
					            if (!config.sysAgentEnabled)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                UI.Show(UIRes.I18N("NeedHttpGlobalProxy"));
 | 
					                UI.Show(UIRes.I18N("NeedHttpGlobalProxy"));
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
| 
						 | 
					@ -622,7 +621,7 @@ namespace v2rayN.Forms
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void menuSpeedServer_Click(object sender, EventArgs e)
 | 
					        private void menuSpeedServer_Click(object sender, EventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!config.sysAgentEnabled || config.listenerType != 1)
 | 
					            if (!config.sysAgentEnabled)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                UI.Show(UIRes.I18N("NeedHttpGlobalProxy"));
 | 
					                UI.Show(UIRes.I18N("NeedHttpGlobalProxy"));
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -147,10 +147,10 @@ namespace v2rayN
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public const string CustomIconName = "v2rayN.ico";
 | 
					        public const string CustomIconName = "v2rayN.ico";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public const string Loopback = "127.0.0.1";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public const string InboundAPITagName = "api";
 | 
					        public const string InboundAPITagName = "api";
 | 
				
			||||||
        public const string InboundProxyTagName = "proxy";  
 | 
					        public const string InboundProxyTagName = "proxy";  
 | 
				
			||||||
        public const string Loopback = "127.0.0.1";
 | 
					 | 
				
			||||||
        public const string InboundAPIProtocal = "dokodemo-door";
 | 
					        public const string InboundAPIProtocal = "dokodemo-door";
 | 
				
			||||||
     
 | 
					     
 | 
				
			||||||
        public enum StatisticsFreshRate
 | 
					        public enum StatisticsFreshRate
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -276,6 +276,7 @@ namespace v2rayN.Handler
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
 | 
					                HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
 | 
				
			||||||
                myHttpWebRequest.Timeout = 5000;
 | 
					                myHttpWebRequest.Timeout = 5000;
 | 
				
			||||||
 | 
					                myHttpWebRequest.Proxy = new WebProxy(Global.Loopback, Global.sysAgentPort);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var timer = new Stopwatch();
 | 
					                var timer = new Stopwatch();
 | 
				
			||||||
                timer.Start();
 | 
					                timer.Start();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,7 +95,7 @@ namespace v2rayN.Handler
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Global.statePort = GetFreePort();
 | 
					                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();
 | 
					                channel_.ConnectAsync();
 | 
				
			||||||
                client_ = new StatsService.StatsServiceClient(channel_);
 | 
					                client_ = new StatsService.StatsServiceClient(channel_);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -159,7 +159,7 @@ namespace v2rayN.Handler
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    inbound.listen = "127.0.0.1";
 | 
					                    inbound.listen = Global.Loopback;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                //开启udp
 | 
					                //开启udp
 | 
				
			||||||
                inbound.settings.udp = config.inbound[0].udpEnabled;
 | 
					                inbound.settings.udp = config.inbound[0].udpEnabled;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -100,12 +100,14 @@ namespace v2rayN.Handler
 | 
				
			||||||
                ServicePointManager.DefaultConnectionLimit = 256;
 | 
					                ServicePointManager.DefaultConnectionLimit = 256;
 | 
				
			||||||
                if (UpdateCompleted != null)
 | 
					                if (UpdateCompleted != null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    UpdateCompleted(this, new ResultEventArgs(false, url));
 | 
					                    UpdateCompleted(this, new ResultEventArgs(false, "Downloading..."));
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                progressPercentage = -1;
 | 
					                progressPercentage = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                WebClientEx ws = new WebClientEx();
 | 
					                WebClientEx ws = new WebClientEx();
 | 
				
			||||||
 | 
					                ws.Proxy = new WebProxy(Global.Loopback, Global.sysAgentPort);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                ws.DownloadFileCompleted += ws_DownloadFileCompleted;
 | 
					                ws.DownloadFileCompleted += ws_DownloadFileCompleted;
 | 
				
			||||||
                ws.DownloadProgressChanged += ws_DownloadProgressChanged;
 | 
					                ws.DownloadProgressChanged += ws_DownloadProgressChanged;
 | 
				
			||||||
                ws.DownloadFileAsync(new Uri(url), Utils.GetPath(DownloadFileName));
 | 
					                ws.DownloadFileAsync(new Uri(url), Utils.GetPath(DownloadFileName));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ namespace v2rayN.HttpProxyHandler
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        PACServerHandle.Stop();
 | 
					                        PACServerHandle.Stop();
 | 
				
			||||||
                        PACFileWatcherHandle.StopWatch();
 | 
					                        PACFileWatcherHandle.StopWatch();
 | 
				
			||||||
                        SysProxyHandle.SetIEProxy(true, true, "127.0.0.1:" + port, null);
 | 
					                        SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}", null);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else if (type == 2)
 | 
					                    else if (type == 2)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
| 
						 | 
					@ -168,8 +168,8 @@ namespace v2rayN.HttpProxyHandler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static string GetPacUrl()
 | 
					        public static string GetPacUrl()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            string pacUrl = string.Format("http://127.0.0.1:{0}/pac/?t={1}", Global.pacPort,
 | 
					            string pacUrl = $"http://{Global.Loopback}:{Global.pacPort}/pac/?t={GetTimestamp(DateTime.Now)}";
 | 
				
			||||||
                          GetTimestamp(DateTime.Now));
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return pacUrl;
 | 
					            return pacUrl;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,7 @@ namespace v2rayN.HttpProxyHandler
 | 
				
			||||||
            //{
 | 
					            //{
 | 
				
			||||||
            //    throw new Exception("未发现HTTP代理,无法设置代理更新");
 | 
					            //    throw new Exception("未发现HTTP代理,无法设置代理更新");
 | 
				
			||||||
            //}
 | 
					            //}
 | 
				
			||||||
            WebClient http = new WebClient();
 | 
					            var http = new WebClientEx();
 | 
				
			||||||
            //http.Headers.Add("Connection", "Close");
 | 
					            //http.Headers.Add("Connection", "Close");
 | 
				
			||||||
            //http.Proxy = new WebProxy(IPAddress.Loopback.ToString(), httpProxy.localPort);
 | 
					            //http.Proxy = new WebProxy(IPAddress.Loopback.ToString(), httpProxy.localPort);
 | 
				
			||||||
            http.DownloadStringCompleted += http_DownloadStringCompleted;
 | 
					            http.DownloadStringCompleted += http_DownloadStringCompleted;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,11 +31,11 @@ namespace v2rayN.HttpProxyHandler
 | 
				
			||||||
            //{
 | 
					            //{
 | 
				
			||||||
            //    pacPort = Global.pacPort;
 | 
					            //    pacPort = Global.pacPort;
 | 
				
			||||||
            //}
 | 
					            //}
 | 
				
			||||||
            if (InitServer("127.0.0.1"))
 | 
					            if (InitServer(Global.Loopback))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                pacPort = Global.pacPort;
 | 
					                pacPort = Global.pacPort;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else if (InitServerB("127.0.0.1"))
 | 
					            else if (InitServerB(Global.Loopback))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                pacPort = Global.pacPort;
 | 
					                pacPort = Global.pacPort;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -99,7 +99,7 @@ namespace v2rayN.HttpProxyHandler
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                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));
 | 
					                FileManager.ByteArrayToFile(Utils.GetTempPath(_uniqueConfigFile), Encoding.UTF8.GetBytes(privoxyConfig));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,17 +5,42 @@ namespace v2rayN.HttpProxyHandler
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    class WebClientEx : WebClient
 | 
					    class WebClientEx : WebClient
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public int Timeout { get; set; }
 | 
					        public int Timeout
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get; set;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        public WebClientEx(int timeout = 3000)
 | 
					        public WebClientEx(int timeout = 3000)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Timeout = timeout;
 | 
					            Timeout = timeout;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        protected override WebRequest GetWebRequest(Uri address)
 | 
					        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.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;
 | 
					            return request;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,4 +33,4 @@ using System.Runtime.InteropServices;
 | 
				
			||||||
// 方法是按如下所示使用“*”:
 | 
					// 方法是按如下所示使用“*”:
 | 
				
			||||||
//[assembly: AssemblyVersion("1.0.*")]
 | 
					//[assembly: AssemblyVersion("1.0.*")]
 | 
				
			||||||
//[assembly: AssemblyVersion("1.0.0")]
 | 
					//[assembly: AssemblyVersion("1.0.0")]
 | 
				
			||||||
[assembly: AssemblyFileVersion("2.43")]
 | 
					[assembly: AssemblyFileVersion("2.45")]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue