From 117f9b4662774ad2a43904a401162c9b6a623254 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 28 Jul 2014 05:23:19 +0200 Subject: [PATCH] gluon-mesh-batman-adv: don't parse ip output for nodeinfo --- .../lib/gluon/announce/nodeinfo.d/network/addresses | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/package/gluon-mesh-batman-adv/files/lib/gluon/announce/nodeinfo.d/network/addresses b/package/gluon-mesh-batman-adv/files/lib/gluon/announce/nodeinfo.d/network/addresses index 6df96876..d55f8340 100644 --- a/package/gluon-mesh-batman-adv/files/lib/gluon/announce/nodeinfo.d/network/addresses +++ b/package/gluon-mesh-batman-adv/files/lib/gluon/announce/nodeinfo.d/network/addresses @@ -1,8 +1,12 @@ -local ip = util.exec('ip -o -6 addr show dev br-client') +local ip = require 'luci.ip' local addresses = {} -for _, line in ipairs(util.split(ip)) do - table.insert(addresses, line:match('inet6 ([%x:]+)/')) + +for line in io.lines('/proc/net/if_inet6') do + local matches = { line:match('^' .. string.rep('(%x%x%x%x)', 8) .. string.rep(' %x%x', 4) .. '%s+([^%s]+)$') } + if matches[9] == 'br-client' then + table.insert(addresses, ip.IPv6(string.format('%s:%s:%s:%s:%s:%s:%s:%s', unpack(matches))):string():lower()) + end end return addresses