mirror of
https://github.com/FastTunnel/FastTunnel.git
synced 2025-02-08 10:59:31 +08:00
1
This commit is contained in:
parent
d813c16406
commit
b1d694a183
|
@ -39,8 +39,8 @@ namespace FastTunnel.Api.Controllers
|
||||||
{
|
{
|
||||||
if ((serverOptionsMonitor.CurrentValue?.Api?.Accounts?.Length ?? 0) == 0)
|
if ((serverOptionsMonitor.CurrentValue?.Api?.Accounts?.Length ?? 0) == 0)
|
||||||
{
|
{
|
||||||
ApiResponse.errorCode = ErrorCodeEnum.NoAccount;
|
ApiResponse.Success = false;
|
||||||
ApiResponse.errorMessage = "账号或密码错误";
|
ApiResponse.Message = "账号或密码错误";
|
||||||
return ApiResponse;
|
return ApiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ namespace FastTunnel.Api.Controllers
|
||||||
|
|
||||||
if (account == null)
|
if (account == null)
|
||||||
{
|
{
|
||||||
ApiResponse.errorCode = ErrorCodeEnum.NoAccount;
|
ApiResponse.Success = false;
|
||||||
ApiResponse.errorMessage = "账号或密码错误";
|
ApiResponse.Message = "账号或密码错误";
|
||||||
return ApiResponse;
|
return ApiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ namespace FastTunnel.Api.Controllers
|
||||||
new Claim("Name", account.Name)
|
new Claim("Name", account.Name)
|
||||||
};
|
};
|
||||||
|
|
||||||
ApiResponse.data = GenerateToken(
|
ApiResponse.Data = GenerateToken(
|
||||||
claims,
|
claims,
|
||||||
serverOptionsMonitor.CurrentValue.Api.JWT.IssuerSigningKey,
|
serverOptionsMonitor.CurrentValue.Api.JWT.IssuerSigningKey,
|
||||||
serverOptionsMonitor.CurrentValue.Api.JWT.Expires,
|
serverOptionsMonitor.CurrentValue.Api.JWT.Expires,
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class SystemController : BaseController
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ApiResponse GetResponseTempList()
|
public ApiResponse GetResponseTempList()
|
||||||
{
|
{
|
||||||
ApiResponse.data = new
|
ApiResponse.Data = new
|
||||||
{
|
{
|
||||||
Count = fastTunnelServer.ResponseTasks.Count,
|
Count = fastTunnelServer.ResponseTasks.Count,
|
||||||
Rows = fastTunnelServer.ResponseTasks.Select(x => new
|
Rows = fastTunnelServer.ResponseTasks.Select(x => new
|
||||||
|
@ -50,7 +50,7 @@ public class SystemController : BaseController
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ApiResponse GetAllWebList()
|
public ApiResponse GetAllWebList()
|
||||||
{
|
{
|
||||||
ApiResponse.data = new
|
ApiResponse.Data = new
|
||||||
{
|
{
|
||||||
Count = fastTunnelServer.WebList.Count,
|
Count = fastTunnelServer.WebList.Count,
|
||||||
Rows = fastTunnelServer.WebList.Select(x => new { x.Key, x.Value.WebConfig.LocalIp, x.Value.WebConfig.LocalPort })
|
Rows = fastTunnelServer.WebList.Select(x => new { x.Key, x.Value.WebConfig.LocalIp, x.Value.WebConfig.LocalPort })
|
||||||
|
@ -66,7 +66,7 @@ public class SystemController : BaseController
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ApiResponse GetServerOption()
|
public ApiResponse GetServerOption()
|
||||||
{
|
{
|
||||||
ApiResponse.data = fastTunnelServer.ServerOption;
|
ApiResponse.Data = fastTunnelServer.ServerOption;
|
||||||
return ApiResponse;
|
return ApiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class SystemController : BaseController
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ApiResponse GetAllForwardList()
|
public ApiResponse GetAllForwardList()
|
||||||
{
|
{
|
||||||
ApiResponse.data = new
|
ApiResponse.Data = new
|
||||||
{
|
{
|
||||||
Count = fastTunnelServer.ForwardList.Count,
|
Count = fastTunnelServer.ForwardList.Count,
|
||||||
Rows = fastTunnelServer.ForwardList.Select(x => new { x.Key, x.Value.SSHConfig.LocalIp, x.Value.SSHConfig.LocalPort, x.Value.SSHConfig.RemotePort })
|
Rows = fastTunnelServer.ForwardList.Select(x => new { x.Key, x.Value.SSHConfig.LocalIp, x.Value.SSHConfig.LocalPort, x.Value.SSHConfig.RemotePort })
|
||||||
|
@ -94,7 +94,7 @@ public class SystemController : BaseController
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ApiResponse GetOnlineClientCount()
|
public ApiResponse GetOnlineClientCount()
|
||||||
{
|
{
|
||||||
ApiResponse.data = fastTunnelServer.ConnectedClientCount;
|
ApiResponse.Data = fastTunnelServer.ConnectedClientCount;
|
||||||
return ApiResponse;
|
return ApiResponse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ namespace FastTunnel.Api.Filters
|
||||||
_logger.LogError(context.Exception, "【全局异常捕获】");
|
_logger.LogError(context.Exception, "【全局异常捕获】");
|
||||||
var res = new ApiResponse()
|
var res = new ApiResponse()
|
||||||
{
|
{
|
||||||
errorCode = ErrorCodeEnum.Exception,
|
Success = false,
|
||||||
data = null,
|
Data = null,
|
||||||
errorMessage = context.Exception.Message,
|
Message = context.Exception.Message,
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = new JsonResult(res) { StatusCode = 200 };
|
var result = new JsonResult(res) { StatusCode = 200 };
|
||||||
|
|
|
@ -12,21 +12,12 @@ namespace FastTunnel.Server.Models
|
||||||
/// 错误码
|
/// 错误码
|
||||||
/// 0 成功,其他为失败
|
/// 0 成功,其他为失败
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ErrorCodeEnum errorCode { get; set; }
|
public bool Success { get; set; }
|
||||||
|
|
||||||
public string errorMessage { get; set; }
|
public string Message { get; set; }
|
||||||
|
|
||||||
public object data { get; set; }
|
public string Code { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
public enum ErrorCodeEnum
|
public object Data { get; set; }
|
||||||
{
|
|
||||||
NONE = 0,
|
|
||||||
|
|
||||||
AuthError = 1,
|
|
||||||
|
|
||||||
Exception = 2,
|
|
||||||
|
|
||||||
NoAccount = 3,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
"FastTunnel": {
|
"FastTunnel": {
|
||||||
"Server": {
|
"Server": {
|
||||||
// [必选] 服务端ip/域名(来自服务端配置文件的urls参数)
|
// [必选] 服务端ip/域名(来自服务端配置文件的urls参数)
|
||||||
"ServerAddr": "127.0.0.1",
|
"ServerAddr": "suidao.bx.com.cn",
|
||||||
// [必选] 服务端监听的通信端口(来自服务端配置文件的urls参数)
|
// [必选] 服务端监听的通信端口(来自服务端配置文件的urls参数)
|
||||||
"ServerPort": 1270
|
"ServerPort": 1270
|
||||||
},
|
},
|
||||||
|
|
|
@ -67,8 +67,9 @@ public class FastTunnelClient : IFastTunnelClient
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex.Message);
|
_logger.LogError(ex.Message);
|
||||||
await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("===== FastTunnel Client End =====");
|
_logger.LogInformation("===== FastTunnel Client End =====");
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class Startup
|
||||||
app.UseFastTunnelServer();
|
app.UseFastTunnelServer();
|
||||||
// -------------------FastTunnel STEP2 END-------------------
|
// -------------------FastTunnel STEP2 END-------------------
|
||||||
|
|
||||||
app.UseStaticFiles();
|
// app.UseStaticFiles();
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user