Skip to content

Commit

Permalink
拆分节点自动注册和应用主动注册为两个配置。#59
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jun 20, 2024
1 parent afffc59 commit edfec02
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Stardust.Server/Controllers/ConfigController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public ConfigInfo GetAll([FromBody] ConfigInModel model, String token)
}

var ip = HttpContext.GetUserHost();
app ??= _tokenService.Authorize(appId, secret, _setting.AutoRegister, ip);
app ??= _tokenService.Authorize(appId, secret, _setting.AppAutoRegister, ip);

// 新建应用配置
var config = AppConfig.FindByName(appId);
Expand Down
2 changes: 1 addition & 1 deletion Stardust.Server/Controllers/LogController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task<EmptyResult> Post()
app = new App
{
Name = appId,
Enable = _setting.AutoRegister,
Enable = _setting.AppAutoRegister,
};
app.Insert();
}
Expand Down
2 changes: 1 addition & 1 deletion Stardust.Server/Controllers/OAuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public TokenModel Token([FromBody] TokenInModel model)
// 密码模式
if (model.grant_type == "password")
{
var app = _tokenService.Authorize(model.UserName, model.Password, set.AutoRegister, ip);
var app = _tokenService.Authorize(model.UserName, model.Password, set.AppAutoRegister, ip);

// 更新应用信息
app.LastLogin = DateTime.Now;
Expand Down
2 changes: 1 addition & 1 deletion Stardust.Server/Controllers/TraceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public async Task<TraceResponse> ReportRaw(String token)
}
else
{
app.Enable = set.AutoRegister;
app.Enable = set.AppAutoRegister;
}

app.Insert();
Expand Down
8 changes: 6 additions & 2 deletions Stardust.Server/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ public class StarServerSetting : Config<StarServerSetting>
[Description("会话超时。默认600秒")]
public Int32 SessionTimeout { get; set; } = 600;

/// <summary>自动注册。允许客户端自动注册,默认true</summary>
[Description("自动注册。允许客户端自动注册,默认true")]
/// <summary>自动注册。允许节点客户端自动注册,默认true</summary>
[Description("自动注册。允许节点客户端自动注册,默认true")]
public Boolean AutoRegister { get; set; } = true;

/// <summary>应用自动注册。允许应用客户端自动注册,默认true</summary>
[Description("应用自动注册。允许应用客户端自动注册,默认true")]
public Boolean AppAutoRegister { get; set; } = true;

/// <summary>准入白名单。若指定,仅允许符合IP条件的节点进行注册,多个逗号隔开,支持*模糊匹配</summary>
[Description("准入白名单。若指定,仅允许符合IP条件的节点进行注册,多个逗号隔开,支持*模糊匹配")]
public String WhiteIP { get; set; } = "";
Expand Down

0 comments on commit edfec02

Please sign in to comment.