Add PPTP VPN client runtime and GUI
[tomato.git] / release / src / router / www / vpn-pptp.asp
bloba19b95449b473b0dc6505b7b717f436db49efa87
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 elem.display(PR('_pptp_client_srvsub'), PR('_pptp_client_srvsubmsk'), !E('_f_pptp_client_dfltroute').checked);
52 var f = E('_pptp_client_mtuenable').value == '0';
53 if (f) {
54 E('_pptp_client_mtu').value = '1450';
56 E('_pptp_client_mtu').disabled = f;
57 f = E('_pptp_client_mruenable').value == '0';
58 if (f) {
59 E('_pptp_client_mru').value = '1450';
61 E('_pptp_client_mru').disabled = f;
63 if (!v_range('_pptp_client_mtu', quiet, 576, 1500)) ret = 0;
64 if (!v_range('_pptp_client_mru', quiet, 576, 1500)) ret = 0;
65 if (!v_ip('_pptp_client_srvip', true) && !v_domain('_pptp_client_srvip', true)) { ferror.set(E('_pptp_client_srvip'), "Invalid server address.", quiet); ret = 0; }
66 if (!E('_f_pptp_client_dfltroute').checked && !v_ip('_pptp_client_srvsub', true)) { ferror.set(E('_pptp_client_srvsub'), "Invalid subnet address.", quiet); ret = 0; }
67 if (!E('_f_pptp_client_dfltroute').checked && !v_ip('_pptp_client_srvsubmsk', true)) { ferror.set(E('_pptp_client_srvsubmsk'), "Invalid netmask address.", quiet); ret = 0; }
69 changed |= ret;
70 return ret;
73 function save()
75 if (!verifyFields(null, false)) return;
77 var fom = E('_fom');
79 E('pptp_client_enable').value = E('_f_pptp_client_enable').checked ? 1 : 0;
80 E('pptp_client_nat').value = E('_f_pptp_client_nat').checked ? 1 : 0;
81 E('pptp_client_dfltroute').value = E('_f_pptp_client_dfltroute').checked ? 1 : 0;
82 E('pptp_client_stateless').value = E('_f_pptp_client_stateless').checked ? 1 : 0;
84 form.submit(fom, 1);
86 changed = 0;
88 </script>
90 <style type='text/css'>
91 textarea {
92 width: 98%;
93 height: 10em;
95 </style>
97 </head>
98 <body>
99 <form id='_fom' method='post' action='/tomato.cgi'>
100 <table id='container' cellspacing=0>
101 <tr><td colspan=2 id='header'>
102 <div class='title'>Tomato</div>
103 <div class='version'>Version <% version(); %></div>
104 </td></tr>
105 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
106 <td id='content'>
107 <div id='ident'><% ident(); %></div>
109 <!-- / / / -->
111 <input type='hidden' name='_nextpage' value='vpn-pptp.asp'>
112 <input type='hidden' name='_service' value=''>
113 <input type='hidden' name='_nextwait' value='5'>
115 <input type='hidden' id='pptp_client_enable' name='pptp_client_enable'>
116 <input type='hidden' id='pptp_client_peerdns' name='pptp_client_peerdns'>
117 <input type='hidden' id='pptp_client_nat' name='pptp_client_nat'>
118 <input type='hidden' id='pptp_client_dfltroute' name='pptp_client_dfltroute'>
119 <input type='hidden' id='pptp_client_stateless' name='pptp_client_stateless'>
121 <div class='section-title'>PPTP Client Configuration</div>
122 <div class='section'>
123 <script type='text/javascript'>
124 createFieldTable('', [
125 { title: 'Start with WAN', name: 'f_pptp_client_enable', type: 'checkbox', value: nvram.pptp_client_enable != 0 },
126 { title: 'Server Address', name: 'pptp_client_srvip', type: 'text', size: 17, value: nvram.pptp_client_srvip },
127 { title: 'Username: ', name: 'pptp_client_username', type: 'text', maxlen: 50, size: 54, value: nvram.pptp_client_username },
128 { title: 'Password: ', name: 'pptp_client_passwd', type: 'password', maxlen: 50, size: 54, value: nvram.pptp_client_passwd },
129 { title: 'Encryption', name: 'pptp_client_crypt', type: 'select', value: nvram.pptp_client_crypt,
130 options: [['0', 'Auto'],['1', 'None'],['2','Maximum (128 bit only)'],['3','Required (128 or 40 bit)']] },
131 { title: 'Stateless MPPE connection', name: 'f_pptp_client_stateless', type: 'checkbox', value: nvram.pptp_client_stateless != 0 },
132 { title: 'Accept DNS configuration', name: 'pptp_client_peerdns', type: 'select', options: [[0, 'Disabled'],[1, 'Yes'],[2, 'Exclusive']], value: nvram.pptp_client_peerdns },
133 { title: 'Redirect Internet traffic', name: 'f_pptp_client_dfltroute', type: 'checkbox', value: nvram.pptp_client_dfltroute != 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: 'Create NAT on tunnel', name: 'f_pptp_client_nat', type: 'checkbox', value: nvram.pptp_client_nat != 0 },
138 { title: 'MTU', multi: [
139 { name: 'pptp_client_mtuenable', type: 'select', options: [['0', 'Default'],['1','Manual']], value: nvram.pptp_client_mtuenable },
140 { name: 'pptp_client_mtu', type: 'text', maxlen: 4, size: 6, value: nvram.pptp_client_mtu } ] },
141 { title: 'MRU', multi: [
142 { name: 'pptp_client_mruenable', type: 'select', options: [['0', 'Default'],['1','Manual']], value: nvram.pptp_client_mruenable },
143 { name: 'pptp_client_mru', type: 'text', maxlen: 4, size: 6, value: nvram.pptp_client_mru } ] },
144 { title: 'Custom Configuration', name: 'pptp_client_custom', type: 'textarea', value: nvram.pptp_client_custom }
146 W('<input type="button" value="' + (pptpup ? 'Stop' : 'Start') + ' Now" onclick="toggle(\'pptpclient\', pptpup)" id="_pptpclient_button">');
147 </script>
148 </div>
150 <!-- / / / -->
152 </td></tr>
153 <tr><td id='footer' colspan=2>
154 <span id='footer-msg'></span>
155 <input type='button' value='Save' id='save-button' onclick='save()'>
156 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
157 </td></tr>
158 </table>
159 </form>
160 <script type='text/javascript'>verifyFields(null, 1);</script>
161 </body>
162 </html>