From d0860e57a54a7b9ce6338a8241651d53280ddc01 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Sat, 15 Jan 2022 11:51:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20IPAddress=20?= =?UTF-8?q?=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/LoginLogSearch.razor.cs | 3 +++ .../Extensions/InternalIPAddressExtensions.cs | 24 +++++++++++++++++++ .../Pages/Admin/Logins.razor.cs | 3 +++ 3 files changed, 30 insertions(+) create mode 100644 src/blazor/admin/BootstrapAdmin.Web/Extensions/InternalIPAddressExtensions.cs diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/LoginLogSearch.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Components/LoginLogSearch.razor.cs index ff501372..4067a373 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Components/LoginLogSearch.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/LoginLogSearch.razor.cs @@ -2,6 +2,9 @@ namespace BootstrapAdmin.Web.Components; +/// +/// +/// public partial class LoginLogSearch { /// diff --git a/src/blazor/admin/BootstrapAdmin.Web/Extensions/InternalIPAddressExtensions.cs b/src/blazor/admin/BootstrapAdmin.Web/Extensions/InternalIPAddressExtensions.cs new file mode 100644 index 00000000..57c8f42a --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web/Extensions/InternalIPAddressExtensions.cs @@ -0,0 +1,24 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Website: https://www.blazor.zone or https://argozhang.github.io/ + +using System.Net; + +namespace Microsoft.AspNetCore.Builder; + +/// +/// IPAddress 内部操作扩展类 +/// +internal static class InternalIPAddressExtensions +{ + /// + /// + /// + /// + /// + public static string ToIPv4String(this IPAddress? address) + { + var ipv4Address = (address ?? IPAddress.IPv6Loopback).ToString(); + return ipv4Address.StartsWith("::ffff:") ? (address ?? IPAddress.IPv6Loopback).MapToIPv4().ToString() : ipv4Address; + } +} diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Logins.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Logins.razor.cs index 4c23888f..35bd8084 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Logins.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Logins.razor.cs @@ -2,6 +2,9 @@ namespace BootstrapAdmin.Web.Pages.Admin; +/// +/// +/// public partial class Logins { ///