Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
Nse
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
吴超
Nse
Commits
ec36cc0e
Commit
ec36cc0e
authored
Aug 28, 2025
by
周海峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取本地ip优化
parent
5ab19c3a
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
47 行增加
和
22 行删除
+47
-22
src/main/java/com/chenyang/nse/bussiness/tools/licensekey/LicenseKeyTool.java
+47
-22
没有找到文件。
src/main/java/com/chenyang/nse/bussiness/tools/licensekey/LicenseKeyTool.java
View file @
ec36cc0e
...
...
@@ -158,29 +158,53 @@ public class LicenseKeyTool {
}
}
public
static
List
getLinuxLocalUUID
()
{
List
<
String
>
ipList
=
new
ArrayList
();
String
device
=
""
;
try
{
Process
process
=
Runtime
.
getRuntime
().
exec
(
"blkid "
+
device
);
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
String
line
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
String
[]
ac
=
line
.
split
(
" "
);
String
uuid
=
ac
[
1
];
String
[]
uuids
=
uuid
.
split
(
"\""
);
String
uuidr
=
uuids
[
1
];
ipList
.
add
(
uuidr
);
public
static
List
<
String
>
getLinuxLocalUUID
()
{
List
<
String
>
resultList
=
new
ArrayList
<>();
String
os
=
System
.
getProperty
(
"os.name"
).
toLowerCase
();
System
.
out
.
println
(
"os.name:"
+
os
);
if
(
os
.
contains
(
"mac"
))
{
// macOS 获取本地IP
try
{
Enumeration
<
NetworkInterface
>
interfaces
=
NetworkInterface
.
getNetworkInterfaces
();
while
(
interfaces
.
hasMoreElements
())
{
NetworkInterface
ni
=
interfaces
.
nextElement
();
if
(!
ni
.
getName
().
contains
(
"lo"
)
&&
!
ni
.
getName
().
contains
(
"docker"
))
{
Enumeration
<
InetAddress
>
addresses
=
ni
.
getInetAddresses
();
while
(
addresses
.
hasMoreElements
())
{
InetAddress
addr
=
addresses
.
nextElement
();
if
(!
addr
.
isLoopbackAddress
()
&&
addr
instanceof
java
.
net
.
Inet4Address
)
{
resultList
.
add
(
addr
.
getHostAddress
());
}
}
}
}
}
catch
(
SocketException
e
)
{
Log
.
info
(
"获取mac本地IP失败: "
+
e
.
getMessage
());
}
}
else
{
// Linux 获取UUID
String
device
=
""
;
try
{
Process
process
=
Runtime
.
getRuntime
().
exec
(
"blkid "
+
device
);
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
String
line
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
String
[]
ac
=
line
.
split
(
" "
);
if
(
ac
.
length
>
1
)
{
String
uuid
=
ac
[
1
];
String
[]
uuids
=
uuid
.
split
(
"\""
);
if
(
uuids
.
length
>
1
)
{
String
uuidr
=
uuids
[
1
];
resultList
.
add
(
uuidr
);
}
}
}
reader
.
close
();
}
catch
(
IOException
e
)
{
Log
.
info
(
"校验的证书是不是失效--linuxLocalUUID"
+
e
.
getMessage
());
}
reader
.
close
();
}
catch
(
IOException
e
)
{
Log
.
info
(
"校验的证书是不是失效--linuxLocalUUID"
+
e
.
getMessage
());
}
return
ipList
;
return
resultList
;
}
public
static
List
getLinuxLocalIp
()
throws
SocketException
{
...
...
@@ -240,7 +264,8 @@ public class LicenseKeyTool {
}
public
static
void
main
(
String
[]
args
)
{
String
content
=
"有效期1个月,10.10.200.24,fe:fc:fe:21:01:2d,2024-12-11,2025-01-11,5"
;
// String content = "有效期1个月,10.10.200.24,fe:fc:fe:21:01:2d,2024-12-11,2025-01-11,5";
String
content
=
"有效期1个月,172.16.100.75,3a:8f:fa:94:67:1a,2024-12-11,2025-11-11,100"
;
String
password
=
"ghca"
;
System
.
out
.
println
(
"加密之前:"
+
content
);
String
encrypt
=
AesTool
.
encrypt
(
content
,
password
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论