CommonUtils/Networks/IpUtil.cs
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
namespace CommonUtils
{
public static class IpUtil
{
public static string MyIp
{
get
{
StringBuilder Info = new StringBuilder("");
Info.Append("本机名:");
Info.AppendLine(Dns.GetHostName());
Info.Append("IP 地址:");
Info.AppendLine(" -> ");
IPAddress[] ipHost = Dns.GetHostAddresses(Dns.GetHostName());
foreach (IPAddress address in ipHost)
{
long scopeId = 0;
try
{
scopeId = address.ScopeId;
}
catch
{
}
Info.AppendLine(scopeId + " >> ");
Info.AppendLine(address.ToString());
Info.AppendLine();
}
return Info.ToString();
}
}
public static string Hide(string ip)
{
var cells = ip.Split('.');
if (cells.Length == 4)
return string.Format("{0}.{1}.*.{2}", cells[0], cells[1], cells[3]);
return ip;
}
//public static string GetZone(string ip)
//{
//}
public static IPAddress GetFromIpString(string ip)
=> IPAddress.Parse(ip);
public static IPAddress GetFromIpParts(byte part1, byte part2, byte part3, byte part4)
=> new IPAddress(new byte[] { part1, part2, part3, part4 });
后面还有 136 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。