|
@@ -38,7 +38,9 @@
|
|
|
#include "sp_httpDefine.h"
|
|
|
#include <iostream>
|
|
|
#include <sstream>
|
|
|
-
|
|
|
+#include <future>
|
|
|
+#include <chrono>
|
|
|
+#include <thread>
|
|
|
|
|
|
|
|
|
|
|
@@ -1744,11 +1746,31 @@ ErrorCodeEnum SpEntity::GetToken(CSimpleString &channelId, CSimpleString &token)
|
|
|
|
|
|
ErrorCodeEnum SpEntity::SetNewPathToFirewall(CSimpleString &pszPath)
|
|
|
{
|
|
|
+ if (pszPath.GetLength() == 0) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SetNewPathToFirewall param error");
|
|
|
+ return Error_Param;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
#ifdef _WIN32
|
|
|
- return sp_AddFirewallRuleByPath(pszPath.GetData()) ? Error_Succeed : Error_Bug;
|
|
|
+ auto addFirewall_worker = [this](std::string path)
|
|
|
+ {
|
|
|
+ return sp_AddFirewallRuleByPath(path.c_str()) ? Error_Succeed : Error_Bug;
|
|
|
+ };
|
|
|
+
|
|
|
+ std::future<ErrorCodeEnum> result = std::async(std::launch::async, addFirewall_worker, pszPath.GetData());
|
|
|
+
|
|
|
+ auto status = result.wait_for(std::chrono::seconds(30));
|
|
|
+ if (status == std::future_status::ready)
|
|
|
+ return result.get();
|
|
|
+ else
|
|
|
+ return Error_TimeOut;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
#else
|
|
|
return Error_NotSupport;
|
|
|
-#endif // RVC_OS_WIN
|
|
|
+#endif // RVC_OS_WIN
|
|
|
|
|
|
|
|
|
}
|