Distribution_Service/Server/Configuration/Config.h
2025-12-05 16:46:23 +08:00

89 lines
3.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef DISTRIBUTION_SERVICE_CONFIG_H
#define DISTRIBUTION_SERVICE_CONFIG_H
#include "CCDatagramSocket.h"
#include "CCFile.h"
#include "CCJSONObject.h"
#include "CCString.h"
struct ConfigTerm{
char macChkStr[20]; //终端Mac
char termIDnVerStr[20]; //发送的是软件版本接收的是终端ID
char macStr[20]; //终端Mac地址
char servIPAddrStr[20]; //服务器IP地址
char termIPAddrStr[20]; //终端IP
char termIPGwStr[20]; //终端IP网关
char termIPNmStr[20]; //子网掩码
char termCmdPortStr[6]; //终端指令端口号
char servCmdPortStr[6]; //服务器指令端口号
char termStmPortStr[6]; //终端码流端口号
char workModeStr[2]; //工作模式
char btNameStr[32]; //蓝牙音频名称
char dhcpFlagStr[2]; //DHCP开关标识
char btPwdStr[5]; //蓝牙音频密码
char termTypeStr[6]; //终端类型
char sipUsrNameStr[30]; //SIP用户名称
char sipUsrPwdStr[30]; //SIP用户密码
char sipProxyRealmStr[30]; //SIP服务器IP地址/域名
char cmdFlagByteStr[3]; //指令标识
char onlineFlagStr[2]; //在线状态标志
};
class Config {
JSON_TYPE_INTRUSIVE(Config,IP,OrderPort,StreamPort,HttpPort,Flag,ServerID,ServerIP,ServerPort,ID
,Name);
public:
int ServerID = 2;
int ID = 1;
CTL::String Name = "Distribution 1";
int ONLINEVol = 1;
CTL::String IP = "0.0.0.0";
CTL::String ServerIP = "192.168.2.208"; // 目标主服务器IP
int ServerPort = 10060; // 目标主服务器端口
int OrderPort = 10050; // 10060
int ConfigPort = 22060; // 22060
int StreamPort = 10062;
bool isConnect = false;
int HttpPort = 9090;
bool Flag = false;
CTL::String MacAddr;
CTL::String TermIPGw;
CTL::String TermIPNm;
CTL::String Ver = "DS:V0.11(251205A)";
inline static std::shared_mutex m_mutex_udp;
CTL::DatagramSocket* m_socket_udp = nullptr;
inline static std::shared_mutex m_mutex_udp_tool;
CTL::DatagramSocket* m_socket_udp_tool = nullptr;
CTL::IPVX IP_x = CTL::IPV4;
private:
public:
static void Save();
static void Init();
static Config* getConfig();
static bool IsRunning();
static CTL::String GetFileDir() {
return CCFile::NormalizePath("./");
}
static CTL::String GetSettingDir() {
const auto root = GetFileDir();
const auto path = CCFile::NormalizePath(root + "/Setting");
const CCFile file(path);
if(!file.isExists()){
CCFile::Create(path,true);
}
return path;
}
static CTL::String GetSettingDB() {
const auto root = GetSettingDir();
return CCFile::NormalizePath(root + "/Setting.json");
}
static CTL::String GetIP();
static ConfigTerm *getThisInfo();
static void groupBroadcast(const CTL::ByteArray& data,int port);
static void SetNetWorkInfo(const CTL::String& IP,const CTL::String& GW,const CTL::String& Mask);
static void CloseService();
static CTL::String GetNetMaskCIDR(const CTL::String& Mask);/*获取CIDR格式子网掩码*/
};
#endif