Example #1
0
    public SnmpWorkHost()
    {
        try
        {
            // SnmpWorkSettings を読み込む
            this.SettingsHive = new HiveData <SnmpWorkSettings>(Hive.SharedLocalConfigHive, $"SnmpWork", null, HiveSyncPolicy.AutoReadFromFile);

            // データベース
            this.InternalDbHive = new HiveData <SnmpWorkInternalDb>(Hive.SharedLocalConfigHive, "InternalDatabase/SnmpWorkInternalDb",
                                                                    getDefaultDataFunc: () => new SnmpWorkInternalDb(),
                                                                    policy: HiveSyncPolicy.AutoReadWriteFile,
                                                                    serializer: HiveSerializerSelection.RichJson);

            // HTTP サーバーを立ち上げる
            this.Cgi = new CgiHttpServer(new SnmpWorkCgiHandler(this), new HttpServerOptions()
            {
                AutomaticRedirectToHttpsIfPossible = false,
                DisableHiveBasedSetting            = true,
                DenyRobots                 = true,
                UseGlobalCertVault         = false,
                LocalHostOnly              = true,
                HttpPortsList              = new int[] { Settings.HttpPort }.ToList(),
                HttpsPortsList             = new List <int>(),
                UseKestrelWithIPACoreStack = true,
            },
                                         true);
        }
        catch
        {
            this._DisposeSafe();
            throw;
        }
    }
Example #2
0
    public MyIpServerHost()
    {
        try
        {
            // Settings を読み込む
            this.SettingsHive = new HiveData <MyIpServerSettings>(Hive.SharedLocalConfigHive, $"MyIpServer", null, HiveSyncPolicy.AutoReadFromFile);

            List <IPEndPoint> dnsServers = new List <IPEndPoint>();

            foreach (var host in this.Settings.DnsServerList)
            {
                var ep = host._ToIPEndPoint(53, allowed: AllowedIPVersions.IPv4, true);
                if (ep != null)
                {
                    dnsServers.Add(ep);
                }
            }

            if (dnsServers.Count == 0)
            {
                throw new CoresLibException("dnsServers.Count == 0");
            }

            this.Dns = new DnsClientLibBasedDnsResolver(
                new DnsResolverSettings(
                    flags: DnsResolverFlags.RoundRobinServers | DnsResolverFlags.UdpOnly,
                    dnsServersList: dnsServers
                    )
                );

            // HTTP サーバーを立ち上げる
            this.Cgi = new CgiHttpServer(new MyIpServerCgiHandler(this), new HttpServerOptions()
            {
                AutomaticRedirectToHttpsIfPossible = false,
                UseKestrelWithIPACoreStack         = false,
                HttpPortsList      = new int[] { 80, 992 }.ToList(),
                HttpsPortsList     = new int[] { 443 }.ToList(),
                UseStaticFiles     = false,
                MaxRequestBodySize = 32 * 1024,
                ReadTimeoutMsecs   = this.Settings.HttpTimeoutMsecs,
            },
                                         true);
        }
        catch
        {
            this._DisposeSafe();
            throw;
        }
    }
Example #3
0
 public StressMonServer()
 {
     try
     {
         this.Cgi = new CgiHttpServer(new StressMonServerCore(this), new HttpServerOptions()
         {
             AutomaticRedirectToHttpsIfPossible = false,
             DisableHiveBasedSetting            = true,
             DenyRobots                 = true,
             UseGlobalCertVault         = false,
             LocalHostOnly              = false,
             HttpPortsList              = new int[] { Consts.Ports.StressMonServerPort }.ToList(),
             HttpsPortsList             = new List <int>(),
             UseKestrelWithIPACoreStack = false,
         },
                                      true);
     }
     catch
     {
         this._DisposeSafe();
         throw;
     }
 }
Example #4
0
 public static HttpServer <CgiHttpServerBuilder> StartServer(HttpServerOptions httpCfg, CgiHttpServer cgiHttpServer, CancellationToken cancel = default)
 => new HttpServer <CgiHttpServerBuilder>(httpCfg, cgiHttpServer, cancel);