2
0

openvpn-advanced.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  1. -- Copyright 2008 Steven Barth <steven@midlink.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local fs = require("nixio.fs")
  4. local knownParams = {
  5. --
  6. --Widget
  7. -- ID
  8. -- Display name
  9. -- Default(s)
  10. -- Description
  11. -- Option(s)
  12. { "service", translate("Service"), {
  13. -- initialisation and daemon options
  14. { ListValue,
  15. "verb",
  16. { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 },
  17. translate("Set output verbosity") },
  18. { Flag,
  19. "mlock",
  20. 0,
  21. translate("Disable Paging") },
  22. { Flag,
  23. "disable_occ",
  24. 0,
  25. translate("Disable options consistency check") },
  26. -- { Value,
  27. -- "user",
  28. -- "root",
  29. -- translate("Set UID to user") },
  30. -- { Value,
  31. -- "group",
  32. -- "root",
  33. -- translate("Set GID to group") },
  34. { Value,
  35. "cd",
  36. "/etc/openvpn",
  37. translate("Change to directory before initialization") },
  38. { Value,
  39. "chroot",
  40. "/var/run",
  41. translate("Chroot to directory after initialization") },
  42. -- { Value,
  43. -- "daemon",
  44. -- "Instance-Name",
  45. -- translate("Daemonize after initialization") },
  46. -- { Value,
  47. -- "syslog",
  48. -- "Instance-Name",
  49. -- translate("Output to syslog and do not daemonize") },
  50. { Flag,
  51. "passtos",
  52. 0,
  53. translate("TOS passthrough (applies to IPv4 only)") },
  54. -- { Value,
  55. -- "inetd",
  56. -- "nowait Instance-Name",
  57. -- translate("Run as an inetd or xinetd server") },
  58. { Value,
  59. "log",
  60. "/var/log/openvpn.log",
  61. translate("Write log to file") },
  62. { Value,
  63. "log_append",
  64. "/var/log/openvpn.log",
  65. translate("Append log to file") },
  66. { Flag,
  67. "suppress_timestamps",
  68. 0,
  69. translate("Don't log timestamps") },
  70. -- { Value,
  71. -- "writepid",
  72. -- "/var/run/openvpn.pid",
  73. -- translate("Write process ID to file") },
  74. { Value,
  75. "nice",
  76. 0,
  77. translate("Change process priority") },
  78. { Flag,
  79. "fast_io",
  80. 0,
  81. translate("Optimize TUN/TAP/UDP writes") },
  82. { Value,
  83. "echo",
  84. "some params echoed to log",
  85. translate("Echo parameters to log") },
  86. { ListValue,
  87. "remap_usr1",
  88. { "SIGHUP", "SIGTERM" },
  89. translate("Remap SIGUSR1 signals") },
  90. { Value,
  91. "status",
  92. "/var/run/openvpn.status 5",
  93. translate("Write status to file every n seconds") },
  94. { Value,
  95. "status_version",
  96. { 1, 2 },
  97. translate("Status file format version") }, -- status
  98. { Value,
  99. "mute",
  100. 5,
  101. translate("Limit repeated log messages") },
  102. { Value,
  103. "up",
  104. "/usr/bin/ovpn-up",
  105. translate("Shell cmd to execute after tun device open") },
  106. { Value,
  107. "up_delay",
  108. 5,
  109. translate("Delay tun/tap open and up script execution") },
  110. { Value,
  111. "down",
  112. "/usr/bin/ovpn-down",
  113. translate("Shell cmd to run after tun device close") },
  114. { Flag,
  115. "down_pre",
  116. 0,
  117. translate("Call down cmd/script before TUN/TAP close") },
  118. { Flag,
  119. "up_restart",
  120. 0,
  121. translate("Run up/down scripts for all restarts") },
  122. { Value,
  123. "route_up",
  124. "/usr/bin/ovpn-routeup",
  125. translate("Execute shell cmd after routes are added") },
  126. { Value,
  127. "ipchange",
  128. "/usr/bin/ovpn-ipchange",
  129. translate("Execute shell command on remote IP change"),
  130. { mode="p2p" } },
  131. { DynamicList,
  132. "setenv",
  133. { "VAR1 value1", "VAR2 value2" },
  134. translate("Pass environment variables to script") },
  135. { Value,
  136. "tls_verify",
  137. "/usr/bin/ovpn-tlsverify",
  138. translate("Shell command to verify X509 name") },
  139. { Value,
  140. "client_connect",
  141. "/usr/bin/ovpn-clientconnect",
  142. translate("Run script cmd on client connection") },
  143. { Value,
  144. "client_disconnect",
  145. "/usr/bin/ovpn-clientdisconnect",
  146. translate("Run script cmd on client disconnection") },
  147. { Value,
  148. "learn_address",
  149. "/usr/bin/ovpn-learnaddress",
  150. translate("Executed in server mode whenever an IPv4 address/route or MAC address is added to OpenVPN's internal routing table") },
  151. { Value,
  152. "auth_user_pass_verify",
  153. "/usr/bin/ovpn-userpass via-env",
  154. translate("Executed in server mode on new client connections, when the client is still untrusted") },
  155. { ListValue,
  156. "script_security",
  157. { 0, 1, 2, 3 },
  158. translate("Policy level over usage of external programs and scripts") },
  159. { ListValue,
  160. "compress",
  161. { "frames_only", "lzo", "lz4", "stub-v2"},
  162. translate("Security recommendation: It is recommended to not enable compression and set this parameter to `stub-v2`") },
  163. } },
  164. { "networking", translate("Networking"), {
  165. -- socket config
  166. { ListValue,
  167. "mode",
  168. { "p2p", "server" },
  169. translate("Major mode") },
  170. { Value,
  171. "local",
  172. "0.0.0.0",
  173. translate("Local host name or IP address") },
  174. { Value,
  175. "port",
  176. 1194,
  177. translate("TCP/UDP port # for both local and remote") },
  178. { Value,
  179. "lport",
  180. 1194,
  181. translate("TCP/UDP port # for local (default=1194)") },
  182. { Value,
  183. "rport",
  184. 1194,
  185. translate("TCP/UDP port # for remote (default=1194)") },
  186. { ListValue,
  187. "proto",
  188. { "udp", "tcp-client", "tcp-server" },
  189. translate("Use protocol") },
  190. { Flag,
  191. "float",
  192. 0,
  193. translate("Allow remote to change its IP or port") },
  194. { Flag,
  195. "nobind",
  196. 0,
  197. translate("Do not bind to local address and port") },
  198. { Flag,
  199. "multihome",
  200. 0,
  201. translate("When you have more than one IP address (e.g. multiple interfaces, or secondary IP addresses), and do not use --local to force binding to one specific address only") },
  202. { Value,
  203. "dev",
  204. "tun0",
  205. translate("tun/tap device") },
  206. { ListValue,
  207. "dev_type",
  208. { "tun", "tap" },
  209. translate("Type of used device") },
  210. { Value,
  211. "dev_node",
  212. "/dev/net/tun",
  213. translate("Use tun/tap device node") },
  214. { Value,
  215. "ifconfig",
  216. "10.200.200.3 10.200.200.1",
  217. translate("Set tun/tap adapter parameters") },
  218. { Flag,
  219. "ifconfig_noexec",
  220. 0,
  221. translate("Don't actually execute ifconfig") },
  222. { Flag,
  223. "ifconfig_nowarn",
  224. 0,
  225. translate("Don't warn on ifconfig inconsistencies") },
  226. { DynamicList,
  227. "route",
  228. "10.123.0.0 255.255.0.0",
  229. translate("Add route after establishing connection") },
  230. { Value,
  231. "route_gateway",
  232. "10.234.1.1",
  233. translate("Specify a default gateway for routes") },
  234. { Value,
  235. "route_delay",
  236. 0,
  237. translate("Delay n seconds after connection") },
  238. { Flag,
  239. "route_noexec",
  240. 0,
  241. translate("Don't add routes automatically") },
  242. { Flag,
  243. "route_nopull",
  244. 0,
  245. translate("Don't pull routes automatically") },
  246. { Flag,
  247. "allow_recursive_routing",
  248. 0,
  249. translate("Don't drop incoming tun packets with same destination as host") },
  250. { ListValue,
  251. "mtu_disc",
  252. { "yes", "maybe", "no" },
  253. translate("Enable Path MTU discovery") },
  254. { Flag,
  255. "mtu_test",
  256. 0,
  257. translate("Empirically measure MTU") },
  258. { ListValue,
  259. "comp_lzo",
  260. { "yes", "no", "adaptive" },
  261. translate("Security recommendation: It is recommended to not enable compression and set this parameter to `no`")},
  262. { Flag,
  263. "comp_noadapt",
  264. 0,
  265. translate("Don't use adaptive lzo compression"),
  266. { comp_lzo=1 } },
  267. { Value,
  268. "link_mtu",
  269. 1500,
  270. translate("Set TCP/UDP MTU") },
  271. { Value,
  272. "tun_mtu",
  273. 1500,
  274. translate("Set tun/tap device MTU") },
  275. { Value,
  276. "tun_mtu_extra",
  277. 1500,
  278. translate("Set tun/tap device overhead") },
  279. { Value,
  280. "fragment",
  281. 1500,
  282. translate("Enable internal datagram fragmentation"),
  283. { proto="udp" } },
  284. { Value,
  285. "mssfix",
  286. 1450,
  287. translate("Set upper bound on TCP MSS"),
  288. { proto="udp" } },
  289. { Value,
  290. "sndbuf",
  291. 65536,
  292. translate("Set the TCP/UDP send buffer size") },
  293. { Value,
  294. "rcvbuf",
  295. 65536,
  296. translate("Set the TCP/UDP receive buffer size") },
  297. { Value,
  298. "txqueuelen",
  299. 100,
  300. translate("Set tun/tap TX queue length") },
  301. { Value,
  302. "shaper",
  303. 10240,
  304. translate("Shaping for peer bandwidth") },
  305. { Value,
  306. "inactive",
  307. 240,
  308. translate("tun/tap inactivity timeout") },
  309. { Value,
  310. "keepalive",
  311. "10 60",
  312. translate("Helper directive to simplify the expression of --ping and --ping-restart in server mode configurations") },
  313. { Value,
  314. "ping",
  315. 30,
  316. translate("Ping remote every n seconds over TCP/UDP port") },
  317. { Value,
  318. "ping_exit",
  319. 120,
  320. translate("Remote ping timeout") },
  321. { Value,
  322. "ping_restart",
  323. 60,
  324. translate("Restart after remote ping timeout") },
  325. { Flag,
  326. "ping_timer_rem",
  327. 0,
  328. translate("Only process ping timeouts if routes exist") },
  329. { Flag,
  330. "persist_tun",
  331. 0,
  332. translate("Keep tun/tap device open on restart") },
  333. { Flag,
  334. "persist_key",
  335. 0,
  336. translate("Don't re-read key on restart") },
  337. { Flag,
  338. "persist_local_ip",
  339. 0,
  340. translate("Keep local IP address on restart") },
  341. { Flag,
  342. "persist_remote_ip",
  343. 0,
  344. translate("Keep remote IP address on restart") },
  345. -- management channel
  346. { Value,
  347. "management",
  348. "127.0.0.1 31194 /etc/openvpn/mngmt-pwds",
  349. translate("Enable management interface on <em>IP</em> <em>port</em>") },
  350. -- management
  351. { Flag,
  352. "management_query_passwords",
  353. 0,
  354. translate("Query management channel for private key") },
  355. -- management
  356. { Flag,
  357. "management_hold",
  358. 0,
  359. translate("Start OpenVPN in a hibernating state") },
  360. -- management
  361. { Value,
  362. "management_log_cache",
  363. 100,
  364. translate("Number of lines for log file history") },
  365. { ListValue,
  366. "topology",
  367. { "net30", "p2p", "subnet" },
  368. translate("'net30', 'p2p', or 'subnet'"),
  369. {dev_type="tun" } },
  370. { Flag,
  371. "disable_dco",
  372. 0,
  373. translate("Disable Data Channel Offloading (DCO) support") },
  374. } },
  375. { "vpn", translate("VPN"), {
  376. { Value,
  377. "server",
  378. "10.200.200.0 255.255.255.0",
  379. translate("Configure server mode"),
  380. { client="0" }, { client="" } },
  381. { Value,
  382. "server_bridge",
  383. "10.200.200.1 255.255.255.0 10.200.200.200 10.200.200.250",
  384. translate("Configure server bridge"),
  385. { client="0" }, { client="" } },
  386. { DynamicList,
  387. "push",
  388. { "redirect-gateway", "comp-lzo" },
  389. translate("Push options to peer"),
  390. { client="0" }, { client="" } },
  391. { Flag,
  392. "push_reset",
  393. 0,
  394. translate("Don't inherit global push options"),
  395. { client="0" }, { client="" } },
  396. { Flag,
  397. "disable",
  398. 0,
  399. translate("Client is disabled"),
  400. { client="0" }, { client="" } },
  401. { Value,
  402. "ifconfig_pool",
  403. "10.200.200.100 10.200.200.150 255.255.255.0",
  404. translate("Set aside a pool of subnets"),
  405. { client="0" }, { client="" } },
  406. { Value,
  407. "ifconfig_pool_persist",
  408. "/etc/openvpn/ipp.txt 600",
  409. translate("Persist/unpersist ifconfig-pool"),
  410. { client="0" }, { client="" } },
  411. { Value,
  412. "ifconfig_push",
  413. "10.200.200.1 255.255.255.255",
  414. translate("Push an ifconfig option to remote"),
  415. { client="0" }, { client="" } },
  416. { Value,
  417. "iroute",
  418. "10.200.200.0 255.255.255.0",
  419. translate("Route subnet to client"),
  420. { client="0" }, { client="" } },
  421. { Flag,
  422. "client_to_client",
  423. 0,
  424. translate("Allow client-to-client traffic"),
  425. { client="0" }, { client="" } },
  426. { Flag,
  427. "duplicate_cn",
  428. 0,
  429. translate("Allow multiple clients with same certificate"),
  430. { client="0" }, { client="" } },
  431. { Value,
  432. "client_config_dir",
  433. "/etc/openvpn/ccd",
  434. translate("Directory for custom client config files"),
  435. { client="0" }, { client="" } },
  436. { Flag,
  437. "ccd_exclusive",
  438. 0,
  439. translate("Refuse connection if no custom client config"),
  440. { client="0" }, { client="" } },
  441. { Value,
  442. "tmp_dir",
  443. "/var/run/openvpn",
  444. translate("Temporary directory for client-connect return file"),
  445. { client="0" }, { client="" } },
  446. { Value,
  447. "hash_size",
  448. "256 256",
  449. translate("Set size of real and virtual address hash tables"),
  450. { client="0" }, { client="" } },
  451. { Value,
  452. "bcast_buffers",
  453. 256,
  454. translate("Number of allocated broadcast buffers"),
  455. { client="0" }, { client="" } },
  456. { Value,
  457. "tcp_queue_limit",
  458. 64,
  459. translate("Maximum number of queued TCP output packets"),
  460. { client="0" }, { client="" } },
  461. { Value,
  462. "max_clients",
  463. 10,
  464. translate("Allowed maximum of connected clients"),
  465. { client="0" }, { client="" } },
  466. { Value,
  467. "max_routes_per_client",
  468. 256,
  469. translate("Allowed maximum of internal"),
  470. { client="0" }, { client="" } },
  471. { Value,
  472. "connect_freq",
  473. "3 10",
  474. translate("Allowed maximum of new connections"),
  475. { client="0" }, { client="" } },
  476. { Flag,
  477. "username_as_common_name",
  478. 0,
  479. translate("Use username as common name"),
  480. { client="0" }, { client="" } },
  481. { Flag,
  482. "client",
  483. 0,
  484. translate("Configure client mode") },
  485. { Flag,
  486. "pull",
  487. 0,
  488. translate("Accept options pushed from server"),
  489. { client="1" } },
  490. { FileUpload,
  491. "auth_user_pass",
  492. "/etc/openvpn/userpass.txt",
  493. translate("Authenticate using username/password"),
  494. { client="1" } },
  495. { ListValue,
  496. "auth_retry",
  497. { "none", "nointeract", "interact" },
  498. translate("Handling of authentication failures"),
  499. { client="1" } },
  500. { Value,
  501. "explicit_exit_notify",
  502. 1,
  503. translate("Send notification to peer on disconnect"),
  504. { client="1" } },
  505. { DynamicList,
  506. "remote",
  507. "1.2.3.4",
  508. translate("Remote host name or IP address") },
  509. { Flag,
  510. "remote_random",
  511. 0,
  512. translate("Randomly choose remote server"),
  513. { client="1" } },
  514. { Value,
  515. "connect_retry",
  516. 5,
  517. translate("Connection retry interval"),
  518. { proto="tcp-client" }, { client="1" } },
  519. { Value,
  520. "http_proxy",
  521. "192.168.1.100 8080",
  522. translate("Connect to remote host through an HTTP proxy"),
  523. { client="1" } },
  524. { Flag,
  525. "http_proxy_retry",
  526. 0,
  527. translate("Retry indefinitely on HTTP proxy errors"),
  528. { client="1" } },
  529. { Value,
  530. "http_proxy_timeout",
  531. 5,
  532. translate("Proxy timeout in seconds"),
  533. { client="1" } },
  534. { DynamicList,
  535. "http_proxy_option",
  536. { "VERSION 1.0", "AGENT OpenVPN/2.0.9" },
  537. translate("Set extended HTTP proxy options"),
  538. { client="1" } },
  539. { Value,
  540. "socks_proxy",
  541. "192.168.1.200 1080",
  542. translate("Connect through Socks5 proxy"),
  543. { client="1" } },
  544. -- client && socks_proxy
  545. { Value,
  546. "socks_proxy_retry",
  547. 5,
  548. translate("Retry indefinitely on Socks proxy errors"),
  549. { client="1" } },
  550. { Value,
  551. "resolv_retry",
  552. "infinite",
  553. translate("If hostname resolve fails, retry"),
  554. { client="1" } },
  555. { ListValue,
  556. "redirect_gateway",
  557. { "", "local", "def1", "local def1" },
  558. translate("Automatically redirect default route"),
  559. { client="1" } },
  560. { Value,
  561. "verify_client_cert",
  562. { "none", "optional", "require" },
  563. translate("Specify whether the client is required to supply a valid certificate") },
  564. } },
  565. { "cryptography", translate("Cryptography"), {
  566. { FileUpload,
  567. "secret",
  568. "/etc/openvpn/secret.key",
  569. translate("Enable Static Key encryption mode (non-TLS)") },
  570. -- parse
  571. { Value,
  572. "auth",
  573. "SHA1",
  574. translate("HMAC authentication for packets") },
  575. -- parse
  576. { Value,
  577. "cipher",
  578. {
  579. "AES-128-CBC",
  580. "AES-128-CFB",
  581. "AES-128-CFB1",
  582. "AES-128-CFB8",
  583. "AES-128-GCM",
  584. "AES-128-OFB",
  585. "AES-192-CBC",
  586. "AES-192-CFB",
  587. "AES-192-CFB1",
  588. "AES-192-CFB8",
  589. "AES-192-GCM",
  590. "AES-192-OFB",
  591. "AES-256-CBC",
  592. "AES-256-CFB",
  593. "AES-256-CFB1",
  594. "AES-256-CFB8",
  595. "AES-256-GCM",
  596. "AES-256-OFB",
  597. "BF-CBC",
  598. "BF-CFB",
  599. "BF-OFB",
  600. "CAST5-CBC",
  601. "CAST5-CFB",
  602. "CAST5-OFB",
  603. "DES-CBC",
  604. "DES-CFB",
  605. "DES-CFB1",
  606. "DES-CFB8",
  607. "DES-EDE-CBC",
  608. "DES-EDE-CFB",
  609. "DES-EDE-OFB",
  610. "DES-EDE3-CBC",
  611. "DES-EDE3-CFB",
  612. "DES-EDE3-CFB1",
  613. "DES-EDE3-CFB8",
  614. "DES-EDE3-OFB",
  615. "DES-OFB",
  616. "DESX-CBC",
  617. "RC2-40-CBC",
  618. "RC2-64-CBC",
  619. "RC2-CBC",
  620. "RC2-CFB",
  621. "RC2-OFB"
  622. },
  623. translate("Encryption cipher for packets") },
  624. -- parse
  625. { Value,
  626. "keysize",
  627. 1024,
  628. translate("Size of cipher key") },
  629. -- parse
  630. { Value,
  631. "engine",
  632. "dynamic",
  633. translate("Enable OpenSSL hardware crypto engines") },
  634. { Value,
  635. "replay_window",
  636. "64 15",
  637. translate("Replay protection sliding window size") },
  638. { Flag,
  639. "mute_replay_warnings",
  640. 0,
  641. translate("Silence the output of replay warnings") },
  642. { Value,
  643. "replay_persist",
  644. "/var/run/openvpn-replay-state",
  645. translate("Persist replay-protection state") },
  646. { Flag,
  647. "tls_server",
  648. 0,
  649. translate("Enable TLS and assume server role"),
  650. { tls_client="" }, { tls_client="0" } },
  651. { Flag,
  652. "tls_client",
  653. 0,
  654. translate("Enable TLS and assume client role"),
  655. { tls_server="" }, { tls_server="0" } },
  656. { FileUpload,
  657. "ca",
  658. "/etc/easy-rsa/keys/ca.crt",
  659. translate("Certificate authority") },
  660. { FileUpload,
  661. "dh",
  662. "/etc/easy-rsa/keys/dh1024.pem",
  663. translate("Diffie-Hellman parameters") },
  664. { FileUpload,
  665. "cert",
  666. "/etc/easy-rsa/keys/some-client.crt",
  667. translate("Local certificate") },
  668. { FileUpload,
  669. "key",
  670. "/etc/easy-rsa/keys/some-client.key",
  671. translate("Local private key") },
  672. { FileUpload,
  673. "pkcs12",
  674. "/etc/easy-rsa/keys/some-client.pk12",
  675. translate("PKCS#12 file containing keys") },
  676. { ListValue,
  677. "key_method",
  678. { 1, 2 },
  679. translate("Enable TLS and assume client role") },
  680. { DynamicList,
  681. "tls_cipher",
  682. {
  683. "TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384",
  684. "TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384",
  685. "TLS-DHE-RSA-WITH-AES-256-GCM-SHA384",
  686. "TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256",
  687. "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256",
  688. "TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256",
  689. "TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256",
  690. "TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256",
  691. "TLS-DHE-RSA-WITH-AES-128-GCM-SHA256",
  692. "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384",
  693. "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384",
  694. "TLS-DHE-RSA-WITH-AES-256-CBC-SHA256",
  695. "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256",
  696. "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256",
  697. "TLS-DHE-RSA-WITH-AES-128-CBC-SHA256",
  698. "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA",
  699. "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA",
  700. "TLS-DHE-RSA-WITH-AES-256-CBC-SHA",
  701. "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA",
  702. "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA",
  703. "TLS-DHE-RSA-WITH-AES-128-CBC-SHA"
  704. },
  705. translate("TLS cipher") },
  706. { DynamicList,
  707. "tls_ciphersuites",
  708. {
  709. "TLS_AES_256_GCM_SHA384",
  710. "TLS_AES_128_GCM_SHA256",
  711. "TLS_CHACHA20_POLY1305_SHA256"
  712. },
  713. translate("TLS 1.3 or newer cipher") },
  714. { Value,
  715. "tls_timeout",
  716. 2,
  717. translate("Retransmit timeout on TLS control channel") },
  718. { Value,
  719. "reneg_bytes",
  720. 1024,
  721. translate("Renegotiate data chan. key after bytes") },
  722. { Value,
  723. "reneg_pkts",
  724. 100,
  725. translate("Renegotiate data chan. key after packets") },
  726. { Value,
  727. "reneg_sec",
  728. 3600,
  729. translate("Renegotiate data chan. key after seconds") },
  730. { Value,
  731. "hand_window",
  732. 60,
  733. translate("Timeframe for key exchange") },
  734. { Value,
  735. "tran_window",
  736. 3600,
  737. translate("Key transition window") },
  738. { Flag,
  739. "single_session",
  740. 0,
  741. translate("Allow only one session") },
  742. { Flag,
  743. "tls_exit",
  744. 0,
  745. translate("Exit on TLS negotiation failure") },
  746. { Value,
  747. "tls_auth",
  748. "/etc/openvpn/tlsauth.key",
  749. translate("Additional authentication over TLS") },
  750. { Value,
  751. "tls_crypt",
  752. "/etc/openvpn/tlscrypt.key",
  753. translate("Encrypt and authenticate all control channel packets with the key") },
  754. { Value,
  755. "tls_crypt_v2",
  756. "/etc/openvpn/servertlscryptv2.key",
  757. translate("Encrypt and authenticate all control channel packets with the key, version 2.") },
  758. -- { Value,
  759. -- "askpass",
  760. -- "[file]",
  761. -- translate("Get PEM password from controlling tty before we daemonize") },
  762. { Flag,
  763. "auth_nocache",
  764. 0,
  765. translate("Don't cache --askpass or --auth-user-pass passwords") },
  766. { Value,
  767. "tls_remote",
  768. "remote_x509_name",
  769. translate("Only accept connections from given X509 name") },
  770. { ListValue,
  771. "ns_cert_type",
  772. { "client", "server" },
  773. translate("Require explicit designation on certificate") },
  774. { ListValue,
  775. "remote_cert_tls",
  776. { "client", "server" },
  777. translate("Require explicit key usage on certificate") },
  778. { Value,
  779. "crl_verify",
  780. "/etc/easy-rsa/keys/crl.pem",
  781. translate("Check peer certificate against a CRL") },
  782. { Value,
  783. "tls_version_min",
  784. "1.0",
  785. translate("The lowest supported TLS version") },
  786. { Value,
  787. "tls_version_max",
  788. "1.2",
  789. translate("The highest supported TLS version") },
  790. { ListValue,
  791. "key_direction",
  792. { 0, 1 },
  793. translate("The key direction for 'tls-auth' and 'secret' options") },
  794. { Flag,
  795. "ncp_disable",
  796. 0,
  797. translate("This completely disables cipher negotiation") },
  798. { DynamicList,
  799. "ncp_ciphers",
  800. {
  801. "AES-256-GCM",
  802. "AES-128-GCM"
  803. },
  804. translate("Restrict the allowed ciphers to be negotiated") },
  805. { DynamicList,
  806. "data_ciphers",
  807. {
  808. "CHACHA20-POLY1305",
  809. "AES-256-GCM",
  810. "AES-128-GCM",
  811. "AES-256-CBC"
  812. },
  813. translate("Restrict the allowed ciphers to be negotiated") },
  814. } }
  815. }
  816. local cts = { }
  817. local params = { }
  818. local title = ""
  819. local m = Map("openvpn")
  820. m.redirect = luci.dispatcher.build_url("admin", "vpn", "openvpn")
  821. m.apply_on_parse = true
  822. local p = m:section( SimpleSection )
  823. p.template = "openvpn/pageswitch"
  824. p.mode = "advanced"
  825. p.instance = arg[1]
  826. p.category = arg[2] or knownParams[1][1]
  827. for _, c in ipairs(knownParams) do
  828. cts[#cts+1] = { id = c[1], title = c[2] }
  829. if c[1] == p.category then
  830. title = c[2]
  831. params = c[3]
  832. end
  833. end
  834. p.categories = cts
  835. local s = m:section(
  836. NamedSection, arg[1], "openvpn", title
  837. )
  838. s.addremove = false
  839. s.anonymous = true
  840. for _, option in ipairs(params) do
  841. local o = s:option(
  842. option[1], option[2],
  843. option[2], option[4]
  844. )
  845. o.optional = true
  846. if option[1] == DummyValue then
  847. o.value = option[3]
  848. elseif option[1] == FileUpload then
  849. o.initial_directory = "/etc/openvpn"
  850. function o.cfgvalue(self, section)
  851. local cfg_val = AbstractValue.cfgvalue(self, section)
  852. if cfg_val then
  853. return cfg_val
  854. end
  855. end
  856. function o.formvalue(self, section)
  857. local sel_val = AbstractValue.formvalue(self, section)
  858. local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox")
  859. if sel_val and sel_val ~= "" then
  860. return sel_val
  861. end
  862. if txt_val and txt_val ~= "" then
  863. return txt_val
  864. end
  865. end
  866. function o.remove(self, section)
  867. local cfg_val = AbstractValue.cfgvalue(self, section)
  868. local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox")
  869. if cfg_val and fs.access(cfg_val) and txt_val == "" then
  870. fs.unlink(cfg_val)
  871. end
  872. return AbstractValue.remove(self, section)
  873. end
  874. elseif option[1] == Flag then
  875. o.default = nil
  876. else
  877. if option[1] == DynamicList then
  878. function o.cfgvalue(...)
  879. local val = AbstractValue.cfgvalue(...)
  880. return ( val and type(val) ~= "table" ) and { val } or val
  881. end
  882. end
  883. if type(option[3]) == "table" then
  884. if o.optional then o:value("", "-- remove --") end
  885. for _, v in ipairs(option[3]) do
  886. v = tostring(v)
  887. o:value(v)
  888. end
  889. o.default = tostring(option[3][1])
  890. else
  891. o.default = tostring(option[3])
  892. end
  893. end
  894. for i=5,#option do
  895. if type(option[i]) == "table" then
  896. o:depends(option[i])
  897. end
  898. end
  899. end
  900. return m