From aec2bfd2a4424b00195c6391fef4afe07dcbc116 Mon Sep 17 00:00:00 2001 From: Guiling Qiyu <114603828+GuilingQiyu@users.noreply.github.com> Date: Fri, 15 Aug 2025 08:47:20 +0800 Subject: [PATCH 01/10] Packages (Linux): fixes Linglong detection by counting linglong layers (#1903) * Packages (Linux): fixes Linglong detection on Deepin * Packages (Linux): fixes Linglong detection to count layers * Update src/detection/packages/packages_linux.c --------- Co-authored-by: Carter Li --- src/detection/packages/packages_linux.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index 04bf4935b5..fbd607413c 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -446,12 +446,7 @@ static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts, { packageCounts->guixSystem += getGuixPackages(baseDir, "/run/current-system/profile"); } - if (!(options->disabled & FF_PACKAGES_FLAG_LINGLONG_BIT)) - { - packageCounts->linglong += getNumElements(baseDir, "/var/lib/linglong/repo/refs/heads/main", true); - if (packageCounts->linglong == 0) - packageCounts->linglong += getNumElements(baseDir, "/var/lib/linglong/repo/refs/remotes/stable/main", true); - } + if (!(options->disabled & FF_PACKAGES_FLAG_LINGLONG_BIT)) packageCounts->linglong += getNumElements(baseDir, "/var/lib/linglong/layers", true); if (!(options->disabled & FF_PACKAGES_FLAG_PACSTALL_BIT)) packageCounts->pacstall += getNumElements(baseDir, "/var/lib/pacstall/metadata", false); if (!(options->disabled & FF_PACKAGES_FLAG_PISI_BIT)) packageCounts->pisi += getNumElements(baseDir, "/var/lib/pisi/package", true); if (!(options->disabled & FF_PACKAGES_FLAG_PKGSRC_BIT)) packageCounts->pkgsrc += getNumElements(baseDir, "/usr/pkg/pkgdb", DT_DIR); From c1db6929822bb89afd66c08a419ae63aeaef1ee8 Mon Sep 17 00:00:00 2001 From: Ashish SHUKLA Date: Thu, 14 Aug 2025 21:37:12 +0200 Subject: [PATCH 02/10] FFstrbuf: wrap yyjson.h include in conditional --- src/util/FFstrbuf.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index 44498d3e91..39737fed00 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -9,7 +9,12 @@ #include #include #include -#include "3rdparty/yyjson/yyjson.h" + +#ifdef FF_USE_SYSTEM_YYJSON + #include +#else + #include "3rdparty/yyjson/yyjson.h" +#endif #ifdef _WIN32 // #include From a5fd671b923cc13c73d20b5a31ac51167f0c1ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 15 Aug 2025 13:29:22 +0800 Subject: [PATCH 03/10] LocalIP: fix `showMac` does not honor `defaultRouteOnly` --- src/detection/localip/localip.h | 2 +- src/detection/localip/localip_linux.c | 383 +++++++++++++++--------- src/detection/localip/localip_windows.c | 32 +- src/modules/localip/localip.c | 6 +- src/util/FFlist.h | 6 + 5 files changed, 268 insertions(+), 161 deletions(-) diff --git a/src/detection/localip/localip.h b/src/detection/localip/localip.h index 78609f6908..e3361cfbfe 100644 --- a/src/detection/localip/localip.h +++ b/src/detection/localip/localip.h @@ -12,7 +12,7 @@ typedef struct FFLocalIpResult FFstrbuf flags; int32_t mtu; int32_t speed; // in Mbps - bool defaultRoute; + FFLocalIpType defaultRoute; } FFLocalIpResult; typedef struct FFLocalIpNIFlag diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index 298631927f..3d1a7cd87e 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -108,58 +108,22 @@ static const FFLocalIpNIFlag niFlagOptions[] = { {}, }; -static void addNewIp(FFlist* list, const char* name, const char* addr, int type, bool defaultRoute, uint64_t flags, bool firstOnly) +typedef enum __attribute__((__packed__)) FFIPv6Type { - FFLocalIpResult* ip = NULL; - - FF_LIST_FOR_EACH(FFLocalIpResult, temp, *list) - { - if (!ffStrbufEqualS(&temp->name, name)) continue; - ip = temp; - if (defaultRoute) ip->defaultRoute = true; - break; - } - if (!ip) - { - ip = (FFLocalIpResult*) ffListAdd(list); - ffStrbufInitS(&ip->name, name); - ffStrbufInit(&ip->ipv4); - ffStrbufInit(&ip->ipv6); - ffStrbufInit(&ip->mac); - ffStrbufInit(&ip->flags); - ip->defaultRoute = defaultRoute; - ip->mtu = -1; - ip->speed = -1; - - ffLocalIpFillNIFlags(&ip->flags, flags, niFlagOptions); - } - - switch (type) - { - case AF_INET: - if (ip->ipv4.length) - { - if (firstOnly) return; - ffStrbufAppendC(&ip->ipv4, ','); - } - ffStrbufAppendS(&ip->ipv4, addr); - break; - case AF_INET6: - if (ip->ipv6.length) - { - if (firstOnly) return; - ffStrbufAppendC(&ip->ipv6, ','); - } - ffStrbufAppendS(&ip->ipv6, addr); - break; - case -1: - ffStrbufSetS(&ip->mac, addr); - break; - } -} - -static bool isIPv6AddressPreferred(struct ifaddrs* ifa, struct sockaddr_in6* addr) + FF_IPV6_Other, + FF_IPV6_GUA = 0b0001, + FF_IPV6_GUA_SECONDARY = 0b0101, + FF_IPV6_ULA = 0b0010, + FF_IPV6_ULA_SECONDARY = 0b0110, + FF_IPV6_TYPE_MASK = 0b0011, + FF_IPV6_SECONDARY_FLAG = 0b1100, + FF_IPV6_PREFERRED = UINT8_MAX, +} FFIPv6Type; + +static FFIPv6Type getIpType(struct ifaddrs* ifa) { + struct sockaddr_in6* addr = (struct sockaddr_in6*) ifa->ifa_addr; + #ifndef IN6_IS_ADDR_GLOBAL #define IN6_IS_ADDR_GLOBAL(a) \ ((((const uint32_t *) (a))[0] & htonl(0x70000000)) == htonl(0x20000000)) @@ -168,8 +132,13 @@ static bool isIPv6AddressPreferred(struct ifaddrs* ifa, struct sockaddr_in6* add #define IN6_IS_ADDR_UNIQUE_LOCAL(a) \ ((((const uint32_t *) (a))[0] & htonl(0xfe000000)) == htonl(0xfc000000)) #endif - if (!IN6_IS_ADDR_GLOBAL(&addr->sin6_addr) && !IN6_IS_ADDR_UNIQUE_LOCAL(&addr->sin6_addr)) - return false; + FFIPv6Type result = FF_IPV6_Other; + if (IN6_IS_ADDR_GLOBAL(&addr->sin6_addr)) + result = FF_IPV6_GUA; + else if (IN6_IS_ADDR_UNIQUE_LOCAL(&addr->sin6_addr)) + result = FF_IPV6_ULA; + else + return FF_IPV6_Other; #ifdef SIOCGIFAFLAG_IN6 static int sockfd = 0; @@ -184,26 +153,26 @@ static bool isIPv6AddressPreferred(struct ifaddrs* ifa, struct sockaddr_in6* add if (sockfd > 0) fcntl(sockfd, F_SETFD, FD_CLOEXEC); #endif } - if (sockfd < 0) return true; // Give up + if (sockfd < 0) return result; struct in6_ifreq ifr6 = {}; ffStrCopy(ifr6.ifr_name, ifa->ifa_name, IFNAMSIZ); ifr6.ifr_addr = *addr; if (ioctl(sockfd, SIOCGIFAFLAG_IN6, &ifr6) != 0) - return true; + return result; + #ifdef IN6_IFF_PREFER_SOURCE if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_PREFER_SOURCE) - return true; + return FF_IPV6_PREFERRED; #endif - return !(ifr6.ifr_ifru.ifru_flags6 & (IN6_IFF_DEPRECATED | IN6_IFF_TEMPORARY | IN6_IFF_TENTATIVE | IN6_IFF_DUPLICATED + if (ifr6.ifr_ifru.ifru_flags6 & (IN6_IFF_DEPRECATED | IN6_IFF_TEMPORARY | IN6_IFF_TENTATIVE | IN6_IFF_DUPLICATED #ifdef IN6_IFF_OPTIMISTIC | IN6_IFF_OPTIMISTIC #endif - )); + )) result |= FF_IPV6_SECONDARY_FLAG; + return result; #elif __linux__ - FF_UNUSED(ifa); - static FFlist addresses = {}; if (addresses.elementSize == 0) { @@ -230,38 +199,99 @@ static bool isIPv6AddressPreferred(struct ifaddrs* ifa, struct sockaddr_in6* add --addresses.length; } } - if (addresses.capacity == 0) return true; // Give up + if (addresses.capacity == 0) return result; FF_LIST_FOR_EACH(struct in6_addr, entry, addresses) { if (memcmp(&addr->sin6_addr, entry, sizeof(struct in6_addr)) == 0) - return true; + return result; } - return false; + result |= FF_IPV6_SECONDARY_FLAG; + return result; #elif __sun if (ifa->ifa_flags & IFF_PREFERRED) - return true; - return !(ifa->ifa_flags & (IFF_DEPRECATED | IFF_TEMPORARY | IFF_DUPLICATE)); + return FF_IPV6_PREFERRED; + if (ifa->ifa_flags & (IFF_DEPRECATED | IFF_TEMPORARY | IFF_DUPLICATE)) + result |= FF_IPV6_SECONDARY_FLAG; + return result; #else - return true; + return result; #endif } +typedef struct { + struct ifaddrs* mac; + FFlist /**/ ipv4; + FFlist /**/ ipv6; +} FFAdapter; + +static void appendIpv4(const FFLocalIpOptions* options, FFstrbuf* buffer, const struct ifaddrs* ifa) +{ + struct sockaddr_in* ipv4 = (struct sockaddr_in*) ifa->ifa_addr; + + char addressBuffer[INET_ADDRSTRLEN + 16]; + inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN); + + if (options->showType & FF_LOCALIP_TYPE_PREFIX_LEN_BIT) + { + struct sockaddr_in* netmask = (struct sockaddr_in*) ifa->ifa_netmask; + int cidr = __builtin_popcount(netmask->sin_addr.s_addr); + if (cidr != 0) + { + size_t len = strlen(addressBuffer); + snprintf(addressBuffer + len, 16, "/%d", cidr); + } + } + + if (buffer->length) ffStrbufAppendC(buffer, ','); + ffStrbufAppendS(buffer, addressBuffer); +} + +static void appendIpv6(const FFLocalIpOptions* options, FFstrbuf* buffer, const struct ifaddrs* ifa) +{ + struct sockaddr_in6* ipv6 = (struct sockaddr_in6*) ifa->ifa_addr; + + char addressBuffer[INET6_ADDRSTRLEN + 16]; + inet_ntop(AF_INET6, &ipv6->sin6_addr, addressBuffer, INET6_ADDRSTRLEN); + + if (options->showType & FF_LOCALIP_TYPE_PREFIX_LEN_BIT) + { + struct sockaddr_in6* netmask = (struct sockaddr_in6*) ifa->ifa_netmask; + int cidr = 0; + static_assert(sizeof(netmask->sin6_addr) % sizeof(uint64_t) == 0, ""); + for (uint32_t i = 0; i < sizeof(netmask->sin6_addr) / sizeof(uint64_t); ++i) + cidr += __builtin_popcountll(((uint64_t*) &netmask->sin6_addr)[i]); + if (cidr != 0) + { + size_t len = strlen(addressBuffer); + snprintf(addressBuffer + len, 16, "/%d", cidr); + } + } + + if (buffer->length) ffStrbufAppendC(buffer, ','); + ffStrbufAppendS(buffer, addressBuffer); +} + const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { struct ifaddrs* ifAddrStruct = NULL; if(getifaddrs(&ifAddrStruct) < 0) return "getifaddrs(&ifAddrStruct) failed"; + const FFNetifDefaultRouteResult* defaultRouteV4 = ffNetifGetDefaultRouteV4(); + const FFNetifDefaultRouteResult* defaultRouteV6 = ffNetifGetDefaultRouteV6(); + + FF_LIST_AUTO_DESTROY adapters = ffListCreate(sizeof(FFAdapter)); + for (struct ifaddrs* ifa = ifAddrStruct; ifa; ifa = ifa->ifa_next) { if (!ifa->ifa_addr) continue; -#ifdef IFF_RUNNING + #ifdef IFF_RUNNING if (!(ifa->ifa_flags & IFF_RUNNING)) continue; -#endif + #endif if ((ifa->ifa_flags & IFF_LOOPBACK) && !(options->showType & FF_LOCALIP_TYPE_LOOP_BIT)) continue; @@ -269,107 +299,182 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) if (options->namePrefix.length && strncmp(ifa->ifa_name, options->namePrefix.chars, options->namePrefix.length) != 0) continue; - uint64_t flags = options->showType & FF_LOCALIP_TYPE_FLAGS_BIT ? ifa->ifa_flags : 0; + if (!(options->showType & FF_LOCALIP_TYPE_MAC_BIT) && + ifa->ifa_addr->sa_family != AF_INET && ifa->ifa_addr->sa_family != AF_INET6) + continue; + + if (options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) + { + if (!ffStrEquals(defaultRouteV4->ifName, ifa->ifa_name) && + !ffStrEquals(defaultRouteV6->ifName, ifa->ifa_name)) + continue; + } + + FFAdapter* adapter = NULL; + FF_LIST_FOR_EACH(FFAdapter, x, adapters) + { + if (ffStrEquals(x->mac->ifa_name, ifa->ifa_name)) + { + adapter = x; + break; + } + } + if (!adapter) + { + adapter = ffListAdd(&adapters); + *adapter = (FFAdapter) { + .mac = ifa, + .ipv4 = ffListCreate(sizeof(struct ifaddrs*)), + .ipv6 = ffListCreate(sizeof(struct ifaddrs*)), + }; + } - if (ifa->ifa_addr->sa_family == AF_INET) + switch (ifa->ifa_addr->sa_family) { - if (!(options->showType & FF_LOCALIP_TYPE_IPV4_BIT)) - continue; + case AF_INET: + if (options->showType & FF_LOCALIP_TYPE_IPV4_BIT) + *FF_LIST_ADD(struct ifaddrs*, adapter->ipv4) = ifa; + break; + case AF_INET6: + if (options->showType & FF_LOCALIP_TYPE_IPV6_BIT) + *FF_LIST_ADD(struct ifaddrs*, adapter->ipv6) = ifa; + break; + #if __FreeBSD__ || __OpenBSD__ || __APPLE__ || __NetBSD__ || __HAIKU__ + case AF_LINK: adapter->mac = ifa; break; + #elif !__sun + case AF_PACKET: adapter->mac = ifa; break; + #endif + } + } - struct sockaddr_in* ipv4 = (struct sockaddr_in*) ifa->ifa_addr; + FF_LIST_FOR_EACH(FFAdapter, adapter, adapters) + { + FFLocalIpResult* item = FF_LIST_ADD(FFLocalIpResult, *results); + ffStrbufInitS(&item->name, adapter->mac->ifa_name); + ffStrbufInit(&item->ipv4); + ffStrbufInit(&item->ipv6); + ffStrbufInit(&item->mac); + ffStrbufInit(&item->flags); + item->defaultRoute = FF_LOCALIP_TYPE_NONE; + item->mtu = -1; + item->speed = -1; + + if (options->showType & FF_LOCALIP_TYPE_FLAGS_BIT) + ffLocalIpFillNIFlags(&item->flags, adapter->mac->ifa_flags, niFlagOptions); + + if ((options->showType & FF_LOCALIP_TYPE_IPV4_BIT)) + { + bool isDefaultRouteIf = ffStrEquals(defaultRouteV4->ifName, adapter->mac->ifa_name); + + if (isDefaultRouteIf) item->defaultRoute |= FF_LOCALIP_TYPE_IPV4_BIT; - const FFNetifDefaultRouteResult* defaultRoute = ffNetifGetDefaultRouteV4(); - bool isDefaultRouteIf = ffStrEquals(defaultRoute->ifName, ifa->ifa_name); if (options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) { if (!isDefaultRouteIf) - continue; - - if (!(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT)) - { - bool isPreferredSourceAddr = defaultRoute->preferredSourceAddrV4 == 0 || ipv4->sin_addr.s_addr == defaultRoute->preferredSourceAddrV4; - if (!isPreferredSourceAddr) - continue; - } + goto v6; } - char addressBuffer[INET_ADDRSTRLEN + 16]; - inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN); - - if (options->showType & FF_LOCALIP_TYPE_PREFIX_LEN_BIT) + if (!(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT)) { - struct sockaddr_in* netmask = (struct sockaddr_in*) ifa->ifa_netmask; - int cidr = __builtin_popcount(netmask->sin_addr.s_addr); - if (cidr != 0) + struct ifaddrs* ifa = NULL; + if (isDefaultRouteIf && defaultRouteV4->preferredSourceAddrV4 != 0) // preferredSourceAddrV4 is only set for the default route { - size_t len = strlen(addressBuffer); - snprintf(addressBuffer + len, 16, "/%d", cidr); + FF_LIST_FOR_EACH(struct ifaddrs*, pifa, adapter->ipv4) + { + struct sockaddr_in* ipv4 = (struct sockaddr_in*) (*pifa)->ifa_addr; + if (ipv4->sin_addr.s_addr == defaultRouteV4->preferredSourceAddrV4) + { + ifa = *pifa; + break; + } + } } + if (ifa) + appendIpv4(options, &item->ipv4, ifa); + else if (adapter->ipv4.length > 0) + appendIpv4(options, &item->ipv4, *FF_LIST_GET(struct ifaddrs*, adapter->ipv4, 0)); + } + else + { + FF_LIST_FOR_EACH(struct ifaddrs*, pifa, adapter->ipv4) + appendIpv4(options, &item->ipv4, *pifa); } - - addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET, isDefaultRouteIf, flags, !(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT)); } - else if (ifa->ifa_addr->sa_family == AF_INET6) + v6: + if ((options->showType & FF_LOCALIP_TYPE_IPV6_BIT)) { - if (!(options->showType & FF_LOCALIP_TYPE_IPV6_BIT)) - continue; - - const FFNetifDefaultRouteResult* defaultRoute = ffNetifGetDefaultRouteV6(); - bool isDefaultRouteIf = ffStrEquals(defaultRoute->ifName, ifa->ifa_name); - if ((options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) && !isDefaultRouteIf) - continue; + bool isDefaultRouteIf = ffStrEquals(defaultRouteV6->ifName, adapter->mac->ifa_name); - struct sockaddr_in6* ipv6 = (struct sockaddr_in6 *)ifa->ifa_addr; - if (!(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT) && !isIPv6AddressPreferred(ifa, ipv6)) - continue; + if (isDefaultRouteIf) item->defaultRoute |= FF_LOCALIP_TYPE_IPV6_BIT; - char addressBuffer[INET6_ADDRSTRLEN + 16]; - inet_ntop(AF_INET6, &ipv6->sin6_addr, addressBuffer, INET6_ADDRSTRLEN); + if (options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) + { + if (!isDefaultRouteIf) + goto mac; + } - if (options->showType & FF_LOCALIP_TYPE_PREFIX_LEN_BIT) + if (!(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT)) { - struct sockaddr_in6* netmask = (struct sockaddr_in6*) ifa->ifa_netmask; - int cidr = 0; - static_assert(sizeof(netmask->sin6_addr) % sizeof(uint64_t) == 0, ""); - for (uint32_t i = 0; i < sizeof(netmask->sin6_addr) / sizeof(uint64_t); ++i) - cidr += __builtin_popcountll(((uint64_t*) &netmask->sin6_addr)[i]); - if (cidr != 0) + struct ifaddrs* selected = NULL; + struct ifaddrs* secondary = NULL; + + FF_LIST_FOR_EACH(struct ifaddrs*, pifa, adapter->ipv6) { - size_t len = strlen(addressBuffer); - snprintf(addressBuffer + len, 16, "/%d", cidr); + FFIPv6Type type = getIpType(*pifa); + if (type == FF_IPV6_PREFERRED) + { + selected = *pifa; + break; + } + else if (type == FF_IPV6_GUA && !selected) + selected = *pifa; + else if (type == FF_IPV6_ULA && !secondary) + secondary = *pifa; } - } + if (!selected) selected = secondary; - addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET6, isDefaultRouteIf, flags, !(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT)); + if (selected) + appendIpv6(options, &item->ipv6, selected); + else if (adapter->ipv6.length > 0) + appendIpv6(options, &item->ipv6, *FF_LIST_GET(struct ifaddrs*, adapter->ipv6, 0)); + } + else + { + FF_LIST_FOR_EACH(struct ifaddrs*, pifa, adapter->ipv6) + appendIpv6(options, &item->ipv6, *pifa); + } } - #if __FreeBSD__ || __OpenBSD__ || __APPLE__ || __NetBSD__ || __HAIKU__ - else if (ifa->ifa_addr->sa_family == AF_LINK) + mac: + #ifndef __sun + if (options->showType & FF_LOCALIP_TYPE_MAC_BIT) { - if (!(options->showType & FF_LOCALIP_TYPE_MAC_BIT)) - continue; - - char addressBuffer[32]; - uint8_t* ptr = (uint8_t*) LLADDR((struct sockaddr_dl *)ifa->ifa_addr); - snprintf(addressBuffer, ARRAY_SIZE(addressBuffer), "%02x:%02x:%02x:%02x:%02x:%02x", - ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); - addNewIp(results, ifa->ifa_name, addressBuffer, -1, false, flags, false); + if (adapter->mac->ifa_addr) + { + #if __FreeBSD__ || __OpenBSD__ || __APPLE__ || __NetBSD__ || __HAIKU__ + uint8_t* ptr = (uint8_t*) LLADDR((struct sockaddr_dl *)adapter->mac->ifa_addr); + #else + uint8_t* ptr = ((struct sockaddr_ll *)adapter->mac->ifa_addr)->sll_addr; + #endif + ffStrbufSetF(&item->mac, "%02x:%02x:%02x:%02x:%02x:%02x", + ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); + } } #else - else if (ifa->ifa_addr->sa_family == AF_PACKET) - { - if (!(options->showType & FF_LOCALIP_TYPE_MAC_BIT)) - continue; - - char addressBuffer[32]; - uint8_t* ptr = ((struct sockaddr_ll *)ifa->ifa_addr)->sll_addr; - snprintf(addressBuffer, ARRAY_SIZE(addressBuffer), "%02x:%02x:%02x:%02x:%02x:%02x", - ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); - addNewIp(results, ifa->ifa_name, addressBuffer, -1, false, flags, false); - } + (void) adapter; #endif } - if (ifAddrStruct) freeifaddrs(ifAddrStruct); + FF_LIST_FOR_EACH(FFAdapter, adapter, adapters) + { + ffListDestroy(&adapter->ipv4); + ffListDestroy(&adapter->ipv6); + } + + if (ifAddrStruct) + { + freeifaddrs(ifAddrStruct); + ifAddrStruct = NULL; + } if ((options->showType & FF_LOCALIP_TYPE_MTU_BIT) || (options->showType & FF_LOCALIP_TYPE_SPEED_BIT) #ifdef __sun diff --git a/src/detection/localip/localip_windows.c b/src/detection/localip/localip_windows.c index e983330790..9a86bd0277 100644 --- a/src/detection/localip/localip_windows.c +++ b/src/detection/localip/localip_windows.c @@ -54,9 +54,6 @@ static void addNewIp(FFlist* list, const char* name, const char* addr, int type, if (ip->ipv6.length) ffStrbufAppendC(&ip->ipv6, ','); ffStrbufAppendS(&ip->ipv6, addr); break; - case -1: - ffStrbufSetS(&ip->mac, addr); - break; } } @@ -92,18 +89,12 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) return "GetAdaptersAddresses() failed"; } - uint32_t defaultRouteIfIndex = ffNetifGetDefaultRouteV4()->ifIndex; - // Iterate through all of the adapters for (IP_ADAPTER_ADDRESSES* adapter = adapter_addresses; adapter; adapter = adapter->Next) { if (adapter->OperStatus != IfOperStatusUp) continue; - bool isDefaultRoute = adapter->IfIndex == defaultRouteIfIndex; - if ((options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) && !isDefaultRoute) - continue; - bool isLoop = adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK; if (isLoop && !(options->showType & FF_LOCALIP_TYPE_LOOP_BIT)) continue; @@ -115,16 +106,6 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) if (options->namePrefix.length && strncmp(name, options->namePrefix.chars, options->namePrefix.length) != 0) continue; - if (options->showType & FF_LOCALIP_TYPE_MAC_BIT && adapter->PhysicalAddressLength == 6) - { - char addressBuffer[32]; - uint8_t* ptr = adapter->PhysicalAddress; - snprintf(addressBuffer, ARRAY_SIZE(addressBuffer), "%02x:%02x:%02x:%02x:%02x:%02x", - ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); - addNewIp(results, name, addressBuffer, -1, newIp, isDefaultRoute); - newIp = false; - } - uint32_t typesToAdd = options->showType & (FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_IPV6_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT); for (IP_ADAPTER_UNICAST_ADDRESS* ifa = adapter->FirstUnicastAddress; ifa; ifa = ifa->Next) @@ -136,6 +117,10 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { if (!(typesToAdd & (FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT))) continue; + bool isDefaultRoute = ((options->showType & FF_LOCALIP_TYPE_IPV4_BIT) && ffNetifGetDefaultRouteV4()->ifIndex == adapter->IfIndex); + if ((options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) && !isDefaultRoute) + continue; + SOCKADDR_IN* ipv4 = (SOCKADDR_IN*) ifa->Address.lpSockaddr; char addressBuffer[INET_ADDRSTRLEN + 6]; inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN); @@ -156,6 +141,10 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { if (!(typesToAdd & (FF_LOCALIP_TYPE_IPV6_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT))) continue; + bool isDefaultRoute = ((options->showType & FF_LOCALIP_TYPE_IPV6_BIT) && ffNetifGetDefaultRouteV6()->ifIndex == adapter->IfIndex); + if ((options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) && !isDefaultRoute) + continue; + SOCKADDR_IN6* ipv6 = (SOCKADDR_IN6*) ifa->Address.lpSockaddr; char addressBuffer[INET6_ADDRSTRLEN + 6]; inet_ntop(AF_INET6, &ipv6->sin6_addr, addressBuffer, INET6_ADDRSTRLEN); @@ -183,6 +172,11 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) result->mtu = (int32_t) adapter->Mtu; if (options->showType & FF_LOCALIP_TYPE_FLAGS_BIT) ffLocalIpFillNIFlags(&result->flags, adapter->Flags, niFlagOptions); + if (options->showType & FF_LOCALIP_TYPE_MAC_BIT && adapter->PhysicalAddressLength == 6) + { + uint8_t* ptr = adapter->PhysicalAddress; + ffStrbufSetF(&result->mac, "%02x:%02x:%02x:%02x:%02x:%02x", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); + } } } diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index b6edad8794..84b860dc4c 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -91,9 +91,11 @@ static void printIp(FFLocalIpResult* ip, bool markDefaultRoute, FFstrbuf* buffer } if (ip->flags.length) { - if (buffer->length) ffStrbufAppendS(buffer, " <"); + bool flag = buffer->length > 0; + if (flag) ffStrbufAppendS(buffer, " <"); ffStrbufAppend(buffer, &ip->flags); - ffStrbufAppendC(buffer, '>'); + if (flag) + ffStrbufAppendC(buffer, '>'); } if (markDefaultRoute && ip->defaultRoute) ffStrbufAppendS(buffer, " *"); diff --git a/src/util/FFlist.h b/src/util/FFlist.h index d15f14f807..a105d6cd82 100644 --- a/src/util/FFlist.h +++ b/src/util/FFlist.h @@ -120,3 +120,9 @@ static inline void ffListClear(FFlist* list) assert((listVar).capacity > (index)); \ (itemType*)(listVar).data + (index); \ }) + +#define FF_LIST_ADD(itemType, listVar) \ + ({ \ + assert(sizeof(itemType) == (listVar).elementSize); \ + (itemType*) ffListAdd(&(listVar)); \ + }) From 46081a3e52d671ac6cb5bbc80899333656485c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 16 Aug 2025 04:24:26 +0000 Subject: [PATCH 04/10] LocalIP (Linux): fixes incorrect return and ensures struct initialization --- src/detection/localip/localip_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index 3d1a7cd87e..a4c82bb88a 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -179,7 +179,7 @@ static FFIPv6Type getIpType(struct ifaddrs* ifa) ffListInit(&addresses, sizeof(struct in6_addr)); FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); if (!ffReadFileBuffer("/proc/net/if_inet6", &buffer)) - return true; + return result; char* line = NULL; size_t len = 0; @@ -487,7 +487,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { FF_LIST_FOR_EACH(FFLocalIpResult, iface, *results) { - struct ifreq ifr; + struct ifreq ifr = {}; ffStrCopy(ifr.ifr_name, iface->name.chars, IFNAMSIZ); if (options->showType & FF_LOCALIP_TYPE_MTU_BIT) From c4cb6c65a94ea4fa7ac1880cfd07682357caf42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 16 Aug 2025 04:43:28 +0000 Subject: [PATCH 05/10] LocalIP (Linux): add verbose debug log --- src/detection/localip/localip_linux.c | 153 +++++++++++++++++++++++++- 1 file changed, 147 insertions(+), 6 deletions(-) diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index a4c82bb88a..52a5ef5736 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -2,6 +2,7 @@ #include "common/io/io.h" #include "common/netif/netif.h" #include "util/stringUtils.h" +#include "util/debug.h" #include #include @@ -124,6 +125,8 @@ static FFIPv6Type getIpType(struct ifaddrs* ifa) { struct sockaddr_in6* addr = (struct sockaddr_in6*) ifa->ifa_addr; + FF_DEBUG("Checking IPv6 type for interface %s", ifa->ifa_name); + #ifndef IN6_IS_ADDR_GLOBAL #define IN6_IS_ADDR_GLOBAL(a) \ ((((const uint32_t *) (a))[0] & htonl(0x70000000)) == htonl(0x20000000)) @@ -134,11 +137,20 @@ static FFIPv6Type getIpType(struct ifaddrs* ifa) #endif FFIPv6Type result = FF_IPV6_Other; if (IN6_IS_ADDR_GLOBAL(&addr->sin6_addr)) + { result = FF_IPV6_GUA; + FF_DEBUG("Interface %s has Global Unicast Address", ifa->ifa_name); + } else if (IN6_IS_ADDR_UNIQUE_LOCAL(&addr->sin6_addr)) + { result = FF_IPV6_ULA; + FF_DEBUG("Interface %s has Unique Local Address", ifa->ifa_name); + } else + { + FF_DEBUG("Interface %s has other IPv6 address type", ifa->ifa_name); return FF_IPV6_Other; + } #ifdef SIOCGIFAFLAG_IN6 static int sockfd = 0; @@ -232,6 +244,8 @@ static void appendIpv4(const FFLocalIpOptions* options, FFstrbuf* buffer, const char addressBuffer[INET_ADDRSTRLEN + 16]; inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN); + FF_DEBUG("Adding IPv4 address %s for interface %s", addressBuffer, ifa->ifa_name); + if (options->showType & FF_LOCALIP_TYPE_PREFIX_LEN_BIT) { struct sockaddr_in* netmask = (struct sockaddr_in*) ifa->ifa_netmask; @@ -254,6 +268,8 @@ static void appendIpv6(const FFLocalIpOptions* options, FFstrbuf* buffer, const char addressBuffer[INET6_ADDRSTRLEN + 16]; inet_ntop(AF_INET6, &ipv6->sin6_addr, addressBuffer, INET6_ADDRSTRLEN); + FF_DEBUG("Adding IPv6 address %s for interface %s", addressBuffer, ifa->ifa_name); + if (options->showType & FF_LOCALIP_TYPE_PREFIX_LEN_BIT) { struct sockaddr_in6* netmask = (struct sockaddr_in6*) ifa->ifa_netmask; @@ -274,42 +290,76 @@ static void appendIpv6(const FFLocalIpOptions* options, FFstrbuf* buffer, const const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { + FF_DEBUG("Starting local IP detection with showType=0x%x, namePrefix='%s'", + options->showType, options->namePrefix.chars); + struct ifaddrs* ifAddrStruct = NULL; if(getifaddrs(&ifAddrStruct) < 0) + { + FF_DEBUG("getifaddrs() failed"); return "getifaddrs(&ifAddrStruct) failed"; + } + + FF_DEBUG("Successfully retrieved interface addresses"); const FFNetifDefaultRouteResult* defaultRouteV4 = ffNetifGetDefaultRouteV4(); const FFNetifDefaultRouteResult* defaultRouteV6 = ffNetifGetDefaultRouteV6(); + FF_DEBUG("Default routes - IPv4: %s, IPv6: %s", + defaultRouteV4->ifName, defaultRouteV6->ifName); + FF_LIST_AUTO_DESTROY adapters = ffListCreate(sizeof(FFAdapter)); for (struct ifaddrs* ifa = ifAddrStruct; ifa; ifa = ifa->ifa_next) { if (!ifa->ifa_addr) + { + FF_DEBUG("Skipping interface %s (no address)", ifa->ifa_name); continue; + } #ifdef IFF_RUNNING if (!(ifa->ifa_flags & IFF_RUNNING)) + { + FF_DEBUG("Skipping interface %s (not running)", ifa->ifa_name); continue; + } #endif if ((ifa->ifa_flags & IFF_LOOPBACK) && !(options->showType & FF_LOCALIP_TYPE_LOOP_BIT)) + { + FF_DEBUG("Skipping loopback interface %s", ifa->ifa_name); continue; + } if (options->namePrefix.length && strncmp(ifa->ifa_name, options->namePrefix.chars, options->namePrefix.length) != 0) + { + FF_DEBUG("Skipping interface %s (doesn't match prefix '%s')", + ifa->ifa_name, options->namePrefix.chars); continue; + } if (!(options->showType & FF_LOCALIP_TYPE_MAC_BIT) && ifa->ifa_addr->sa_family != AF_INET && ifa->ifa_addr->sa_family != AF_INET6) + { + FF_DEBUG("Skipping interface %s (unsupported address family %d)", + ifa->ifa_name, ifa->ifa_addr->sa_family); continue; + } if (options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) { if (!ffStrEquals(defaultRouteV4->ifName, ifa->ifa_name) && !ffStrEquals(defaultRouteV6->ifName, ifa->ifa_name)) + { + FF_DEBUG("Skipping interface %s (not default route interface)", ifa->ifa_name); continue; + } } + FF_DEBUG("Processing interface %s (family=%d, flags=0x%x)", + ifa->ifa_name, ifa->ifa_addr->sa_family, ifa->ifa_flags); + FFAdapter* adapter = NULL; FF_LIST_FOR_EACH(FFAdapter, x, adapters) { @@ -327,28 +377,46 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) .ipv4 = ffListCreate(sizeof(struct ifaddrs*)), .ipv6 = ffListCreate(sizeof(struct ifaddrs*)), }; + FF_DEBUG("Created new adapter entry for interface %s", ifa->ifa_name); } switch (ifa->ifa_addr->sa_family) { case AF_INET: if (options->showType & FF_LOCALIP_TYPE_IPV4_BIT) + { *FF_LIST_ADD(struct ifaddrs*, adapter->ipv4) = ifa; + FF_DEBUG("Added IPv4 entry for interface %s", ifa->ifa_name); + } break; case AF_INET6: if (options->showType & FF_LOCALIP_TYPE_IPV6_BIT) + { *FF_LIST_ADD(struct ifaddrs*, adapter->ipv6) = ifa; + FF_DEBUG("Added IPv6 entry for interface %s", ifa->ifa_name); + } break; #if __FreeBSD__ || __OpenBSD__ || __APPLE__ || __NetBSD__ || __HAIKU__ - case AF_LINK: adapter->mac = ifa; break; + case AF_LINK: + adapter->mac = ifa; + FF_DEBUG("Updated MAC entry for interface %s", ifa->ifa_name); + break; #elif !__sun - case AF_PACKET: adapter->mac = ifa; break; + case AF_PACKET: + adapter->mac = ifa; + FF_DEBUG("Updated MAC entry for interface %s", ifa->ifa_name); + break; #endif } } + FF_DEBUG("Found %u network adapters", adapters.length); + FF_LIST_FOR_EACH(FFAdapter, adapter, adapters) { + FF_DEBUG("Processing adapter %s (IPv4 entries: %u, IPv6 entries: %u)", + adapter->mac->ifa_name, adapter->ipv4.length, adapter->ipv6.length); + FFLocalIpResult* item = FF_LIST_ADD(FFLocalIpResult, *results); ffStrbufInitS(&item->name, adapter->mac->ifa_name); ffStrbufInit(&item->ipv4); @@ -360,24 +428,34 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) item->speed = -1; if (options->showType & FF_LOCALIP_TYPE_FLAGS_BIT) + { ffLocalIpFillNIFlags(&item->flags, adapter->mac->ifa_flags, niFlagOptions); + FF_DEBUG("Added flags for interface %s: %s", adapter->mac->ifa_name, item->flags.chars); + } if ((options->showType & FF_LOCALIP_TYPE_IPV4_BIT)) { bool isDefaultRouteIf = ffStrEquals(defaultRouteV4->ifName, adapter->mac->ifa_name); - if (isDefaultRouteIf) item->defaultRoute |= FF_LOCALIP_TYPE_IPV4_BIT; + if (isDefaultRouteIf) + { + item->defaultRoute |= FF_LOCALIP_TYPE_IPV4_BIT; + FF_DEBUG("Interface %s is IPv4 default route", adapter->mac->ifa_name); + } if (options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) { if (!isDefaultRouteIf) + { + FF_DEBUG("Skipping IPv4 for interface %s (not default route)", adapter->mac->ifa_name); goto v6; + } } if (!(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT)) { struct ifaddrs* ifa = NULL; - if (isDefaultRouteIf && defaultRouteV4->preferredSourceAddrV4 != 0) // preferredSourceAddrV4 is only set for the default route + if (isDefaultRouteIf && defaultRouteV4->preferredSourceAddrV4 != 0) { FF_LIST_FOR_EACH(struct ifaddrs*, pifa, adapter->ipv4) { @@ -385,6 +463,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) if (ipv4->sin_addr.s_addr == defaultRouteV4->preferredSourceAddrV4) { ifa = *pifa; + FF_DEBUG("Found preferred IPv4 source address for interface %s", adapter->mac->ifa_name); break; } } @@ -392,10 +471,14 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) if (ifa) appendIpv4(options, &item->ipv4, ifa); else if (adapter->ipv4.length > 0) + { appendIpv4(options, &item->ipv4, *FF_LIST_GET(struct ifaddrs*, adapter->ipv4, 0)); + FF_DEBUG("Using first IPv4 address for interface %s", adapter->mac->ifa_name); + } } else { + FF_DEBUG("Adding all IPv4 addresses for interface %s", adapter->mac->ifa_name); FF_LIST_FOR_EACH(struct ifaddrs*, pifa, adapter->ipv4) appendIpv4(options, &item->ipv4, *pifa); } @@ -405,12 +488,19 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { bool isDefaultRouteIf = ffStrEquals(defaultRouteV6->ifName, adapter->mac->ifa_name); - if (isDefaultRouteIf) item->defaultRoute |= FF_LOCALIP_TYPE_IPV6_BIT; + if (isDefaultRouteIf) + { + item->defaultRoute |= FF_LOCALIP_TYPE_IPV6_BIT; + FF_DEBUG("Interface %s is IPv6 default route", adapter->mac->ifa_name); + } if (options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) { if (!isDefaultRouteIf) + { + FF_DEBUG("Skipping IPv6 for interface %s (not default route)", adapter->mac->ifa_name); goto mac; + } } if (!(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT)) @@ -424,22 +514,33 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) if (type == FF_IPV6_PREFERRED) { selected = *pifa; + FF_DEBUG("Found preferred IPv6 address for interface %s", adapter->mac->ifa_name); break; } else if (type == FF_IPV6_GUA && !selected) + { selected = *pifa; + FF_DEBUG("Found GUA IPv6 address for interface %s", adapter->mac->ifa_name); + } else if (type == FF_IPV6_ULA && !secondary) + { secondary = *pifa; + FF_DEBUG("Found ULA IPv6 address for interface %s", adapter->mac->ifa_name); + } } if (!selected) selected = secondary; if (selected) appendIpv6(options, &item->ipv6, selected); else if (adapter->ipv6.length > 0) + { appendIpv6(options, &item->ipv6, *FF_LIST_GET(struct ifaddrs*, adapter->ipv6, 0)); + FF_DEBUG("Using first IPv6 address for interface %s", adapter->mac->ifa_name); + } } else { + FF_DEBUG("Adding all IPv6 addresses for interface %s", adapter->mac->ifa_name); FF_LIST_FOR_EACH(struct ifaddrs*, pifa, adapter->ipv6) appendIpv6(options, &item->ipv6, *pifa); } @@ -457,6 +558,11 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) #endif ffStrbufSetF(&item->mac, "%02x:%02x:%02x:%02x:%02x:%02x", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); + FF_DEBUG("Added MAC address %s for interface %s", item->mac.chars, adapter->mac->ifa_name); + } + else + { + FF_DEBUG("No MAC address available for interface %s", adapter->mac->ifa_name); } } #else @@ -474,6 +580,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { freeifaddrs(ifAddrStruct); ifAddrStruct = NULL; + FF_DEBUG("Cleaned up interface address structures"); } if ((options->showType & FF_LOCALIP_TYPE_MTU_BIT) || (options->showType & FF_LOCALIP_TYPE_SPEED_BIT) @@ -482,6 +589,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) #endif ) { + FF_DEBUG("Retrieving additional interface properties (MTU/Speed/MAC)"); FF_AUTO_CLOSE_FD int sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd > 0) { @@ -493,7 +601,14 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) if (options->showType & FF_LOCALIP_TYPE_MTU_BIT) { if (ioctl(sockfd, SIOCGIFMTU, &ifr) == 0) + { iface->mtu = (int32_t) ifr.ifr_mtu; + FF_DEBUG("Interface %s MTU: %d", iface->name.chars, iface->mtu); + } + else + { + FF_DEBUG("Failed to get MTU for interface %s", iface->name.chars); + } } if (options->showType & FF_LOCALIP_TYPE_SPEED_BIT) @@ -502,12 +617,21 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) struct ethtool_cmd edata = { .cmd = ETHTOOL_GSET }; ifr.ifr_data = (void*) &edata; if (ioctl(sockfd, SIOCETHTOOL, &ifr) == 0) - iface->speed = (edata.speed_hi << 16) | edata.speed; // ethtool_cmd_speed is not available on Android + { + iface->speed = (edata.speed_hi << 16) | edata.speed; + FF_DEBUG("Interface %s speed: %d Mbps", iface->name.chars, iface->speed); + } + else + { + // ethtool_cmd_speed is not available on Android + FF_DEBUG("Failed to get speed for interface %s via ethtool", iface->name.chars); + } #elif __FreeBSD__ || __APPLE__ || __OpenBSD__ || __NetBSD__ struct ifmediareq ifmr = {}; ffStrCopy(ifmr.ifm_name, iface->name.chars, IFNAMSIZ); if (ioctl(sockfd, SIOCGIFMEDIA, &ifmr) == 0 && (IFM_TYPE(ifmr.ifm_active) & IFM_ETHER)) { + FF_DEBUG("Interface %s media type: 0x%x", iface->name.chars, IFM_SUBTYPE(ifmr.ifm_active)); switch (IFM_SUBTYPE(ifmr.ifm_active)) { #ifdef IFM_HPNA_1 @@ -872,7 +996,15 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) iface->speed = 56000; break; default: iface->speed = -1; + FF_DEBUG("Unknown media subtype for interface %s", iface->name.chars); + break; } + if (iface->speed > 0) + FF_DEBUG("Interface %s speed: %d Mbps", iface->name.chars, iface->speed); + } + else + { + FF_DEBUG("Failed to get media info for interface %s", iface->name.chars); } #endif } @@ -883,6 +1015,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) const uint8_t* ptr = (uint8_t*) ifr.ifr_addr.sa_data; // NOT ifr_enaddr ffStrbufSetF(&iface->mac, "%02x:%02x:%02x:%02x:%02x:%02x", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); + FF_DEBUG("Added MAC address %s for interface %s (Solaris)", iface->mac.chars, iface->name.chars); } if (options->showType & FF_LOCALIP_TYPE_SPEED_BIT) { @@ -896,7 +1029,10 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { kstat_named_t* ifspeed = (kstat_named_t*) kstat_data_lookup(ks, "ifspeed"); if (ifspeed) + { iface->speed = (int32_t) (ifspeed->value.ui64 / 1000 / 1000); + FF_DEBUG("Interface %s speed: %d Mbps (kstat)", iface->name.chars, iface->speed); + } } break; } @@ -905,7 +1041,12 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) #endif } } + else + { + FF_DEBUG("Failed to create socket for interface property retrieval"); + } } + FF_DEBUG("Local IP detection completed, found %u interfaces", results->length); return NULL; } From 41cffac80c44e5a5f6dee557e3a9120f922401d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 16 Aug 2025 13:10:35 +0800 Subject: [PATCH 06/10] CI: adds default build type to CI environment --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f22e9d3735..15df27186f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,9 @@ on: - push - pull_request +env: + CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }} + jobs: spellcheck: runs-on: ubuntu-latest From 597c6f3dbca986951ee9596f26f1fda9d4c7245b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 16 Aug 2025 15:12:44 +0800 Subject: [PATCH 07/10] Netif (Linux): add verbose logs --- src/common/netif/netif_linux.c | 62 +++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/common/netif/netif_linux.c b/src/common/netif/netif_linux.c index cef654d6b5..1dcdad84c2 100644 --- a/src/common/netif/netif_linux.c +++ b/src/common/netif/netif_linux.c @@ -1,6 +1,7 @@ #include "netif.h" #include "common/io/io.h" #include "util/mallocHelper.h" +#include "util/debug.h" #include #include @@ -11,11 +12,18 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) { + FF_DEBUG("Starting IPv4 default route detection"); + FF_AUTO_CLOSE_FD int sock_fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE); if (sock_fd < 0) + { + FF_DEBUG("Failed to create netlink socket: errno=%d", errno); return false; + } + FF_DEBUG("Created netlink socket: fd=%d", sock_fd); unsigned pid = (unsigned) getpid(); + FF_DEBUG("Process PID: %u", pid); // Bind socket struct sockaddr_nl addr = { @@ -25,8 +33,10 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) }; if (bind(sock_fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { + FF_DEBUG("Failed to bind socket: errno=%d", errno); return false; } + FF_DEBUG("Successfully bound socket"); struct { struct nlmsghdr nlh; @@ -72,8 +82,10 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) (struct sockaddr*)&dest_addr, sizeof(dest_addr)); if (sent != sizeof(req)) { + FF_DEBUG("Failed to send netlink request: sent=%zd, expected=%zu", sent, sizeof(req)); return false; } + FF_DEBUG("Sent netlink request: %zd bytes", sent); struct sockaddr_nl src_addr = {}; socklen_t src_addr_len = sizeof(src_addr); @@ -88,16 +100,20 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) ssize_t peek_size = recvmsg(sock_fd, &msg, MSG_PEEK | MSG_TRUNC); if (peek_size < 0) { + FF_DEBUG("Failed to peek message size: errno=%d", errno); return false; } + FF_DEBUG("Message size: %zd bytes", peek_size); FF_AUTO_FREE uint8_t* buffer = malloc((size_t)peek_size); ssize_t received = recvfrom(sock_fd, buffer, (size_t)peek_size, 0, (struct sockaddr*)&src_addr, &src_addr_len); if (received != peek_size) { + FF_DEBUG("Failed to receive complete message: received=%zd, expected=%zd", received, peek_size); return false; } + FF_DEBUG("Received netlink response: %zd bytes", received); struct { uint32_t metric; @@ -105,6 +121,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) uint32_t prefsrc; } entry; uint32_t minMetric = UINT32_MAX; + int routeCount = 0; for (const struct nlmsghdr* nlh = (struct nlmsghdr*)buffer; NLMSG_OK(nlh, received); @@ -112,11 +129,15 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) if (nlh->nlmsg_seq != 1 || nlh->nlmsg_pid != pid) continue; if (nlh->nlmsg_type == NLMSG_DONE) + { + FF_DEBUG("Received NLMSG_DONE, processed %d routes", routeCount); break; + } if (nlh->nlmsg_type != RTM_NEWROUTE) continue; + routeCount++; struct rtmsg* rtm = (struct rtmsg*)NLMSG_DATA(nlh); if (rtm->rtm_family != AF_INET) continue; @@ -124,6 +145,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) if (rtm->rtm_dst_len != 0) continue; + FF_DEBUG("Processing IPv4 default route candidate #%d", routeCount); entry = (__typeof__(entry)) { .metric = UINT32_MAX }; // Parse route attributes @@ -138,20 +160,25 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) uint32_t rta_data = *(uint32_t*) RTA_DATA(rta); switch (rta->rta_type) { case RTA_DST: + FF_DEBUG("Found destination: %s", inet_ntoa(*(struct in_addr*)&rta_data)); if (rta_data != 0) goto next; break; case RTA_OIF: entry.ifindex = rta_data; + FF_DEBUG("Found interface index: %u", entry.ifindex); break; case RTA_GATEWAY: if (rta_data == 0) goto next; + FF_DEBUG("Found gateway: %s", inet_ntoa(*(struct in_addr*)&rta_data)); break; case RTA_PRIORITY: if (rta_data >= minMetric) goto next; entry.metric = rta_data; + FF_DEBUG("Found metric: %u", entry.metric); break; case RTA_PREFSRC: entry.prefsrc = rta_data; + FF_DEBUG("Found preferred source: %s", inet_ntoa(*(struct in_addr*)&rta_data)); break; } } @@ -163,24 +190,34 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) } minMetric = entry.metric; result->ifIndex = entry.ifindex; - result->preferredSourceAddrV4 = entry.prefsrc; + FF_DEBUG("Updated best route: ifindex=%u, metric=%u", entry.ifindex, entry.metric); + // result->preferredSourceAddrV4 = entry.prefsrc; } if (minMetric < UINT32_MAX) { if_indextoname(result->ifIndex, result->ifName); + FF_DEBUG("Found default IPv4 route: interface=%s, index=%u, metric=%u", result->ifName, result->ifIndex, minMetric); return true; } + FF_DEBUG("No IPv4 default route found"); return false; } bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) { + FF_DEBUG("Starting IPv6 default route detection"); + FF_AUTO_CLOSE_FD int sock_fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE); if (sock_fd < 0) + { + FF_DEBUG("Failed to create netlink socket: errno=%d", errno); return false; + } + FF_DEBUG("Created netlink socket: fd=%d", sock_fd); unsigned pid = (unsigned) getpid(); + FF_DEBUG("Process PID: %u", pid); // Bind socket struct sockaddr_nl addr = { @@ -190,8 +227,10 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) }; if (bind(sock_fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { + FF_DEBUG("Failed to bind socket: errno=%d", errno); return false; } + FF_DEBUG("Successfully bound socket"); struct { struct nlmsghdr nlh; @@ -237,8 +276,10 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) (struct sockaddr*)&dest_addr, sizeof(dest_addr)); if (sent != sizeof(req)) { + FF_DEBUG("Failed to send netlink request: sent=%zd, expected=%zu", sent, sizeof(req)); return false; } + FF_DEBUG("Sent netlink request: %zd bytes", sent); struct sockaddr_nl src_addr = {}; socklen_t src_addr_len = sizeof(src_addr); @@ -253,22 +294,27 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) ssize_t peek_size = recvmsg(sock_fd, &msg, MSG_PEEK | MSG_TRUNC); if (peek_size < 0) { + FF_DEBUG("Failed to peek message size: errno=%d", errno); return false; } + FF_DEBUG("Message size: %zd bytes", peek_size); FF_AUTO_FREE uint8_t* buffer = malloc((size_t)peek_size); ssize_t received = recvfrom(sock_fd, buffer, (size_t)peek_size, 0, (struct sockaddr*)&src_addr, &src_addr_len); if (received != peek_size) { + FF_DEBUG("Failed to receive complete message: received=%zd, expected=%zd", received, peek_size); return false; } + FF_DEBUG("Received netlink response: %zd bytes", received); struct { uint32_t metric; uint32_t ifindex; } entry; uint32_t minMetric = UINT32_MAX; + int routeCount = 0; for (const struct nlmsghdr* nlh = (struct nlmsghdr*)buffer; NLMSG_OK(nlh, received); @@ -276,11 +322,15 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) if (nlh->nlmsg_seq != 1 || nlh->nlmsg_pid != pid) continue; if (nlh->nlmsg_type == NLMSG_DONE) + { + FF_DEBUG("Received NLMSG_DONE, processed %d routes", routeCount); break; + } if (nlh->nlmsg_type != RTM_NEWROUTE) continue; + routeCount++; struct rtmsg* rtm = (struct rtmsg*)NLMSG_DATA(nlh); if (rtm->rtm_family != AF_INET6) continue; @@ -288,6 +338,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) if (rtm->rtm_dst_len != 0) continue; + FF_DEBUG("Processing IPv6 default route candidate #%d", routeCount); entry = (__typeof__(entry)) { .metric = UINT32_MAX }; // Parse route attributes @@ -299,6 +350,8 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) switch (rta->rta_type) { case RTA_DST: if (RTA_PAYLOAD(rta) >= sizeof(struct in6_addr)) { + FF_MAYBE_UNUSED char str[INET6_ADDRSTRLEN]; + FF_DEBUG("Found destination: %s", inet_ntop(AF_INET6, RTA_DATA(rta), str, sizeof(str))); struct in6_addr* dst = (struct in6_addr*) RTA_DATA(rta); if (!IN6_IS_ADDR_UNSPECIFIED(dst)) goto next; } @@ -306,12 +359,15 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) case RTA_OIF: if (RTA_PAYLOAD(rta) >= sizeof(uint32_t)) { entry.ifindex = *(uint32_t*) RTA_DATA(rta); + FF_DEBUG("Found interface index: %u", entry.ifindex); } break; case RTA_GATEWAY: if (RTA_PAYLOAD(rta) >= sizeof(struct in6_addr)) { struct in6_addr* gw = (struct in6_addr*) RTA_DATA(rta); if (IN6_IS_ADDR_UNSPECIFIED(gw)) goto next; + FF_MAYBE_UNUSED char str[INET6_ADDRSTRLEN]; + FF_DEBUG("Found gateway: %s", inet_ntop(AF_INET6, gw, str, sizeof(str))); } break; case RTA_PRIORITY: @@ -319,6 +375,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) uint32_t metric = *(uint32_t*) RTA_DATA(rta); if (metric >= minMetric) goto next; entry.metric = metric; + FF_DEBUG("Found metric: %u", entry.metric); } break; } @@ -331,12 +388,15 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) } minMetric = entry.metric; result->ifIndex = entry.ifindex; + FF_DEBUG("Updated best route: ifindex=%u, metric=%u", entry.ifindex, entry.metric); } if (minMetric < UINT32_MAX) { if_indextoname(result->ifIndex, result->ifName); + FF_DEBUG("Found default IPv6 route: interface=%s, index=%u, metric=%u", result->ifName, result->ifIndex, minMetric); return true; } + FF_DEBUG("No IPv6 default route found"); return false; } From 6356f9d0e5dc04fc2fbc9d75006605674537ab39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 16 Aug 2025 17:15:44 +0800 Subject: [PATCH 08/10] Netif (Linux): improves default route detection and error handling Ref: #1902 --- src/common/netif/netif_linux.c | 123 +++++++++++++++++---------------- 1 file changed, 62 insertions(+), 61 deletions(-) diff --git a/src/common/netif/netif_linux.c b/src/common/netif/netif_linux.c index 1dcdad84c2..1c31000034 100644 --- a/src/common/netif/netif_linux.c +++ b/src/common/netif/netif_linux.c @@ -7,9 +7,6 @@ #include #include -#define FF_STR_INDIR(x) #x -#define FF_STR(x) FF_STR_INDIR(x) - bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) { FF_DEBUG("Starting IPv4 default route detection"); @@ -17,7 +14,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) FF_AUTO_CLOSE_FD int sock_fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE); if (sock_fd < 0) { - FF_DEBUG("Failed to create netlink socket: errno=%d", errno); + FF_DEBUG("Failed to create netlink socket: %s", strerror(errno)); return false; } FF_DEBUG("Created netlink socket: fd=%d", sock_fd); @@ -28,17 +25,17 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) // Bind socket struct sockaddr_nl addr = { .nl_family = AF_NETLINK, - .nl_pid = pid, + .nl_pid = 0, // Let kernel choose PID .nl_groups = 0, // No multicast groups }; if (bind(sock_fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { - FF_DEBUG("Failed to bind socket: errno=%d", errno); + FF_DEBUG("Failed to bind socket: %s", strerror(errno)); return false; } FF_DEBUG("Successfully bound socket"); - struct { + struct __attribute__((__packed__)) { struct nlmsghdr nlh; struct rtmsg rtm; struct rtattr rta; @@ -90,27 +87,18 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) struct sockaddr_nl src_addr = {}; socklen_t src_addr_len = sizeof(src_addr); - struct iovec iov = {}; - struct msghdr msg = { - .msg_name = &src_addr, - .msg_namelen = sizeof(src_addr), - .msg_iov = &iov, - .msg_iovlen = 1, - }; + uint8_t buffer[1024 * 16]; // 16 KB buffer should be sufficient + + ssize_t received = recvfrom(sock_fd, buffer, sizeof(buffer), 0, + (struct sockaddr*)&src_addr, &src_addr_len); - ssize_t peek_size = recvmsg(sock_fd, &msg, MSG_PEEK | MSG_TRUNC); - if (peek_size < 0) { - FF_DEBUG("Failed to peek message size: errno=%d", errno); + if (received < 0) { + FF_DEBUG("Failed to receive netlink response: %s", strerror(errno)); return false; } - FF_DEBUG("Message size: %zd bytes", peek_size); - - FF_AUTO_FREE uint8_t* buffer = malloc((size_t)peek_size); - ssize_t received = recvfrom(sock_fd, buffer, (size_t)peek_size, 0, - (struct sockaddr*)&src_addr, &src_addr_len); - if (received != peek_size) { - FF_DEBUG("Failed to receive complete message: received=%zd, expected=%zd", received, peek_size); + if (received >= (ssize_t)sizeof(buffer)) { + FF_DEBUG("Failed to receive complete message (possible truncation)"); return false; } FF_DEBUG("Received netlink response: %zd bytes", received); @@ -134,6 +122,12 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) break; } + if (nlh->nlmsg_type == NLMSG_ERROR) { + struct nlmsgerr* err = (struct nlmsgerr*)NLMSG_DATA(nlh); + FF_DEBUG("Netlink reports error: %s", strerror(-err->error)); + continue; + } + if (nlh->nlmsg_type != RTM_NEWROUTE) continue; @@ -146,7 +140,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) continue; FF_DEBUG("Processing IPv4 default route candidate #%d", routeCount); - entry = (__typeof__(entry)) { .metric = UINT32_MAX }; + entry = (__typeof__(entry)) { }; // Default to zero metric (no RTA_PRIORITY found) // Parse route attributes size_t rtm_len = RTM_PAYLOAD(nlh); @@ -160,21 +154,20 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) uint32_t rta_data = *(uint32_t*) RTA_DATA(rta); switch (rta->rta_type) { case RTA_DST: - FF_DEBUG("Found destination: %s", inet_ntoa(*(struct in_addr*)&rta_data)); - if (rta_data != 0) goto next; - break; + FF_DEBUG("Unexpected RTA_DST: %s (len=%u)", inet_ntoa((struct in_addr) { .s_addr = rta_data }), rtm->rtm_dst_len); + goto next; case RTA_OIF: entry.ifindex = rta_data; FF_DEBUG("Found interface index: %u", entry.ifindex); break; case RTA_GATEWAY: - if (rta_data == 0) goto next; FF_DEBUG("Found gateway: %s", inet_ntoa(*(struct in_addr*)&rta_data)); + if (rta_data == 0) goto next; break; case RTA_PRIORITY: + FF_DEBUG("Found metric: %u", rta_data); if (rta_data >= minMetric) goto next; entry.metric = rta_data; - FF_DEBUG("Found metric: %u", entry.metric); break; case RTA_PREFSRC: entry.prefsrc = rta_data; @@ -183,15 +176,21 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) } } - if (entry.metric >= minMetric) + if (entry.ifindex == 0 || entry.metric >= minMetric) { next: + FF_DEBUG("Skipping route: ifindex=%u, metric=%u", entry.ifindex, entry.metric); continue; } minMetric = entry.metric; result->ifIndex = entry.ifindex; - FF_DEBUG("Updated best route: ifindex=%u, metric=%u", entry.ifindex, entry.metric); - // result->preferredSourceAddrV4 = entry.prefsrc; + FF_DEBUG("Updated best route: ifindex=%u, metric=%u, prefsrc=%x", entry.ifindex, entry.metric, entry.prefsrc); + result->preferredSourceAddrV4 = entry.prefsrc; + if (minMetric == 0) + { + FF_DEBUG("Found zero metric route, stopping further processing"); + break; // Stop processing if we found a zero metric route + } } if (minMetric < UINT32_MAX) @@ -211,7 +210,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) FF_AUTO_CLOSE_FD int sock_fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE); if (sock_fd < 0) { - FF_DEBUG("Failed to create netlink socket: errno=%d", errno); + FF_DEBUG("Failed to create netlink socket: %s", strerror(errno)); return false; } FF_DEBUG("Created netlink socket: fd=%d", sock_fd); @@ -222,17 +221,17 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) // Bind socket struct sockaddr_nl addr = { .nl_family = AF_NETLINK, - .nl_pid = pid, + .nl_pid = 0, // Let kernel choose PID .nl_groups = 0, // No multicast groups }; if (bind(sock_fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { - FF_DEBUG("Failed to bind socket: errno=%d", errno); + FF_DEBUG("Failed to bind socket: %s", strerror(errno)); return false; } FF_DEBUG("Successfully bound socket"); - struct { + struct __attribute__((__packed__)) { struct nlmsghdr nlh; struct rtmsg rtm; struct rtattr rta; @@ -284,30 +283,20 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) struct sockaddr_nl src_addr = {}; socklen_t src_addr_len = sizeof(src_addr); - struct iovec iov = {}; - struct msghdr msg = { - .msg_name = &src_addr, - .msg_namelen = sizeof(src_addr), - .msg_iov = &iov, - .msg_iovlen = 1, - }; + uint8_t buffer[1024 * 16]; // 16 KB buffer should be sufficient - ssize_t peek_size = recvmsg(sock_fd, &msg, MSG_PEEK | MSG_TRUNC); - if (peek_size < 0) { - FF_DEBUG("Failed to peek message size: errno=%d", errno); + ssize_t received = recvfrom(sock_fd, buffer, sizeof(buffer), 0, + (struct sockaddr*)&src_addr, &src_addr_len); + + if (received < 0) { + FF_DEBUG("Failed to receive netlink response: %s", strerror(errno)); return false; } - FF_DEBUG("Message size: %zd bytes", peek_size); - - FF_AUTO_FREE uint8_t* buffer = malloc((size_t)peek_size); - ssize_t received = recvfrom(sock_fd, buffer, (size_t)peek_size, 0, - (struct sockaddr*)&src_addr, &src_addr_len); - if (received != peek_size) { - FF_DEBUG("Failed to receive complete message: received=%zd, expected=%zd", received, peek_size); + if (received >= (ssize_t)sizeof(buffer)) { + FF_DEBUG("Failed to receive complete message (possible truncation)"); return false; } - FF_DEBUG("Received netlink response: %zd bytes", received); struct { uint32_t metric; @@ -327,6 +316,12 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) break; } + if (nlh->nlmsg_type == NLMSG_ERROR) { + struct nlmsgerr* err = (struct nlmsgerr*)NLMSG_DATA(nlh); + FF_DEBUG("Netlink reports error: %s", strerror(-err->error)); + continue; + } + if (nlh->nlmsg_type != RTM_NEWROUTE) continue; @@ -339,7 +334,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) continue; FF_DEBUG("Processing IPv6 default route candidate #%d", routeCount); - entry = (__typeof__(entry)) { .metric = UINT32_MAX }; + entry = (__typeof__(entry)) { }; // Default to zero metric (no RTA_PRIORITY found) // Parse route attributes size_t rtm_len = RTM_PAYLOAD(nlh); @@ -351,9 +346,8 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) case RTA_DST: if (RTA_PAYLOAD(rta) >= sizeof(struct in6_addr)) { FF_MAYBE_UNUSED char str[INET6_ADDRSTRLEN]; - FF_DEBUG("Found destination: %s", inet_ntop(AF_INET6, RTA_DATA(rta), str, sizeof(str))); - struct in6_addr* dst = (struct in6_addr*) RTA_DATA(rta); - if (!IN6_IS_ADDR_UNSPECIFIED(dst)) goto next; + FF_DEBUG("Unexpected RTA_DST: %s", inet_ntop(AF_INET6, RTA_DATA(rta), str, sizeof(str))); + goto next; } break; case RTA_OIF: @@ -373,22 +367,29 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) case RTA_PRIORITY: if (RTA_PAYLOAD(rta) >= sizeof(uint32_t)) { uint32_t metric = *(uint32_t*) RTA_DATA(rta); + FF_DEBUG("Found metric: %u", metric); if (metric >= minMetric) goto next; entry.metric = metric; - FF_DEBUG("Found metric: %u", entry.metric); } break; } } - if (entry.metric >= minMetric) + if (entry.ifindex == 0 || entry.metric >= minMetric) { next: + FF_DEBUG("Skipping route: ifindex=%u, metric=%u", entry.ifindex, entry.metric); continue; } minMetric = entry.metric; result->ifIndex = entry.ifindex; FF_DEBUG("Updated best route: ifindex=%u, metric=%u", entry.ifindex, entry.metric); + + if (minMetric == 0) + { + FF_DEBUG("Found zero metric route, stopping further processing"); + break; // Stop processing if we found a zero metric route + } } if (minMetric < UINT32_MAX) From b994ce5b5577c5f28318721330c31bb3e29b7a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 16 Aug 2025 17:54:20 +0800 Subject: [PATCH 09/10] LocalIP: refines default route detection and JSON output for local IPs Add verbose log for Windows --- src/detection/localip/localip_linux.c | 13 +- src/detection/localip/localip_windows.c | 186 ++++++++++++++++-------- src/modules/localip/localip.c | 9 +- 3 files changed, 141 insertions(+), 67 deletions(-) diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index 52a5ef5736..ad96452298 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -302,12 +302,6 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) FF_DEBUG("Successfully retrieved interface addresses"); - const FFNetifDefaultRouteResult* defaultRouteV4 = ffNetifGetDefaultRouteV4(); - const FFNetifDefaultRouteResult* defaultRouteV6 = ffNetifGetDefaultRouteV6(); - - FF_DEBUG("Default routes - IPv4: %s, IPv6: %s", - defaultRouteV4->ifName, defaultRouteV6->ifName); - FF_LIST_AUTO_DESTROY adapters = ffListCreate(sizeof(FFAdapter)); for (struct ifaddrs* ifa = ifAddrStruct; ifa; ifa = ifa->ifa_next) @@ -349,8 +343,9 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) if (options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) { - if (!ffStrEquals(defaultRouteV4->ifName, ifa->ifa_name) && - !ffStrEquals(defaultRouteV6->ifName, ifa->ifa_name)) + // If the interface is not the default route for either IPv4 or IPv6, skip it + if (!((options->showType & FF_LOCALIP_TYPE_IPV4_BIT) && ffStrEquals(ffNetifGetDefaultRouteV4()->ifName, ifa->ifa_name)) && + !((options->showType & FF_LOCALIP_TYPE_IPV6_BIT) && ffStrEquals(ffNetifGetDefaultRouteV6()->ifName, ifa->ifa_name))) { FF_DEBUG("Skipping interface %s (not default route interface)", ifa->ifa_name); continue; @@ -435,6 +430,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) if ((options->showType & FF_LOCALIP_TYPE_IPV4_BIT)) { + const FFNetifDefaultRouteResult* defaultRouteV4 = ffNetifGetDefaultRouteV4(); bool isDefaultRouteIf = ffStrEquals(defaultRouteV4->ifName, adapter->mac->ifa_name); if (isDefaultRouteIf) @@ -486,6 +482,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) v6: if ((options->showType & FF_LOCALIP_TYPE_IPV6_BIT)) { + const FFNetifDefaultRouteResult* defaultRouteV6 = ffNetifGetDefaultRouteV6(); bool isDefaultRouteIf = ffStrEquals(defaultRouteV6->ifName, adapter->mac->ifa_name); if (isDefaultRouteIf) diff --git a/src/detection/localip/localip_windows.c b/src/detection/localip/localip_windows.c index 9a86bd0277..0fe1038530 100644 --- a/src/detection/localip/localip_windows.c +++ b/src/detection/localip/localip_windows.c @@ -4,6 +4,7 @@ #include "common/netif/netif.h" #include "util/mallocHelper.h" #include "util/windows/unicode.h" +#include "util/debug.h" #include "localip.h" #define FF_LOCALIP_NIFLAG(name) { IP_ADAPTER_##name, #name } @@ -23,42 +24,11 @@ static const FFLocalIpNIFlag niFlagOptions[] = { {}, }; -static void addNewIp(FFlist* list, const char* name, const char* addr, int type, bool newIp, bool defaultRoute) -{ - FFLocalIpResult* ip = NULL; - - if (newIp) - { - ip = (FFLocalIpResult*) ffListAdd(list); - ffStrbufInitS(&ip->name, name); - ffStrbufInit(&ip->ipv4); - ffStrbufInit(&ip->ipv6); - ffStrbufInit(&ip->mac); - ffStrbufInit(&ip->flags); - ip->defaultRoute = defaultRoute; - ip->speed = -1; - ip->mtu = -1; - } - else - { - ip = FF_LIST_GET(FFLocalIpResult, *list, list->length - 1); - } - - switch (type) - { - case AF_INET: - if (ip->ipv4.length) ffStrbufAppendC(&ip->ipv4, ','); - ffStrbufAppendS(&ip->ipv4, addr); - break; - case AF_INET6: - if (ip->ipv6.length) ffStrbufAppendC(&ip->ipv6, ','); - ffStrbufAppendS(&ip->ipv6, addr); - break; - } -} - const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { + FF_DEBUG("Starting local IP detection with showType=0x%X, namePrefix='%.*s'", + options->showType, (int)options->namePrefix.length, options->namePrefix.chars); + IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = NULL; // Multiple attempts in case interfaces change while @@ -66,60 +36,134 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) DWORD adapter_addresses_buffer_size = 0; for (int attempts = 0;; ++attempts) { + FF_DEBUG("Attempt %d to get adapter addresses, buffer size: %lu", attempts + 1, adapter_addresses_buffer_size); + if (adapter_addresses_buffer_size) { adapter_addresses = (IP_ADAPTER_ADDRESSES*)realloc(adapter_addresses, adapter_addresses_buffer_size); assert(adapter_addresses); } + DWORD family = options->showType & FF_LOCALIP_TYPE_IPV4_BIT + ? options->showType & FF_LOCALIP_TYPE_IPV6_BIT ? AF_UNSPEC : AF_INET + : AF_INET6; + FF_DEBUG("Calling GetAdaptersAddresses with family=%u, flags=0x%X", (unsigned)family, + GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER); + DWORD error = GetAdaptersAddresses( - options->showType & FF_LOCALIP_TYPE_IPV4_BIT - ? options->showType & FF_LOCALIP_TYPE_IPV6_BIT ? AF_UNSPEC : AF_INET - : AF_INET6, + family, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER, NULL, adapter_addresses, &adapter_addresses_buffer_size); if (error == ERROR_SUCCESS) + { + FF_DEBUG("GetAdaptersAddresses succeeded on attempt %d", attempts + 1); break; + } else if (ERROR_BUFFER_OVERFLOW == error && attempts < 4) + { + FF_DEBUG("Buffer overflow, need %lu bytes, retrying", adapter_addresses_buffer_size); continue; + } else + { + FF_DEBUG("GetAdaptersAddresses failed with error %lu after %d attempts", error, attempts + 1); return "GetAdaptersAddresses() failed"; + } } + int adapterCount = 0; + int processedCount = 0; + // Iterate through all of the adapters for (IP_ADAPTER_ADDRESSES* adapter = adapter_addresses; adapter; adapter = adapter->Next) { + adapterCount++; + + FF_DEBUG("Processing adapter %d: IfIndex=%u, IfType=%u, OperStatus=%u", + adapterCount, (unsigned)adapter->IfIndex, (unsigned)adapter->IfType, (unsigned)adapter->OperStatus); + if (adapter->OperStatus != IfOperStatusUp) + { + FF_DEBUG("Skipping adapter %u (not operational, status=%d)", (unsigned)adapter->IfIndex, adapter->OperStatus); continue; + } bool isLoop = adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK; + FF_DEBUG("Adapter %u: isLoopback=%s", (unsigned)adapter->IfIndex, isLoop ? "true" : "false"); + if (isLoop && !(options->showType & FF_LOCALIP_TYPE_LOOP_BIT)) + { + FF_DEBUG("Skipping loopback adapter %u (loopback not requested)", (unsigned)adapter->IfIndex); continue; - - bool newIp = true; + } char name[128]; WideCharToMultiByte(CP_UTF8, 0, adapter->FriendlyName, -1, name, ARRAY_SIZE(name), NULL, NULL); + FF_DEBUG("Adapter %u name: '%s'", (unsigned)adapter->IfIndex, name); + if (options->namePrefix.length && strncmp(name, options->namePrefix.chars, options->namePrefix.length) != 0) + { + FF_DEBUG("Skipping adapter %u (name doesn't match prefix '%.*s')", + (unsigned)adapter->IfIndex, (int)options->namePrefix.length, options->namePrefix.chars); continue; + } + + if (options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) + { + if (!((options->showType & FF_LOCALIP_TYPE_IPV4_BIT) && ffNetifGetDefaultRouteV4()->ifIndex == adapter->IfIndex) && + !((options->showType & FF_LOCALIP_TYPE_IPV6_BIT) && ffNetifGetDefaultRouteV6()->ifIndex == adapter->IfIndex)) + { + FF_DEBUG("Skipping interface %u (not default route interface)", (unsigned)adapter->IfIndex); + continue; + } + } + + processedCount++; + FF_DEBUG("Creating result item for adapter %u ('%s')", (unsigned)adapter->IfIndex, name); + + FFLocalIpResult* item = (FFLocalIpResult*) ffListAdd(results); + ffStrbufInitS(&item->name, name); + ffStrbufInit(&item->ipv4); + ffStrbufInit(&item->ipv6); + ffStrbufInit(&item->mac); + ffStrbufInit(&item->flags); + item->defaultRoute = FF_LOCALIP_TYPE_NONE; + item->speed = -1; + item->mtu = -1; uint32_t typesToAdd = options->showType & (FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_IPV6_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT); + FF_DEBUG("Types to add for adapter %u: 0x%X", (unsigned)adapter->IfIndex, typesToAdd); + + int ipv4Count = 0, ipv6Count = 0; for (IP_ADAPTER_UNICAST_ADDRESS* ifa = adapter->FirstUnicastAddress; ifa; ifa = ifa->Next) { + FF_DEBUG("Processing unicast address: family=%d, DadState=%d", + ifa->Address.lpSockaddr->sa_family, ifa->DadState); + if (!(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT) && ifa->DadState != IpDadStatePreferred) + { + FF_DEBUG("Skipping address (DadState=%d, not preferred)", ifa->DadState); continue; + } if (ifa->Address.lpSockaddr->sa_family == AF_INET) { - if (!(typesToAdd & (FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT))) continue; + if (!(typesToAdd & (FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT))) + { + FF_DEBUG("Skipping IPv4 address (not requested in typesToAdd=0x%X)", typesToAdd); + continue; + } bool isDefaultRoute = ((options->showType & FF_LOCALIP_TYPE_IPV4_BIT) && ffNetifGetDefaultRouteV4()->ifIndex == adapter->IfIndex); if ((options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) && !isDefaultRoute) + { + FF_DEBUG("Skipping IPv4 address (not on default route interface)"); continue; + } SOCKADDR_IN* ipv4 = (SOCKADDR_IN*) ifa->Address.lpSockaddr; char addressBuffer[INET_ADDRSTRLEN + 6]; @@ -131,19 +175,30 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) snprintf(addressBuffer + len, 6, "/%u", (unsigned) ifa->OnLinkPrefixLength); } - addNewIp(results, name, addressBuffer, AF_INET, newIp, isDefaultRoute); - newIp = false; + FF_DEBUG("Adding IPv4 address: %s (isDefaultRoute=%s)", addressBuffer, isDefaultRoute ? "true" : "false"); + if (item->ipv4.length) ffStrbufAppendC(&item->ipv4, ','); + ffStrbufAppendS(&item->ipv4, addressBuffer); + if (isDefaultRoute) item->defaultRoute |= FF_LOCALIP_TYPE_IPV4_BIT; + + ipv4Count++; typesToAdd &= ~(unsigned) FF_LOCALIP_TYPE_IPV4_BIT; if (typesToAdd == 0) break; } else if (ifa->Address.lpSockaddr->sa_family == AF_INET6) { - if (!(typesToAdd & (FF_LOCALIP_TYPE_IPV6_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT))) continue; + if (!(typesToAdd & (FF_LOCALIP_TYPE_IPV6_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT))) + { + FF_DEBUG("Skipping IPv6 address (not requested in typesToAdd=0x%X)", typesToAdd); + continue; + } bool isDefaultRoute = ((options->showType & FF_LOCALIP_TYPE_IPV6_BIT) && ffNetifGetDefaultRouteV6()->ifIndex == adapter->IfIndex); if ((options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) && !isDefaultRoute) + { + FF_DEBUG("Skipping IPv6 address (not on default route interface)"); continue; + } SOCKADDR_IN6* ipv6 = (SOCKADDR_IN6*) ifa->Address.lpSockaddr; char addressBuffer[INET6_ADDRSTRLEN + 6]; @@ -155,30 +210,45 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) snprintf(addressBuffer + len, 6, "/%u", (unsigned) ifa->OnLinkPrefixLength); } - addNewIp(results, name, addressBuffer, AF_INET6, newIp, isDefaultRoute); - newIp = false; + FF_DEBUG("Adding IPv6 address: %s (isDefaultRoute=%s)", addressBuffer, isDefaultRoute ? "true" : "false"); + + if (item->ipv6.length) ffStrbufAppendC(&item->ipv6, ','); + ffStrbufAppendS(&item->ipv6, addressBuffer); + if (isDefaultRoute) item->defaultRoute |= FF_LOCALIP_TYPE_IPV6_BIT; + ipv6Count++; typesToAdd &= ~(unsigned) FF_LOCALIP_TYPE_IPV6_BIT; if (typesToAdd == 0) break; } } - if (!newIp) + FF_DEBUG("Adapter %u: collected %d IPv4 and %d IPv6 addresses", (unsigned)adapter->IfIndex, ipv4Count, ipv6Count); + + if (options->showType & FF_LOCALIP_TYPE_SPEED_BIT) { - FFLocalIpResult* result = FF_LIST_GET(FFLocalIpResult, *results, results->length - 1); - if (options->showType & FF_LOCALIP_TYPE_SPEED_BIT) - result->speed = (int32_t) (adapter->ReceiveLinkSpeed / 1000000); - if (options->showType & FF_LOCALIP_TYPE_MTU_BIT) - result->mtu = (int32_t) adapter->Mtu; - if (options->showType & FF_LOCALIP_TYPE_FLAGS_BIT) - ffLocalIpFillNIFlags(&result->flags, adapter->Flags, niFlagOptions); - if (options->showType & FF_LOCALIP_TYPE_MAC_BIT && adapter->PhysicalAddressLength == 6) - { - uint8_t* ptr = adapter->PhysicalAddress; - ffStrbufSetF(&result->mac, "%02x:%02x:%02x:%02x:%02x:%02x", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); - } + item->speed = (int32_t) (adapter->ReceiveLinkSpeed / 1000000); + FF_DEBUG("Adapter %u speed: %d Mbps (raw: %llu)", (unsigned)adapter->IfIndex, item->speed, adapter->ReceiveLinkSpeed); + } + if (options->showType & FF_LOCALIP_TYPE_MTU_BIT) + { + item->mtu = (int32_t) adapter->Mtu; + FF_DEBUG("Adapter %u MTU: %d", (unsigned)adapter->IfIndex, item->mtu); + } + if (options->showType & FF_LOCALIP_TYPE_FLAGS_BIT) + { + ffLocalIpFillNIFlags(&item->flags, adapter->Flags, niFlagOptions); + FF_DEBUG("Adapter %u flags: 0x%lX -> '%s'", (unsigned)adapter->IfIndex, adapter->Flags, item->flags.chars); + } + if (options->showType & FF_LOCALIP_TYPE_MAC_BIT && adapter->PhysicalAddressLength == 6) + { + uint8_t* ptr = adapter->PhysicalAddress; + ffStrbufSetF(&item->mac, "%02x:%02x:%02x:%02x:%02x:%02x", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); + FF_DEBUG("Adapter %u MAC: %s", (unsigned)adapter->IfIndex, item->mac.chars); } } + FF_DEBUG("Local IP detection completed: scanned %d adapters, processed %d, results count: %u", + adapterCount, processedCount, results->length); + return NULL; } diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index 84b860dc4c..6892305ecf 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -344,7 +344,14 @@ void ffGenerateLocalIpJsonResult(FF_MAYBE_UNUSED FFLocalIpOptions* options, yyjs { yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr); yyjson_mut_obj_add_strbuf(doc, obj, "name", &ip->name); - yyjson_mut_obj_add_bool(doc, obj, "defaultRoute", ip->defaultRoute); + if (options->showType & (FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_IPV6_BIT)) + { + yyjson_mut_val* defaultRoute = yyjson_mut_obj_add_obj(doc, obj, "defaultRoute"); + if (options->showType & FF_LOCALIP_TYPE_IPV4_BIT) + yyjson_mut_obj_add_bool(doc, defaultRoute, "ipv4", !!(ip->defaultRoute & FF_LOCALIP_TYPE_IPV4_BIT)); + if (options->showType & FF_LOCALIP_TYPE_IPV6_BIT) + yyjson_mut_obj_add_bool(doc, defaultRoute, "ipv6", !!(ip->defaultRoute & FF_LOCALIP_TYPE_IPV6_BIT)); + } if (options->showType & FF_LOCALIP_TYPE_IPV4_BIT) yyjson_mut_obj_add_strbuf(doc, obj, "ipv4", &ip->ipv4); if (options->showType & FF_LOCALIP_TYPE_IPV6_BIT) From 3004f29c08af12584f0566503979fe5da70b4235 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 16 Aug 2025 21:18:07 +0800 Subject: [PATCH 10/10] Release: v2.50.2 --- CHANGELOG.md | 8 ++++++++ CMakeLists.txt | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa772285ef..9a6ac10728 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 2.50.2 + +Bugfixes: +* Fixes linglong package detection V2 (#1903, Packages, Linux) +* Fixes building with `-DENABLE_SYSTEM_YYJSON=ON` (#1904) +* Fixes `showMac` does not honor `defaultRouteOnly` (#1902, LocalIP, Linux) +* Fixes failing to acquire default route on Linux in certain cases (#1902, LocalIP, Linux) + # 2.50.1 Bugfixes: diff --git a/CMakeLists.txt b/CMakeLists.txt index 98b839efb3..c0737a6e47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url project(fastfetch - VERSION 2.50.1 + VERSION 2.50.2 LANGUAGES C DESCRIPTION "Fast neofetch-like system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"