示例#1
0
        public static void Main(string[] args)
        {
            Config            = new AoiConfig();
            Config.RankEnable = true;

            if (Config.CacheEnable && Config.GeoCacheEnable || Config.RankEnable)
            {
                Console.WriteLine(
                    "This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com");
                var timer = new Timer(100)
                {
                    Enabled = true, AutoReset = true
                };
                timer.Elapsed += (_, _) =>
                {
                    timer.Interval = 3600000 * 24;
                    GetFileUpdate("GeoLite2-ASN.mmdb", Config.MaxmindAsnDbUrl);
                    GetFileUpdate("GeoLite2-City.mmdb", Config.MaxmindCityDbUrl);
                };
            }

            if (Config.ChinaListEnable)
            {
                var timer = new Timer(100)
                {
                    Enabled = true, AutoReset = true
                };
                timer.Elapsed += (_, _) =>
                {
                    timer.Interval = 3600000 * 24;
                    GetFileUpdate("China_WhiteList.List", "https://mili.one/china_whitelist.txt");
                    Task.Run(() =>
                    {
                        while (true)
                        {
                            if (File.Exists(DNSChinaConfig.Config.ChinaListPath))
                            {
                                File.ReadAllLines(DNSChinaConfig.Config.ChinaListPath).ToList()
                                .ConvertAll(DomainName.Parse);
                                break;
                            }

                            Thread.Sleep(1000);
                        }
                    });
                };
            }

            File.WriteAllText("Token.txt", Config.AdminToken);
            CreateHostBuilder(args).Build().Run();
        }
示例#2
0
        public static void Main(string[] args)
        {
            Config = new AoiConfig
            {
                RankEnable      = true,
                ChinaListEnable = true,
                UseResolveRoute = true,
                UseAdminRoute   = true,
                TransIdEnable   = true
            };

            DNSRank.UseS3    = false;
            DNSRank.S3Client = new AmazonS3Client(
                "KeyID",
                "ApplicationKey",
                new AmazonS3Config
            {
                ServiceURL = "https://s3.us-west-000.backblazeb2.com/"
            }
                );

            if (Config.CacheEnable && Config.GeoCacheEnable || Config.RankEnable)
            {
                Console.WriteLine(
                    "This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com");
                var timer = new Timer(100)
                {
                    Enabled = true, AutoReset = true
                };
                timer.Elapsed += (_, _) =>
                {
                    timer.Interval = 3600000 * 24;
                    GetFileUpdate("GeoLite2-ASN.mmdb", Config.MaxmindAsnDbUrl);
                    GetFileUpdate("GeoLite2-City.mmdb", Config.MaxmindCityDbUrl);
                };
            }

            if (Config.ChinaListEnable)
            {
                var timer = new Timer(100)
                {
                    Enabled = true, AutoReset = true
                };
                timer.Elapsed += (_, _) =>
                {
                    timer.Interval = 3600000 * 24;
                    GetFileUpdate("China_WhiteList.List", DNSChinaConfig.Config.ChinaListUrl);
                    Task.Run(() =>
                    {
                        while (true)
                        {
                            if (File.Exists(DNSChinaConfig.Config.ChinaListPath))
                            {
                                DNSChina.ChinaList = File.ReadAllLines(DNSChinaConfig.Config.ChinaListPath).ToList()
                                                     .ConvertAll(DomainName.Parse);
                                break;
                            }

                            Thread.Sleep(1000);
                        }
                    });
                };
            }

            File.WriteAllText("Token.txt", Config.AdminToken);
            CreateHostBuilder(args).Build().Run();
        }