V20260324
This commit is contained in:
parent
3f12dc6ee0
commit
7cf8c5c6fc
@ -386,7 +386,7 @@ endif()
|
|||||||
if(CMAKE_HOST_UNIX)
|
if(CMAKE_HOST_UNIX)
|
||||||
target_link_libraries(CC_API PUBLIC
|
target_link_libraries(CC_API PUBLIC
|
||||||
nlohmann_json
|
nlohmann_json
|
||||||
libcppp-reiconv.shared
|
libcppp-reiconv.static
|
||||||
crypto ssl
|
crypto ssl
|
||||||
)
|
)
|
||||||
if (AUDIO_IO)
|
if (AUDIO_IO)
|
||||||
@ -395,7 +395,7 @@ if(CMAKE_HOST_UNIX)
|
|||||||
elseif(CMAKE_HOST_WIN32)
|
elseif(CMAKE_HOST_WIN32)
|
||||||
target_link_libraries(CC_API PUBLIC
|
target_link_libraries(CC_API PUBLIC
|
||||||
nlohmann_json
|
nlohmann_json
|
||||||
libcppp-reiconv.shared
|
libcppp-reiconv.static
|
||||||
crypto ssl
|
crypto ssl
|
||||||
)
|
)
|
||||||
if (NOT CMAKE_SYSTEM_NAME STREQUAL "OHOS" AND NOT W_T_L_Arm)
|
if (NOT CMAKE_SYSTEM_NAME STREQUAL "OHOS" AND NOT W_T_L_Arm)
|
||||||
|
|||||||
@ -278,7 +278,7 @@ namespace CTL {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
void Conversion(T* str, const ByteHander size) {
|
void Conversion(T* str, const ByteHander size) {
|
||||||
const auto c_str = reinterpret_cast<const char*>(str);
|
const auto c_str = reinterpret_cast<const char*>(str);
|
||||||
bytes.assign(c_str, c_str + size);
|
bytes.assign(&c_str[0], &c_str[0] + size);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取字节数组的子数组。
|
* 获取字节数组的子数组。
|
||||||
|
|||||||
@ -233,7 +233,7 @@ void CTL::Application::StartDaemon(int argc, char **argv) {
|
|||||||
Sh += String::format(" {} Daemon_Start &\n", AppNamePathSh.c_str());
|
Sh += String::format(" {} Daemon_Start &\n", AppNamePathSh.c_str());
|
||||||
Sh += String::format(" echo $! > {}.pid\n", AppName.c_str());
|
Sh += String::format(" echo $! > {}.pid\n", AppName.c_str());
|
||||||
Sh += String::format(" echo \"Start {}\"\n", AppNamePathSh.c_str());
|
Sh += String::format(" echo \"Start {}\"\n", AppNamePathSh.c_str());
|
||||||
Sh += " sleep 1\n";
|
Sh += " sleep 3\n";
|
||||||
Sh += "fi\n";
|
Sh += "fi\n";
|
||||||
Sh += String::format("sleep {}\n", DaemonTime);
|
Sh += String::format("sleep {}\n", DaemonTime);
|
||||||
Sh += "done\n";
|
Sh += "done\n";
|
||||||
|
|||||||
@ -33,6 +33,9 @@ target_link_libraries(Distribution_Service PUBLIC CC_API)
|
|||||||
|
|
||||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm|ARM|Armv[0-9]+")
|
if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm|ARM|Armv[0-9]+")
|
||||||
target_link_libraries(Distribution_Service PUBLIC stdc++fs)
|
target_link_libraries(Distribution_Service PUBLIC stdc++fs)
|
||||||
|
# set_target_properties(Distribution_Service PROPERTIES
|
||||||
|
# LINK_FLAGS "-static-libgcc -static-libstdc++"
|
||||||
|
# )
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_include_directories(Distribution_Service PUBLIC
|
target_include_directories(Distribution_Service PUBLIC
|
||||||
|
|||||||
@ -13,9 +13,9 @@ std::shared_mutex Config::m_mutex_udp_tool;
|
|||||||
void Config::Save() {
|
void Config::Save() {
|
||||||
const auto Setting = getConfig();
|
const auto Setting = getConfig();
|
||||||
try {
|
try {
|
||||||
const CTL::JSONObject Json = *Setting;
|
const JSON Json(*Setting);
|
||||||
const auto Path = GetSettingDB();
|
const auto Path = GetSettingDB();
|
||||||
CTL::FileOutStream::WriteFile(Path,Json.to_String());
|
CTL::FileOutStream::WriteFile(Path,Json.dump());
|
||||||
}
|
}
|
||||||
catch (CCException& e) {
|
catch (CCException& e) {
|
||||||
BS_Log::Error("Config::Save Error: {}",e.what());
|
BS_Log::Error("Config::Save Error: {}",e.what());
|
||||||
@ -43,12 +43,28 @@ void Config::Init() {
|
|||||||
Setting->WorkingMode = Json["WorkingMode"];
|
Setting->WorkingMode = Json["WorkingMode"];
|
||||||
Setting->TermNumber = Json["TermNumber"];
|
Setting->TermNumber = Json["TermNumber"];
|
||||||
Setting->DHCPFlag = Json["DHCPFlag"];
|
Setting->DHCPFlag = Json["DHCPFlag"];
|
||||||
|
Setting->TermIPGw = Json["TermIPGw"];
|
||||||
|
Setting->TermIPNm = Json["TermIPNm"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (CCException& e) {
|
catch (CCException& e) {
|
||||||
BS_Log::Error("Config::Init Error: {}",e.what());
|
BS_Log::Error("Config::Init Error: {}",e.what());
|
||||||
}
|
}
|
||||||
|
#ifdef IS_ARM32
|
||||||
|
if (Setting->IP.empty())
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Setting->MacAddr = CTL::System::GetMac();
|
||||||
|
}
|
||||||
|
catch (...){}
|
||||||
|
Setting->IP = "192.168.1.108";
|
||||||
|
Setting->TermIPNm = "255.255.255.0";
|
||||||
|
Setting->TermIPGw = "192.168.1.1";
|
||||||
|
}
|
||||||
|
SetNetWorkInfo(Setting->IP,Setting->TermIPGw,Setting->TermIPNm);
|
||||||
|
#else
|
||||||
Setting->IP = GetIP();
|
Setting->IP = GetIP();
|
||||||
|
#endif
|
||||||
BS_Log::Log("Local IP: {}",Setting->IP.c_str());
|
BS_Log::Log("Local IP: {}",Setting->IP.c_str());
|
||||||
BS_Log::Log("Local ID: {}",Setting->ID);
|
BS_Log::Log("Local ID: {}",Setting->ID);
|
||||||
}
|
}
|
||||||
@ -86,31 +102,70 @@ CTL::String Config::GetIP() {
|
|||||||
ConfigTerm * Config::getThisInfo() {
|
ConfigTerm * Config::getThisInfo() {
|
||||||
const auto Setting = getConfig();
|
const auto Setting = getConfig();
|
||||||
const auto Data = new ConfigTerm;
|
const auto Data = new ConfigTerm;
|
||||||
std::strcpy(Data->termIDnVerStr,Setting->Ver.c_str());
|
std::memset(Data, 0, sizeof(ConfigTerm));
|
||||||
std::strcpy(Data->macStr,Setting->MacAddr.c_str());
|
#define SAFE_STRNCPY(dest, src, size) do { \
|
||||||
std::strcpy(Data->macChkStr,Setting->MacAddr.c_str());
|
const auto& s = (src); \
|
||||||
std::strcpy(Data->servIPAddrStr,Setting->ServerIP.c_str());
|
if (!s.empty()) { \
|
||||||
std::strcpy(Data->termIPAddrStr,Setting->IP.c_str());
|
std::strncpy((dest), s.c_str(), (size) - 1); \
|
||||||
std::strcpy(Data->termIPGwStr,Setting->TermIPGw.c_str());
|
(dest)[(size) - 1] = '\0'; \
|
||||||
std::strcpy(Data->termIPNmStr,Setting->TermIPNm.c_str());
|
} \
|
||||||
std::strcpy(Data->termCmdPortStr,CC::to_String(Setting->OrderPort).c_str());
|
} while(0)
|
||||||
std::strcpy(Data->servCmdPortStr,CC::to_String(Setting->ServerPort).c_str());
|
try {
|
||||||
std::strcpy(Data->termStmPortStr,CC::to_String(Setting->StreamPort).c_str());
|
SAFE_STRNCPY(Data->termIDnVerStr, Setting->Ver, sizeof(Data->termIDnVerStr));
|
||||||
// const auto workModeStrS = APPTool::GetBytes(Setting->WorkingMode);
|
SAFE_STRNCPY(Data->macStr, Setting->MacAddr, sizeof(Data->macStr));
|
||||||
// std::strcpy(Data->workModeStr,CC::to_String(Setting->WorkingMode).c_str());
|
SAFE_STRNCPY(Data->macChkStr, Setting->MacAddr, sizeof(Data->macChkStr));
|
||||||
// Data->workModeStr[0] = workModeStrS[0];
|
SAFE_STRNCPY(Data->servIPAddrStr, Setting->ServerIP, sizeof(Data->servIPAddrStr));
|
||||||
// Data->workModeStr[1] = workModeStrS[1];
|
SAFE_STRNCPY(Data->termIPAddrStr, Setting->IP, sizeof(Data->termIPAddrStr));
|
||||||
Data->workModeStr[0] = getTermWorkInfo(Setting->WorkingMode);
|
SAFE_STRNCPY(Data->termIPGwStr, Setting->TermIPGw, sizeof(Data->termIPGwStr));
|
||||||
Data->workModeStr[1] = '\0';
|
SAFE_STRNCPY(Data->termIPNmStr, Setting->TermIPNm, sizeof(Data->termIPNmStr));
|
||||||
std::strcpy(Data->btNameStr,"");
|
|
||||||
std::strcpy(Data->dhcpFlagStr,CC::to_String(Setting->DHCPFlag).c_str());
|
const auto termCmdPortStr = CC::to_String(Setting->OrderPort);
|
||||||
std::strcpy(Data->btPwdStr,"");
|
SAFE_STRNCPY(Data->termCmdPortStr, termCmdPortStr, sizeof(Data->termCmdPortStr));
|
||||||
std::strcpy(Data->termTypeStr,CC::to_String(Setting->TermNumber).c_str());
|
|
||||||
std::strcpy(Data->sipUsrNameStr,"");
|
const auto servCmdPortStr = CC::to_String(Setting->ServerPort);
|
||||||
std::strcpy(Data->sipUsrPwdStr,"");
|
SAFE_STRNCPY(Data->servCmdPortStr, servCmdPortStr, sizeof(Data->servCmdPortStr));
|
||||||
std::strcpy(Data->sipProxyRealmStr,"");
|
|
||||||
std::strcpy(Data->cmdFlagByteStr,CC::to_String("").c_str());
|
const auto termStmPortStr = CC::to_String(Setting->StreamPort);
|
||||||
std::strcpy(Data->onlineFlagStr,CC::to_String(Setting->isConnect).c_str());
|
SAFE_STRNCPY(Data->termStmPortStr, termStmPortStr, sizeof(Data->termStmPortStr));
|
||||||
|
|
||||||
|
Data->workModeStr[0] = getTermWorkInfo(Setting->WorkingMode);
|
||||||
|
Data->workModeStr[1] = '\0';
|
||||||
|
|
||||||
|
std::strncpy(Data->btNameStr, "", sizeof(Data->btNameStr) - 1);
|
||||||
|
Data->btNameStr[sizeof(Data->btNameStr) - 1] = '\0';
|
||||||
|
|
||||||
|
const auto dhcpFlagStr = CC::to_String(Setting->DHCPFlag);
|
||||||
|
SAFE_STRNCPY(Data->dhcpFlagStr, dhcpFlagStr, sizeof(Data->dhcpFlagStr));
|
||||||
|
|
||||||
|
std::strncpy(Data->btPwdStr, "", sizeof(Data->btPwdStr) - 1);
|
||||||
|
Data->btPwdStr[sizeof(Data->btPwdStr) - 1] = '\0';
|
||||||
|
|
||||||
|
const auto termTypeStr = CC::to_String(Setting->TermNumber);
|
||||||
|
SAFE_STRNCPY(Data->termTypeStr, termTypeStr, sizeof(Data->termTypeStr));
|
||||||
|
|
||||||
|
std::strncpy(Data->sipUsrNameStr, "", sizeof(Data->sipUsrNameStr) - 1);
|
||||||
|
Data->sipUsrNameStr[sizeof(Data->sipUsrNameStr) - 1] = '\0';
|
||||||
|
|
||||||
|
std::strncpy(Data->sipUsrPwdStr, "", sizeof(Data->sipUsrPwdStr) - 1);
|
||||||
|
Data->sipUsrPwdStr[sizeof(Data->sipUsrPwdStr) - 1] = '\0';
|
||||||
|
|
||||||
|
std::strncpy(Data->sipProxyRealmStr, "", sizeof(Data->sipProxyRealmStr) - 1);
|
||||||
|
Data->sipProxyRealmStr[sizeof(Data->sipProxyRealmStr) - 1] = '\0';
|
||||||
|
|
||||||
|
std::strncpy(Data->cmdFlagByteStr, "", sizeof(Data->cmdFlagByteStr) - 1);
|
||||||
|
Data->cmdFlagByteStr[sizeof(Data->cmdFlagByteStr) - 1] = '\0';
|
||||||
|
|
||||||
|
const auto onlineFlagStr = CC::to_String(Setting->isConnect);
|
||||||
|
SAFE_STRNCPY(Data->onlineFlagStr, onlineFlagStr, sizeof(Data->onlineFlagStr));
|
||||||
|
|
||||||
|
} catch (...) {
|
||||||
|
BS_Log::Error("getThisInfo: String copy exception");
|
||||||
|
delete Data;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef SAFE_STRNCPY
|
||||||
|
|
||||||
return Data;
|
return Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +181,24 @@ void Config::groupBroadcast(const CTL::ByteArray &data, int port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Config::SetNetWorkInfo(const CTL::String& IP,const CTL::String& GW,const CTL::String& Mask) {
|
void Config::SetNetWorkInfo(const CTL::String& IP,const CTL::String& GW,const CTL::String& Mask) {
|
||||||
|
#ifdef IS_ARM32
|
||||||
|
try{
|
||||||
|
CTL::String str = CTL::String::format("ifconfig eth0 down");
|
||||||
|
CTL::System::Execute(str);
|
||||||
|
CTL::Thread::SleepMS(5);
|
||||||
|
str = CTL::String::format("ifconfig eth0 up");
|
||||||
|
CTL::System::Execute(str);
|
||||||
|
CTL::Thread::SleepMS(5);
|
||||||
|
str = CTL::String::format("ifconfig eth0 {} netmask {}",IP.c_str(),Mask.c_str());
|
||||||
|
CTL::System::Execute(str);
|
||||||
|
CTL::Thread::SleepMS(5);
|
||||||
|
str = CTL::String::format("route add default gw {}",GW.c_str());
|
||||||
|
CTL::System::Execute(str);
|
||||||
|
}
|
||||||
|
catch (CCException& e){
|
||||||
|
BS_Log::Error("[fun-configure|MainConfigure] NetInit Error: {}",e.what());
|
||||||
|
}
|
||||||
|
#elif IS_ARM
|
||||||
try{
|
try{
|
||||||
//获取当前网络名称
|
//获取当前网络名称
|
||||||
const CTL::String GetNetName = ("nmcli -t -f NAME,TYPE,DEVICE,STATE con show --active");
|
const CTL::String GetNetName = ("nmcli -t -f NAME,TYPE,DEVICE,STATE con show --active");
|
||||||
@ -154,6 +227,7 @@ void Config::SetNetWorkInfo(const CTL::String& IP,const CTL::String& GW,const CT
|
|||||||
catch (CCException& e){
|
catch (CCException& e){
|
||||||
BS_Log::Error("[fun-configure|MainConfigure] NetInit Error: {}",e.what());
|
BS_Log::Error("[fun-configure|MainConfigure] NetInit Error: {}",e.what());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::CloseService() {
|
void Config::CloseService() {
|
||||||
|
|||||||
@ -31,13 +31,13 @@ struct ConfigTerm{
|
|||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
JSON_TYPE_INTRUSIVE(Config,IP,OrderPort,StreamPort,HttpPort,Flag,ServerID,ServerIP,ServerPort,ID
|
JSON_TYPE_INTRUSIVE(Config,IP,OrderPort,StreamPort,HttpPort,Flag,ServerID,ServerIP,ServerPort,ID
|
||||||
,Name,WorkingMode,TermNumber,DHCPFlag);
|
,Name,WorkingMode,TermNumber,DHCPFlag,TermIPGw,TermIPNm);
|
||||||
public:
|
public:
|
||||||
int ServerID = 2;
|
int ServerID = 2;
|
||||||
int ID = 1;
|
int ID = 1;
|
||||||
CTL::String Name = "Distribution 1";
|
CTL::String Name = "Distribution 1";
|
||||||
int ONLINEVol = 1;
|
int ONLINEVol = 1;
|
||||||
CTL::String IP = "0.0.0.0";
|
CTL::String IP = "";
|
||||||
CTL::String ServerIP = "192.168.2.208"; // 目标主服务器IP
|
CTL::String ServerIP = "192.168.2.208"; // 目标主服务器IP
|
||||||
int ServerPort = 10060; // 目标主服务器端口
|
int ServerPort = 10060; // 目标主服务器端口
|
||||||
int OrderPort = 10050; // 10060
|
int OrderPort = 10050; // 10060
|
||||||
|
|||||||
@ -104,11 +104,14 @@ public:
|
|||||||
}
|
}
|
||||||
static void Function_0xF4(const DataPacket& packet){
|
static void Function_0xF4(const DataPacket& packet){
|
||||||
const auto Setting = Config::getConfig();
|
const auto Setting = Config::getConfig();
|
||||||
ConfigTerm* t = CTL::ByteArray::Conversion<ConfigTerm>(packet.AdditionalData);
|
const auto t = CTL::ByteArray::Conversion<ConfigTerm>(packet.AdditionalData);
|
||||||
CTL::AutoDestruct<ConfigTerm> autoDestruct(t);
|
CTL::AutoDestruct<ConfigTerm> autoDestruct(t);
|
||||||
if (t) {
|
if (t) {
|
||||||
const auto TMac = CTL::String(t->macChkStr);
|
const auto TMac = CTL::String(t->macChkStr);
|
||||||
if (TMac == Setting->MacAddr) {
|
if (TMac == Setting->MacAddr) {
|
||||||
|
const auto IP_t = Setting->IP;
|
||||||
|
const auto GW_t = Setting->TermIPGw;
|
||||||
|
const auto Nm_t = Setting->TermIPNm;
|
||||||
const auto IDS = CTL::String(t->termIDnVerStr);
|
const auto IDS = CTL::String(t->termIDnVerStr);
|
||||||
if (!IDS.empty()) {
|
if (!IDS.empty()) {
|
||||||
const int ID = IDS.to_int();
|
const int ID = IDS.to_int();
|
||||||
@ -156,12 +159,20 @@ public:
|
|||||||
Setting->TermIPNm = NM;
|
Setting->TermIPNm = NM;
|
||||||
}
|
}
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
#if IS_ARM
|
BS_Log::Log("Config::Save...");
|
||||||
Config::SetNetWorkInfo(IP,Setting->TermIPGw,Setting->TermIPNm);
|
|
||||||
#endif
|
|
||||||
Config::Save();
|
Config::Save();
|
||||||
|
#if IS_ARM
|
||||||
|
if (IP_t != Setting->IP || GW_t != Setting->TermIPGw || Nm_t != Setting->TermIPNm){
|
||||||
|
BS_Log::Log("Config::SetNetWorkInfo IP:{} IPGw:{} IPNm: {}",IP.c_str(),
|
||||||
|
Setting->TermIPGw.c_str(),Setting->TermIPNm.c_str());
|
||||||
|
Config::SetNetWorkInfo(IP,Setting->TermIPGw,Setting->TermIPNm);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
BS_Log::Log("Config::CloseService...");
|
||||||
Config::CloseService();
|
Config::CloseService();
|
||||||
|
BS_Log::Log("CTL::Application::ReleaseLock...");
|
||||||
CTL::Application::ReleaseLock();
|
CTL::Application::ReleaseLock();
|
||||||
|
BS_Log::Log("std::terminate...");
|
||||||
CTL::Thread::SleepMS(1000);
|
CTL::Thread::SleepMS(1000);
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class TaskExecutor{
|
|||||||
public:
|
public:
|
||||||
//------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------
|
||||||
static void InitPool() {
|
static void InitPool() {
|
||||||
thread_pool_t.InitStart(100,1024,1000 * 5);
|
thread_pool_t.InitStart(100,100,1000 * 5);
|
||||||
}
|
}
|
||||||
static void ReleasePool() {
|
static void ReleasePool() {
|
||||||
thread_pool_t.Stop();
|
thread_pool_t.Stop();
|
||||||
|
|||||||
@ -131,13 +131,20 @@ public:
|
|||||||
BS_Log::Init();
|
BS_Log::Init();
|
||||||
Config::Init();
|
Config::Init();
|
||||||
TaskExecutor::InitPool();
|
TaskExecutor::InitPool();
|
||||||
TaskInfo::thread_pool.InitStart(255, 1024, 1000);
|
TaskInfo::thread_pool.InitStart(40, 255, 1000);
|
||||||
ConnectionService::init();
|
try
|
||||||
CC::SetCloseFun(CloseFun);
|
{
|
||||||
m_threadPool.AddTask(&ThreadMain::orderRun,this);
|
ConnectionService::init();
|
||||||
m_threadPool.AddTask(&ThreadMain::ConfigTool,this);
|
CC::SetCloseFun(CloseFun);
|
||||||
m_threadPool.AddTask(ThreadMain::ConnectService);
|
m_threadPool.AddTask(&ThreadMain::orderRun,this);
|
||||||
m_threadPool.AddTask(TaskInfo::InitSocket);
|
m_threadPool.AddTask(&ThreadMain::ConfigTool,this);
|
||||||
|
m_threadPool.AddTask(ThreadMain::ConnectService);
|
||||||
|
m_threadPool.AddTask(TaskInfo::InitSocket);
|
||||||
|
}
|
||||||
|
catch (CCException& e)
|
||||||
|
{
|
||||||
|
BS_Log::Error("ThreadMain init: {}",e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
5
gk7205-mount
Normal file
5
gk7205-mount
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
mount -t nfs -o nolock,tcp 192.168.2.208:/home/qingjiao/tarns /mnt
|
||||||
|
ifconfig eth0 up
|
||||||
|
ifconfig eth0 192.168.2.36 netmask 255.255.255.0
|
||||||
|
route add default gw 192.168.2.254
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user