@@ -406,27 +406,35 @@ make_dfmux_collector_v2_from_dict(const char *listenaddr,
406406 for (ssize_t i = 0 ; i < bp::len (items); i++) {
407407 int32_t serial = bp::extract<int >(items[i][1 ])();
408408 in_addr_t ip;
409+ bool found = false ;
409410
410- if (bp::extract<int >(items[i][0 ]).check ()) {
411- ip = bp::extract<int >(items[i][0 ])();
412- } else if (bp::extract<std::string>(items[i][0 ]).check ()) {
413- std::string host = bp::extract<std::string>(
414- items[i][0 ])();
415- struct addrinfo hints, *info;
416- int err;
417-
418- bzero (&hints, sizeof (hints));
419- hints.ai_family = PF_INET;
420-
421- err = getaddrinfo (host.c_str (), NULL , &hints, &info);
422- if (err != 0 )
423- log_fatal (" Could not find host %s (%s)" ,
424- host.c_str (), gai_strerror (err));
425-
426- g3_assert (info->ai_family == PF_INET);
427- ip = ((struct sockaddr_in *)(info->ai_addr ))->
428- sin_addr.s_addr ;
411+ auto int_item = bp::extract<int >(items[i][0 ]);
412+ if (int_item.check ()) {
413+ ip = int_item ();
414+ found = true ;
429415 } else {
416+ auto str_item = bp::extract<std::string>(items[i][0 ]);
417+ if (str_item.check ()) {
418+ std::string host = str_item ();
419+ struct addrinfo hints, *info;
420+ int err;
421+
422+ bzero (&hints, sizeof (hints));
423+ hints.ai_family = PF_INET;
424+
425+ err = getaddrinfo (host.c_str (), NULL , &hints, &info);
426+ if (err != 0 )
427+ log_fatal (" Could not find host %s (%s)" ,
428+ host.c_str (), gai_strerror (err));
429+
430+ g3_assert (info->ai_family == PF_INET);
431+ ip = ((struct sockaddr_in *)(info->ai_addr ))->
432+ sin_addr.s_addr ;
433+
434+ found = true ;
435+ }
436+ }
437+ if (!found) {
430438 log_fatal (" Map keys must be integer or string "
431439 " representations of the IP address or hostname" );
432440 }
0 commit comments