Skip to content

Commit

Permalink
ip network, json ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
trueai-org committed Aug 6, 2024
1 parent ae4ce55 commit 3cc0314
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/Midjourney.API/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public void ConfigureServices(IServiceCollection services)
};
DbHelper.SettingStore.Save(setting);

Thread.Sleep(5 * 1000);
// 等待 1s
Thread.Sleep(1 * 1000);
}
GlobalConfiguration.Setting = setting;

Expand Down
2 changes: 1 addition & 1 deletion src/Midjourney.Infrastructure/GlobalConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class GlobalConfiguration
/// <summary>
/// 版本号
/// </summary>
public static string Version { get; set; } = "v3.0.0-beta.4";
public static string Version { get; set; } = "v3.0.0-beta.5";

/// <summary>
/// 全局配置项
Expand Down
34 changes: 28 additions & 6 deletions src/Midjourney.Infrastructure/Options/IpRateLimitingOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net;
using LiteDB;
using System.Net;

namespace Midjourney.Infrastructure.Options
{
Expand All @@ -20,13 +21,23 @@ public class IpRateLimitingOptions
/// <summary>
/// 白名单 IP 网络
/// </summary>
[BsonIgnore]
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public List<IPNetwork2> WhitelistNetworks
{
get
{
// 格式化白名单
// 如果没有 / , 则默认为 /32
return Whitelist.Select(ip => !ip.Contains("/") ? IPNetwork2.Parse(ip + "/32") : IPNetwork2.Parse(ip)).ToList();
try
{
// 格式化白名单
// 如果没有 / , 则默认为 /32
return Whitelist.Select(ip => !ip.Contains("/") ? IPNetwork2.Parse(ip + "/32") : IPNetwork2.Parse(ip)).ToList();
}
catch
{
}
return new List<IPNetwork2>();
}
}

Expand All @@ -38,12 +49,23 @@ public List<IPNetwork2> WhitelistNetworks
/// <summary>
/// 黑名单 IP 网络
/// </summary>
[BsonIgnore]
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public List<IPNetwork2> BlacklistNetworks
{
get
{
// 格式化黑名单
return Blacklist.Select(ip => IPNetwork2.Parse(ip + "/32")).ToList();
try
{
// 格式化黑名单
return Blacklist.Select(ip => IPNetwork2.Parse(ip + "/32")).ToList();
}
catch
{
}

return new List<IPNetwork2>();
}
}

Expand Down

0 comments on commit 3cc0314

Please sign in to comment.