Skip to content

Commit

Permalink
修复本地 IP 获取错误问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lanthora committed Sep 11, 2024
1 parent 4faf257 commit 9d04444
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/peer/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ uint32_t UdpHolder::IP() {
if (!this->ip) {
try {
for (const auto &iface : Poco::Net::NetworkInterface::list()) {
if (iface.supportsIPv4() && !iface.isLoopback() && !iface.isPointToPoint()) {
if (iface.supportsIPv4() && !iface.isLoopback() && !iface.isPointToPoint() &&
iface.type() != iface.NI_TYPE_OTHER) {
auto firstAddress = iface.firstAddress(Poco::Net::IPAddress::IPv4);
memcpy(&this->ip, firstAddress.addr(), sizeof(this->ip));
this->ip = ntohl(this->ip);
Expand Down

0 comments on commit 9d04444

Please sign in to comment.