1 -- Copyright 2016 Dan Luedtke <mail@danrl.com>
2 -- Licensed to the public under the Apache License 2.0.
5 local map, section, net = ...
6 local ifname = net:get_interface():name()
7 local private_key, listen_port
8 local metric, mtu, preshared_key
9 local peers, public_key, allowed_ips, endpoint, persistent_keepalive
12 -- general ---------------------------------------------------------------------
14 private_key = section:taboption(
18 translate("Private Key"),
19 translate("Required. Base64-encoded private key for this interface.")
21 private_key.password = true
22 private_key.datatype = "rangelength(44, 44)"
23 private_key.optional = false
26 listen_port = section:taboption(
30 translate("Listen Port"),
31 translate("Optional. UDP port used for outgoing and incoming packets.")
33 listen_port.datatype = "port"
34 listen_port.placeholder = "51820"
35 listen_port.optional = true
38 -- advanced --------------------------------------------------------------------
40 metric = section:taboption(
45 translate("Optional.")
47 metric.datatype = "uinteger"
48 metric.placeholder = "0"
49 metric.optional = true
52 mtu = section:taboption(
57 translate("Optional. Maximum Transmission Unit of tunnel interface.")
59 mtu.datatype = "range(1280,1423)"
60 mtu.placeholder = "1423"
64 preshared_key = section:taboption(
68 translate("Preshared Key"),
69 translate("Optional. Adds in an additional layer of symmetric-key " ..
70 "cryptography for post-quantum resistance.")
72 preshared_key.password = true
73 preshared_key.datatype = "rangelength(44, 44)"
74 preshared_key.optional = true
77 -- peers -----------------------------------------------------------------------
81 "wireguard_" .. ifname,
83 translate("Further information about WireGuard interfaces and peers " ..
84 "at <a href=\"http://wireguard.io\">wireguard.io</a>.")
86 peers.template = "cbi/tsection"
87 peers.anonymous = true
88 peers.addremove = true
91 public_key = peers:option(
94 translate("Public Key"),
95 translate("Required. Public key of peer.")
97 public_key.datatype = "rangelength(44, 44)"
98 public_key.optional = false
101 allowed_ips = peers:option(
104 translate("Allowed IPs"),
105 translate("Required. IP addresses and prefixes that this peer is allowed " ..
106 "to use inside the tunnel. Routes will be added accordingly.")
108 allowed_ips.datatype = "ipaddr"
109 allowed_ips.optional = false
112 route_allowed_ips = peers:option(
115 translate("Route Allowed IPs"),
116 translate("Optional. Create routes for Allowed IPs for this peer.")
120 endpoint_host = peers:option(
123 translate("Endpoint Host"),
124 translate("Optional. Host of peer. Names are resolved " ..
125 "prior to bringing up the interface."))
126 endpoint_host.placeholder = "vpn.example.com"
127 endpoint_host.datatype = "host"
130 endpoint_port = peers:option(
133 translate("Endpoint Port"),
134 translate("Optional. Port of peer."))
135 endpoint_port.placeholder = "51820"
136 endpoint_port.datatype = "port"
139 persistent_keepalive = peers:option(
141 "persistent_keepalive",
142 translate("Persistent Keep Alive"),
143 translate("Optional. Seconds between keep alive messages. " ..
144 "Default is 0 (disabled). Recommended value if " ..
145 "this device is behind a NAT is 25."))
146 persistent_keepalive.datatype = "range(0, 65535)"
147 persistent_keepalive.placeholder = "0"