Forráskód Böngészése

Z991239-6413 #comment 去除无用的接口

80374374 3 hónapja
szülő
commit
1f80f34be7

+ 0 - 5
Framework/Common/SpSecureClient.h

@@ -37,11 +37,6 @@ public:
 	// 手工指定通讯参数,@nOption:1、重新鉴权新建会话密钥;2、通过握手使用缓存会话密钥;3、不使用会话密钥,即非安全通道; 4、不协商,直接使用共享会话密钥
 	bool Connect(const char *pServerAddr, int nPort, int nOption); // wait until all authentication operation has been finished
 
-	// !!!!!!!! 此函数已降级,请使用ConnectFromCentralSetting
-	// 使用实体配置项连接, 连接参数从实体配置文件中读取 [Main::Server]和[Main::Server_Backup]项
-	/** 将接口已废弃 [Gifur@202316]*/
-	bool ConnectFromConfig(int nOption);
-		
 	// 使用集中配置项连接
 	bool ConnectFromCentralSetting();
 	

+ 0 - 35
Framework/spbase/SpSecureClient.cpp

@@ -167,41 +167,6 @@ bool SpSecureClient::Connect(const char *pServerAddr, int nPort, int nOption) //
 	return result;
 }
 
-// 使用配置项连接, 连接参数从实体配置文件中读取 [Main]/Server和[Main]/Server_Backup项
-// @option:1、重新鉴权新建会话密钥;2、通过握手使用缓存会话密钥;
-// 3、不使用会话密钥,即非安全通道;	 4、不协商,直接使用共享会话密钥
-bool SpSecureClient::ConnectFromConfig(int nOption)
-{
-	DbgWithLink_DualActive("ConnectFromConfig has been deprecated.");
-	return false;
-
-	if (IsConnectionOK())
-		return true;
-
-	const char* pEntityName = m_pEntity->GetEntityName();
-	ENTITY_CONNECT_INFO connectInfo;
-	if (!readConnectInfoFromConfig(pEntityName, &connectInfo))
-	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Read %s Info Failed", pEntityName);
-		return false;
-	}
-
-	// 判断当前是否已经准入,已准入时强制使用加密通道
-	int nActOption = nOption;
-
-	CSimpleStringA strVal;
-	const ErrorCodeEnum result = m_pEntity->GetFunction()->GetSysVar("EntryPermit", strVal);
-	if (Error_Succeed == result) {
-        if (strVal == "L" && stricmp(pEntityName, "AccessAuthorization") != 0 && stricmp(pEntityName, "Initializer") != 0)
-            nActOption = 2;	// 优先使用缓存密钥
-	}
-
-	if (1 == connectInfo.m_DualActive)
-		return Connect_Dual(&connectInfo, nOption);
-	else
-		return Connect_Single(&connectInfo, nOption);
-}
-
 bool SpSecureClient::readConnectInfoFromConfig(const char *pEntityName, ENTITY_CONNECT_INFO *connectInfo)
 {
 	if (NULL == pEntityName || NULL == connectInfo)

+ 0 - 2
Framework/spbase/test/SpSecureClientTest.cxx

@@ -69,8 +69,6 @@ class CMockSecureClient : public SpSecureClient
 public:
 	CMockSecureClient(CEntityBase* pEntityBase):SpSecureClient(pEntityBase){}
 	
-	//MOCK_METHOD3(Connect, bool(const char* pServerAddr, int nPort, int nOption));
-	MOCK_METHOD1(ConnectFromConfig, bool(int nOption));
 	MOCK_METHOD0(ConnectFromCentralSetting, bool());
 	MOCK_METHOD0(IsConnectionOK, bool());
 	MOCK_METHOD0(IsSecureConn, bool());

+ 1 - 205
Module/mod_accessauth/comm.cpp

@@ -67,20 +67,6 @@ string GetOutPutStr(const char* form, ...) {
 	return ret;
 }
 
-int no_begin_with(const char strA[], const char strB[]) {
-	if (strA == NULL) return 1;
-	if (strB == NULL) return 1;
-	if (strlen(strA) == 0 || strlen(strB) == 0 || strlen(strA) < strlen(strB)) return 1;
-	const char* pA = strA;
-	const char* pB = strB;
-	while (*pA != '\0' && *pB != '\0') {
-		if (*pA != *pB) return 1;
-		pA++;
-		pB++;
-	}
-	return 0;
-}
-
 int str2int(const string str, int& ret) {
 	if (str.size() == 0) return 1;
 	ret = 0;
@@ -111,49 +97,6 @@ int str2int(const string str) {
 	return ret;
 }
 
-vector<string> split_str(string strA, string strB) {
-	vector<string> ret;
-	//cout << "ret:" << ret.size() << endl;
-	if (strA.size() == 0 || strB.size() == 0) {
-		return ret;
-	}
-	char* chA = new char[strA.size()];
-	char* chB = new char[strB.size()];
-	memset(chA, 0, sizeof(chA));
-	memset(chB, 0, sizeof(chB));
-	strcpy(chA, strA.c_str());
-	strcpy(chB, strB.c_str());
-	char* tmp = strtok(chA, chB);
-	while (tmp) {
-		//cout << "tmp:" << tmp << endl;
-		ret.push_back(tmp);
-		tmp = strtok(NULL, chB);
-
-	}
-	delete[] chA;
-	delete[] chB;
-	return ret;
-}
-
-int ip2byte(const string str, BYTE ip[]) {
-	vector<string> ret = split_str(str, ".");
-	vector<string>::iterator it = ret.begin();
-	int index = 0;
-	while (it != ret.end()) {
-		int tmp = 0;
-		if (str2int(*it, tmp)) return 1;
-		else {
-			if (tmp > 255) return 2;
-			else {
-				ip[index] = tmp;
-				index++;
-			}
-		}
-		it++;
-	}
-	return 0;
-}
-
 unsigned char Ch2Hex(char ch)
 {
 	static const char* hex = "0123456789ABCDEF";
@@ -205,45 +148,6 @@ char* Str2Hex(const char* src, int srcLen)
 
 #ifdef __linux__
 	
-	int getIPFromLinux(char* ip) {
-		//if (strlen(ip) < 15) return 1;
-		struct ifaddrs* ifAddrStruct = NULL;
-		void* tmpAddrPtr = NULL;
-		getifaddrs(&ifAddrStruct);
-
-		while (ifAddrStruct != NULL) {
-			if (ifAddrStruct->ifa_addr->sa_family == AF_INET) { 
-				// is a valid IP4 Address
-				tmpAddrPtr = &((struct sockaddr_in*)ifAddrStruct->ifa_addr)->sin_addr;
-				char addressBuffer[INET_ADDRSTRLEN];
-				inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
-				//printf("%s IP Address %s\n", ifAddrStruct->ifa_name, addressBuffer);
-				//99开头行内办公网,10开头行内业务网。规范出自《招商银行总行网络规范汇编(2017年版).pdf》
-				if (!no_begin_with(addressBuffer, "99") || !no_begin_with(addressBuffer, "10")) {
-					memset(ip, 0, sizeof(ip));
-					strcpy(ip, addressBuffer);
-				}
-				else if (strlen(ip) == 0 && no_begin_with(addressBuffer, "127.0")) {
-					memset(ip, 0, sizeof(ip));
-					strcpy(ip, addressBuffer);
-				}
-
-			}
-			/*
-			else if (ifAddrStruct->ifa_addr->sa_family==AF_INET6) { // check it is IP6
-				// is a valid IP6 Address
-				tmpAddrPtr=&((struct sockaddr_in *)ifAddrStruct->ifa_addr)->sin_addr;
-				char addressBuffer[INET6_ADDRSTRLEN];
-				inet_ntop(AF_INET6, tmpAddrPtr, addressBuffer, INET6_ADDRSTRLEN);
-				printf("%s IP Address %s\n", ifAddrStruct->ifa_name, addressBuffer);
-			}
-			*/
-			ifAddrStruct = ifAddrStruct->ifa_next;
-		}
-		//printf("ip=%s\n", ip);
-		return 0;
-	}
-
 	void parse_cpu_id(const char* file_name, const char* match_words, std::string& cpu_id)
 	{
 		cpu_id.c_str();
@@ -493,27 +397,11 @@ char* Str2Hex(const char* src, int srcLen)
     }
 
 #include <unistd.h>
-	bool file_is_exist(string filePath) {
-		return (access(filePath.c_str(), F_OK) == 0);
-	}
 
 	bool dir_is_exist(string dirPath) {
 		return (access(dirPath.c_str(), F_OK) == 0);
 	}
-	//创建成功返回0,创建失败返回1,已经存在返回2
-	int file_create(string filePath) {
-		if (!file_is_exist(filePath)) {
-			FILE* fp;
-			if (fp = fopen(filePath.c_str(), "w")) {
-				fclose(fp);
-				return 0;
-			}
-			else {
-				return 1;
-			}
-		}
-		return 2;
-	}
+
 
 #include <sys/stat.h>
 	//创建成功返回0
@@ -524,58 +412,7 @@ char* Str2Hex(const char* src, int srcLen)
 		return 0;
 	}
 
-	//删除成功返回0
-	int remove_file(string filePath) {
-		return remove(filePath.c_str());
-	}
-
 #include <dirent.h>
-	int remove_dir(string dirPath) {
-		DIR* dir;
-		struct dirent* ptr;
-		dir = opendir(dirPath.c_str());
-		if (dir == NULL) return 1;
-		while ((ptr = readdir(dir)) != NULL) {
-			if (strcmp(ptr->d_name, ".") == 0 || strcmp(ptr->d_name, "..") == 0) continue;
-			char path[1024] = { 0 };
-			strcpy(path, dirPath.c_str());
-			strcat(path, "/");
-			strcat(path, ptr->d_name);
-			if (ptr->d_type == DT_DIR) {
-				remove_dir(path);
-			}
-			else {
-				if (remove_file(path) != 0) return 1;
-			}
-		}
-		closedir(dir);
-		return rmdir(dirPath.c_str());
-	}
-
-	bool set_system_time(TIME* _time)
-	{
-		struct tm p;
-		p.tm_year = _time->year - 1900;
-		p.tm_mon = _time->month - 1;
-		p.tm_mday = _time->day;
-		p.tm_hour = _time->hour;
-		p.tm_min = _time->minute;
-		p.tm_sec = _time->second;
-		//cout << p.tm_year << " " << p.tm_mon << " " << p.tm_mday << " " << p.tm_hour << " " << p.tm_min << " " << p.tm_sec << endl;
-
-		time_t sec = mktime(&p);
-		//cout << sec << endl;
-
-		struct timeval tv;
-		tv.tv_sec = sec;
-		//cout << tv.tv_sec << endl;
-
-		if (settimeofday(&tv, NULL) < 0)
-		{
-			return false;
-		}
-		return true;
-	}
 
 	bool set_system_time_by_sec(int sec)
 	{
@@ -594,45 +431,4 @@ char* Str2Hex(const char* src, int srcLen)
 		return true;
 	}
 
-	TIME* get_system_time()
-	{
-		TIME* t = new TIME();
-
-		time_t timep;
-		time(&timep);
-
-		struct tm* p;
-		p = localtime(&timep);
-
-		t->year = 1900 + p->tm_year;
-		t->month = 1 + p->tm_mon;
-		t->day = p->tm_mday;
-		t->hour = p->tm_hour;
-		t->minute = p->tm_min;
-		t->second = p->tm_sec;
-
-		return t;
-	}
-
-	string time2str(const TIME* tim) {
-		if (tim == NULL) return "";
-		string ret;
-		char timeStr[16] = { 0 };
-		sprintf(timeStr, "%04d%02d%02d%02d%02d%02d", tim->year,
-			tim->month, tim->day, tim->hour, tim->minute, tim->second);
-		ret = timeStr;
-		return ret;
-	}
-
-	TIME* str2time(string str) {
-		if (str.length() < 14) return NULL;
-		TIME* ret = new TIME();
-		ret->year = str2int(str.substr(0, 4));
-		ret->month = str2int(str.substr(4, 2));
-		ret->day = str2int(str.substr(6, 2));
-		ret->hour = str2int(str.substr(8, 2));
-		ret->minute = str2int(str.substr(10, 2));
-		ret->second = str2int(str.substr(12, 2));
-		return ret;
-	}
 #endif // __linux__

+ 0 - 15
Module/mod_accessauth/comm.h

@@ -34,16 +34,10 @@ void GetNewForm(const char* form, char* newForm);
 
 string GetOutPutStr(const char* form, ...);
 
-int no_begin_with(const char strA[], const char strB[]);
-
 int str2int(const string str, int& ret);
 
 int str2int(const string str);
 
-vector<string> split_str(string strA, string strB);
-
-int ip2byte(const string str, BYTE ip[]);
-
 char* Hex2Str(const char* src, int& dstLen);
 
 char* Str2Hex(const char* str, int strLen);
@@ -55,17 +49,12 @@ char* Str2Hex(const char* str, int strLen);
 #include <netinet/in.h> 
 #include <arpa/inet.h>
 #include <unistd.h>
-int getIPFromLinux(char* ip);
 bool get_cpu_id_by_asm(std::string & cpu_id);
 bool get_cpu_id_by_system(std::string& cpu_id, const string save_path = RUNTIME_PATH);
 bool get_board_serial_by_system(std::string& board_serial, const string save_path = RUNTIME_PATH);
 bool get_disk_serial_by_system(std::vector<string>& serial_no, int& errCode, const string save_path = RUNTIME_PATH);
-bool file_is_exist(string filePath);
 bool dir_is_exist(string dirPath);
-int file_create(string filePath);
 int dir_create(string dirPath);
-int remove_file(string filePath);
-int remove_dir(string dirPath);
 #include<sys/time.h>
 #include <time.h>
 typedef struct {
@@ -76,11 +65,7 @@ typedef struct {
 	int minute;
 	int second;
 } TIME;
-bool set_system_time(TIME * _time);
 extern "C" bool set_system_time_by_sec(int sec);
-TIME* get_system_time();
-string time2str(const TIME * tim);
-TIME* str2time(string str);
 #endif //__linux__
 
 #endif // !__COMM_H

+ 0 - 8
Module/mod_heartbeat/HeartBeatFSM.cpp

@@ -1131,18 +1131,10 @@ void HeartBeatConnection::SendHandShake()
 	//oiltest set default value
 	CSimpleStringA warningLevel("w"),runState("O"),customerHandle("c"),callState("s"),
 		localMaintain("l"),remoteMaintain("m"),termStage("U");
-	//m_pEntity->GetFunction()->GetSysVar("WarningLevel",warningLevel);
-
 	strncpy(req.TerminalNo,m_TerminalNo.GetData(),m_TerminalNo.GetLength());
-	//m_pEntity->GetFunction()->GetSysVar("RunState",runState);
 	m_pEntity->GetFunction()->GetSysVar("CustomerHandle",customerHandle);
 	m_pEntity->GetFunction()->GetSysVar("CallState",callState);
-	//m_pEntity->GetFunction()->GetSysVar("LocalMaintain",localMaintain);
-	//m_pEntity->GetFunction()->GetSysVar("RemoteMaintain",remoteMaintain);
 	m_pEntity->GetFunction()->GetSysVar("TerminalStage",termStage);
-	//Dbg("ts[%s]",(LPCTSTR)termStage);
-	//oiltest byteorder
-
 	req.ip = GetLocalIP();
 	req.WarningLevel = warningLevel[0];
 	req.RunState = runState[0];