Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HYH.Registry
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张龙涛
HYH.Registry
Commits
275f803b
Commit
275f803b
authored
Aug 23, 2021
by
zhanglongtao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
1bfba870
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
19 deletions
+45
-19
ComputerInfoHelper.cs
...try.Application/Services/Encryption/ComputerInfoHelper.cs
+32
-17
EncryptionService.cs
...stry.Application/Services/Encryption/EncryptionService.cs
+12
-1
HYH.Registry.Application.xml
src/HYH.Registry.Web.Host/HYH.Registry.Application.xml
+1
-1
No files found.
src/HYH.Registry.Application/Services/Encryption/ComputerInfoHelper.cs
View file @
275f803b
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Management
;
using
System.Management
;
using
System.Net
;
using
System.Net.NetworkInformation
;
using
System.Net.NetworkInformation
;
using
System.Net.Sockets
;
using
System.Text
;
using
System.Text
;
namespace
HYH.Registry.Services.Encryption
namespace
HYH.Registry.Services.Encryption
...
@@ -52,7 +54,7 @@ namespace HYH.Registry.Services.Encryption
...
@@ -52,7 +54,7 @@ namespace HYH.Registry.Services.Encryption
///
///
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
public
static
string
GetName
()
public
static
string
Get
Host
Name
()
{
{
IPGlobalProperties
computerProperties
=
IPGlobalProperties
.
GetIPGlobalProperties
();
IPGlobalProperties
computerProperties
=
IPGlobalProperties
.
GetIPGlobalProperties
();
//获取本机电脑名
//获取本机电脑名
...
@@ -113,16 +115,9 @@ namespace HYH.Registry.Services.Encryption
...
@@ -113,16 +115,9 @@ namespace HYH.Registry.Services.Encryption
/// <returns></returns>
/// <returns></returns>
public
static
string
GetMACIp
()
public
static
string
GetMACIp
()
{
{
//本地计算机网络连接信息
IPGlobalProperties
computerProperties
=
IPGlobalProperties
.
GetIPGlobalProperties
();
//获取本机所有网络连接
//获取本机所有网络连接
NetworkInterface
[]
nics
=
NetworkInterface
.
GetAllNetworkInterfaces
();
NetworkInterface
[]
nics
=
NetworkInterface
.
GetAllNetworkInterfaces
();
//获取本机电脑名
var
HostName
=
computerProperties
.
HostName
;
//获取域名
var
DomainName
=
computerProperties
.
DomainName
;
if
(
nics
==
null
||
nics
.
Length
<
1
)
if
(
nics
==
null
||
nics
.
Length
<
1
)
{
{
return
""
;
return
""
;
...
@@ -151,20 +146,40 @@ namespace HYH.Registry.Services.Encryption
...
@@ -151,20 +146,40 @@ namespace HYH.Registry.Services.Encryption
}
}
}
}
//}
//}
MACIp
+=
"["
+
adapterName
+
":"
+
macip
+
"] "
;
MACIp
+=
"["
+
adapterName
+
":"
+
macip
+
"
-"
+
adapterDescription
+
"-"
+
NetworkInterfaceType
+
"
] "
;
}
}
return
MACIp
;
return
MACIp
;
}
}
//public static string GetHostName()
public
static
string
GetHostName
()
//{
// //获取本机所有网络连接
// NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
// foreach (NetworkInterface adapter in nics)
// {
// var fdd = adapter.GetIPProperties();
// fdd.GetIPv4Properties
// }
//}
//public static string GetIPv4()
//{
//获取内网IP
public
static
IPAddress
GetInternalIP
()
{
{
IPGlobalProperties
computerProperties
=
IPGlobalProperties
.
GetIPGlobalProperties
();
NetworkInterface
[]
nics
=
NetworkInterface
.
GetAllNetworkInterfaces
();
//获取本机电脑名
var
HostName
=
computerProperties
.
HostName
;
foreach
(
NetworkInterface
adapter
in
nics
)
////获取域名
{
//var DomainName = computerProperties.DomainName;
foreach
(
var
uni
in
adapter
.
GetIPProperties
().
UnicastAddresses
)
return
"电脑名:"
+
HostName
;
{
if
(
uni
.
Address
.
AddressFamily
==
AddressFamily
.
InterNetwork
)
{
return
uni
.
Address
;
}
}
}
return
null
;
}
}
//}
}
}
}
}
src/HYH.Registry.Application/Services/Encryption/EncryptionService.cs
View file @
275f803b
...
@@ -84,7 +84,7 @@ namespace HYH.Registry.Services.Encryption
...
@@ -84,7 +84,7 @@ namespace HYH.Registry.Services.Encryption
[
HttpGet
]
[
HttpGet
]
public
string
GetName
()
public
string
GetName
()
{
{
string
netCardMACAddress
=
ComputerInfoHelper
.
GetName
();
string
netCardMACAddress
=
ComputerInfoHelper
.
Get
Host
Name
();
return
netCardMACAddress
;
return
netCardMACAddress
;
}
}
/// <summary>
/// <summary>
...
@@ -160,5 +160,16 @@ namespace HYH.Registry.Services.Encryption
...
@@ -160,5 +160,16 @@ namespace HYH.Registry.Services.Encryption
}
}
return
new
JsonResult
(
flag
);
return
new
JsonResult
(
flag
);
}
}
/// <summary>
/// 获取内网ip
/// </summary>
/// <returns></returns>
public
async
Task
<
object
>
GetInternalIP
()
{
var
InternalIP
=
ComputerInfoHelper
.
GetInternalIP
();
return
InternalIP
.
ToString
();
}
}
}
}
}
src/HYH.Registry.Web.Host/HYH.Registry.Application.xml
View file @
275f803b
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
<param
name=
"Vector"
>
向量
</param>
<param
name=
"Vector"
>
向量
</param>
<returns>
明文
</returns>
<returns>
明文
</returns>
</member>
</member>
<member
name=
"M:HYH.Registry.Services.Encryption.ComputerInfoHelper.GetName"
>
<member
name=
"M:HYH.Registry.Services.Encryption.ComputerInfoHelper.Get
Host
Name"
>
<summary>
<summary>
</summary>
</summary>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment