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") },
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") },
168 translate("Major mode") },
172 translate("Local host name or ip address") },
176 translate("TCP/UDP port # for both local and remote") },
180 translate("TCP/UDP port # for local (default=1194)") },
184 translate("TCP/UDP port # for remote (default=1194)") },
188 translate("Allow remote to change its IP or port") },
192 translate("Do not bind to local address and port") },
196 translate("tun/tap device") },
200 translate("Type of used device") },
204 translate("Use tun/tap device node") },
207 "10.200.200.3 10.200.200.1",
208 translate("Set tun/tap adapter parameters") },
212 translate("Don't actually execute ifconfig") },
216 translate("Don't warn on ifconfig inconsistencies") },
219 "10.123.0.0 255.255.0.0",
220 translate("Add route after establishing connection") },
224 translate("Specify a default gateway for routes") },
228 translate("Delay n seconds after connection") },
232 translate("Don't add routes automatically") },
236 translate("Don't pull routes automatically") },
239 { "yes", "maybe", "no" },
240 translate("Enable Path MTU discovery") },
244 translate("Empirically measure MTU") },
248 translate("Set TCP/UDP MTU") },
252 translate("Set tun/tap device MTU") },
256 translate("Set tun/tap device overhead") },
260 translate("Enable internal datagram fragmentation"),
265 translate("Set upper bound on TCP MSS"),
270 translate("Set the TCP/UDP send buffer size") },
274 translate("Set the TCP/UDP receive buffer size") },
278 translate("Set tun/tap TX queue length") },
282 translate("Shaping for peer bandwidth") },
286 translate("tun/tap inactivity timeout") },
290 translate("Helper directive to simplify the expression of --ping and --ping-restart in server mode configurations") },
294 translate("Ping remote every n seconds over TCP/UDP port") },
298 translate("Remote ping timeout") },
302 translate("Restart after remote ping timeout") },
306 translate("Only process ping timeouts if routes exist") },
310 translate("Keep tun/tap device open on restart") },
314 translate("Don't re-read key on restart") },
318 translate("Keep local IP address on restart") },
322 translate("Keep remote IP address on restart") },
323 -- management channel
326 "127.0.0.1 31194 /etc/openvpn/mngmt-pwds",
327 translate("Enable management interface on <em>IP</em> <em>port</em>") },
330 "management_query_passwords",
332 translate("Query management channel for private key") },
337 translate("Start OpenVPN in a hibernating state") },
340 "management_log_cache",
342 translate("Number of lines for log file history") },
345 { "net30", "p2p", "subnet" },
346 translate("'net30', 'p2p', or 'subnet'"),
353 "10.200.200.0 255.255.255.0",
354 translate("Configure server mode"),
355 { client="0" }, { client="" } },
358 "10.200.200.1 255.255.255.0 10.200.200.200 10.200.200.250",
359 translate("Configure server bridge"),
360 { client="0" }, { client="" } },
363 { "redirect-gateway" },
364 translate("Push options to peer"),
365 { client="0" }, { client="" } },
369 translate("Don't inherit global push options"),
370 { client="0" }, { client="" } },
374 translate("Client is disabled"),
375 { client="0" }, { client="" } },
378 "10.200.200.100 10.200.200.150 255.255.255.0",
379 translate("Set aside a pool of subnets"),
380 { client="0" }, { client="" } },
382 "ifconfig_pool_persist",
383 "/etc/openvpn/ipp.txt 600",
384 translate("Persist/unpersist ifconfig-pool"),
385 { client="0" }, { client="" } },
388 "10.200.200.1 255.255.255.255",
389 translate("Push an ifconfig option to remote"),
390 { client="0" }, { client="" } },
393 "10.200.200.0 255.255.255.0",
394 translate("Route subnet to client"),
395 { client="0" }, { client="" } },
399 translate("Allow client-to-client traffic"),
400 { client="0" }, { client="" } },
404 translate("Allow multiple clients with same certificate"),
405 { client="0" }, { client="" } },
409 translate("Directory for custom client config files"),
410 { client="0" }, { client="" } },
414 translate("Refuse connection if no custom client config"),
415 { client="0" }, { client="" } },
419 translate("Temporary directory for client-connect return file"),
420 { client="0" }, { client="" } },
424 translate("Set size of real and virtual address hash tables"),
425 { client="0" }, { client="" } },
429 translate("Number of allocated broadcast buffers"),
430 { client="0" }, { client="" } },
434 translate("Maximum number of queued TCP output packets"),
435 { client="0" }, { client="" } },
439 translate("Allowed maximum of connected clients"),
440 { client="0" }, { client="" } },
442 "max_routes_per_client",
444 translate("Allowed maximum of internal"),
445 { client="0" }, { client="" } },
449 translate("Allowed maximum of new connections"),
450 { client="0" }, { client="" } },
452 "username_as_common_name",
454 translate("Use username as common name"),
455 { client="0" }, { client="" } },
459 translate("Configure client mode") },
463 translate("Accept options pushed from server"),
467 "/etc/openvpn/userpass.txt",
468 translate("Authenticate using username/password"),
472 { "none", "nointeract", "interact" },
473 translate("Handling of authentication failures"),
476 "explicit_exit_notify",
478 translate("Send notification to peer on disconnect"),
483 translate("Remote host name or ip address"),
488 translate("Randomly choose remote server"),
492 { "udp", "tcp-client", "tcp-server" },
493 translate("Use protocol"),
498 translate("Connection retry interval"),
499 { proto="tcp-client" }, { client="1" } },
502 "192.168.1.100 8080",
503 translate("Connect to remote host through an HTTP proxy"),
508 translate("Retry indefinitely on HTTP proxy errors"),
511 "http_proxy_timeout",
513 translate("Proxy timeout in seconds"),
517 { "VERSION 1.0", "AGENT OpenVPN/2.0.9" },
518 translate("Set extended HTTP proxy options"),
522 "192.168.1.200 1080",
523 translate("Connect through Socks5 proxy"),
525 -- client && socks_proxy
529 translate("Retry indefinitely on Socks proxy errors"),
534 translate("If hostname resolve fails, retry"),
538 { "", "local", "def1", "local def1" },
539 translate("Automatically redirect default route"),
546 "/etc/openvpn/secret.key",
547 translate("Enable Static Key encryption mode (non-TLS)") },
552 translate("HMAC authentication for packets") },
557 translate("Encryption cipher for packets") },
562 translate("Size of cipher key") },
567 translate("Enable OpenSSL hardware crypto engines") },
571 translate("Replay protection sliding window size") },
573 "mute_replay_warnings",
575 translate("Silence the output of replay warnings") },
578 "/var/run/openvpn-replay-state",
579 translate("Persist replay-protection state") },
583 translate("Enable TLS and assume server role"),
584 { tls_client="" }, { tls_client="0" } },
588 translate("Enable TLS and assume client role"),
589 { tls_server="" }, { tls_server="0" } },
592 "/etc/easy-rsa/keys/ca.crt",
593 translate("Certificate authority") },
596 "/etc/easy-rsa/keys/dh1024.pem",
597 translate("Diffie Hellman parameters") },
600 "/etc/easy-rsa/keys/some-client.crt",
601 translate("Local certificate") },
604 "/etc/easy-rsa/keys/some-client.key",
605 translate("Local private key") },
608 "/etc/easy-rsa/keys/some-client.pk12",
609 translate("PKCS#12 file containing keys") },
613 translate("Enable TLS and assume client role") },
616 "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",
617 translate("TLS cipher") },
621 translate("Retransmit timeout on TLS control channel") },
625 translate("Renegotiate data chan. key after bytes") },
629 translate("Renegotiate data chan. key after packets") },
633 translate("Renegotiate data chan. key after seconds") },
637 translate("Timeframe for key exchange") },
641 translate("Key transition window") },
645 translate("Allow only one session") },
649 translate("Exit on TLS negotiation failure") },
652 "/etc/openvpn/tlsauth.key",
653 translate("Additional authentication over TLS") },
656 "/etc/openvpn/tlscrypt.key",
657 translate("Encrypt and authenticate all control channel packets with the key") },
661 -- translate("Get PEM password from controlling tty before we daemonize") },
665 translate("Don't cache --askpass or --auth-user-pass passwords") },
669 translate("Only accept connections from given X509 name") },
672 { "client", "server" },
673 translate("Require explicit designation on certificate") },
676 { "client", "server" },
677 translate("Require explicit key usage on certificate") },
680 "/etc/easy-rsa/keys/crl.pem",
681 translate("Check peer certificate against a CRL") },
685 translate("The lowest supported TLS version") },
689 translate("The highest supported TLS version") },
693 translate("The key direction for 'tls-auth' and 'secret' options") },
701 local m = Map("openvpn")
702 m.redirect = luci.dispatcher.build_url("admin", "services", "openvpn")
703 m.apply_on_parse = true
705 local p = m:section( SimpleSection )
706 p.template = "openvpn/pageswitch"
709 p.category = arg[2] or "Service"
711 for _, c in ipairs(knownParams) do
713 if c[1] == p.category then params = c[2] end
720 NamedSection, arg[1], "openvpn",
721 translate("%s" % arg[2])
724 s.title = translate("%s" % arg[2])
729 for _, option in ipairs(params) do
731 option[1], option[2],
737 if option[1] == DummyValue then
739 elseif option[1] == FileUpload then
741 function o.cfgvalue(self, section)
742 local cfg_val = AbstractValue.cfgvalue(self, section)
749 function o.formvalue(self, section)
750 local sel_val = AbstractValue.formvalue(self, section)
751 local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox")
753 if sel_val and sel_val ~= "" then
757 if txt_val and txt_val ~= "" then
762 function o.remove(self, section)
763 local cfg_val = AbstractValue.cfgvalue(self, section)
764 local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox")
766 if cfg_val and fs.access(cfg_val) and txt_val == "" then
769 return AbstractValue.remove(self, section)
771 elseif option[1] == Flag then
774 if option[1] == DynamicList then
775 function o.cfgvalue(...)
776 local val = AbstractValue.cfgvalue(...)
777 return ( val and type(val) ~= "table" ) and { val } or val
781 if type(option[3]) == "table" then
782 if o.optional then o:value("", "-- remove --") end
783 for _, v in ipairs(option[3]) do
787 o.default = tostring(option[3][1])
789 o.default = tostring(option[3])
794 if type(option[i]) == "table" then