Add PPTP runtime and GUI
[tomato.git] / release / src / router / www / vpn-pptp.asp
blob4fa2bbd307768c4b0c336a95438b01430b1d01bb
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2009 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 Portions Copyright (C) 2010-2011 Jean-Yves Avenard, jean-yves@avenard.org
9 For use with Tomato Firmware only.
10 No part of this file may be used without permission.
11 -->
12 <html>
13 <head>
14 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
15 <meta name='robots' content='noindex,nofollow'>
16 <title>[<% ident(); %>] PPTP: Client</title>
17 <link rel='stylesheet' type='text/css' href='/tomato.css'>
18 <link rel='stylesheet' type='text/css' href='/color.css'>
19 <script type='text/javascript' src='/tomato.js'></script>
21 <!-- / / / -->
23 <script type='text/javascript' src='/debug.js'></script>
25 <script type='text/javascript'>
28 // <% nvram("pptp_client_enable,pptp_client_peerdns,pptp_client_mtuenable,pptp_client_mtu,pptp_client_mruenable,pptp_client_mru,pptp_client_nat,pptp_client_srvip,pptp_client_srvsub,pptp_client_srvsubmsk,pptp_client_username,pptp_client_passwd,pptp_client_mppeopt,pptp_client_crypt,pptp_client_custom,pptp_client_dfltroute,pptp_client_stateless"); %>
30 pptpup = parseInt('<% psup("pptpclient"); %>');
32 var changed = 0;
34 function toggle(service, isup)
36 if (changed) {
37 if (!confirm("Unsaved changes will be lost. Continue anyway?")) return;
39 E('_' + service + '_button').disabled = true;
40 form.submitHidden('/service.cgi', {
41 _redirect: 'vpn-pptp.asp',
42 _service: service + (isup ? '-stop' : '-start')
43 });
46 function verifyFields(focused, quiet)
48 var ret = 1;
50 var f = E('_pptp_client_mtuenable').value == '0';
51 if (f) {
52 E('_pptp_client_mtu').value = '1450';
54 E('_pptp_client_mtu').disabled = f;
55 f = E('_pptp_client_mruenable').value == '0';
56 if (f) {
57 E('_pptp_client_mru').value = '1450';
59 E('_pptp_client_mru').disabled = f;
61 if (!v_range('_pptp_client_mtu', quiet, 576, 1500)) ret = 0;
62 if (!v_range('_pptp_client_mru', quiet, 576, 1500)) ret = 0;
63 if (!v_ip('_pptp_client_srrvip', true) && !v_domain('_pptp_client_srvip', true)) { ferror.set(E('_pptp_client_srvip'), "Invalid server address.", quiet); ret = 0; }
64 if (!v_ip('_pptp_client_srvsub', true)) { ferror.set(E('_pptp_client_srvsub'), "Invalid subnet address.", quiet); ret = 0; }
65 if (!v_ip('_pptp_client_srvsubmsk', true)) { ferror.set(E('_pptp_client_srvsubmsk'), "Invalid netmask address.", quiet); ret = 0; }
67 changed |= ret;
68 return ret;
71 function save()
73 if (!verifyFields(null, false)) return;
75 var fom = E('_fom');
77 E('pptp_client_enable').value = E('_f_pptp_client_enable').checked ? 1 : 0;
78 E('pptp_client_peerdns').value = E('_f_pptp_client_peerdns').checked ? 1 : 0;
79 E('pptp_client_nat').value = E('_f_pptp_client_nat').checked ? 1 : 0;
80 E('pptp_client_dfltroute').value = E('_f_pptp_client_dfltroute').checked ? 1 : 0;
81 E('pptp_client_stateless').value = E('_f_pptp_client_stateless').checked ? 1 : 0;
83 form.submit(fom, 1);
85 changed = 0;
87 </script>
89 <style type='text/css'>
90 textarea {
91 width: 98%;
92 height: 10em;
94 </style>
96 </head>
97 <body>
98 <form id='_fom' method='post' action='/tomato.cgi'>
99 <table id='container' cellspacing=0>
100 <tr><td colspan=2 id='header'>
101 <div class='title'>Tomato</div>
102 <div class='version'>Version <% version(); %></div>
103 </td></tr>
104 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
105 <td id='content'>
106 <div id='ident'><% ident(); %></div>
108 <!-- / / / -->
110 <input type='hidden' name='_nextpage' value='vpn-pptp.asp'>
111 <input type='hidden' name='_service' value=''>
112 <input type='hidden' name='_nextwait' value='5'>
114 <input type='hidden' id='pptp_client_enable' name='pptp_client_enable'>
115 <input type='hidden' id='pptp_client_peerdns' name='pptp_client_peerdns'>
116 <input type='hidden' id='pptp_client_nat' name='pptp_client_nat'>
117 <input type='hidden' id='pptp_client_dfltroute' name='pptp_client_dfltroute'>
118 <input type='hidden' id='pptp_client_stateless' name='pptp_client_stateless'>
120 <div class='section-title'>PPTP Client Configuration</div>
121 <div class='section'>
122 <script type='text/javascript'>
123 createFieldTable('', [
124 { title: 'Start with WAN', name: 'f_pptp_client_enable', type: 'checkbox', value: nvram.pptp_client_enable != 0 },
125 { title: 'Server Address', name: 'pptp_client_srvip', type: 'text', size: 17, value: nvram.pptp_client_srvip },
126 { title: 'Username: ', name: 'pptp_client_username', type: 'text', maxlen: 50, size: 54, value: nvram.pptp_client_username },
127 { title: 'Password: ', name: 'pptp_client_passwd', type: 'password', maxlen: 50, size: 54, value: nvram.pptp_client_passwd },
128 { title: 'Encryption', name: 'pptp_client_crypt', type: 'select', value: nvram.pptp_client_crypt,
129 options: [['0', 'Auto'],['1', 'None'],['2','Maximum (128 bit only)'],['3','Required (128 or 40 bit)']] },
130 { title: 'Stateless MPPE connection', name: 'f_pptp_client_stateless', type: 'checkbox', value: nvram.pptp_client_stateless != 0 },
131 { title: 'Redirect Internet traffic', name: 'f_pptp_client_dfltroute', type: 'checkbox', value: nvram.pptp_client_dfltroute != 0 },
132 { title: 'Accept DNS configuration', name: 'f_pptp_client_peerdns', type: 'checkbox', value: nvram.pptp_client_peerdns != 0 },
133 { title: 'Create NAT on tunnel', name: 'f_pptp_client_nat', type: 'checkbox', value: nvram.pptp_client_nat != 0 },
134 { title: 'Remote subnet / netmask', multi: [
135 { name: 'pptp_client_srvsub', type: 'text', maxlen: 15, size: 17, value: nvram.pptp_client_srvsub },
136 { name: 'pptp_client_srvsubmsk', type: 'text', maxlen: 15, size: 17, prefix: ' /&nbsp', value: nvram.pptp_client_srvsubmsk } ] },
137 { title: 'MTU', multi: [
138 { name: 'pptp_client_mtuenable', type: 'select', options: [['0', 'Default'],['1','Manual']], value: nvram.pptp_client_mtuenable },
139 { name: 'pptp_client_mtu', type: 'text', maxlen: 4, size: 6, value: nvram.pptp_client_mtu } ] },
140 { title: 'MRU', multi: [
141 { name: 'pptp_client_mruenable', type: 'select', options: [['0', 'Default'],['1','Manual']], value: nvram.pptp_client_mruenable },
142 { name: 'pptp_client_mru', type: 'text', maxlen: 4, size: 6, value: nvram.pptp_client_mru } ] },
143 { title: 'Custom Configuration', name: 'pptp_client_custom', type: 'textarea', value: nvram.pptp_client_custom }
145 W('<input type="button" value="' + (pptpup ? 'Stop' : 'Start') + ' Now" onclick="toggle(\'pptpclient\', pptpup)" id="_pptpclient_button">');
146 </script>
147 </div>
149 <!-- / / / -->
151 </td></tr>
152 <tr><td id='footer' colspan=2>
153 <span id='footer-msg'></span>
154 <input type='button' value='Save' id='save-button' onclick='save()'>
155 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
156 </td></tr>
157 </table>
158 </form>
159 <script type='text/javascript'>verifyFields(null, 1);</script>
160 </body>
161 </html>