]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/ovpnmain.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
23 use CGI qw
/:standard/ ;
27 use File
:: Temp qw
/ tempfile tempdir / ;
29 use Archive
:: Zip
qw(:ERROR_CODES :CONSTANTS) ;
30 require '/var/ipfire/general-functions.pl' ;
31 require "${General::swroot}/lang.pl" ;
32 require "${General::swroot}/header.pl" ;
33 require "${General::swroot}/countries.pl" ;
35 # enable only the following on debugging purpose
37 use CGI
:: Carp
'fatalsToBrowser' ;
38 #workaround to suppress a warning when a variable is used only once
39 my @dummy = ( ${ Header
:: colourgreen
} );
43 my %mainsettings = ();
44 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
45 & General
:: readhash
( "/srv/web/ipfire/html/themes/" . $mainsettings { 'THEME' }. "/include/colors.txt" , \
%color );
48 ### Initialize variables
58 my $errormessage = '' ;
60 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
61 $cgiparams { 'ENABLED' } = 'off' ;
62 $cgiparams { 'ENABLED_BLUE' } = 'off' ;
63 $cgiparams { 'ENABLED_ORANGE' } = 'off' ;
64 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
65 $cgiparams { 'NAT' } = 'off' ;
66 $cgiparams { 'COMPRESSION' } = 'off' ;
67 $cgiparams { 'ONLY_PROPOSED' } = 'off' ;
68 $cgiparams { 'ACTION' } = '' ;
69 $cgiparams { 'CA_NAME' } = '' ;
70 $cgiparams { 'DHCP_DOMAIN' } = '' ;
71 $cgiparams { 'DHCP_DNS' } = '' ;
72 $cgiparams { 'DHCP_WINS' } = '' ;
73 $cgiparams { 'DCOMPLZO' } = 'off' ;
74 $cgiparams { 'MSSFIX' } = '' ;
77 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
79 # prepare openvpn config file
85 if ( $netsettings { 'CONFIG_TYPE' } == 2 ) { return 1 ;}
86 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
92 if ( $netsettings { 'CONFIG_TYPE' } == 3 ) { return 1 ;}
93 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
101 while ( abs ( $bytesize ) >= 1024 ){
102 $bytesize = $bytesize / 1024 ;
107 my @units = ( "Bytes" , "KB" , "MB" , "GB" , "TB" , "PB" , "EB" );
108 my $newsize =( int ( $bytesize * 100 + 0.5 ))/ 100 ;
109 return ( " $newsize $units [ $i ]" );
113 my $hostname = $_ [ 0 ];
114 unless ( $hostname ) { return "No hostname" };
115 my $res = new Net
:: DNS
:: Resolver
;
116 my $query = $res -> search ( " $hostname " );
118 foreach my $rr ( $query -> answer ) {
119 ## Potential bug - we are only looking at A records:
120 return 0 if $rr -> type eq "A" ;
123 return $res -> errorstring ;
129 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/serial" )) {
133 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/index.txt" )) {
137 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
138 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
139 unlink ( "${General::swroot}/ovpn/certs/01.pem" );
142 sub newcleanssldatabase
144 if (! - s
"${General::swroot}/ovpn/certs/serial" ) {
145 open ( FILE
, ">${General::swroot}(ovpn/certs/serial" );
149 if (! - s
">${General::swroot}/ovpn/certs/index.txt" ) {
150 system ( "touch ${General::swroot}/ovpn/certs/index.txt" );
152 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
153 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
158 if ( open ( FILE
, "${General::swroot}/ovpn/certs/serial.old" )) {
159 my $hexvalue = < FILE
>;
162 unlink ( "${General::swroot}/ovpn/certs/ $hexvalue .pem" );
167 my $KEY2 = $_ [ 0 ]; # key2
168 my $SRC_PORT = $_ [ 1 ]; # src_port
169 my $PROTOCOL = $_ [ 2 ]; # protocol
170 my $SRC_IP = $_ [ 3 ]; # sourceip
172 my $pfwfilename = "${General::swroot}/portfw/config" ;
173 open ( FILE
, $pfwfilename ) or die 'Unable to open config file.' ;
174 my @pfwcurrent = < FILE
>;
176 my $pfwkey1 = 0 ; # used for finding last sequence number used
177 foreach my $pfwline ( @pfwcurrent )
179 my @pfwtemp = split ( /\,/ , $pfwline );
182 if ( $KEY2 eq "0" ){ # if key2 is 0 then it is a portfw addition
183 if ( $SRC_PORT eq $pfwtemp [ 3 ] &&
184 $PROTOCOL eq $pfwtemp [ 2 ] &&
185 $SRC_IP eq $pfwtemp [ 7 ])
187 $errormessage = " $Lang ::tr{'source port in use'} $SRC_PORT " ;
189 # Check if key2 = 0, if it is then it is a port forward entry and we want the sequence number
190 if ( $pfwtemp [ 1 ] eq "0" ) {
191 $pfwkey1 = $pfwtemp [ 0 ];
193 # Darren Critchley - Duplicate or overlapping Port range check
194 if ( $pfwtemp [ 1 ] eq "0" &&
195 $PROTOCOL eq $pfwtemp [ 2 ] &&
196 $SRC_IP eq $pfwtemp [ 7 ] &&
199 & portchecks
( $SRC_PORT , $pfwtemp [ 5 ]);
200 # &portchecks($pfwtemp[3], $pfwtemp[5]);
201 # &portchecks($pfwtemp[3], $SRC_IP);
205 # $errormessage="$KEY2 $SRC_PORT $PROTOCOL $SRC_IP";
212 my $portrange1 = $_ [ 0 ]; # New port range
213 my $portrange2 = $_ [ 1 ]; # existing port range
214 my @tempr1 = split ( /\:/ , $portrange1 );
215 my @tempr2 = split ( /\:/ , $portrange2 );
217 unless (& checkportinc
( $tempr1 [ 0 ], $portrange2 )){ return 0 ;}
218 unless (& checkportinc
( $tempr1 [ 1 ], $portrange2 )){ return 0 ;}
220 unless (& checkportinc
( $tempr2 [ 0 ], $portrange1 )){ return 0 ;}
221 unless (& checkportinc
( $tempr2 [ 1 ], $portrange1 )){ return 0 ;}
223 return 1 ; # Everything checks out!
226 # Darren Critchley - we want to make sure that a port entry is not within an already existing range
229 my $port1 = $_ [ 0 ]; # Port
230 my $portrange2 = $_ [ 1 ]; # Port range
231 my @tempr1 = split ( /\:/ , $portrange2 );
233 if ( $port1 < $tempr1 [ 0 ] || $port1 > $tempr1 [ 1 ]) {
239 # Darren Critchley - Duplicate or overlapping Port range check
242 my $p1 = $_ [ 0 ]; # New port range
243 my $p2 = $_ [ 1 ]; # existing port range
245 our ( $prtrange1 , $prtrange2 );
247 # if (m/:/ && $prtrange1 == 1) { # comparing two port ranges
248 # unless (&checkportoverlap($p1,$p2)) {
249 # $errormessage = "$Lang::tr{'source port overlaps'} $p1";
252 if ( m/:/ && $prtrange1 == 0 && $errormessage eq '' ) { # compare one port to a range
253 unless (& checkportinc
( $p2 , $p1 )) {
254 $errormessage = " $Lang ::tr{'srcprt within existing'} $p1 " ;
258 if (! m/:/ && $prtrange1 == 1 && $errormessage eq '' ) { # compare one port to a range
259 unless (& checkportinc
( $p1 , $p2 )) {
260 $errormessage = " $Lang ::tr{'srcprt range overlaps'} $p2 " ;
266 # Darren Critchley - certain ports are reserved for IPFire
267 # TCP 67,68,81,222,445
269 # Params passed in -> port, rangeyn, protocol
272 # port 67 and 68 same for tcp and udp, don't bother putting in an array
274 my @tcp_reserved = ( 81 , 222 , 445 );
275 my $prt = $_ [ 0 ]; # the port or range
276 my $ryn = $_ [ 1 ]; # tells us whether or not it is a port range
277 my $prot = $_ [ 2 ]; # protocol
278 my $srcdst = $_ [ 3 ]; # source or destination
279 if ( $ryn ) { # disect port range
280 if ( $srcdst eq "src" ) {
281 $msg = " $Lang ::tr{'rsvd src port overlap'}" ;
283 $msg = " $Lang ::tr{'rsvd dst port overlap'}" ;
285 my @tmprng = split ( /\:/ , $prt );
286 unless ( 67 < $tmprng [ 0 ] || 67 > $tmprng [ 1 ]) { $errormessage = " $msg 67" ; return ; }
287 unless ( 68 < $tmprng [ 0 ] || 68 > $tmprng [ 1 ]) { $errormessage = " $msg 68" ; return ; }
288 if ( $prot eq "tcp" ) {
289 foreach my $prange ( @tcp_reserved ) {
290 unless ( $prange < $tmprng [ 0 ] || $prange > $tmprng [ 1 ]) { $errormessage = " $msg $prange " ; return ; }
294 if ( $srcdst eq "src" ) {
295 $msg = " $Lang ::tr{'reserved src port'}" ;
297 $msg = " $Lang ::tr{'reserved dst port'}" ;
299 if ( $prt == 67 ) { $errormessage = " $msg 67" ; return ; }
300 if ( $prt == 68 ) { $errormessage = " $msg 68" ; return ; }
301 if ( $prot eq "tcp" ) {
302 foreach my $prange ( @tcp_reserved ) {
303 if ( $prange == $prt ) { $errormessage = " $msg $prange " ; return ; }
310 sub writeserverconf
{
311 my %sovpnsettings = ();
312 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%sovpnsettings );
314 open ( CONF
, ">${General::swroot}/ovpn/server.conf" ) or die "Unable to open ${General::swroot}/ovpn/server.conf: $!" ;
316 print CONF
"#OpenVPN Server conf \n " ;
318 print CONF
"daemon openvpnserver \n " ;
319 print CONF
"writepid /var/run/openvpn.pid \n " ;
320 print CONF
"#DAN prepare OpenVPN for listening on blue and orange \n " ;
321 print CONF
";local $sovpnsettings {'VPN_IP'} \n " ;
322 print CONF
"dev $sovpnsettings {'DDEVICE'} \n " ;
323 print CONF
" $sovpnsettings {'DDEVICE'}-mtu $sovpnsettings {'DMTU'} \n " ;
324 print CONF
"proto $sovpnsettings {'DPROTOCOL'} \n " ;
325 print CONF
"port $sovpnsettings {'DDEST_PORT'} \n " ;
326 print CONF
"script-security 3 system \n " ;
327 print CONF
"ifconfig-pool-persist /var/ipfire/ovpn/ovpn-leases.db 3600 \n " ;
328 print CONF
"tls-server \n " ;
329 print CONF
"ca /var/ipfire/ovpn/ca/cacert.pem \n " ;
330 print CONF
"cert /var/ipfire/ovpn/certs/servercert.pem \n " ;
331 print CONF
"key /var/ipfire/ovpn/certs/serverkey.pem \n " ;
332 print CONF
"dh /var/ipfire/ovpn/ca/dh1024.pem \n " ;
333 my @tempovpnsubnet = split ( "\/" , $sovpnsettings { 'DOVPN_SUBNET' });
334 print CONF
"server $tempovpnsubnet [0] $tempovpnsubnet [1] \n " ;
335 print CONF
"push \" route $netsettings {'GREEN_NETADDRESS'} $netsettings {'GREEN_NETMASK'} \"\n " ;
336 if ( $sovpnsettings { CLIENT2CLIENT
} eq 'on' ) {
337 print CONF
"client-to-client \n " ;
339 if ( $sovpnsettings { MSSFIX
} eq 'on' ) {
340 print CONF
"mssfix \n " ;
342 if ( $sovpnsettings { FRAGMENT
} ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' ) {
343 print CONF
"fragment $sovpnsettings {'FRAGMENT'} \n " ;
345 if ( $sovpnsettings { KEEPALIVE_1
} > 0 && $sovpnsettings { KEEPALIVE_2
} > 0 ) {
346 print CONF
"keepalive $sovpnsettings {'KEEPALIVE_1'} $sovpnsettings {'KEEPALIVE_2'} \n " ;
348 print CONF
"status-version 1 \n " ;
349 print CONF
"status /var/log/ovpnserver.log 30 \n " ;
350 print CONF
"cipher $sovpnsettings {DCIPHER} \n " ;
351 if ( $sovpnsettings { DCOMPLZO
} eq 'on' ) {
352 print CONF
"comp-lzo \n " ;
354 if ( $sovpnsettings { REDIRECT_GW_DEF1
} eq 'on' ) {
355 print CONF
"push \" redirect-gateway def1 \"\n " ;
357 if ( $sovpnsettings { DHCP_DOMAIN
} ne '' ) {
358 print CONF
"push \" dhcp-option DOMAIN $sovpnsettings {DHCP_DOMAIN} \"\n " ;
361 if ( $sovpnsettings { DHCP_DNS
} ne '' ) {
362 print CONF
"push \" dhcp-option DNS $sovpnsettings {DHCP_DNS} \"\n " ;
365 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
366 print CONF
"push \" dhcp-option WINS $sovpnsettings {DHCP_WINS} \"\n " ;
369 if ( $sovpnsettings { DHCP_WINS
} eq '' ) {
370 print CONF
"max-clients 100 \n " ;
372 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
373 print CONF
"max-clients $sovpnsettings {MAX_CLIENTS} \n " ;
375 print CONF
"tls-verify /var/ipfire/ovpn/verify \n " ;
376 print CONF
"crl-verify /var/ipfire/ovpn/crls/cacrl.pem \n " ;
377 print CONF
"user nobody \n " ;
378 print CONF
"group nobody \n " ;
379 print CONF
"persist-key \n " ;
380 print CONF
"persist-tun \n " ;
381 if ( $sovpnsettings { LOG_VERB
} ne '' ) {
382 print CONF
"verb $sovpnsettings {LOG_VERB} \n " ;
384 print CONF
"verb 3 \n " ;
392 if ( open ( FILE
, ">/var/log/ovpnserver.log" )) {
400 #hier die refresh page
401 if ( - e
"${General::swroot}/ovpn/gencanow" ) {
403 $refresh = "<meta http-equiv='refresh' content='15;' />" ;
404 & Header
:: showhttpheaders
();
405 & Header
:: openpage
( $Lang :: tr
{ 'OVPN' }, 1 , $refresh );
406 & Header
:: openbigbox
( '100%' , 'center' );
407 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
408 print "<tr> \n <td align='center'><img src='/images/clock.gif' alt='' /></td> \n " ;
409 print "<td colspan='2'><font color='red'>Please be patient this realy can take some time on older hardware...</font></td></tr> \n " ;
411 & Header
:: closebigbox
();
412 & Header
:: closepage
();
415 ##hier die refresh page
419 ### OpenVPN Server Control
421 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' } ||
422 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' } ||
423 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart ovpn server' }) {
424 #start openvpn server
425 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' }){
427 system ( '/usr/local/bin/openvpnctrl' , '-s' );
430 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' }){
431 system ( '/usr/local/bin/openvpnctrl' , '-k' );
434 # #restart openvpn server
435 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart ovpn server' }){
436 #workarund, till SIGHUP also works when running as nobody
437 system ( '/usr/local/bin/openvpnctrl' , '-r' );
443 ### Save Advanced options
446 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save-adv-options' }) {
447 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
448 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
449 #DAN this value has to leave.
450 #new settings for daemon
451 $vpnsettings { 'LOG_VERB' } = $cgiparams { 'LOG_VERB' };
452 $vpnsettings { 'KEEPALIVE_1' } = $cgiparams { 'KEEPALIVE_1' };
453 $vpnsettings { 'KEEPALIVE_2' } = $cgiparams { 'KEEPALIVE_2' };
454 $vpnsettings { 'MAX_CLIENTS' } = $cgiparams { 'MAX_CLIENTS' };
455 $vpnsettings { 'REDIRECT_GW_DEF1' } = $cgiparams { 'REDIRECT_GW_DEF1' };
456 $vpnsettings { 'CLIENT2CLIENT' } = $cgiparams { 'CLIENT2CLIENT' };
457 $vpnsettings { 'DHCP_DOMAIN' } = $cgiparams { 'DHCP_DOMAIN' };
458 $vpnsettings { 'DHCP_DNS' } = $cgiparams { 'DHCP_DNS' };
459 $vpnsettings { 'DHCP_WINS' } = $cgiparams { 'DHCP_WINS' };
461 if ( $cgiparams { 'FRAGMENT' } eq '' ) {
462 delete $vpnsettings { 'FRAGMENT' };
464 if ( $cgiparams { 'FRAGMENT' } !~ /^[0-9]+$/ ) {
465 $errormessage = "Incorrect value, please insert only numbers." ;
468 $vpnsettings { 'FRAGMENT' } = $cgiparams { 'FRAGMENT' };
471 if ( $cgiparams { 'MSSFIX' } ne 'on' ) {
472 delete $vpnsettings { 'MSSFIX' };
474 $vpnsettings { 'MSSFIX' } = $cgiparams { 'MSSFIX' };
476 if ( $cgiparams { 'DHCP_DOMAIN' } ne '' ){
477 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_DOMAIN' }) || & General
:: validip
( $cgiparams { 'DHCP_DOMAIN' })) {
478 $errormessage = $Lang :: tr
{ 'invalid input for dhcp domain' };
482 if ( $cgiparams { 'DHCP_DNS' } ne '' ){
483 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_DNS' }) || & General
:: validip
( $cgiparams { 'DHCP_DNS' })) {
484 $errormessage = $Lang :: tr
{ 'invalid input for dhcp dns' };
488 if ( $cgiparams { 'DHCP_WINS' } ne '' ){
489 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_WINS' }) || & General
:: validip
( $cgiparams { 'DHCP_WINS' })) {
490 $errormessage = $Lang :: tr
{ 'invalid input for dhcp wins' };
494 if (( length ( $cgiparams { 'MAX_CLIENTS' }) == 0 ) || (( $cgiparams { 'MAX_CLIENTS' }) < 1 ) || (( $cgiparams { 'MAX_CLIENTS' }) > 255 )) {
495 $errormessage = $Lang :: tr
{ 'invalid input for max clients' };
498 if ( $cgiparams { 'KEEPALIVE_1' } ne '' ) {
499 if ( $cgiparams { 'KEEPALIVE_1' } !~ /^[0-9]+$/ ) {
500 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1' };
504 if ( $cgiparams { 'KEEPALIVE_2' } ne '' ){
505 if ( $cgiparams { 'KEEPALIVE_2' } !~ /^[0-9]+$/ ) {
506 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 2' };
510 if ( $cgiparams { 'KEEPALIVE_2' } < ( $cgiparams { 'KEEPALIVE_1' } * 2 )){
511 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1:2' };
515 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
516 & writeserverconf
(); #hier ok
520 # m.a.d Save net2net server config
523 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'server' )
526 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
527 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
528 my $ovsubnet = " @ovsubnettemp [0]. @ovsubnettemp [1]. @ovsubnettemp [2]" ;
529 my $tunmtu = $cgiparams { 'MTU' };
530 if ( $tunmtu eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
532 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
533 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
535 open ( SERVERCONF
, ">${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Unable to open ${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf: $!" ;
538 print SERVERCONF
"# n2n Open VPN Server Config by ummeegge und m.a.d \n " ;
539 print SERVERCONF
" \n " ;
540 print SERVERCONF
"# User Sicherheit \n " ;
541 print SERVERCONF
"user nobody \n " ;
542 print SERVERCONF
"group nobody \n " ;
543 print SERVERCONF
"persist-tun \n " ;
544 print SERVERCONF
"persist-key \n " ;
545 print SERVERCONF
" \n " ;
546 print SERVERCONF
"# IP/DNS fuer das Server Gateway - g2g Mode \n " ;
547 print SERVERCONF
"remote $cgiparams {'REMOTE'} \n " ;
548 print SERVERCONF
" \n " ;
549 print SERVERCONF
"# IP Adressen des VPN Tunnels \n " ;
550 print SERVERCONF
"ifconfig $ovsubnet .1 $ovsubnet .2 \n " ;
551 print SERVERCONF
" \n " ;
552 print SERVERCONF
"# Netzwerk auf dem Client Gateway \n " ;
553 print SERVERCONF
"route @remsubnet [0] @remsubnet [1] \n " ;
554 print SERVERCONF
"# Device fuer den Tunnel \n " ;
555 print SERVERCONF
"dev tun \n " ;
556 print SERVERCONF
" \n " ;
557 print SERVERCONF
"#Port und Protokoll \n " ;
558 print SERVERCONF
"port $cgiparams {'DEST_PORT'} \n " ;
559 print SERVERCONF
"proto $cgiparams {'PROTOCOL'} \n " ;
560 print SERVERCONF
" \n " ;
561 print SERVERCONF
"# Paketgroessen \n " ;
562 print SERVERCONF
"tun-mtu $tunmtu \n " ;
563 print SERVERCONF
"fragment 1300 \n " ;
564 print SERVERCONF
"mssfix \n " ;
565 print SERVERCONF
" \n " ;
566 print SERVERCONF
"# Auth Server \n " ;
567 print SERVERCONF
"tls-server \n " ;
568 print SERVERCONF
"ca ${General::swroot}/ovpn/ca/cacert.pem \n " ;
569 print SERVERCONF
"cert ${General::swroot}/ovpn/certs/servercert.pem \n " ;
570 print SERVERCONF
"key ${General::swroot}/ovpn/certs/serverkey.pem \n " ;
571 print SERVERCONF
"dh ${General::swroot}/ovpn/ca/dh1024.pem \n " ;
572 print SERVERCONF
" \n " ;
573 print SERVERCONF
"# Verschluesselung \n " ;
574 print SERVERCONF
"cipher AES-256-CBC \n " ;
575 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
576 print SERVERCONF
"# Kompression einschalten \n " ;
577 print SERVERCONF
"comp-lzo \r\n " ;
578 print SERVERCONF
"# \n " ;
580 print SERVERCONF
"# Debug Level setzen \n " ;
581 print SERVERCONF
"verb 3 \n " ;
582 print SERVERCONF
" \n " ;
583 print SERVERCONF
"# Tunnel Ueberwachung \n " ;
584 print SERVERCONF
"keepalive 10 60 \n " ;
585 print SERVERCONF
" \n " ;
586 print SERVERCONF
"# Als Daemon starten mit Namen ovpnn2n \n " ;
587 print SERVERCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
588 print SERVERCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
589 print SERVERCONF
" \n " ;
590 print SERVERCONF
"# Management Interface aktivieren \n " ;
591 print SERVERCONF
"#management localhost 4711 \n " ;
597 # m.a.d Save net2net client config
599 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'client' )
601 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
602 my $ovsubnet = " @ovsubnettemp [0]. @ovsubnettemp [1]. @ovsubnettemp [2]" ;
603 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
604 my $tunmtu = $cgiparams { 'MTU' };
605 if ( $tunmtu eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
607 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
608 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
610 open ( CLIENTCONF
, ">${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Unable to open ${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf: $!" ;
613 print CLIENTCONF
"# rewritten n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
614 print CLIENTCONF
"# \n " ;
615 print CLIENTCONF
"# User Sicherheit \n " ;
616 print CLIENTCONF
"user nobody \n " ;
617 print CLIENTCONF
"group nobody \n " ;
618 print CLIENTCONF
"persist-tun \n " ;
619 print CLIENTCONF
"persist-key \n " ;
620 print CLIENTCONF
"# \n " ;
621 print CLIENTCONF
"# IP/DNS fuer das Server Gateway - g2g Mode \n " ;
622 print CLIENTCONF
"remote $cgiparams {'REMOTE'} \n " ;
623 print CLIENTCONF
"# \n " ;
624 print CLIENTCONF
"# IP Adressen des VPN Tunnels \n " ;
625 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
626 print CLIENTCONF
"# \n " ;
627 print CLIENTCONF
"# Netzwerk auf dem Server Gateway \n " ;
628 print CLIENTCONF
"route @remsubnet [0]/ @remsubnet [1] \n " ;
629 print CLIENTCONF
"# Device fuer den Tunnel \n " ;
630 print CLIENTCONF
"dev tun \n " ;
631 print CLIENTCONF
"# \n " ;
632 print CLIENTCONF
"#Port und Protokoll \n " ;
633 print CLIENTCONF
"port $cgiparams {'DEST_PORT'} \n " ;
634 print CLIENTCONF
"proto $cgiparams {'PROTOCOL'} \n " ;
635 print CLIENTCONF
"# \n " ;
636 print CLIENTCONF
"# Paketgroessen \n " ;
637 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
638 print CLIENTCONF
"fragment 1300 \n " ;
639 print CLIENTCONF
"mssfix \n " ;
640 print CLIENTCONF
"# \n " ;
641 print CLIENTCONF
"# Auth. Client \n " ;
642 print CLIENTCONF
"tls-client \n " ;
643 print CLIENTCONF
"# \n " ;
644 print CLIENTCONF
"# Verschluesselung \n " ;
645 print CLIENTCONF
"cipher AES-256-CBC \n " ;
646 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12 \r\n " ;
647 print CLIENTCONF
"# \n " ;
648 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
649 print CLIENTCONF
"# Kompression einschalten \n " ;
650 print CLIENTCONF
"comp-lzo \r\n " ;
651 print CLIENTCONF
"# \n " ;
653 print CLIENTCONF
"# \n " ;
654 print CLIENTCONF
"# Debug Level \n " ;
655 print CLIENTCONF
"verb 3 \n " ;
656 print CLIENTCONF
"# \n " ;
657 print CLIENTCONF
"# Tunnel Ueberwachung \n " ;
658 print CLIENTCONF
"keepalive 10 60 \n " ;
659 print CLIENTCONF
"# \n " ;
660 print CLIENTCONF
"# Als Daemon starten \n " ;
661 print CLIENTCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
662 print CLIENTCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
663 print CLIENTCONF
"# \n " ;
664 print CLIENTCONF
"# Management Interface aktivieren \n " ;
665 print CLIENTCONF
"# management localhost 4711 \n " ;
671 # m.a.d Save net2net config end
675 ### Save main settings
679 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
680 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
681 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
682 #DAN this value has to leave.
683 if ( $cgiparams { 'ENABLED' } eq 'on' ){
684 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })) {
685 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
689 if ( $cgiparams { 'ENABLED' } eq 'on' ){
690 & disallowreserved
( $cgiparams { 'DDEST_PORT' }, 0 , $cgiparams { 'DPROTOCOL' }, "dest" );
692 if ( $errormessage ) { goto SETTINGS_ERROR
; }
695 if ( $cgiparams { 'ENABLED' } eq 'on' ){
696 & checkportfw
( 0 , $cgiparams { 'DDEST_PORT' }, $cgiparams { 'DPROTOCOL' }, '0.0.0.0' );
699 if ( $errormessage ) { goto SETTINGS_ERROR
; }
701 if (! & General
:: validipandmask
( $cgiparams { 'DOVPN_SUBNET' })) {
702 $errormessage = $Lang :: tr
{ 'ovpn subnet is invalid' };
705 my @tmpovpnsubnet = split ( "\/" , $cgiparams { 'DOVPN_SUBNET' });
707 if (& General
:: IpInSubnet
( $netsettings { 'RED_ADDRESS' },
708 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
709 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire RED Network $netsettings {'RED_ADDRESS'}" ;
713 if (& General
:: IpInSubnet
( $netsettings { 'GREEN_ADDRESS' },
714 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
715 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Green Network $netsettings {'GREEN_ADDRESS'}" ;
719 if (& General
:: IpInSubnet
( $netsettings { 'BLUE_ADDRESS' },
720 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
721 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Blue Network $netsettings {'BLUE_ADDRESS'}" ;
725 if (& General
:: IpInSubnet
( $netsettings { 'ORANGE_ADDRESS' },
726 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
727 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Orange Network $netsettings {'ORANGE_ADDRESS'}" ;
730 open ( ALIASES
, "${General::swroot}/ethernet/aliases" ) or die 'Unable to open aliases file.' ;
734 my @tempalias = split ( /\,/ , $_ );
735 if ( $tempalias [ 1 ] eq 'on' ) {
736 if (& General
:: IpInSubnet
( $tempalias [ 0 ] ,
737 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
738 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire alias entry $tempalias [0]" ;
743 if ( $errormessage ne '' ){
746 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
747 $errormessage = $Lang :: tr
{ 'invalid input' };
750 if (( length ( $cgiparams { 'DMTU' })== 0 ) || (( $cgiparams { 'DMTU' }) < 1000 )) {
751 $errormessage = $Lang :: tr
{ 'invalid mtu input' };
755 unless (& General
:: validport
( $cgiparams { 'DDEST_PORT' })) {
756 $errormessage = $Lang :: tr
{ 'invalid port' };
759 $vpnsettings { 'ENABLED_BLUE' } = $cgiparams { 'ENABLED_BLUE' };
760 $vpnsettings { 'ENABLED_ORANGE' } = $cgiparams { 'ENABLED_ORANGE' };
761 $vpnsettings { 'ENABLED' } = $cgiparams { 'ENABLED' };
762 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
763 #new settings for daemon
764 $vpnsettings { 'DOVPN_SUBNET' } = $cgiparams { 'DOVPN_SUBNET' };
765 $vpnsettings { 'DDEVICE' } = $cgiparams { 'DDEVICE' };
766 $vpnsettings { 'DPROTOCOL' } = $cgiparams { 'DPROTOCOL' };
767 $vpnsettings { 'DDEST_PORT' } = $cgiparams { 'DDEST_PORT' };
768 $vpnsettings { 'DMTU' } = $cgiparams { 'DMTU' };
769 $vpnsettings { 'DCOMPLZO' } = $cgiparams { 'DCOMPLZO' };
770 $vpnsettings { 'DCIPHER' } = $cgiparams { 'DCIPHER' };
773 if ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' ) { system ( "touch ${General::swroot}/ovpn/enable_blue 2>/dev/null" );} else { system ( "unlink ${General::swroot}/ovpn/enable_blue 2>/dev/null" );}
774 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' ) { system ( "touch ${General::swroot}/ovpn/enable_orange 2>/dev/null" );} else { system ( "unlink ${General::swroot}/ovpn/enable_orange 2>/dev/null" );}
775 if ( $vpnsettings { 'ENABLED' } eq 'on' ) { system ( "touch ${General::swroot}/ovpn/enable 2>/dev/null" );} else { system ( "unlink ${General::swroot}/ovpn/enable 2>/dev/null" );}
776 #new settings for daemon
777 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
778 & writeserverconf
(); #hier ok
783 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'reset' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
785 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
787 foreach my $key ( keys %confighash ) {
788 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
789 delete $confighash { $cgiparams { ' $key ' }};
792 while ( $file = glob ( "${General::swroot}/ovpn/ca/*" )) {
795 while ( $file = glob ( "${General::swroot}/ovpn/certs/*" )) {
798 while ( $file = glob ( "${General::swroot}/ovpn/crls/*" )) {
802 if ( open ( FILE
, ">${General::swroot}/ovpn/caconfig" )) {
806 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
811 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'reset' }) {
812 & Header
:: showhttpheaders
();
813 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
814 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
815 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'are you sure' });
817 <table><form method='post'><input type='hidden' name='AREUSURE' value='yes' />
818 <tr><td align='center'>
819 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
820 $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}
821 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'reset'}' />
822 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td></tr>
827 & Header
:: closebigbox
();
828 & Header
:: closepage
();
832 ### Upload CA Certificate
834 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
835 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
837 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
838 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
842 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
843 $errormessage = $Lang :: tr
{ 'name too long' };
847 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
848 $errormessage = $Lang :: tr
{ 'name is invalid' };
849 goto UPLOAD_CA_ERROR
;
852 # Check if there is no other entry with this name
853 foreach my $key ( keys %cahash ) {
854 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
855 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
860 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
861 $errormessage = $Lang :: tr
{ 'there was no file upload' };
864 # Move uploaded ca to a temporary file
865 ( my $fh , my $filename ) = tempfile
( );
866 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
870 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
871 if ( $temp !~ /CA:TRUE/i ) {
872 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
876 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem" );
878 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
884 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem` ;
885 $casubject =~ /Subject: (.*)[\n]/ ;
887 $casubject =~ s
+/ Email
+, E
+;
888 $casubject =~ s/ ST=/ S=/ ;
889 $casubject = & Header
:: cleanhtml
( $casubject );
891 my $key = & General
:: findhasharraykey
( \
%cahash );
892 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
893 $cahash { $key }[ 1 ] = $casubject ;
894 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
895 # system('/usr/local/bin/ipsecctrl', 'R');
900 ### Display ca certificate
902 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
903 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
905 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
906 & Header
:: showhttpheaders
();
907 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
908 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
909 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ca certificate'}:" );
910 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
911 $output = & Header
:: cleanhtml
( $output , "y" );
912 print "<pre> $output </pre> \n " ;
914 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
915 & Header
:: closebigbox
();
916 & Header
:: closepage
();
919 $errormessage = $Lang :: tr
{ 'invalid key' };
923 ### Download ca certificate
925 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
926 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
928 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
929 print "Content-Type: application/octet-stream \r\n " ;
930 print "Content-Disposition: filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
931 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
934 $errormessage = $Lang :: tr
{ 'invalid key' };
938 ### Remove ca certificate (step 2)
940 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
941 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
942 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
944 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
945 foreach my $key ( keys %confighash ) {
946 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
947 if ( $test =~ /: OK/ ) {
949 # if ($vpnsettings{'ENABLED'} eq 'on' ||
950 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
951 # system('/usr/local/bin/ipsecctrl', 'D', $key);
953 unlink ( "${General::swroot}/ovpn//certs/ $confighash { $key }[1]cert.pem" );
954 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" );
955 delete $confighash { $key };
956 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
957 # &writeipsecfiles();
960 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
961 delete $cahash { $cgiparams { 'KEY' }};
962 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
963 # system('/usr/local/bin/ipsecctrl', 'R');
965 $errormessage = $Lang :: tr
{ 'invalid key' };
968 ### Remove ca certificate (step 1)
970 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
971 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
972 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
974 my $assignedcerts = 0 ;
975 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
976 foreach my $key ( keys %confighash ) {
977 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
978 if ( $test =~ /: OK/ ) {
982 if ( $assignedcerts ) {
983 & Header
:: showhttpheaders
();
984 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
985 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
986 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'are you sure' });
988 <table><form method='post'><input type='hidden' name='AREUSURE' value='yes' />
989 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
990 <tr><td align='center'>
991 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>: $assignedcerts
992 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}
993 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
994 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td></tr>
999 & Header
:: closebigbox
();
1000 & Header
:: closepage
();
1003 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1004 delete $cahash { $cgiparams { 'KEY' }};
1005 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1006 # system('/usr/local/bin/ipsecctrl', 'R');
1009 $errormessage = $Lang :: tr
{ 'invalid key' };
1013 ### Display root certificate
1015 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
1016 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
1018 & Header
:: showhttpheaders
();
1019 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1020 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1021 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
1022 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'root certificate'}:" );
1023 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1025 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'host certificate'}:" );
1026 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1028 $output = & Header
:: cleanhtml
( $output , "y" );
1029 print "<pre> $output </pre> \n " ;
1030 & Header
:: closebox
();
1031 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1032 & Header
:: closebigbox
();
1033 & Header
:: closepage
();
1037 ### Download root certificate
1039 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
1040 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1041 print "Content-Type: application/octet-stream \r\n " ;
1042 print "Content-Disposition: filename=cacert.pem \r\n\r\n " ;
1043 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1048 ### Download host certificate
1050 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
1051 if ( - f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
1052 print "Content-Type: application/octet-stream \r\n " ;
1053 print "Content-Disposition: filename=servercert.pem \r\n\r\n " ;
1054 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1058 ### Form for generating a root certificate
1060 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
1061 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1063 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1064 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1065 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
1066 $cgiparams { 'ACTION' } = '' ;
1067 goto ROOTCERT_ERROR
;
1070 if (( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) && - e
"${General::swroot}/red/active" ) {
1071 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
1072 my $ipaddr = < IPADDR
>;
1075 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
1076 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
1077 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
1080 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1082 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1083 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1084 goto ROOTCERT_ERROR
;
1087 # Move uploaded certificate request to a temporary file
1088 ( my $fh , my $filename ) = tempfile
( );
1089 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1091 goto ROOTCERT_ERROR
;
1094 # Create a temporary dirctory
1095 my $tempdir = tempdir
( CLEANUP
=> 1 );
1097 # Extract the CA certificate from the file
1098 my $pid = open ( OPENSSL
, "|-" );
1099 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1100 if ( $pid ) { # parent
1101 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1102 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1106 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1108 goto ROOTCERT_ERROR
;
1111 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-cacerts' , '-nokeys' ,
1113 '-out' , " $tempdir /cacert.pem" )) {
1114 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1116 goto ROOTCERT_ERROR
;
1120 # Extract the Host certificate from the file
1121 $pid = open ( OPENSSL
, "|-" );
1122 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1123 if ( $pid ) { # parent
1124 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1125 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1129 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1131 goto ROOTCERT_ERROR
;
1134 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-clcerts' , '-nokeys' ,
1136 '-out' , " $tempdir /hostcert.pem" )) {
1137 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1139 goto ROOTCERT_ERROR
;
1143 # Extract the Host key from the file
1144 $pid = open ( OPENSSL
, "|-" );
1145 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1146 if ( $pid ) { # parent
1147 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1148 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1152 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1154 goto ROOTCERT_ERROR
;
1157 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-nocerts' ,
1160 '-out' , " $tempdir /serverkey.pem" )) {
1161 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1163 goto ROOTCERT_ERROR
;
1167 move
( " $tempdir /cacert.pem" , "${General::swroot}/ovpn/ca/cacert.pem" );
1169 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1171 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1172 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1173 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1174 goto ROOTCERT_ERROR
;
1177 move
( " $tempdir /hostcert.pem" , "${General::swroot}/ovpn/certs/servercert.pem" );
1179 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1181 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1182 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1183 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1184 goto ROOTCERT_ERROR
;
1187 move
( " $tempdir /serverkey.pem" , "${General::swroot}/ovpn/certs/serverkey.pem" );
1189 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1191 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1192 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1193 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1194 goto ROOTCERT_ERROR
;
1197 goto ROOTCERT_SUCCESS
;
1199 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
1201 # Validate input since the form was submitted
1202 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
1203 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
1204 goto ROOTCERT_ERROR
;
1206 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
1207 $errormessage = $Lang :: tr
{ 'organization too long' };
1208 goto ROOTCERT_ERROR
;
1210 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1211 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1212 goto ROOTCERT_ERROR
;
1214 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
1215 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
1216 goto ROOTCERT_ERROR
;
1218 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
1219 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1220 goto ROOTCERT_ERROR
;
1222 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
1223 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1224 goto ROOTCERT_ERROR
;
1226 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
1227 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1228 goto ROOTCERT_ERROR
;
1230 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1231 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1232 goto ROOTCERT_ERROR
;
1234 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1235 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1236 goto ROOTCERT_ERROR
;
1238 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1239 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1240 goto ROOTCERT_ERROR
;
1242 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1243 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1244 goto ROOTCERT_ERROR
;
1247 # Copy the cgisettings to vpnsettings and save the configfile
1248 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
1249 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
1250 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
1251 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
1252 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
1253 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
1254 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
1255 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1257 # Replace empty strings with a .
1258 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
1259 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
1260 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
1263 #system ('/bin/touch', "${General::swroot}/ovpn/gencanow");
1265 # Create the CA certificate
1266 my $pid = open ( OPENSSL
, "|-" );
1267 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1268 if ( $pid ) { # parent
1269 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1270 print OPENSSL
" $state \n " ;
1271 print OPENSSL
" $city \n " ;
1272 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1273 print OPENSSL
" $ou \n " ;
1274 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
1275 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1278 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1279 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1280 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1281 goto ROOTCERT_ERROR
;
1284 unless ( exec ( '/usr/bin/openssl' , 'req' , '-x509' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1285 '-days' , '999999' , '-newkey' , 'rsa:2048' ,
1286 '-keyout' , "${General::swroot}/ovpn/ca/cakey.pem" ,
1287 '-out' , "${General::swroot}/ovpn/ca/cacert.pem" ,
1288 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1289 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1290 goto ROOTCERT_ERROR
;
1294 # Create the Host certificate request
1295 $pid = open ( OPENSSL
, "|-" );
1296 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1297 if ( $pid ) { # parent
1298 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1299 print OPENSSL
" $state \n " ;
1300 print OPENSSL
" $city \n " ;
1301 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1302 print OPENSSL
" $ou \n " ;
1303 print OPENSSL
" $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1304 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1305 print OPENSSL
". \n " ;
1306 print OPENSSL
". \n " ;
1309 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1310 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1311 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1312 goto ROOTCERT_ERROR
;
1315 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1316 '-newkey' , 'rsa:1024' ,
1317 '-keyout' , "${General::swroot}/ovpn/certs/serverkey.pem" ,
1318 '-out' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1319 '-extensions' , 'server' ,
1320 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1321 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1322 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1323 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1324 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1325 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1326 goto ROOTCERT_ERROR
;
1330 # Sign the host certificate request
1331 system ( '/usr/bin/openssl' , 'ca' , '-days' , '999999' ,
1332 '-batch' , '-notext' ,
1333 '-in' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1334 '-out' , "${General::swroot}/ovpn/certs/servercert.pem" ,
1335 '-extensions' , 'server' ,
1336 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1338 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1339 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1340 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1341 unlink ( "${General::swroot}/ovpn/serverkey.pem" );
1342 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1343 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1344 & newcleanssldatabase
();
1345 goto ROOTCERT_ERROR
;
1347 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1348 & deletebackupcert
();
1351 # Create an empty CRL
1352 system ( '/usr/bin/openssl' , 'ca' , '-gencrl' ,
1353 '-out' , "${General::swroot}/ovpn/crls/cacrl.pem" ,
1354 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1356 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1357 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1358 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1359 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1360 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1361 & cleanssldatabase
();
1362 goto ROOTCERT_ERROR
;
1364 # &cleanssldatabase();
1366 # Create Diffie Hellmann Parameter
1367 system ( '/usr/bin/openssl' , 'dhparam' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1368 '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" ,
1371 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1372 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1373 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1374 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1375 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1376 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1377 & cleanssldatabase
();
1378 goto ROOTCERT_ERROR
;
1380 # &cleanssldatabase();
1382 goto ROOTCERT_SUCCESS
;
1385 if ( $cgiparams { 'ACTION' } ne '' ) {
1386 & Header
:: showhttpheaders
();
1387 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1388 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1389 if ( $errormessage ) {
1390 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
1391 print "<class name='base'> $errormessage " ;
1392 print " </class>" ;
1393 & Header
:: closebox
();
1395 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'generate root/host certificates'}:" );
1397 <form method='post' enctype='multipart/form-data'>
1398 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1399 <tr><td width='30%' class='base'> $Lang ::tr{'organization name'}:</td>
1400 <td width='35%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td>
1401 <td width='35%' colspan='2'> </td></tr>
1402 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}:</td>
1403 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td>
1404 <td colspan='2'> </td></tr>
1405 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt'*' /></td>
1406 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td>
1407 <td colspan='2'> </td></tr>
1408 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt'*' /></td>
1409 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td>
1410 <td colspan='2'> </td></tr>
1411 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt'*' /></td>
1412 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td>
1413 <td colspan='2'> </td></tr>
1414 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt'*' /></td>
1415 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td>
1416 <td colspan='2'> </td></tr>
1417 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1418 <td class='base'><select name='ROOTCERT_COUNTRY'>
1422 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1423 print "<option value=' $Countries ::countries{ $country }'" ;
1424 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1425 print " selected='selected'" ;
1427 print "> $country </option>" ;
1431 <td colspan='2'> </td></tr>
1433 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /></td>
1434 <td> </td><td> </td></tr>
1435 <tr><td class='base' colspan='4' align='left'>
1436 <img src='/blob.gif' valign='top' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
1437 <tr><td class='base' colspan='4' align='left'>
1438 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1439 $Lang ::tr{'generating the root and host certificates may take a long time. it can take up to several minutes on older hardware. please be patient'}
1441 <tr><td colspan='4' bgcolor='#000000'><img src='/images/null.gif' width='1' height='1' border='0' /></td></tr>
1442 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
1443 <td nowrap='nowrap'><input type='file' name='FH' size='32'></td>
1444 <td colspan='2'> </td></tr>
1445 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' ></td>
1446 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td>
1447 <td colspan='2'> </td></tr>
1449 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td>
1450 <td colspan='2'> </td></tr>
1451 <tr><td class='base' colspan='4' align='left'>
1452 <img src='/blob.gif' valign='top' al='*' > $Lang ::tr{'this field may be blank'}</td></tr>
1456 & Header
:: closebox
();
1458 & Header
:: closebigbox
();
1459 & Header
:: closepage
();
1464 system ( "chmod 600 ${General::swroot}/ovpn/certs/serverkey.pem" );
1465 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1466 # $vpnsettings{'ENABLE_BLUE'} eq 'on') {
1467 # system('/usr/local/bin/ipsecctrl', 'S');
1471 ### Enable/Disable connection
1475 # m.a.d net2net Anpassung
1478 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
1480 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1481 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1482 # my $n2nactive = '';
1483 my $n2nactive = `/bin/ps ax|grep $confighash { $cgiparams {'KEY'}}[1]|grep -v grep|awk \' {print \ $1 } \' ` ;
1485 if ( $confighash { $cgiparams { 'KEY' }}) {
1488 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
1489 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
1490 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1492 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
1493 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
1498 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
1499 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1501 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
1502 if ( $n2nactive ne '' ){
1503 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
1507 $errormessage = $Lang :: tr
{ 'invalid key' };
1513 ### Download OpenVPN client package
1517 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'dl client arch' }) {
1518 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1519 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1521 my $clientovpn = '' ;
1523 my $tempdir = tempdir
( CLEANUP
=> 1 );
1524 my $zippath = " $tempdir /" ;
1527 # m.a.d net2net DL Client Package
1530 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
1532 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-Client.zip" ;
1533 my $zippathname = " $zippath $zipname " ;
1534 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1].conf" ;
1535 my @ovsubnettemp = split ( /\./ , $confighash { $cgiparams { 'KEY' }}[ 27 ]);
1536 my $ovsubnet = " @ovsubnettemp [0]. @ovsubnettemp [1]. @ovsubnettemp [2]" ;
1539 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
1540 flock CLIENTCONF
, 2 ;
1542 my $zip = Archive
:: Zip
-> new ();
1543 print CLIENTCONF
"# n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
1544 print CLIENTCONF
"# \n " ;
1545 print CLIENTCONF
"# User Sicherheit \n " ;
1546 print CLIENTCONF
"user nobody \n " ;
1547 print CLIENTCONF
"group nobody \n " ;
1548 print CLIENTCONF
"persist-tun \n " ;
1549 print CLIENTCONF
"persist-key \n " ;
1550 print CLIENTCONF
"# \n " ;
1551 print CLIENTCONF
"# IP/DNS fuer das Server Gateway - g2g Mode \n " ;
1552 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} \n " ;
1553 print CLIENTCONF
"# \n " ;
1554 print CLIENTCONF
"# IP Adressen des VPN Tunnels \n " ;
1555 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
1556 print CLIENTCONF
"# \n " ;
1557 print CLIENTCONF
"# Netzwerk auf dem Server Gateway \n " ;
1558 print CLIENTCONF
"route $confighash { $cgiparams {'KEY'}}[8] \n " ;
1559 print CLIENTCONF
"# Device fuer den Tunnel \n " ;
1560 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \n " ;
1561 print CLIENTCONF
"# \n " ;
1562 print CLIENTCONF
"#Port und Protokoll \n " ;
1563 print CLIENTCONF
"port $confighash { $cgiparams {'KEY'}}[29] \n " ;
1564 print CLIENTCONF
"proto $confighash { $cgiparams {'KEY'}}[28] \n " ;
1565 print CLIENTCONF
"# \n " ;
1566 print CLIENTCONF
"# Paketgroessen \n " ;
1567 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1500' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
1568 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
1569 print CLIENTCONF
"fragment 1300 \n " ;
1570 print CLIENTCONF
"mssfix \n " ;
1571 print CLIENTCONF
"# \n " ;
1572 print CLIENTCONF
"# Auth. Client \n " ;
1573 print CLIENTCONF
"tls-client \n " ;
1574 print CLIENTCONF
"# \n " ;
1575 print CLIENTCONF
"# Verschluesselung \n " ;
1576 print CLIENTCONF
"cipher AES-256-CBC \n " ;
1577 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
1578 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
1579 $zip -> addFile ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" , " $confighash { $cgiparams {'KEY'}}[1].p12" ) or die "Can't add file $confighash { $cgiparams {'KEY'}}[1].p12 \n " ;
1581 print CLIENTCONF
"# \n " ;
1582 if ( $confighash { $cgiparams { 'KEY' }}[ 30 ] eq 'on' ) {
1583 print CLIENTCONF
"# Kompression einschalten \n " ;
1584 print CLIENTCONF
"comp-lzo \r\n " ;
1585 print CLIENTCONF
"# \n " ;
1587 print CLIENTCONF
"# Debug Level \n " ;
1588 print CLIENTCONF
"verb 3 \n " ;
1589 print CLIENTCONF
"# \n " ;
1590 print CLIENTCONF
"# Tunnel Ueberwachung \n " ;
1591 print CLIENTCONF
"keepalive 10 60 \n " ;
1592 print CLIENTCONF
"# \n " ;
1593 print CLIENTCONF
"# Als Daemon starten \n " ;
1594 print CLIENTCONF
"daemon $confighash { $cgiparams {'KEY'}}[1]n2n \n " ;
1595 print CLIENTCONF
"writepid /var/run/ $confighash { $cgiparams {'KEY'}}[1]n2n.pid \n " ;
1596 print CLIENTCONF
"# \n " ;
1597 print CLIENTCONF
"# Management Interface aktivieren \n " ;
1598 print CLIENTCONF
"# management localhost 4711 \n " ;
1599 print CLIENTCONF
"# remsub $confighash { $cgiparams {'KEY'}}[11] \n " ;
1604 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
1605 my $status = $zip -> writeToFileNamed ( $zippathname );
1607 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
1608 @fileholder = < DLFILE
>;
1609 print "Content-Type:application/x-download \n " ;
1610 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
1616 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.zip" ;
1617 my $zippathname = " $zippath $zipname " ;
1618 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.ovpn" ;
1621 # m.a.d net2net DL Client Package end
1624 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
1625 flock CLIENTCONF
, 2 ;
1627 my $zip = Archive
:: Zip
-> new ();
1629 print CLIENTCONF
"#OpenVPN Server conf \r\n " ;
1630 print CLIENTCONF
"tls-client \r\n " ;
1631 print CLIENTCONF
"client \r\n " ;
1632 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \r\n " ;
1633 print CLIENTCONF
"proto $vpnsettings {'DPROTOCOL'} \r\n " ;
1634 print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu $vpnsettings {'DMTU'} \r\n " ;
1635 if ( $vpnsettings { 'ENABLED' } eq 'on' ){
1636 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} $vpnsettings {'DDEST_PORT'} \r\n " ;
1637 if ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
1638 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Blue interface \r\n " ;
1639 print CLIENTCONF
";remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
1641 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
1642 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
1643 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
1645 } elsif ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
1646 print CLIENTCONF
"remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
1647 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
1648 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
1649 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
1651 } elsif ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
1652 print CLIENTCONF
"remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
1655 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
1656 print CLIENTCONF
"pkcs12 $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
1657 $zip -> addFile ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" , " $confighash { $cgiparams {'KEY'}}[1].p12" ) or die "Can't add file $confighash { $cgiparams {'KEY'}}[1].p12 \n " ;
1659 print CLIENTCONF
"ca cacert.pem \r\n " ;
1660 print CLIENTCONF
"cert $confighash { $cgiparams {'KEY'}}[1]cert.pem \r\n " ;
1661 print CLIENTCONF
"key $confighash { $cgiparams {'KEY'}}[1].key \r\n " ;
1662 $zip -> addFile ( "${General::swroot}/ovpn/ca/cacert.pem" , "cacert.pem" ) or die "Can't add file cacert.pem \n " ;
1663 $zip -> addFile ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" , " $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) or die "Can't add file $confighash { $cgiparams {'KEY'}}[1]cert.pem \n " ;
1665 print CLIENTCONF
"cipher $vpnsettings {DCIPHER} \r\n " ;
1666 if ( $vpnsettings { DCOMPLZO
} eq 'on' ) {
1667 print CLIENTCONF
"comp-lzo \r\n " ;
1669 print CLIENTCONF
"verb 3 \r\n " ;
1670 print CLIENTCONF
"ns-cert-type server \r\n " ;
1671 print CLIENTCONF
"tls-remote $vpnsettings {ROOTCERT_HOSTNAME} \r\n " ;
1672 if ( $vpnsettings { MSSFIX
} eq 'on' ) {
1673 print CLIENTCONF
"mssfix \r\n " ;
1675 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' ) {
1676 print CLIENTCONF
"fragment $vpnsettings {'FRAGMENT'} \r\n " ;
1680 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
1681 my $status = $zip -> writeToFileNamed ( $zippathname );
1683 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
1684 @fileholder = < DLFILE
>;
1685 print "Content-Type:application/x-download \n " ;
1686 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
1694 ### Remove connection
1698 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
1699 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1700 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1702 if ( $confighash { $cgiparams { 'KEY' }}) {
1703 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1704 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
1705 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
1708 my $temp = `/usr/bin/openssl ca -revoke ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
1711 # m.a.d net2net Anpassung
1713 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
1715 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
1716 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
1717 unlink ( $certfile ) or die "Removing $certfile fail: $!" ;
1718 unlink ( $conffile ) or die "Removing $conffile fail: $!" ;
1719 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
1723 # m.a.d net2net Anpassung end
1726 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
1727 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
1728 delete $confighash { $cgiparams { 'KEY' }};
1729 my $temp2 = `/usr/bin/openssl ca -gencrl -out ${General::swroot}/ovpn/crls/cacrl.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
1730 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1731 #&writeserverconf();
1733 $errormessage = $Lang :: tr
{ 'invalid key' };
1738 ### Download PKCS12 file
1740 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
1741 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1743 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
1744 print "Content-Type: application/octet-stream \r\n\r\n " ;
1745 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
1749 ### Display certificate
1751 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
1752 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1754 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1755 & Header
:: showhttpheaders
();
1756 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1757 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1758 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate'}:" );
1759 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1760 $output = & Header
:: cleanhtml
( $output , "y" );
1761 print "<pre> $output </pre> \n " ;
1762 & Header
:: closebox
();
1763 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1764 & Header
:: closebigbox
();
1765 & Header
:: closepage
();
1769 ### Display Certificate Revoke List
1771 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show crl' }) {
1772 # &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash);
1774 if ( - f
"${General::swroot}/ovpn/crls/cacrl.pem" ) {
1775 & Header
:: showhttpheaders
();
1776 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1777 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1778 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'crl'}:" );
1779 my $output = `/usr/bin/openssl crl -text -noout -in ${General::swroot}/ovpn/crls/cacrl.pem` ;
1780 $output = & Header
:: cleanhtml
( $output , "y" );
1781 print "<pre> $output </pre> \n " ;
1782 & Header
:: closebox
();
1783 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1784 & Header
:: closebigbox
();
1785 & Header
:: closepage
();
1790 ### Advanced Server Settings
1793 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced server' }) {
1797 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
1799 # if ($cgiparams{'CLIENT2CLIENT'} eq '') {
1800 # $cgiparams{'CLIENT2CLIENT'} = 'on';
1803 if ( $cgiparams { 'MAX_CLIENTS' } eq '' ) {
1804 $cgiparams { 'MAX_CLIENTS' } = '100' ;
1807 if ( $cgiparams { 'KEEPALIVE_1' } eq '' ) {
1808 $cgiparams { 'KEEPALIVE_1' } = '10' ;
1810 if ( $cgiparams { 'KEEPALIVE_2' } eq '' ) {
1811 $cgiparams { 'KEEPALIVE_2' } = '60' ;
1813 if ( $cgiparams { 'LOG_VERB' } eq '' ) {
1814 $cgiparams { 'LOG_VERB' } = '3' ;
1816 $checked { 'CLIENT2CLIENT' }{ 'off' } = '' ;
1817 $checked { 'CLIENT2CLIENT' }{ 'on' } = '' ;
1818 $checked { 'CLIENT2CLIENT' }{ $cgiparams { 'CLIENT2CLIENT' }} = 'CHECKED' ;
1819 $checked { 'REDIRECT_GW_DEF1' }{ 'off' } = '' ;
1820 $checked { 'REDIRECT_GW_DEF1' }{ 'on' } = '' ;
1821 $checked { 'REDIRECT_GW_DEF1' }{ $cgiparams { 'REDIRECT_GW_DEF1' }} = 'CHECKED' ;
1822 $selected { 'ENGINES' }{ $cgiparams { 'ENGINES' }} = 'SELECTED' ;
1823 $checked { 'MSSFIX' }{ 'off' } = '' ;
1824 $checked { 'MSSFIX' }{ 'on' } = '' ;
1825 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
1826 $selected { 'LOG_VERB' }{ '1' } = '' ;
1827 $selected { 'LOG_VERB' }{ '2' } = '' ;
1828 $selected { 'LOG_VERB' }{ '3' } = '' ;
1829 $selected { 'LOG_VERB' }{ '4' } = '' ;
1830 $selected { 'LOG_VERB' }{ '5' } = '' ;
1831 $selected { 'LOG_VERB' }{ '6' } = '' ;
1832 $selected { 'LOG_VERB' }{ '7' } = '' ;
1833 $selected { 'LOG_VERB' }{ '8' } = '' ;
1834 $selected { 'LOG_VERB' }{ '9' } = '' ;
1835 $selected { 'LOG_VERB' }{ '10' } = '' ;
1836 $selected { 'LOG_VERB' }{ '11' } = '' ;
1837 $selected { 'LOG_VERB' }{ '0' } = '' ;
1838 $selected { 'LOG_VERB' }{ $cgiparams { 'LOG_VERB' }} = 'SELECTED' ;
1842 & Header
:: showhttpheaders
();
1843 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
1844 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1845 if ( $errormessage ) {
1846 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
1847 print "<class name='base'> $errormessage \n " ;
1848 print " </class> \n " ;
1849 & Header
:: closebox
();
1851 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'advanced server' });
1853 <form method='post' enctype='multipart/form-data'>
1854 <table width='100%'>
1856 <td colspan='4'><b> $Lang ::tr{'dhcp-options'}</b></td>
1859 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1862 <td class='base'>Domain</td>
1863 <td><input type='TEXT' name='DHCP_DOMAIN' value=' $cgiparams {'DHCP_DOMAIN'}' size='30' /></td>
1866 <td class='base'>DNS</td>
1867 <td><input type='TEXT' name='DHCP_DNS' value=' $cgiparams {'DHCP_DNS'}' size='30' /></td>
1870 <td class='base'>WINS</td>
1871 <td><input type='TEXT' name='DHCP_WINS' value=' $cgiparams {'DHCP_WINS'}' size='30' /></td>
1875 <table width='100%'>
1877 <td class'base'><b> $Lang ::tr{'misc-options'}</b></td>
1880 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='50%'></td>
1883 <td class='base'>Client-To-Client</td>
1884 <td><input type='checkbox' name='CLIENT2CLIENT' $checked {'CLIENT2CLIENT'}{'on'} /></td>
1887 <td class='base'>Redirect-Gateway def1</td>
1888 <td><input type='checkbox' name='REDIRECT_GW_DEF1' $checked {'REDIRECT_GW_DEF1'}{'on'} /></td>
1891 <td class='base'>Max-Clients</td>
1892 <td><input type='text' name='MAX_CLIENTS' value=' $cgiparams {'MAX_CLIENTS'}' size='10' /></td>
1895 <td class='base'>Keppalive <br />
1896 (ping/ping-restart)</td>
1897 <td><input type='TEXT' name='KEEPALIVE_1' value=' $cgiparams {'KEEPALIVE_1'}' size='10' /></td>
1898 <td><input type='TEXT' name='KEEPALIVE_2' value=' $cgiparams {'KEEPALIVE_2'}' size='10' /></td>
1901 <td class='base'>fragment <br></td>
1902 <td><input type='TEXT' name='FRAGMENT' value=' $cgiparams {'FRAGMENT'}' size='10' /></td>
1903 <td>Default: <span class="base">1300</span></td>
1906 <td class='base'>mssfix</td>
1907 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
1908 <td>Default: on</td>
1914 <table width='100%'>
1916 <td class'base'><b>Crypto-Engines</b></td>
1919 <td width='15%'></td> <td width='30%'> </td><td width='25%'> </td><td width='30%'></td>
1921 <tr><td class='base'>Engines:</td>
1922 <td><select name='ENGINES'><option value="none" $selected {'ENGINES'}{'none'}>none</option>
1923 <option value="cryptodev" $selected {'ENGINES'}{'cryptodev'}>cryptodev</option>
1924 <option value="padlock" $selected {'ENGINES'}{'padlock'}>padlock</option>
1930 <table width='100%'>
1932 <td class'base'><b> $Lang ::tr{'log-options'}</b></td>
1935 <td width='15%'></td> <td width='30%'> </td><td width='25%'> </td><td width='30%'></td>
1938 <tr><td class='base'>VERB</td>
1939 <td><select name='LOG_VERB'><option value='1' $selected {'LOG_VERB'}{'1'}>1</option>
1940 <option value='2' $selected {'LOG_VERB'}{'2'}>2</option>
1941 <option value='3' $selected {'LOG_VERB'}{'3'}>3</option>
1942 <option value='4' $selected {'LOG_VERB'}{'4'}>4</option>
1943 <option value='5' $selected {'LOG_VERB'}{'5'}>5</option>
1944 <option value='6' $selected {'LOG_VERB'}{'6'}>6</option>
1945 <option value='7' $selected {'LOG_VERB'}{'7'}>7</option>
1946 <option value='8' $selected {'LOG_VERB'}{'8'}>8</option>
1947 <option value='9' $selected {'LOG_VERB'}{'9'}>9</option>
1948 <option value='10' $selected {'LOG_VERB'}{'10'}>10</option>
1949 <option value='11' $selected {'LOG_VERB'}{'11'}>11</option>
1950 <option value='0' $selected {'LOG_VERB'}{'0'}>0</option></select></td>
1953 <table width='100%'>
1956 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' /></td>
1957 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
1965 & Header
:: closebox
();
1966 # print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'>$Lang::tr{'back'}</a></div>";
1967 & Header
:: closebigbox
();
1968 & Header
:: closepage
();
1972 ### Openvpn Connections Statistics
1974 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ovpn con stat' }) {
1975 & Header
:: showhttpheaders
();
1976 & Header
:: openpage
( $Lang :: tr
{ 'ovpn con stat' }, 1 , '' );
1977 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1978 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ovpn con stat' });
1981 # <td><b>$Lang::tr{'protocol'}</b></td>
1982 # protocol temp removed
1984 <table width='100%' border='0' cellpadding='2' cellspacing='0'>
1986 <td><b> $Lang ::tr{'common name'}</b></td>
1987 <td><b> $Lang ::tr{'real address'}</b></td>
1988 <td><b> $Lang ::tr{'virtual address'}</b></td>
1989 <td><b> $Lang ::tr{'loged in at'}</b></td>
1990 <td><b> $Lang ::tr{'bytes sent'}</b></td>
1991 <td><b> $Lang ::tr{'bytes received'}</b></td>
1992 <td><b> $Lang ::tr{'last activity'}</b></td>
1996 my $filename = "/var/log/ovpnserver.log" ;
1997 open ( FILE
, $filename ) or die 'Unable to open config file.' ;
1998 my @current = < FILE
>;
2007 my %userlookup = ();
2008 foreach my $line ( @current )
2011 if ( $line =~ /^Updated,(.+)/ ){
2012 @match = split ( /^Updated,(.+)/ , $line );
2013 $status = $match [ 1 ];
2016 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
2017 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
2018 if ( $match [ 1 ] ne "Common Name" ) {
2020 $userlookup { $match [ 2 ]} = $uid ;
2021 $users [ $uid ]{ 'CommonName' } = $match [ 1 ];
2022 $users [ $uid ]{ 'RealAddress' } = $match [ 2 ];
2023 $users [ $uid ]{ 'BytesReceived' } = & sizeformat
( $match [ 3 ]);
2024 $users [ $uid ]{ 'BytesSent' } = & sizeformat
( $match [ 4 ]);
2025 $users [ $uid ]{ 'Since' } = $match [ 5 ];
2026 $users [ $uid ]{ 'Proto' } = $proto ;
2030 if ( $line =~ /^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ ) {
2031 @match = split ( m/^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ , $line );
2032 if ( $match [ 1 ] ne "Virtual Address" ) {
2033 $address = $match [ 3 ];
2034 #find the uid in the lookup table
2035 $uid = $userlookup { $address };
2036 $users [ $uid ]{ 'VirtualAddress' } = $match [ 1 ];
2037 $users [ $uid ]{ 'LastRef' } = $match [ 4 ];
2043 for ( my $idx = 1 ; $idx <= $user2 ; $idx ++){
2045 print "<tr bgcolor=' $color {'color20'}'> \n " ;
2047 print "<tr bgcolor=' $color {'color22'}'> \n " ;
2049 print "<td align='left'> $users [ $idx -1]{'CommonName'}</td>" ;
2050 print "<td align='left'> $users [ $idx -1]{'RealAddress'}</td>" ;
2051 print "<td align='left'> $users [ $idx -1]{'VirtualAddress'}</td>" ;
2052 print "<td align='left'> $users [ $idx -1]{'Since'}</td>" ;
2053 print "<td align='left'> $users [ $idx -1]{'BytesSent'}</td>" ;
2054 print "<td align='left'> $users [ $idx -1]{'BytesReceived'}</td>" ;
2055 print "<td align='left'> $users [ $idx -1]{'LastRef'}</td>" ;
2056 # print "<td align='left'>$users[$idx-1]{'Proto'}</td>";
2062 <table width='100%' border='0' cellpadding='2' cellspacing='0'>
2067 <tr><td align='center' > $Lang ::tr{'the statistics were last updated at'} <b> $status </b></td></tr>
2071 & Header
:: closebox
();
2072 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2073 & Header
:: closebigbox
();
2074 & Header
:: closepage
();
2078 ### Download Certificate
2080 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
2081 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2083 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2084 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \r\n " ;
2085 print "Content-Type: application/octet-stream \r\n\r\n " ;
2086 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2091 ### Enable/Disable connection
2094 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
2096 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2097 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2099 if ( $confighash { $cgiparams { 'KEY' }}) {
2100 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
2101 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
2102 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2103 #&writeserverconf();
2104 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2105 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2106 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
2109 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
2110 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2111 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2112 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2114 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2115 #&writeserverconf();
2118 $errormessage = $Lang :: tr
{ 'invalid key' };
2122 ### Restart connection
2124 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
2125 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2126 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2128 if ( $confighash { $cgiparams { 'KEY' }}) {
2129 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2130 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2131 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
2134 $errormessage = $Lang :: tr
{ 'invalid key' };
2138 ### Remove connection
2140 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
2141 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2142 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2144 if ( $confighash { $cgiparams { 'KEY' }}) {
2145 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2146 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2147 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2149 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
2150 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2151 delete $confighash { $cgiparams { 'KEY' }};
2152 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2153 #&writeserverconf();
2155 $errormessage = $Lang :: tr
{ 'invalid key' };
2160 ### Choose between adding a host-net or net-net connection
2164 # m.a.d Anpassung wegen upload n2n Package
2167 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
2168 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2169 & Header
:: showhttpheaders
();
2170 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2171 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2172 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection type' });
2174 <b> $Lang ::tr{'connection type'}:</b><br />
2175 <table><form method='post' ENCTYPE="multipart/form-data">
2176 <tr><td><input type='radio' name='TYPE' value='host' checked /></td>
2177 <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
2178 <tr><td><input type='radio' name='TYPE' value='net' /></td>
2179 <td class='base'> $Lang ::tr{'net to net vpn'}</td></tr>
2180 <tr><td><input type='radio' name='TYPE' value='net2net' /></td>
2181 <td class='base'> $Lang ::tr{'net to net vpn'} (Upload Client Package)</td></tr>
2182 <tr><td> </td><td class='base'><input type='file' name='FH' size='30'></td></tr>
2183 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
2188 & Header
:: closebox
();
2189 & Header
:: closebigbox
();
2190 & Header
:: closepage
();
2194 # m.a.d uploading a IPFire n2n Client package
2197 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2net' )){
2201 my $uplconffilename = '' ;
2202 my $uplp12name = '' ;
2203 my $complzoactive = '' ;
2209 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2211 # Check if a file is uploaded
2213 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
2214 $errormessage = $Lang :: tr
{ 'there was no file upload' };
2218 # Move uploaded IPfire n2n package to temporary file
2220 ( my $fh , my $filename ) = tempfile
( );
2221 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
2226 my $zip = Archive
:: Zip
-> new ();
2227 my $zipName = $filename ;
2228 my $status = $zip -> read ( $zipName );
2229 if ( $status != AZ_OK
) {
2230 $errormessage = "Read of $zipName failed \n " ;
2234 my $tempdir = tempdir
( CLEANUP
=> 1 );
2235 my @files = $zip -> memberNames ();
2237 $zip -> extractMemberWithoutPaths ( $_ , " $tempdir / $_ " );
2239 my $countfiles = @files ;
2241 # Check if we have not more then 2 files
2243 if ( $countfiles == 2 ){
2245 if ( $_ =~ /.conf$/ ){
2246 $uplconffilename = $_ ;
2248 if ( $_ =~ /.p12$/ ){
2252 if (( $uplconffilename eq '' ) || ( $uplp12name eq '' )){
2253 $errormessage = "Either no *.conf or no *.p12 file found \n " ;
2257 open ( FILE
, " $tempdir / $uplconffilename " ) or die 'Unable to open*.conf file' ;
2258 @firen2nconf = < FILE
>;
2260 chomp ( @firen2nconf );
2264 $errormessage = "Filecount does not match only 2 files are allowed \n " ;
2269 # m.a.d prepare imported ipfire net2net data
2272 my @n2nname = split ( /\./ , $uplconffilename );
2273 $n2nname [ 0 ] =~ s/\n|\r//g ;
2275 if ( !- d
"${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) {
2276 mkdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" , 0770 ); }
2278 move
( " $tempdir / $uplconffilename " , "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $uplconffilename " );
2281 $errormessage = "*.conf move failed: $!" ;
2286 move
( " $tempdir / $uplp12name " , "${General::swroot}/ovpn/certs/ $uplp12name " );
2288 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
2294 #my @n2nroute = split(/ /, (grep { /^route/ } @firen2nconf)[0]);
2295 my @n2nproto = split ( / / , ( grep { /^proto/ } @firen2nconf )[ 0 ]);
2296 my @n2nport = split ( / / , ( grep { /^port/ } @firen2nconf )[ 0 ]);
2297 my @n2ntunmtu = split ( / / , ( grep { /^tun-mtu/ } @firen2nconf )[ 0 ]);
2298 my @n2ncomplzo = grep { /^comp-lzo/ } @firen2nconf ;
2299 if ( $n2ncomplzo [ 0 ] =~ /comp-lzo/ ){ $complzoactive = "on" ;} else { $complzoactive = "off" ;}
2300 my @n2nremote = split ( / / , ( grep { /^remote/ } @firen2nconf )[ 0 ]);
2301 my @n2novpnsuball = split ( / / , ( grep { /^ifconfig/ } @firen2nconf )[ 0 ]);
2302 my @n2novpnsub = split ( /\./ , $n2novpnsuball [ 1 ]);
2303 my @n2nremsub = split ( / / , ( grep { /^route/ } @firen2nconf )[ 0 ]);
2304 my @n2nlocalsub = split ( / / , ( grep { /^# remsub/ } @firen2nconf )[ 0 ]);
2306 # $errormessage = &Ovpnfunc::ovelapplausi("$tmposupnet3[0].$tmposupnet3[1].$tmposupnet3[2].0","255.255.255.0");
2307 # if ($errormessage ne ''){
2312 # m.a.d delete CR and LF from arrays for this chomp doesnt work
2315 #$n2nroute[1] =~ s/\n|\r//g;
2316 $n2nremote [ 1 ] =~ s/\n|\r//g ;
2317 #$n2nroute[1] =~ s/\n|\r//g;
2318 #$n2nroute[2] =~ s/\n|\r//g;
2319 $n2novpnsub [ 0 ] =~ s/\n|\r//g ;
2320 $n2novpnsub [ 1 ] =~ s/\n|\r//g ;
2321 $n2novpnsub [ 2 ] =~ s/\n|\r//g ;
2322 $n2nproto [ 1 ] =~ s/\n|\r//g ;
2323 $n2nport [ 1 ] =~ s/\n|\r//g ;
2324 $n2ntunmtu [ 1 ] =~ s/\n|\r//g ;
2325 $n2nremsub [ 1 ] =~ s/\n|\r//g ;
2326 $n2nlocalsub [ 2 ] =~ s/\n|\r//g ;
2327 chomp ( $complzoactive );
2330 # m.a.d Write n2n config
2334 # Check if there is no other entry with this name
2337 foreach my $dkey ( keys %confighash ) {
2338 if ( $confighash { $dkey }[ 1 ] eq $n2nname [ 0 ]) {
2339 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
2344 $key = & General
:: findhasharraykey
( \
%confighash );
2346 foreach my $i ( 0 .. 31 ) { $confighash { $key }[ $i ] = "" ;}
2347 $confighash { $key }[ 0 ] = 'off' ;
2348 $confighash { $key }[ 1 ] = $n2nname [ 0 ];
2349 $confighash { $key }[ 2 ] = $n2nname [ 0 ];
2350 $confighash { $key }[ 3 ] = 'net' ;
2351 $confighash { $key }[ 4 ] = 'cert' ;
2352 $confighash { $key }[ 6 ] = 'client' ;
2353 $confighash { $key }[ 8 ] = $n2nlocalsub [ 2 ];
2354 $confighash { $key }[ 10 ] = $n2nremote [ 1 ];
2355 $confighash { $key }[ 11 ] = $n2nremsub [ 1 ];
2356 $confighash { $key }[ 25 ] = 'IPFire n2n Client' ;
2357 $confighash { $key }[ 26 ] = 'red' ;
2358 $confighash { $key }[ 27 ] = " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ;
2359 $confighash { $key }[ 28 ] = $n2nproto [ 1 ];
2360 $confighash { $key }[ 29 ] = $n2nport [ 1 ];
2361 $confighash { $key }[ 30 ] = $complzoactive ;
2362 $confighash { $key }[ 31 ] = $n2ntunmtu [ 1 ];
2365 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2368 & Header
:: showhttpheaders
();
2369 & Header
:: openpage
( 'Validate imported configuration' , 1 , '' );
2370 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
2371 if ( $errormessage ) {
2372 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2373 print "<class name='base'> $errormessage " ;
2374 print " </class>" ;
2375 & Header
:: closebox
();
2379 & Header
:: openbox
( '100%' , 'LEFT' , 'import ipfire net2net config' );
2381 if ( $errormessage eq '' ){
2383 <!-- ipfire net2net config gui -->
2384 <table width='100%'>
2385 <tr><td width='25%'> </td><td width='25%'> </td></tr>
2386 <tr><td class='boldbase'> $Lang ::tr{'name'}:</td><td><b> $n2nname [0]</b></td></tr>
2387 <tr><td> </td><td> </td></tr>
2388 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td><td><b> $confighash { $key }[6]</b></td></tr>
2389 <tr><td class='boldbase' nowrap='nowrap'>Remote Host </td><td><b> $confighash { $key }[10]</b></td></tr>
2390 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td><td><b> $confighash { $key }[8]</b></td></tr>
2391 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td><td><b> $confighash { $key }[11]</b></td></tr>
2392 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td><td><b> $confighash { $key }[27]</b></td></tr>
2393 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td><td><b> $confighash { $key }[28]</b></td></tr>
2394 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'destination port'}:</td><td><b> $confighash { $key }[29]</b></td></tr>
2395 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td><td><b> $confighash { $key }[30]</b></td></tr>
2396 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'}</td><td><b> $confighash { $key }[31]</b></td></tr>
2397 <tr><td> </td><td> </td></tr>
2401 & Header
:: closebox
();
2404 if ( $errormessage ) {
2405 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2407 print "<div align='center'><form method='post' ENCTYPE='multipart/form-data'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />" ;
2408 print "<input type='hidden' name='TYPE' value='net2netakn' />" ;
2409 print "<input type='hidden' name='KEY' value=' $key ' />" ;
2410 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
2412 & Header
:: closebigbox
();
2413 & Header
:: closepage
();
2418 ### Accept IPFire n2n Package Settings
2421 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
2424 ### Discard and Rollback IPFire n2n Package Settings
2427 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'cancel' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
2429 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2431 if ( $confighash { $cgiparams { 'KEY' }}) {
2433 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
2434 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2435 unlink ( $certfile ) or die "Removing $certfile fail: $!" ;
2436 unlink ( $conffile ) or die "Removing $conffile fail: $!" ;
2437 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
2438 delete $confighash { $cgiparams { 'KEY' }};
2439 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2442 $errormessage = $Lang :: tr
{ 'invalid key' };
2447 # m.a.d end uploading a IPFire n2n Client package
2452 ### Adding a new connection
2454 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
2455 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
2456 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
2458 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2459 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
2460 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2462 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
2463 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
2464 $errormessage = $Lang :: tr
{ 'invalid key' };
2467 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
2468 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
2469 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
2470 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
2471 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
2472 $cgiparams { 'SIDE' } = $confighash { $cgiparams { 'KEY' }}[ 6 ];
2473 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
2474 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
2475 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
2476 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
2477 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
2479 $cgiparams { 'OVPN_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
2480 $cgiparams { 'PROTOCOL' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
2481 $cgiparams { 'DEST_PORT' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
2482 $cgiparams { 'COMPLZO' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
2483 $cgiparams { 'MTU' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
2485 #ab hiere error uebernehmen
2486 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
2487 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
2488 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
2489 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
2494 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
2495 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
2499 if ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
2500 $errormessage = $Lang :: tr
{ 'name is invalid' };
2504 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
2505 $errormessage = $Lang :: tr
{ 'name too long' };
2509 # if (($cgiparams{'TYPE'} eq 'net') && ($cgiparams{'SIDE'} !~ /^(left|right)$/)) {
2510 # $errormessage = $Lang::tr{'ipfire side is invalid'};
2511 # goto VPNCONF_ERROR;
2514 # Check if there is no other entry with this name
2515 if (! $cgiparams { 'KEY' }) {
2516 foreach my $key ( keys %confighash ) {
2517 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
2518 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
2524 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! $cgiparams { 'REMOTE' })) {
2525 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
2529 if ( $cgiparams { 'REMOTE' }) {
2530 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
2531 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
2532 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
2535 if (& valid_dns_host
( $cgiparams { 'REMOTE' })) {
2536 $warnmessage = " $Lang ::tr{'check vpn lr'} $cgiparams {'REMOTE'}. $Lang ::tr{'dns check failed'}" ;
2541 if ( $cgiparams { 'TYPE' } ne 'host' ) {
2542 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
2543 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
2544 goto VPNCONF_ERROR
;}
2546 # Check if there is no other entry without IP-address and PSK
2547 if ( $cgiparams { 'REMOTE' } eq '' ) {
2548 foreach my $key ( keys %confighash ) {
2549 if (( $cgiparams { 'KEY' } ne $key ) &&
2550 ( $confighash { $key }[ 4 ] eq 'psk' || $cgiparams { 'AUTH' } eq 'psk' ) &&
2551 $confighash { $key }[ 10 ] eq '' ) {
2552 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
2557 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
2558 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
2562 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
2563 $errormessage = $Lang :: tr
{ 'invalid input' };
2566 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
2567 $errormessage = $Lang :: tr
{ 'invalid input' };
2572 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
2573 # if (! length($cgiparams{'PSK'}) ) {
2574 # $errormessage = $Lang::tr{'pre-shared key is too short'};
2575 # goto VPNCONF_ERROR;
2577 # if ($cgiparams{'PSK'} =~ /['",&]/) {
2578 # $errormessage = $Lang::tr{'invalid characters found in pre-shared key'};
2579 # goto VPNCONF_ERROR;
2581 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
2582 if ( $cgiparams { 'KEY' }) {
2583 $errormessage = $Lang :: tr
{ 'cant change certificates' };
2586 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
2587 $errormessage = $Lang :: tr
{ 'there was no file upload' };
2591 # Move uploaded certificate request to a temporary file
2592 ( my $fh , my $filename ) = tempfile
( );
2593 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
2598 # Sign the certificate request and move it
2599 # Sign the host certificate request
2600 system ( '/usr/bin/openssl' , 'ca' , '-days' , '999999' ,
2601 '-batch' , '-notext' ,
2603 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
2604 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
2606 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
2608 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
2609 & newcleanssldatabase
();
2613 & deletebackupcert
();
2616 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
2617 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
2619 $temp =~ s
+/ Email
+, E
+;
2620 $temp =~ s/ ST=/ S=/ ;
2621 $cgiparams { 'CERT_NAME' } = $temp ;
2622 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
2623 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
2624 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
2625 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
2628 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
2629 if ( $cgiparams { 'KEY' }) {
2630 $errormessage = $Lang :: tr
{ 'cant change certificates' };
2633 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
2634 $errormessage = $Lang :: tr
{ 'there was no file upload' };
2637 # Move uploaded certificate to a temporary file
2638 ( my $fh , my $filename ) = tempfile
( );
2639 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
2644 # Verify the certificate has a valid CA and move it
2646 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/cacert.pem $filename ` ;
2647 if ( $test =~ /: OK/ ) {
2650 foreach my $key ( keys %cahash ) {
2651 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $key }[0]cert.pem $filename ` ;
2652 if ( $test =~ /: OK/ ) {
2658 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
2662 move
( $filename , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
2664 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
2670 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
2671 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
2673 $temp =~ s
+/ Email
+, E
+;
2674 $temp =~ s/ ST=/ S=/ ;
2675 $cgiparams { 'CERT_NAME' } = $temp ;
2676 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
2677 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
2678 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
2679 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
2680 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
2683 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
2684 if ( $cgiparams { 'KEY' }) {
2685 $errormessage = $Lang :: tr
{ 'cant change certificates' };
2688 # Validate input since the form was submitted
2689 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
2690 $errormessage = $Lang :: tr
{ 'name too long' };
2693 if ( $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
2694 $errormessage = $Lang :: tr
{ 'invalid input for name' };
2697 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
2698 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
2701 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
2702 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
2705 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
2706 $errormessage = $Lang :: tr
{ 'invalid input for department' };
2709 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
2710 $errormessage = $Lang :: tr
{ 'organization too long' };
2713 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
2714 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
2717 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
2718 $errormessage = $Lang :: tr
{ 'invalid input for city' };
2721 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
2722 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
2725 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
2726 $errormessage = $Lang :: tr
{ 'invalid input for country' };
2729 if ( $cgiparams { 'CERT_PASS1' } ne '' && $cgiparams { 'CERT_PASS2' } ne '' ){
2730 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
2731 $errormessage = $Lang :: tr
{ 'password too short' };
2735 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
2736 $errormessage = $Lang :: tr
{ 'passwords do not match' };
2740 # Replace empty strings with a .
2741 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
2742 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
2743 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
2745 # Create the Host certificate request client
2746 my $pid = open ( OPENSSL
, "|-" );
2747 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto VPNCONF_ERROR
;};
2748 if ( $pid ) { # parent
2749 print OPENSSL
" $cgiparams {'CERT_COUNTRY'} \n " ;
2750 print OPENSSL
" $state \n " ;
2751 print OPENSSL
" $city \n " ;
2752 print OPENSSL
" $cgiparams {'CERT_ORGANIZATION'} \n " ;
2753 print OPENSSL
" $ou \n " ;
2754 print OPENSSL
" $cgiparams {'CERT_NAME'} \n " ;
2755 print OPENSSL
" $cgiparams {'CERT_EMAIL'} \n " ;
2756 print OPENSSL
". \n " ;
2757 print OPENSSL
". \n " ;
2760 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
2761 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}key.pem" );
2762 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}req.pem" );
2766 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
2767 '-newkey' , 'rsa:1024' ,
2768 '-keyout' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
2769 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
2770 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
2771 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
2772 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
2773 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
2778 # Sign the host certificate request
2779 system ( '/usr/bin/openssl' , 'ca' , '-days' , '999999' ,
2780 '-batch' , '-notext' ,
2781 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
2782 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
2783 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
2785 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
2786 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
2787 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
2788 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
2789 & newcleanssldatabase
();
2792 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
2793 & deletebackupcert
();
2796 # Create the pkcs12 file
2797 system ( '/usr/bin/openssl' , 'pkcs12' , '-export' ,
2798 '-inkey' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
2799 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
2800 '-name' , $cgiparams { 'NAME' },
2801 '-passout' , "pass: $cgiparams {'CERT_PASS1'}" ,
2802 '-certfile' , "${General::swroot}/ovpn/ca/cacert.pem" ,
2803 '-caname' , " $vpnsettings {'ROOTCERT_ORGANIZATION'} CA" ,
2804 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
2806 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
2807 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
2808 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
2809 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
2812 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
2814 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
2815 ; # Nothing, just editing
2817 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
2821 # Check if there is no other entry with this common name
2822 if ((! $cgiparams { 'KEY' }) && ( $cgiparams { 'AUTH' } ne 'psk' )) {
2823 foreach my $key ( keys %confighash ) {
2824 if ( $confighash { $key }[ 2 ] eq $cgiparams { 'CERT_NAME' }) {
2825 $errormessage = $Lang :: tr
{ 'a connection with this common name already exists' };
2832 my $key = $cgiparams { 'KEY' };
2834 $key = & General
:: findhasharraykey
( \
%confighash );
2835 foreach my $i ( 0 .. 31 ) { $confighash { $key }[ $i ] = "" ;}
2837 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
2838 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
2839 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
2840 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
2842 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
2843 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
2844 $confighash { $key }[ 4 ] = 'psk' ;
2845 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
2847 $confighash { $key }[ 4 ] = 'cert' ;
2849 if ( $cgiparams { 'TYPE' } eq 'net' ) {
2850 $confighash { $key }[ 6 ] = $cgiparams { 'SIDE' };
2851 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
2853 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
2854 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
2855 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
2856 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
2858 $confighash { $key }[ 27 ] = $cgiparams { 'OVPN_SUBNET' };
2859 $confighash { $key }[ 28 ] = $cgiparams { 'PROTOCOL' };
2860 $confighash { $key }[ 29 ] = $cgiparams { 'DEST_PORT' };
2861 $confighash { $key }[ 30 ] = $cgiparams { 'COMPLZO' };
2862 $confighash { $key }[ 31 ] = $cgiparams { 'MTU' };
2864 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2865 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
2866 $cgiparams { 'KEY' } = $key ;
2867 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
2871 $cgiparams { 'ENABLED' } = 'on' ;
2872 $cgiparams { 'SIDE' } = 'left' ;
2873 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) {
2874 $cgiparams { 'AUTH' } = 'psk' ;
2875 } elsif ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
2876 $cgiparams { 'AUTH' } = 'certfile' ;
2878 $cgiparams { 'AUTH' } = 'certgen' ;
2880 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
2881 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
2882 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
2883 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
2884 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
2888 $checked { 'ENABLED' }{ 'off' } = '' ;
2889 $checked { 'ENABLED' }{ 'on' } = '' ;
2890 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
2891 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
2892 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
2893 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
2894 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
2895 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
2896 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
2899 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
2900 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
2901 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = 'CHECKED' ;
2903 $selected { 'SIDE' }{ 'server' } = '' ;
2904 $selected { 'SIDE' }{ 'client' } = '' ;
2905 $selected { 'SIDE' }{ $cgiparams { 'SIDE' }} = 'SELECTED' ;
2907 $checked { 'AUTH' }{ 'psk' } = '' ;
2908 $checked { 'AUTH' }{ 'certreq' } = '' ;
2909 $checked { 'AUTH' }{ 'certgen' } = '' ;
2910 $checked { 'AUTH' }{ 'certfile' } = '' ;
2911 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = 'CHECKED' ;
2913 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = 'SELECTED' ;
2915 $checked { 'COMPLZO' }{ 'off' } = '' ;
2916 $checked { 'COMPLZO' }{ 'on' } = '' ;
2917 $checked { 'COMPLZO' }{ $cgiparams { 'COMPLZO' }} = 'CHECKED' ;
2921 & Header
:: showhttpheaders
();
2922 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2923 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
2924 if ( $errormessage ) {
2925 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2926 print "<class name='base'> $errormessage " ;
2927 print " </class>" ;
2928 & Header
:: closebox
();
2932 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'warning messages'}:" );
2933 print "<class name='base'> $warnmessage " ;
2934 print " </class>" ;
2935 & Header
:: closebox
();
2938 print "<form method='post' enctype='multipart/form-data'>" ;
2939 print "<input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />" ;
2941 if ( $cgiparams { 'KEY' }) {
2942 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
2943 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
2946 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'connection'}:" );
2947 print "<table width='100%'> \n " ;
2948 print "<tr><td width='25%' class='boldbase'> $Lang ::tr{'name'}:</td>" ;
2949 if ( $cgiparams { 'TYPE' } eq 'host' ) {
2950 if ( $cgiparams { 'KEY' }) {
2951 print "<td width='35%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td> \n " ;
2953 print "<td width='35%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' size='30' /></td>" ;
2955 # print "<tr><td>$Lang::tr{'interface'}</td>";
2956 # print "<td><select name='INTERFACE'>";
2957 # print "<option value='RED' $selected{'INTERFACE'}{'RED'}>RED</option>";
2958 # if ($netsettings{'BLUE_DEV'} ne '') {
2959 # print "<option value='BLUE' $selected{'INTERFACE'}{'BLUE'}>BLUE</option>";
2961 # print "<option value='GREEN' $selected{'INTERFACE'}{'GREEN'}>GREEN</option>";
2962 # print "<option value='ORANGE' $selected{'INTERFACE'}{'ORANGE'}>ORANGE</option>";
2963 # print "</select></td></tr>";
2966 print "<input type='hidden' name='INTERFACE' value='red' />" ;
2967 if ( $cgiparams { 'KEY' }) {
2968 print "<td width='25%' class='base' nowrap='nowrap'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
2970 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' /></td>" ;
2973 <td width='25%'> </td>
2974 <td width='25%'> </td></tr>
2975 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td>
2976 <td><select name='SIDE'><option value='server' $selected {'SIDE'}{'server'}>OpenVPN Server</option>
2977 <option value='client' $selected {'SIDE'}{'client'}>OpenVPN Client</option></select></td>
2978 <td class='boldbase'> $Lang ::tr{'remote host/ip'}:</td>
2979 <td><input type='TEXT' name='REMOTE' value=' $cgiparams {'REMOTE'}' /></td></tr>
2980 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
2981 <td><input type='TEXT' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' /></td>
2982 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
2983 <td><input type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' /></td></tr>
2984 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td>
2985 <td><input type='TEXT' name='OVPN_SUBNET' value=' $cgiparams {'OVPN_SUBNET'}' /></td></tr>
2986 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
2987 <td><select name='PROTOCOL'><option value='udp' $selected {'PROTOCOL'}{'udp'}>UDP</option>
2988 <option value='tcp' $selected {'PROTOCOL'}{'tcp'}>TCP</option></select></td>
2989 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
2990 <td><input type='TEXT' name='DEST_PORT' value=' $cgiparams {'DEST_PORT'}' size='5' /></td></tr>
2991 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td>
2992 <td><input type='checkbox' name='COMPLZO' $checked {'COMPLZO'}{'on'} /></td>
2993 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} <img src='/blob.gif' /></td>
2994 <td> <input type='TEXT' name='MTU' VALUE=' $cgiparams {'MTU'}'size='5' /></TD>
3000 print "<tr><td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' /></td>" ;
3001 print "<td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td></tr>" ;
3003 if ( $cgiparams { 'TYPE' } eq 'host' ) {
3005 print "<tr><td> $Lang ::tr{'enabled'} <input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td> \n " ;
3008 # if ($cgiparams{'KEY'}) {
3009 # print "<td colspan='3'> </td></tr></table>";
3011 # print "<td colspan='3'><input type='checkbox' name='EDIT_ADVANCED' $checked{'EDIT_ADVANCED'}{'on'} /> $Lang::tr{'edit advanced settings when done'}</tr></table>";
3014 print "<td colspan='3'> </td></tr></table>" ;
3019 & Header
:: closebox
();
3021 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
3022 # &Header::openbox('100%', 'LEFT', $Lang::tr{'authentication'});
3024 # <table width='100%' cellpadding='0' cellspacing='5' border='0'>
3025 # <tr><td class='base' width='50%'>$Lang::tr{'use a pre-shared key'}</td>
3026 # <td class='base' width='50%'><input type='text' name='PSK' size='30' value='$cgiparams{'PSK'}' /></td></tr>
3030 # &Header::closebox();
3031 } elsif (! $cgiparams { 'KEY' }) {
3033 my $cakeydisabled = '' ;
3034 my $cacrtdisabled = '' ;
3035 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) { $cakeydisabled = "disabled='disabled'" } else { $cakeydisabled = "" };
3036 if ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) { $cacrtdisabled = "disabled='disabled'" } else { $cacrtdisabled = "" };
3037 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'authentication' });
3040 if ( $cgiparams { 'TYPE' } eq 'host' ) {
3043 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
3044 <tr><td colspan='3' bgcolor='#000000'><img src='/images/null.gif' width='1' height='1' border='0' /></td></tr>
3045 <tr><td><input type='radio' name='AUTH' value='certreq' $checked {'AUTH'}{'certreq'} $cakeydisabled /></td><td class='base'> $Lang ::tr{'upload a certificate request'}</td><td class='base' rowspan='2'><input type='file' name='FH' size='30' $cacrtdisabled ></td></tr>
3046 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td><td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
3047 <tr><td colspan='3' bgcolor='#000000'><img src='/images/null.gif' width='1' height='1' BORDER='0' /></td></tr>
3048 <tr><td><input type='radio' name='AUTH' value='certgen' $checked {'AUTH'}{'certgen'} $cakeydisabled /></td><td class='base'> $Lang ::tr{'generate a certificate'}</td><td> </td></tr>
3049 <tr><td> </td><td class='base'> $Lang ::tr{'users fullname or system hostname'}:</td><td class='base' nowrap='nowrap'><input type='text' name='CERT_NAME' value=' $cgiparams {'CERT_NAME'}' SIZE='32' $cakeydisabled /></td></tr>
3050 <tr><td> </td><td class='base'> $Lang ::tr{'users email'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_EMAIL' value=' $cgiparams {'CERT_EMAIL'}' SIZE='32' $cakeydisabled /></td></tr>
3051 <tr><td> </td><td class='base'> $Lang ::tr{'users department'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_OU' value=' $cgiparams {'CERT_OU'}' SIZE='32' $cakeydisabled /></td></tr>
3052 <tr><td> </td><td class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_ORGANIZATION' value=' $cgiparams {'CERT_ORGANIZATION'}' SIZE='32' $cakeydisabled /></td></tr>
3053 <tr><td> </td><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif'></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_CITY' value=' $cgiparams {'CERT_CITY'}' SIZE='32' $cakeydisabled /></td></tr>
3054 <tr><td> </td><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_STATE' value=' $cgiparams {'CERT_STATE'}' SIZE='32' $cakeydisabled /></td></tr>
3055 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
3060 # m.a.d Disbale upload cert for n2n connections
3066 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
3068 <tr><td><input type='radio' name='AUTH' value='certgen' $checked {'AUTH'}{'certgen'} $cakeydisabled /></td><td class='base'> $Lang ::tr{'generate a certificate'}</td><td> </td></tr>
3069 <tr><td> </td><td class='base'> $Lang ::tr{'users fullname or system hostname'}:</td><td class='base' nowrap='nowrap'><input type='text' name='CERT_NAME' value=' $cgiparams {'CERT_NAME'}' SIZE='32' $cakeydisabled /></td></tr>
3070 <tr><td> </td><td class='base'> $Lang ::tr{'users email'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_EMAIL' value=' $cgiparams {'CERT_EMAIL'}' SIZE='32' $cakeydisabled /></td></tr>
3071 <tr><td> </td><td class='base'> $Lang ::tr{'users department'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_OU' value=' $cgiparams {'CERT_OU'}' SIZE='32' $cakeydisabled /></td></tr>
3072 <tr><td> </td><td class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_ORGANIZATION' value=' $cgiparams {'CERT_ORGANIZATION'}' SIZE='32' $cakeydisabled /></td></tr>
3073 <tr><td> </td><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif'></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_CITY' value=' $cgiparams {'CERT_CITY'}' SIZE='32' $cakeydisabled /></td></tr>
3074 <tr><td> </td><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_STATE' value=' $cgiparams {'CERT_STATE'}' SIZE='32' $cakeydisabled /></td></tr>
3075 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
3083 # m.a.d Disbale upload cert for n2n connections end
3086 foreach my $country ( sort keys %{ Countries
:: countries
}) {
3087 print "<option value=' $Countries ::countries{ $country }'" ;
3088 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
3089 print " selected='selected'" ;
3091 print "> $country </option>" ;
3094 # m.a.d Disbale pkcs-password for n2n connections
3097 if ( $cgiparams { 'TYPE' } eq 'host' ) {
3101 <td class='base'> $Lang ::tr{'valid till'} (days):</td>
3102 <td class='base' nowrap='nowrap'><input type='text' name='DAYS_VALID' value=' $cgiparams {'DAYS_VALID'}' size='32' $cakeydisabled /></td></tr>
3104 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
3105 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
3106 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:<BR>( $Lang ::tr{'confirmation'})</td>
3107 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
3113 <tr><td> </td><td> </td><td> </td></tr>
3114 <tr><td> </td><td> </td><td> </td></tr>
3121 # m.a.d Disbale pkcs-password for n2n connections end
3124 & Header
:: closebox
();
3127 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
3128 if ( $cgiparams { 'KEY' }) {
3129 # print "<input type='submit' name='ACTION' value='$Lang::tr{'advanced'}' />";
3131 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
3132 & Header
:: closebigbox
();
3133 & Header
:: closepage
();
3141 ### Default status page
3146 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
3147 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
3148 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3150 my @status = `/bin/cat /var/log/ovpnserver.log` ;
3152 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
3153 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
3154 my $ipaddr = < IPADDR
>;
3157 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
3158 if ( $cgiparams { 'VPN_IP' } eq '' ) {
3159 $cgiparams { 'VPN_IP' } = $ipaddr ;
3165 if ( $cgiparams { 'DCIPHER' } eq '' ) {
3166 $cgiparams { 'DCIPHER' } = 'BF-CBC' ;
3168 # if ($cgiparams{'DCOMPLZO'} eq '') {
3169 # $cgiparams{'DCOMPLZO'} = 'on';
3171 if ( $cgiparams { 'DDEST_PORT' } eq '' ) {
3172 $cgiparams { 'DDEST_PORT' } = '1194' ;
3174 if ( $cgiparams { 'DMTU' } eq '' ) {
3175 $cgiparams { 'DMTU' } = '1400' ;
3177 if ( $cgiparams { 'DOVPN_SUBNET' } eq '' ) {
3178 $cgiparams { 'DOVPN_SUBNET' } = '10.' . int ( rand ( 256 )) . '.' . int ( rand ( 256 )) . '.0/255.255.255.0' ;
3181 $checked { 'ENABLED' }{ 'off' } = '' ;
3182 $checked { 'ENABLED' }{ 'on' } = '' ;
3183 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
3184 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
3185 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
3186 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
3187 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
3188 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
3189 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
3190 $selected { 'DDEVICE' }{ 'tun' } = '' ;
3191 $selected { 'DDEVICE' }{ 'tap' } = '' ;
3192 $selected { 'DDEVICE' }{ $cgiparams { 'DDEVICE' }} = 'SELECTED' ;
3194 $selected { 'DPROTOCOL' }{ 'udp' } = '' ;
3195 $selected { 'DPROTOCOL' }{ 'tcp' } = '' ;
3196 $selected { 'DPROTOCOL' }{ $cgiparams { 'DPROTOCOL' }} = 'SELECTED' ;
3198 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
3199 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
3200 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
3201 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
3202 $selected { 'DCIPHER' }{ 'RC2-CBC' } = '' ;
3203 $selected { 'DCIPHER' }{ 'RC2-40-CBC' } = '' ;
3204 $selected { 'DCIPHER' }{ 'RC2-64-CBC' } = '' ;
3205 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
3206 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
3207 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
3208 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
3209 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
3210 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
3211 $checked { 'DCOMPLZO' }{ 'off' } = '' ;
3212 $checked { 'DCOMPLZO' }{ 'on' } = '' ;
3213 $checked { 'DCOMPLZO' }{ $cgiparams { 'DCOMPLZO' }} = 'CHECKED' ;
3216 & Header
:: showhttpheaders
();
3217 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
3218 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
3220 if ( $errormessage ) {
3221 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
3222 print "<class name='base'> $errormessage \n " ;
3223 print " </class> \n " ;
3224 & Header
:: closebox
();
3227 my $sactive = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourred}' width='50%'><tr><td align='center'><b><font color='#FFFFFF'> $Lang ::tr{'stopped'}</font></b></td></tr></table>" ;
3228 my $srunning = "no" ;
3229 my $activeonrun = "" ;
3230 if ( - e
"/var/run/openvpn.pid" ){
3231 $sactive = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourgreen}' width='50%'><tr><td align='center'><b><font color='#FFFFFF'> $Lang ::tr{'running'}</font></b></td></tr></table>" ;
3235 $activeonrun = "disabled='disabled'" ;
3237 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'global settings' });
3239 <table width='100%'>
3240 <form method='post'>
3241 <td width='25%'> </td>
3242 <td width='25%'> </td>
3243 <td width='25%'> </td></tr>
3244 <tr><td class='boldbase'> $Lang ::tr{'ovpn server status'}</td>
3245 <td align='left'> $sactive </td>
3246 <tr><td class='boldbase'> $Lang ::tr{'ovpn on red'}</td>
3247 <td><input type='checkbox' name='ENABLED' $checked {'ENABLED'}{'on'} /></td>
3250 if (& haveBlueNet
()) {
3251 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on blue'}</td>" ;
3252 print "<td><input type='checkbox' name='ENABLED_BLUE' $checked {'ENABLED_BLUE'}{'on'} /></td>" ;
3254 if (& haveOrangeNet
()) {
3255 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on orange'}</td>" ;
3256 print "<td><input type='checkbox' name='ENABLED_ORANGE' $checked {'ENABLED_ORANGE'}{'on'} /></td>" ;
3259 <tr><td class='base' nowrap='nowrap' colspan='2'> $Lang ::tr{'local vpn hostname/ip'}:<br /><input type='text' name='VPN_IP' value=' $cgiparams {'VPN_IP'}' size='30' /></td>
3260 <td class='boldbase' nowrap='nowrap' colspan='2'> $Lang ::tr{'ovpn subnet'}<br /><input type='TEXT' name='DOVPN_SUBNET' value=' $cgiparams {'DOVPN_SUBNET'}' size='30' /></td></tr>
3261 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn device'}</td>
3262 <td><select name='DDEVICE' ><option value='tun' $selected {'DDEVICE'}{'tun'}>TUN</option>
3263 <!-- this is still not working
3264 <option value='tap' $selected {'DDEVICE'}{'tap'}>TAP</option></select>--> </td>
3265 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
3266 <td><select name='DPROTOCOL'><option value='udp' $selected {'DPROTOCOL'}{'udp'}>UDP</option>
3267 <option value='tcp' $selected {'DPROTOCOL'}{'tcp'}>TCP</option></select></td>
3268 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
3269 <td><input type='TEXT' name='DDEST_PORT' value=' $cgiparams {'DDEST_PORT'}' size='5' /></td></tr>
3270 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} </td>
3271 <td> <input type='TEXT' name='DMTU' VALUE=' $cgiparams {'DMTU'}'size='5' /></TD>
3272 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td>
3273 <td><input type='checkbox' name='DCOMPLZO' $checked {'DCOMPLZO'}{'on'} /></td>
3274 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td>
3275 <td><select name='DCIPHER'><option value='DES-CBC' $selected {'DCIPHER'}{'DES-CBC'}>DES-CBC</option>
3276 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC</option>
3277 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC</option>
3278 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC</option>
3279 <option value='RC2-CBC' $selected {'DCIPHER'}{'RC2-CBC'}>RC2-CBC</option>
3280 <option value='RC2-40-CBC' $selected {'DCIPHER'}{'RC2-40-CBC'}>RC2-40-CBC</option>
3281 <option value='RC2-64-CBC' $selected {'DCIPHER'}{'RC2-64-CBC'}>RC2-64-CBC</option>
3282 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC</option>
3283 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC</option>
3284 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-128-CBC</option>
3285 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-192-CBC</option>
3286 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-256-CBC</option></select></td>
3290 if ( $srunning eq "yes" ) {
3291 print "<tr><td align='left'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' disabled='disabled' /></td>" ;
3292 print "<td><input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' disabled='disabled'/></td>" ;
3293 print "<td><input type='submit' name='ACTION' value=' $Lang ::tr{'stop ovpn server'}' /></td>" ;
3294 print "<td><input type='submit' name='ACTION' value=' $Lang ::tr{'restart ovpn server'}' /></td></tr>" ;
3296 print "<tr><td align='left'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>" ;
3297 print "<td><input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' /></td>" ;
3298 if (( - e
"${General::swroot}/ovpn/ca/cacert.pem" &&
3299 - e
"${General::swroot}/ovpn/ca/dh1024.pem" &&
3300 - e
"${General::swroot}/ovpn/certs/servercert.pem" &&
3301 - e
"${General::swroot}/ovpn/certs/serverkey.pem" ) &&
3302 (( $cgiparams { 'ENABLED' } eq 'on' ) ||
3303 ( $cgiparams { 'ENABLED_BLUE' } eq 'on' ) ||
3304 ( $cgiparams { 'ENABLED_ORANGE' } eq 'on' ))){
3305 print "<td><input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' /></td>" ;
3306 print "<td><input type='submit' name='ACTION' value=' $Lang ::tr{'restart ovpn server'}' /></td></tr>" ;
3308 print "<td><input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' disabled='disabled' /></td>" ;
3309 print "<td><input type='submit' name='ACTION' value=' $Lang ::tr{'restart ovpn server'}' disabled='disabled' /></td></tr>" ;
3312 print "</form></table>" ;
3313 & Header
:: closebox
();
3314 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate authorities'}:" );
3316 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
3318 <td width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
3319 <td width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></td>
3320 <td width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></td>
3324 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
3325 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
3326 $casubject =~ /Subject: (.*)[\n]/ ;
3328 $casubject =~ s
+/ Email
+, E
+;
3329 $casubject =~ s/ ST=/ S=/ ;
3332 <tr bgcolor=' $color {'color22'}'>
3333 <td class='base'> $Lang ::tr{'root certificate'}</td>
3334 <td class='base'> $casubject </td>
3335 <form method='post' name='frmrootcrta'><td width='3%' align='center'>
3336 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
3337 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/info.gif' alt=' $Lang ::tr{'show root certificate'}' title=' $Lang ::tr{'show root certificate'}' width='20' height='20' border='0' />
3339 <form method='post' name='frmrootcrtb'><td width='3%' align='center'>
3340 <input type='image' name=' $Lang ::tr{'download root certificate'}' src='/images/media-floppy.png' alt=' $Lang ::tr{'download root certificate'}' title=' $Lang ::tr{'download root certificate'}' border='0' />
3341 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
3343 <td width='4%'> </td></tr>
3347 # display rootcert generation buttons
3349 <tr bgcolor=' $color {'color22'}'>
3350 <td class='base'> $Lang ::tr{'root certificate'}:</td>
3351 <td class='base'> $Lang ::tr{'not present'}</td>
3352 <td colspan='3'> </td></tr>
3357 if (- f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
3358 my $hostsubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
3359 $hostsubject =~ /Subject: (.*)[\n]/ ;
3361 $hostsubject =~ s
+/ Email
+, E
+;
3362 $hostsubject =~ s/ ST=/ S=/ ;
3365 <tr bgcolor=' $color {'color20'}'>
3366 <td class='base'> $Lang ::tr{'host certificate'}</td>
3367 <td class='base'> $hostsubject </td>
3368 <form method='post' name='frmhostcrta'><td width='3%' align='center'>
3369 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
3370 <input type='image' name=' $Lang ::tr{'show host certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show host certificate'}' title=' $Lang ::tr{'show host certificate'}' width='20' height='20' border='0' />
3372 <form method='post' name='frmhostcrtb'><td width='3%' align='center'>
3373 <input type='image' name=' $Lang ::tr{'download host certificate'}' src='/images/media-floppy.png' alt=' $Lang ::tr{'download host certificate'}' title=' $Lang ::tr{'download host certificate'}' border='0' />
3374 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download host certificate'}' />
3376 <td width='4%'> </td></tr>
3382 <tr bgcolor=' $color {'color20'}'>
3383 <td width='25%' class='base'> $Lang ::tr{'host certificate'}:</td>
3384 <td class='base'> $Lang ::tr{'not present'}</td>
3385 </td><td colspan='3'> </td></tr>
3390 if (! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
3391 print "<tr><td colspan='5' align='center'><form method='post'>" ;
3392 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' />" ;
3393 print "</form></td></tr> \n " ;
3396 if ( keys %cahash > 0 ) {
3397 foreach my $key ( keys %cahash ) {
3398 if (( $key + 1 ) % 2 ) {
3399 print "<tr bgcolor=' $color {'color20'}'> \n " ;
3401 print "<tr bgcolor=' $color {'color22'}'> \n " ;
3403 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
3404 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
3406 <form method='post' name='cafrm${key}a'><td align='center'>
3407 <input type='image' name=' $Lang ::tr{'show ca certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show ca certificate'}' title=' $Lang ::tr{'show ca certificate'}' border='0' />
3408 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
3409 <input type='hidden' name='KEY' value=' $key ' />
3411 <form method='post' name='cafrm${key}b'><td align='center'>
3412 <input type='image' name=' $Lang ::tr{'download ca certificate'}' src='/images/media-floppy.png' alt=' $Lang ::tr{'download ca certificate'}' title=' $Lang ::tr{'download ca certificate'}' border='0' />
3413 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
3414 <input type='hidden' name='KEY' value=' $key ' />
3416 <form method='post' name='cafrm${key}c'><td align='center'>
3417 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
3418 <input type='image' name=' $Lang ::tr{'remove ca certificate'}' src='/images/delete.gif' alt=' $Lang ::tr{'remove ca certificate'}' title=' $Lang ::tr{'remove ca certificate'}' width='20' height='20' border='0' />
3419 <input type='hidden' name='KEY' value=' $key ' />
3428 # If the file contains entries, print Key to action icons
3429 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
3433 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
3434 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
3435 <td class='base'> $Lang ::tr{'show certificate'}</td>
3436 <td> <img src='/images/media-floppy.png' alt=' $Lang ::tr{'download certificate'}' /></td>
3437 <td class='base'> $Lang ::tr{'download certificate'}</td>
3444 <form method='post' enctype='multipart/form-data'>
3445 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
3446 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}:</td>
3447 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' />
3448 <td nowrap='nowrap'><input type='file' name='FH' size='30' /></td>
3449 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /><br /><input type='submit' name='ACTION' value=' $Lang ::tr{'show crl'}' /></td>
3450 </tr></table></form>
3454 & Header
:: closebox
();
3455 if ( $srunning eq "yes" ) {
3456 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'reset'}' disabled='disabled' /></div></form> \n " ;
3458 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'reset'}' /></div></form> \n " ;
3460 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
3463 # m.a.d Client Status Table
3466 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'Client status and controlc' });
3470 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
3472 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
3473 <td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></td>
3474 <td width='18%' class='boldbase' align='center'><b> $Lang ::tr{'common name'}</b></td>
3475 <td width='17%' class='boldbase' align='center'><b> $Lang ::tr{'valid till'}</b></td>
3476 <td width='25%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b><br /><img src='/images/null.gif' width='125' height='1' border='0' alt='L2089' /></td>
3477 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></td>
3478 <td width='5%' class='boldbase' colspan='6' align='center'><b> $Lang ::tr{'action'}</b></td>
3484 foreach my $key ( keys %confighash ) {
3485 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
3488 print "<tr bgcolor=' $color {'color20'}'> \n " ;
3490 print "<tr bgcolor=' $color {'color22'}'> \n " ;
3492 print "<td align='center' nowrap='nowrap'> $confighash { $key }[1]</td>" ;
3493 print "<td align='center' nowrap='nowrap'>" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
3494 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
3495 print "<td align='left' nowrap='nowrap'> $confighash { $key }[2]</td>" ;
3497 print "<td align='left'> </td>" ;
3499 my $cavalid = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
3500 $cavalid =~ /Not After : (.*)[\n]/ ;
3502 print "<td align='center'> $cavalid </td>" ;
3503 print "<td align='center'> $confighash { $key }[25]</td>" ;
3505 my $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourred}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b></td></tr></table>" ;
3507 if ( $confighash { $key }[ 0 ] eq 'off' ) {
3508 $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourblue}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b></td></tr></table>" ;
3512 # m.a.d net2net Status
3515 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'host' ){
3519 foreach my $line ( @status ) {
3522 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
3523 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
3524 if ( $match [ 1 ] ne "Common Name" ) {
3528 if ( $cn eq " $confighash { $key }[2]" ) {
3529 $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourblue}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b></td></tr></table>" ;
3534 my @tempovpnsubnet = split ( "\/" , $confighash { $key }[ 27 ]);
3535 my @ovpnip = split /\./ , $tempovpnsubnet [ 0 ];
3538 if ( $confighash { $key }[ 6 ] eq 'server' ) {
3539 $pingip = " $ovpnip [0]. $ovpnip [1]. $ovpnip [2].2" ;
3541 $pingip = " $ovpnip [0]. $ovpnip [1]. $ovpnip [2].1" ;
3544 my $p = Net
:: Ping
-> new ( "udp" , 1 );
3546 if ( $p -> ping ( $pingip )) {
3547 $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourgreen}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b></td></tr></table>" ;
3555 # m.a.d net2net Status end
3559 my $disable_clientdl = "disabled='disabled'" ;
3560 if (( $cgiparams { 'ENABLED' } eq 'on' ) ||
3561 ( $cgiparams { 'ENABLED_BLUE' } eq 'on' ) ||
3562 ( $cgiparams { 'ENABLED_ORANGE' } eq 'on' )){
3563 $disable_clientdl = "" ;
3566 <td align='center'> $active </td>
3568 <form method='post' name='frm${key}a'><td align='center'>
3569 <input type='image' name=' $Lang ::tr{'dl client arch'}' $disable_clientdl src='/images/openvpn.png' alt=' $Lang ::tr{'dl client arch'}' title=' $Lang ::tr{'dl client arch'}' border='0' />
3570 <input type='hidden' name='ACTION' value=' $Lang ::tr{'dl client arch'}' $disable_clientdl />
3571 <input type='hidden' name='KEY' value=' $key ' $disable_clientdl />
3575 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
3577 <form method='post' name='frm${key}b'><td align='center'>
3578 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' border='0' />
3579 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
3580 <input type='hidden' name='KEY' value=' $key ' />
3584 print "<td> </td>" ;
3586 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" ) {
3588 <form method='post' name='frm${key}c'><td align='center'>
3589 <input type='image' name=' $Lang ::tr{'download pkcs12 file'}' src='/images/media-floppy.png' alt=' $Lang ::tr{'download pkcs12 file'}' title=' $Lang ::tr{'download pkcs12 file'}' border='0' />
3590 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
3591 <input type='hidden' name='KEY' value=' $key ' />
3594 ; } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
3596 <form method='post' name='frm${key}c'><td align='center'>
3597 <input type='image' name=' $Lang ::tr{'download certificate'}' src='/images/media-floppy.png' alt=' $Lang ::tr{'download certificate'}' title=' $Lang ::tr{'download certificate'}' border='0' />
3598 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
3599 <input type='hidden' name='KEY' value=' $key ' />
3603 print "<td> </td>" ;
3606 <form method='post' name='frm${key}d'><td align='center'>
3607 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' alt=' $Lang ::tr{'toggle enable disable'}' title=' $Lang ::tr{'toggle enable disable'}' border='0' />
3608 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
3609 <input type='hidden' name='KEY' value=' $key ' />
3612 <form method='post' name='frm${key}e'><td align='center'>
3613 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
3614 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' width='20' height='20' border='0'/>
3615 <input type='hidden' name='KEY' value=' $key ' />
3617 <form method='post' name='frm${key}f'><td align='center'>
3618 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
3619 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' width='20' height='20' border='0' />
3620 <input type='hidden' name='KEY' value=' $key ' />
3629 # If the config file contains entries, print Key to action icons
3634 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
3635 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
3636 <td class='base'> $Lang ::tr{'click to disable'}</td>
3637 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
3638 <td class='base'> $Lang ::tr{'show certificate'}</td>
3639 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
3640 <td class='base'> $Lang ::tr{'edit'}</td>
3641 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
3642 <td class='base'> $Lang ::tr{'remove'}</td>
3646 <td> <img src='/images/off.gif' alt='?OFF' /></td>
3647 <td class='base'> $Lang ::tr{'click to enable'}</td>
3648 <td> <img src='/images/media-floppy.png' alt='?FLOPPY' /></td>
3649 <td class='base'> $Lang ::tr{'download certificate'}</td>
3650 <td> <img src='/images/openvpn.png' alt='?RELOAD'/></td>
3651 <td class='base'> $Lang ::tr{'dl client arch'}</td>
3659 <table width='100%'>
3660 <form method='post'>
3661 <tr><td width='50%' ><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
3662 <td width='50%' ><input type='submit' name='ACTION' value=' $Lang ::tr{'ovpn con stat'}' $activeonrun /></td></tr>
3667 & Header
:: closebox
();
3669 & Header
:: closepage
();