mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-24 02:00:24 +07:00
in the port busy check, for tcp now only LISTEN ports are checked
This commit is contained in:
@@ -655,6 +655,11 @@ ErrorCode ServerController::isServerPortBusy(const ServerCredentials &credential
|
|||||||
script = script.append("|:%1").arg(port);
|
script = script.append("|:%1").arg(port);
|
||||||
}
|
}
|
||||||
script = script.append("' | grep -i %1").arg(transportProto);
|
script = script.append("' | grep -i %1").arg(transportProto);
|
||||||
|
|
||||||
|
if (transportProto == "tcp") {
|
||||||
|
script = script.append(" | grep LISTEN");
|
||||||
|
}
|
||||||
|
|
||||||
ErrorCode errorCode = runScript(credentials,
|
ErrorCode errorCode = runScript(credentials,
|
||||||
replaceVars(script, genVarsForScript(credentials, container)), cbReadStdOut, cbReadStdErr);
|
replaceVars(script, genVarsForScript(credentials, container)), cbReadStdOut, cbReadStdErr);
|
||||||
if (errorCode != ErrorCode::NoError) {
|
if (errorCode != ErrorCode::NoError) {
|
||||||
@@ -662,14 +667,6 @@ ErrorCode ServerController::isServerPortBusy(const ServerCredentials &credential
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!stdOut.isEmpty()) {
|
if (!stdOut.isEmpty()) {
|
||||||
if (transportProto == "tcp") {
|
|
||||||
const static QRegularExpression localPortRegExp(".*:(\\d+)->");
|
|
||||||
QRegularExpressionMatch localPortMatch = localPortRegExp.match(stdOut);
|
|
||||||
if (localPortMatch.hasMatch() && localPortMatch.captured(1) != port) {
|
|
||||||
return ErrorCode::NoError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ErrorCode::ServerPortAlreadyAllocatedError;
|
return ErrorCode::ServerPortAlreadyAllocatedError;
|
||||||
}
|
}
|
||||||
return ErrorCode::NoError;
|
return ErrorCode::NoError;
|
||||||
|
|||||||
Reference in New Issue
Block a user