proto_wireguard.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. -- Copyright 2016 Dan Luedtke <mail@danrl.com>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local map, section, net = ...
  4. local ifname = net:get_interface():name()
  5. local private_key, listen_port
  6. local metric, mtu, preshared_key
  7. local peers, public_key, allowed_ips, endpoint, persistent_keepalive
  8. -- general ---------------------------------------------------------------------
  9. private_key = section:taboption(
  10. "general",
  11. Value,
  12. "private_key",
  13. translate("Private Key"),
  14. translate("Required. Base64-encoded private key for this interface.")
  15. )
  16. private_key.password = true
  17. private_key.datatype = "rangelength(44, 44)"
  18. private_key.optional = false
  19. listen_port = section:taboption(
  20. "general",
  21. Value,
  22. "listen_port",
  23. translate("Listen Port"),
  24. translate("Optional. UDP port used for outgoing and incoming packets.")
  25. )
  26. listen_port.datatype = "port"
  27. listen_port.placeholder = "51820"
  28. listen_port.optional = true
  29. -- advanced --------------------------------------------------------------------
  30. metric = section:taboption(
  31. "advanced",
  32. Value,
  33. "metric",
  34. translate("Metric"),
  35. translate("Optional.")
  36. )
  37. metric.datatype = "uinteger"
  38. metric.placeholder = "0"
  39. metric.optional = true
  40. mtu = section:taboption(
  41. "advanced",
  42. Value,
  43. "mtu",
  44. translate("MTU"),
  45. translate("Optional. Maximum Transmission Unit of tunnel interface.")
  46. )
  47. mtu.datatype = "range(1280,1423)"
  48. mtu.placeholder = "1423"
  49. mtu.optional = true
  50. preshared_key = section:taboption(
  51. "advanced",
  52. Value,
  53. "preshared_key",
  54. translate("Preshared Key"),
  55. translate("Optional. Adds in an additional layer of symmetric-key " ..
  56. "cryptography for post-quantum resistance.")
  57. )
  58. preshared_key.password = true
  59. preshared_key.datatype = "rangelength(44, 44)"
  60. preshared_key.optional = true
  61. -- peers -----------------------------------------------------------------------
  62. peers = map:section(
  63. TypedSection,
  64. "wireguard_" .. ifname,
  65. translate("Peers"),
  66. translate("Further information about WireGuard interfaces and peers " ..
  67. "at <a href=\"http://wireguard.io\">wireguard.io</a>.")
  68. )
  69. peers.template = "cbi/tsection"
  70. peers.anonymous = true
  71. peers.addremove = true
  72. public_key = peers:option(
  73. Value,
  74. "public_key",
  75. translate("Public Key"),
  76. translate("Required. Public key of peer.")
  77. )
  78. public_key.datatype = "rangelength(44, 44)"
  79. public_key.optional = false
  80. allowed_ips = peers:option(
  81. DynamicList,
  82. "allowed_ips",
  83. translate("Allowed IPs"),
  84. translate("Required. IP addresses and prefixes that this peer is allowed " ..
  85. "to use inside the tunnel. Usually the peer's tunnel IP " ..
  86. "addresses and the networks the peer routes through the tunnel.")
  87. )
  88. allowed_ips.datatype = "ipaddr"
  89. allowed_ips.optional = false
  90. route_allowed_ips = peers:option(
  91. Flag,
  92. "route_allowed_ips",
  93. translate("Route Allowed IPs"),
  94. translate("Optional. Create routes for Allowed IPs for this peer.")
  95. )
  96. endpoint_host = peers:option(
  97. Value,
  98. "endpoint_host",
  99. translate("Endpoint Host"),
  100. translate("Optional. Host of peer. Names are resolved " ..
  101. "prior to bringing up the interface."))
  102. endpoint_host.placeholder = "vpn.example.com"
  103. endpoint_host.datatype = "host"
  104. endpoint_port = peers:option(
  105. Value,
  106. "endpoint_port",
  107. translate("Endpoint Port"),
  108. translate("Optional. Port of peer."))
  109. endpoint_port.placeholder = "51820"
  110. endpoint_port.datatype = "port"
  111. persistent_keepalive = peers:option(
  112. Value,
  113. "persistent_keepalive",
  114. translate("Persistent Keep Alive"),
  115. translate("Optional. Seconds between keep alive messages. " ..
  116. "Default is 0 (disabled). Recommended value if " ..
  117. "this device is behind a NAT is 25."))
  118. persistent_keepalive.datatype = "range(0, 65535)"
  119. persistent_keepalive.placeholder = "0"