多配置文件的支持
This commit is contained in:
parent
1900b77ba9
commit
fade24de0e
@ -1,6 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace FastGithub
|
namespace FastGithub
|
||||||
{
|
{
|
||||||
@ -30,6 +32,13 @@ namespace FastGithub
|
|||||||
{
|
{
|
||||||
c.ValidateOnBuild = false;
|
c.ValidateOnBuild = false;
|
||||||
})
|
})
|
||||||
|
.ConfigureAppConfiguration(c =>
|
||||||
|
{
|
||||||
|
foreach (var jsonFile in Directory.GetFiles(".", "appsettings.*.json"))
|
||||||
|
{
|
||||||
|
c.AddJsonFile(Path.GetFileName(jsonFile), true, true);
|
||||||
|
}
|
||||||
|
})
|
||||||
.ConfigureServices((ctx, services) =>
|
.ConfigureServices((ctx, services) =>
|
||||||
{
|
{
|
||||||
services.AddDnsServer();
|
services.AddDnsServer();
|
||||||
|
|||||||
35
FastGithub/appsettings.github.json
Normal file
35
FastGithub/appsettings.github.json
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
// 新增的子配置文件appsettings.*.json,重启应用程序才生效
|
||||||
"FastGithub": {
|
"FastGithub": {
|
||||||
"PureDns": { // 用于解析DomainConfigs的域名
|
"PureDns": { // 用于解析DomainConfigs的域名
|
||||||
"IPAddress": "127.0.0.1",
|
"IPAddress": "127.0.0.1",
|
||||||
@ -8,82 +9,17 @@
|
|||||||
"IPAddress": "114.114.114.114",
|
"IPAddress": "114.114.114.114",
|
||||||
"Port": 53
|
"Port": 53
|
||||||
},
|
},
|
||||||
"DomainConfigs": { // 域名的*表示除.之外0到多个任意字符
|
"DomainConfigs": {
|
||||||
"github.com": {
|
"*.x.y.z.com": { // 域名的*表示除.之外0到多个任意字符
|
||||||
"TlsSni": false, // 指示tls握手时是否发送SNI
|
"TlsSni": false, // 指示tls握手时是否发送SNI
|
||||||
"TlsSniPattern": null, // SNI表达式,@domain变量表示取域名值 @ipadress变量表示取ip @random变量表示取随机值,其它字符保留不替换
|
"TlsSniPattern": null, // SNI表达式,@domain变量表示取域名值 @ipadress变量表示取ip @random变量表示取随机值,其它字符保留不替换
|
||||||
"TlsIgnoreNameMismatch": false, // 是否忽略服务器证书域名不匹配,当不发送SNI时服务器可能发回域名不匹配的证书,默认为false
|
"TlsIgnoreNameMismatch": false, // 是否忽略服务器证书域名不匹配,当不发送SNI时服务器可能发回域名不匹配的证书,默认为false
|
||||||
"Timeout": null, // 请求超时时长,格式为"00:02:00",默认为null
|
"Timeout": null, // 请求超时时长,格式为"00:02:00",默认为null
|
||||||
"Destination": null // 请求目的地,格式为绝对或相对Uri,默认null
|
"Destination": null, // 请求目的地,格式为绝对或相对Uri,默认null
|
||||||
//"Response": { // 阻断请求直接响应,设置了Response其它配置都不起作用了
|
"Response": { // 阻断请求直接响应,设置了Response其它配置都不起作用了
|
||||||
// "StatusCode": 404,
|
"StatusCode": 404, // 响应的状态码
|
||||||
// "ContentType": "text/plain;charset=utf-8",
|
"ContentType": "text/plain;charset=utf-8", // 如果有ContentValue,就要指示ContentType
|
||||||
// "ContentValue": "阻断的请求"
|
"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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
45
FastGithub/appsettings.stackoverflow.json
Normal file
45
FastGithub/appsettings.stackoverflow.json
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user