-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathindex.html
More file actions
157 lines (140 loc) · 4.69 KB
/
index.html
File metadata and controls
157 lines (140 loc) · 4.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>ONC File Generator</title>
<link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="style/style.css" type="text/css" />
</head>
<body>
<script>
var guid1 = guid();
var guid2 = guid();
var result = "";
function checkFields() {
if(
document.forms['oncValues'].name.value === "" ||
document.forms['oncValues'].hostname.value === "" ||
document.forms['oncValues'].port.value === "" ||
document.forms['oncValues'].username.value === "" ||
document.forms['oncValues'].X509.value === "" ||
document.forms['oncValues'].TLS.value === ""
){
alert("Please fill out all the fields");
return;
}
createResult();
}
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
function formatValue(value,type){
if (type === "X509") {
var result = value.replace(/^.*#.*$\n/mg, "");
result = result.replace(/^.*-.*$/mg, "");
result = result.replace(/(\r\n|\n|\r)/gm,"");
return result
}else if (type === "TLS"){
var result = value.replace(/^.*#.*$\n/mg, "");
result = result.replace(/(?:\r\n|\r|\n)/g,"\\n");
return result
}
}
function createResult(){
result =
`{
"Type":"UnencryptedConfiguration",
"Certificates": [ {
"GUID": "{${guid1}}",
"Type": "Authority",
"X509": "${formatValue(document.forms['oncValues'].X509.value,"X509")}"
} ],
"NetworkConfigurations": [ {
"GUID": "{${guid2}}",
"Name": "${document.forms['oncValues'].name.value}",
"Type": "VPN",
"VPN": {
"Type": "OpenVPN",
"Host": "${document.forms['oncValues'].hostname.value}",
"OpenVPN": {
"ServerCARef": "{${guid1}}",
"AuthRetry": "interact",
"ClientCertType": "Pattern",
"ClientCertPattern": {
"IssuerCARef": [ "{${guid1}}" ]
},
"CompLZO": "true",
"Port": ${document.forms['oncValues'].port.value},
"Proto": "udp",
"RemoteCertTLS":"server",
"RemoteCertEKU": "TLS Web Server Authentication",
"SaveCredentials": false,
"ServerPollTimeout": 10,
"Username": "${document.forms['oncValues'].username.value}",
"KeyDirection":"1",
"TLSAuthContents":"${formatValue(document.forms['oncValues'].TLS.value,"TLS")}"
}
}
} ]
}`;
download(document.forms['oncValues'].name.value+".onc",result)
}
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
pom.setAttribute('download', filename);
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
pom.dispatchEvent(event);
}
else {
pom.click();
}
}
</script>
<div id="mainContent">
<h1>ONC File Generator</h1>
<p>This page main goal is to generate an ONC file that can be used to import an OpenVPN connection in ChromeOS</p>
<br />
<br />
<form name="oncValues">
<label for="name">Name of the connection</label>
<input type="text" name="name"/>
<br />
<br />
<label for="hostname">Hostname/IP</label>
<input type="text" name="hostname"/>
<br />
<br />
<label for="port">Port</label>
<input type="text" name="port"/>
<br />
<br />
<label for="username">Username</label>
<input type="text" name="username"/>
<br />
<br />
<label for="X509">Content of your CA.crt</label>
<textarea name="X509" rows="25" cols="50"></textarea>
<br />
<br />
<label for="TLS">Content of your TLS auth key</label>
<textarea name="TLS" rows="25" cols="50"></textarea>
<br />
<br />
<input type="button" onclick="checkFields()" value="Generate File"/>
</form>
<br />
<br />
<p>Thanks to the fine gentleman who made the tutorial <a href="https://docs.google.com/document/d/18TU22gueH5OKYHZVJ5nXuqHnk2GN6nDvfu2Hbrb4YLE/pub">here</a></p>
<p><a href="https://github.com/Quack6765/oncgenerator">GitHub</a></p>
</div>
</body>
</html>