tinyproxy.lua 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. -- Copyright 2008 Steven Barth <steven@midlink.org>
  2. -- Copyright 2008-2010 Jo-Philipp Wich <jow@openwrt.org>
  3. -- Licensed to the public under the Apache License 2.0.
  4. m = Map("tinyproxy", translate("Tinyproxy"),
  5. translate("Tinyproxy is a small and fast non-caching HTTP(S)-Proxy"))
  6. s = m:section(TypedSection, "tinyproxy", translate("Server Settings"))
  7. s.anonymous = true
  8. s:tab("general", translate("General settings"))
  9. s:tab("privacy", translate("Privacy settings"))
  10. s:tab("filter", translate("Filtering and ACLs"))
  11. s:tab("limits", translate("Server limits"))
  12. o = s:taboption("general", Flag, "enabled", translate("Enable Tinyproxy server"))
  13. o.rmempty = false
  14. function o.write(self, section, value)
  15. if value == "1" then
  16. luci.sys.init.enable("tinyproxy")
  17. else
  18. luci.sys.init.disable("tinyproxy")
  19. end
  20. return Flag.write(self, section, value)
  21. end
  22. o = s:taboption("general", Value, "Port", translate("Listen port"),
  23. translate("Specifies the HTTP port Tinyproxy is listening on for requests"))
  24. o.optional = true
  25. o.datatype = "port"
  26. o.placeholder = 8888
  27. o = s:taboption("general", Value, "Listen", translate("Listen address"),
  28. translate("Specifies the addresses Tinyproxy is listening on for requests"))
  29. o.optional = true
  30. o.datatype = "ipaddr"
  31. o.placeholder = "0.0.0.0"
  32. o = s:taboption("general", Value, "Bind", translate("Bind address"),
  33. translate("Specifies the address Tinyproxy binds to for outbound forwarded requests"))
  34. o.optional = true
  35. o.datatype = "ipaddr"
  36. o.placeholder = "0.0.0.0"
  37. o = s:taboption("general", Value, "DefaultErrorFile", translate("Error page"),
  38. translate("HTML template file to serve when HTTP errors occur"))
  39. o.optional = true
  40. o.default = "/usr/share/tinyproxy/default.html"
  41. o = s:taboption("general", Value, "StatFile", translate("Statistics page"),
  42. translate("HTML template file to serve for stat host requests"))
  43. o.optional = true
  44. o.default = "/usr/share/tinyproxy/stats.html"
  45. o = s:taboption("general", Flag, "Syslog", translate("Use syslog"),
  46. translate("Writes log messages to syslog instead of a log file"))
  47. o = s:taboption("general", Value, "LogFile", translate("Log file"),
  48. translate("Log file to use for dumping messages"))
  49. o.default = "/var/log/tinyproxy.log"
  50. o:depends("Syslog", "")
  51. o = s:taboption("general", ListValue, "LogLevel", translate("Log level"),
  52. translate("Logging verbosity of the Tinyproxy process"))
  53. o:value("Critical")
  54. o:value("Error")
  55. o:value("Warning")
  56. o:value("Notice")
  57. o:value("Connect")
  58. o:value("Info")
  59. o = s:taboption("general", Value, "User", translate("User"),
  60. translate("Specifies the user name the Tinyproxy process is running as"))
  61. o.default = "nobody"
  62. o = s:taboption("general", Value, "Group", translate("Group"),
  63. translate("Specifies the group name the Tinyproxy process is running as"))
  64. o.default = "nogroup"
  65. --
  66. -- Privacy
  67. --
  68. o = s:taboption("privacy", Flag, "XTinyproxy", translate("X-Tinyproxy header"),
  69. translate("Adds an \"X-Tinyproxy\" HTTP header with the client IP address to forwarded requests"))
  70. o = s:taboption("privacy", Value, "ViaProxyName", translate("Via hostname"),
  71. translate("Specifies the Tinyproxy hostname to use in the Via HTTP header"))
  72. o.placeholder = "tinyproxy"
  73. o.datatype = "hostname"
  74. s:taboption("privacy", DynamicList, "Anonymous", translate("Header whitelist"),
  75. translate("Specifies HTTP header names which are allowed to pass-through, all others are discarded. Leave empty to disable header filtering"))
  76. --
  77. -- Filter
  78. --
  79. o = s:taboption("filter", DynamicList, "Allow", translate("Allowed clients"),
  80. translate("List of IP addresses or ranges which are allowed to use the proxy server"))
  81. o.placeholder = "0.0.0.0"
  82. o.datatype = "ipaddr"
  83. o = s:taboption("filter", DynamicList, "ConnectPort", translate("Allowed connect ports"),
  84. translate("List of allowed ports for the CONNECT method. A single value \"0\" allows all ports"))
  85. o.placeholder = 0
  86. o.datatype = "port"
  87. s:taboption("filter", FileUpload, "Filter", translate("Filter file"),
  88. translate("Plaintext file with URLs or domains to filter. One entry per line"))
  89. s:taboption("filter", Flag, "FilterURLs", translate("Filter by URLs"),
  90. translate("By default, filtering is done based on domain names. Enable this to match against URLs instead"))
  91. s:taboption("filter", Flag, "FilterExtended", translate("Filter by RegExp"),
  92. translate("By default, basic POSIX expressions are used for filtering. Enable this to activate extended regular expressions"))
  93. s:taboption("filter", Flag, "FilterCaseSensitive", translate("Filter case-sensitive"),
  94. translate("By default, filter strings are treated as case-insensitive. Enable this to make the matching case-sensitive"))
  95. s:taboption("filter", Flag, "FilterDefaultDeny", translate("Default deny"),
  96. translate("By default, the filter rules act as blacklist. Enable this option to only allow matched URLs or domain names"))
  97. --
  98. -- Limits
  99. --
  100. o = s:taboption("limits", Value, "Timeout", translate("Connection timeout"),
  101. translate("Maximum number of seconds an inactive connection is held open"))
  102. o.optional = true
  103. o.datatype = "uinteger"
  104. o.default = 600
  105. o = s:taboption("limits", Value, "MaxClients", translate("Max. clients"),
  106. translate("Maximum allowed number of concurrently connected clients"))
  107. o.datatype = "uinteger"
  108. o.default = 10
  109. o = s:taboption("limits", Value, "MinSpareServers", translate("Min. spare servers"),
  110. translate("Minimum number of prepared idle processes"))
  111. o.datatype = "uinteger"
  112. o.default = 5
  113. o = s:taboption("limits", Value, "MaxSpareServers", translate("Max. spare servers"),
  114. translate("Maximum number of prepared idle processes"))
  115. o.datatype = "uinteger"
  116. o.default = 10
  117. o = s:taboption("limits", Value, "StartServers", translate("Start spare servers"),
  118. translate("Number of idle processes to start when launching Tinyproxy"))
  119. o.datatype = "uinteger"
  120. o.default = 5
  121. o = s:taboption("limits", Value, "MaxRequestsPerChild", translate("Max. requests per server"),
  122. translate("Maximum allowed number of requests per process. If it is exeeded, the process is restarted. Zero means unlimited."))
  123. o.datatype = "uinteger"
  124. o.default = 0
  125. --
  126. -- Upstream
  127. --
  128. s = m:section(TypedSection, "upstream", translate("Upstream Proxies"),
  129. translate("Upstream proxy rules define proxy servers to use when accessing certain IP addresses or domains."))
  130. s.anonymous = true
  131. s.addremove = true
  132. t = s:option(ListValue, "type", translate("Policy"),
  133. translate("<em>Via proxy</em> routes requests to the given target via the specifed upstream proxy, <em>Reject access</em> disables any upstream proxy for the target"))
  134. t:value("proxy", translate("Via proxy"))
  135. t:value("reject", translate("Reject access"))
  136. ta = s:option(Value, "target", translate("Target host"),
  137. translate("Can be either an IP address or range, a domain name or \".\" for any host without domain"))
  138. ta.rmempty = true
  139. ta.placeholder = "0.0.0.0/0"
  140. ta.datatype = "host"
  141. v = s:option(Value, "via", translate("Via proxy"),
  142. translate("Specifies the upstream proxy to use for accessing the target host. Format is <code>address:port</code>"))
  143. v:depends({type="proxy"})
  144. v.placeholder = "10.0.0.1:8080"
  145. return m