]>
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-2011 IPFire Team <info@ipfire.org> #
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 ###############################################################################
22 # Based on IPFireCore 55
25 use CGI qw
/:standard/ ;
30 use File
:: Temp qw
/ tempfile tempdir / ;
32 use Archive
:: Zip
qw(:ERROR_CODES :CONSTANTS) ;
33 require '/var/ipfire/general-functions.pl' ;
34 require "${General::swroot}/lang.pl" ;
35 require "${General::swroot}/header.pl" ;
36 require "${General::swroot}/countries.pl" ;
38 # enable only the following on debugging purpose
40 #use CGI::Carp 'fatalsToBrowser';
41 #workaround to suppress a warning when a variable is used only once
42 my @dummy = ( ${ Header
:: colourgreen
}, ${ Header
:: colourblue
} );
46 my %mainsettings = ();
47 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
48 & General
:: readhash
( "/srv/web/ipfire/html/themes/" . $mainsettings { 'THEME' }. "/include/colors.txt" , \
%color );
51 ### Initialize variables
64 my $errormessage = '' ;
66 my $routes_push_file = '' ;
67 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
68 $cgiparams { 'ENABLED' } = 'off' ;
69 $cgiparams { 'ENABLED_BLUE' } = 'off' ;
70 $cgiparams { 'ENABLED_ORANGE' } = 'off' ;
71 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
72 $cgiparams { 'NAT' } = 'off' ;
73 $cgiparams { 'COMPRESSION' } = 'off' ;
74 $cgiparams { 'ONLY_PROPOSED' } = 'off' ;
75 $cgiparams { 'ACTION' } = '' ;
76 $cgiparams { 'CA_NAME' } = '' ;
77 $cgiparams { 'DHCP_DOMAIN' } = '' ;
78 $cgiparams { 'DHCP_DNS' } = '' ;
79 $cgiparams { 'DHCP_WINS' } = '' ;
80 $cgiparams { 'ROUTES_PUSH' } = '' ;
81 $cgiparams { 'DCOMPLZO' } = 'off' ;
82 $cgiparams { 'MSSFIX' } = '' ;
83 $cgiparams { 'number' } = '' ;
84 $cgiparams { 'PMTU_DISCOVERY' } = '' ;
85 $routes_push_file = "${General::swroot}/ovpn/routes_push" ;
86 unless (- e
$routes_push_file ) { system ( "touch $routes_push_file " ); }
87 unless (- e
"${General::swroot}/ovpn/ccd.conf" ) { system ( "touch ${General::swroot}/ovpn/ccd.conf" ); }
88 unless (- e
"${General::swroot}/ovpn/ccdroute" ) { system ( "touch ${General::swroot}/ovpn/ccdroute" ); }
89 unless (- e
"${General::swroot}/ovpn/ccdroute2" ) { system ( "touch ${General::swroot}/ovpn/ccdroute2" ); }
91 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
93 # prepare openvpn config file
99 if ( $netsettings { 'CONFIG_TYPE' } == 2 ) { return 1 ;}
100 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
106 if ( $netsettings { 'CONFIG_TYPE' } == 3 ) { return 1 ;}
107 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
112 my $bytesize = shift ;
115 while ( abs ( $bytesize ) >= 1024 ){
116 $bytesize = $bytesize / 1024 ;
121 my @units = ( "Bytes" , "KB" , "MB" , "GB" , "TB" , "PB" , "EB" );
122 my $newsize =( int ( $bytesize * 100 + 0.5 ))/ 100 ;
123 return ( " $newsize $units [ $i ]" );
127 my $hostname = $_ [ 0 ];
128 unless ( $hostname ) { return "No hostname" };
129 my $res = new Net
:: DNS
:: Resolver
;
130 my $query = $res -> search ( " $hostname " );
132 foreach my $rr ( $query -> answer ) {
133 ## Potential bug - we are only looking at A records:
134 return 0 if $rr -> type eq "A" ;
137 return $res -> errorstring ;
143 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/serial" )) {
147 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/index.txt" )) {
151 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
152 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
153 unlink ( "${General::swroot}/ovpn/certs/01.pem" );
156 sub newcleanssldatabase
158 if (! - s
"${General::swroot}/ovpn/certs/serial" ) {
159 open ( FILE
, ">${General::swroot}(ovpn/certs/serial" );
163 if (! - s
">${General::swroot}/ovpn/certs/index.txt" ) {
164 system ( "touch ${General::swroot}/ovpn/certs/index.txt" );
166 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
167 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
172 if ( open ( FILE
, "${General::swroot}/ovpn/certs/serial.old" )) {
173 my $hexvalue = < FILE
>;
176 unlink ( "${General::swroot}/ovpn/certs/ $hexvalue .pem" );
181 my $KEY2 = $_ [ 0 ]; # key2
182 my $SRC_PORT = $_ [ 1 ]; # src_port
183 my $PROTOCOL = $_ [ 2 ]; # protocol
184 my $SRC_IP = $_ [ 3 ]; # sourceip
186 my $pfwfilename = "${General::swroot}/portfw/config" ;
187 open ( FILE
, $pfwfilename ) or die 'Unable to open config file.' ;
188 my @pfwcurrent = < FILE
>;
190 my $pfwkey1 = 0 ; # used for finding last sequence number used
191 foreach my $pfwline ( @pfwcurrent )
193 my @pfwtemp = split ( /\,/ , $pfwline );
196 if ( $KEY2 eq "0" ){ # if key2 is 0 then it is a portfw addition
197 if ( $SRC_PORT eq $pfwtemp [ 3 ] &&
198 $PROTOCOL eq $pfwtemp [ 2 ] &&
199 $SRC_IP eq $pfwtemp [ 7 ])
201 $errormessage = " $Lang ::tr{'source port in use'} $SRC_PORT " ;
203 # Check if key2 = 0, if it is then it is a port forward entry and we want the sequence number
204 if ( $pfwtemp [ 1 ] eq "0" ) {
205 $pfwkey1 = $pfwtemp [ 0 ];
207 # Darren Critchley - Duplicate or overlapping Port range check
208 if ( $pfwtemp [ 1 ] eq "0" &&
209 $PROTOCOL eq $pfwtemp [ 2 ] &&
210 $SRC_IP eq $pfwtemp [ 7 ] &&
213 & portchecks
( $SRC_PORT , $pfwtemp [ 5 ]);
214 # &portchecks($pfwtemp[3], $pfwtemp[5]);
215 # &portchecks($pfwtemp[3], $SRC_IP);
219 # $errormessage="$KEY2 $SRC_PORT $PROTOCOL $SRC_IP";
226 my $portrange1 = $_ [ 0 ]; # New port range
227 my $portrange2 = $_ [ 1 ]; # existing port range
228 my @tempr1 = split ( /\:/ , $portrange1 );
229 my @tempr2 = split ( /\:/ , $portrange2 );
231 unless (& checkportinc
( $tempr1 [ 0 ], $portrange2 )){ return 0 ;}
232 unless (& checkportinc
( $tempr1 [ 1 ], $portrange2 )){ return 0 ;}
234 unless (& checkportinc
( $tempr2 [ 0 ], $portrange1 )){ return 0 ;}
235 unless (& checkportinc
( $tempr2 [ 1 ], $portrange1 )){ return 0 ;}
237 return 1 ; # Everything checks out!
240 # Darren Critchley - we want to make sure that a port entry is not within an already existing range
243 my $port1 = $_ [ 0 ]; # Port
244 my $portrange2 = $_ [ 1 ]; # Port range
245 my @tempr1 = split ( /\:/ , $portrange2 );
247 if ( $port1 < $tempr1 [ 0 ] || $port1 > $tempr1 [ 1 ]) {
253 # Darren Critchley - Duplicate or overlapping Port range check
256 my $p1 = $_ [ 0 ]; # New port range
257 my $p2 = $_ [ 1 ]; # existing port range
259 our ( $prtrange1 , $prtrange2 );
261 # if (m/:/ && $prtrange1 == 1) { # comparing two port ranges
262 # unless (&checkportoverlap($p1,$p2)) {
263 # $errormessage = "$Lang::tr{'source port overlaps'} $p1";
266 if ( m/:/ && $prtrange1 == 0 && $errormessage eq '' ) { # compare one port to a range
267 unless (& checkportinc
( $p2 , $p1 )) {
268 $errormessage = " $Lang ::tr{'srcprt within existing'} $p1 " ;
272 if (! m/:/ && $prtrange1 == 1 && $errormessage eq '' ) { # compare one port to a range
273 unless (& checkportinc
( $p1 , $p2 )) {
274 $errormessage = " $Lang ::tr{'srcprt range overlaps'} $p2 " ;
280 # Darren Critchley - certain ports are reserved for IPFire
281 # TCP 67,68,81,222,445
283 # Params passed in -> port, rangeyn, protocol
286 # port 67 and 68 same for tcp and udp, don't bother putting in an array
288 my @tcp_reserved = ( 81 , 222 , 445 );
289 my $prt = $_ [ 0 ]; # the port or range
290 my $ryn = $_ [ 1 ]; # tells us whether or not it is a port range
291 my $prot = $_ [ 2 ]; # protocol
292 my $srcdst = $_ [ 3 ]; # source or destination
293 if ( $ryn ) { # disect port range
294 if ( $srcdst eq "src" ) {
295 $msg = " $Lang ::tr{'rsvd src port overlap'}" ;
297 $msg = " $Lang ::tr{'rsvd dst port overlap'}" ;
299 my @tmprng = split ( /\:/ , $prt );
300 unless ( 67 < $tmprng [ 0 ] || 67 > $tmprng [ 1 ]) { $errormessage = " $msg 67" ; return ; }
301 unless ( 68 < $tmprng [ 0 ] || 68 > $tmprng [ 1 ]) { $errormessage = " $msg 68" ; return ; }
302 if ( $prot eq "tcp" ) {
303 foreach my $prange ( @tcp_reserved ) {
304 unless ( $prange < $tmprng [ 0 ] || $prange > $tmprng [ 1 ]) { $errormessage = " $msg $prange " ; return ; }
308 if ( $srcdst eq "src" ) {
309 $msg = " $Lang ::tr{'reserved src port'}" ;
311 $msg = " $Lang ::tr{'reserved dst port'}" ;
313 if ( $prt == 67 ) { $errormessage = " $msg 67" ; return ; }
314 if ( $prt == 68 ) { $errormessage = " $msg 68" ; return ; }
315 if ( $prot eq "tcp" ) {
316 foreach my $prange ( @tcp_reserved ) {
317 if ( $prange == $prt ) { $errormessage = " $msg $prange " ; return ; }
325 sub writeserverconf
{
326 my %sovpnsettings = ();
328 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%sovpnsettings );
331 open ( CONF
, ">${General::swroot}/ovpn/server.conf" ) or die "Unable to open ${General::swroot}/ovpn/server.conf: $!" ;
333 print CONF
"#OpenVPN Server conf \n " ;
335 print CONF
"daemon openvpnserver \n " ;
336 print CONF
"writepid /var/run/openvpn.pid \n " ;
337 print CONF
"#DAN prepare OpenVPN for listening on blue and orange \n " ;
338 print CONF
";local $sovpnsettings {'VPN_IP'} \n " ;
339 print CONF
"dev $sovpnsettings {'DDEVICE'} \n " ;
340 print CONF
"proto $sovpnsettings {'DPROTOCOL'} \n " ;
341 print CONF
"port $sovpnsettings {'DDEST_PORT'} \n " ;
342 print CONF
"script-security 3 system \n " ;
343 print CONF
"ifconfig-pool-persist /var/ipfire/ovpn/ovpn-leases.db 3600 \n " ;
344 print CONF
"client-config-dir /var/ipfire/ovpn/ccd \n " ;
345 print CONF
"tls-server \n " ;
346 print CONF
"ca /var/ipfire/ovpn/ca/cacert.pem \n " ;
347 print CONF
"cert /var/ipfire/ovpn/certs/servercert.pem \n " ;
348 print CONF
"key /var/ipfire/ovpn/certs/serverkey.pem \n " ;
349 print CONF
"dh /var/ipfire/ovpn/ca/dh1024.pem \n " ;
350 my @tempovpnsubnet = split ( "\/" , $sovpnsettings { 'DOVPN_SUBNET' });
351 print CONF
"server $tempovpnsubnet [0] $tempovpnsubnet [1] \n " ;
352 #print CONF "push \"route $netsettings{'GREEN_NETADDRESS'} $netsettings{'GREEN_NETMASK'}\"\n";
354 # Check if we are using mssfix, fragment or mtu-disc and set the corretct mtu of 1500.
355 # If we doesn't use one of them, we can use the configured mtu value.
356 if ( $sovpnsettings { 'MSSFIX' } eq 'on' )
357 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
358 elsif ( $sovpnsettings { 'FRAGMENT' } ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' )
359 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
360 elsif ( $sovpnsettings { 'PMTU_DISCOVERY' } ne 'off' )
361 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
363 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu $sovpnsettings {'DMTU'} \n " ; }
365 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
366 @temp = split ( /\n/ , $vpnsettings { 'ROUTES_PUSH' });
369 @tempovpnsubnet = split ( "\/" ,& General
:: ipcidr2msk
( $_ ));
370 print CONF
"push \" route " . $tempovpnsubnet [ 0 ]. " " . $tempovpnsubnet [ 1 ] . " \"\n " ;
375 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
376 foreach my $key ( keys %ccdconfhash ) {
377 my $a = $ccdconfhash { $key }[ 1 ];
378 my ( $b , $c ) = split ( /\/ /, $a );
379 print CONF
"route $b " .& General
:: cidrtosub
( $c ). " \n " ;
382 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
383 foreach my $key ( keys %ccdroutehash ) {
384 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
385 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
386 print CONF
"route $a $b \n " ;
391 if ( $sovpnsettings { CLIENT2CLIENT
} eq 'on' ) {
392 print CONF
"client-to-client \n " ;
394 if ( $sovpnsettings { MSSFIX
} eq 'on' ) {
395 print CONF
"mssfix \n " ;
397 if ( $sovpnsettings { FRAGMENT
} ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' ) {
398 print CONF
"fragment $sovpnsettings {'FRAGMENT'} \n " ;
401 if ( $sovpnsettings { PMTU_DISCOVERY
} ne 'off' ) {
402 print CONF
"mtu-disc $sovpnsettings {'PMTU_DISCOVERY'} \n " ;
405 if ( $sovpnsettings { KEEPALIVE_1
} > 0 && $sovpnsettings { KEEPALIVE_2
} > 0 ) {
406 print CONF
"keepalive $sovpnsettings {'KEEPALIVE_1'} $sovpnsettings {'KEEPALIVE_2'} \n " ;
408 print CONF
"status-version 1 \n " ;
409 print CONF
"status /var/log/ovpnserver.log 30 \n " ;
410 print CONF
"cipher $sovpnsettings {DCIPHER} \n " ;
411 if ( $sovpnsettings { DCOMPLZO
} eq 'on' ) {
412 print CONF
"comp-lzo \n " ;
414 if ( $sovpnsettings { REDIRECT_GW_DEF1
} eq 'on' ) {
415 print CONF
"push \" redirect-gateway def1 \"\n " ;
417 if ( $sovpnsettings { DHCP_DOMAIN
} ne '' ) {
418 print CONF
"push \" dhcp-option DOMAIN $sovpnsettings {DHCP_DOMAIN} \"\n " ;
421 if ( $sovpnsettings { DHCP_DNS
} ne '' ) {
422 print CONF
"push \" dhcp-option DNS $sovpnsettings {DHCP_DNS} \"\n " ;
425 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
426 print CONF
"push \" dhcp-option WINS $sovpnsettings {DHCP_WINS} \"\n " ;
429 if ( $sovpnsettings { DHCP_WINS
} eq '' ) {
430 print CONF
"max-clients 100 \n " ;
432 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
433 print CONF
"max-clients $sovpnsettings {MAX_CLIENTS} \n " ;
435 print CONF
"tls-verify /var/ipfire/ovpn/verify \n " ;
436 print CONF
"crl-verify /var/ipfire/ovpn/crls/cacrl.pem \n " ;
437 print CONF
"user nobody \n " ;
438 print CONF
"group nobody \n " ;
439 print CONF
"persist-key \n " ;
440 print CONF
"persist-tun \n " ;
441 if ( $sovpnsettings { LOG_VERB
} ne '' ) {
442 print CONF
"verb $sovpnsettings {LOG_VERB} \n " ;
444 print CONF
"verb 3 \n " ;
452 if ( open ( FILE
, ">/var/log/ovpnserver.log" )) {
462 my %ccdconfhash = ();
464 my $ccdnetname = $_ [ 0 ];
465 if (- f
"${General::swroot}/ovpn/ovpnconfig" ){
466 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
467 foreach my $key ( keys %ccdhash ) {
468 if ( $ccdhash { $key }[ 32 ] eq $ccdnetname ) {
469 $errormessage = $Lang :: tr
{ 'ccd err hostinnet' };
474 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
475 foreach my $key ( keys %ccdconfhash ) {
476 if ( $ccdconfhash { $key }[ 0 ] eq $ccdnetname ){
477 delete $ccdconfhash { $key };
480 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
492 my $ovpnsubnet = $_ [ 2 ];
498 if (!& General
:: validhostname
( $ccdname )){
499 $errormessage = $Lang :: tr
{ 'ccd err invalidname' };
503 if (& General
:: validipandmask
( $ccdnet )){
504 $ccdnet =& General
:: iporsubtocidr
( $ccdnet );
506 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
509 ( $ccdip , $subcidr ) = split ( /\/ /, $ccdnet );
510 if ( $ccdname eq '' ) {
511 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err name' }. "<br>" ;
513 #check if we try to use same network as ovpn server
514 if (& General
:: iporsubtocidr
( $ccdnet ) eq & General
:: iporsubtocidr
( $ovpnsubnet )) {
515 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err isovpnnet' }. "<br>" ;
518 #check if we use a name/subnet that already exists
519 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
520 foreach my $key ( keys %ccdconfhash ) {
521 @ccdconf = split ( /\/ /, $ccdconfhash { $key }[ 1 ]);
522 if ( $ccdname eq $ccdconfhash { $key }[ 0 ]) { $errormessage = $errormessage . $Lang :: tr
{ 'ccd err nameexist' }. "<br>" ;}
523 my ( $newip , $newsub ) = split ( /\/ /, $ccdnet );
524 if (& General
:: IpInSubnet
( $newip , $ccdconf [ 0 ],& General
:: iporsubtodec
( $ccdconf [ 1 ]))) { $errormessage = $errormessage . $Lang :: tr
{ 'ccd err issubnet' }. "<br>" ;}
527 #check if we use one of ipfire's networks (green,orange,blue)
529 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%ownnet );
530 if (( $ownnet { 'GREEN_NETADDRESS' } ne '' && $ownnet { 'GREEN_NETADDRESS' } ne '0.0.0.0' ) && & General
:: IpInSubnet
( $ownnet { 'GREEN_NETADDRESS' }, $ccdip ,& General
:: iporsubtodec
( $subcidr ))){ $errormessage = $Lang :: tr
{ 'ccd err green' };}
531 if (( $ownnet { 'ORANGE_NETADDRESS' } ne '' && $ownnet { 'ORANGE_NETADDRESS' } ne '0.0.0.0' ) && & General
:: IpInSubnet
( $ownnet { 'ORANGE_NETADDRESS' }, $ccdip ,& General
:: iporsubtodec
( $subcidr ))){ $errormessage = $Lang :: tr
{ 'ccd err orange' };}
532 if (( $ownnet { 'BLUE_NETADDRESS' } ne '' && $ownnet { 'BLUE_NETADDRESS' } ne '0.0.0.0' ) && & General
:: IpInSubnet
( $ownnet { 'BLUE_NETADDRESS' }, $ccdip ,& General
:: iporsubtodec
( $subcidr ))){ $errormessage = $Lang :: tr
{ 'ccd err blue' };}
533 if (( $ownnet { 'RED_NETADDRESS' } ne '' && $ownnet { 'RED_NETADDRESS' } ne '0.0.0.0' ) && & General
:: IpInSubnet
( $ownnet { 'RED_NETADDRESS' }, $ccdip ,& General
:: iporsubtodec
( $subcidr ))){ $errormessage = $Lang :: tr
{ 'ccd err red' };}
536 if (! $errormessage ) {
538 $baseaddress =& General
:: getnetworkip
( $ccdip , $subcidr );
539 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
540 my $key = & General
:: findhasharraykey
( \
%ccdconfhash );
541 foreach my $i ( 0 .. 1 ) { $ccdconfhash { $key }[ $i ] = "" ;}
542 $ccdconfhash { $key }[ 0 ] = $ccdname ;
543 $ccdconfhash { $key }[ 1 ] = $baseaddress . "/" . $subcidr ;
544 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
546 $cgiparams { 'ccdname' }= '' ;
547 $cgiparams { 'ccdsubnet' }= '' ;
559 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
560 foreach my $key ( keys %ccdconfhash ) {
561 if ( $ccdconfhash { $key }[ 0 ] eq $oldname ) {
562 foreach my $key1 ( keys %ccdconfhash ) {
563 if ( $ccdconfhash { $key1 }[ 0 ] eq $newname ){
564 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err netadrexist' };
567 $ccdconfhash { $key }[ 0 ]= $newname ;
568 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
575 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
576 foreach my $key ( keys %ccdhash ) {
577 if ( $ccdhash { $key }[ 32 ] eq $oldname ) {
578 $ccdhash { $key }[ 32 ]= $newname ;
579 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
588 my $ccdnetwork = $_ [ 0 ];
591 @octets = split ( "\/" , $ccdnetwork );
592 @subnet = split /\./ , & General
:: cidrtosub
( $octets [ 1 ]);
605 my ( $ip1 , $ip2 , $ip3 , $ip4 )= split /\./ , $ipin ;
613 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
614 $iprange [ 0 ]= $ip1 . "." . $ip2 . "." . $ip3 . "." .2 ;
615 for ( my $i = 0 ; $i <= $count - 1 ; $i ++) {
616 my $tmpip = $iprange [ $i - 1 ];
618 $iprange [ $i ]= & General
:: getnextip
( $tmpip , 4 );
621 foreach my $key ( keys %ccdhash ) {
623 foreach my $tmp ( @iprange ){
624 my ( $net , $sub ) = split ( /\/ /, $ccdhash { $key }[ 33 ]);
626 if ( $hasip ne $ccdhash { $key }[ 33 ] ){
627 splice ( @iprange , $r , 1 );
639 my ( $ccdip , $subcidr ) = split ( "/" , $_ [ 0 ]);
641 my @allccdips =& getccdadresses
( $ccdip , $subcidr ,& ccdmaxclients
( $ccdip . "/" . $subcidr ), $tz );
642 print "<select name=' $boxname ' STYLE='font-family : arial; font-size : 9pt; width:130px;' >" ;
643 foreach ( @allccdips ) {
646 print "<option value=' $ip ' " ;
647 if ( $ip eq $cgiparams { $boxname } ){
650 print "> $ip </option>" ;
660 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
661 foreach my $key ( keys %ccdhash ) {
662 if ( $ccdhash { $key }[ 32 ] eq $name ){ $i ++;}
667 sub check_routes_push
670 my ( $ip , $cidr ) = split ( /\/ /, $val );
671 ##check for existing routes in routes_push
672 if (- e
"${General::swroot}/ovpn/routes_push" ) {
673 open ( FILE
, "${General::swroot}/ovpn/routes_push" );
677 my ( $ip2 , $cidr2 ) = split ( /\/ /, " $_ " );
678 my $val2 = $ip2 . "/" .& General
:: iporsubtodec
( $cidr2 );
684 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: iporsubtodec
( $cidr2 ))){
697 my ( $ip , $cidr ) = split ( /\/ /, $val );
698 #check for existing routes in ccdroute
699 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
700 foreach my $key ( keys %ccdroutehash ) {
701 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
702 if (& General
:: iporsubtodec
( $val ) eq $ccdroutehash { $key }[ $i ] && $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' }){
705 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
707 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )&& $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' } ){
718 my ( $ip , $cidr ) = split ( /\/ /, $val );
719 #check for existing routes in ccdroute
720 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
721 foreach my $key ( keys %ccdconfhash ) {
722 if (& General
:: iporsubtocidr
( $val ) eq $ccdconfhash { $key }[ 1 ]){
725 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdconfhash { $key }[ 1 ]);
727 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: cidrtosub
( $cidr2 ))){
741 my $ipdotmask = $_ [ 0 ];
742 if (& General
:: validip
( $ipdotmask )) { return 0 ; }
743 if (!( $ipdotmask =~ /^(.*?)\/ (.* ?
)$/)) { }
745 if (( $mask =~ /\./ )) { return 0 ; }
749 # -------------------------------------------------------------------
751 sub write_routepushfile
753 open ( FILE
, "> $routes_push_file " );
755 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
756 print FILE
$vpnsettings { 'ROUTES_PUSH' };
761 sub read_routepushfile
763 if (- e
" $routes_push_file " ) {
764 open ( FILE
, " $routes_push_file " );
765 delete $vpnsettings { 'ROUTES_PUSH' };
766 while (< FILE
>) { $vpnsettings { 'ROUTES_PUSH' } .= $_ };
768 $cgiparams { 'ROUTES_PUSH' } = $vpnsettings { 'ROUTES_PUSH' };
774 #hier die refresh page
775 if ( - e
"${General::swroot}/ovpn/gencanow" ) {
777 $refresh = "<meta http-equiv='refresh' content='15;' />" ;
778 & Header
:: showhttpheaders
();
779 & Header
:: openpage
( $Lang :: tr
{ 'OVPN' }, 1 , $refresh );
780 & Header
:: openbigbox
( '100%' , 'center' );
781 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
782 print "<tr> \n <td align='center'><img src='/images/clock.gif' alt='' /></td> \n " ;
783 print "<td colspan='2'><font color='red'>Please be patient this realy can take some time on older hardware...</font></td></tr> \n " ;
785 & Header
:: closebigbox
();
786 & Header
:: closepage
();
789 ##hier die refresh page
793 ### OpenVPN Server Control
795 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' } ||
796 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' } ||
797 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart ovpn server' }) {
798 #start openvpn server
799 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' }){
801 system ( '/usr/local/bin/openvpnctrl' , '-s' );
804 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' }){
805 system ( '/usr/local/bin/openvpnctrl' , '-k' );
808 # #restart openvpn server
809 # if ($cgiparams{'ACTION'} eq $Lang::tr{'restart ovpn server'}){
810 #workarund, till SIGHUP also works when running as nobody
811 # system('/usr/local/bin/openvpnctrl', '-r');
817 ### Save Advanced options
820 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save-adv-options' }) {
821 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
822 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
823 #DAN this value has to leave.
824 #new settings for daemon
825 $vpnsettings { 'LOG_VERB' } = $cgiparams { 'LOG_VERB' };
826 $vpnsettings { 'KEEPALIVE_1' } = $cgiparams { 'KEEPALIVE_1' };
827 $vpnsettings { 'KEEPALIVE_2' } = $cgiparams { 'KEEPALIVE_2' };
828 $vpnsettings { 'MAX_CLIENTS' } = $cgiparams { 'MAX_CLIENTS' };
829 $vpnsettings { 'REDIRECT_GW_DEF1' } = $cgiparams { 'REDIRECT_GW_DEF1' };
830 $vpnsettings { 'CLIENT2CLIENT' } = $cgiparams { 'CLIENT2CLIENT' };
831 $vpnsettings { 'DHCP_DOMAIN' } = $cgiparams { 'DHCP_DOMAIN' };
832 $vpnsettings { 'DHCP_DNS' } = $cgiparams { 'DHCP_DNS' };
833 $vpnsettings { 'DHCP_WINS' } = $cgiparams { 'DHCP_WINS' };
834 $vpnsettings { 'ROUTES_PUSH' } = $cgiparams { 'ROUTES_PUSH' };
835 $vpnsettings { 'PMTU_DISCOVERY' } = $cgiparams { 'PMTU_DISCOVERY' };
838 if ( $cgiparams { 'FRAGMENT' } eq '' ) {
839 delete $vpnsettings { 'FRAGMENT' };
841 if ( $cgiparams { 'FRAGMENT' } !~ /^[0-9]+$/ ) {
842 $errormessage = "Incorrect value, please insert only numbers." ;
845 $vpnsettings { 'FRAGMENT' } = $cgiparams { 'FRAGMENT' };
848 if ( $cgiparams { 'MSSFIX' } ne 'on' ) {
849 delete $vpnsettings { 'MSSFIX' };
851 $vpnsettings { 'MSSFIX' } = $cgiparams { 'MSSFIX' };
854 if ( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) {
855 if (( $cgiparams { 'MSSFIX' } eq 'on' ) || ( $cgiparams { 'FRAGMENT' } ne '' )) {
856 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
861 if ( $cgiparams { 'DHCP_DOMAIN' } ne '' ){
862 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_DOMAIN' }) || & General
:: validip
( $cgiparams { 'DHCP_DOMAIN' })) {
863 $errormessage = $Lang :: tr
{ 'invalid input for dhcp domain' };
867 if ( $cgiparams { 'DHCP_DNS' } ne '' ){
868 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_DNS' }) || & General
:: validip
( $cgiparams { 'DHCP_DNS' })) {
869 $errormessage = $Lang :: tr
{ 'invalid input for dhcp dns' };
873 if ( $cgiparams { 'DHCP_WINS' } ne '' ){
874 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_WINS' }) || & General
:: validip
( $cgiparams { 'DHCP_WINS' })) {
875 $errormessage = $Lang :: tr
{ 'invalid input for dhcp wins' };
879 if ( $cgiparams { 'ROUTES_PUSH' } ne '' ){
880 @temp = split ( /\n/ , $cgiparams { 'ROUTES_PUSH' });
881 undef $vpnsettings { 'ROUTES_PUSH' };
883 foreach my $tmpip ( @temp )
885 s/^\s+//g ; s/\s+$//g ;
890 unless (& General
:: validipandmask
( $tmpip )) {
891 $errormessage = " $tmpip " . $Lang :: tr
{ 'ovpn errmsg invalid ip or mask' };
894 my ( $ip , $cidr ) = split ( "\/" ,& General
:: ipcidr2msk
( $tmpip ));
896 if ( $ip eq $netsettings { 'GREEN_NETADDRESS' } && $cidr eq $netsettings { 'GREEN_NETMASK' }) {
897 $errormessage = $Lang :: tr
{ 'ovpn errmsg green already pushed' };
902 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
903 foreach my $key ( keys %ccdroutehash ) {
904 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
905 if ( $ip . "/" . $cidr eq $ccdroutehash { $key }[ $i ] ){
906 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
909 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
910 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )){
911 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
919 $vpnsettings { 'ROUTES_PUSH' } .= $tmpip . " \n " ;
922 & write_routepushfile
;
923 undef $vpnsettings { 'ROUTES_PUSH' };
926 undef $vpnsettings { 'ROUTES_PUSH' };
927 & write_routepushfile
;
929 if (( length ( $cgiparams { 'MAX_CLIENTS' }) == 0 ) || (( $cgiparams { 'MAX_CLIENTS' }) < 1 ) || (( $cgiparams { 'MAX_CLIENTS' }) > 255 )) {
930 $errormessage = $Lang :: tr
{ 'invalid input for max clients' };
933 if ( $cgiparams { 'KEEPALIVE_1' } ne '' ) {
934 if ( $cgiparams { 'KEEPALIVE_1' } !~ /^[0-9]+$/ ) {
935 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1' };
939 if ( $cgiparams { 'KEEPALIVE_2' } ne '' ){
940 if ( $cgiparams { 'KEEPALIVE_2' } !~ /^[0-9]+$/ ) {
941 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 2' };
945 if ( $cgiparams { 'KEEPALIVE_2' } < ( $cgiparams { 'KEEPALIVE_1' } * 2 )){
946 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1:2' };
950 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
951 & writeserverconf
(); #hier ok
958 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'server' )
961 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
962 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
963 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
966 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
967 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
969 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: $!" ;
972 print SERVERCONF
"# IPFire n2n Open VPN Server Config by ummeegge und m.a.d \n " ;
973 print SERVERCONF
" \n " ;
974 print SERVERCONF
"# User Security \n " ;
975 print SERVERCONF
"user nobody \n " ;
976 print SERVERCONF
"group nobody \n " ;
977 print SERVERCONF
"persist-tun \n " ;
978 print SERVERCONF
"persist-key \n " ;
979 print SERVERCONF
"script-security 2 \n " ;
980 print SERVERCONF
"# IP/DNS for remote Server Gateway \n " ;
981 print SERVERCONF
"remote $cgiparams {'REMOTE'} \n " ;
982 print SERVERCONF
"float \n " ;
983 print SERVERCONF
"# IP adresses of the VPN Subnet \n " ;
984 print SERVERCONF
"ifconfig $ovsubnet .1 $ovsubnet .2 \n " ;
985 print SERVERCONF
"# Client Gateway Network \n " ;
986 print SERVERCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
987 print SERVERCONF
"# tun Device \n " ;
988 print SERVERCONF
"dev tun \n " ;
989 print SERVERCONF
"# Port and Protokol \n " ;
990 print SERVERCONF
"port $cgiparams {'DEST_PORT'} \n " ;
992 if ( $cgiparams { 'PROTOCOL' } eq 'tcp' ) {
993 print SERVERCONF
"proto tcp-server \n " ;
994 print SERVERCONF
"# Packet size \n " ;
995 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1400' } else { $tunmtu = $cgiparams { 'MTU' }};
996 print SERVERCONF
"tun-mtu $tunmtu \n " ;
999 if ( $cgiparams { 'PROTOCOL' } eq 'udp' ) {
1000 print SERVERCONF
"proto udp \n " ;
1001 print SERVERCONF
"# Paketsize \n " ;
1002 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
1003 print SERVERCONF
"tun-mtu $tunmtu \n " ;
1004 if ( $cgiparams { 'FRAGMENT' } ne '' ) { print SERVERCONF
"fragment $cgiparams {'FRAGMENT'} \n " ;}
1005 if ( $cgiparams { 'MSSFIX' } eq 'on' ) { print SERVERCONF
"mssfix \n " ; };
1007 if ( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) {
1008 if (( $cgiparams { 'MSSFIX' } ne 'on' ) || ( $cgiparams { 'FRAGMENT' } eq '' )) {
1009 if ( $cgiparams { 'MTU' } eq '1500' ) {
1010 print SERVERCONF
"mtu-disc $cgiparams {'PMTU_DISCOVERY'} \n " ;
1014 print SERVERCONF
"# Auth. Server \n " ;
1015 print SERVERCONF
"tls-server \n " ;
1016 print SERVERCONF
"ca ${General::swroot}/ovpn/ca/cacert.pem \n " ;
1017 print SERVERCONF
"cert ${General::swroot}/ovpn/certs/servercert.pem \n " ;
1018 print SERVERCONF
"key ${General::swroot}/ovpn/certs/serverkey.pem \n " ;
1019 print SERVERCONF
"dh ${General::swroot}/ovpn/ca/dh1024.pem \n " ;
1020 print SERVERCONF
"# Cipher \n " ;
1021 print SERVERCONF
"cipher AES-256-CBC \n " ;
1022 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
1023 print SERVERCONF
"# Enable Compression \n " ;
1024 print SERVERCONF
"comp-lzo \r\n " ;
1026 print SERVERCONF
"# Debug Level \n " ;
1027 print SERVERCONF
"verb 3 \n " ;
1028 print SERVERCONF
"# Tunnel check \n " ;
1029 print SERVERCONF
"keepalive 10 60 \n " ;
1030 print SERVERCONF
"# Start as daemon \n " ;
1031 print SERVERCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
1032 print SERVERCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
1033 print SERVERCONF
"# Activate Management Interface and Port \n " ;
1034 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) { print SERVERCONF
"management localhost $cgiparams {'DEST_PORT'} \n " }
1035 else { print SERVERCONF
"management localhost $cgiparams {'OVPN_MGMT'} \n " };
1044 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'client' )
1046 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
1047 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
1048 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
1051 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
1052 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
1054 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: $!" ;
1056 flock CLIENTCONF
, 2 ;
1057 print CLIENTCONF
"# IPFire rewritten n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
1058 print CLIENTCONF
"# \n " ;
1059 print CLIENTCONF
"# User Security \n " ;
1060 print CLIENTCONF
"user nobody \n " ;
1061 print CLIENTCONF
"group nobody \n " ;
1062 print CLIENTCONF
"persist-tun \n " ;
1063 print CLIENTCONF
"persist-key \n " ;
1064 print CLIENTCONF
"script-security 2 \n " ;
1065 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
1066 print CLIENTCONF
"remote $cgiparams {'REMOTE'} \n " ;
1067 print CLIENTCONF
"float \n " ;
1068 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
1069 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
1070 print CLIENTCONF
"# Server Gateway Network \n " ;
1071 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
1072 print CLIENTCONF
"# tun Device \n " ;
1073 print CLIENTCONF
"dev tun \n " ;
1074 print CLIENTCONF
"# Port and Protokol \n " ;
1075 print CLIENTCONF
"port $cgiparams {'DEST_PORT'} \n " ;
1077 if ( $cgiparams { 'PROTOCOL' } eq 'tcp' ) {
1078 print CLIENTCONF
"proto tcp-client \n " ;
1079 print CLIENTCONF
"# Packet size \n " ;
1080 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1400' } else { $tunmtu = $cgiparams { 'MTU' }};
1081 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
1084 if ( $cgiparams { 'PROTOCOL' } eq 'udp' ) {
1085 print CLIENTCONF
"proto udp \n " ;
1086 print CLIENTCONF
"# Paketsize \n " ;
1087 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
1088 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
1089 if ( $cgiparams { 'FRAGMENT' } ne '' ) { print CLIENTCONF
"fragment $cgiparams {'FRAGMENT'} \n " ;}
1090 if ( $cgiparams { 'MSSFIX' } eq 'on' ) { print CLIENTCONF
"mssfix \n " ; };
1092 if ( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) {
1093 if (( $cgiparams { 'MSSFIX' } ne 'on' ) || ( $cgiparams { 'FRAGMENT' } eq '' )) {
1094 if ( $cgiparams { 'MTU' } eq '1500' ) {
1095 print CLIENTCONF
"mtu-disc $cgiparams {'PMTU_DISCOVERY'} \n " ;
1099 print CLIENTCONF
"ns-cert-type server \n " ;
1100 print CLIENTCONF
"# Auth. Client \n " ;
1101 print CLIENTCONF
"tls-client \n " ;
1102 print CLIENTCONF
"# Cipher \n " ;
1103 print CLIENTCONF
"cipher AES-256-CBC \n " ;
1104 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12 \r\n " ;
1105 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
1106 print CLIENTCONF
"# Enable Compression \n " ;
1107 print CLIENTCONF
"comp-lzo \r\n " ;
1109 print CLIENTCONF
"# Debug Level \n " ;
1110 print CLIENTCONF
"verb 3 \n " ;
1111 print CLIENTCONF
"# Tunnel check \n " ;
1112 print CLIENTCONF
"keepalive 10 60 \n " ;
1113 print CLIENTCONF
"# Start as daemon \n " ;
1114 print CLIENTCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
1115 print CLIENTCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
1116 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
1117 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) { print CLIENTCONF
"management localhost $cgiparams {'DEST_PORT'} \n " }
1118 else { print CLIENTCONF
"management localhost $cgiparams {'OVPN_MGMT'} \n " };
1124 ### Save main settings
1128 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
1129 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1130 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
1131 #DAN this value has to leave.
1132 if ( $cgiparams { 'ENABLED' } eq 'on' ){
1133 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })) {
1134 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1135 goto SETTINGS_ERROR
;
1138 if ( $cgiparams { 'ENABLED' } eq 'on' ){
1139 & disallowreserved
( $cgiparams { 'DDEST_PORT' }, 0 , $cgiparams { 'DPROTOCOL' }, "dest" );
1141 if ( $errormessage ) { goto SETTINGS_ERROR
; }
1144 if ( $cgiparams { 'ENABLED' } eq 'on' ){
1145 & checkportfw
( 0 , $cgiparams { 'DDEST_PORT' }, $cgiparams { 'DPROTOCOL' }, '0.0.0.0' );
1148 if ( $errormessage ) { goto SETTINGS_ERROR
; }
1150 if (! & General
:: validipandmask
( $cgiparams { 'DOVPN_SUBNET' })) {
1151 $errormessage = $Lang :: tr
{ 'ovpn subnet is invalid' };
1152 goto SETTINGS_ERROR
;
1154 my @tmpovpnsubnet = split ( "\/" , $cgiparams { 'DOVPN_SUBNET' });
1156 if (& General
:: IpInSubnet
( $netsettings { 'RED_ADDRESS' },
1157 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1158 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire RED Network $netsettings {'RED_ADDRESS'}" ;
1159 goto SETTINGS_ERROR
;
1162 if (& General
:: IpInSubnet
( $netsettings { 'GREEN_ADDRESS' },
1163 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1164 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Green Network $netsettings {'GREEN_ADDRESS'}" ;
1165 goto SETTINGS_ERROR
;
1168 if (& General
:: IpInSubnet
( $netsettings { 'BLUE_ADDRESS' },
1169 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1170 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Blue Network $netsettings {'BLUE_ADDRESS'}" ;
1171 goto SETTINGS_ERROR
;
1174 if (& General
:: IpInSubnet
( $netsettings { 'ORANGE_ADDRESS' },
1175 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1176 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Orange Network $netsettings {'ORANGE_ADDRESS'}" ;
1177 goto SETTINGS_ERROR
;
1179 open ( ALIASES
, "${General::swroot}/ethernet/aliases" ) or die 'Unable to open aliases file.' ;
1183 my @tempalias = split ( /\,/ , $_ );
1184 if ( $tempalias [ 1 ] eq 'on' ) {
1185 if (& General
:: IpInSubnet
( $tempalias [ 0 ] ,
1186 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1187 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire alias entry $tempalias [0]" ;
1192 if ( $errormessage ne '' ){
1193 goto SETTINGS_ERROR
;
1195 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1196 $errormessage = $Lang :: tr
{ 'invalid input' };
1197 goto SETTINGS_ERROR
;
1199 if (( length ( $cgiparams { 'DMTU' })== 0 ) || (( $cgiparams { 'DMTU' }) < 1000 )) {
1200 $errormessage = $Lang :: tr
{ 'invalid mtu input' };
1201 goto SETTINGS_ERROR
;
1204 unless (& General
:: validport
( $cgiparams { 'DDEST_PORT' })) {
1205 $errormessage = $Lang :: tr
{ 'invalid port' };
1206 goto SETTINGS_ERROR
;
1208 $vpnsettings { 'ENABLED_BLUE' } = $cgiparams { 'ENABLED_BLUE' };
1209 $vpnsettings { 'ENABLED_ORANGE' } = $cgiparams { 'ENABLED_ORANGE' };
1210 $vpnsettings { 'ENABLED' } = $cgiparams { 'ENABLED' };
1211 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
1212 #new settings for daemon
1213 $vpnsettings { 'DOVPN_SUBNET' } = $cgiparams { 'DOVPN_SUBNET' };
1214 $vpnsettings { 'DDEVICE' } = $cgiparams { 'DDEVICE' };
1215 $vpnsettings { 'DPROTOCOL' } = $cgiparams { 'DPROTOCOL' };
1216 $vpnsettings { 'DDEST_PORT' } = $cgiparams { 'DDEST_PORT' };
1217 $vpnsettings { 'DMTU' } = $cgiparams { 'DMTU' };
1218 $vpnsettings { 'DCOMPLZO' } = $cgiparams { 'DCOMPLZO' };
1219 $vpnsettings { 'DCIPHER' } = $cgiparams { 'DCIPHER' };
1222 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" );}
1223 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" );}
1224 if ( $vpnsettings { 'ENABLED' } eq 'on' ) { system ( "touch ${General::swroot}/ovpn/enable 2>/dev/null" );} else { system ( "unlink ${General::swroot}/ovpn/enable 2>/dev/null" );}
1225 #new settings for daemon
1226 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1227 & writeserverconf
(); #hier ok
1230 ### Reset all step 2
1232 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'reset' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1234 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1236 foreach my $key ( keys %confighash ) {
1237 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
1238 delete $confighash { $cgiparams { ' $key ' }};
1241 while ( $file = glob ( "${General::swroot}/ovpn/ca/*" )) {
1244 while ( $file = glob ( "${General::swroot}/ovpn/certs/*" )) {
1247 while ( $file = glob ( "${General::swroot}/ovpn/crls/*" )) {
1250 & cleanssldatabase
();
1251 if ( open ( FILE
, ">${General::swroot}/ovpn/caconfig" )) {
1255 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1256 #&writeserverconf();
1258 ### Reset all step 1
1260 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'reset' }) {
1261 & Header
:: showhttpheaders
();
1262 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1263 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1264 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'are you sure' });
1266 <table><form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1267 <tr><td align='center'>
1268 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1269 $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}
1270 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'reset'}' />
1271 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td></tr>
1275 & Header
:: closebox
();
1276 & Header
:: closebigbox
();
1277 & Header
:: closepage
();
1281 ### Upload CA Certificate
1283 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
1284 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1286 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1287 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1288 goto UPLOADCA_ERROR
;
1291 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
1292 $errormessage = $Lang :: tr
{ 'name too long' };
1296 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
1297 $errormessage = $Lang :: tr
{ 'name is invalid' };
1298 goto UPLOAD_CA_ERROR
;
1301 # Check if there is no other entry with this name
1302 foreach my $key ( keys %cahash ) {
1303 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
1304 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
1305 goto UPLOADCA_ERROR
;
1309 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1310 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1311 goto UPLOADCA_ERROR
;
1313 # Move uploaded ca to a temporary file
1314 ( my $fh , my $filename ) = tempfile
( );
1315 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1317 goto UPLOADCA_ERROR
;
1319 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
1320 if ( $temp !~ /CA:TRUE/i ) {
1321 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1323 goto UPLOADCA_ERROR
;
1325 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1327 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1329 goto UPLOADCA_ERROR
;
1333 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem` ;
1334 $casubject =~ /Subject: (.*)[\n]/ ;
1336 $casubject =~ s
+/ Email
+, E
+;
1337 $casubject =~ s/ ST=/ S=/ ;
1338 $casubject = & Header
:: cleanhtml
( $casubject );
1340 my $key = & General
:: findhasharraykey
( \
%cahash );
1341 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1342 $cahash { $key }[ 1 ] = $casubject ;
1343 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1344 # system('/usr/local/bin/ipsecctrl', 'R');
1349 ### Display ca certificate
1351 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
1352 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1354 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1355 & Header
:: showhttpheaders
();
1356 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1357 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1358 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ca certificate'}:" );
1359 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1360 $output = & Header
:: cleanhtml
( $output , "y" );
1361 print "<pre> $output </pre> \n " ;
1362 & Header
:: closebox
();
1363 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1364 & Header
:: closebigbox
();
1365 & Header
:: closepage
();
1368 $errormessage = $Lang :: tr
{ 'invalid key' };
1372 ### Download ca certificate
1374 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
1375 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1377 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1378 print "Content-Type: application/octet-stream \r\n " ;
1379 print "Content-Disposition: filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
1380 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1383 $errormessage = $Lang :: tr
{ 'invalid key' };
1387 ### Remove ca certificate (step 2)
1389 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1390 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1391 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1393 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1394 foreach my $key ( keys %confighash ) {
1395 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` ;
1396 if ( $test =~ /: OK/ ) {
1398 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1399 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
1400 # system('/usr/local/bin/ipsecctrl', 'D', $key);
1402 unlink ( "${General::swroot}/ovpn//certs/ $confighash { $key }[1]cert.pem" );
1403 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" );
1404 delete $confighash { $key };
1405 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1406 # &writeipsecfiles();
1409 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1410 delete $cahash { $cgiparams { 'KEY' }};
1411 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1412 # system('/usr/local/bin/ipsecctrl', 'R');
1414 $errormessage = $Lang :: tr
{ 'invalid key' };
1417 ### Remove ca certificate (step 1)
1419 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
1420 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1421 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1423 my $assignedcerts = 0 ;
1424 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1425 foreach my $key ( keys %confighash ) {
1426 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` ;
1427 if ( $test =~ /: OK/ ) {
1431 if ( $assignedcerts ) {
1432 & Header
:: showhttpheaders
();
1433 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1434 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1435 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'are you sure' });
1437 <table><form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1438 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1439 <tr><td align='center'>
1440 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>: $assignedcerts
1441 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}
1442 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
1443 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td></tr>
1447 & Header
:: closebox
();
1448 & Header
:: closebigbox
();
1449 & Header
:: closepage
();
1452 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1453 delete $cahash { $cgiparams { 'KEY' }};
1454 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1455 # system('/usr/local/bin/ipsecctrl', 'R');
1458 $errormessage = $Lang :: tr
{ 'invalid key' };
1462 ### Display root certificate
1464 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
1465 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
1467 & Header
:: showhttpheaders
();
1468 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1469 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1470 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
1471 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'root certificate'}:" );
1472 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1474 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'host certificate'}:" );
1475 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1477 $output = & Header
:: cleanhtml
( $output , "y" );
1478 print "<pre> $output </pre> \n " ;
1479 & Header
:: closebox
();
1480 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1481 & Header
:: closebigbox
();
1482 & Header
:: closepage
();
1486 ### Download root certificate
1488 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
1489 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1490 print "Content-Type: application/octet-stream \r\n " ;
1491 print "Content-Disposition: filename=cacert.pem \r\n\r\n " ;
1492 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1497 ### Download host certificate
1499 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
1500 if ( - f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
1501 print "Content-Type: application/octet-stream \r\n " ;
1502 print "Content-Disposition: filename=servercert.pem \r\n\r\n " ;
1503 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1507 ### Form for generating a root certificate
1509 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
1510 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1512 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1513 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1514 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
1515 $cgiparams { 'ACTION' } = '' ;
1516 goto ROOTCERT_ERROR
;
1519 if (( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) && - e
"${General::swroot}/red/active" ) {
1520 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
1521 my $ipaddr = < IPADDR
>;
1524 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
1525 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
1526 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
1529 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1531 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1532 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1533 goto ROOTCERT_ERROR
;
1536 # Move uploaded certificate request to a temporary file
1537 ( my $fh , my $filename ) = tempfile
( );
1538 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1540 goto ROOTCERT_ERROR
;
1543 # Create a temporary dirctory
1544 my $tempdir = tempdir
( CLEANUP
=> 1 );
1546 # Extract the CA certificate from the file
1547 my $pid = open ( OPENSSL
, "|-" );
1548 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1549 if ( $pid ) { # parent
1550 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1551 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1555 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1557 goto ROOTCERT_ERROR
;
1560 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-cacerts' , '-nokeys' ,
1562 '-out' , " $tempdir /cacert.pem" )) {
1563 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1565 goto ROOTCERT_ERROR
;
1569 # Extract the Host certificate from the file
1570 $pid = open ( OPENSSL
, "|-" );
1571 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1572 if ( $pid ) { # parent
1573 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1574 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1578 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1580 goto ROOTCERT_ERROR
;
1583 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-clcerts' , '-nokeys' ,
1585 '-out' , " $tempdir /hostcert.pem" )) {
1586 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1588 goto ROOTCERT_ERROR
;
1592 # Extract the Host key from the file
1593 $pid = open ( OPENSSL
, "|-" );
1594 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1595 if ( $pid ) { # parent
1596 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1597 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1601 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1603 goto ROOTCERT_ERROR
;
1606 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-nocerts' ,
1609 '-out' , " $tempdir /serverkey.pem" )) {
1610 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1612 goto ROOTCERT_ERROR
;
1616 move
( " $tempdir /cacert.pem" , "${General::swroot}/ovpn/ca/cacert.pem" );
1618 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1620 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1621 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1622 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1623 goto ROOTCERT_ERROR
;
1626 move
( " $tempdir /hostcert.pem" , "${General::swroot}/ovpn/certs/servercert.pem" );
1628 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1630 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1631 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1632 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1633 goto ROOTCERT_ERROR
;
1636 move
( " $tempdir /serverkey.pem" , "${General::swroot}/ovpn/certs/serverkey.pem" );
1638 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1640 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1641 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1642 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1643 goto ROOTCERT_ERROR
;
1646 goto ROOTCERT_SUCCESS
;
1648 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
1650 # Validate input since the form was submitted
1651 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
1652 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
1653 goto ROOTCERT_ERROR
;
1655 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
1656 $errormessage = $Lang :: tr
{ 'organization too long' };
1657 goto ROOTCERT_ERROR
;
1659 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1660 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1661 goto ROOTCERT_ERROR
;
1663 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
1664 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
1665 goto ROOTCERT_ERROR
;
1667 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
1668 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1669 goto ROOTCERT_ERROR
;
1671 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
1672 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1673 goto ROOTCERT_ERROR
;
1675 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
1676 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1677 goto ROOTCERT_ERROR
;
1679 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1680 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1681 goto ROOTCERT_ERROR
;
1683 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1684 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1685 goto ROOTCERT_ERROR
;
1687 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1688 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1689 goto ROOTCERT_ERROR
;
1691 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1692 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1693 goto ROOTCERT_ERROR
;
1696 # Copy the cgisettings to vpnsettings and save the configfile
1697 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
1698 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
1699 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
1700 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
1701 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
1702 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
1703 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
1704 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1706 # Replace empty strings with a .
1707 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
1708 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
1709 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
1712 #system ('/bin/touch', "${General::swroot}/ovpn/gencanow");
1714 # Create the CA certificate
1715 my $pid = open ( OPENSSL
, "|-" );
1716 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1717 if ( $pid ) { # parent
1718 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1719 print OPENSSL
" $state \n " ;
1720 print OPENSSL
" $city \n " ;
1721 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1722 print OPENSSL
" $ou \n " ;
1723 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
1724 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1727 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1728 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1729 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1730 goto ROOTCERT_ERROR
;
1733 unless ( exec ( '/usr/bin/openssl' , 'req' , '-x509' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1734 '-days' , '999999' , '-newkey' , 'rsa:2048' ,
1735 '-keyout' , "${General::swroot}/ovpn/ca/cakey.pem" ,
1736 '-out' , "${General::swroot}/ovpn/ca/cacert.pem" ,
1737 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1738 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1739 goto ROOTCERT_ERROR
;
1743 # Create the Host certificate request
1744 $pid = open ( OPENSSL
, "|-" );
1745 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1746 if ( $pid ) { # parent
1747 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1748 print OPENSSL
" $state \n " ;
1749 print OPENSSL
" $city \n " ;
1750 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1751 print OPENSSL
" $ou \n " ;
1752 print OPENSSL
" $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1753 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1754 print OPENSSL
". \n " ;
1755 print OPENSSL
". \n " ;
1758 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1759 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1760 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1761 goto ROOTCERT_ERROR
;
1764 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1765 '-newkey' , 'rsa:1024' ,
1766 '-keyout' , "${General::swroot}/ovpn/certs/serverkey.pem" ,
1767 '-out' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1768 '-extensions' , 'server' ,
1769 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1770 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1771 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1772 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1773 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1774 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1775 goto ROOTCERT_ERROR
;
1779 # Sign the host certificate request
1780 system ( '/usr/bin/openssl' , 'ca' , '-days' , '999999' ,
1781 '-batch' , '-notext' ,
1782 '-in' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1783 '-out' , "${General::swroot}/ovpn/certs/servercert.pem" ,
1784 '-extensions' , 'server' ,
1785 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1787 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1788 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1789 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1790 unlink ( "${General::swroot}/ovpn/serverkey.pem" );
1791 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1792 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1793 & newcleanssldatabase
();
1794 goto ROOTCERT_ERROR
;
1796 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1797 & deletebackupcert
();
1800 # Create an empty CRL
1801 system ( '/usr/bin/openssl' , 'ca' , '-gencrl' ,
1802 '-out' , "${General::swroot}/ovpn/crls/cacrl.pem" ,
1803 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1805 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1806 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1807 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1808 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1809 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1810 & cleanssldatabase
();
1811 goto ROOTCERT_ERROR
;
1813 # &cleanssldatabase();
1815 # Create Diffie Hellmann Parameter
1816 system ( '/usr/bin/openssl' , 'dhparam' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1817 '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" ,
1820 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1821 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1822 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1823 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1824 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1825 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1826 & cleanssldatabase
();
1827 goto ROOTCERT_ERROR
;
1829 # &cleanssldatabase();
1831 goto ROOTCERT_SUCCESS
;
1834 if ( $cgiparams { 'ACTION' } ne '' ) {
1835 & Header
:: showhttpheaders
();
1836 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1837 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1838 if ( $errormessage ) {
1839 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
1840 print "<class name='base'> $errormessage " ;
1841 print " </class>" ;
1842 & Header
:: closebox
();
1844 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'generate root/host certificates'}:" );
1846 <form method='post' enctype='multipart/form-data'>
1847 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1848 <tr><td width='30%' class='base'> $Lang ::tr{'organization name'}:</td>
1849 <td width='35%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td>
1850 <td width='35%' colspan='2'> </td></tr>
1851 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}:</td>
1852 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td>
1853 <td colspan='2'> </td></tr>
1854 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt'*' /></td>
1855 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td>
1856 <td colspan='2'> </td></tr>
1857 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt'*' /></td>
1858 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td>
1859 <td colspan='2'> </td></tr>
1860 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt'*' /></td>
1861 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td>
1862 <td colspan='2'> </td></tr>
1863 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt'*' /></td>
1864 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td>
1865 <td colspan='2'> </td></tr>
1866 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1867 <td class='base'><select name='ROOTCERT_COUNTRY'>
1871 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1872 print "<option value=' $Countries ::countries{ $country }'" ;
1873 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1874 print " selected='selected'" ;
1876 print "> $country </option>" ;
1880 <td colspan='2'> </td></tr>
1882 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /></td>
1883 <td> </td><td> </td></tr>
1884 <tr><td class='base' colspan='4' align='left'>
1885 <img src='/blob.gif' valign='top' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
1886 <tr><td class='base' colspan='4' align='left'>
1887 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1888 $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'}
1890 <tr><td colspan='4' bgcolor='#000000'><img src='/images/null.gif' width='1' height='1' border='0' /></td></tr>
1891 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
1892 <td nowrap='nowrap'><input type='file' name='FH' size='32'></td>
1893 <td colspan='2'> </td></tr>
1894 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' ></td>
1895 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td>
1896 <td colspan='2'> </td></tr>
1898 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td>
1899 <td colspan='2'> </td></tr>
1900 <tr><td class='base' colspan='4' align='left'>
1901 <img src='/blob.gif' valign='top' al='*' > $Lang ::tr{'this field may be blank'}</td></tr>
1905 & Header
:: closebox
();
1907 & Header
:: closebigbox
();
1908 & Header
:: closepage
();
1913 system ( "chmod 600 ${General::swroot}/ovpn/certs/serverkey.pem" );
1914 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1915 # $vpnsettings{'ENABLE_BLUE'} eq 'on') {
1916 # system('/usr/local/bin/ipsecctrl', 'S');
1920 ### Enable/Disable connection
1927 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
1929 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1930 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1931 # my $n2nactive = '';
1932 my $n2nactive = `/bin/ps ax|grep $confighash { $cgiparams {'KEY'}}[1]|grep -v grep|awk \' {print \ $1 } \' ` ;
1934 if ( $confighash { $cgiparams { 'KEY' }}) {
1935 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
1936 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
1937 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1939 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
1940 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
1944 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
1945 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1947 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
1948 if ( $n2nactive ne '' ){
1949 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
1953 $errormessage = $Lang :: tr
{ 'invalid key' };
1959 ### Download OpenVPN client package
1963 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'dl client arch' }) {
1964 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1965 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1967 my $clientovpn = '' ;
1969 my $tempdir = tempdir
( CLEANUP
=> 1 );
1970 my $zippath = " $tempdir /" ;
1976 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
1978 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-Client.zip" ;
1979 my $zippathname = " $zippath $zipname " ;
1980 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1].conf" ;
1981 my @ovsubnettemp = split ( /\./ , $confighash { $cgiparams { 'KEY' }}[ 27 ]);
1982 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
1984 my @remsubnet = split ( /\/ /, $confighash { $cgiparams { 'KEY' }}[ 8 ]);
1985 my $n2nfragment = '' ;
1987 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
1988 flock CLIENTCONF
, 2 ;
1990 my $zip = Archive
:: Zip
-> new ();
1991 print CLIENTCONF
"# IPFire n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
1992 print CLIENTCONF
"# \n " ;
1993 print CLIENTCONF
"# User Security \n " ;
1994 print CLIENTCONF
"user nobody \n " ;
1995 print CLIENTCONF
"group nobody \n " ;
1996 print CLIENTCONF
"persist-tun \n " ;
1997 print CLIENTCONF
"persist-key \n " ;
1998 print CLIENTCONF
"script-security 2 \n " ;
1999 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
2000 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} \n " ;
2001 print CLIENTCONF
"float \n " ;
2002 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
2003 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
2004 print CLIENTCONF
"# Server Gateway Network \n " ;
2005 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
2006 print CLIENTCONF
"# tun Device \n " ;
2007 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \n " ;
2008 print CLIENTCONF
"# Port and Protokoll \n " ;
2009 print CLIENTCONF
"port $confighash { $cgiparams {'KEY'}}[29] \n " ;
2011 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'tcp' ) {
2012 print CLIENTCONF
"proto tcp-client \n " ;
2013 print CLIENTCONF
"# Packet size \n " ;
2014 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1400' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2015 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2018 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'udp' ) {
2019 print CLIENTCONF
"proto udp \n " ;
2020 print CLIENTCONF
"# Paketsize \n " ;
2021 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1500' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2022 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2023 if ( $confighash { $cgiparams { 'KEY' }}[ 24 ] ne '' ) { print CLIENTCONF
"fragment $confighash { $cgiparams {'KEY'}}[24] \n " ;}
2024 if ( $confighash { $cgiparams { 'KEY' }}[ 23 ] eq 'on' ) { print CLIENTCONF
"mssfix \n " ;}
2026 if ( $confighash { $cgiparams { 'KEY' }}[ 38 ] ne 'off' ) {
2027 if (( $confighash { $cgiparams { 'KEY' }}[ 23 ] ne 'on' ) || ( $confighash { $cgiparams { 'KEY' }}[ 24 ] eq '' )) {
2028 if ( $tunmtu eq '1500' ) {
2029 print CLIENTCONF
"mtu-disc $confighash { $cgiparams {'KEY'}}[38] \n " ;
2033 print CLIENTCONF
"ns-cert-type server \n " ;
2034 print CLIENTCONF
"# Auth. Client \n " ;
2035 print CLIENTCONF
"tls-client \n " ;
2036 print CLIENTCONF
"# Cipher \n " ;
2037 print CLIENTCONF
"cipher AES-256-CBC \n " ;
2038 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2039 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2040 $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 " ;
2042 if ( $confighash { $cgiparams { 'KEY' }}[ 30 ] eq 'on' ) {
2043 print CLIENTCONF
"# Enable Compression \n " ;
2044 print CLIENTCONF
"comp-lzo \r\n " ;
2046 print CLIENTCONF
"# Debug Level \n " ;
2047 print CLIENTCONF
"verb 3 \n " ;
2048 print CLIENTCONF
"# Tunnel check \n " ;
2049 print CLIENTCONF
"keepalive 10 60 \n " ;
2050 print CLIENTCONF
"# Start as daemon \n " ;
2051 print CLIENTCONF
"daemon $confighash { $cgiparams {'KEY'}}[1]n2n \n " ;
2052 print CLIENTCONF
"writepid /var/run/ $confighash { $cgiparams {'KEY'}}[1]n2n.pid \n " ;
2053 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
2054 if ( $confighash { $cgiparams { 'KEY' }}[ 22 ] eq '' ) { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[29] \n " }
2055 else { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[22] \n " };
2056 print CLIENTCONF
"# remsub $confighash { $cgiparams {'KEY'}}[11] \n " ;
2061 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2062 my $status = $zip -> writeToFileNamed ( $zippathname );
2064 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2065 @fileholder = < DLFILE
>;
2066 print "Content-Type:application/x-download \n " ;
2067 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2073 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.zip" ;
2074 my $zippathname = " $zippath $zipname " ;
2075 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.ovpn" ;
2081 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2082 flock CLIENTCONF
, 2 ;
2084 my $zip = Archive
:: Zip
-> new ();
2086 print CLIENTCONF
"#OpenVPN Client conf \r\n " ;
2087 print CLIENTCONF
"tls-client \r\n " ;
2088 print CLIENTCONF
"client \r\n " ;
2089 print CLIENTCONF
"nobind \n " ;
2090 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \r\n " ;
2091 print CLIENTCONF
"proto $vpnsettings {'DPROTOCOL'} \r\n " ;
2093 # Check if we are using fragment, mssfix or mtu-disc and set MTU to 1500
2094 # or use configured value.
2095 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' )
2096 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
2097 elsif ( $vpnsettings { MSSFIX
} eq 'on' )
2098 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
2099 elsif ( $vpnsettings { PMTU_DISCOVERY
} ne 'off' )
2100 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
2102 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu $vpnsettings {'DMTU'} \r\n " ; }
2104 if ( $vpnsettings { 'ENABLED' } eq 'on' ){
2105 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2106 if ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2107 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Blue interface \r\n " ;
2108 print CLIENTCONF
";remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2110 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2111 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2112 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2114 } elsif ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2115 print CLIENTCONF
"remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2116 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2117 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2118 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2120 } elsif ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2121 print CLIENTCONF
"remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2124 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2125 print CLIENTCONF
"pkcs12 $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2126 $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 " ;
2128 print CLIENTCONF
"ca cacert.pem \r\n " ;
2129 print CLIENTCONF
"cert $confighash { $cgiparams {'KEY'}}[1]cert.pem \r\n " ;
2130 print CLIENTCONF
"key $confighash { $cgiparams {'KEY'}}[1].key \r\n " ;
2131 $zip -> addFile ( "${General::swroot}/ovpn/ca/cacert.pem" , "cacert.pem" ) or die "Can't add file cacert.pem \n " ;
2132 $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 " ;
2134 print CLIENTCONF
"cipher $vpnsettings {DCIPHER} \r\n " ;
2135 if ( $vpnsettings { DCOMPLZO
} eq 'on' ) {
2136 print CLIENTCONF
"comp-lzo \r\n " ;
2138 print CLIENTCONF
"verb 3 \r\n " ;
2139 print CLIENTCONF
"ns-cert-type server \r\n " ;
2140 print CLIENTCONF
"tls-remote $vpnsettings {ROOTCERT_HOSTNAME} \r\n " ;
2141 if ( $vpnsettings { MSSFIX
} eq 'on' ) {
2142 print CLIENTCONF
"mssfix \r\n " ;
2144 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' ) {
2145 print CLIENTCONF
"fragment $vpnsettings {'FRAGMENT'} \r\n " ;
2147 if ( $vpnsettings { PMTU_DISCOVERY
} ne 'off' ) {
2148 if (( $vpnsettings { MSSFIX
} ne 'on' ) || ( $vpnsettings { FRAGMENT
} eq '' )) {
2149 print CLIENTCONF
"mtu-disc $vpnsettings {'PMTU_DISCOVERY'} \n " ;
2154 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2155 my $status = $zip -> writeToFileNamed ( $zippathname );
2157 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2158 @fileholder = < DLFILE
>;
2159 print "Content-Type:application/x-download \n " ;
2160 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2168 ### Remove connection
2172 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
2173 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2174 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2176 if ( $confighash { $cgiparams { 'KEY' }}) {
2177 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2178 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2179 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2182 my $temp = `/usr/bin/openssl ca -revoke ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2188 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
2190 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
2191 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2192 unlink ( $certfile ) or die "Removing $certfile fail: $!" ;
2193 unlink ( $conffile ) or die "Removing $conffile fail: $!" ;
2194 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
2198 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
2199 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2201 # A.Marx CCD delete ccd files and routes
2204 if (- f
"${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" )
2206 unlink "${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" ;
2209 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2210 foreach my $key ( keys %ccdroutehash ) {
2211 if ( $ccdroutehash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2212 delete $ccdroutehash { $key };
2215 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2217 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2218 foreach my $key ( keys %ccdroute2hash ) {
2219 if ( $ccdroute2hash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2220 delete $ccdroute2hash { $key };
2223 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2230 delete $confighash { $cgiparams { 'KEY' }};
2231 my $temp2 = `/usr/bin/openssl ca -gencrl -out ${General::swroot}/ovpn/crls/cacrl.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2232 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2234 #&writeserverconf();
2236 $errormessage = $Lang :: tr
{ 'invalid key' };
2241 ### Download PKCS12 file
2243 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
2244 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2246 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
2247 print "Content-Type: application/octet-stream \r\n\r\n " ;
2248 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
2252 ### Display certificate
2254 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
2255 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2257 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2258 & Header
:: showhttpheaders
();
2259 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2260 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2261 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate'}:" );
2262 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2263 $output = & Header
:: cleanhtml
( $output , "y" );
2264 print "<pre> $output </pre> \n " ;
2265 & Header
:: closebox
();
2266 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2267 & Header
:: closebigbox
();
2268 & Header
:: closepage
();
2272 ### Display Certificate Revoke List
2274 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show crl' }) {
2275 # &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash);
2277 if ( - f
"${General::swroot}/ovpn/crls/cacrl.pem" ) {
2278 & Header
:: showhttpheaders
();
2279 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2280 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2281 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'crl'}:" );
2282 my $output = `/usr/bin/openssl crl -text -noout -in ${General::swroot}/ovpn/crls/cacrl.pem` ;
2283 $output = & Header
:: cleanhtml
( $output , "y" );
2284 print "<pre> $output </pre> \n " ;
2285 & Header
:: closebox
();
2286 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2287 & Header
:: closebigbox
();
2288 & Header
:: closepage
();
2293 ### Advanced Server Settings
2296 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced server' }) {
2301 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
2305 # if ($cgiparams{'CLIENT2CLIENT'} eq '') {
2306 # $cgiparams{'CLIENT2CLIENT'} = 'on';
2309 if ( $cgiparams { 'MAX_CLIENTS' } eq '' ) {
2310 $cgiparams { 'MAX_CLIENTS' } = '100' ;
2312 if ( $cgiparams { 'KEEPALIVE_1' } eq '' ) {
2313 $cgiparams { 'KEEPALIVE_1' } = '10' ;
2315 if ( $cgiparams { 'KEEPALIVE_2' } eq '' ) {
2316 $cgiparams { 'KEEPALIVE_2' } = '60' ;
2318 if ( $cgiparams { 'LOG_VERB' } eq '' ) {
2319 $cgiparams { 'LOG_VERB' } = '3' ;
2321 $checked { 'CLIENT2CLIENT' }{ 'off' } = '' ;
2322 $checked { 'CLIENT2CLIENT' }{ 'on' } = '' ;
2323 $checked { 'CLIENT2CLIENT' }{ $cgiparams { 'CLIENT2CLIENT' }} = 'CHECKED' ;
2324 $checked { 'REDIRECT_GW_DEF1' }{ 'off' } = '' ;
2325 $checked { 'REDIRECT_GW_DEF1' }{ 'on' } = '' ;
2326 $checked { 'REDIRECT_GW_DEF1' }{ $cgiparams { 'REDIRECT_GW_DEF1' }} = 'CHECKED' ;
2327 $selected { 'ENGINES' }{ $cgiparams { 'ENGINES' }} = 'SELECTED' ;
2328 $checked { 'MSSFIX' }{ 'off' } = '' ;
2329 $checked { 'MSSFIX' }{ 'on' } = '' ;
2330 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
2331 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
2332 $selected { 'LOG_VERB' }{ '1' } = '' ;
2333 $selected { 'LOG_VERB' }{ '2' } = '' ;
2334 $selected { 'LOG_VERB' }{ '3' } = '' ;
2335 $selected { 'LOG_VERB' }{ '4' } = '' ;
2336 $selected { 'LOG_VERB' }{ '5' } = '' ;
2337 $selected { 'LOG_VERB' }{ '6' } = '' ;
2338 $selected { 'LOG_VERB' }{ '7' } = '' ;
2339 $selected { 'LOG_VERB' }{ '8' } = '' ;
2340 $selected { 'LOG_VERB' }{ '9' } = '' ;
2341 $selected { 'LOG_VERB' }{ '10' } = '' ;
2342 $selected { 'LOG_VERB' }{ '11' } = '' ;
2343 $selected { 'LOG_VERB' }{ '0' } = '' ;
2344 $selected { 'LOG_VERB' }{ $cgiparams { 'LOG_VERB' }} = 'SELECTED' ;
2346 & Header
:: showhttpheaders
();
2347 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
2348 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
2349 if ( $errormessage ) {
2350 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2351 print "<class name='base'> $errormessage \n " ;
2352 print " </class> \n " ;
2353 & Header
:: closebox
();
2355 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'advanced server' });
2357 <form method='post' enctype='multipart/form-data' disabled>
2358 <table width='100%' border=0>
2360 <td colspan='4'><b> $Lang ::tr{'dhcp-options'}</b></td>
2363 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2366 <td class='base'>Domain</td>
2367 <td><input type='TEXT' name='DHCP_DOMAIN' value=' $cgiparams {'DHCP_DOMAIN'}' size='30' /></td>
2370 <td class='base'>DNS</td>
2371 <td><input type='TEXT' name='DHCP_DNS' value=' $cgiparams {'DHCP_DNS'}' size='30' /></td>
2374 <td class='base'>WINS</td>
2375 <td><input type='TEXT' name='DHCP_WINS' value=' $cgiparams {'DHCP_WINS'}' size='30' /></td>
2378 <td colspan='4'><b> $Lang ::tr{'ovpn routes push options'}</b></td>
2381 <td class='base'> $Lang ::tr{'ovpn routes push'}</td>
2383 <textarea name='ROUTES_PUSH' cols='26' rows='6' wrap='off'>
2387 if ( $cgiparams { 'ROUTES_PUSH' } ne '' )
2389 print $cgiparams { 'ROUTES_PUSH' };
2398 <table width='100%'>
2400 <td class'base'><b> $Lang ::tr{'misc-options'}</b></td>
2403 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2406 <td class='base'>Client-To-Client</td>
2407 <td><input type='checkbox' name='CLIENT2CLIENT' $checked {'CLIENT2CLIENT'}{'on'} /></td>
2410 <td class='base'>Redirect-Gateway def1</td>
2411 <td><input type='checkbox' name='REDIRECT_GW_DEF1' $checked {'REDIRECT_GW_DEF1'}{'on'} /></td>
2414 <td class='base'>Max-Clients</td>
2415 <td><input type='text' name='MAX_CLIENTS' value=' $cgiparams {'MAX_CLIENTS'}' size='10' /></td>
2418 <td class='base'>Keppalive <br />
2419 (ping/ping-restart)</td>
2420 <td><input type='TEXT' name='KEEPALIVE_1' value=' $cgiparams {'KEEPALIVE_1'}' size='10' /></td>
2421 <td><input type='TEXT' name='KEEPALIVE_2' value=' $cgiparams {'KEEPALIVE_2'}' size='10' /></td>
2424 <td class='base'>fragment <br></td>
2425 <td><input type='TEXT' name='FRAGMENT' value=' $cgiparams {'FRAGMENT'}' size='10' /></td>
2426 <td>Default: <span class="base">1300</span></td>
2429 <td class='base'>mssfix</td>
2430 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
2431 <td>Default: on</td>
2435 <td class='base'> $Lang ::tr{'ovpn mtu-disc'}</td>
2436 <td><input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}</td>
2437 <td><input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}</td>
2438 <td><input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}</td>
2439 <td><input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}</td>
2445 <table width='100%'>
2447 <td class'base'><b>Crypto-Engines</b></td>
2450 <td width='15%'></td> <td width='30%'> </td><td width='25%'> </td><td width='30%'></td>
2452 <tr><td class='base'>Engines:</td>
2453 <td><select name='ENGINES'><option value="none" $selected {'ENGINES'}{'none'}>none</option>
2454 <option value="cryptodev" $selected {'ENGINES'}{'cryptodev'}>cryptodev</option>
2455 <option value="padlock" $selected {'ENGINES'}{'padlock'}>padlock</option>
2461 <table width='100%'>
2463 <td class'base'><b> $Lang ::tr{'log-options'}</b></td>
2466 <td width='15%'></td> <td width='30%'> </td><td width='25%'> </td><td width='30%'></td>
2469 <tr><td class='base'>VERB</td>
2470 <td><select name='LOG_VERB'><option value='1' $selected {'LOG_VERB'}{'1'}>1</option>
2471 <option value='2' $selected {'LOG_VERB'}{'2'}>2</option>
2472 <option value='3' $selected {'LOG_VERB'}{'3'}>3</option>
2473 <option value='4' $selected {'LOG_VERB'}{'4'}>4</option>
2474 <option value='5' $selected {'LOG_VERB'}{'5'}>5</option>
2475 <option value='6' $selected {'LOG_VERB'}{'6'}>6</option>
2476 <option value='7' $selected {'LOG_VERB'}{'7'}>7</option>
2477 <option value='8' $selected {'LOG_VERB'}{'8'}>8</option>
2478 <option value='9' $selected {'LOG_VERB'}{'9'}>9</option>
2479 <option value='10' $selected {'LOG_VERB'}{'10'}>10</option>
2480 <option value='11' $selected {'LOG_VERB'}{'11'}>11</option>
2481 <option value='0' $selected {'LOG_VERB'}{'0'}>0</option></select></td>
2485 if ( - e
"/var/run/openvpn.pid" ){
2486 print " <br><b><font color='#990000'> $Lang ::tr{'attention'}:</b></font><br>
2487 $Lang ::tr{'server restart'}<br><br>
2492 <table width='100%'>
2495 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' /></td>
2496 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2504 & Header
:: closebox
();
2505 # print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'>$Lang::tr{'back'}</a></div>";
2506 & Header
:: closebigbox
();
2507 & Header
:: closepage
();
2511 # A.Marx CCD Add,delete or edit CCD net
2513 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd net' } ||
2514 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' } ||
2515 $cgiparams { 'ACTION' } eq "kill" ||
2516 $cgiparams { 'ACTION' } eq "edit" ||
2517 $cgiparams { 'ACTION' } eq 'editsave' ){
2518 & Header
:: showhttpheaders
();
2519 & Header
:: openpage
( $Lang :: tr
{ 'ccd net' }, 1 , '' );
2520 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2522 if ( $cgiparams { 'ACTION' } eq "kill" ){
2523 & delccdnet
( $cgiparams { 'net' });
2526 if ( $cgiparams { 'ACTION' } eq 'editsave' ){
2527 my ( $a , $b ) = split ( /\|/ , $cgiparams { 'ccdname' });
2528 if ( $a ne $b ){ & modccdnet
( $a , $b );}
2531 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' }) {
2532 & addccdnet
( $cgiparams { 'ccdname' }, $cgiparams { 'ccdsubnet' }, $cgiparams { 'DOVPN_SUBNET' });
2534 if ( $errormessage ) {
2535 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2536 print "<class name='base'> $errormessage " ;
2537 print " </class>" ;
2538 & Header
:: closebox
();
2540 if ( $cgiparams { 'ACTION' } eq "edit" ){
2542 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd modify' });
2545 <table width='100%' border=0>
2546 <tr><form method='post'>
2547 <td width='10%' nowrap='nowrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2548 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' readonly /></td></tr>
2549 <tr><td colspan='4' align='right'><hr><input type='submit' value=' $Lang ::tr{'save'}' /><input type='hidden' name='ACTION' value='editsave'/>
2550 <input type='hidden' name='ccdname' value=' $cgiparams {'ccdname'}'/><input type='submit' value=' $Lang ::tr{'cancel'}' />
2555 & Header
:: closebox
();
2557 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2559 <table width='100%' border='0' cellpadding='0' cellspacing='1'>
2561 <td class='boldbase' align='center'><b> $Lang ::tr{'ccd name'}</td><td class='boldbase' align='center'><b> $Lang ::tr{'network'}</td><td class='boldbase' width='15%' align='center'><b> $Lang ::tr{'ccd used'}</td><td width='3%'></td><td width='3%'></td></tr>
2566 if (! - e
"/var/run/openvpn.pid" ){
2567 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd add' });
2569 <table width='100%' border='0'>
2570 <tr><form method='post'>
2571 <td colspan='4'> $Lang ::tr{'ccd hint'}<br><br></td></tr>
2573 <td width='10%' nowrap='nwrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2574 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' /></td></tr>
2575 <tr><td colspan=4><hr /></td></tr><tr>
2576 <td colspan='4' align='right'><input type='hidden' name='ACTION' value=' $Lang ::tr{'ccd add'}' /><input type='submit' value=' $Lang ::tr{'add'}' /><input type='hidden' name='DOVPN_SUBNET' value=' $cgiparams {'DOVPN_SUBNET'}'/></td></tr>
2580 & Header
:: closebox
();
2582 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2584 <table width='100%' border='0' cellpadding='0' cellspacing='1'>
2586 <td class='boldbase' align='center' nowrap='nowrap' width='20%'><b> $Lang ::tr{'ccd name'}</td><td class='boldbase' align='center' width='8%'><b> $Lang ::tr{'network'}</td><td class='boldbase' width='8%' align='center' nowrap='nowrap'><b> $Lang ::tr{'ccd used'}</td><td width='1%' align='center'></td><td width='1%' align='center'></td></tr>
2591 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
2594 foreach my $key ( keys %ccdconfhash ) {
2595 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
2597 my $ccdhosts = & hostsinnet
( $ccdconf [ 0 ]);
2598 if ( $count % 2 ){ print " <tr bgcolor=' $color {'color22'}'>" ;}
2599 else { print " <tr bgcolor=' $color {'color20'}'>" ;}
2600 print "<td> $ccdconf [0]</td><td align='center'> $ccdconf [1]</td><td align='center'> $ccdhosts /" .(& ccdmaxclients
( $ccdconf [ 1 ])+ 1 ). "</td><td>" ;
2602 <form method='post' />
2603 <input type='image' src='/images/edit.gif' align='middle' alt= $Lang ::tr{'edit'} title= $Lang ::tr{'edit'} />
2604 <input type='hidden' name='ACTION' value='edit'/>
2605 <input type='hidden' name='ccdname' value=' $ccdconf [0]' />
2606 <input type='hidden' name='ccdsubnet' value=' $ccdconf [1]' />
2608 <form method='post' />
2609 <td><input type='hidden' name='ACTION' value='kill'/>
2610 <input type='hidden' name='number' value=' $count ' />
2611 <input type='hidden' name='net' value=' $ccdconf [0]' />
2612 <input type='image' src='/images/delete.gif' align='middle' alt= $Lang ::tr{'remove'} title= $Lang ::tr{'remove'} /></form></td></tr>
2616 print "</table></form>" ;
2617 & Header
:: closebox
();
2618 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2619 & Header
:: closebigbox
();
2620 & Header
:: closepage
();
2626 ### Openvpn Connections Statistics
2628 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ovpn con stat' }) {
2629 & Header
:: showhttpheaders
();
2630 & Header
:: openpage
( $Lang :: tr
{ 'ovpn con stat' }, 1 , '' );
2631 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2632 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ovpn con stat' });
2635 # <td><b>$Lang::tr{'protocol'}</b></td>
2636 # protocol temp removed
2638 <table width='100%' border='0' cellpadding='2' cellspacing='0'>
2640 <td><b> $Lang ::tr{'common name'}</b></td>
2641 <td><b> $Lang ::tr{'real address'}</b></td>
2642 <td><b> $Lang ::tr{'virtual address'}</b></td>
2643 <td><b> $Lang ::tr{'loged in at'}</b></td>
2644 <td><b> $Lang ::tr{'bytes sent'}</b></td>
2645 <td><b> $Lang ::tr{'bytes received'}</b></td>
2646 <td><b> $Lang ::tr{'last activity'}</b></td>
2650 my $filename = "/var/log/ovpnserver.log" ;
2651 open ( FILE
, $filename ) or die 'Unable to open config file.' ;
2652 my @current = < FILE
>;
2661 my %userlookup = ();
2662 foreach my $line ( @current )
2665 if ( $line =~ /^Updated,(.+)/ ){
2666 @match = split ( /^Updated,(.+)/ , $line );
2667 $status = $match [ 1 ];
2670 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
2671 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
2672 if ( $match [ 1 ] ne "Common Name" ) {
2674 $userlookup { $match [ 2 ]} = $uid ;
2675 $users [ $uid ]{ 'CommonName' } = $match [ 1 ];
2676 $users [ $uid ]{ 'RealAddress' } = $match [ 2 ];
2677 $users [ $uid ]{ 'BytesReceived' } = & sizeformat
( $match [ 3 ]);
2678 $users [ $uid ]{ 'BytesSent' } = & sizeformat
( $match [ 4 ]);
2679 $users [ $uid ]{ 'Since' } = $match [ 5 ];
2680 $users [ $uid ]{ 'Proto' } = $proto ;
2684 if ( $line =~ /^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ ) {
2685 @match = split ( m/^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ , $line );
2686 if ( $match [ 1 ] ne "Virtual Address" ) {
2687 $address = $match [ 3 ];
2688 #find the uid in the lookup table
2689 $uid = $userlookup { $address };
2690 $users [ $uid ]{ 'VirtualAddress' } = $match [ 1 ];
2691 $users [ $uid ]{ 'LastRef' } = $match [ 4 ];
2697 for ( my $idx = 1 ; $idx <= $user2 ; $idx ++){
2699 print "<tr bgcolor=' $color {'color20'}'> \n " ;
2701 print "<tr bgcolor=' $color {'color22'}'> \n " ;
2703 print "<td align='left'> $users [ $idx -1]{'CommonName'}</td>" ;
2704 print "<td align='left'> $users [ $idx -1]{'RealAddress'}</td>" ;
2705 print "<td align='left'> $users [ $idx -1]{'VirtualAddress'}</td>" ;
2706 print "<td align='left'> $users [ $idx -1]{'Since'}</td>" ;
2707 print "<td align='left'> $users [ $idx -1]{'BytesSent'}</td>" ;
2708 print "<td align='left'> $users [ $idx -1]{'BytesReceived'}</td>" ;
2709 print "<td align='left'> $users [ $idx -1]{'LastRef'}</td>" ;
2710 # print "<td align='left'>$users[$idx-1]{'Proto'}</td>";
2716 <table width='100%' border='0' cellpadding='2' cellspacing='0'>
2721 <tr><td align='center' > $Lang ::tr{'the statistics were last updated at'} <b> $status </b></td></tr>
2725 & Header
:: closebox
();
2726 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2727 & Header
:: closebigbox
();
2728 & Header
:: closepage
();
2732 ### Download Certificate
2734 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
2735 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2737 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2738 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \r\n " ;
2739 print "Content-Type: application/octet-stream \r\n\r\n " ;
2740 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2745 ### Enable/Disable connection
2748 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
2750 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2751 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2753 if ( $confighash { $cgiparams { 'KEY' }}) {
2754 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
2755 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
2756 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2757 #&writeserverconf();
2758 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2759 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2760 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
2763 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
2764 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2765 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2766 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2768 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2769 #&writeserverconf();
2772 $errormessage = $Lang :: tr
{ 'invalid key' };
2776 ### Restart connection
2778 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
2779 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2780 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2782 if ( $confighash { $cgiparams { 'KEY' }}) {
2783 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2784 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2785 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
2788 $errormessage = $Lang :: tr
{ 'invalid key' };
2792 ### Remove connection
2794 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
2795 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2796 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2798 if ( $confighash { $cgiparams { 'KEY' }}) {
2799 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2800 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2801 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2803 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
2804 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2805 delete $confighash { $cgiparams { 'KEY' }};
2806 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2807 #&writeserverconf();
2809 $errormessage = $Lang :: tr
{ 'invalid key' };
2814 ### Choose between adding a host-net or net-net connection
2821 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
2822 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2823 & Header
:: showhttpheaders
();
2824 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2825 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2826 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection type' });
2828 if ( - s
"${General::swroot}/ovpn/settings" ) {
2831 <b> $Lang ::tr{'connection type'}:</b><br />
2832 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
2833 <tr><td><input type='radio' name='TYPE' value='host' checked /></td>
2834 <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
2835 <tr><td><input type='radio' name='TYPE' value='net' /></td>
2836 <td class='base'> $Lang ::tr{'net to net vpn'}</td></tr>
2837 <tr><td><input type='radio' name='TYPE' value='net2net' /></td>
2838 <td class='base'> $Lang ::tr{'net to net vpn'} (Upload Client Package)</td></tr>
2839 <tr><td> </td><td class='base'><input type='file' name='FH' size='30'></td></tr>
2840 <tr><td> </td><td>Import Connection Name <img src='/blob.gif' /></td></tr>
2841 <tr><td> </td><td class='base'><input type='text' name='n2nname' size='30'>Default : Client Packagename</td></tr>
2842 <tr><td colspan='3'><hr /></td></tr>
2843 <tr><td align='right' colspan='3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
2844 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
2852 <b> $Lang ::tr{'connection type'}:</b><br />
2853 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
2854 <tr><td><input type='radio' name='TYPE' value='host' checked /></td> <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
2855 <tr><td align='right' colspan'3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
2862 & Header
:: closebox
();
2863 & Header
:: closebigbox
();
2864 & Header
:: closepage
();
2871 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2net' )){
2875 my $uplconffilename = '' ;
2876 my $uplconffilename2 = '' ;
2877 my $uplp12name = '' ;
2878 my $uplp12name2 = '' ;
2885 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2887 # Check if a file is uploaded
2889 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
2890 $errormessage = $Lang :: tr
{ 'there was no file upload' };
2894 # Move uploaded IPfire n2n package to temporary file
2896 ( my $fh , my $filename ) = tempfile
( );
2897 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
2902 my $zip = Archive
:: Zip
-> new ();
2903 my $zipName = $filename ;
2904 my $status = $zip -> read ( $zipName );
2905 if ( $status != AZ_OK
) {
2906 $errormessage = "Read of $zipName failed \n " ;
2910 my $tempdir = tempdir
( CLEANUP
=> 1 );
2911 my @files = $zip -> memberNames ();
2913 $zip -> extractMemberWithoutPaths ( $_ , " $tempdir / $_ " );
2915 my $countfiles = @files ;
2917 # Check if we have not more then 2 files
2919 if ( $countfiles == 2 ){
2921 if ( $_ =~ /.conf$/ ){
2922 $uplconffilename = $_ ;
2924 if ( $_ =~ /.p12$/ ){
2928 if (( $uplconffilename eq '' ) || ( $uplp12name eq '' )){
2929 $errormessage = "Either no *.conf or no *.p12 file found \n " ;
2933 open ( FILE
, " $tempdir / $uplconffilename " ) or die 'Unable to open*.conf file' ;
2934 @firen2nconf = < FILE
>;
2936 chomp ( @firen2nconf );
2940 $errormessage = "Filecount does not match only 2 files are allowed \n " ;
2948 if ( $cgiparams { 'n2nname' } ne '' ){
2950 $uplconffilename2 = " $cgiparams {'n2nname'}.conf" ;
2951 $uplp12name2 = " $cgiparams {'n2nname'}.p12" ;
2952 $n2nname [ 0 ] = $cgiparams { 'n2nname' };
2953 my @n2nname2 = split ( /\./ , $uplconffilename );
2954 $n2nname2 [ 0 ] =~ s/\n|\r//g ;
2955 my $input1 = "${General::swroot}/ovpn/certs/ $uplp12name " ;
2956 my $output1 = "${General::swroot}/ovpn/certs/ $uplp12name2 " ;
2957 my $input2 = " $n2nname2 [0]n2n" ;
2958 my $output2 = " $n2nname [0]n2n" ;
2959 my $filename = " $tempdir / $uplconffilename " ;
2960 open ( FILE
, "< $filename " ) or die 'Unable to open config file.' ;
2961 my @current = < FILE
>;
2963 foreach ( @current ) { s/$input1/$output1/g ;}
2964 foreach ( @current ) { s/$input2/$output2/g ;}
2965 open ( OUT
, "> $filename " ) || die 'Unable to open config file.' ;
2970 $uplconffilename2 = $uplconffilename ;
2971 $uplp12name2 = $uplp12name ;
2972 @n2nname = split ( /\./ , $uplconffilename );
2973 $n2nname [ 0 ] =~ s/\n|\r//g ;
2975 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
2976 unless (- d
"${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" , 0770 or die "Unable to create dir $!" ;}
2978 move
( " $tempdir / $uplconffilename " , "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $uplconffilename2 " );
2981 $errormessage = "*.conf move failed: $!" ;
2986 move
( " $tempdir / $uplp12name " , "${General::swroot}/ovpn/certs/ $uplp12name2 " );
2987 chmod 0600 , "${General::swroot}/ovpn/certs/ $uplp12name " ;
2990 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
2998 my @n2nmtudisc = split ( / / , ( grep { /^mtu-disc/ } @firen2nconf )[ 0 ]);;
2999 my @n2nproto2 = split ( / / , ( grep { /^proto/ } @firen2nconf )[ 0 ]);
3000 my @n2nproto = split ( /-/ , $n2nproto2 [ 1 ]);
3001 my @n2nport = split ( / / , ( grep { /^port/ } @firen2nconf )[ 0 ]);
3002 my @n2ntunmtu = split ( / / , ( grep { /^tun-mtu/ } @firen2nconf )[ 0 ]);
3003 my @n2ncomplzo = grep { /^comp-lzo/ } @firen2nconf ;
3004 if ( $n2ncomplzo [ 0 ] =~ /comp-lzo/ ){ $complzoactive = "on" ;} else { $complzoactive = "off" ;}
3005 my @n2nmssfix = grep { /^mssfix/ } @firen2nconf ;
3006 if ( $n2nmssfix [ 0 ] =~ /mssfix/ ){ $mssfixactive = "on" ;} else { $mssfixactive = "off" ;}
3007 #my @n2nmssfix = split(/ /, (grep { /^mssfix/ } @firen2nconf)[0]);
3008 my @n2nfragment = split ( / / , ( grep { /^fragment/ } @firen2nconf )[ 0 ]);
3009 my @n2nremote = split ( / / , ( grep { /^remote/ } @firen2nconf )[ 0 ]);
3010 my @n2novpnsuball = split ( / / , ( grep { /^ifconfig/ } @firen2nconf )[ 0 ]);
3011 my @n2novpnsub = split ( /\./ , $n2novpnsuball [ 1 ]);
3012 my @n2nremsub = split ( / / , ( grep { /^route/ } @firen2nconf )[ 0 ]);
3013 my @n2nmgmt = split ( / / , ( grep { /^management/ } @firen2nconf )[ 0 ]);
3014 my @n2nlocalsub = split ( / / , ( grep { /^# remsub/ } @firen2nconf )[ 0 ]);
3018 # m.a.d delete CR and LF from arrays for this chomp doesnt work
3021 $n2nremote [ 1 ] =~ s/\n|\r//g ;
3022 $n2novpnsub [ 0 ] =~ s/\n|\r//g ;
3023 $n2novpnsub [ 1 ] =~ s/\n|\r//g ;
3024 $n2novpnsub [ 2 ] =~ s/\n|\r//g ;
3025 $n2nproto [ 0 ] =~ s/\n|\r//g ;
3026 $n2nport [ 1 ] =~ s/\n|\r//g ;
3027 $n2ntunmtu [ 1 ] =~ s/\n|\r//g ;
3028 $n2nremsub [ 1 ] =~ s/\n|\r//g ;
3029 $n2nremsub [ 2 ] =~ s/\n|\r//g ;
3030 $n2nlocalsub [ 2 ] =~ s/\n|\r//g ;
3031 $n2nfragment [ 1 ] =~ s/\n|\r//g ;
3032 $n2nmgmt [ 2 ] =~ s/\n|\r//g ;
3033 $n2nmtudisc [ 1 ] =~ s/\n|\r//g ;
3034 chomp ( $complzoactive );
3035 chomp ( $mssfixactive );
3042 # Check if there is no other entry with this name
3045 foreach my $dkey ( keys %confighash ) {
3046 if ( $confighash { $dkey }[ 1 ] eq $n2nname [ 0 ]) {
3047 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3048 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3049 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3050 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3056 # Check if OpenVPN Subnet is valid
3059 foreach my $dkey ( keys %confighash ) {
3060 if ( $confighash { $dkey }[ 27 ] eq " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ) {
3061 $errormessage = 'The OpenVPN Subnet is already in use' ;
3062 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3063 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3064 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3070 # Check im Dest Port is vaild
3073 foreach my $dkey ( keys %confighash ) {
3074 if ( $confighash { $dkey }[ 29 ] eq $n2nport [ 1 ] ) {
3075 $errormessage = 'The OpenVPN Port is already in use' ;
3076 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3077 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3078 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3085 $key = & General
:: findhasharraykey
( \
%confighash );
3087 foreach my $i ( 0 .. 39 ) { $confighash { $key }[ $i ] = "" ;}
3089 $confighash { $key }[ 0 ] = 'off' ;
3090 $confighash { $key }[ 1 ] = $n2nname [ 0 ];
3091 $confighash { $key }[ 2 ] = $n2nname [ 0 ];
3092 $confighash { $key }[ 3 ] = 'net' ;
3093 $confighash { $key }[ 4 ] = 'cert' ;
3094 $confighash { $key }[ 6 ] = 'client' ;
3095 $confighash { $key }[ 8 ] = $n2nlocalsub [ 2 ];
3096 $confighash { $key }[ 10 ] = $n2nremote [ 1 ];
3097 $confighash { $key }[ 11 ] = " $n2nremsub [1]/ $n2nremsub [2]" ;
3098 $confighash { $key }[ 22 ] = $n2nmgmt [ 2 ];
3099 $confighash { $key }[ 23 ] = $mssfixactive ;
3100 $confighash { $key }[ 24 ] = $n2nfragment [ 1 ];
3101 $confighash { $key }[ 25 ] = 'IPFire n2n Client' ;
3102 $confighash { $key }[ 26 ] = 'red' ;
3103 $confighash { $key }[ 27 ] = " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ;
3104 $confighash { $key }[ 28 ] = $n2nproto [ 0 ];
3105 $confighash { $key }[ 29 ] = $n2nport [ 1 ];
3106 $confighash { $key }[ 30 ] = $complzoactive ;
3107 $confighash { $key }[ 31 ] = $n2ntunmtu [ 1 ];
3108 $confighash { $key }[ 38 ] = $n2nmtudisc [ 1 ];
3111 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3115 & Header
:: showhttpheaders
();
3116 & Header
:: openpage
( 'Validate imported configuration' , 1 , '' );
3117 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
3118 if ( $errormessage ) {
3119 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
3120 print "<class name='base'> $errormessage " ;
3121 print " </class>" ;
3122 & Header
:: closebox
();
3126 & Header
:: openbox
( '100%' , 'LEFT' , 'import ipfire net2net config' );
3128 if ( $errormessage eq '' ){
3130 <!-- ipfire net2net config gui -->
3131 <table width='100%'>
3132 <tr><td width='25%'> </td><td width='25%'> </td></tr>
3133 <tr><td class='boldbase'> $Lang ::tr{'name'}:</td><td><b> $n2nname [0]</b></td></tr>
3134 <tr><td> </td><td> </td></tr>
3135 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td><td><b> $confighash { $key }[6]</b></td></tr>
3136 <tr><td class='boldbase' nowrap='nowrap'>Remote Host </td><td><b> $confighash { $key }[10]</b></td></tr>
3137 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td><td><b> $confighash { $key }[8]</b></td></tr>
3138 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td><td><b> $confighash { $key }[11]</b></td></tr>
3139 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td><td><b> $confighash { $key }[27]</b></td></tr>
3140 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td><td><b> $confighash { $key }[28]</b></td></tr>
3141 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'destination port'}:</td><td><b> $confighash { $key }[29]</b></td></tr>
3142 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td><td><b> $confighash { $key }[30]</b></td></tr>
3143 <tr><td class='boldbase' nowrap='nowrap'>MSSFIX </td><td><b> $confighash { $key }[23]</b></td></tr>
3144 <tr><td class='boldbase' nowrap='nowrap'>Fragment </td><td><b> $confighash { $key }[24]</b></td></tr>
3145 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'}</td><td><b> $confighash { $key }[31]</b></td></tr>
3146 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td><td><b> $confighash { $key }[38]</b></td></tr>
3147 <tr><td class='boldbase' nowrap='nowrap'>Management Port </td><td><b> $confighash { $key }[22]</b></td></tr>
3148 <tr><td> </td><td> </td></tr>
3152 & Header
:: closebox
();
3155 if ( $errormessage ) {
3156 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3158 print "<div align='center'><form method='post' ENCTYPE='multipart/form-data'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />" ;
3159 print "<input type='hidden' name='TYPE' value='net2netakn' />" ;
3160 print "<input type='hidden' name='KEY' value=' $key ' />" ;
3161 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
3163 & Header
:: closebigbox
();
3164 & Header
:: closepage
();
3169 ### Accept IPFire n2n Package Settings
3172 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3175 ### Discard and Rollback IPFire n2n Package Settings
3178 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'cancel' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3180 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3182 if ( $confighash { $cgiparams { 'KEY' }}) {
3184 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
3185 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
3186 unlink ( $certfile ) or die "Removing $certfile fail: $!" ;
3187 unlink ( $conffile ) or die "Removing $conffile fail: $!" ;
3188 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
3189 delete $confighash { $cgiparams { 'KEY' }};
3190 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3193 $errormessage = $Lang :: tr
{ 'invalid key' };
3203 ### Adding a new connection
3205 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
3206 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
3207 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
3209 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3210 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
3211 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3213 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
3214 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
3215 $errormessage = $Lang :: tr
{ 'invalid key' };
3218 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
3219 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
3220 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
3221 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
3222 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
3223 $cgiparams { 'SIDE' } = $confighash { $cgiparams { 'KEY' }}[ 6 ];
3224 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
3225 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
3226 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
3227 $cgiparams { 'OVPN_MGMT' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
3228 $cgiparams { 'MSSFIX' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
3229 $cgiparams { 'FRAGMENT' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
3230 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
3231 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
3232 $cgiparams { 'OVPN_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
3233 $cgiparams { 'PROTOCOL' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
3234 $cgiparams { 'DEST_PORT' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
3235 $cgiparams { 'COMPLZO' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
3236 $cgiparams { 'MTU' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
3237 $cgiparams { 'CHECK1' } = $confighash { $cgiparams { 'KEY' }}[ 32 ];
3238 my $name = $cgiparams { 'CHECK1' } ;
3239 $cgiparams { $name } = $confighash { $cgiparams { 'KEY' }}[ 33 ];
3240 $cgiparams { 'RG' } = $confighash { $cgiparams { 'KEY' }}[ 34 ];
3241 $cgiparams { 'CCD_DNS1' } = $confighash { $cgiparams { 'KEY' }}[ 35 ];
3242 $cgiparams { 'CCD_DNS2' } = $confighash { $cgiparams { 'KEY' }}[ 36 ];
3243 $cgiparams { 'CCD_WINS' } = $confighash { $cgiparams { 'KEY' }}[ 37 ];
3244 $cgiparams { 'PMTU_DISCOVERY' } = $confighash { $cgiparams { 'KEY' }}[ 38 ];
3245 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
3246 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
3248 #A.Marx CCD check iroute field and convert it to decimal
3251 my %ccdroutehash =();
3253 if ( $cgiparams { 'IR' } ne '' ){
3254 @temp = split ( " \n " , $cgiparams { 'IR' });
3255 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3257 foreach my $key ( keys %ccdroutehash ) {
3258 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3260 delete $ccdroutehash { $key };
3262 $keypoint = & General
:: findhasharraykey
( \
%ccdroutehash );
3265 $ccdroutehash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3268 foreach $val ( @temp ){
3271 my ( $ip , $cidr ) = split ( /\/ /, $val );
3272 $cidr =& General
:: iporsubtodec
( $cidr );
3274 #check if iroute exists in ccdroute
3275 foreach my $key ( keys %ccdroutehash ) {
3276 foreach my $oldiroute ( 1 .. $ #{$ccdroutehash{$key}}){
3277 if ( $ccdroutehash { $key }[ $oldiroute ] eq " $ip / $cidr " ) {
3278 $errormessage = $Lang :: tr
{ 'ccd err irouteexist' };
3284 #check for existing network IP's
3285 if ((& General
:: IpInSubnet
( $ip , $netsettings { GREEN_NETADDRESS
}, $netsettings { GREEN_NETMASK
}) && $netsettings { GREEN_NETADDRESS
} ne '0.0.0.0' )||
3286 (& General
:: IpInSubnet
( $ip , $netsettings { RED_NETADDRESS
}, $netsettings { RED_NETMASK
}) && $netsettings { RED_NETADDRESS
} ne '0.0.0.0' )||
3287 (& General
:: IpInSubnet
( $ip , $netsettings { BLUE_NETADDRESS
}, $netsettings { BLUE_NETMASK
}) && $netsettings { BLUE_NETADDRESS
} ne '0.0.0.0' && $netsettings { BLUE_NETADDRESS
} gt '' )||
3288 (& General
:: IpInSubnet
( $ip , $netsettings { ORANGE_NETADDRESS
}, $netsettings { ORANGE_NETMASK
}) && $netsettings { ORANGE_NETADDRESS
} ne '0.0.0.0' && $netsettings { ORANGE_NETADDRESS
} gt '' )){
3289 $errormessage = " $ip USED FOR SYSTEM!" ;
3295 if (& General
:: validipandmask
( $val )){
3296 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3298 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $ip / $cidr )" ;
3303 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3306 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3307 foreach my $key ( keys %ccdroutehash ) {
3308 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3309 delete $ccdroutehash { $key };
3310 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3316 #check route field and convert it to decimal
3321 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3322 if ( $cgiparams { 'IFROUTE' } eq $Lang :: tr
{ 'ccd none' } || $cgiparams { 'IFROUTE' } eq '' ) {
3323 undef $cgiparams { 'IFROUTE' };
3324 foreach my $key ( keys %ccdroute2hash ){
3325 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3326 delete $ccdroute2hash { $key };
3329 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3332 foreach my $key ( keys %ccdroute2hash ) {
3333 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3335 delete $ccdroute2hash { $key };
3337 $keypoint = & General
:: findhasharraykey
( \
%ccdroute2hash );
3338 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3342 $ccdroute2hash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3343 @temp = split ( /\|/ , $cgiparams { 'IFROUTE' });
3345 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%ownnet );
3346 foreach $val ( @temp ){
3349 if ( $val eq $Lang :: tr
{ 'green' })
3351 $val = $ownnet { GREEN_NETADDRESS
}. "/" . $ownnet { GREEN_NETMASK
};
3353 if ( $val eq $Lang :: tr
{ 'blue' })
3355 $val = $ownnet { BLUE_NETADDRESS
}. "/" . $ownnet { BLUE_NETMASK
};
3357 if ( $val eq $Lang :: tr
{ 'orange' })
3359 $val = $ownnet { ORANGE_NETADDRESS
}. "/" . $ownnet { ORANGE_NETMASK
};
3361 my ( $ip , $cidr ) = split ( /\/ /, $val );
3362 if (! & check_routes_push
( $val )){ $errormessage = $errormessage . "Route $val " . $Lang :: tr
{ 'ccd err routeovpn2' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3363 if (! & check_ccdroute
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err inuse' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3364 if (! & check_ccdconf
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err routeovpn' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3365 if (& General
:: validipandmask
( $val )){
3366 $val = $ip . "/" .& General
:: iporsubtodec
( $cidr );
3367 $ccdroute2hash { $keypoint }[ $i ] = $val ;
3369 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3374 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3377 if ( $cgiparams { 'CCD_DNS1' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS1' })) {
3378 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 1" ;
3382 if ( $cgiparams { 'CCD_DNS2' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS2' })) {
3383 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 2" ;
3387 if ( $cgiparams { 'CCD_WINS' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_WINS' })) {
3388 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp wins' };
3396 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
3397 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
3398 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3399 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3400 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3406 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
3407 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
3408 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3409 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3410 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3415 if ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
3416 $errormessage = $Lang :: tr
{ 'name is invalid' };
3417 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3418 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3419 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3424 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
3425 $errormessage = $Lang :: tr
{ 'name too long' };
3426 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3427 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3428 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3437 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3439 if ( $cgiparams { 'DEST_PORT' } eq $vpnsettings { 'DDEST_PORT' }) {
3440 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3441 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3442 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3446 if ( $cgiparams { 'DEST_PORT' } eq '' ) {
3447 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3448 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3449 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3453 if ( $cgiparams { 'OVPN_SUBNET' } eq $vpnsettings { 'DOVPN_SUBNET' }) {
3454 $errormessage = $Lang :: tr
{ 'openvpn subnet is used' };
3455 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3456 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3460 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3461 $errormessage = $Lang :: tr
{ 'openvpn mssfix allowed with udp' };
3462 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3463 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3467 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'FRAGMENT' } ne '' )) {
3468 $errormessage = $Lang :: tr
{ 'openvpn fragment allowed with udp' };
3469 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3470 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3474 if (( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) && ( $cgiparams { 'MTU' } ne '1500' )) {
3475 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc and mtu not 1500' };
3476 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3477 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3481 if ( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) {
3482 if (( $cgiparams { 'FRAGMENT' } ne '' ) || ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3483 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
3484 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3485 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3490 if ( & validdotmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3491 $errormessage = $Lang :: tr
{ 'openvpn prefix local subnet' };
3492 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3493 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3497 if ( & validdotmask
( $cgiparams { 'OVPN_SUBNET' })) {
3498 $errormessage = $Lang :: tr
{ 'openvpn prefix openvpn subnet' };
3499 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3500 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3504 if ( & validdotmask
( $cgiparams { 'REMOTE_SUBNET' })) {
3505 $errormessage = $Lang :: tr
{ 'openvpn prefix remote subnet' };
3506 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3507 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3511 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
3512 $cgiparams { 'OVPN_MGMT' } = $cgiparams { 'DEST_PORT' };
3517 # if (($cgiparams{'TYPE'} eq 'net') && ($cgiparams{'SIDE'} !~ /^(left|right)$/)) {
3518 # $errormessage = $Lang::tr{'ipfire side is invalid'};
3519 # goto VPNCONF_ERROR;
3522 # Check if there is no other entry with this name
3523 if (! $cgiparams { 'KEY' }) {
3524 foreach my $key ( keys %confighash ) {
3525 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
3526 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3527 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3528 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3529 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3536 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! $cgiparams { 'REMOTE' })) {
3537 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3538 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3539 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3540 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3545 if ( $cgiparams { 'REMOTE' }) {
3546 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
3547 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
3548 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3549 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3550 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3551 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3555 if (& valid_dns_host
( $cgiparams { 'REMOTE' })) {
3556 $warnmessage = " $Lang ::tr{'check vpn lr'} $cgiparams {'REMOTE'}. $Lang ::tr{'dns check failed'}" ;
3557 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3564 if ( $cgiparams { 'TYPE' } ne 'host' ) {
3565 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3566 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
3567 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3568 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3569 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3571 goto VPNCONF_ERROR
;}
3573 # Check if there is no other entry without IP-address and PSK
3574 if ( $cgiparams { 'REMOTE' } eq '' ) {
3575 foreach my $key ( keys %confighash ) {
3576 if (( $cgiparams { 'KEY' } ne $key ) &&
3577 ( $confighash { $key }[ 4 ] eq 'psk' || $cgiparams { 'AUTH' } eq 'psk' ) &&
3578 $confighash { $key }[ 10 ] eq '' ) {
3579 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
3584 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
3585 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
3586 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3587 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3591 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
3592 $errormessage = $Lang :: tr
{ 'invalid input' };
3595 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
3596 $errormessage = $Lang :: tr
{ 'invalid input' };
3601 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
3602 # if (! length($cgiparams{'PSK'}) ) {
3603 # $errormessage = $Lang::tr{'pre-shared key is too short'};
3604 # goto VPNCONF_ERROR;
3606 # if ($cgiparams{'PSK'} =~ /['",&]/) {
3607 # $errormessage = $Lang::tr{'invalid characters found in pre-shared key'};
3608 # goto VPNCONF_ERROR;
3610 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
3611 if ( $cgiparams { 'KEY' }) {
3612 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3615 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3616 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3620 # Move uploaded certificate request to a temporary file
3621 ( my $fh , my $filename ) = tempfile
( );
3622 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3627 # Sign the certificate request and move it
3628 # Sign the host certificate request
3629 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
3630 '-batch' , '-notext' ,
3632 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
3633 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
3635 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3637 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3638 & newcleanssldatabase
();
3642 & deletebackupcert
();
3645 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
3646 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
3648 $temp =~ s
+/ Email
+, E
+;
3649 $temp =~ s/ ST=/ S=/ ;
3650 $cgiparams { 'CERT_NAME' } = $temp ;
3651 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
3652 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
3653 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
3654 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
3657 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
3658 if ( $cgiparams { 'KEY' }) {
3659 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3662 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3663 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3666 # Move uploaded certificate to a temporary file
3667 ( my $fh , my $filename ) = tempfile
( );
3668 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3673 # Verify the certificate has a valid CA and move it
3675 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/cacert.pem $filename ` ;
3676 if ( $test =~ /: OK/ ) {
3679 foreach my $key ( keys %cahash ) {
3680 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $key }[0]cert.pem $filename ` ;
3681 if ( $test =~ /: OK/ ) {
3687 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
3691 move
( $filename , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3693 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
3699 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
3700 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
3702 $temp =~ s
+/ Email
+, E
+;
3703 $temp =~ s/ ST=/ S=/ ;
3704 $cgiparams { 'CERT_NAME' } = $temp ;
3705 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
3706 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
3707 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
3708 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3709 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
3712 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
3713 if ( $cgiparams { 'KEY' }) {
3714 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3717 # Validate input since the form was submitted
3718 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
3719 $errormessage = $Lang :: tr
{ 'name too long' };
3722 if ( $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
3723 $errormessage = $Lang :: tr
{ 'invalid input for name' };
3726 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
3727 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
3730 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
3731 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
3734 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
3735 $errormessage = $Lang :: tr
{ 'invalid input for department' };
3738 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
3739 $errormessage = $Lang :: tr
{ 'organization too long' };
3742 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
3743 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
3746 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
3747 $errormessage = $Lang :: tr
{ 'invalid input for city' };
3750 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
3751 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
3754 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
3755 $errormessage = $Lang :: tr
{ 'invalid input for country' };
3758 if ( $cgiparams { 'CERT_PASS1' } ne '' && $cgiparams { 'CERT_PASS2' } ne '' ){
3759 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
3760 $errormessage = $Lang :: tr
{ 'password too short' };
3764 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
3765 $errormessage = $Lang :: tr
{ 'passwords do not match' };
3769 # Replace empty strings with a .
3770 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
3771 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
3772 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
3774 # Create the Host certificate request client
3775 my $pid = open ( OPENSSL
, "|-" );
3776 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto VPNCONF_ERROR
;};
3777 if ( $pid ) { # parent
3778 print OPENSSL
" $cgiparams {'CERT_COUNTRY'} \n " ;
3779 print OPENSSL
" $state \n " ;
3780 print OPENSSL
" $city \n " ;
3781 print OPENSSL
" $cgiparams {'CERT_ORGANIZATION'} \n " ;
3782 print OPENSSL
" $ou \n " ;
3783 print OPENSSL
" $cgiparams {'CERT_NAME'} \n " ;
3784 print OPENSSL
" $cgiparams {'CERT_EMAIL'} \n " ;
3785 print OPENSSL
". \n " ;
3786 print OPENSSL
". \n " ;
3789 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3790 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}key.pem" );
3791 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}req.pem" );
3795 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
3796 '-newkey' , 'rsa:1024' ,
3797 '-keyout' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
3798 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
3799 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
3800 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
3801 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
3802 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
3807 # Sign the host certificate request
3808 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
3809 '-batch' , '-notext' ,
3810 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
3811 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
3812 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
3814 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3815 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
3816 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
3817 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3818 & newcleanssldatabase
();
3821 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
3822 & deletebackupcert
();
3825 # Create the pkcs12 file
3826 system ( '/usr/bin/openssl' , 'pkcs12' , '-export' ,
3827 '-inkey' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
3828 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
3829 '-name' , $cgiparams { 'NAME' },
3830 '-passout' , "pass: $cgiparams {'CERT_PASS1'}" ,
3831 '-certfile' , "${General::swroot}/ovpn/ca/cacert.pem" ,
3832 '-caname' , " $vpnsettings {'ROOTCERT_ORGANIZATION'} CA" ,
3833 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
3835 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3836 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
3837 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3838 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
3841 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
3843 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
3844 ; # Nothing, just editing
3846 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
3850 # Check if there is no other entry with this common name
3851 if ((! $cgiparams { 'KEY' }) && ( $cgiparams { 'AUTH' } ne 'psk' )) {
3852 foreach my $key ( keys %confighash ) {
3853 if ( $confighash { $key }[ 2 ] eq $cgiparams { 'CERT_NAME' }) {
3854 $errormessage = $Lang :: tr
{ 'a connection with this common name already exists' };
3861 my $key = $cgiparams { 'KEY' };
3864 $key = & General
:: findhasharraykey
( \
%confighash );
3865 foreach my $i ( 0 .. 38 ) { $confighash { $key }[ $i ] = "" ;}
3867 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
3868 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
3869 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
3870 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
3873 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
3874 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
3875 $confighash { $key }[ 4 ] = 'psk' ;
3876 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
3878 $confighash { $key }[ 4 ] = 'cert' ;
3880 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3881 $confighash { $key }[ 6 ] = $cgiparams { 'SIDE' };
3882 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
3884 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
3885 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
3886 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
3887 $confighash { $key }[ 22 ] = $confighash { $key }[ 29 ];
3889 $confighash { $key }[ 22 ] = $cgiparams { 'OVPN_MGMT' };
3891 $confighash { $key }[ 23 ] = $cgiparams { 'MSSFIX' };
3892 $confighash { $key }[ 24 ] = $cgiparams { 'FRAGMENT' };
3893 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
3894 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
3896 $confighash { $key }[ 27 ] = $cgiparams { 'OVPN_SUBNET' };
3897 $confighash { $key }[ 28 ] = $cgiparams { 'PROTOCOL' };
3898 $confighash { $key }[ 29 ] = $cgiparams { 'DEST_PORT' };
3899 $confighash { $key }[ 30 ] = $cgiparams { 'COMPLZO' };
3900 $confighash { $key }[ 31 ] = $cgiparams { 'MTU' };
3901 $confighash { $key }[ 32 ] = $cgiparams { 'CHECK1' };
3902 my $name = $cgiparams { 'CHECK1' };
3903 $confighash { $key }[ 33 ] = $cgiparams { $name };
3904 $confighash { $key }[ 34 ] = $cgiparams { 'RG' };
3905 $confighash { $key }[ 35 ] = $cgiparams { 'CCD_DNS1' };
3906 $confighash { $key }[ 36 ] = $cgiparams { 'CCD_DNS2' };
3907 $confighash { $key }[ 37 ] = $cgiparams { 'CCD_WINS' };
3908 $confighash { $key }[ 38 ] = $cgiparams { 'PMTU_DISCOVERY' };
3911 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3913 if ( $cgiparams { 'CHECK1' } ){
3915 my ( $ccdip , $ccdsub )= split "/" , $cgiparams { $name };
3916 my ( $a , $b , $c , $d ) = split ( /\./ , $ccdip );
3917 if ( - e
"${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ){ unlink "${General::swroot}/ovpn/ccd/ $cgiparams {'CERT_NAME'}" ;}
3918 open ( CCDRWCONF
, '>' , "${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ) or die "Unable to create clientconfigfile $!" ;
3919 print CCDRWCONF
"# OpenVPN Clientconfig from CCD extension by Copymaster# \n\n " ;
3920 if ( $cgiparams { 'CHECK1' } eq 'dynamic' ){
3921 print CCDRWCONF
"#This client uses the dynamic pool \n " ;
3923 print CCDRWCONF
"#Ip address client and Server \n " ;
3924 print CCDRWCONF
"ifconfig-push $ccdip " .& General
:: getlastip
( $ccdip , 1 ). " \n " ;
3926 if ( $confighash { $key }[ 34 ] eq 'on' ){
3927 print CCDRWCONF
" \n #Redirect Gateway: \n #All IP traffic is redirected through the vpn \n " ;
3928 print CCDRWCONF
"push redirect-gateway \n " ;
3930 if ( $cgiparams { 'IR' } ne '' ){
3931 print CCDRWCONF
" \n #Client routes these Networks (behind Client) \n " ;
3932 foreach my $key ( keys %ccdroutehash ){
3933 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
3934 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
3935 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
3936 print CCDRWCONF
"iroute $a $b \n " ;
3941 if ( $cgiparams { 'IFROUTE' } ne '' ){
3942 print CCDRWCONF
" \n #Client gets routes to these Networks (behind IPFIRE) \n " ;
3943 foreach my $key ( keys %ccdroute2hash ){
3944 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
3945 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}){
3946 if ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'blue' }){
3948 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%blue );
3949 print CCDRWCONF
"push \" route $blue {BLUE_ADDRESS} $blue {BLUE_NETMASK} \n " ;
3950 } elsif ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'orange' }){
3952 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%orange );
3953 print CCDRWCONF
"push \" route $orange {ORANGE_ADDRESS} $orange {ORANGE_NETMASK} \n " ;
3955 my ( $a , $b )= split ( /\/ /, $ccdroute2hash { $key }[ $i ]);
3956 print CCDRWCONF
"push \" route $a $b \"\n " ;
3962 if (( $cgiparams { 'CCD_DNS1' } eq '' ) && ( $cgiparams { 'CCD_DNS1' } ne '' )){ $cgiparams { 'CCD_DNS1' } = $cgiparams { 'CCD_DNS2' }; $cgiparams { 'CCD_DNS2' }= '' ;}
3963 if ( $cgiparams { 'CCD_DNS1' } ne '' ){
3964 print CCDRWCONF
" \n #Client gets these Nameservers \n " ;
3965 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS1'} \" \n " ;
3967 if ( $cgiparams { 'CCD_DNS2' } ne '' ){
3968 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS2'} \" \n " ;
3970 if ( $cgiparams { 'CCD_WINS' } ne '' ){
3971 print CCDRWCONF
" \n #Client gets this WINS server \n " ;
3972 print CCDRWCONF
"push \" dhcp-option WINS $cgiparams {'CCD_WINS'} \" \n " ;
3981 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3983 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
3984 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
3986 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3987 my $key = $cgiparams { 'KEY' };
3989 $key = & General
:: findhasharraykey
( \
%confighash );
3990 foreach my $i ( 0 .. 31 ) { $confighash { $key }[ $i ] = "" ;}
3992 $confighash { $key }[ 0 ] = 'on' ;
3993 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3995 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4003 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
4004 $cgiparams { 'KEY' } = $key ;
4005 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
4009 $cgiparams { 'ENABLED' } = 'on' ;
4013 $cgiparams { 'MSSFIX' } = 'on' ;
4014 $cgiparams { 'FRAGMENT' } = '1300' ;
4015 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4019 $cgiparams { 'SIDE' } = 'left' ;
4020 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) {
4021 $cgiparams { 'AUTH' } = 'psk' ;
4022 } elsif ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4023 $cgiparams { 'AUTH' } = 'certfile' ;
4025 $cgiparams { 'AUTH' } = 'certgen' ;
4027 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
4028 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
4029 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
4030 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
4031 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
4035 $checked { 'ENABLED' }{ 'off' } = '' ;
4036 $checked { 'ENABLED' }{ 'on' } = '' ;
4037 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4038 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4039 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4040 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4041 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4042 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4043 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4046 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
4047 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
4048 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = 'CHECKED' ;
4050 $selected { 'SIDE' }{ 'server' } = '' ;
4051 $selected { 'SIDE' }{ 'client' } = '' ;
4052 $selected { 'SIDE' }{ $cgiparams { 'SIDE' }} = 'SELECTED' ;
4054 $selected { 'PROTOCOL' }{ 'udp' } = '' ;
4055 $selected { 'PROTOCOL' }{ 'tcp' } = '' ;
4056 $selected { 'PROTOCOL' }{ $cgiparams { 'PROTOCOL' }} = 'SELECTED' ;
4059 $checked { 'AUTH' }{ 'psk' } = '' ;
4060 $checked { 'AUTH' }{ 'certreq' } = '' ;
4061 $checked { 'AUTH' }{ 'certgen' } = '' ;
4062 $checked { 'AUTH' }{ 'certfile' } = '' ;
4063 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = 'CHECKED' ;
4065 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = 'SELECTED' ;
4067 $checked { 'COMPLZO' }{ 'off' } = '' ;
4068 $checked { 'COMPLZO' }{ 'on' } = '' ;
4069 $checked { 'COMPLZO' }{ $cgiparams { 'COMPLZO' }} = 'CHECKED' ;
4071 $checked { 'MSSFIX' }{ 'off' } = '' ;
4072 $checked { 'MSSFIX' }{ 'on' } = '' ;
4073 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4075 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
4079 & Header
:: showhttpheaders
();
4080 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
4081 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4082 if ( $errormessage ) {
4083 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4084 print "<class name='base'> $errormessage " ;
4085 print " </class>" ;
4086 & Header
:: closebox
();
4090 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'warning messages'}:" );
4091 print "<class name='base'> $warnmessage " ;
4092 print " </class>" ;
4093 & Header
:: closebox
();
4096 print "<form method='post' enctype='multipart/form-data'>" ;
4097 print "<input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />" ;
4099 if ( $cgiparams { 'KEY' }) {
4100 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
4101 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
4104 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'connection'}:" );
4105 print "<table width='100%' border='0'> \n " ;
4109 print "<tr><td width='14%' class='boldbase'> $Lang ::tr{'name'}: </td>" ;
4111 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4112 if ( $cgiparams { 'KEY' }) {
4113 print "<td width='35%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4116 print "<td width='35%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' size='30' /></td>" ;
4118 # print "<tr><td>$Lang::tr{'interface'}</td>";
4119 # print "<td><select name='INTERFACE'>";
4120 # print "<option value='RED' $selected{'INTERFACE'}{'RED'}>RED</option>";
4121 # if ($netsettings{'BLUE_DEV'} ne '') {
4122 # print "<option value='BLUE' $selected{'INTERFACE'}{'BLUE'}>BLUE</option>";
4124 # print "<option value='GREEN' $selected{'INTERFACE'}{'GREEN'}>GREEN</option>";
4125 # print "<option value='ORANGE' $selected{'INTERFACE'}{'ORANGE'}>ORANGE</option>";
4126 # print "</select></td></tr>";
4129 print "<input type='hidden' name='INTERFACE' value='red' />" ;
4130 if ( $cgiparams { 'KEY' }) {
4131 print "<td width='25%' class='base' nowrap='nowrap'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4133 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' /></td>" ;
4139 <td width='25%'> </td>
4140 <td width='25%'> </td></tr>
4141 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td>
4142 <td><select name='SIDE'><option value='server' $selected {'SIDE'}{'server'}> $Lang ::tr{'openvpn server'}</option>
4143 <option value='client' $selected {'SIDE'}{'client'}> $Lang ::tr{'openvpn client'}</option></select></td>
4144 <td class='boldbase'> $Lang ::tr{'remote host/ip'}:</td>
4145 <td><input type='TEXT' name='REMOTE' value=' $cgiparams {'REMOTE'}' /></td></tr>
4146 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
4147 <td><input type='TEXT' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' /></td>
4148 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
4149 <td><input type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' /></td></tr>
4150 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td>
4151 <td><input type='TEXT' name='OVPN_SUBNET' value=' $cgiparams {'OVPN_SUBNET'}' /></td></tr>
4152 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
4154 <td><select name='PROTOCOL'><option value='udp' $selected {'PROTOCOL'}{'udp'}>UDP</option>
4155 <option value='tcp' $selected {'PROTOCOL'}{'tcp'}>TCP</option></select></td>
4157 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
4158 <td><input type='TEXT' name='DEST_PORT' value=' $cgiparams {'DEST_PORT'}' size='5' /></td></tr>
4159 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'} <img src='/blob.gif'</td>
4160 <td><input type='checkbox' name='COMPLZO' $checked {'COMPLZO'}{'on'} /></td>
4162 <tr><td class='boldbase' nowrap='nowrap'>mssfix <img src='/blob.gif' /></td>
4163 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
4164 <td> $Lang ::tr{'openvpn default'}: <span class="base">on</span></td>
4166 <tr><td class='boldbase' nowrap='nowrap'>fragment <img src='/blob.gif' /></td>
4167 <td><input type='TEXT' name='FRAGMENT' VALUE=' $cgiparams {'FRAGMENT'}'size='5' /></td>
4168 <td> $Lang ::tr{'openvpn default'}: <span class="base">1300</span></td>
4170 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} <img src='/blob.gif' /></td>
4171 <td> <input type='TEXT' name='MTU' VALUE=' $cgiparams {'MTU'}'size='5' /></td>
4172 <td colspan='2'> $Lang ::tr{'openvpn default'}: udp/tcp <span class="base">1500/1400</span></td>
4174 <tr><td class='boldbase' nowrap='nowrap'>Management Port <img src='/blob.gif' /></td>
4175 <td> <input type='TEXT' name='OVPN_MGMT' VALUE=' $cgiparams {'OVPN_MGMT'}'size='5' /></td>
4176 <td colspan='2'> $Lang ::tr{'openvpn default'}: <span class="base"> $Lang ::tr{'destination port'}</span></td>
4179 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td>
4181 <input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}
4182 <input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}
4183 <input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}
4184 <input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}
4192 print "<tr><td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' /></td>" ;
4193 print "<td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td></tr></table>" ;
4195 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4196 print "<tr><td> $Lang ::tr{'enabled'} <input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>" ;
4199 print "</tr></table><br><br>" ;
4200 #A.Marx CCD new client
4201 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4202 print "<table border='0' width='100%' cellspacing='1' cellpadding='0'><tr><td colspan='3'><hr><br><b> $Lang ::tr{'ccd choose net'}</td></tr><tr><td height='20' colspan='3'></td></tr>" ;
4205 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnnet );
4206 $vpnip = $vpnnet { 'DOVPN_SUBNET' };
4207 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
4211 $checked { 'check1' }{ 'off' } = '' ;
4212 $checked { 'check1' }{ 'on' } = '' ;
4213 $checked { 'check1' }{ $cgiparams { 'CHECK1' }} = 'CHECKED' ;
4214 print "<tr><td align='center' width='1%' valign='top'><input type='radio' name='CHECK1' value='dynamic' checked /></td><td align='left' valign='top' width='35%'> $Lang ::tr{'ccd dynrange'} ( $vpnip )</td><td width='30%'>" ;
4215 print "</td></tr></table><br><br>" ;
4216 my $name = $cgiparams { 'CHECK1' };
4217 $checked { 'RG' }{ $cgiparams { 'RG' }} = 'CHECKED' ;
4219 if (! - z
"${General::swroot}/ovpn/ccd.conf" ){
4220 print "<table border='0' width='100%' cellspacing='1' cellpadding='0'><tr><td width='1%'></td><td width='30%' class='boldbase' align='center'><b> $Lang ::tr{'ccd name'}</td><td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'network'}</td><td class='boldbase' align='center' width='18%'><b> $Lang ::tr{'ccd clientip'}</td></tr>" ;
4221 foreach my $key ( keys %ccdconfhash ) {
4223 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
4224 if ( $count % 2 ){ print "<tr bgcolor=' $color {'color22'}'>" ;} else { print "<tr bgcolor=' $color {'color20'}'>" ;}
4225 print "<td align='center' width='1%'><input type='radio' name='CHECK1' value=' $ccdconf [0]' $checked {'check1'}{ $ccdconf [0]}/></td><td> $ccdconf [0]</td><td width='40%' align='center'> $ccdconf [1]</td><td align='left' width='10%'>" ;
4226 & fillselectbox
( $ccdconf [ 1 ], $ccdconf [ 0 ], $cgiparams { $name });
4229 print "</table><br><br><hr><br><br>" ;
4233 & Header
:: closebox
();
4234 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
4236 } elsif (! $cgiparams { 'KEY' }) {
4240 my $cakeydisabled = '' ;
4241 my $cacrtdisabled = '' ;
4242 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) { $cakeydisabled = "disabled='disabled'" } else { $cakeydisabled = "" };
4243 if ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) { $cacrtdisabled = "disabled='disabled'" } else { $cacrtdisabled = "" };
4245 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'authentication' });
4248 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4251 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4253 <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>
4254 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td><td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
4255 <tr><td colspan='3'> </td></tr>
4256 <tr><td colspan='3'><hr /></td></tr>
4257 <tr><td colspan='3'> </td></tr>
4258 <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>
4259 <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>
4260 <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>
4261 <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>
4262 <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>
4263 <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>
4264 <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>
4265 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4276 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4278 <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>
4279 <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>
4280 <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>
4281 <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>
4282 <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>
4283 <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>
4284 <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>
4285 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4297 foreach my $country ( sort keys %{ Countries
:: countries
}) {
4298 print "<option value=' $Countries ::countries{ $country }'" ;
4299 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
4300 print " selected='selected'" ;
4302 print "> $country </option>" ;
4308 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4312 <td> </td><td class='base'> $Lang ::tr{'valid till'} (days):</td>
4313 <td class='base' nowrap='nowrap'><input type='text' name='DAYS_VALID' value=' $cgiparams {'DAYS_VALID'}' size='32' $cakeydisabled /></td></tr>
4315 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
4316 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
4317 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:<BR>( $Lang ::tr{'confirmation'})</td>
4318 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
4319 <tr><td colspan='3'> </td></tr>
4320 <tr><td colspan='3'><hr /></td></tr>
4321 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4327 <tr><td> </td><td> </td><td> </td></tr>
4328 <tr><td> </td><td> </td><td> </td></tr>
4329 <tr><td colspan='3'><hr /></td></tr>
4330 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4340 & Header
:: closebox
();
4344 #A.Marx CCD new client
4345 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4347 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ccd client options'}:" );
4351 <table border='0' width='100%'>
4352 <tr><td width='20%'>Redirect Gateway:</td><td colspan='3'><input type='checkbox' name='RG' $checked {'RG'}{'on'} /></td></tr>
4353 <tr><td colspan='4'><b><br> $Lang ::tr{'ccd routes'}</b></td></tr>
4354 <tr><td colspan='4'> </td></tr>
4355 <tr><td valign='top'> $Lang ::tr{'ccd iroute'}</td><td align='left' width='30%'><textarea name='IR' cols='26' rows='6' wrap='off'>
4358 if ( $cgiparams { 'IR' } ne '' ){
4359 print $cgiparams { 'IR' };
4361 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4362 foreach my $key ( keys %ccdroutehash ) {
4363 if ( $cgiparams { 'NAME' } eq $ccdroutehash { $key }[ 0 ]){
4364 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
4365 if ( $ccdroutehash { $key }[ $i ] ne '' ){
4366 print $ccdroutehash { $key }[ $i ]. " \n " ;
4368 $cgiparams { 'IR' } .= $ccdroutehash { $key }[ $i ];
4375 </textarea></td><td valign='top' colspan='2'> $Lang ::tr{'ccd iroutehint'}</td></tr>
4376 <tr><td colspan='4'><br></td></tr>
4377 <tr><td valign='top' rowspan='3'> $Lang ::tr{'ccd iroute2'}</td><td align='left' valign='top' rowspan='3'><select name='IFROUTE' style="width: 205px"; size='6' multiple>
4381 open ( FILE
, "${General::swroot}/main/routing" ) ;
4384 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
4390 print "<option> $Lang ::tr{'ccd none'}</option>" ;
4391 print "<option selected> $Lang ::tr{'green'}</option>" ;
4393 foreach my $line ( @current ) {
4394 chomp ( $line ); # remove newline
4395 my @temp = split ( /\,/ , $line );
4396 $temp [ 1 ] = '' unless defined $temp [ 1 ]; # not always populated
4397 my ( $a , $b ) = split ( /\/ /, $temp [ 1 ]);
4398 $temp [ 1 ] = $a . "/" .& General
:: iporsubtocidr
( $b );
4399 foreach my $key ( keys %ccdroute2hash ) {
4400 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4401 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4403 if ( $ccdroute2hash { $key }[ $i ] eq $a . "/" .& General
:: iporsubtodec
( $b )){
4406 if (& haveBlueNet
()){
4407 if ( $netsettings { 'BLUE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'BLUE_NETMASK' }) eq $ccdroute2hash { $key }[ $i ]) {
4412 if (& haveOrangeNet
()){
4413 if ( $netsettings { 'ORANGE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'ORANGE_NETMASK' }) eq $ccdroute2hash { $key }[ $i ]) {
4420 if ( $set == '1' ){ print "<option selected> $temp [1]</option>" ; $set = 0 ;} else { print "<option> $temp [1]</option>" ;}
4421 if (& haveBlueNet
() && $selblue == '1' ){ print "<option selected> $Lang ::tr{'blue'}</option>" ; $selblue = 0 ;} elsif (& haveBlueNet
() && $selblue == '0' ){ print "<option> $Lang ::tr{'blue'}</option>" ;}
4422 if (& haveOrangeNet
() && $selorange == '1' ){ print "<option selected> $Lang ::tr{'orange'}</option>" ; $selorange = 0 ;} elsif (& haveOrangeNet
() && $selorange == '0' ){ print "<option> $Lang ::tr{'orange'}</option>" ;}
4425 </select></td><td valign='top'>DNS1:</td><td valign='top'><input type='TEXT' name='CCD_DNS1' value=' $cgiparams {'CCD_DNS1'}' size='30' /></td></tr>
4426 <tr valign='top'><td>DNS2:</td><td><input type='TEXT' name='CCD_DNS2' value=' $cgiparams {'CCD_DNS2'}' size='30' /></td></tr>
4427 <tr valign='top'><td valign='top'>WINS:</td><td><input type='TEXT' name='CCD_WINS' value=' $cgiparams {'CCD_WINS'}' size='30' /></td></tr></table><br><hr>
4431 & Header
:: closebox
();
4433 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
4434 if ( $cgiparams { 'KEY' }) {
4435 # print "<input type='submit' name='ACTION' value='$Lang::tr{'advanced'}' />";
4437 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
4438 & Header
:: closebigbox
();
4439 & Header
:: closepage
();
4447 ### Default status page
4452 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
4453 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
4454 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4456 my @status = `/bin/cat /var/log/ovpnserver.log` ;
4458 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
4459 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
4460 my $ipaddr = < IPADDR
>;
4463 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
4464 if ( $cgiparams { 'VPN_IP' } eq '' ) {
4465 $cgiparams { 'VPN_IP' } = $ipaddr ;
4471 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4472 $cgiparams { 'DCIPHER' } = 'BF-CBC' ;
4474 if ( $cgiparams { 'DDEST_PORT' } eq '' ) {
4475 $cgiparams { 'DDEST_PORT' } = '1194' ;
4477 if ( $cgiparams { 'DMTU' } eq '' ) {
4478 $cgiparams { 'DMTU' } = '1400' ;
4480 if ( $cgiparams { 'DOVPN_SUBNET' } eq '' ) {
4481 $cgiparams { 'DOVPN_SUBNET' } = '10.' . int ( rand ( 256 )) . '.' . int ( rand ( 256 )) . '.0/255.255.255.0' ;
4483 $checked { 'ENABLED' }{ 'off' } = '' ;
4484 $checked { 'ENABLED' }{ 'on' } = '' ;
4485 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4486 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4487 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4488 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4489 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4490 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4491 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4492 $selected { 'DDEVICE' }{ 'tun' } = '' ;
4493 $selected { 'DDEVICE' }{ 'tap' } = '' ;
4494 $selected { 'DDEVICE' }{ $cgiparams { 'DDEVICE' }} = 'SELECTED' ;
4496 $selected { 'DPROTOCOL' }{ 'udp' } = '' ;
4497 $selected { 'DPROTOCOL' }{ 'tcp' } = '' ;
4498 $selected { 'DPROTOCOL' }{ $cgiparams { 'DPROTOCOL' }} = 'SELECTED' ;
4500 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4501 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4502 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4503 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4504 $selected { 'DCIPHER' }{ 'RC2-CBC' } = '' ;
4505 $selected { 'DCIPHER' }{ 'RC2-40-CBC' } = '' ;
4506 $selected { 'DCIPHER' }{ 'RC2-64-CBC' } = '' ;
4507 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4508 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4509 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4510 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4511 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4512 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4513 $checked { 'DCOMPLZO' }{ 'off' } = '' ;
4514 $checked { 'DCOMPLZO' }{ 'on' } = '' ;
4515 $checked { 'DCOMPLZO' }{ $cgiparams { 'DCOMPLZO' }} = 'CHECKED' ;
4517 $checked { 'MSSFIX' }{ 'off' } = '' ;
4518 $checked { 'MSSFIX' }{ 'on' } = '' ;
4519 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4521 & Header
:: showhttpheaders
();
4522 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
4523 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4525 if ( $errormessage ) {
4526 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4527 print "<class name='base'> $errormessage \n " ;
4528 print " </class> \n " ;
4529 & Header
:: closebox
();
4532 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>" ;
4533 my $srunning = "no" ;
4534 my $activeonrun = "" ;
4535 if ( - e
"/var/run/openvpn.pid" ){
4536 $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>" ;
4540 $activeonrun = "disabled='disabled'" ;
4542 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'global settings' });
4544 <table width='100%' border=0>
4545 <form method='post'>
4546 <td width='25%'> </td>
4547 <td width='25%'> </td>
4548 <td width='25%'> </td></tr>
4549 <tr><td class='boldbase'> $Lang ::tr{'ovpn server status'}</td>
4550 <td align='left'> $sactive </td>
4551 <tr><td class='boldbase'> $Lang ::tr{'ovpn on red'}</td>
4552 <td><input type='checkbox' name='ENABLED' $checked {'ENABLED'}{'on'} /></td>
4555 if (& haveBlueNet
()) {
4556 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on blue'}</td>" ;
4557 print "<td><input type='checkbox' name='ENABLED_BLUE' $checked {'ENABLED_BLUE'}{'on'} /></td>" ;
4559 if (& haveOrangeNet
()) {
4560 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on orange'}</td>" ;
4561 print "<td><input type='checkbox' name='ENABLED_ORANGE' $checked {'ENABLED_ORANGE'}{'on'} /></td>" ;
4564 <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>
4565 <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>
4566 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn device'}</td>
4567 <td><select name='DDEVICE' ><option value='tun' $selected {'DDEVICE'}{'tun'}>TUN</option>
4568 <!-- this is still not working
4569 <option value='tap' $selected {'DDEVICE'}{'tap'}>TAP</option></select>--> </td>
4570 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
4571 <td><select name='DPROTOCOL'><option value='udp' $selected {'DPROTOCOL'}{'udp'}>UDP</option>
4572 <option value='tcp' $selected {'DPROTOCOL'}{'tcp'}>TCP</option></select></td>
4573 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
4574 <td><input type='TEXT' name='DDEST_PORT' value=' $cgiparams {'DDEST_PORT'}' size='5' /></td></tr>
4575 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} </td>
4576 <td> <input type='TEXT' name='DMTU' VALUE=' $cgiparams {'DMTU'}'size='5' /></TD>
4577 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td>
4578 <td><input type='checkbox' name='DCOMPLZO' $checked {'DCOMPLZO'}{'on'} /></td>
4579 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td>
4580 <td><select name='DCIPHER'><option value='DES-CBC' $selected {'DCIPHER'}{'DES-CBC'}>DES-CBC</option>
4581 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC</option>
4582 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC</option>
4583 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC</option>
4584 <option value='RC2-CBC' $selected {'DCIPHER'}{'RC2-CBC'}>RC2-CBC</option>
4585 <option value='RC2-40-CBC' $selected {'DCIPHER'}{'RC2-40-CBC'}>RC2-40-CBC</option>
4586 <option value='RC2-64-CBC' $selected {'DCIPHER'}{'RC2-64-CBC'}>RC2-64-CBC</option>
4587 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC</option>
4588 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC</option>
4589 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-128-CBC</option>
4590 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-192-CBC</option>
4591 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-256-CBC</option></select></td></tr>
4592 <tr><td colspan='4'><hr /></td></tr>
4596 if ( $srunning eq "yes" ) {
4597 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' disabled='disabled' />" ;
4598 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
4599 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
4600 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'stop ovpn server'}' /></td></tr>" ;
4602 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
4603 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
4604 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
4605 if (( - e
"${General::swroot}/ovpn/ca/cacert.pem" &&
4606 - e
"${General::swroot}/ovpn/ca/dh1024.pem" &&
4607 - e
"${General::swroot}/ovpn/certs/servercert.pem" &&
4608 - e
"${General::swroot}/ovpn/certs/serverkey.pem" ) &&
4609 (( $cgiparams { 'ENABLED' } eq 'on' ) ||
4610 ( $cgiparams { 'ENABLED_BLUE' } eq 'on' ) ||
4611 ( $cgiparams { 'ENABLED_ORANGE' } eq 'on' ))){
4612 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' /></td></tr>" ;
4614 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' disabled='disabled' /></td></tr>" ;
4617 print "</form></table>" ;
4618 & Header
:: closebox
();
4619 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate authorities'}:" );
4621 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
4623 <td width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
4624 <td width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></td>
4625 <td width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></td>
4629 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4630 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
4631 $casubject =~ /Subject: (.*)[\n]/ ;
4633 $casubject =~ s
+/ Email
+, E
+;
4634 $casubject =~ s/ ST=/ S=/ ;
4637 <tr bgcolor=' $color {'color22'}'>
4638 <td class='base'> $Lang ::tr{'root certificate'}</td>
4639 <td class='base'> $casubject </td>
4640 <form method='post' name='frmrootcrta'><td width='3%' align='center'>
4641 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
4642 <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' />
4644 <form method='post' name='frmrootcrtb'><td width='3%' align='center'>
4645 <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' />
4646 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
4648 <td width='4%'> </td></tr>
4652 # display rootcert generation buttons
4654 <tr bgcolor=' $color {'color22'}'>
4655 <td class='base'> $Lang ::tr{'root certificate'}:</td>
4656 <td class='base'> $Lang ::tr{'not present'}</td>
4657 <td colspan='3'> </td></tr>
4662 if (- f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
4663 my $hostsubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
4664 $hostsubject =~ /Subject: (.*)[\n]/ ;
4666 $hostsubject =~ s
+/ Email
+, E
+;
4667 $hostsubject =~ s/ ST=/ S=/ ;
4670 <tr bgcolor=' $color {'color20'}'>
4671 <td class='base'> $Lang ::tr{'host certificate'}</td>
4672 <td class='base'> $hostsubject </td>
4673 <form method='post' name='frmhostcrta'><td width='3%' align='center'>
4674 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
4675 <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' />
4677 <form method='post' name='frmhostcrtb'><td width='3%' align='center'>
4678 <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' />
4679 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download host certificate'}' />
4681 <td width='4%'> </td></tr>
4687 <tr bgcolor=' $color {'color20'}'>
4688 <td width='25%' class='base'> $Lang ::tr{'host certificate'}:</td>
4689 <td class='base'> $Lang ::tr{'not present'}</td>
4690 </td><td colspan='3'> </td></tr>
4695 if (! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4696 print "<tr><td colspan='5' align='center'><form method='post'>" ;
4697 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' />" ;
4698 print "</form></td></tr> \n " ;
4701 if ( keys %cahash > 0 ) {
4702 foreach my $key ( keys %cahash ) {
4703 if (( $key + 1 ) % 2 ) {
4704 print "<tr bgcolor=' $color {'color20'}'> \n " ;
4706 print "<tr bgcolor=' $color {'color22'}'> \n " ;
4708 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
4709 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
4711 <form method='post' name='cafrm${key}a'><td align='center'>
4712 <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' />
4713 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
4714 <input type='hidden' name='KEY' value=' $key ' />
4716 <form method='post' name='cafrm${key}b'><td align='center'>
4717 <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' />
4718 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
4719 <input type='hidden' name='KEY' value=' $key ' />
4721 <form method='post' name='cafrm${key}c'><td align='center'>
4722 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
4723 <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' />
4724 <input type='hidden' name='KEY' value=' $key ' />
4733 # If the file contains entries, print Key to action icons
4734 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4738 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
4739 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
4740 <td class='base'> $Lang ::tr{'show certificate'}</td>
4741 <td> <img src='/images/media-floppy.png' alt=' $Lang ::tr{'download certificate'}' /></td>
4742 <td class='base'> $Lang ::tr{'download certificate'}</td>
4750 <form method='post' enctype='multipart/form-data'>
4751 <table width='100%' border='0'>
4752 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}:</td><td nowrap='nowrap' width='8%'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' align='left'/></td><td nowrap='nowrap' align='right'><input type='file' name='FH' size='25' /><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td></tr>
4753 <tr><td colspan='4'><hr /></td></tr>
4754 <tr align='right'><td colspan='4' align='right' width='80%'><input type='submit' name='ACTION' value=' $Lang ::tr{'show crl'}' /></td></tr>
4760 & Header
:: closebox
();
4761 if ( $srunning eq "yes" ) {
4762 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'reset'}' disabled='disabled' /></div></form> \n " ;
4764 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'reset'}' /></div></form> \n " ;
4766 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4770 #<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>
4773 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'Client status and controlc' });
4777 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
4779 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
4780 <td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></td>
4781 <td width='22%' class='boldbase' align='center'><b> $Lang ::tr{'network'}</b></td>
4782 <td width='20%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></td>
4783 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></td>
4784 <td width='5%' class='boldbase' colspan='6' align='center'><b> $Lang ::tr{'action'}</b></td>
4790 foreach my $key ( sort { uc ( $confighash { $a }[ 1 ]) cmp uc ( $confighash { $b }[ 1 ]) } keys %confighash ) {
4791 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
4794 print "<tr bgcolor=' $color {'color20'}'> \n " ;
4796 print "<tr bgcolor=' $color {'color22'}'> \n " ;
4798 print "<td align='center' nowrap='nowrap'> $confighash { $key }[1]</td>" ;
4799 print "<td align='center' nowrap='nowrap'>" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
4800 #if ($confighash{$key}[4] eq 'cert') {
4801 #print "<td align='left' nowrap='nowrap'>$confighash{$key}[2]</td>";
4803 #print "<td align='left'> </td>";
4805 my $cavalid = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
4806 $cavalid =~ /Not After : (.*)[\n]/ ;
4808 if ( $confighash { $key }[ 32 ] eq "" && $confighash { $key }[ 3 ] eq 'net' ){ $confighash { $key }[ 32 ]= "net-2-net" ;}
4809 if ( $confighash { $key }[ 32 ] eq "" && $confighash { $key }[ 3 ] eq 'host' ){ $confighash { $key }[ 32 ]= "dynamic" ;}
4810 print "<td align='center'> $confighash { $key }[32]</td>" ;
4811 print "<td align='center'> $confighash { $key }[25]</td>" ;
4813 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>" ;
4815 if ( $confighash { $key }[ 0 ] eq 'off' ) {
4816 $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>" ;
4823 if ( $confighash { $key }[ 3 ] eq 'net' ) {
4825 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
4828 my $tport = $confighash { $key }[ 22 ];
4829 my $tnet = new Net
:: Telnet
( Timeout
=> 5 , Errmode
=> 'return' , Port
=> $tport );
4831 $tnet -> open ( '127.0.0.1' );
4832 @output = $tnet -> cmd ( String
=> 'state' , Prompt
=> '/(END.* \n |ERROR:.* \n )/' );
4833 @tustate = split ( /\,/ , $output [ 1 ]);
4835 #CONNECTING -- OpenVPN's initial state.
4836 #WAIT -- (Client only) Waiting for initial response from server.
4837 #AUTH -- (Client only) Authenticating with server.
4838 #GET_CONFIG -- (Client only) Downloading configuration options from server.
4839 #ASSIGN_IP -- Assigning IP address to virtual network interface.
4840 #ADD_ROUTES -- Adding routes to system.
4841 #CONNECTED -- Initialization Sequence Completed.
4842 #RECONNECTING -- A restart has occurred.
4843 #EXITING -- A graceful exit is in progress.
4846 if ( $tustate [ 1 ] eq 'CONNECTED' ) {
4847 $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourgreen}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b></tr></td></table>" ;
4849 $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourred}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'> $tustate [1]</font></b></td></tr></table>" ;
4857 foreach my $line ( @status ) {
4859 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
4860 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
4861 if ( $match [ 1 ] ne "Common Name" ) {
4865 if ( $cn eq " $confighash { $key }[2]" ) {
4866 $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>" ;
4875 my $disable_clientdl = "disabled='disabled'" ;
4876 if (( $cgiparams { 'ENABLED' } eq 'on' ) ||
4877 ( $cgiparams { 'ENABLED_BLUE' } eq 'on' ) ||
4878 ( $cgiparams { 'ENABLED_ORANGE' } eq 'on' )){
4879 $disable_clientdl = "" ;
4882 <td align='center'> $active </td>
4884 <form method='post' name='frm${key}a'><td align='center'>
4885 <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' />
4886 <input type='hidden' name='ACTION' value=' $Lang ::tr{'dl client arch'}' $disable_clientdl />
4887 <input type='hidden' name='KEY' value=' $key ' $disable_clientdl />
4891 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
4893 <form method='post' name='frm${key}b'><td align='center'>
4894 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' border='0' />
4895 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
4896 <input type='hidden' name='KEY' value=' $key ' />
4900 print "<td> </td>" ;
4902 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" ) {
4904 <form method='post' name='frm${key}c'><td align='center'>
4905 <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' />
4906 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
4907 <input type='hidden' name='KEY' value=' $key ' />
4910 ; } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
4912 <form method='post' name='frm${key}c'><td align='center'>
4913 <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' />
4914 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
4915 <input type='hidden' name='KEY' value=' $key ' />
4919 print "<td> </td>" ;
4922 <form method='post' name='frm${key}d'><td align='center'>
4923 <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' />
4924 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
4925 <input type='hidden' name='KEY' value=' $key ' />
4928 <form method='post' name='frm${key}e'><td align='center'>
4929 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
4930 <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'/>
4931 <input type='hidden' name='KEY' value=' $key ' />
4933 <form method='post' name='frm${key}f'><td align='center'>
4934 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
4935 <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' />
4936 <input type='hidden' name='KEY' value=' $key ' />
4945 # If the config file contains entries, print Key to action icons
4950 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
4951 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
4952 <td class='base'> $Lang ::tr{'click to disable'}</td>
4953 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
4954 <td class='base'> $Lang ::tr{'show certificate'}</td>
4955 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
4956 <td class='base'> $Lang ::tr{'edit'}</td>
4957 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
4958 <td class='base'> $Lang ::tr{'remove'}</td>
4962 <td> <img src='/images/off.gif' alt='?OFF' /></td>
4963 <td class='base'> $Lang ::tr{'click to enable'}</td>
4964 <td> <img src='/images/media-floppy.png' alt='?FLOPPY' /></td>
4965 <td class='base'> $Lang ::tr{'download certificate'}</td>
4966 <td> <img src='/images/openvpn.png' alt='?RELOAD'/></td>
4967 <td class='base'> $Lang ::tr{'dl client arch'}</td>
4975 <table width='100%'>
4976 <form method='post'>
4977 <tr><td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
4978 <input type='submit' name='ACTION' value=' $Lang ::tr{'ovpn con stat'}' $activeonrun /></td></tr>
4983 & Header
:: closebox
();
4985 & Header
:: closepage
();