Skip to content

Commit a6cb30d

Browse files
committed
LocalIP: print all IPs if multiple IPs are assigned to the same interface
1 parent de6b1f9 commit a6cb30d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/detection/localip/localip_linux.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ static void addNewIp(FFlist* list, const char* name, const char* addr, int type,
4040
switch (type)
4141
{
4242
case AF_INET:
43-
ffStrbufSetS(&ip->ipv4, addr);
43+
if (ip->ipv4.length) ffStrbufAppendC(&ip->ipv4, ',');
44+
ffStrbufAppendS(&ip->ipv4, addr);
4445
break;
4546
case AF_INET6:
46-
ffStrbufSetS(&ip->ipv6, addr);
47+
if (ip->ipv6.length) ffStrbufAppendC(&ip->ipv6, ',');
48+
ffStrbufAppendS(&ip->ipv6, addr);
4749
break;
4850
case -1:
4951
ffStrbufSetS(&ip->mac, addr);

src/detection/localip/localip_windows.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "util/windows/unicode.h"
77
#include "localip.h"
88

9-
static void addNewIp(FFlist* list, const char* name, const char* value, int type, bool newIp, bool defaultRoute)
9+
static void addNewIp(FFlist* list, const char* name, const char* addr, int type, bool newIp, bool defaultRoute)
1010
{
1111
FFLocalIpResult* ip = NULL;
1212

@@ -27,13 +27,15 @@ static void addNewIp(FFlist* list, const char* name, const char* value, int type
2727
switch (type)
2828
{
2929
case AF_INET:
30-
ffStrbufSetS(&ip->ipv4, value);
30+
if (ip->ipv4.length) ffStrbufAppendC(&ip->ipv4, ',');
31+
ffStrbufAppendS(&ip->ipv4, addr);
3132
break;
3233
case AF_INET6:
33-
ffStrbufSetS(&ip->ipv6, value);
34+
if (ip->ipv6.length) ffStrbufAppendC(&ip->ipv6, ',');
35+
ffStrbufAppendS(&ip->ipv6, addr);
3436
break;
3537
case -1:
36-
ffStrbufSetS(&ip->mac, value);
38+
ffStrbufSetS(&ip->mac, addr);
3739
break;
3840
}
3941
}

0 commit comments

Comments
 (0)