Skip to content

Commit be5d213

Browse files
olliewalshClemensElflein
authored andcommitted
Fix IP introspection issues with multiple interfaces
If an interface does not have an IP then continue to the next interface instead of bailing out.
1 parent b13022f commit be5d213

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

libxbot-service-interface/src/Socket.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ bool get_ip(std::string &ip) {
4646

4747
// Get IP address
4848
if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) {
49-
perror("SIOCGIFADDR");
50-
break;
49+
continue; // No IP on interface
5150
}
5251

5352
const char *addrStr = inet_ntoa(reinterpret_cast<struct sockaddr_in *>(&ifr.ifr_addr)->sin_addr);

libxbot-service/src/portable/linux/socket.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ bool get_ip(char* ip, size_t ip_len) {
4949

5050
// Get IP address
5151
if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) {
52-
perror("SIOCGIFADDR");
53-
break;
52+
continue; // No IP on interface
5453
}
5554

5655
const char* addrStr = inet_ntoa(reinterpret_cast<struct sockaddr_in*>(&ifr.ifr_addr)->sin_addr);

0 commit comments

Comments
 (0)