diff --git a/srcs/open_dhcp/opendhcpd.cpp b/srcs/open_dhcp/opendhcpd.cpp index 507c865..2362969 100644 --- a/srcs/open_dhcp/opendhcpd.cpp +++ b/srcs/open_dhcp/opendhcpd.cpp @@ -4388,6 +4388,9 @@ void *init(void *lparam) { } } + // 合并 vcpe.cfg 配置文件配置内容 + opendhcp_add_listener(); + /* for (int i = 0; i < cfig.rangeCount; i++) { diff --git a/srcs/open_dhcp/opendhcpd.h b/srcs/open_dhcp/opendhcpd.h index 710aef5..815d2e3 100644 --- a/srcs/open_dhcp/opendhcpd.h +++ b/srcs/open_dhcp/opendhcpd.h @@ -609,6 +609,7 @@ MYWORD qLen(char *); const char *getRequestMethod(const char *buffer); void prepareUserHtmlRespStatus(data19 *req); void opendhcp_init_http_server(); +int opendhcp_add_listener(); void sendUserList(data19 *req, const char *pRequest, dhcpMap *dhcpCache, data2 *cfig, time_t t); void sendAllLists(data19 *req, bool kRunning, dhcpMap *dhcpCache, data2 *cfig); int getHwAddr(char *buff, char *mac); diff --git a/srcs/open_dhcp/query.cpp b/srcs/open_dhcp/query.cpp index 6a3dd3e..64e444c 100644 --- a/srcs/open_dhcp/query.cpp +++ b/srcs/open_dhcp/query.cpp @@ -593,6 +593,28 @@ static void opendhcp_http_expand_rangeset(http_request *request, hw_http_respons hw_http_response_send(response, req, response_complete); } +/** + * 添加配置文件监听接口 + * @return + */ +int opendhcp_add_listener() { + int i; + vector listen_ip = config_get_dhcp_listen_on(); + + for (i = 0; listen_ip && i < vect_size(listen_ip); i++) { + const char *pIp = (const char *)vect_get_at(listen_ip, i); + if (pIp && strlen(pIp) > 0) { + MYDWORD addr = inet_addr(pIp); + addServer(cfig.specifiedServers, MAX_SERVERS, addr); + } + } + + return i; +} + +/** + * 增加 DHCP Server HTTP服务接口 + */ void opendhcp_init_http_server() { static int added = FALSE;