proto_pptp.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. -- Copyright 2011-2012 Jo-Philipp Wich <jow@openwrt.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local map, section, net = ...
  4. local server, username, password
  5. local defaultroute, metric, peerdns, dns,
  6. keepalive_failure, keepalive_interval, demand, mtu
  7. server = section:taboption("general", Value, "server", translate("VPN Server"))
  8. server.datatype = "host"
  9. username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
  10. password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
  11. password.password = true
  12. defaultroute = section:taboption("advanced", Flag, "defaultroute",
  13. translate("Use default gateway"),
  14. translate("If unchecked, no default route is configured"))
  15. defaultroute.default = defaultroute.enabled
  16. metric = section:taboption("advanced", Value, "metric",
  17. translate("Use gateway metric"))
  18. metric.placeholder = "0"
  19. metric.datatype = "uinteger"
  20. metric:depends("defaultroute", defaultroute.enabled)
  21. peerdns = section:taboption("advanced", Flag, "peerdns",
  22. translate("Use DNS servers advertised by peer"),
  23. translate("If unchecked, the advertised DNS server addresses are ignored"))
  24. peerdns.default = peerdns.enabled
  25. dns = section:taboption("advanced", DynamicList, "dns",
  26. translate("Use custom DNS servers"))
  27. dns:depends("peerdns", "")
  28. dns.datatype = "ipaddr"
  29. dns.cast = "string"
  30. keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
  31. translate("LCP echo failure threshold"),
  32. translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
  33. function keepalive_failure.cfgvalue(self, section)
  34. local v = m:get(section, "keepalive")
  35. if v and #v > 0 then
  36. return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
  37. end
  38. end
  39. keepalive_failure.placeholder = "0"
  40. keepalive_failure.datatype = "uinteger"
  41. keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
  42. translate("LCP echo interval"),
  43. translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
  44. function keepalive_interval.cfgvalue(self, section)
  45. local v = m:get(section, "keepalive")
  46. if v and #v > 0 then
  47. return tonumber(v:match("^%d+[ ,]+(%d+)"))
  48. end
  49. end
  50. function keepalive_interval.write(self, section, value)
  51. local f = tonumber(keepalive_failure:formvalue(section)) or 0
  52. local i = tonumber(value) or 5
  53. if i < 1 then i = 1 end
  54. if f > 0 then
  55. m:set(section, "keepalive", "%d %d" %{ f, i })
  56. else
  57. m:del(section, "keepalive")
  58. end
  59. end
  60. keepalive_interval.remove = keepalive_interval.write
  61. keepalive_failure.write = keepalive_interval.write
  62. keepalive_failure.remove = keepalive_interval.write
  63. keepalive_interval.placeholder = "5"
  64. keepalive_interval.datatype = "min(1)"
  65. demand = section:taboption("advanced", Value, "demand",
  66. translate("Inactivity timeout"),
  67. translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
  68. demand.placeholder = "0"
  69. demand.datatype = "uinteger"
  70. mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
  71. mtu.placeholder = "1500"
  72. mtu.datatype = "max(9200)"