From 65f291d478688cad1abfeede6a29c540ea1079dc Mon Sep 17 00:00:00 2001 From: Gui Iribarren Date: Mon, 30 Sep 2013 18:49:04 +0200 Subject: [PATCH] better heuristics for filtering bat-hosts candidate entries: only accept 6-bytes MACs, and not all-zeroes like lo --- alfred/files/bat-hosts.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/alfred/files/bat-hosts.lua b/alfred/files/bat-hosts.lua index c92357e..67d2523 100644 --- a/alfred/files/bat-hosts.lua +++ b/alfred/files/bat-hosts.lua @@ -14,10 +14,7 @@ function get_interfaces_names() local ret = {} for name in io.popen("ls -1 /sys/class/net/"):lines() do - -- skip loopback ("lo") mac (00:00:00:00:00:00) - if name ~= "lo" then - table.insert(ret, name) - end + table.insert(ret, name) end return ret @@ -46,7 +43,9 @@ local function generate_bat_hosts() end for mac, iname in pairs(ifaces) do - table.insert(ret, mac.." "..hostname.."_"..iname.."\n") + if mac:match("^%x%x:%x%x:%x%x:%x%x:%x%x:%x%x$") and not mac:match("00:00:00:00:00:00") then + table.insert(ret, mac.." "..hostname.."_"..iname.."\n") + end end return ret