1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Licensed to the public under the Apache License 2.0.
4 local fs = require("nixio.fs")
15 { "service", translate("Service"), {
16 -- initialisation and daemon options
19 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 },
20 translate("Set output verbosity") },
24 translate("Disable Paging") },
28 translate("Disable options consistency check") },
32 -- translate("Set UID to user") },
36 -- translate("Set GID to group") },
40 translate("Change to directory before initialization") },
44 translate("Chroot to directory after initialization") },
48 -- translate("Daemonize after initialization") },
52 -- translate("Output to syslog and do not daemonize") },
56 translate("TOS passthrough (applies to IPv4 only)") },
59 -- "nowait Instance-Name",
60 -- translate("Run as an inetd or xinetd server") },
63 "/var/log/openvpn.log",
64 translate("Write log to file") },
67 "/var/log/openvpn.log",
68 translate("Append log to file") },
70 "suppress_timestamps",
72 translate("Don't log timestamps") },
75 -- "/var/run/openvpn.pid",
76 -- translate("Write process ID to file") },
80 translate("Change process priority") },
84 translate("Optimize TUN/TAP/UDP writes") },
87 "some params echoed to log",
88 translate("Echo parameters to log") },
91 { "SIGHUP", "SIGTERM" },
92 translate("Remap SIGUSR1 signals") },
95 "/var/run/openvpn.status 5",
96 translate("Write status to file every n seconds") },
100 translate("Status file format version") }, -- status
104 translate("Limit repeated log messages") },
108 translate("Shell cmd to execute after tun device open") },
112 translate("Delay tun/tap open and up script execution") },
115 "/usr/bin/ovpn-down",
116 translate("Shell cmd to run after tun device close") },
120 translate("Call down cmd/script before TUN/TAP close") },
124 translate("Run up/down scripts for all restarts") },
127 "/usr/bin/ovpn-routeup",
128 translate("Execute shell cmd after routes are added") },
131 "/usr/bin/ovpn-ipchange",
132 translate("Execute shell command on remote IP change"),
136 { "VAR1 value1", "VAR2 value2" },
137 translate("Pass environment variables to script") },
140 "/usr/bin/ovpn-tlsverify",
141 translate("Shell command to verify X509 name") },
144 "/usr/bin/ovpn-clientconnect",
145 translate("Run script cmd on client connection") },
148 "/usr/bin/ovpn-clientdisconnect",
149 translate("Run script cmd on client disconnection") },
152 "/usr/bin/ovpn-learnaddress",
153 translate("Executed in server mode whenever an IPv4 address/route or MAC address is added to OpenVPN's internal routing table") },
155 "auth_user_pass_verify",
156 "/usr/bin/ovpn-userpass via-env",
157 translate("Executed in server mode on new client connections, when the client is still untrusted") },
161 translate("Policy level over usage of external programs and scripts") },
165 translate("Enable a compression algorithm") },
168 { "networking", translate("Networking"), {
173 translate("Major mode") },
177 translate("Local host name or IP address") },
181 translate("TCP/UDP port # for both local and remote") },
185 translate("TCP/UDP port # for local (default=1194)") },
189 translate("TCP/UDP port # for remote (default=1194)") },
193 translate("Allow remote to change its IP or port") },
197 translate("Do not bind to local address and port") },
201 translate("tun/tap device") },
205 translate("Type of used device") },
209 translate("Use tun/tap device node") },
212 "10.200.200.3 10.200.200.1",
213 translate("Set tun/tap adapter parameters") },
217 translate("Don't actually execute ifconfig") },
221 translate("Don't warn on ifconfig inconsistencies") },
224 "10.123.0.0 255.255.0.0",
225 translate("Add route after establishing connection") },
229 translate("Specify a default gateway for routes") },
233 translate("Delay n seconds after connection") },
237 translate("Don't add routes automatically") },
241 translate("Don't pull routes automatically") },
243 "allow_recursive_routing",
245 translate("Don't drop incoming tun packets with same destination as host") },
248 { "yes", "maybe", "no" },
249 translate("Enable Path MTU discovery") },
253 translate("Empirically measure MTU") },
256 { "yes", "no", "adaptive" },
257 translate("Use fast LZO compression") },
261 translate("Don't use adaptive lzo compression"),
266 translate("Set TCP/UDP MTU") },
270 translate("Set tun/tap device MTU") },
274 translate("Set tun/tap device overhead") },
278 translate("Enable internal datagram fragmentation"),
283 translate("Set upper bound on TCP MSS"),
288 translate("Set the TCP/UDP send buffer size") },
292 translate("Set the TCP/UDP receive buffer size") },
296 translate("Set tun/tap TX queue length") },
300 translate("Shaping for peer bandwidth") },
304 translate("tun/tap inactivity timeout") },
308 translate("Helper directive to simplify the expression of --ping and --ping-restart in server mode configurations") },
312 translate("Ping remote every n seconds over TCP/UDP port") },
316 translate("Remote ping timeout") },
320 translate("Restart after remote ping timeout") },
324 translate("Only process ping timeouts if routes exist") },
328 translate("Keep tun/tap device open on restart") },
332 translate("Don't re-read key on restart") },
336 translate("Keep local IP address on restart") },
340 translate("Keep remote IP address on restart") },
341 -- management channel
344 "127.0.0.1 31194 /etc/openvpn/mngmt-pwds",
345 translate("Enable management interface on <em>IP</em> <em>port</em>") },
348 "management_query_passwords",
350 translate("Query management channel for private key") },
355 translate("Start OpenVPN in a hibernating state") },
358 "management_log_cache",
360 translate("Number of lines for log file history") },
363 { "net30", "p2p", "subnet" },
364 translate("'net30', 'p2p', or 'subnet'"),
368 { "vpn", translate("VPN"), {
371 "10.200.200.0 255.255.255.0",
372 translate("Configure server mode"),
373 { client="0" }, { client="" } },
376 "10.200.200.1 255.255.255.0 10.200.200.200 10.200.200.250",
377 translate("Configure server bridge"),
378 { client="0" }, { client="" } },
381 { "redirect-gateway", "comp-lzo" },
382 translate("Push options to peer"),
383 { client="0" }, { client="" } },
387 translate("Don't inherit global push options"),
388 { client="0" }, { client="" } },
392 translate("Client is disabled"),
393 { client="0" }, { client="" } },
396 "10.200.200.100 10.200.200.150 255.255.255.0",
397 translate("Set aside a pool of subnets"),
398 { client="0" }, { client="" } },
400 "ifconfig_pool_persist",
401 "/etc/openvpn/ipp.txt 600",
402 translate("Persist/unpersist ifconfig-pool"),
403 { client="0" }, { client="" } },
406 "10.200.200.1 255.255.255.255",
407 translate("Push an ifconfig option to remote"),
408 { client="0" }, { client="" } },
411 "10.200.200.0 255.255.255.0",
412 translate("Route subnet to client"),
413 { client="0" }, { client="" } },
417 translate("Allow client-to-client traffic"),
418 { client="0" }, { client="" } },
422 translate("Allow multiple clients with same certificate"),
423 { client="0" }, { client="" } },
427 translate("Directory for custom client config files"),
428 { client="0" }, { client="" } },
432 translate("Refuse connection if no custom client config"),
433 { client="0" }, { client="" } },
437 translate("Temporary directory for client-connect return file"),
438 { client="0" }, { client="" } },
442 translate("Set size of real and virtual address hash tables"),
443 { client="0" }, { client="" } },
447 translate("Number of allocated broadcast buffers"),
448 { client="0" }, { client="" } },
452 translate("Maximum number of queued TCP output packets"),
453 { client="0" }, { client="" } },
457 translate("Allowed maximum of connected clients"),
458 { client="0" }, { client="" } },
460 "max_routes_per_client",
462 translate("Allowed maximum of internal"),
463 { client="0" }, { client="" } },
467 translate("Allowed maximum of new connections"),
468 { client="0" }, { client="" } },
470 "username_as_common_name",
472 translate("Use username as common name"),
473 { client="0" }, { client="" } },
477 translate("Configure client mode") },
481 translate("Accept options pushed from server"),
485 "/etc/openvpn/userpass.txt",
486 translate("Authenticate using username/password"),
490 { "none", "nointeract", "interact" },
491 translate("Handling of authentication failures"),
494 "explicit_exit_notify",
496 translate("Send notification to peer on disconnect"),
501 translate("Remote host name or IP address") },
505 translate("Randomly choose remote server"),
509 { "udp", "tcp-client", "tcp-server" },
510 translate("Use protocol"),
515 translate("Connection retry interval"),
516 { proto="tcp-client" }, { client="1" } },
519 "192.168.1.100 8080",
520 translate("Connect to remote host through an HTTP proxy"),
525 translate("Retry indefinitely on HTTP proxy errors"),
528 "http_proxy_timeout",
530 translate("Proxy timeout in seconds"),
534 { "VERSION 1.0", "AGENT OpenVPN/2.0.9" },
535 translate("Set extended HTTP proxy options"),
539 "192.168.1.200 1080",
540 translate("Connect through Socks5 proxy"),
542 -- client && socks_proxy
546 translate("Retry indefinitely on Socks proxy errors"),
551 translate("If hostname resolve fails, retry"),
555 { "", "local", "def1", "local def1" },
556 translate("Automatically redirect default route"),
559 "verify_client_cert",
560 { "none", "optional", "require" },
561 translate("Specify whether the client is required to supply a valid certificate") },
564 { "cryptography", translate("Cryptography"), {
567 "/etc/openvpn/secret.key",
568 translate("Enable Static Key encryption mode (non-TLS)") },
573 translate("HMAC authentication for packets") },
622 translate("Encryption cipher for packets") },
627 translate("Size of cipher key") },
632 translate("Enable OpenSSL hardware crypto engines") },
636 translate("Replay protection sliding window size") },
638 "mute_replay_warnings",
640 translate("Silence the output of replay warnings") },
643 "/var/run/openvpn-replay-state",
644 translate("Persist replay-protection state") },
648 translate("Enable TLS and assume server role"),
649 { tls_client="" }, { tls_client="0" } },
653 translate("Enable TLS and assume client role"),
654 { tls_server="" }, { tls_server="0" } },
657 "/etc/easy-rsa/keys/ca.crt",
658 translate("Certificate authority") },
661 "/etc/easy-rsa/keys/dh1024.pem",
662 translate("Diffie-Hellman parameters") },
665 "/etc/easy-rsa/keys/some-client.crt",
666 translate("Local certificate") },
669 "/etc/easy-rsa/keys/some-client.key",
670 translate("Local private key") },
673 "/etc/easy-rsa/keys/some-client.pk12",
674 translate("PKCS#12 file containing keys") },
678 translate("Enable TLS and assume client role") },
682 "DHE-RSA-AES256-SHA",
683 "DHE-DSS-AES256-SHA",
685 "EDH-RSA-DES-CBC3-SHA",
686 "EDH-DSS-DES-CBC3-SHA",
688 "DHE-RSA-AES128-SHA",
689 "DHE-DSS-AES128-SHA",
693 "EDH-RSA-DES-CBC-SHA",
694 "EDH-DSS-DES-CBC-SHA",
696 "EXP-EDH-RSA-DES-CBC-SHA",
697 "EXP-EDH-DSS-DES-CBC-SHA",
702 translate("TLS cipher") },
706 "TLS_AES_256_GCM_SHA384",
707 "TLS_AES_128_GCM_SHA256",
708 "TLS_CHACHA20_POLY1305_SHA256"
710 translate("TLS 1.3 or newer cipher") },
714 translate("Retransmit timeout on TLS control channel") },
718 translate("Renegotiate data chan. key after bytes") },
722 translate("Renegotiate data chan. key after packets") },
726 translate("Renegotiate data chan. key after seconds") },
730 translate("Timeframe for key exchange") },
734 translate("Key transition window") },
738 translate("Allow only one session") },
742 translate("Exit on TLS negotiation failure") },
745 "/etc/openvpn/tlsauth.key",
746 translate("Additional authentication over TLS") },
749 "/etc/openvpn/tlscrypt.key",
750 translate("Encrypt and authenticate all control channel packets with the key") },
754 -- translate("Get PEM password from controlling tty before we daemonize") },
758 translate("Don't cache --askpass or --auth-user-pass passwords") },
762 translate("Only accept connections from given X509 name") },
765 { "client", "server" },
766 translate("Require explicit designation on certificate") },
769 { "client", "server" },
770 translate("Require explicit key usage on certificate") },
773 "/etc/easy-rsa/keys/crl.pem",
774 translate("Check peer certificate against a CRL") },
778 translate("The lowest supported TLS version") },
782 translate("The highest supported TLS version") },
786 translate("The key direction for 'tls-auth' and 'secret' options") },
790 translate("This completely disables cipher negotiation") },
793 "AES-256-GCM:AES-128-GCM",
794 translate("Restrict the allowed ciphers to be negotiated") },
803 local m = Map("openvpn")
804 m.redirect = luci.dispatcher.build_url("admin", "vpn", "openvpn")
805 m.apply_on_parse = true
807 local p = m:section( SimpleSection )
808 p.template = "openvpn/pageswitch"
811 p.category = arg[2] or knownParams[1][1]
813 for _, c in ipairs(knownParams) do
814 cts[#cts+1] = { id = c[1], title = c[2] }
815 if c[1] == p.category then
825 NamedSection, arg[1], "openvpn", title
832 for _, option in ipairs(params) do
834 option[1], option[2],
840 if option[1] == DummyValue then
842 elseif option[1] == FileUpload then
844 o.initial_directory = "/etc/openvpn"
846 function o.cfgvalue(self, section)
847 local cfg_val = AbstractValue.cfgvalue(self, section)
854 function o.formvalue(self, section)
855 local sel_val = AbstractValue.formvalue(self, section)
856 local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox")
858 if sel_val and sel_val ~= "" then
862 if txt_val and txt_val ~= "" then
867 function o.remove(self, section)
868 local cfg_val = AbstractValue.cfgvalue(self, section)
869 local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox")
871 if cfg_val and fs.access(cfg_val) and txt_val == "" then
874 return AbstractValue.remove(self, section)
876 elseif option[1] == Flag then
879 if option[1] == DynamicList then
880 function o.cfgvalue(...)
881 local val = AbstractValue.cfgvalue(...)
882 return ( val and type(val) ~= "table" ) and { val } or val
886 if type(option[3]) == "table" then
887 if o.optional then o:value("", "-- remove --") end
888 for _, v in ipairs(option[3]) do
892 o.default = tostring(option[3][1])
894 o.default = tostring(option[3])
899 if type(option[i]) == "table" then