mirror of
https://github.com/239573049/FastGateway.git
synced 2026-10-29 06:03:43 +08:00
增加IP请求头
This commit is contained in:
@@ -8,11 +8,11 @@ public class GatewayBackgroundService(
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
// 数据库迁移
|
||||
freeSql.CodeFirst.SyncStructure(typeof(RouteEntity), typeof(ClusterEntity), typeof(CertificateEntity), typeof(StaticFileProxyEntity), typeof(SettingEntity));
|
||||
freeSql.CodeFirst.SyncStructure(typeof(RouteEntity), typeof(ClusterEntity), typeof(CertificateEntity),
|
||||
typeof(StaticFileProxyEntity));
|
||||
|
||||
// 首次启动时更新配置
|
||||
await gatewayService.RefreshConfig();
|
||||
await certificateService.RefreshConfig();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,5 +48,6 @@ public sealed class RouteEntity : Entity
|
||||
/// <summary>
|
||||
/// 匹配域名
|
||||
/// </summary>
|
||||
[Column(MapType = typeof(string), StringLength = -1)]
|
||||
public string[] Hosts { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
namespace Gateway.Entities;
|
||||
|
||||
public sealed class SettingEntity : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置名称
|
||||
/// </summary>
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 显示名称
|
||||
/// </summary>
|
||||
public string? DisplayName { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 设置描述
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认值
|
||||
/// </summary>
|
||||
public string? DefaultValue { get; set; }
|
||||
|
||||
public Dictionary<string, string> ExtraProperties { get; set; } = new();
|
||||
}
|
||||
@@ -26,3 +26,5 @@ global using Microsoft.IdentityModel.Tokens;
|
||||
global using System.Collections.Concurrent;
|
||||
global using Microsoft.AspNetCore.Http.Features;
|
||||
global using System.Net.NetworkInformation;
|
||||
global using Gateway.BackgroundServices;
|
||||
global using Gateway.Tunnel;
|
||||
@@ -13,7 +13,7 @@ public static class StringHelper
|
||||
string[] units = ["B", "KB", "MB", "GB", "TB", "PB", "EB"];
|
||||
|
||||
double formattedSize = bytes;
|
||||
int unitIndex = 0;
|
||||
var unitIndex = 0;
|
||||
|
||||
while (formattedSize >= scale && unitIndex < units.Length - 1)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Gateway.Options;
|
||||
|
||||
public class GatewayOptions
|
||||
{
|
||||
public const string Name = "Gateway";
|
||||
|
||||
/// <summary>
|
||||
/// Gateway版本
|
||||
/// </summary>
|
||||
public static string? Version { get; set; }
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
#region FreeSql类型转换
|
||||
|
||||
using Gateway.BackgroundServices;
|
||||
using Gateway.Tunnel;
|
||||
|
||||
Utils.TypeHandlers.TryAdd(typeof(Dictionary<string, string>), new StringJsonHandler<Dictionary<string, string>>());
|
||||
Utils.TypeHandlers.TryAdd(typeof(List<DestinationsEntity>), new StringJsonHandler<List<DestinationsEntity>>());
|
||||
Utils.TypeHandlers.TryAdd(typeof(string[]), new StringJsonHandler<string[]>());
|
||||
@@ -27,6 +24,9 @@ var freeSql = new FreeSqlBuilder()
|
||||
builder.Configuration.GetSection(nameof(JwtOptions))
|
||||
.Get<JwtOptions>();
|
||||
|
||||
builder.Configuration.GetSection(GatewayOptions.Name)
|
||||
.Get<GatewayOptions>();
|
||||
|
||||
// 获取环境变量
|
||||
var https_password = Environment.GetEnvironmentVariable("HTTPS_PASSWORD") ?? "dd666666";
|
||||
var https_file = Environment.GetEnvironmentVariable("HTTPS_FILE") ?? "gateway.pfx";
|
||||
|
||||
@@ -13,5 +13,8 @@
|
||||
"JwtOptions": {
|
||||
"Secret": "Das*ist*ein*tokasdf*Passwort*123@#$%^",
|
||||
"ExpireDay": 30
|
||||
},
|
||||
"Gateway": {
|
||||
"Version": "1.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user