From 5b74eb44e9f78371490329d425e2f6d685fd70b6 Mon Sep 17 00:00:00 2001 From: huangxin Date: Mon, 21 Nov 2022 15:48:57 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E4=BF=AE=E6=AD=A3=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D=E4=B8=BA=E8=BF=9B=E7=A8=8B=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=202.=20=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/opendhcp.ini | 10 +++++----- srcs/libs/CMakeLists.txt | 3 +-- srcs/libs/crypto/base64.c | 6 +++--- srcs/libs/include/config.h | 1 + srcs/libs/init/init.c | 5 +++-- srcs/libs/misc/misc.c | 11 +++++++++++ srcs/vcpe_main.c | 1 - 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/config/opendhcp.ini b/config/opendhcp.ini index 189cdd9..e67e089 100644 --- a/config/opendhcp.ini +++ b/config/opendhcp.ini @@ -43,14 +43,14 @@ LogLevel=All # This is http inerface for viewing lease status, # Default is 127.0.0.1:6789 # 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 # HTTP client IPs Here. If no Client IP is specified then All # Clients can access the HTTP Interface -HTTPClient=192.168.30.1 -HTTPClient=192.168.30.110 -HTTPClient=192.168.100.1 -HTTPClient=192.168.100.110 +#HTTPClient=192.168.30.1 +#HTTPClient=192.168.30.110 +#HTTPClient=192.168.100.1 +#HTTPClient=192.168.100.110 ;HTTPClient=192.168.23.123 # You can also change the title of html page ;HTTPTitle=This is Custom Title diff --git a/srcs/libs/CMakeLists.txt b/srcs/libs/CMakeLists.txt index b380b06..16f58b2 100644 --- a/srcs/libs/CMakeLists.txt +++ b/srcs/libs/CMakeLists.txt @@ -6,8 +6,7 @@ include(ExternalProject) INCLUDE_DIRECTORIES(include ./ ./include ../lwip/src/include ../lwip/src/arch_linux/include ../include - ../httpserver/include ../httpserver/src/haywire ../httpserver/src/haywire/configuration - ${COMMON_INCLUDE}) + ../httpserver/include ../httpserver/src/haywire ../httpserver/src/haywire/configuration) FILE(GLOB C_HEADS include/*.h include/uthash/*.h include/s2j/*.h vector/*.h) AUX_SOURCE_DIRECTORY(json C_SRC) diff --git a/srcs/libs/crypto/base64.c b/srcs/libs/crypto/base64.c index e839c46..c5c64ac 100644 --- a/srcs/libs/crypto/base64.c +++ b/srcs/libs/crypto/base64.c @@ -83,7 +83,7 @@ const char *base64_encode(unsigned char *pSrc, unsigned int sLen) { 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); memset(pEncode, 0, size); @@ -118,7 +118,7 @@ unsigned char *base64_decode(const char *pBase64, unsigned int *pOutSize) { return (NULL); } - size = strlen(pBase64); + size = (int)strlen(pBase64); pDecode = (unsigned char *)malloc(size); memset(pDecode, 0, size); #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)); #else 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 if (pOutSize) { *pOutSize = enSize; diff --git a/srcs/libs/include/config.h b/srcs/libs/include/config.h index d716a82..73d1ba1 100644 --- a/srcs/libs/include/config.h +++ b/srcs/libs/include/config.h @@ -66,6 +66,7 @@ typedef enum { } CONFIG_ITEM_ID; const char *get_cur_process_dir(); +const char*get_cur_process_name(); const char *config_get_ssl_ca_path(); const char *cfg_get_config_directory(); diff --git a/srcs/libs/init/init.c b/srcs/libs/init/init.c index f6c524f..2866496 100644 --- a/srcs/libs/init/init.c +++ b/srcs/libs/init/init.c @@ -72,7 +72,7 @@ int user_init(const char *pAppCfgFile, const char *pCfgDirectory, const char *pK utstring_new(pPath); 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); zlog_profile(); 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)); } - 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); diff --git a/srcs/libs/misc/misc.c b/srcs/libs/misc/misc.c index d8934d8..bf2ee09 100644 --- a/srcs/libs/misc/misc.c +++ b/srcs/libs/misc/misc.c @@ -232,4 +232,15 @@ int get_nic_info(const char *pName, unsigned int *pIp, unsigned int *pNetmask, u close(sock); 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); } \ No newline at end of file diff --git a/srcs/vcpe_main.c b/srcs/vcpe_main.c index 51aee84..32754dd 100644 --- a/srcs/vcpe_main.c +++ b/srcs/vcpe_main.c @@ -47,7 +47,6 @@ static void lwip_init_env() { int main(int argc, char **argv) { int ret; - hiredisResetAllocators(); #ifdef OPENDHCPDDNS_ON return dual_server_main(argc, argv); #else