Skip to content

Commit 6bc7d67

Browse files
rgetzpcercuei
authored andcommitted
dns_sd: ignore localhosts in scans
sometimes we get: 2: 127.0.0.1 on Raspberry Pi 4 Model B Rev 1.5 [ip:phaser.local] 3: 192.168.1.105 on Raspberry Pi 4 Model B Rev 1.5 [ip:phaser.local] 4: 192.168.2.10 on Raspberry Pi 4 Model B Rev 1.5 [ip:phaser.local] 5: 2601:190:400:da:a448:8c38:150a:7d4e on Raspberry Pi 4 Model B Rev 1.5 [ip:phaser.local] obviously, 127.0.0.1 is not useful at all, so throw it away when we are looking for duplicates. Signed-off-by: Robin Getz <[email protected]>
1 parent 306dcf5 commit 6bc7d67

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

dns_sd.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,26 @@ void remove_dup_discovery_data(struct dns_sd_discovery_data **ddata)
251251
}
252252
i++;
253253
}
254+
255+
prev = NULL;
256+
ndata = d;
257+
i = 0;
258+
while (ndata->next) {
259+
if (!strcmp(ndata->addr_str, "127.0.0.1") ||
260+
!strcmp(ndata->addr_str, "::1")) {
261+
IIO_DEBUG("Removing localhost in list: %i '%s' '%s' port:%hu\n",
262+
i, ndata->hostname, ndata->addr_str, ndata->port);
263+
dnssd_remove_node(&d, i);
264+
if (!prev)
265+
ndata = d;
266+
else
267+
ndata = prev->next;
268+
continue;
269+
}
270+
i++;
271+
prev = ndata;
272+
ndata = ndata->next;
273+
}
254274
iio_mutex_unlock(d->lock);
255275

256276
*ddata = d;

0 commit comments

Comments
 (0)