浏览代码

拆分配置文件

陈国伟 4 年之前
父节点
当前提交
b1f3a79122

+ 1 - 1
FastGithub.Scanner/GithubLookupFactoryOptions.cs

@@ -5,7 +5,7 @@ namespace FastGithub.Scanner
     /// <summary>
     /// 域名
     /// </summary>
-    [Options("Github:Lookup")]
+    [Options("Lookup")]
     sealed class GithubLookupFactoryOptions
     {
         /// <summary>

+ 1 - 1
FastGithub.Scanner/GithubScanOptions.cs

@@ -5,7 +5,7 @@ namespace FastGithub.Scanner
     /// <summary>
     /// 扫描选项
     /// </summary>
-    [Options("Github:Scan")]
+    [Options("Scan")]
     sealed class GithubScanOptions
     {
         /// <summary>

+ 1 - 1
FastGithub.Scanner/LookupProviders/GithubMetaProviderOptions.cs

@@ -5,7 +5,7 @@ namespace FastGithub.Scanner.LookupProviders
     /// <summary>
     /// Github公开的域名与ip关系提供者选项
     /// </summary>
-    [Options("Github:Lookup:GithubMetaProvider")]
+    [Options("Lookup:GithubMetaProvider")]
     sealed class GithubMetaProviderOptions
     {
         /// <summary>

+ 1 - 1
FastGithub.Scanner/LookupProviders/IPAddressComProviderOptions.cs

@@ -3,7 +3,7 @@
     /// <summary>
     /// ipaddress.com的域名与ip关系提供者选项
     /// </summary>
-    [Options("Github:Lookup:IPAddressComProvider")]
+    [Options("Lookup:IPAddressComProvider")]
     sealed class IPAddressComProviderOptions
     {
         /// <summary>

+ 1 - 1
FastGithub.Scanner/LookupProviders/PublicDnsProviderOptions.cs

@@ -5,7 +5,7 @@ namespace FastGithub.Scanner.LookupProviders
     /// <summary>
     /// 公共dns的域名与ip关系提供者选项
     /// </summary>
-    [Options("Github:Lookup:PublicDnsProvider")]
+    [Options("Lookup:PublicDnsProvider")]
     sealed class PublicDnsProviderOptions
     {
         /// <summary>

+ 1 - 1
FastGithub.Scanner/ScanMiddlewares/HttpsScanOptions.cs

@@ -6,7 +6,7 @@ namespace FastGithub.Scanner.ScanMiddlewares
     /// <summary>
     /// https扫描选项
     /// </summary>
-    [Options("Github:Scan:HttpsScan")]
+    [Options("Scan:HttpsScan")]
     sealed class HttpsScanOptions
     {
         /// <summary>

+ 1 - 1
FastGithub.Scanner/ScanMiddlewares/TcpScanOptions.cs

@@ -5,7 +5,7 @@ namespace FastGithub.Scanner.ScanMiddlewares
     /// <summary>
     /// tcp扫描选项
     /// </summary>
-    [Options("Github:Scan:TcpScan")]
+    [Options("Scan:TcpScan")]
     sealed class TcpScanOptions
     {
         /// <summary>

+ 3 - 0
FastGithub/FastGithub.csproj

@@ -23,6 +23,9 @@
 	</ItemGroup>
 
 	<ItemGroup>
+		<None Update="appsettings.github.json">
+		  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</None>
 		<None Update="appsettings.json">
 			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
 		</None>

+ 10 - 1
FastGithub/Program.cs

@@ -1,4 +1,6 @@
-using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Hosting;
+using System.IO;
 
 namespace FastGithub
 {
@@ -24,6 +26,13 @@ namespace FastGithub
                 .CreateDefaultBuilder(args)
                 .UseWindowsService()
                 .UseBinaryPathContentRoot()
+                .ConfigureAppConfiguration(c =>
+                {
+                    foreach (var jsonFile in Directory.GetFiles(".", "appsettings.*.json"))
+                    {
+                        c.AddJsonFile(jsonFile, optional: true);
+                    }
+                })
                 .ConfigureServices((ctx, services) =>
                 {
                     services.AddAppUpgrade();

+ 1 - 1
FastGithub/README.MD

@@ -12,4 +12,4 @@ github定制版的dns服务,解析github最优的ip
 ### 以windows服务运行
 以管理员身份运行cmd,键入如下命令,其中D:\Softs为软件实际目录
 * D:\Softs\FastGithub.exe start // 安装并启动服务
-* D:\Softs\FastGithub.exe stop  // 卸载并删除服务
+* D:\Softs\FastGithub.exe stop  // 卸载并删除服务 

+ 39 - 0
FastGithub/appsettings.github.json

@@ -0,0 +1,39 @@
+{
+  "Lookup": { // ip查找
+    "Domains": [ // 查找的域名,下面是github最主要的域名
+      "github.com",
+      "api.github.com",
+      "collector.githubapp.com",
+      "github.githubassets.com",
+      "raw.githubusercontent.com",
+      "avatars.githubusercontent.com",
+      "favicons.githubusercontent.com"
+    ]
+  },
+  "Scan": {
+    "HttpsScan": {
+      "Rules": { // 域名扫描规则,缺失的域名,将默认HEAD请求到域名的根路径
+        "github.com": {
+          "Method": "HEAD",
+          "Path": "/xljiulang/FastGithub"
+        },
+        "github.githubassets.com": {
+          "Method": "HEAD",
+          "Path": "/favicons/favicon.png"
+        },
+        "raw.githubusercontent.com": {
+          "Method": "HEAD",
+          "Path": "/xljiulang/FastGithub/master/README.md"
+        },
+        "avatars.githubusercontent.com": {
+          "Method": "HEAD",
+          "Path": "/u/8308014?s=40&v=4"
+        },
+        "favicons.githubusercontent.com": {
+          "Method": "HEAD",
+          "Path": "/github.com"
+        }
+      }
+    }
+  }
+}

+ 32 - 65
FastGithub/appsettings.json

@@ -4,72 +4,39 @@
     "GithubTTL": "00:10:00", // github相关域名解析结果的存活时长
     "SetToLocalMachine": true // 是否设置本机使用此dns(仅支持windows)
   },
-  "Github": {
-    "Lookup": { // ip查找
-      "Domains": [ // 查找的域名,下面是github最主要的域名
-        "github.com",
-        "api.github.com",
-        "collector.githubapp.com",
-        "github.githubassets.com",
-        "raw.githubusercontent.com",
-        "avatars.githubusercontent.com",
-        "favicons.githubusercontent.com"
-      ],
-      "IPAddressComProvider": {
-        "Enable": true // 是从启用从address.com查找ip
-      },
-      "GithubMetaProvider": {
-        "Enable": true, // 是否从github获取ip列表
-        "MetaUri": "https://gitee.com/jiulang/fast-github/raw/master/FastGithub/meta.json"
-      },
-      "PublicDnsProvider": {
-        "Enable": true, // 是否需要从dns服务器查找ip
-        "Timeout": "00:00:00.100", // dns查询超时时长
-        "Dnss": [ // dns服务器列表
-          "1.2.4.8",
-          "8.8.8.8",
-          "223.5.5.5",
-          "123.125.81.6",
-          "180.76.76.76",
-          "119.29.29.29",
-          "208.67.220.220",
-          "114.114.114.114"
-        ]
-      }
+  "Lookup": { // ip查找     
+    "IPAddressComProvider": {
+      "Enable": true // 是从启用从address.com查找ip
     },
-    "Scan": {
-      "FullScanInterval": "02:00:00", // 完整扫描时间间隔
-      "ResultScanInterval": "00:01:00", // 结果扫描时间间隔
-      "TcpScan": {
-        "Timeout": "00:00:01", // tcp扫描超时时间
-        "CacheExpiration": "00:30:00" // 扫描结果缓存时长
-      },
-      "HttpsScan": {
-        "Timeout": "00:00:05", // https扫描超时时间
-        "ConnectionClose": false, // 是否使用https短连接
-        "Rules": { // 域名扫描规则,缺失的域名,将默认HEAD请求到域名的根路径
-          "github.com": {
-            "Method": "HEAD",
-            "Path": "/xljiulang/FastGithub"
-          },
-          "github.githubassets.com": {
-            "Method": "HEAD",
-            "Path": "/favicons/favicon.png"
-          },
-          "raw.githubusercontent.com": {
-            "Method": "HEAD",
-            "Path": "/xljiulang/FastGithub/master/README.md"
-          },
-          "avatars.githubusercontent.com": {
-            "Method": "HEAD",
-            "Path": "/u/8308014?s=40&v=4"
-          },
-          "favicons.githubusercontent.com": {
-            "Method": "HEAD",
-            "Path": "/github.com"
-          }
-        }
-      }
+    "GithubMetaProvider": {
+      "Enable": true, // 是否从github获取ip列表
+      "MetaUri": "https://gitee.com/jiulang/fast-github/raw/master/FastGithub/meta.json"
+    },
+    "PublicDnsProvider": {
+      "Enable": true, // 是否需要从dns服务器查找ip
+      "Timeout": "00:00:00.100", // dns查询超时时长
+      "Dnss": [ // dns服务器列表
+        "1.2.4.8",
+        "8.8.8.8",
+        "223.5.5.5",
+        "123.125.81.6",
+        "180.76.76.76",
+        "119.29.29.29",
+        "208.67.220.220",
+        "114.114.114.114"
+      ]
+    }
+  },
+  "Scan": {
+    "FullScanInterval": "02:00:00", // 完整扫描时间间隔
+    "ResultScanInterval": "00:01:00", // 结果扫描时间间隔
+    "TcpScan": {
+      "Timeout": "00:00:01", // tcp扫描超时时间
+      "CacheExpiration": "00:30:00" // 扫描结果缓存时长
+    },
+    "HttpsScan": {
+      "Timeout": "00:00:05", // https扫描超时时间
+      "ConnectionClose": false // 是否使用https短连接       
     }
   },
   "Logging": {