Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gamera_videos_no_ui
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liusq
gamera_videos_no_ui
Commits
88ad9e2a
Commit
88ad9e2a
authored
Oct 10, 2024
by
“liusq”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改命令
parent
c3dd3878
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
VidesData.h
+9
-5
No files found.
VidesData.h
View file @
88ad9e2a
...
@@ -487,27 +487,30 @@ inline bool pingAddress(const QString &address) {
...
@@ -487,27 +487,30 @@ inline bool pingAddress(const QString &address) {
QProcess
process
;
QProcess
process
;
QString
program
=
"ping"
;
QString
program
=
"ping"
;
QStringList
arguments
;
QStringList
arguments
;
#ifdef Q_OS_WIN
#ifdef Q_OS_WIN
// Windows
下通常不需要
sudo
// Windows
下通常不需要
sudo
arguments
<<
"-n"
<<
"1"
<<
address
;
arguments
<<
"-n"
<<
"1"
<<
address
;
#else
#else
// 使用sudo
// 不使用 sudo
program
=
"sudo"
;
arguments
<<
"-c"
<<
"1"
<<
address
;
arguments
<<
"ping"
<<
"-c"
<<
"1"
<<
address
;
#endif
#endif
process
.
start
(
program
,
arguments
);
process
.
start
(
program
,
arguments
);
if
(
!
process
.
waitForStarted
())
{
if
(
!
process
.
waitForStarted
())
{
qWarning
()
<<
"Failed to start 'ping' process for"
<<
address
;
return
false
;
return
false
;
}
}
// 使用较长的超时值,确保进程有足够时间完成
// 使用较长的超时值,确保进程有足够时间完成
if
(
!
process
.
waitForFinished
(
3000
))
{
if
(
!
process
.
waitForFinished
(
3000
))
{
process
.
kill
();
// 如果超时,强制终止进程
process
.
kill
();
// 如果超时,强制终止进程
qWarning
()
<<
"Ping process timed out for"
<<
address
;
return
false
;
return
false
;
}
}
QString
output
(
process
.
readAllStandardOutput
());
QString
output
(
process
.
readAllStandardOutput
());
qDebug
()
<<
"Ping Output for"
<<
address
<<
":"
<<
output
;
// 调试输出
// 简单的 Ping 成功检查逻辑
// 简单的 Ping 成功检查逻辑
#ifdef Q_OS_WIN
#ifdef Q_OS_WIN
...
@@ -517,7 +520,6 @@ inline bool pingAddress(const QString &address) {
...
@@ -517,7 +520,6 @@ inline bool pingAddress(const QString &address) {
#endif
#endif
}
}
inline
QString
findReachableIp
()
{
inline
QString
findReachableIp
()
{
QList
<
QHostAddress
>
ipAddressesList
=
QNetworkInterface
::
allAddresses
();
QList
<
QHostAddress
>
ipAddressesList
=
QNetworkInterface
::
allAddresses
();
for
(
const
QHostAddress
&
address
:
ipAddressesList
)
{
for
(
const
QHostAddress
&
address
:
ipAddressesList
)
{
...
@@ -527,7 +529,9 @@ inline QString findReachableIp() {
...
@@ -527,7 +529,9 @@ inline QString findReachableIp() {
for
(
int
i
=
254
;
i
>=
1
;
--
i
)
{
// 从 254 开始递减
for
(
int
i
=
254
;
i
>=
1
;
--
i
)
{
// 从 254 开始递减
QString
ip
=
currentSubnet
+
QString
::
number
(
i
);
QString
ip
=
currentSubnet
+
QString
::
number
(
i
);
qInfo
()
<<
"Found findReachableIp IP:"
<<
ip
;
if
(
!
pingAddress
(
ip
))
{
if
(
!
pingAddress
(
ip
))
{
qInfo
()
<<
"ping 不通的ip:"
<<
ip
;
return
ip
;
return
ip
;
}
}
}
}
...
...
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