qos.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. -- Copyright 2008 Steven Barth <steven@midlink.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local wa = require "luci.tools.webadmin"
  4. local fs = require "nixio.fs"
  5. m = Map("qos", translate("Quality of Service"),
  6. translate("With <abbr title=\"Quality of Service\">QoS</abbr> you " ..
  7. "can prioritize network traffic selected by addresses, " ..
  8. "ports or services."))
  9. s = m:section(TypedSection, "interface", translate("Interfaces"))
  10. s.addremove = true
  11. s.anonymous = false
  12. e = s:option(Flag, "enabled", translate("Enable"))
  13. e.rmempty = false
  14. c = s:option(ListValue, "classgroup", translate("Classification group"))
  15. c:value("Default", translate("default"))
  16. c.default = "Default"
  17. s:option(Flag, "overhead", translate("Calculate overhead"))
  18. s:option(Flag, "halfduplex", translate("Half-duplex"))
  19. dl = s:option(Value, "download", translate("Download speed (kbit/s)"))
  20. dl.datatype = "and(uinteger,min(1))"
  21. ul = s:option(Value, "upload", translate("Upload speed (kbit/s)"))
  22. ul.datatype = "and(uinteger,min(1))"
  23. s = m:section(TypedSection, "classify", translate("Classification Rules"))
  24. s.template = "cbi/tblsection"
  25. s.anonymous = true
  26. s.addremove = true
  27. s.sortable = true
  28. t = s:option(ListValue, "target", translate("Target"))
  29. t:value("Priority", translate("priority"))
  30. t:value("Express", translate("express"))
  31. t:value("Normal", translate("normal"))
  32. t:value("Bulk", translate("low"))
  33. t.default = "Normal"
  34. srch = s:option(Value, "srchost", translate("Source host"))
  35. srch.rmempty = true
  36. srch:value("", translate("all"))
  37. wa.cbi_add_knownips(srch)
  38. dsth = s:option(Value, "dsthost", translate("Destination host"))
  39. dsth.rmempty = true
  40. dsth:value("", translate("all"))
  41. wa.cbi_add_knownips(dsth)
  42. l7 = s:option(ListValue, "layer7", translate("Service"))
  43. l7.rmempty = true
  44. l7:value("", translate("all"))
  45. local pats = io.popen("find /etc/l7-protocols/ -type f -name '*.pat'")
  46. if pats then
  47. local l
  48. while true do
  49. l = pats:read("*l")
  50. if not l then break end
  51. l = l:match("([^/]+)%.pat$")
  52. if l then
  53. l7:value(l)
  54. end
  55. end
  56. pats:close()
  57. end
  58. p = s:option(Value, "proto", translate("Protocol"))
  59. p:value("", translate("all"))
  60. p:value("tcp", "TCP")
  61. p:value("udp", "UDP")
  62. p:value("icmp", "ICMP")
  63. p.rmempty = true
  64. ports = s:option(Value, "ports", translate("Ports"))
  65. ports.rmempty = true
  66. ports:value("", translate("all"))
  67. bytes = s:option(Value, "connbytes", translate("Number of bytes"))
  68. comment = s:option(Value, "comment", translate("Comment"))
  69. return m