mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-20 10:50:48 +08:00
build:10.5.1
fix: 反向代理正确获取客户端IP refactor: 添加demo站点域名
This commit is contained in:
@@ -20,11 +20,14 @@ A cross-platform, high-performance edge data collection gateway based on net9.
|
||||
## Demo
|
||||
|
||||
|
||||
[Demo](http://47.119.161.158:5000/)
|
||||
[Demo](https://demo.thingsgateway.cn/)
|
||||
|
||||
|
||||
Account: **SuperAdmin**
|
||||
|
||||
|
||||
Password: **111111**
|
||||
|
||||
|
||||
**In the upper-right corner, switch to the IoT Gateway module in the personal popup box**
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
## 演示
|
||||
|
||||
[ThingsGateway演示地址](http://47.119.161.158:5000/)
|
||||
[ThingsGateway演示地址](https://demo.thingsgateway.cn/)
|
||||
|
||||
账户 : **SuperAdmin**
|
||||
|
||||
|
@@ -137,7 +137,7 @@ public sealed class OperDescAttribute : MoAttribute
|
||||
Name = (localizerType == null ? App.CreateLocalizerByType(typeof(OperDescAttribute)) : App.CreateLocalizerByType(localizerType))![Description],
|
||||
Category = LogCateGoryEnum.Operate,
|
||||
ExeStatus = true,
|
||||
OpIp = AppService?.RemoteIpAddress?.MapToIPv4()?.ToString() ?? string.Empty,
|
||||
OpIp = AppService?.RemoteIpAddress ?? string.Empty,
|
||||
OpBrowser = clientInfo?.UA?.Family + clientInfo?.UA?.Major,
|
||||
OpOs = clientInfo?.OS?.Family + clientInfo?.OS?.Major,
|
||||
OpTime = DateTime.Now,
|
||||
|
@@ -72,7 +72,7 @@ public class AppService : IAppService
|
||||
}
|
||||
public ClaimsPrincipal? User => App.User;
|
||||
|
||||
public IPAddress? RemoteIpAddress => App.HttpContext?.Connection?.RemoteIpAddress;
|
||||
public string? RemoteIpAddress => App.HttpContext?.GetRemoteIpAddressToIPv4();
|
||||
|
||||
public int LocalPort => App.HttpContext.Connection.LocalPort;
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ public class HybridAppService : IAppService
|
||||
{
|
||||
var str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0";
|
||||
ClientInfo = Parser.GetDefault().Parse(str);
|
||||
RemoteIpAddress = IPAddress.Parse("127.0.0.1");
|
||||
RemoteIpAddress = "127.0.0.1";
|
||||
}
|
||||
public ClientInfo? ClientInfo { get; }
|
||||
|
||||
@@ -56,7 +56,7 @@ public class HybridAppService : IAppService
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress? RemoteIpAddress { get; }
|
||||
public string? RemoteIpAddress { get; }
|
||||
|
||||
public string GetReturnUrl(string returnUrl)
|
||||
{
|
||||
|
@@ -31,7 +31,7 @@ public interface IAppService
|
||||
/// <summary>
|
||||
/// RemoteIpAddress
|
||||
/// </summary>
|
||||
public IPAddress? RemoteIpAddress { get; }
|
||||
public string? RemoteIpAddress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// GetReturnUrl
|
||||
|
@@ -105,7 +105,7 @@ public class AuthService : IAuthService
|
||||
{
|
||||
var loginEvent = new LoginEvent
|
||||
{
|
||||
Ip = _appService.RemoteIpAddress?.MapToIPv4()?.ToString(),
|
||||
Ip = _appService.RemoteIpAddress,
|
||||
SysUser = userinfo,
|
||||
VerificatId = verificatId
|
||||
};
|
||||
@@ -236,7 +236,7 @@ public class AuthService : IAuthService
|
||||
//登录事件参数
|
||||
var logingEvent = new LoginEvent
|
||||
{
|
||||
Ip = _appService.RemoteIpAddress?.MapToIPv4()?.ToString(),
|
||||
Ip = _appService.RemoteIpAddress,
|
||||
Device = App.GetService<IAppService>().ClientInfo?.OS?.ToString(),
|
||||
Expire = expire,
|
||||
SysUser = sysUser,
|
||||
|
@@ -298,9 +298,9 @@ public class Startup : AppStartup
|
||||
public void Use(IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
|
||||
{
|
||||
var app = (WebApplication)applicationBuilder;
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All, KnownNetworks = { }, KnownProxies = { } });
|
||||
app.UseBootstrapBlazor();
|
||||
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All });
|
||||
|
||||
// 启用本地化
|
||||
var option = app.Services.GetService<IOptions<RequestLocalizationOptions>>();
|
||||
|
@@ -106,7 +106,7 @@ public static class HttpContextExtensions
|
||||
/// <param name="context"></param>
|
||||
/// <param name="xff">是否优先取 X-Forwarded-For</param>
|
||||
/// <returns></returns>
|
||||
public static string GetRemoteIpAddressToIPv4(this HttpContext context, bool xff = false)
|
||||
public static string GetRemoteIpAddressToIPv4(this HttpContext context, bool xff = true)
|
||||
{
|
||||
var ipv4 = context.Connection.RemoteIpAddress?.MapToIPv4()?.ToString();
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<PluginVersion>10.4.22</PluginVersion>
|
||||
<ProPluginVersion>10.4.22</ProPluginVersion>
|
||||
<PluginVersion>10.5.1</PluginVersion>
|
||||
<ProPluginVersion>10.5.1</ProPluginVersion>
|
||||
<AuthenticationVersion>2.1.7</AuthenticationVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@@ -13,6 +13,7 @@ using BootstrapBlazor.Components;
|
||||
using Mapster;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using SqlSugar;
|
||||
@@ -139,7 +140,7 @@ public class ControlController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
return await GlobalData.RpcService.InvokeDeviceMethodAsync($"WebApi-{UserManager.UserAccount}-{App.HttpContext.Connection.RemoteIpAddress.MapToIPv4()}", deviceDatas).ConfigureAwait(false);
|
||||
return await GlobalData.RpcService.InvokeDeviceMethodAsync($"WebApi-{UserManager.UserAccount}-{App.HttpContext?.GetRemoteIpAddressToIPv4()}", deviceDatas).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@
|
||||
<h4>
|
||||
<a id="user-content-演示" class="anchor" href="#%E6%BC%94%E7%A4%BA"></a>演示
|
||||
</h4>
|
||||
<p><a href="http://47.119.161.158:5000/">ThingsGateway演示地址</a></p>
|
||||
<p><a href="https://demo.thingsgateway.cn/">ThingsGateway演示地址</a></p>
|
||||
<p>账户 : <strong>SuperAdmin</strong></p>
|
||||
<p>密码 : <strong>111111</strong></p>
|
||||
<p><strong>右上角个人弹出框中,切换到物联网关模块</strong></p>
|
||||
|
@@ -280,9 +280,9 @@ public class Startup : AppStartup
|
||||
public void Use(IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
|
||||
{
|
||||
var app = (WebApplication)applicationBuilder;
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All, KnownNetworks = { }, KnownProxies = { } });
|
||||
app.UseBootstrapBlazor();
|
||||
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All });
|
||||
|
||||
// 启用本地化
|
||||
var option = app.Services.GetService<IOptions<RequestLocalizationOptions>>();
|
||||
|
@@ -298,9 +298,10 @@ public class Startup : AppStartup
|
||||
public void Use(IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
|
||||
{
|
||||
var app = (WebApplication)applicationBuilder;
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All, KnownNetworks = { }, KnownProxies = { } });
|
||||
|
||||
app.UseBootstrapBlazor();
|
||||
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All });
|
||||
|
||||
// 启用本地化
|
||||
var option = app.Services.GetService<IOptions<RequestLocalizationOptions>>();
|
||||
|
@@ -7,7 +7,7 @@
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5000"
|
||||
"applicationUrl": "http://*:5000"
|
||||
},
|
||||
"demo": {
|
||||
"commandName": "Project",
|
||||
@@ -16,7 +16,7 @@
|
||||
"ASPNETCORE_ENVIRONMENT": "Demo"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5000"
|
||||
"applicationUrl": "http://*:5000"
|
||||
},
|
||||
|
||||
"IIS Express": {
|
||||
@@ -32,7 +32,7 @@
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:59494/",
|
||||
"applicationUrl": "http://*:59494/",
|
||||
"sslPort": 44372
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"urls": "http://*:5000",
|
||||
|
||||
"ConfigurationScanDirectories": [ "Configuration", "" ], // 扫描配置文件json文件夹(自动合并该文件夹里面所有json文件)
|
||||
"IgnoreConfigurationFiles": [ "" ],
|
||||
|
@@ -304,9 +304,9 @@ public class Startup : AppStartup
|
||||
public void Use(IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
|
||||
{
|
||||
var app = (WebApplication)applicationBuilder;
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All, KnownNetworks = { }, KnownProxies = { } });
|
||||
app.UseBootstrapBlazor();
|
||||
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All });
|
||||
|
||||
// 启用本地化
|
||||
var option = app.Services.GetService<IOptions<RequestLocalizationOptions>>();
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>10.4.22</Version>
|
||||
<Version>10.5.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user