OCT 增加HTTP服务配置项支持
This commit is contained in:
parent
a933d6a44a
commit
1aaad54c7e
|
@ -326,12 +326,8 @@ const char *config_item_dump_fmt(const char *titleMessage) {
|
||||||
CFG_BOOL_VALUE(pItem) ? "True" : "False");
|
CFG_BOOL_VALUE(pItem) ? "True" : "False");
|
||||||
break;
|
break;
|
||||||
case VALUE_TYPE_INTEGRAL:
|
case VALUE_TYPE_INTEGRAL:
|
||||||
s = sdscatprintf(s,
|
s = sdscatprintf(
|
||||||
"|%4d | %-25s | %-45s | %-44lld |\n",
|
s, "|%4d | %-25s | %-45s | %-44lld |\n", pItem->cfgId, tmp2, pItem->pcfgKey, CFG_INT_VALUE(pItem));
|
||||||
pItem->cfgId,
|
|
||||||
tmp2,
|
|
||||||
pItem->pcfgKey,
|
|
||||||
CFG_INT_VALUE(pItem));
|
|
||||||
break;
|
break;
|
||||||
case VALUE_TYPE_FLOAT:
|
case VALUE_TYPE_FLOAT:
|
||||||
s = sdscatprintf(s,
|
s = sdscatprintf(s,
|
||||||
|
@ -491,6 +487,10 @@ do {
|
||||||
ADD_CFG_ITEM(CFG_VXLAN_PEER_IP, "application.vxlan_wan.peer_ip", VALUE_TYPE_STRING, "", "vxLan peer ip address"); \
|
ADD_CFG_ITEM(CFG_VXLAN_PEER_IP, "application.vxlan_wan.peer_ip", VALUE_TYPE_STRING, "", "vxLan peer ip address"); \
|
||||||
ADD_CFG_ITEM(CFG_VXLAN_PEER_MAC, "application.vxlan_wan.peer_mac", VALUE_TYPE_STRING, "", "vxLan peer mac address"); \
|
ADD_CFG_ITEM(CFG_VXLAN_PEER_MAC, "application.vxlan_wan.peer_mac", VALUE_TYPE_STRING, "", "vxLan peer mac address"); \
|
||||||
ADD_CFG_ITEM(CFG_VXLAN_PKG_FILTER, "application.vxlan_wan.pkg_filter", VALUE_TYPE_STRING, "", "vxLan package filter"); \
|
ADD_CFG_ITEM(CFG_VXLAN_PKG_FILTER, "application.vxlan_wan.pkg_filter", VALUE_TYPE_STRING, "", "vxLan package filter"); \
|
||||||
|
/*HTTP Server 配置*/ \
|
||||||
|
ADD_CFG_ITEM(CFG_HTTP_SVR_ADDR, "application.http_svr.listen_addr", VALUE_TYPE_STRING, "0.0.0.0", "Network address to listen on"); \
|
||||||
|
ADD_CFG_ITEM(CFG_HTTP_SVR_PORT, "application.http_svr.listen_port", VALUE_TYPE_INTEGRAL, "6789", "Network port to listen on"); \
|
||||||
|
ADD_CFG_ITEM(CFG_HTTP_SVR_TCP_NODELAY, "application.http_svr.tcp_nodelay", VALUE_TYPE_BOOL, "1", "TCP delay switch"); \
|
||||||
} while (0)// clang-format on
|
} while (0)// clang-format on
|
||||||
|
|
||||||
int init_config_system(const char *pCfgFile, const char *pKey) {
|
int init_config_system(const char *pCfgFile, const char *pKey) {
|
||||||
|
|
|
@ -3,6 +3,18 @@
|
||||||
//
|
//
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
const char* config_get_http_server_addr() {
|
||||||
|
return cfg_get_string_value(CFG_HTTP_SVR_ADDR);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int config_get_http_server_port() {
|
||||||
|
return cfg_get_integral_value(CFG_HTTP_SVR_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
int config_get_http_server_tcp_nodelay() {
|
||||||
|
return cfg_get_bool_value(CFG_HTTP_SVR_TCP_NODELAY);
|
||||||
|
}
|
||||||
|
|
||||||
const char *config_get_vxlan_nic_name() {
|
const char *config_get_vxlan_nic_name() {
|
||||||
return cfg_get_string_value(CFG_VXLAN_NIC_NAME);
|
return cfg_get_string_value(CFG_VXLAN_NIC_NAME);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,9 @@ typedef enum {
|
||||||
CFG_VXLAN_PEER_IP = 25,
|
CFG_VXLAN_PEER_IP = 25,
|
||||||
CFG_VXLAN_PEER_MAC = 26,
|
CFG_VXLAN_PEER_MAC = 26,
|
||||||
CFG_VXLAN_PKG_FILTER = 27,
|
CFG_VXLAN_PKG_FILTER = 27,
|
||||||
|
CFG_HTTP_SVR_ADDR = 29,
|
||||||
|
CFG_HTTP_SVR_PORT = 30,
|
||||||
|
CFG_HTTP_SVR_TCP_NODELAY = 31,
|
||||||
CONFIG_ITEM_ID_MAX
|
CONFIG_ITEM_ID_MAX
|
||||||
} CONFIG_ITEM_ID;
|
} CONFIG_ITEM_ID;
|
||||||
|
|
||||||
|
@ -90,7 +93,9 @@ const char *config_get_vxlan_nic_name();
|
||||||
const char *config_get_vxlan_peer_mac();
|
const char *config_get_vxlan_peer_mac();
|
||||||
const char *config_get_vxlan_peer_ip();
|
const char *config_get_vxlan_peer_ip();
|
||||||
const char *config_get_vxlan_pkg_filter();
|
const char *config_get_vxlan_pkg_filter();
|
||||||
|
const char *config_get_http_server_addr();
|
||||||
|
unsigned int config_get_http_server_port();
|
||||||
|
int config_get_http_server_tcp_nodelay();
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,15 +5,16 @@
|
||||||
#include "user_errno.h"
|
#include "user_errno.h"
|
||||||
#include "haywire.h"
|
#include "haywire.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
int http_svr_init() {
|
int http_svr_init() {
|
||||||
configuration config;
|
configuration config;
|
||||||
config.http_listen_address = "0.0.0.0";
|
config.http_listen_address = (char*)config_get_http_server_addr();
|
||||||
config.http_listen_port = 8000;
|
config.http_listen_port = config_get_http_server_port();
|
||||||
config.thread_count = 0;
|
config.thread_count = 0;
|
||||||
config.parser = "http_parser";
|
config.parser = "http_parser";
|
||||||
config.balancer = "ipc";
|
config.balancer = "ipc";
|
||||||
config.tcp_nodelay = TRUE;
|
config.tcp_nodelay = config_get_http_server_tcp_nodelay();
|
||||||
config.max_request_size = 1048576;
|
config.max_request_size = 1048576;
|
||||||
|
|
||||||
hw_init_with_config(&config);
|
hw_init_with_config(&config);
|
||||||
|
|
Loading…
Reference in New Issue