|
@@ -0,0 +1,67 @@
|
|
1
|
+--[[
|
|
2
|
+
|
|
3
|
+LuCI Squid module
|
|
4
|
+
|
|
5
|
+Copyright (C) 2015, OpenWrt.org
|
|
6
|
+
|
|
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
|
|
10
|
+
|
|
11
|
+ http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+Author: Marko Ratkaj <marko.ratkaj@sartura.hr>
|
|
14
|
+
|
|
15
|
+]]--
|
|
16
|
+
|
|
17
|
+local fs = require "nixio.fs"
|
|
18
|
+local sys = require "luci.sys"
|
|
19
|
+require "ubus"
|
|
20
|
+
|
|
21
|
+m = Map("squid", translate("Squid"))
|
|
22
|
+m.on_after_commit = function() luci.sys.call("/etc/init.d/squid restart") end
|
|
23
|
+
|
|
24
|
+s = m:section(TypedSection, "squid")
|
|
25
|
+s.anonymous = true
|
|
26
|
+s.addremove = false
|
|
27
|
+
|
|
28
|
+s:tab("general", translate("General Settings"))
|
|
29
|
+
|
|
30
|
+http_port = s:taboption("general", Value, "http_port", translate("Port"))
|
|
31
|
+http_port.datatype = "portrange"
|
|
32
|
+http_port.placeholder = "0-65535"
|
|
33
|
+
|
|
34
|
+visible_hostname = s:taboption("general", Value, "visible_hostname", translate("Visible Hostname"))
|
|
35
|
+visible_hostname.datatype="string"
|
|
36
|
+visible_hostname.placeholder = "OpenWrt"
|
|
37
|
+
|
|
38
|
+coredump_dir = s:taboption("general", Value, "coredump_dir", translate("Coredump files directory"))
|
|
39
|
+coredump_dir.datatype="string"
|
|
40
|
+coredump_dir.placeholder = "/tmp/squid"
|
|
41
|
+
|
|
42
|
+s:tab("advanced", translate("Advanced Settings"))
|
|
43
|
+
|
|
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
|
|
48
|
+
|
|
49
|
+function squid_config_file.cfgvalue()
|
|
50
|
+ local uci = require "luci.model.uci".cursor_state()
|
|
51
|
+ local file = uci:get("squid", "squid", "config_file")
|
|
52
|
+ if file then
|
|
53
|
+ return fs.readfile(file) or ""
|
|
54
|
+ else
|
|
55
|
+ return ""
|
|
56
|
+ end
|
|
57
|
+end
|
|
58
|
+
|
|
59
|
+function squid_config_file.write(self, section, value)
|
|
60
|
+ if value then
|
|
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"))
|
|
64
|
+ end
|
|
65
|
+end
|
|
66
|
+
|
|
67
|
+return m
|