Unverified Commit 848b0a58 authored by kharade's avatar kharade

fix config parse

parent 91472316
......@@ -216,55 +216,56 @@ int ausf_config::load(const std::string& config_file) {
}
// NRF
try {
std::string astring = {};
const Setting& nrf_cfg = ausf_cfg[AUSF_CONFIG_STRING_NRF];
struct in_addr nrf_ipv4_addr = {};
unsigned int nrf_port = 0;
std::string nrf_api_version = {};
if (!use_fqdn_dns) {
nrf_cfg.lookupValue(AUSF_CONFIG_STRING_NRF_IPV4_ADDRESS, astring);
IPV4_STR_ADDR_TO_INADDR(
util::trim(astring).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr;
if (!(nrf_cfg.lookupValue(AUSF_CONFIG_STRING_NRF_PORT, nrf_port))) {
Logger::ausf_app().error(AUSF_CONFIG_STRING_NRF_PORT "failed");
throw(AUSF_CONFIG_STRING_NRF_PORT "failed");
}
nrf_addr.port = nrf_port;
if (register_nrf) {
try {
std::string astring = {};
if (!(nrf_cfg.lookupValue(
AUSF_CONFIG_STRING_API_VERSION, nrf_api_version))) {
Logger::ausf_app().error(AUSF_CONFIG_STRING_API_VERSION "failed");
throw(AUSF_CONFIG_STRING_API_VERSION "failed");
}
nrf_addr.api_version = nrf_api_version;
const Setting& nrf_cfg = ausf_cfg[AUSF_CONFIG_STRING_NRF];
struct in_addr nrf_ipv4_addr = {};
unsigned int nrf_port = 0;
std::string nrf_api_version = {};
} else {
nrf_cfg.lookupValue(AUSF_CONFIG_STRING_FQDN_DNS, astring);
uint8_t addr_type = {0};
std::string address = {};
fqdn::resolve(astring, address, nrf_port, addr_type);
if (addr_type != 0) { // IPv6
// TODO:
throw("DO NOT SUPPORT IPV6 ADDR FOR NRF!");
} else { // IPv4
if (!use_fqdn_dns) {
nrf_cfg.lookupValue(AUSF_CONFIG_STRING_NRF_IPV4_ADDRESS, astring);
IPV4_STR_ADDR_TO_INADDR(
util::trim(address).c_str(), nrf_ipv4_addr,
util::trim(astring).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr;
nrf_addr.port = nrf_port;
nrf_addr.api_version = "v1"; // TODO: to get API version from DNS
nrf_addr.fqdn = astring;
nrf_addr.ipv4_addr = nrf_ipv4_addr;
if (!(nrf_cfg.lookupValue(AUSF_CONFIG_STRING_NRF_PORT, nrf_port))) {
Logger::ausf_app().error(AUSF_CONFIG_STRING_NRF_PORT "failed");
throw(AUSF_CONFIG_STRING_NRF_PORT "failed");
}
nrf_addr.port = nrf_port;
if (!(nrf_cfg.lookupValue(
AUSF_CONFIG_STRING_API_VERSION, nrf_api_version))) {
Logger::ausf_app().error(AUSF_CONFIG_STRING_API_VERSION "failed");
throw(AUSF_CONFIG_STRING_API_VERSION "failed");
}
nrf_addr.api_version = nrf_api_version;
} else {
nrf_cfg.lookupValue(AUSF_CONFIG_STRING_FQDN_DNS, astring);
uint8_t addr_type = {0};
std::string address = {};
fqdn::resolve(astring, address, nrf_port, addr_type);
if (addr_type != 0) { // IPv6
// TODO:
throw("DO NOT SUPPORT IPV6 ADDR FOR NRF!");
} else { // IPv4
IPV4_STR_ADDR_TO_INADDR(
util::trim(address).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr;
nrf_addr.port = nrf_port;
nrf_addr.api_version = "v1"; // TODO: to get API version from DNS
nrf_addr.fqdn = astring;
}
}
} catch (const SettingNotFoundException& nfex) {
Logger::ausf_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror;
}
} catch (const SettingNotFoundException& nfex) {
Logger::ausf_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror;
}
return RETURNok;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment