qos.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. local uci = require "luci.model.uci"
  34. uci.cursor():foreach("qos", "class",
  35. function (section)
  36. local n = section[".name"]
  37. if string.sub(n,-string.len("_down"))~="_down" then
  38. t:value(n)
  39. end
  40. end)
  41. t.default = "Normal"
  42. srch = s:option(Value, "srchost", translate("Source host"))
  43. srch.rmempty = true
  44. srch:value("", translate("all"))
  45. wa.cbi_add_knownips(srch)
  46. dsth = s:option(Value, "dsthost", translate("Destination host"))
  47. dsth.rmempty = true
  48. dsth:value("", translate("all"))
  49. wa.cbi_add_knownips(dsth)
  50. p = s:option(Value, "proto", translate("Protocol"))
  51. p:value("", translate("all"))
  52. p:value("tcp", "TCP")
  53. p:value("udp", "UDP")
  54. p:value("icmp", "ICMP")
  55. p.rmempty = true
  56. ports = s:option(Value, "ports", translate("Ports"))
  57. ports.rmempty = true
  58. ports:value("", translate("all"))
  59. bytes = s:option(Value, "connbytes", translate("Number of bytes"))
  60. comment = s:option(Value, "comment", translate("Comment"))
  61. return m