Skip to content

Commit

Permalink
下发应用密钥时,保存到本地配置文件
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jul 27, 2024
1 parent 8d263b7 commit 07f5a08
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Stardust.Extensions/TracerMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static void SaveServiceAddress(HttpContext ctx)
var baseAddress = $"{uri.Scheme}://{uri.Authority}";

var set = NewLife.Setting.Current;
var ss = set.ServiceAddress.Split(",").ToList();
var ss = set.ServiceAddress?.Split(",").ToList() ?? [];
if (!ss.Contains(baseAddress))
{
// 过滤掉本机地址
Expand Down
2 changes: 2 additions & 0 deletions Stardust/StarFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ private Boolean Valid()

if (_client == null)
{
var set = StarSetting.Current;
var client = new AppClient(Server)
{
Factory = this,
Expand All @@ -272,6 +273,7 @@ private Boolean Valid()
Secret = Secret,
ClientId = ClientId,
NodeCode = Local?.Info?.Code,
Setting = set,

Log = Log,
};
Expand Down
5 changes: 4 additions & 1 deletion Stardust/StarSetting.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.ComponentModel;
using NewLife.Configuration;
using NewLife.Remoting.Clients;

namespace Stardust;

/// <summary>星尘客户端配置</summary>
[Config("Star")]
public class StarSetting : Config<StarSetting>
public class StarSetting : Config<StarSetting>, IClientSetting
{
#region 属性
/// <summary>调试开关。默认false</summary>
Expand Down Expand Up @@ -43,5 +44,7 @@ public class StarSetting : Config<StarSetting>
/// <summary>最大异常采样数。采样周期内,最多只记录指定数量的异常事件,默认10</summary>
[Description("最大异常采样数。采样周期内,最多只记录指定数量的异常事件,默认10")]
public Int32 MaxErrors { get; set; } = 10;

String IClientSetting.Code { get => AppKey!; set => AppKey = value; }
#endregion
}

0 comments on commit 07f5a08

Please sign in to comment.