◸code
module("luci.controller.socat", package.seeall)

function index()
  entry({"admin","services","socat"}, cbi("socat"), "Socat", 100)
end
require("luci.sys")

m = Map("socat", translate("Socat Service"), translate("Configure socat service"))

s = m:section(TypedSection, "socat", "")
s.addremove = true
s.anonymous = false

enable = s:option(Flag, "enable", translate("Enable"))
enable.rmempty = false

run_as = s:option(Value, "user", translate("Run As"))
run_as.default = 'root'
run_as.rmempty = false

options = s:option(TextValue, "SocatOptions", translate("Socat Options"))
options.default = 'TCP6-LISTEN:12345,fork,reuseaddr TCP:10.10.10.10:12345'
options.rmempty = false

local apply = luci.http.formvalue("cbi.apply")
if apply then
  io.popen("/etc/init.d/socat restart")
end

return m