更新组件
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
||||
<PackageReference Include="NewLife.Core" Version="8.1.2019.510" />
|
||||
<PackageReference Include="NewLife.Core" Version="8.3.2019.822" />
|
||||
<PackageReference Include="PinYinConverterCore" Version="1.0.2" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
|
||||
<PackageReference Include="ZKWeb.System.Drawing" Version="4.0.1" />
|
||||
|
||||
@@ -9,6 +9,9 @@ using System.Net;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Configuration.Json;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace COMCMS.Common
|
||||
{
|
||||
@@ -1067,6 +1070,24 @@ namespace COMCMS.Common
|
||||
}
|
||||
#endregion
|
||||
|
||||
private static String[] _Excludes = new[] { "Loopback", "VMware", "VBox", "Virtual", "Teredo", "Microsoft", "VPN", "VNIC", "IEEE" };
|
||||
/// <summary>获取所有网卡MAC地址</summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Byte[]> GetMacs()
|
||||
{
|
||||
foreach (var item in NetworkInterface.GetAllNetworkInterfaces())
|
||||
{
|
||||
if (_Excludes.Any(e => item.Description.Contains(e))) continue;
|
||||
if (item.Speed < 1_000_000) continue;
|
||||
|
||||
var addrs = item.GetIPProperties().UnicastAddresses.Where(e => e.Address.AddressFamily == AddressFamily.InterNetwork).ToArray();
|
||||
if (addrs.All(e => IPAddress.IsLoopback(e.Address))) continue;
|
||||
|
||||
var mac = item.GetPhysicalAddress()?.GetAddressBytes();
|
||||
if (mac != null && mac.Length == 6) yield return mac;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region 常用扩展方法
|
||||
|
||||
Reference in New Issue
Block a user