diff --git a/src/config.cpp b/src/config.cpp index e2fe10e..11aa2e5 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -29,6 +29,8 @@ void split_addr_into(const char* name, std::vector& out, const std: { size_t pos=0u; + // parse, resolve host names, then re-print. + // Catch syntax errors early, and normalize prior to removing duplicates while(pos& out, const std: out.emplace_back(strm.str()); } } + + // remove any duplicates + std::sort(out.begin(), out.end()); + out.erase(std::unique(out.begin(), out.end()), + out.end()); } std::string join_addr(const std::vector& in) diff --git a/test/testconfig.cpp b/test/testconfig.cpp index e8ca193..437129e 100644 --- a/test/testconfig.cpp +++ b/test/testconfig.cpp @@ -101,7 +101,7 @@ void testDefs() testEq(conf.udp_port, 1234); testFalse(conf.autoAddrList); testEq(conf.addressList, std::vector({"1.2.1.2:1234", "4.3.2.1:1234"})); - testEq(conf.interfaces, std::vector({"1.2.3.4", "1.1.1.1"})); + testEq(conf.interfaces, std::vector({"1.1.1.1", "1.2.3.4"})); } { @@ -141,7 +141,7 @@ void testDefs() testEq(conf.tcp_port, 5678); testFalse(conf.auto_beacon); testEq(conf.beaconDestinations, std::vector({"1.2.1.2:1234", "4.3.2.1:1234"})); - testEq(conf.interfaces, std::vector({"1.2.3.4:5678", "1.1.1.1:5678"})); + testEq(conf.interfaces, std::vector({"1.1.1.1:5678", "1.2.3.4:5678"})); } }