278 changed files with 6977 additions and 3840 deletions
@ -1,26 +0,0 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
|
||||
|
|
||||
<PropertyGroup> |
|
||||
<TargetFramework>netstandard2.0</TargetFramework> |
|
||||
<RootNamespace /> |
|
||||
</PropertyGroup> |
|
||||
|
|
||||
<ItemGroup> |
|
||||
<PackageReference Include="Volo.Abp.Localization" Version="2.9.0" /> |
|
||||
</ItemGroup> |
|
||||
|
|
||||
<ItemGroup> |
|
||||
<None Remove="LINGYUN\ApiGateWay\Admin\Localization\DomainShared\en.json" /> |
|
||||
<None Remove="LINGYUN\ApiGateWay\Admin\Localization\DomainShared\zh-Hans.json" /> |
|
||||
</ItemGroup> |
|
||||
|
|
||||
<ItemGroup> |
|
||||
<EmbeddedResource Include="LINGYUN\ApiGateWay\Admin\Localization\DomainShared\en.json" /> |
|
||||
<EmbeddedResource Include="LINGYUN\ApiGateWay\Admin\Localization\DomainShared\zh-Hans.json" /> |
|
||||
</ItemGroup> |
|
||||
|
|
||||
<ItemGroup> |
|
||||
<Folder Include="LINGYUN\ApiGateWay\Admin\Routes\" /> |
|
||||
</ItemGroup> |
|
||||
|
|
||||
</Project> |
|
||||
@ -1,32 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Localization; |
|
||||
using Volo.Abp.Localization; |
|
||||
using Volo.Abp.Localization.ExceptionHandling; |
|
||||
using Volo.Abp.Modularity; |
|
||||
using Volo.Abp.VirtualFileSystem; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin |
|
||||
{ |
|
||||
[DependsOn(typeof(AbpLocalizationModule))] |
|
||||
public class ApiGateWayAdminDomainSharedModule : AbpModule |
|
||||
{ |
|
||||
public override void ConfigureServices(ServiceConfigurationContext context) |
|
||||
{ |
|
||||
Configure<AbpVirtualFileSystemOptions>(options => |
|
||||
{ |
|
||||
options.FileSets.AddEmbedded<ApiGateWayAdminDomainSharedModule>(); |
|
||||
}); |
|
||||
|
|
||||
Configure<AbpLocalizationOptions>(options => |
|
||||
{ |
|
||||
options.Resources |
|
||||
.Add<ApiGateWayAdminResource>("zh-Hans") |
|
||||
.AddVirtualJson("/LINGYUN/ApiGateWay/Admin/Localization/Resources"); |
|
||||
}); |
|
||||
|
|
||||
Configure<AbpExceptionLocalizationOptions>(options => |
|
||||
{ |
|
||||
options.MapCodeNamespace("ApiGateWayAdmin", typeof(ApiGateWayAdminResource)); |
|
||||
}); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,8 +0,0 @@ |
|||||
namespace LINGYUN.ApiGateWay.Admin |
|
||||
{ |
|
||||
public class HostAndPortConsts |
|
||||
{ |
|
||||
// 计算机名最大长度
|
|
||||
public const int MaxHostLength = 255; |
|
||||
} |
|
||||
} |
|
||||
@ -1,7 +0,0 @@ |
|||||
namespace LINGYUN.ApiGateWay.Admin.Http |
|
||||
{ |
|
||||
public class HttpDelegatingHandlerConsts |
|
||||
{ |
|
||||
public const int MaxNameLength = 256; |
|
||||
} |
|
||||
} |
|
||||
@ -1,10 +0,0 @@ |
|||||
using Volo.Abp.Localization; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Localization |
|
||||
{ |
|
||||
[LocalizationResourceName("ApiGatewayAdmin")] |
|
||||
public class ApiGateWayAdminResource |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
@ -1,5 +0,0 @@ |
|||||
{ |
|
||||
"culture": "en", |
|
||||
"texts": { |
|
||||
} |
|
||||
} |
|
||||
@ -1,6 +0,0 @@ |
|||||
{ |
|
||||
"culture": "zh-Hans", |
|
||||
"texts": { |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
@ -1,13 +0,0 @@ |
|||||
namespace LINGYUN.ApiGateWay.Admin |
|
||||
{ |
|
||||
public class RouteGroupAppKey |
|
||||
{ |
|
||||
public string AppId { get; } |
|
||||
public string AppName { get; } |
|
||||
public RouteGroupAppKey(string appId, string appName) |
|
||||
{ |
|
||||
AppId = appId; |
|
||||
AppName = appName; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,17 +0,0 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
|
||||
|
|
||||
<PropertyGroup> |
|
||||
<TargetFramework>netstandard2.0</TargetFramework> |
|
||||
<RootNamespace /> |
|
||||
</PropertyGroup> |
|
||||
|
|
||||
<ItemGroup> |
|
||||
<PackageReference Include="Volo.Abp.Caching" Version="2.9.0" /> |
|
||||
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="2.9.0" /> |
|
||||
</ItemGroup> |
|
||||
|
|
||||
<ItemGroup> |
|
||||
<ProjectReference Include="..\LINGYUN.ApiGateWay.Admin.Domain.Shared\LINGYUN.ApiGateWay.Admin.Domain.Shared.csproj" /> |
|
||||
</ItemGroup> |
|
||||
|
|
||||
</Project> |
|
||||
@ -1,12 +0,0 @@ |
|||||
using Volo.Abp.Domain; |
|
||||
using Volo.Abp.Modularity; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin |
|
||||
{ |
|
||||
[DependsOn( |
|
||||
typeof(ApiGateWayAdminDomainSharedModule), |
|
||||
typeof(AbpDddDomainModule))] |
|
||||
public class ApiGateWayAdminDomainModule : AbpModule |
|
||||
{ |
|
||||
} |
|
||||
} |
|
||||
@ -1,12 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Text; |
|
||||
using Volo.Abp.Domain.Entities.Auditing; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Globals |
|
||||
{ |
|
||||
public class Global : FullAuditedAggregateRoot<Guid> |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
@ -1,62 +0,0 @@ |
|||||
using JetBrains.Annotations; |
|
||||
using System; |
|
||||
using Volo.Abp; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin |
|
||||
{ |
|
||||
public class HostAndPort : Entity<Guid> |
|
||||
{ |
|
||||
public virtual string Host { get; protected set; } |
|
||||
public virtual int? Port { get; protected set; } |
|
||||
protected HostAndPort() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public HostAndPort(Guid id, [NotNull] string host, int? port = null) |
|
||||
{ |
|
||||
Id = id; |
|
||||
BindHost(host, port); |
|
||||
} |
|
||||
|
|
||||
public void BindHost([NotNull] string host, int? port = null) |
|
||||
{ |
|
||||
Check.NotNullOrWhiteSpace(host, nameof(host), HostAndPortConsts.MaxHostLength); |
|
||||
Host = host; |
|
||||
Port = port; |
|
||||
} |
|
||||
|
|
||||
public override int GetHashCode() |
|
||||
{ |
|
||||
if (!Host.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
if (Port.HasValue) |
|
||||
{ |
|
||||
return Host.GetHashCode() & Port.Value; |
|
||||
} |
|
||||
return Host.GetHashCode(); |
|
||||
} |
|
||||
return base.GetHashCode(); |
|
||||
} |
|
||||
|
|
||||
public override bool Equals(object obj) |
|
||||
{ |
|
||||
if (obj == null || |
|
||||
Host.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
if (obj is HostAndPort hostAndPort) |
|
||||
{ |
|
||||
if (Port.HasValue) |
|
||||
{ |
|
||||
return hostAndPort.Host.Equals(Host) && |
|
||||
Port.Equals(hostAndPort.Port); |
|
||||
} |
|
||||
return hostAndPort.Host.Equals(Host); |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,13 +0,0 @@ |
|||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Http |
|
||||
{ |
|
||||
public class DownstreamHttpMethod : HttpMethod |
|
||||
{ |
|
||||
public DownstreamHttpMethod(Guid id, string method) |
|
||||
: base(id, method) |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,45 +0,0 @@ |
|||||
using JetBrains.Annotations; |
|
||||
using System; |
|
||||
using Volo.Abp; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Http |
|
||||
{ |
|
||||
public class HttpDelegatingHandler : Entity<Guid> |
|
||||
{ |
|
||||
public virtual string Name { get; protected set; } |
|
||||
protected HttpDelegatingHandler() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public HttpDelegatingHandler(Guid id, [NotNull] string name) |
|
||||
{ |
|
||||
Id = id; |
|
||||
Name = Check.NotNullOrWhiteSpace(name, nameof(name), HttpDelegatingHandlerConsts.MaxNameLength); |
|
||||
} |
|
||||
|
|
||||
public override int GetHashCode() |
|
||||
{ |
|
||||
if (!Name.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return Name.GetHashCode(); |
|
||||
} |
|
||||
return base.GetHashCode(); |
|
||||
} |
|
||||
|
|
||||
public override bool Equals(object obj) |
|
||||
{ |
|
||||
if (obj == null || |
|
||||
Name.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
if (obj is HttpDelegatingHandler handler) |
|
||||
{ |
|
||||
return Name.Equals(handler.Name, StringComparison.CurrentCultureIgnoreCase); |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,43 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Http |
|
||||
{ |
|
||||
public class HttpHandler : Entity<Guid> |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 每台服务器最大连接数
|
|
||||
/// </summary>
|
|
||||
public virtual int? MaxConnectionsPerServer { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 允许自动重定向
|
|
||||
/// </summary>
|
|
||||
public virtual bool AllowAutoRedirect { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 使用Cookie容器
|
|
||||
/// </summary>
|
|
||||
public virtual bool UseCookieContainer { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 启用跟踪
|
|
||||
/// </summary>
|
|
||||
public virtual bool UseTracing { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 启用代理
|
|
||||
/// </summary>
|
|
||||
public virtual bool UseProxy { get; set; } |
|
||||
protected HttpHandler() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public HttpHandler(Guid id) |
|
||||
{ |
|
||||
Id = id; |
|
||||
} |
|
||||
|
|
||||
public void ChangeMaxConnection(int? maxConnection = 1000) |
|
||||
{ |
|
||||
MaxConnectionsPerServer = maxConnection; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,51 +0,0 @@ |
|||||
using JetBrains.Annotations; |
|
||||
using System; |
|
||||
using Volo.Abp; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Http |
|
||||
{ |
|
||||
public abstract class HttpHeader : Entity<Guid> |
|
||||
{ |
|
||||
public virtual string Key { get; protected set; } |
|
||||
public virtual string Value { get; protected set; } |
|
||||
|
|
||||
protected HttpHeader() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
protected HttpHeader(Guid id, [NotNull] string key, [NotNull] string value) |
|
||||
{ |
|
||||
Id = id; |
|
||||
Key = Check.NotNullOrWhiteSpace(key, nameof(key)); |
|
||||
Value = Check.NotNullOrWhiteSpace(value, nameof(value)); |
|
||||
} |
|
||||
|
|
||||
public override int GetHashCode() |
|
||||
{ |
|
||||
if (!Key.IsNullOrWhiteSpace() && |
|
||||
!Value.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return Key.GetHashCode() & Value.GetHashCode(); |
|
||||
} |
|
||||
return base.GetHashCode(); |
|
||||
} |
|
||||
|
|
||||
public override bool Equals(object obj) |
|
||||
{ |
|
||||
if (obj == null || |
|
||||
Key.IsNullOrWhiteSpace() || |
|
||||
Value.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
if (obj is HttpHeader httpHeader) |
|
||||
{ |
|
||||
return httpHeader.Key.Equals(Key, StringComparison.CurrentCultureIgnoreCase) && |
|
||||
httpHeader.Value.Equals(Value, StringComparison.CurrentCultureIgnoreCase); |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,45 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Http |
|
||||
{ |
|
||||
public abstract class HttpMethod : Entity<Guid> |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Http调用方法
|
|
||||
/// </summary>
|
|
||||
public virtual string Method { get; protected set; } |
|
||||
protected HttpMethod() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
protected HttpMethod(Guid id, string method) |
|
||||
{ |
|
||||
Id = id; |
|
||||
Method = method; |
|
||||
} |
|
||||
|
|
||||
public override int GetHashCode() |
|
||||
{ |
|
||||
if (!Method.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return Method.GetHashCode(); |
|
||||
} |
|
||||
return base.GetHashCode(); |
|
||||
} |
|
||||
|
|
||||
public override bool Equals(object obj) |
|
||||
{ |
|
||||
if (obj == null || |
|
||||
Method.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
if (obj is HttpMethod httpMethod) |
|
||||
{ |
|
||||
return httpMethod.Method.Equals(Method); |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,51 +0,0 @@ |
|||||
using JetBrains.Annotations; |
|
||||
using System; |
|
||||
using Volo.Abp; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Http |
|
||||
{ |
|
||||
public class HttpQuery : Entity<Guid> |
|
||||
{ |
|
||||
public virtual string Key { get; protected set; } |
|
||||
public virtual string Value { get; protected set; } |
|
||||
|
|
||||
protected HttpQuery() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
protected HttpQuery(Guid id, [NotNull] string key, [NotNull] string value) |
|
||||
{ |
|
||||
Id = id; |
|
||||
Key = Check.NotNullOrWhiteSpace(key, nameof(key)); |
|
||||
Value = Check.NotNullOrWhiteSpace(value, nameof(value)); |
|
||||
} |
|
||||
|
|
||||
public override int GetHashCode() |
|
||||
{ |
|
||||
if (!Key.IsNullOrWhiteSpace() && |
|
||||
!Value.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return Key.GetHashCode() & Value.GetHashCode(); |
|
||||
} |
|
||||
return base.GetHashCode(); |
|
||||
} |
|
||||
|
|
||||
public override bool Equals(object obj) |
|
||||
{ |
|
||||
if (obj == null || |
|
||||
Key.IsNullOrWhiteSpace() || |
|
||||
Value.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
if (obj is HttpQuery httpQuery) |
|
||||
{ |
|
||||
return Key.Equals(httpQuery.Key, StringComparison.CurrentCultureIgnoreCase) && |
|
||||
Value.Equals(httpQuery.Value, StringComparison.CurrentCultureIgnoreCase); |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,13 +0,0 @@ |
|||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Http |
|
||||
{ |
|
||||
public class UpstreamHttpMethod : HttpMethod |
|
||||
{ |
|
||||
public UpstreamHttpMethod(Guid id, string method) |
|
||||
: base(id, method) |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,37 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin |
|
||||
{ |
|
||||
public class LoadBalancer : Entity<Guid> |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 负载均衡类型
|
|
||||
/// </summary>
|
|
||||
public virtual string Type { get; private set; } |
|
||||
/// <summary>
|
|
||||
/// 用于Cookie会话密钥
|
|
||||
/// </summary>
|
|
||||
public virtual string Key { get; private set; } |
|
||||
/// <summary>
|
|
||||
/// 会话阻断时间
|
|
||||
/// </summary>
|
|
||||
public virtual int? Expiry { get; private set; } |
|
||||
protected LoadBalancer() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
public LoadBalancer(Guid id, string type, string key, int? expiry = null) |
|
||||
{ |
|
||||
Id = id; |
|
||||
ApplyPolicy(type, key, expiry); |
|
||||
} |
|
||||
|
|
||||
public void ApplyPolicy(string type, string key, int? expiry = null) |
|
||||
{ |
|
||||
Type = type; |
|
||||
Key = key; |
|
||||
Expiry = expiry; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,32 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin |
|
||||
{ |
|
||||
public class QoS : Entity<Guid> |
|
||||
{ |
|
||||
public virtual int? ExceptionsAllowedBeforeBreaking { get; private set; } |
|
||||
|
|
||||
public virtual int? DurationOfBreak { get; private set; } |
|
||||
|
|
||||
public virtual int? TimeoutValue { get; private set; } |
|
||||
|
|
||||
protected QoS() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public QoS(Guid id, int? exceptionsAllowdBeforeBreaking = null, int? durationOfBreak = null, int? timeOut = null) |
|
||||
{ |
|
||||
Id = id; |
|
||||
ApplyPolicy(exceptionsAllowdBeforeBreaking, durationOfBreak, timeOut); |
|
||||
} |
|
||||
|
|
||||
public void ApplyPolicy(int? exceptionsAllowdBeforeBreaking = null, int? durationOfBreak = null, int? timeOut = null) |
|
||||
{ |
|
||||
ExceptionsAllowedBeforeBreaking = exceptionsAllowdBeforeBreaking; |
|
||||
DurationOfBreak = durationOfBreak; |
|
||||
TimeoutValue = timeOut; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,57 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Security; |
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin |
|
||||
{ |
|
||||
public class RateLimitRule : Entity<Guid> |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 客户端白名单列表,多个以分号分隔
|
|
||||
/// </summary>
|
|
||||
public virtual ICollection<RouteClientWhite> ClientWhiteList { get; private set; } |
|
||||
/// <summary>
|
|
||||
/// 是否启用流量现值
|
|
||||
/// </summary>
|
|
||||
public virtual bool EnableRateLimiting { get; private set; } |
|
||||
/// <summary>
|
|
||||
/// 限速时段
|
|
||||
/// </summary>
|
|
||||
public virtual string Period { get; private set; } |
|
||||
/// <summary>
|
|
||||
/// 速率极限周期
|
|
||||
/// </summary>
|
|
||||
public virtual double? PeriodTimespan { get; private set; } |
|
||||
/// <summary>
|
|
||||
/// 客户端在定义的时间内可以发出的最大请求数
|
|
||||
/// </summary>
|
|
||||
public virtual long? Limit { get; private set; } |
|
||||
|
|
||||
protected RateLimitRule() |
|
||||
{ |
|
||||
ClientWhiteList = new List<RouteClientWhite>(); |
|
||||
} |
|
||||
|
|
||||
public RateLimitRule(Guid id, string period = "", double? periodTimespan = null, |
|
||||
long? limit = null, bool enabled = true) |
|
||||
{ |
|
||||
Id = id; |
|
||||
ChangeRateLimitState(enabled); |
|
||||
ApplyPolicy(period, periodTimespan, limit); |
|
||||
} |
|
||||
|
|
||||
public void ChangeRateLimitState(bool enabled = true) |
|
||||
{ |
|
||||
EnableRateLimiting = enabled; |
|
||||
} |
|
||||
|
|
||||
public void ApplyPolicy(string period = "", double? periodTimespan = null, |
|
||||
long? limit = null) |
|
||||
{ |
|
||||
Period = period; |
|
||||
PeriodTimespan = periodTimespan; |
|
||||
Limit = limit; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,348 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Security; |
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Collections.ObjectModel; |
|
||||
using System.Linq; |
|
||||
using Volo.Abp.Domain.Entities.Auditing; |
|
||||
using Volo.Abp.Guids; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class Route : FullAuditedAggregateRoot<Guid> |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 应用标识
|
|
||||
/// </summary>
|
|
||||
public virtual string AppId { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 路由名称
|
|
||||
/// </summary>
|
|
||||
public virtual string Name { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 请求标识
|
|
||||
/// </summary>
|
|
||||
public virtual string RequestIdKey { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 是否区分大小写
|
|
||||
/// </summary>
|
|
||||
public virtual bool RouteIsCaseSensitive { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 服务名称
|
|
||||
/// </summary>
|
|
||||
public virtual string ServiceName { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 服务命名空间
|
|
||||
/// </summary>
|
|
||||
public virtual string ServiceNamespace { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 下游协议
|
|
||||
/// </summary>
|
|
||||
public virtual string DownstreamScheme { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 下游路由路径
|
|
||||
/// </summary>
|
|
||||
public virtual string DownstreamPathTemplate { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 上游路由路径
|
|
||||
/// </summary>
|
|
||||
public virtual string UpstreamPathTemplate { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 变更下游路径
|
|
||||
/// </summary>
|
|
||||
public virtual string ChangeDownstreamPathTemplate { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 上游主机
|
|
||||
/// </summary>
|
|
||||
public virtual string UpstreamHost { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 聚合标识
|
|
||||
/// </summary>
|
|
||||
public virtual string Key { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 优先级
|
|
||||
/// </summary>
|
|
||||
public virtual int? Priority { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 超时时间
|
|
||||
/// </summary>
|
|
||||
public virtual int? Timeout { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 忽略SSL警告
|
|
||||
/// </summary>
|
|
||||
public virtual bool DangerousAcceptAnyServerCertificateValidator { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 下游版本号
|
|
||||
/// </summary>
|
|
||||
public virtual string DownstreamHttpVersion { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 下游Http方法列表
|
|
||||
/// </summary>
|
|
||||
public virtual ICollection<RouteUpstreamHttpMethod> UpstreamHttpMethods { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 上游Http方法列表
|
|
||||
/// </summary>
|
|
||||
public virtual ICollection<RouteDownstreamHttpMethod> DownstreamHttpMethods { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 添加请求头参数
|
|
||||
/// </summary>
|
|
||||
public virtual ICollection<RouteAddRequestHttpHeader> AddHeadersToRequest { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 下游请求头转换
|
|
||||
/// </summary>
|
|
||||
public virtual ICollection<RouteUpstreamTransformHttpHeader> UpstreamHeaderTransform { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 上游请求头转换
|
|
||||
/// </summary>
|
|
||||
public virtual ICollection<RouteDownstreamTransformHttpHeader> DownstreamHeaderTransform { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 请求声明转换
|
|
||||
/// </summary>
|
|
||||
public virtual ICollection<RouteAddToRequestClaim> AddClaimsToRequest { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 请求必须的声明
|
|
||||
/// </summary>
|
|
||||
public virtual ICollection<RouteRequirementClaim> RouteClaimsRequirement { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 用户声明到请求头转换
|
|
||||
/// </summary>
|
|
||||
public virtual ICollection<RouteAddToRequestHttpQuery> AddQueriesToRequest { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 下游主机列表
|
|
||||
/// </summary>
|
|
||||
public virtual ICollection<RouteDownstreamHostAndPort> DownstreamHostAndPorts { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 授权处理器列表
|
|
||||
/// </summary>
|
|
||||
public virtual ICollection<RouteHttpDelegatingHandler> DelegatingHandlers { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// Http选项
|
|
||||
/// </summary>
|
|
||||
public virtual RouteHttpHandler HttpHandler { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 授权
|
|
||||
/// </summary>
|
|
||||
public virtual RouteAuthentication Authentication { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 速率限制
|
|
||||
/// </summary>
|
|
||||
public virtual RouteRateLimitRule RouteRateLimitRule { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 负债均衡
|
|
||||
/// </summary>
|
|
||||
public virtual RouteLoadBalancer LoadBalancer { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 服务质量
|
|
||||
/// </summary>
|
|
||||
public virtual RouteQos QoS { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 文件缓存
|
|
||||
/// </summary>
|
|
||||
public virtual RouteCache Cache { get; protected set; } |
|
||||
/// <summary>
|
|
||||
/// 安全策略
|
|
||||
/// </summary>
|
|
||||
public virtual RouteSecurity Security { get; protected set; } |
|
||||
|
|
||||
protected Route() |
|
||||
{ |
|
||||
UpstreamHttpMethods = new Collection<RouteUpstreamHttpMethod>(); |
|
||||
DownstreamHttpMethods = new Collection<RouteDownstreamHttpMethod>(); |
|
||||
AddHeadersToRequest = new Collection<RouteAddRequestHttpHeader>(); |
|
||||
UpstreamHeaderTransform = new Collection<RouteUpstreamTransformHttpHeader>(); |
|
||||
DownstreamHeaderTransform = new Collection<RouteDownstreamTransformHttpHeader>(); |
|
||||
AddClaimsToRequest = new Collection<RouteAddToRequestClaim>(); |
|
||||
RouteClaimsRequirement = new Collection<RouteRequirementClaim>(); |
|
||||
AddQueriesToRequest = new Collection<RouteAddToRequestHttpQuery>(); |
|
||||
DownstreamHostAndPorts = new Collection<RouteDownstreamHostAndPort>(); |
|
||||
DelegatingHandlers = new Collection<RouteHttpDelegatingHandler>(); |
|
||||
} |
|
||||
|
|
||||
public void AddDownstreamHttpMethod(IGuidGenerator generator, string method) |
|
||||
{ |
|
||||
DownstreamHttpMethods.AddIfNotContains(new RouteDownstreamHttpMethod(Id, generator.Create(), method)); ; |
|
||||
} |
|
||||
|
|
||||
public void RemoveDownstreamHttpMethod(string method) |
|
||||
{ |
|
||||
DownstreamHttpMethods.RemoveAll(x => x.Method.Equals(method, StringComparison.CurrentCultureIgnoreCase)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllDownstreamHttpMethod() |
|
||||
{ |
|
||||
DownstreamHttpMethods.Clear(); |
|
||||
} |
|
||||
|
|
||||
public void AddUpstreamHttpMethod(IGuidGenerator generator, string method) |
|
||||
{ |
|
||||
UpstreamHttpMethods.AddIfNotContains(new RouteUpstreamHttpMethod(Id, generator.Create(), method)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveUpstreamHttpMethod(string method) |
|
||||
{ |
|
||||
UpstreamHttpMethods.RemoveAll(x => x.Method.Equals(method, StringComparison.CurrentCultureIgnoreCase)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllUpstreamHttpMethod() |
|
||||
{ |
|
||||
UpstreamHttpMethods.Clear(); |
|
||||
} |
|
||||
|
|
||||
public void AddRequestHeader(IGuidGenerator generator, string key, string value) |
|
||||
{ |
|
||||
AddHeadersToRequest.AddIfNotContains(new RouteAddRequestHttpHeader(Id, generator.Create(), key, value)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveRequestHeader(string key, string value) |
|
||||
{ |
|
||||
AddHeadersToRequest.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase) |
|
||||
&& x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllRequestHeader() |
|
||||
{ |
|
||||
AddHeadersToRequest.Clear(); |
|
||||
} |
|
||||
|
|
||||
public void AddUpstreamHeaderTransform(IGuidGenerator generator, string key, string value) |
|
||||
{ |
|
||||
UpstreamHeaderTransform.AddIfNotContains(new RouteUpstreamTransformHttpHeader(Id, generator.Create(), key, value)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveUpstreamHeaderTransform(string key, string value) |
|
||||
{ |
|
||||
UpstreamHeaderTransform.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase) |
|
||||
&& x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllUpstreamHeaderTransform() |
|
||||
{ |
|
||||
UpstreamHeaderTransform.Clear(); |
|
||||
} |
|
||||
|
|
||||
public void AddDownstreamHeaderTransform(IGuidGenerator generator, string key, string value) |
|
||||
{ |
|
||||
DownstreamHeaderTransform.AddIfNotContains(new RouteDownstreamTransformHttpHeader(Id, generator.Create(), key, value)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveDownstreamHeaderTransform(string key, string value) |
|
||||
{ |
|
||||
DownstreamHeaderTransform.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase) |
|
||||
&& x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllDownstreamHeaderTransform() |
|
||||
{ |
|
||||
DownstreamHeaderTransform.Clear(); |
|
||||
} |
|
||||
|
|
||||
public void AddRequestClaim(IGuidGenerator generator, string key, string value) |
|
||||
{ |
|
||||
AddClaimsToRequest.AddIfNotContains(new RouteAddToRequestClaim(Id, generator.Create(), key, value)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveRequestClaim(string key, string value) |
|
||||
{ |
|
||||
AddClaimsToRequest.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase) |
|
||||
&& x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllRequestClaim() |
|
||||
{ |
|
||||
AddClaimsToRequest.Clear(); |
|
||||
} |
|
||||
|
|
||||
public void AddRequirementClaim(IGuidGenerator generator, string key, string value) |
|
||||
{ |
|
||||
RouteClaimsRequirement.AddIfNotContains(new RouteRequirementClaim(Id, generator.Create(), key, value)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveRequirementClaim(string key, string value) |
|
||||
{ |
|
||||
RouteClaimsRequirement.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase) |
|
||||
&& x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllRequirementClaim() |
|
||||
{ |
|
||||
RouteClaimsRequirement.Clear(); |
|
||||
} |
|
||||
|
|
||||
public void AddRequestQuery(IGuidGenerator generator, string key, string value) |
|
||||
{ |
|
||||
AddQueriesToRequest.AddIfNotContains(new RouteAddToRequestHttpQuery(Id, generator.Create(), key, value)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveRequestQuery(string key, string value) |
|
||||
{ |
|
||||
AddQueriesToRequest.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase) |
|
||||
&& x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllRequestQuery() |
|
||||
{ |
|
||||
AddQueriesToRequest.Clear(); |
|
||||
} |
|
||||
|
|
||||
public void AddDownstreamHost(IGuidGenerator generator, string host, int? port) |
|
||||
{ |
|
||||
DownstreamHostAndPorts.AddIfNotContains(new RouteDownstreamHostAndPort(Id, generator.Create(), host, port)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveDownstreamHost(string host, int? port) |
|
||||
{ |
|
||||
DownstreamHostAndPorts.RemoveAll(x => x.Host.Equals(host, StringComparison.CurrentCultureIgnoreCase) |
|
||||
&& x.Port.Equals(port)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllDownstreamHost() |
|
||||
{ |
|
||||
DownstreamHostAndPorts.Clear(); |
|
||||
} |
|
||||
|
|
||||
public void AddDelegatingHandler(IGuidGenerator generator, string name) |
|
||||
{ |
|
||||
DelegatingHandlers.AddIfNotContains(new RouteHttpDelegatingHandler(Id, generator.Create(), name)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveDelegatingHandler(string name) |
|
||||
{ |
|
||||
DelegatingHandlers.RemoveAll(x => x.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllDelegatingHandler() |
|
||||
{ |
|
||||
DelegatingHandlers.Clear(); |
|
||||
} |
|
||||
|
|
||||
public void BindService(string serviceName, string @namespace) |
|
||||
{ |
|
||||
ServiceName = serviceName; |
|
||||
ServiceNamespace = @namespace; |
|
||||
} |
|
||||
|
|
||||
public void UseHttpHandler(IGuidGenerator generator, bool autoRedirect = false, bool useCookie = false, |
|
||||
bool useTracking = false, bool useProxy = false, int? maxConnection = 1000) |
|
||||
{ |
|
||||
if (HttpHandler == null) |
|
||||
{ |
|
||||
HttpHandler = new RouteHttpHandler(generator.Create(), Id); |
|
||||
} |
|
||||
HttpHandler.UseProxy = useProxy; |
|
||||
HttpHandler.UseTracing = useTracking; |
|
||||
HttpHandler.UseCookieContainer = useCookie; |
|
||||
HttpHandler.AllowAutoRedirect = autoRedirect; |
|
||||
HttpHandler.ChangeMaxConnection(maxConnection); |
|
||||
} |
|
||||
|
|
||||
public void UseAuthentication(IGuidGenerator generator, string provider, IEnumerable<string> allowScope) |
|
||||
{ |
|
||||
if (Authentication == null) |
|
||||
{ |
|
||||
Authentication = new RouteAuthentication(generator.Create(), Id, provider); |
|
||||
} |
|
||||
Authentication.AddScopes(allowScope); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
} |
|
||||
} |
|
||||
@ -1,20 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Http; |
|
||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteAddRequestHttpHeader : HttpHeader |
|
||||
{ |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteAddRequestHttpHeader() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
public RouteAddRequestHttpHeader(Guid routeId, Guid httpHeaderId, string key, string value) |
|
||||
: base(httpHeaderId, key, value) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,20 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Security; |
|
||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteAddToRequestClaim : Claim |
|
||||
{ |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteAddToRequestClaim() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
public RouteAddToRequestClaim(Guid routeId, Guid claimId, string key, string value) |
|
||||
: base(claimId, key, value) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,20 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Http; |
|
||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteAddToRequestHttpQuery : HttpQuery |
|
||||
{ |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteAddToRequestHttpQuery() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
public RouteAddToRequestHttpQuery(Guid routeId, Guid httpQueryId, string key, string value) |
|
||||
: base(httpQueryId, key, value) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,45 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteAllowedScope : Entity<int> |
|
||||
{ |
|
||||
public virtual string Scope { get; protected set; } |
|
||||
public virtual Guid AuthenticationId { get; protected set; } |
|
||||
public virtual RouteAuthentication Authentication { get; protected set; } |
|
||||
protected RouteAllowedScope() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public RouteAllowedScope(Guid authenticationId, string scope) |
|
||||
{ |
|
||||
AuthenticationId = authenticationId; |
|
||||
Scope = scope; |
|
||||
} |
|
||||
|
|
||||
public override int GetHashCode() |
|
||||
{ |
|
||||
if (!Scope.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return Scope.GetHashCode(); |
|
||||
} |
|
||||
return base.GetHashCode(); |
|
||||
} |
|
||||
|
|
||||
public override bool Equals(object obj) |
|
||||
{ |
|
||||
if (obj == null || |
|
||||
Scope.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
if (obj is RouteAllowedScope allowedScope) |
|
||||
{ |
|
||||
return allowedScope.Scope.Equals(Scope); |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,53 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteAuthentication : Entity<Guid> |
|
||||
{ |
|
||||
public virtual string AuthenticationProviderKey { get; private set; } |
|
||||
public virtual ICollection<RouteAllowedScope> AllowedScopes { get; set; } |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteAuthentication() |
|
||||
{ |
|
||||
AllowedScopes = new List<RouteAllowedScope>(); |
|
||||
} |
|
||||
|
|
||||
public RouteAuthentication(Guid id, Guid routeId, string providerKey) |
|
||||
{ |
|
||||
Id = id; |
|
||||
RouteId = routeId; |
|
||||
ChangeProvider(providerKey); |
|
||||
} |
|
||||
|
|
||||
public void ChangeProvider(string providerKey) |
|
||||
{ |
|
||||
AuthenticationProviderKey = providerKey; |
|
||||
} |
|
||||
|
|
||||
public void AddScope(string scope) |
|
||||
{ |
|
||||
AllowedScopes.AddIfNotContains(new RouteAllowedScope(Id, scope)); |
|
||||
} |
|
||||
|
|
||||
public void AddScopes(IEnumerable<string> scope) |
|
||||
{ |
|
||||
foreach(var scop in scope) |
|
||||
{ |
|
||||
AddScope(scop); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public void RemoveScope(string scope) |
|
||||
{ |
|
||||
AllowedScopes.RemoveAll(x => x.Scope.Equals(scope, StringComparison.CurrentCultureIgnoreCase)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllScope() |
|
||||
{ |
|
||||
AllowedScopes.Clear(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,22 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteCache : Entity<int> |
|
||||
{ |
|
||||
public virtual int? TtlSeconds { get; private set; } |
|
||||
public virtual string Region { get; private set; } |
|
||||
public virtual Guid RouteId { get; private set; } |
|
||||
public virtual Route Route { get; private set; } |
|
||||
protected RouteCache() |
|
||||
{ |
|
||||
} |
|
||||
public RouteCache(Guid routeId, string region = "", int? ttlSeconds = null) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
Region = region; |
|
||||
TtlSeconds = ttlSeconds; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,19 +0,0 @@ |
|||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteDownstreamHostAndPort : HostAndPort |
|
||||
{ |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteDownstreamHostAndPort() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
public RouteDownstreamHostAndPort(Guid routeId, Guid hostId, string key, int? port) |
|
||||
: base(hostId, key, port) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,21 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Http; |
|
||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteDownstreamHttpMethod : HttpMethod |
|
||||
{ |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteDownstreamHttpMethod() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public RouteDownstreamHttpMethod(Guid routeId, Guid httpMethodId, string method) |
|
||||
: base(httpMethodId, method) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,20 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Http; |
|
||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteDownstreamTransformHttpHeader : HttpHeader |
|
||||
{ |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteDownstreamTransformHttpHeader() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
public RouteDownstreamTransformHttpHeader(Guid routeId, Guid httpHeaderId, string key, string value) |
|
||||
: base(httpHeaderId, key, value) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,21 +0,0 @@ |
|||||
using JetBrains.Annotations; |
|
||||
using LINGYUN.ApiGateWay.Admin.Http; |
|
||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteHttpDelegatingHandler : HttpDelegatingHandler |
|
||||
{ |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteHttpDelegatingHandler() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
public RouteHttpDelegatingHandler(Guid routeId, Guid httpHandlerId, [NotNull] string name) |
|
||||
: base(httpHandlerId, name) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,20 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Http; |
|
||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteHttpHandler : HttpHandler |
|
||||
{ |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteHttpHandler() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
public RouteHttpHandler(Guid id, Guid routeId) |
|
||||
{ |
|
||||
Id = id; |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,11 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Text; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteHttpMethod |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
@ -1,23 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteLoadBalancer : Entity<int> |
|
||||
{ |
|
||||
public virtual Guid LoadBalancerId { get; private set; } |
|
||||
public virtual LoadBalancer LoadBalancer { get; private set; } |
|
||||
public virtual Guid RouteId { get; private set; } |
|
||||
public virtual Route Route { get; private set; } |
|
||||
protected RouteLoadBalancer() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public RouteLoadBalancer(Guid routeId, Guid loadBalancerId) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
LoadBalancerId = loadBalancerId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,22 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteQos : Entity<int> |
|
||||
{ |
|
||||
public virtual Guid QoSId { get; protected set; } |
|
||||
public virtual QoS QoS { get; protected set; } |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteQos() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
public RouteQos(Guid routeId, Guid qosId) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
QoSId = qosId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,23 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteRateLimitRule : Entity<int> |
|
||||
{ |
|
||||
public virtual Guid RateLimitRuleId { get; protected set; } |
|
||||
public virtual RateLimitRule RateLimitRule { get; protected set; } |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteRateLimitRule() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public RouteRateLimitRule(Guid routeId, Guid rateLimitRuleId) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
RateLimitRuleId = rateLimitRuleId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,20 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Security; |
|
||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteRequirementClaim : Claim |
|
||||
{ |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteRequirementClaim() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
public RouteRequirementClaim(Guid routeId, Guid claimId, string key, string value) |
|
||||
: base(claimId, key, value) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,21 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Http; |
|
||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteUpstreamHttpMethod : HttpMethod |
|
||||
{ |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteUpstreamHttpMethod() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public RouteUpstreamHttpMethod(Guid routeId, Guid httpMethodId, string method) |
|
||||
: base(httpMethodId, method) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,20 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Http; |
|
||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Routes |
|
||||
{ |
|
||||
public class RouteUpstreamTransformHttpHeader : HttpHeader |
|
||||
{ |
|
||||
public virtual Guid RouteId { get; protected set; } |
|
||||
public virtual Route Route { get; protected set; } |
|
||||
protected RouteUpstreamTransformHttpHeader() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
public RouteUpstreamTransformHttpHeader(Guid routeId, Guid httpHeaderId, string key, string value) |
|
||||
: base(httpHeaderId, key, value) |
|
||||
{ |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,50 +0,0 @@ |
|||||
using JetBrains.Annotations; |
|
||||
using System; |
|
||||
using Volo.Abp; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Security |
|
||||
{ |
|
||||
public class Claim : Entity<Guid> |
|
||||
{ |
|
||||
public virtual string Key { get; protected set; } |
|
||||
public virtual string Value { get; protected set; } |
|
||||
protected Claim() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
protected Claim(Guid id, [NotNull] string key, [NotNull] string value) |
|
||||
{ |
|
||||
Id = id; |
|
||||
Key = Check.NotNullOrWhiteSpace(key, nameof(key)); |
|
||||
Value = Check.NotNullOrWhiteSpace(value, nameof(value)); |
|
||||
} |
|
||||
|
|
||||
public override int GetHashCode() |
|
||||
{ |
|
||||
if (!Key.IsNullOrWhiteSpace() && |
|
||||
!Value.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return Key.GetHashCode() & Value.GetHashCode(); |
|
||||
} |
|
||||
return base.GetHashCode(); |
|
||||
} |
|
||||
|
|
||||
public override bool Equals(object obj) |
|
||||
{ |
|
||||
if (obj == null || |
|
||||
Key.IsNullOrWhiteSpace() || |
|
||||
Value.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
if (obj is Claim claim) |
|
||||
{ |
|
||||
return claim.Key.Equals(Key, StringComparison.CurrentCultureIgnoreCase) && |
|
||||
claim.Value.Equals(Value, StringComparison.CurrentCultureIgnoreCase); |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,34 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Security |
|
||||
{ |
|
||||
public class RouteClientWhite : Entity<int> |
|
||||
{ |
|
||||
public virtual string ClientId { get; private set; } |
|
||||
public virtual Guid RateLimitRuleId { get; private set; } |
|
||||
public virtual RateLimitRule RateLimitRule { get; private set; } |
|
||||
public override int GetHashCode() |
|
||||
{ |
|
||||
if (!ClientId.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return ClientId.GetHashCode(); |
|
||||
} |
|
||||
return base.GetHashCode(); |
|
||||
} |
|
||||
|
|
||||
public override bool Equals(object obj) |
|
||||
{ |
|
||||
if (obj == null || |
|
||||
ClientId.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
if (obj is RouteClientWhite clientWhite) |
|
||||
{ |
|
||||
return clientWhite.ClientId.Equals(ClientId); |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,40 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Security |
|
||||
{ |
|
||||
public class RouteIPBlock : Entity<int> |
|
||||
{ |
|
||||
public virtual string Address { get; private set; } |
|
||||
public virtual Guid SecurityId { get; private set; } |
|
||||
public virtual RouteSecurity Security { get; private set; } |
|
||||
protected RouteIPBlock() { } |
|
||||
public RouteIPBlock(Guid securityId, string address) |
|
||||
{ |
|
||||
SecurityId = securityId; |
|
||||
Address = address; |
|
||||
} |
|
||||
public override int GetHashCode() |
|
||||
{ |
|
||||
if (!Address.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return Address.GetHashCode(); |
|
||||
} |
|
||||
return base.GetHashCode(); |
|
||||
} |
|
||||
|
|
||||
public override bool Equals(object obj) |
|
||||
{ |
|
||||
if (obj == null || |
|
||||
Address.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
if (obj is RouteIPBlock iPBlock) |
|
||||
{ |
|
||||
return iPBlock.Address.Equals(Address); |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,41 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Security |
|
||||
{ |
|
||||
public class RouteIPWhite : Entity<int> |
|
||||
{ |
|
||||
public virtual string Address { get; private set; } |
|
||||
public virtual Guid SecurityId { get; private set; } |
|
||||
public virtual RouteSecurity Security { get; private set; } |
|
||||
|
|
||||
protected RouteIPWhite() { } |
|
||||
public RouteIPWhite(Guid securityId, string address) |
|
||||
{ |
|
||||
SecurityId = securityId; |
|
||||
Address = address; |
|
||||
} |
|
||||
public override int GetHashCode() |
|
||||
{ |
|
||||
if (!Address.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return Address.GetHashCode(); |
|
||||
} |
|
||||
return base.GetHashCode(); |
|
||||
} |
|
||||
|
|
||||
public override bool Equals(object obj) |
|
||||
{ |
|
||||
if(obj == null || |
|
||||
Address.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
if (obj is RouteIPWhite iPWhite) |
|
||||
{ |
|
||||
return iPWhite.Address.Equals(Address); |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,56 +0,0 @@ |
|||||
using LINGYUN.ApiGateWay.Admin.Routes; |
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateWay.Admin.Security |
|
||||
{ |
|
||||
public class RouteSecurity : Entity<Guid> |
|
||||
{ |
|
||||
public virtual ICollection<RouteIPWhite> IPAllowedList { get; private set; } |
|
||||
public virtual ICollection<RouteIPBlock> IPBlockedList { get; private set; } |
|
||||
public virtual Guid RouteId { get; private set; } |
|
||||
public virtual Route Route { get; private set; } |
|
||||
protected RouteSecurity() |
|
||||
{ |
|
||||
IPAllowedList = new List<RouteIPWhite>(); |
|
||||
IPBlockedList = new List<RouteIPBlock>(); |
|
||||
} |
|
||||
|
|
||||
public RouteSecurity(Guid id, Guid routeId) : this() |
|
||||
{ |
|
||||
Id = id; |
|
||||
RouteId = routeId; |
|
||||
} |
|
||||
|
|
||||
public void AddIpWhite(string address) |
|
||||
{ |
|
||||
IPAllowedList.AddIfNotContains(new RouteIPWhite(Id, address)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveIpWhite(string address) |
|
||||
{ |
|
||||
IPAllowedList.RemoveAll(ip => ip.Address.Equals(address)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllIpWhite() |
|
||||
{ |
|
||||
IPAllowedList.Clear(); |
|
||||
} |
|
||||
|
|
||||
public void AddIpBlock(string address) |
|
||||
{ |
|
||||
IPBlockedList.AddIfNotContains(new RouteIPBlock(Id, address)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveIpBlock(string address) |
|
||||
{ |
|
||||
IPBlockedList.RemoveAll(ip => ip.Address.Equals(address)); |
|
||||
} |
|
||||
|
|
||||
public void RemoveAllIpBlock() |
|
||||
{ |
|
||||
IPBlockedList.Clear(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,12 +1,10 @@ |
|||||
using Newtonsoft.Json; |
using System; |
||||
using System; |
|
||||
|
|
||||
namespace LINGYUN.ApiGateway.Ocelot |
namespace LINGYUN.ApiGateway.Ocelot |
||||
{ |
{ |
||||
[Serializable] |
[Serializable] |
||||
public class DynamicReRouteDto : DynamicReRouteDtoBase |
public class DynamicReRouteDto : DynamicReRouteDtoBase |
||||
{ |
{ |
||||
[JsonConverter(typeof(HexLongConverter))] |
public virtual string DynamicReRouteId { get; set; } |
||||
public virtual long DynamicReRouteId { get; set; } |
|
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,30 +0,0 @@ |
|||||
using System; |
|
||||
|
|
||||
namespace Newtonsoft.Json |
|
||||
{ |
|
||||
public class HexLongConverter : JsonConverter |
|
||||
{ |
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) |
|
||||
{ |
|
||||
long v = value is ulong ? (long)(ulong)value : (long)value; |
|
||||
writer.WriteValue(v.ToString()); |
|
||||
} |
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) |
|
||||
{ |
|
||||
string value = reader.Value as string; |
|
||||
long lValue = long.Parse(value); |
|
||||
return typeof(ulong) == objectType ? (object)(ulong)lValue : lValue; |
|
||||
} |
|
||||
public override bool CanConvert(Type objectType) |
|
||||
{ |
|
||||
switch (objectType.FullName) |
|
||||
{ |
|
||||
case "System.Int64": |
|
||||
case "System.UInt64": |
|
||||
return true; |
|
||||
default: |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,15 +1,15 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
<Import Project="..\..\..\common.props" /> |
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>netcoreapp3.1</TargetFramework> |
<TargetFramework>net5.0</TargetFramework> |
||||
<RootNamespace /> |
<RootNamespace /> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.1.8" /> |
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="5.0.0" /> |
||||
<PackageReference Include="Volo.Abp.AspNetCore.SignalR" Version="3.3.0" /> |
<PackageReference Include="Volo.Abp.AspNetCore.SignalR" Version="4.0.0" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
</Project> |
</Project> |
||||
|
|||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue