5 Copyright (C) 2015, OpenWrt.org
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Author: Marko Ratkaj <marko.ratkaj@sartura.hr>
17 local fs = require "nixio.fs"
18 local sys = require "luci.sys"
21 m = Map("squid", translate("Squid"))
22 m.on_after_commit = function() luci.sys.call("/etc/init.d/squid restart") end
24 s = m:section(TypedSection, "squid")
28 s:tab("general", translate("General Settings"))
30 http_port = s:taboption("general", Value, "http_port", translate("Port"))
31 http_port.datatype = "portrange"
32 http_port.placeholder = "0-65535"
34 visible_hostname = s:taboption("general", Value, "visible_hostname", translate("Visible Hostname"))
35 visible_hostname.datatype="string"
36 visible_hostname.placeholder = "OpenWrt"
38 coredump_dir = s:taboption("general", Value, "coredump_dir", translate("Coredump files directory"))
39 coredump_dir.datatype="string"
40 coredump_dir.placeholder = "/tmp/squid"
42 s:tab("advanced", translate("Advanced Settings"))
44 squid_config_file = s:taboption("advanced", TextValue, "_data", "")
45 squid_config_file.wrap = "off"
46 squid_config_file.rows = 25
47 squid_config_file.rmempty = false
49 function squid_config_file.cfgvalue()
50 local uci = require "luci.model.uci".cursor_state()
51 local file = uci:get("squid", "squid", "config_file")
53 return fs.readfile(file) or ""
59 function squid_config_file.write(self, section, value)
61 local uci = require "luci.model.uci".cursor_state()
62 local file = uci:get("squid", "squid", "config_file")
63 fs.writefile(file, value:gsub("\r\n", "\n"))