#!/usr/bin/lua

--! Copyright (C) 2019  Gioacchino Mazzurco <gio@altermundi.net>
--! This is free software, licensed under the GNU Affero General Public License v3

local JSON = require("luci.jsonc")

local outputTable = {}

for key,value in pairs(
	JSON.parse(io.stdin:read("*all")) ) do
	table.insert(outputTable, key.." "..value.data)
end

io.output("/etc/babeld-hosts"):write(table.concat(outputTable,"\n").."\n")
