多配置文件的支持

This commit is contained in:
xljiulang 2021-07-22 22:49:31 +08:00
parent 1900b77ba9
commit fade24de0e
4 changed files with 97 additions and 72 deletions

View File

@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.IO;
namespace FastGithub
{
@ -30,6 +32,13 @@ namespace FastGithub
{
c.ValidateOnBuild = false;
})
.ConfigureAppConfiguration(c =>
{
foreach (var jsonFile in Directory.GetFiles(".", "appsettings.*.json"))
{
c.AddJsonFile(Path.GetFileName(jsonFile), true, true);
}
})
.ConfigureServices((ctx, services) =>
{
services.AddDnsServer();

View File

@ -0,0 +1,35 @@
{
"FastGithub": {
"DomainConfigs": {
"github.com": {
"TlsSni": false
},
"githubstatus.com": {
"TlsSni": false
},
"*.github.com": {
"TlsSni": false
},
"*.github.io": {
"TlsSni": false,
"TlsIgnoreNameMismatch": true
},
"*.githubapp.com": {
"TlsSni": false,
"TlsIgnoreNameMismatch": true
},
"*.githubassets.com": {
"TlsSni": false,
"TlsIgnoreNameMismatch": true
},
"*.githubusercontent.com": {
"TlsSni": false,
"TlsIgnoreNameMismatch": true
},
"*github*.s3.amazonaws.com": {
"TlsSni": false,
"TlsIgnoreNameMismatch": true
}
}
}
}

View File

@ -1,4 +1,5 @@
{
// appsettings.*.json
"FastGithub": {
"PureDns": { // DomainConfigs
"IPAddress": "127.0.0.1",
@ -8,82 +9,17 @@
"IPAddress": "114.114.114.114",
"Port": 53
},
"DomainConfigs": { // *.0
"github.com": {
"DomainConfigs": {
"*.x.y.z.com": { // *.0
"TlsSni": false, // tlsSNI
"TlsSniPattern": null, // SNI@domain @ipadressip @random
"TlsIgnoreNameMismatch": false, // SNIfalse
"Timeout": null, // "00:02:00"null
"Destination": null // Urinull
//"Response": { // Response
// "StatusCode": 404,
// "ContentType": "text/plain;charset=utf-8",
// "ContentValue": "阻断的请求"
//}
},
"githubstatus.com": {
"TlsSni": false
},
"*.github.com": {
"TlsSni": false
},
"*.github.io": {
"TlsSni": false,
"TlsIgnoreNameMismatch": true
},
"*.githubapp.com": {
"TlsSni": false,
"TlsIgnoreNameMismatch": true
},
"*.githubassets.com": {
"TlsSni": false,
"TlsIgnoreNameMismatch": true
},
"*.githubusercontent.com": {
"TlsSni": false,
"TlsIgnoreNameMismatch": true
},
"*github*.s3.amazonaws.com": {
"TlsSni": false,
"TlsIgnoreNameMismatch": true
},
"ajax.googleapis.com": {
"TlsSni": true,
"Destination": "https://gapis.geekzu.org/ajax/"
},
"fonts.googleapis.com": {
"TlsSni": true,
"Destination": "https://fonts.geekzu.org/"
},
"themes.googleusercontent.com": {
"TlsSni": true,
"Destination": "https://gapis.geekzu.org/g-themes/"
},
"fonts.gstatic.com": {
"TlsSni": true,
"Destination": "https://gapis.geekzu.org/g-fonts/"
},
"secure.gravatar.com": {
"TlsSni": true,
"Destination": "https://sdn.geekzu.org/"
},
"*.gravatar.com": {
"TlsSni": true,
"Destination": "https://fdn.geekzu.org/"
},
"i.stack.imgur.com": {
"Response": {
"StatusCode": 404
}
},
"lh*.googleusercontent.com": {
"Response": {
"StatusCode": 404
}
},
"www.google.com": {
"Response": {
"StatusCode": 404
"Destination": null, // Urinull
"Response": { // Response
"StatusCode": 404, //
"ContentType": "text/plain;charset=utf-8", // ContentValueContentType
"ContentValue": "这是一个用于示范配置的域名" //
}
}
}

View File

@ -0,0 +1,45 @@
{
"FastGithub": {
"DomainConfigs": {
"ajax.googleapis.com": {
"TlsSni": true,
"Destination": "https://gapis.geekzu.org/ajax/"
},
"fonts.googleapis.com": {
"TlsSni": true,
"Destination": "https://fonts.geekzu.org/"
},
"themes.googleusercontent.com": {
"TlsSni": true,
"Destination": "https://gapis.geekzu.org/g-themes/"
},
"fonts.gstatic.com": {
"TlsSni": true,
"Destination": "https://gapis.geekzu.org/g-fonts/"
},
"secure.gravatar.com": {
"TlsSni": true,
"Destination": "https://sdn.geekzu.org/"
},
"*.gravatar.com": {
"TlsSni": true,
"Destination": "https://fdn.geekzu.org/"
},
"i.stack.imgur.com": {
"Response": {
"StatusCode": 404
}
},
"lh*.googleusercontent.com": {
"Response": {
"StatusCode": 404
}
},
"www.google.com": {
"Response": {
"StatusCode": 404
}
}
}
}
}