OCT 1. 修正日志文件名为进程文件名

2. 修正部分代码格式问题
This commit is contained in:
huangxin 2022-11-21 15:48:57 +08:00
parent 42795a7361
commit 5b74eb44e9
7 changed files with 24 additions and 13 deletions

View File

@ -43,14 +43,14 @@ LogLevel=All
# This is http inerface for viewing lease status, # This is http inerface for viewing lease status,
# Default is 127.0.0.1:6789 # Default is 127.0.0.1:6789
# You can change it here to any network interface. # You can change it here to any network interface.
HTTPServer=192.168.30.1:6789 #HTTPServer=192.168.30.1:6789
# Also to limit the clients access, you can specify upto 8 # Also to limit the clients access, you can specify upto 8
# HTTP client IPs Here. If no Client IP is specified then All # HTTP client IPs Here. If no Client IP is specified then All
# Clients can access the HTTP Interface # Clients can access the HTTP Interface
HTTPClient=192.168.30.1 #HTTPClient=192.168.30.1
HTTPClient=192.168.30.110 #HTTPClient=192.168.30.110
HTTPClient=192.168.100.1 #HTTPClient=192.168.100.1
HTTPClient=192.168.100.110 #HTTPClient=192.168.100.110
;HTTPClient=192.168.23.123 ;HTTPClient=192.168.23.123
# You can also change the title of html page # You can also change the title of html page
;HTTPTitle=This is Custom Title ;HTTPTitle=This is Custom Title

View File

@ -6,8 +6,7 @@ include(ExternalProject)
INCLUDE_DIRECTORIES(include INCLUDE_DIRECTORIES(include
./ ./include ../lwip/src/include ../lwip/src/arch_linux/include ../include ./ ./include ../lwip/src/include ../lwip/src/arch_linux/include ../include
../httpserver/include ../httpserver/src/haywire ../httpserver/src/haywire/configuration ../httpserver/include ../httpserver/src/haywire ../httpserver/src/haywire/configuration)
${COMMON_INCLUDE})
FILE(GLOB C_HEADS include/*.h include/uthash/*.h include/s2j/*.h vector/*.h) FILE(GLOB C_HEADS include/*.h include/uthash/*.h include/s2j/*.h vector/*.h)
AUX_SOURCE_DIRECTORY(json C_SRC) AUX_SOURCE_DIRECTORY(json C_SRC)

View File

@ -83,7 +83,7 @@ const char *base64_encode(unsigned char *pSrc, unsigned int sLen) {
return (NULL); return (NULL);
} }
size = ((sLen / 3) * 4) + 4 + (sLen / 64) + sLen % 64; size = (int)(((sLen / 3) * 4) + 4 + (sLen / 64) + sLen % 64);
pEncode = (char *)malloc(size); pEncode = (char *)malloc(size);
memset(pEncode, 0, size); memset(pEncode, 0, size);
@ -118,7 +118,7 @@ unsigned char *base64_decode(const char *pBase64, unsigned int *pOutSize) {
return (NULL); return (NULL);
} }
size = strlen(pBase64); size = (int)strlen(pBase64);
pDecode = (unsigned char *)malloc(size); pDecode = (unsigned char *)malloc(size);
memset(pDecode, 0, size); memset(pDecode, 0, size);
#if !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L #if !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
@ -126,7 +126,7 @@ unsigned char *base64_decode(const char *pBase64, unsigned int *pOutSize) {
EVP_DecodeUpdate(&ctx, pDecode, &enSize, (const unsigned char *)pBase64, strlen(pBase64)); EVP_DecodeUpdate(&ctx, pDecode, &enSize, (const unsigned char *)pBase64, strlen(pBase64));
#else #else
EVP_DecodeInit(pCtx); EVP_DecodeInit(pCtx);
EVP_DecodeUpdate(pCtx, pDecode, &enSize, (const unsigned char *)pBase64, strlen(pBase64)); EVP_DecodeUpdate(pCtx, pDecode, &enSize, (const unsigned char *)pBase64, (int)strlen(pBase64));
#endif #endif
if (pOutSize) { if (pOutSize) {
*pOutSize = enSize; *pOutSize = enSize;

View File

@ -66,6 +66,7 @@ typedef enum {
} CONFIG_ITEM_ID; } CONFIG_ITEM_ID;
const char *get_cur_process_dir(); const char *get_cur_process_dir();
const char*get_cur_process_name();
const char *config_get_ssl_ca_path(); const char *config_get_ssl_ca_path();
const char *cfg_get_config_directory(); const char *cfg_get_config_directory();

View File

@ -72,7 +72,7 @@ int user_init(const char *pAppCfgFile, const char *pCfgDirectory, const char *pK
utstring_new(pPath); utstring_new(pPath);
utstring_printf(pPath, "%s/%s", bufCfgDir, "zlog.conf"); utstring_printf(pPath, "%s/%s", bufCfgDir, "zlog.conf");
if ((ret = dzlog_init(utstring_body(pPath), "libagent")) != ERR_SUCCESS) { if ((ret = dzlog_init(utstring_body(pPath), get_cur_process_name())) != ERR_SUCCESS) {
printf("Zlog configure file [%s] init result: %d+++++\n", utstring_body(pPath), ret); printf("Zlog configure file [%s] init result: %d+++++\n", utstring_body(pPath), ret);
zlog_profile(); zlog_profile();
return -ERR_ZLOG_INIT; return -ERR_ZLOG_INIT;
@ -80,7 +80,8 @@ int user_init(const char *pAppCfgFile, const char *pCfgDirectory, const char *pK
dzlog_info("Zlog used configure file [%s]\n", utstring_body(pPath)); dzlog_info("Zlog used configure file [%s]\n", utstring_body(pPath));
} }
zlog_level_switch(zlog_get_category("libagent"), logLevel > ZLOG_LEVEL_DEBUG ? logLevel : ZLOG_LEVEL_DEBUG); zlog_level_switch(zlog_get_category(get_cur_process_name()),
logLevel > ZLOG_LEVEL_DEBUG ? logLevel : ZLOG_LEVEL_DEBUG);
utstring_free(pPath); utstring_free(pPath);

View File

@ -233,3 +233,14 @@ int get_nic_info(const char *pName, unsigned int *pIp, unsigned int *pNetmask, u
close(sock); close(sock);
return err; return err;
} }
const char*get_cur_process_name() {
static char g_exeName[1024];
memset(g_exeName, 0, 1024);
if (readlink("/proc/self/exe", g_exeName, 1023) <= 0) {
return NULL;
}
return basename_v2(g_exeName);
}

View File

@ -47,7 +47,6 @@ static void lwip_init_env() {
int main(int argc, char **argv) { int main(int argc, char **argv) {
int ret; int ret;
hiredisResetAllocators();
#ifdef OPENDHCPDDNS_ON #ifdef OPENDHCPDDNS_ON
return dual_server_main(argc, argv); return dual_server_main(argc, argv);
#else #else