|
@@ -0,0 +1,78 @@
|
|
1
|
+--[[
|
|
2
|
+LuCI - Lua Configuration Interface
|
|
3
|
+
|
|
4
|
+Copyright 2014 Nikos Mavrogiannopoulos <nmav@gnutls.org>
|
|
5
|
+
|
|
6
|
+Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+you may not use this file except in compliance with the License.
|
|
8
|
+You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+ http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+]]--
|
|
12
|
+
|
|
13
|
+local map, section, net = ...
|
|
14
|
+
|
|
15
|
+local server, username, password, cert, ca
|
|
16
|
+local oc_cert_file, oc_key_file, oc_ca_file
|
|
17
|
+
|
|
18
|
+local ifc = net:get_interface():name()
|
|
19
|
+
|
|
20
|
+oc_cert_file = "/etc/openconnect/user-cert-" .. ifc .. ".pem"
|
|
21
|
+oc_key_file = "/etc/openconnect/user-key-" .. ifc .. ".pem"
|
|
22
|
+oc_ca_file = "/etc/openconnect/ca-" .. ifc .. ".pem"
|
|
23
|
+
|
|
24
|
+server = section:taboption("general", Value, "server", translate("VPN Server"))
|
|
25
|
+server.datatype = "host"
|
|
26
|
+
|
|
27
|
+port = section:taboption("general", Value, "port", translate("VPN Server port"))
|
|
28
|
+port.placeholder = "443"
|
|
29
|
+port.datatype = "port"
|
|
30
|
+
|
|
31
|
+section:taboption("general", Value, "serverhash", translate("VPN Server's certificate SHA1 hash"))
|
|
32
|
+
|
|
33
|
+section:taboption("general", Value, "authgroup", translate("AuthGroup"))
|
|
34
|
+
|
|
35
|
+username = section:taboption("general", Value, "username", translate("Username"))
|
|
36
|
+password = section:taboption("general", Value, "password", translate("Password"))
|
|
37
|
+password.password = true
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+cert = section:taboption("advanced", Value, "usercert", translate("User certificate (PEM encoded)"))
|
|
41
|
+cert.template = "cbi/tvalue"
|
|
42
|
+cert.rows = 10
|
|
43
|
+
|
|
44
|
+function cert.cfgvalue(self, section)
|
|
45
|
+ return nixio.fs.readfile(oc_cert_file)
|
|
46
|
+end
|
|
47
|
+
|
|
48
|
+function cert.write(self, section, value)
|
|
49
|
+ value = value:gsub("\r\n?", "\n")
|
|
50
|
+ nixio.fs.writefile(oc_cert_file, value)
|
|
51
|
+end
|
|
52
|
+
|
|
53
|
+cert = section:taboption("advanced", Value, "userkey", translate("User key (PEM encoded)"))
|
|
54
|
+cert.template = "cbi/tvalue"
|
|
55
|
+cert.rows = 10
|
|
56
|
+
|
|
57
|
+function cert.cfgvalue(self, section)
|
|
58
|
+ return nixio.fs.readfile(oc_key_file)
|
|
59
|
+end
|
|
60
|
+
|
|
61
|
+function cert.write(self, section, value)
|
|
62
|
+ value = value:gsub("\r\n?", "\n")
|
|
63
|
+ nixio.fs.writefile(oc_key_file, value)
|
|
64
|
+end
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+ca = section:taboption("advanced", Value, "ca", translate("CA certificate; if empty it will be saved after the first connection."))
|
|
68
|
+ca.template = "cbi/tvalue"
|
|
69
|
+ca.rows = 10
|
|
70
|
+
|
|
71
|
+function ca.cfgvalue(self, section)
|
|
72
|
+ return nixio.fs.readfile(oc_ca_file)
|
|
73
|
+end
|
|
74
|
+
|
|
75
|
+function ca.write(self, section, value)
|
|
76
|
+ value = value:gsub("\r\n?", "\n")
|
|
77
|
+ nixio.fs.writefile(oc_ca_file, value)
|
|
78
|
+end
|