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 -- initialisation and daemon options
18 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 },
19 translate("Set output verbosity") },
23 translate("Disable Paging") },
27 translate("Disable options consistency check") },
31 -- translate("Set UID to user") },
35 -- translate("Set GID to group") },
39 translate("Change to directory before initialization") },
43 translate("Chroot to directory after initialization") },
47 -- translate("Daemonize after initialization") },
51 -- translate("Output to syslog and do not daemonize") },
55 translate("TOS passthrough (applies to IPv4 only)") },
58 -- "nowait Instance-Name",
59 -- translate("Run as an inetd or xinetd server") },
62 "/var/log/openvpn.log",
63 translate("Write log to file") },
66 "/var/log/openvpn.log",
67 translate("Append log to file") },
69 "suppress_timestamps",
71 translate("Don't log timestamps") },
74 -- "/var/run/openvpn.pid",
75 -- translate("Write process ID to file") },
79 translate("Change process priority") },
83 translate("Optimize TUN/TAP/UDP writes") },
86 "some params echoed to log",
87 translate("Echo parameters to log") },
90 { "SIGHUP", "SIGTERM" },
91 translate("Remap SIGUSR1 signals") },
94 "/var/run/openvpn.status 5",
95 translate("Write status to file every n seconds") },
99 translate("Status file format version") }, -- status
103 translate("Limit repeated log messages") },
107 translate("Shell cmd to execute after tun device open") },
111 translate("Delay tun/tap open and up script execution") },
114 "/usr/bin/ovpn-down",
115 translate("Shell cmd to run after tun device close") },
119 translate("Call down cmd/script before TUN/TAP close") },
123 translate("Run up/down scripts for all restarts") },
126 "/usr/bin/ovpn-routeup",
127 translate("Execute shell cmd after routes are added") },
130 "/usr/bin/ovpn-ipchange",
131 translate("Execute shell command on remote ip change"),
135 { "VAR1 value1", "VAR2 value2" },
136 translate("Pass environment variables to script") },
139 "/usr/bin/ovpn-tlsverify",
140 translate("Shell command to verify X509 name") },
143 "/usr/bin/ovpn-clientconnect",
144 translate("Run script cmd on client connection") },
147 "/usr/bin/ovpn-clientdisconnect",
148 translate("Run script cmd on client disconnection") },
151 "/usr/bin/ovpn-learnaddress",
152 translate("Executed in server mode whenever an IPv4 address/route or MAC address is added to OpenVPN's internal routing table") },
154 "auth_user_pass_verify",
155 "/usr/bin/ovpn-userpass via-env",
156 translate("Executed in server mode on new client connections, when the client is still untrusted") },
160 translate("Policy level over usage of external programs and scripts") },
164 translate("Enable a compression algorithm") },
172 translate("Major mode") },
176 translate("Local host name or ip address") },
180 translate("TCP/UDP port # for both local and remote") },
184 translate("TCP/UDP port # for local (default=1194)") },
188 translate("TCP/UDP port # for remote (default=1194)") },
192 translate("Allow remote to change its IP or port") },
196 translate("Do not bind to local address and port") },
200 translate("tun/tap device") },
204 translate("Type of used device") },
208 translate("Use tun/tap device node") },
211 "10.200.200.3 10.200.200.1",
212 translate("Set tun/tap adapter parameters") },
216 translate("Don't actually execute ifconfig") },
220 translate("Don't warn on ifconfig inconsistencies") },
223 "10.123.0.0 255.255.0.0",
224 translate("Add route after establishing connection") },
228 translate("Specify a default gateway for routes") },
232 translate("Delay n seconds after connection") },
236 translate("Don't add routes automatically") },
240 translate("Don't pull routes automatically") },
242 "allow_recursive_routing",
244 translate("Don't drop incoming tun packets with same destination as host") },
247 { "yes", "maybe", "no" },
248 translate("Enable Path MTU discovery") },
252 translate("Empirically measure MTU") },
255 { "yes", "no", "adaptive" },
256 translate("Use fast LZO compression") },
260 translate("Don't use adaptive lzo compression"),
265 translate("Set TCP/UDP MTU") },
269 translate("Set tun/tap device MTU") },
273 translate("Set tun/tap device overhead") },
277 translate("Enable internal datagram fragmentation"),
282 translate("Set upper bound on TCP MSS"),
287 translate("Set the TCP/UDP send buffer size") },
291 translate("Set the TCP/UDP receive buffer size") },
295 translate("Set tun/tap TX queue length") },
299 translate("Shaping for peer bandwidth") },
303 translate("tun/tap inactivity timeout") },
307 translate("Helper directive to simplify the expression of --ping and --ping-restart in server mode configurations") },
311 translate("Ping remote every n seconds over TCP/UDP port") },
315 translate("Remote ping timeout") },
319 translate("Restart after remote ping timeout") },
323 translate("Only process ping timeouts if routes exist") },
327 translate("Keep tun/tap device open on restart") },
331 translate("Don't re-read key on restart") },
335 translate("Keep local IP address on restart") },
339 translate("Keep remote IP address on restart") },
340 -- management channel
343 "127.0.0.1 31194 /etc/openvpn/mngmt-pwds",
344 translate("Enable management interface on <em>IP</em> <em>port</em>") },
347 "management_query_passwords",
349 translate("Query management channel for private key") },
354 translate("Start OpenVPN in a hibernating state") },
357 "management_log_cache",
359 translate("Number of lines for log file history") },
362 { "net30", "p2p", "subnet" },
363 translate("'net30', 'p2p', or 'subnet'"),
370 "10.200.200.0 255.255.255.0",
371 translate("Configure server mode"),
372 { client="0" }, { client="" } },
375 "10.200.200.1 255.255.255.0 10.200.200.200 10.200.200.250",
376 translate("Configure server bridge"),
377 { client="0" }, { client="" } },
380 { "redirect-gateway", "comp-lzo" },
381 translate("Push options to peer"),
382 { client="0" }, { client="" } },
386 translate("Don't inherit global push options"),
387 { client="0" }, { client="" } },
391 translate("Client is disabled"),
392 { client="0" }, { client="" } },
395 "10.200.200.100 10.200.200.150 255.255.255.0",
396 translate("Set aside a pool of subnets"),
397 { client="0" }, { client="" } },
399 "ifconfig_pool_persist",
400 "/etc/openvpn/ipp.txt 600",
401 translate("Persist/unpersist ifconfig-pool"),
402 { client="0" }, { client="" } },
405 "10.200.200.1 255.255.255.255",
406 translate("Push an ifconfig option to remote"),
407 { client="0" }, { client="" } },
410 "10.200.200.0 255.255.255.0",
411 translate("Route subnet to client"),
412 { client="0" }, { client="" } },
416 translate("Allow client-to-client traffic"),
417 { client="0" }, { client="" } },
421 translate("Allow multiple clients with same certificate"),
422 { client="0" }, { client="" } },
426 translate("Directory for custom client config files"),
427 { client="0" }, { client="" } },
431 translate("Refuse connection if no custom client config"),
432 { client="0" }, { client="" } },
436 translate("Temporary directory for client-connect return file"),
437 { client="0" }, { client="" } },
441 translate("Set size of real and virtual address hash tables"),
442 { client="0" }, { client="" } },
446 translate("Number of allocated broadcast buffers"),
447 { client="0" }, { client="" } },
451 translate("Maximum number of queued TCP output packets"),
452 { client="0" }, { client="" } },
456 translate("Allowed maximum of connected clients"),
457 { client="0" }, { client="" } },
459 "max_routes_per_client",
461 translate("Allowed maximum of internal"),
462 { client="0" }, { client="" } },
466 translate("Allowed maximum of new connections"),
467 { client="0" }, { client="" } },
469 "username_as_common_name",
471 translate("Use username as common name"),
472 { client="0" }, { client="" } },
476 translate("Configure client mode") },
480 translate("Accept options pushed from server"),
484 "/etc/openvpn/userpass.txt",
485 translate("Authenticate using username/password"),
489 { "none", "nointeract", "interact" },
490 translate("Handling of authentication failures"),
493 "explicit_exit_notify",
495 translate("Send notification to peer on disconnect"),
500 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") },
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") },
681 "DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DES-CBC3-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:AES128-SHA:RC4-SHA:RC4-MD5:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:EXP-EDH-RSA-DES-CBC-SHA:EXP-EDH-DSS-DES-CBC-SHA:EXP-DES-CBC-SHA:EXP-RC2-CBC-MD5:EXP-RC4-MD5",
682 translate("TLS cipher") },
685 "TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256",
686 translate("TLS 1.3 or newer cipher") },
690 translate("Retransmit timeout on TLS control channel") },
694 translate("Renegotiate data chan. key after bytes") },
698 translate("Renegotiate data chan. key after packets") },
702 translate("Renegotiate data chan. key after seconds") },
706 translate("Timeframe for key exchange") },
710 translate("Key transition window") },
714 translate("Allow only one session") },
718 translate("Exit on TLS negotiation failure") },
721 "/etc/openvpn/tlsauth.key",
722 translate("Additional authentication over TLS") },
725 "/etc/openvpn/tlscrypt.key",
726 translate("Encrypt and authenticate all control channel packets with the key") },
730 -- translate("Get PEM password from controlling tty before we daemonize") },
734 translate("Don't cache --askpass or --auth-user-pass passwords") },
738 translate("Only accept connections from given X509 name") },
741 { "client", "server" },
742 translate("Require explicit designation on certificate") },
745 { "client", "server" },
746 translate("Require explicit key usage on certificate") },
749 "/etc/easy-rsa/keys/crl.pem",
750 translate("Check peer certificate against a CRL") },
754 translate("The lowest supported TLS version") },
758 translate("The highest supported TLS version") },
762 translate("The key direction for 'tls-auth' and 'secret' options") },
766 translate("This completely disables cipher negotiation") },
769 "AES-256-GCM:AES-128-GCM",
770 translate("Restrict the allowed ciphers to be negotiated") },
778 local m = Map("openvpn")
779 m.redirect = luci.dispatcher.build_url("admin", "services", "openvpn")
780 m.apply_on_parse = true
782 local p = m:section( SimpleSection )
783 p.template = "openvpn/pageswitch"
786 p.category = arg[2] or "Service"
788 for _, c in ipairs(knownParams) do
790 if c[1] == p.category then params = c[2] end
797 NamedSection, arg[1], "openvpn",
798 translate("%s" % arg[2])
801 s.title = translate("%s" % arg[2])
806 for _, option in ipairs(params) do
808 option[1], option[2],
814 if option[1] == DummyValue then
816 elseif option[1] == FileUpload then
818 function o.cfgvalue(self, section)
819 local cfg_val = AbstractValue.cfgvalue(self, section)
826 function o.formvalue(self, section)
827 local sel_val = AbstractValue.formvalue(self, section)
828 local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox")
830 if sel_val and sel_val ~= "" then
834 if txt_val and txt_val ~= "" then
839 function o.remove(self, section)
840 local cfg_val = AbstractValue.cfgvalue(self, section)
841 local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox")
843 if cfg_val and fs.access(cfg_val) and txt_val == "" then
846 return AbstractValue.remove(self, section)
848 elseif option[1] == Flag then
851 if option[1] == DynamicList then
852 function o.cfgvalue(...)
853 local val = AbstractValue.cfgvalue(...)
854 return ( val and type(val) ~= "table" ) and { val } or val
858 if type(option[3]) == "table" then
859 if o.optional then o:value("", "-- remove --") end
860 for _, v in ipairs(option[3]) do
864 o.default = tostring(option[3][1])
866 o.default = tostring(option[3])
871 if type(option[i]) == "table" then