public InternetChecker(InternetCheckerOptions?options = null, TcpIpSystem?tcpIp = null)
        {
            this.Options = options?._CloneIfClonable() ?? new InternetCheckerOptions();
            this.TcpIp   = tcpIp ?? LocalNet;

            this.StartMainLoop(MainLoopAsync);
        }
 public GetMyIpClient(TcpIpSystem?tcpIp = null)
 {
     this.TcpIp = tcpIp ?? LocalNet;
     this.Web   = new WebApi(new WebApiOptions(new WebApiSettings {
         SslAcceptAnyCerts = true, UseProxy = false, Timeout = CoresConfig.GetMyIpClientSettings.Timeout
     }, this.TcpIp));
 }
Beispiel #3
0
        public SslCertCollectorUtil(int maxConcurrentTasks, IEnumerable <SniHostnameIpAddressPair> pairs, TcpIpSystem?tcpIp = null)
        {
            this.TcpIp = tcpIp ?? LocalNet;

            this.MaxConcurrentTasks = maxConcurrentTasks._Max(1);

            // 入力リストを整理する
            // (SNI + IP アドレス のほか、IP アドレス + IP アドレスも追加する)
            HashSet <SniHostnameIpAddressPair> tmpList = new HashSet <SniHostnameIpAddressPair>(pairs.Distinct());

            Queue = new ConcurrentQueue <SslCertCollectorItem>();

            foreach (SniHostnameIpAddressPair pair in pairs)
            {
                SslCertCollectorItem e1 = new SslCertCollectorItem
                {
                    FriendName  = pair.SniHostName,
                    SniHostName = pair.SniHostName,
                    IpAddress   = pair.IpAddress,
                };

                Queue.Enqueue(e1);

                SslCertCollectorItem e2 = new SslCertCollectorItem
                {
                    FriendName  = pair.SniHostName,
                    SniHostName = pair.IpAddress,
                    IpAddress   = pair.IpAddress,
                };

                Queue.Enqueue(e2);
            }
        }
Beispiel #4
0
        public SpeedTestServer(TcpIpSystem system, params int[] ports)
        {
            this.System      = system;
            this.ServerPorts = ports;

            InitSendData();

            StartMainLoop(ServerMainLoop);
        }
Beispiel #5
0
        public DnsIpPairGeneratorUtil(int maxConcurrentTasks, IEnumerable <string> fqdnSet, TcpIpSystem?tcpIp = null)
        {
            this.TcpIp = tcpIp ?? LocalNet;

            this.MaxConcurrentTasks = maxConcurrentTasks._Max(1);

            // ひとまずソート
            List <string> fqdnList = fqdnSet.Distinct(StrComparer.IgnoreCaseComparer).OrderBy(x => x, StrComparer.IgnoreCaseComparer).ToList();

            // キューに入れる
            FqdnQueue = new ConcurrentQueue <string>(fqdnList);
        }
        public async Task ResolveDestHostnameIfNecessaryAsync(TcpIpSystem system, CancellationToken cancel = default)
        {
            if (this.NeedToSolveDestHostname == false)
            {
                return;
            }

            IPAddress ip = await system.GetIpAsync(this.DestHostname !, this.AddressFamily, this.DnsTimeout, cancel);

            this.DestIp = ip;
            this.NeedToSolveDestHostname = false;
        }
        public WebApiOptions(WebApiSettings?settings = null, TcpIpSystem?tcpIp = null)
        {
            if (settings == null)
            {
                settings = new WebApiSettings();
            }
            if (tcpIp == null)
            {
                tcpIp = LocalNet;
            }

            this.Settings = settings;
            this.TcpIp    = tcpIp;
        }
Beispiel #8
0
 public SpeedTestClient(TcpIpSystem system, IPAddress ip, int port, int numConnection, int timespan, SpeedTestModeFlag mode, CancellationToken cancel = default)
 {
     this.System        = system;
     this.ServerIP      = ip;
     this.ServerPort    = port;
     this.Cancel        = cancel;
     this.NumConnection = Math.Max(numConnection, 1);
     this.TimeSpan      = Math.Max(timespan, 1000);
     this.Mode          = mode;
     if (Mode == SpeedTestModeFlag.Both)
     {
         this.NumConnection = Math.Max(NumConnection, 2);
     }
     this.ClientStartEvent = new AsyncManualResetEvent();
     InitSendData();
 }
        public IPv4V6DualStackSpeculativeConnector(TcpConnectParam basicParam, TcpIpSystem system) : base(basicParam)
        {
            if (basicParam.DestHostname._IsEmpty())
            {
                // IP address is specified
                AddAttempt(new Attempt(system, basicParam, 0));
                return;
            }

            // Hostname is specified
            var hostInfo = system.GetHostInfo(true);

            if (hostInfo.IsIPv4Supported)
            {
                AddAttempt(new Attempt(system, new TcpConnectParam(basicParam.DestHostname, basicParam.DestPort, AddressFamily.InterNetwork,
                                                                   connectTimeout: basicParam.ConnectTimeout, dnsTimeout: basicParam.DnsTimeout), 0));
            }

            if (hostInfo.IsIPv6Supported)
            {
                AddAttempt(new Attempt(system, new TcpConnectParam(basicParam.DestHostname, basicParam.DestPort, AddressFamily.InterNetworkV6,
                                                                   connectTimeout: basicParam.ConnectTimeout, dnsTimeout: basicParam.DnsTimeout), 0));
            }
        }
Beispiel #10
0
        static public async Task <List <SpeedTestClient.Result> > RunSpeedTestWithMultiTryAsync(TcpIpSystem system, IPAddress ip, int port, int numConnection, int timespan, SpeedTestModeFlag mode, int numTry, int interval, CancellationToken cancel = default)
        {
            List <SpeedTestClient.Result> ret = new List <Result>();

            numTry = Math.Max(numTry, 1);

            for (int i = 0; i < numTry; i++)
            {
                if (cancel.IsCancellationRequested)
                {
                    return(new List <Result>());
                }

                SpeedTestClient tc = new SpeedTestClient(system, ip, port, numConnection, timespan, mode, cancel);

                var result = await tc.RunClientAsync();

                if (result != null)
                {
                    ret.Add(result);
                }

                await cancel._WaitUntilCanceledAsync(Util.GenRandInterval(interval));
            }

            return(ret);
        }
 public LogServerOptionsBase(TcpIpSystem tcpIp, PalSslServerAuthenticationOptions sslAuthOptions, string?rateLimiterConfigName = null, params IPEndPoint[] endPoints)
     : base(tcpIp, sslAuthOptions, rateLimiterConfigName, endPoints.Any() ? endPoints : IPUtil.GenerateListeningEndPointsList(false, Consts.Ports.LogServerDefaultServicePort))
 {
 }