]>
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-2013 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 my $confighost = "${General::swroot}/fwhosts/customhosts" ;
68 my $configgrp = "${General::swroot}/fwhosts/customgroups" ;
69 my $customnet = "${General::swroot}/fwhosts/customnetworks" ;
71 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
72 $cgiparams { 'ENABLED' } = 'off' ;
73 $cgiparams { 'ENABLED_BLUE' } = 'off' ;
74 $cgiparams { 'ENABLED_ORANGE' } = 'off' ;
75 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
76 $cgiparams { 'NAT' } = 'off' ;
77 $cgiparams { 'COMPRESSION' } = 'off' ;
78 $cgiparams { 'ONLY_PROPOSED' } = 'off' ;
79 $cgiparams { 'ACTION' } = '' ;
80 $cgiparams { 'CA_NAME' } = '' ;
81 $cgiparams { 'DHCP_DOMAIN' } = '' ;
82 $cgiparams { 'DHCP_DNS' } = '' ;
83 $cgiparams { 'DHCP_WINS' } = '' ;
84 $cgiparams { 'ROUTES_PUSH' } = '' ;
85 $cgiparams { 'DCOMPLZO' } = 'off' ;
86 $cgiparams { 'MSSFIX' } = '' ;
87 $cgiparams { 'number' } = '' ;
88 $cgiparams { 'PMTU_DISCOVERY' } = '' ;
89 $routes_push_file = "${General::swroot}/ovpn/routes_push" ;
90 unless (- e
$routes_push_file ) { system ( "touch $routes_push_file " ); }
91 unless (- e
"${General::swroot}/ovpn/ccd.conf" ) { system ( "touch ${General::swroot}/ovpn/ccd.conf" ); }
92 unless (- e
"${General::swroot}/ovpn/ccdroute" ) { system ( "touch ${General::swroot}/ovpn/ccdroute" ); }
93 unless (- e
"${General::swroot}/ovpn/ccdroute2" ) { system ( "touch ${General::swroot}/ovpn/ccdroute2" ); }
95 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
97 # prepare openvpn config file
103 if ( $netsettings { 'CONFIG_TYPE' } == 2 ) { return 1 ;}
104 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
110 if ( $netsettings { 'CONFIG_TYPE' } == 3 ) { return 1 ;}
111 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
116 my $bytesize = shift ;
119 while ( abs ( $bytesize ) >= 1024 ){
120 $bytesize = $bytesize / 1024 ;
125 my @units = ( "Bytes" , "KB" , "MB" , "GB" , "TB" , "PB" , "EB" );
126 my $newsize =( int ( $bytesize * 100 + 0.5 ))/ 100 ;
127 return ( " $newsize $units [ $i ]" );
132 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/serial" )) {
136 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/index.txt" )) {
140 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
141 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
142 unlink ( "${General::swroot}/ovpn/certs/01.pem" );
145 sub newcleanssldatabase
147 if (! - s
"${General::swroot}/ovpn/certs/serial" ) {
148 open ( FILE
, ">${General::swroot}(ovpn/certs/serial" );
152 if (! - s
">${General::swroot}/ovpn/certs/index.txt" ) {
153 system ( "touch ${General::swroot}/ovpn/certs/index.txt" );
155 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
156 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
161 if ( open ( FILE
, "${General::swroot}/ovpn/certs/serial.old" )) {
162 my $hexvalue = < FILE
>;
165 unlink ( "${General::swroot}/ovpn/certs/ $hexvalue .pem" );
172 my $confignat = "${General::swroot}/forward/nat" ;
174 & General
:: readhasharray
( $confignat , \
%natconfig );
175 foreach my $key ( sort keys %natconfig ){
176 my @portarray = split ( /\|/ , $natconfig { $key }[ 30 ]);
177 foreach my $value ( @portarray ){
179 my ( $a , $b ) = split ( ":" , $value );
180 if ( $DPROT eq $natconfig { $key }[ 12 ] && $DPORT gt $a && $DPORT lt $b ){
181 $errormessage = " $Lang ::tr{'source port in use'} $DPORT " ;
184 if ( $DPROT eq $natconfig { $key }[ 12 ] && $DPORT eq $value ){
185 $errormessage = " $Lang ::tr{'source port in use'} $DPORT " ;
195 my $portrange1 = $_ [ 0 ]; # New port range
196 my $portrange2 = $_ [ 1 ]; # existing port range
197 my @tempr1 = split ( /\:/ , $portrange1 );
198 my @tempr2 = split ( /\:/ , $portrange2 );
200 unless (& checkportinc
( $tempr1 [ 0 ], $portrange2 )){ return 0 ;}
201 unless (& checkportinc
( $tempr1 [ 1 ], $portrange2 )){ return 0 ;}
203 unless (& checkportinc
( $tempr2 [ 0 ], $portrange1 )){ return 0 ;}
204 unless (& checkportinc
( $tempr2 [ 1 ], $portrange1 )){ return 0 ;}
206 return 1 ; # Everything checks out!
209 # Darren Critchley - we want to make sure that a port entry is not within an already existing range
212 my $port1 = $_ [ 0 ]; # Port
213 my $portrange2 = $_ [ 1 ]; # Port range
214 my @tempr1 = split ( /\:/ , $portrange2 );
216 if ( $port1 < $tempr1 [ 0 ] || $port1 > $tempr1 [ 1 ]) {
223 # Darren Critchley - certain ports are reserved for IPFire
224 # TCP 67,68,81,222,445
226 # Params passed in -> port, rangeyn, protocol
229 # port 67 and 68 same for tcp and udp, don't bother putting in an array
231 my @tcp_reserved = ( 81 , 222 , 445 );
232 my $prt = $_ [ 0 ]; # the port or range
233 my $ryn = $_ [ 1 ]; # tells us whether or not it is a port range
234 my $prot = $_ [ 2 ]; # protocol
235 my $srcdst = $_ [ 3 ]; # source or destination
236 if ( $ryn ) { # disect port range
237 if ( $srcdst eq "src" ) {
238 $msg = " $Lang ::tr{'rsvd src port overlap'}" ;
240 $msg = " $Lang ::tr{'rsvd dst port overlap'}" ;
242 my @tmprng = split ( /\:/ , $prt );
243 unless ( 67 < $tmprng [ 0 ] || 67 > $tmprng [ 1 ]) { $errormessage = " $msg 67" ; return ; }
244 unless ( 68 < $tmprng [ 0 ] || 68 > $tmprng [ 1 ]) { $errormessage = " $msg 68" ; return ; }
245 if ( $prot eq "tcp" ) {
246 foreach my $prange ( @tcp_reserved ) {
247 unless ( $prange < $tmprng [ 0 ] || $prange > $tmprng [ 1 ]) { $errormessage = " $msg $prange " ; return ; }
251 if ( $srcdst eq "src" ) {
252 $msg = " $Lang ::tr{'reserved src port'}" ;
254 $msg = " $Lang ::tr{'reserved dst port'}" ;
256 if ( $prt == 67 ) { $errormessage = " $msg 67" ; return ; }
257 if ( $prt == 68 ) { $errormessage = " $msg 68" ; return ; }
258 if ( $prot eq "tcp" ) {
259 foreach my $prange ( @tcp_reserved ) {
260 if ( $prange == $prt ) { $errormessage = " $msg $prange " ; return ; }
267 sub writeserverconf
{
268 my %sovpnsettings = ();
270 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%sovpnsettings );
273 open ( CONF
, ">${General::swroot}/ovpn/server.conf" ) or die "Unable to open ${General::swroot}/ovpn/server.conf: $!" ;
275 print CONF
"#OpenVPN Server conf \n " ;
277 print CONF
"daemon openvpnserver \n " ;
278 print CONF
"writepid /var/run/openvpn.pid \n " ;
279 print CONF
"#DAN prepare OpenVPN for listening on blue and orange \n " ;
280 print CONF
";local $sovpnsettings {'VPN_IP'} \n " ;
281 print CONF
"dev $sovpnsettings {'DDEVICE'} \n " ;
282 print CONF
"proto $sovpnsettings {'DPROTOCOL'} \n " ;
283 print CONF
"port $sovpnsettings {'DDEST_PORT'} \n " ;
284 print CONF
"script-security 3 system \n " ;
285 print CONF
"ifconfig-pool-persist /var/ipfire/ovpn/ovpn-leases.db 3600 \n " ;
286 print CONF
"client-config-dir /var/ipfire/ovpn/ccd \n " ;
287 print CONF
"tls-server \n " ;
288 print CONF
"ca /var/ipfire/ovpn/ca/cacert.pem \n " ;
289 print CONF
"cert /var/ipfire/ovpn/certs/servercert.pem \n " ;
290 print CONF
"key /var/ipfire/ovpn/certs/serverkey.pem \n " ;
291 print CONF
"dh /var/ipfire/ovpn/ca/dh1024.pem \n " ;
292 my @tempovpnsubnet = split ( "\/" , $sovpnsettings { 'DOVPN_SUBNET' });
293 print CONF
"server $tempovpnsubnet [0] $tempovpnsubnet [1] \n " ;
294 #print CONF "push \"route $netsettings{'GREEN_NETADDRESS'} $netsettings{'GREEN_NETMASK'}\"\n";
296 # Check if we are using mssfix, fragment or mtu-disc and set the corretct mtu of 1500.
297 # If we doesn't use one of them, we can use the configured mtu value.
298 if ( $sovpnsettings { 'MSSFIX' } eq 'on' )
299 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
300 elsif ( $sovpnsettings { 'FRAGMENT' } ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' )
301 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
302 elsif (( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
303 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
304 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'no' ))
305 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
307 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu $sovpnsettings {'DMTU'} \n " ; }
309 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
310 @temp = split ( /\n/ , $vpnsettings { 'ROUTES_PUSH' });
313 @tempovpnsubnet = split ( "\/" ,& General
:: ipcidr2msk
( $_ ));
314 print CONF
"push \" route " . $tempovpnsubnet [ 0 ]. " " . $tempovpnsubnet [ 1 ] . " \"\n " ;
319 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
320 foreach my $key ( keys %ccdconfhash ) {
321 my $a = $ccdconfhash { $key }[ 1 ];
322 my ( $b , $c ) = split ( /\/ /, $a );
323 print CONF
"route $b " .& General
:: cidrtosub
( $c ). " \n " ;
326 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
327 foreach my $key ( keys %ccdroutehash ) {
328 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
329 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
330 print CONF
"route $a $b \n " ;
335 if ( $sovpnsettings { CLIENT2CLIENT
} eq 'on' ) {
336 print CONF
"client-to-client \n " ;
338 if ( $sovpnsettings { MSSFIX
} eq 'on' ) {
339 print CONF
"mssfix \n " ;
341 if ( $sovpnsettings { FRAGMENT
} ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' ) {
342 print CONF
"fragment $sovpnsettings {'FRAGMENT'} \n " ;
345 # Check if a valid operating mode has been choosen and use it.
346 if (( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
347 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
348 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'no' )) {
349 print CONF
"mtu-disc $sovpnsettings {'PMTU_DISCOVERY'} \n " ;
352 if ( $sovpnsettings { KEEPALIVE_1
} > 0 && $sovpnsettings { KEEPALIVE_2
} > 0 ) {
353 print CONF
"keepalive $sovpnsettings {'KEEPALIVE_1'} $sovpnsettings {'KEEPALIVE_2'} \n " ;
355 print CONF
"status-version 1 \n " ;
356 print CONF
"status /var/log/ovpnserver.log 30 \n " ;
357 print CONF
"cipher $sovpnsettings {DCIPHER} \n " ;
358 if ( $sovpnsettings { DCOMPLZO
} eq 'on' ) {
359 print CONF
"comp-lzo \n " ;
361 if ( $sovpnsettings { REDIRECT_GW_DEF1
} eq 'on' ) {
362 print CONF
"push \" redirect-gateway def1 \"\n " ;
364 if ( $sovpnsettings { DHCP_DOMAIN
} ne '' ) {
365 print CONF
"push \" dhcp-option DOMAIN $sovpnsettings {DHCP_DOMAIN} \"\n " ;
368 if ( $sovpnsettings { DHCP_DNS
} ne '' ) {
369 print CONF
"push \" dhcp-option DNS $sovpnsettings {DHCP_DNS} \"\n " ;
372 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
373 print CONF
"push \" dhcp-option WINS $sovpnsettings {DHCP_WINS} \"\n " ;
376 if ( $sovpnsettings { DHCP_WINS
} eq '' ) {
377 print CONF
"max-clients 100 \n " ;
379 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
380 print CONF
"max-clients $sovpnsettings {MAX_CLIENTS} \n " ;
382 print CONF
"tls-verify /var/ipfire/ovpn/verify \n " ;
383 print CONF
"crl-verify /var/ipfire/ovpn/crls/cacrl.pem \n " ;
384 print CONF
"user nobody \n " ;
385 print CONF
"group nobody \n " ;
386 print CONF
"persist-key \n " ;
387 print CONF
"persist-tun \n " ;
388 if ( $sovpnsettings { LOG_VERB
} ne '' ) {
389 print CONF
"verb $sovpnsettings {LOG_VERB} \n " ;
391 print CONF
"verb 3 \n " ;
399 if ( open ( FILE
, ">/var/log/ovpnserver.log" )) {
409 my %ccdconfhash = ();
411 my $ccdnetname = $_ [ 0 ];
412 if (- f
"${General::swroot}/ovpn/ovpnconfig" ){
413 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
414 foreach my $key ( keys %ccdhash ) {
415 if ( $ccdhash { $key }[ 32 ] eq $ccdnetname ) {
416 $errormessage = $Lang :: tr
{ 'ccd err hostinnet' };
421 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
422 foreach my $key ( keys %ccdconfhash ) {
423 if ( $ccdconfhash { $key }[ 0 ] eq $ccdnetname ){
424 delete $ccdconfhash { $key };
427 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
449 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err name' }. "<br>" ;
453 if (!& General
:: validhostname
( $ccdname ))
455 $errormessage = $Lang :: tr
{ 'ccd err invalidname' };
459 ( $ccdip , $subcidr ) = split ( /\/ /, $ccdnet );
460 $subcidr =& General
:: iporsubtocidr
( $subcidr );
464 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
468 if (!& General
:: validipandmask
( $ccdnet )){
469 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
473 $errormessage =& General
:: checksubnets
( $ccdname , $ccdnet );
476 if (! $errormessage ) {
478 $baseaddress =& General
:: getnetworkip
( $ccdip , $subcidr );
479 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
480 my $key = & General
:: findhasharraykey
( \
%ccdconfhash );
481 foreach my $i ( 0 .. 1 ) { $ccdconfhash { $key }[ $i ] = "" ;}
482 $ccdconfhash { $key }[ 0 ] = $ccdname ;
483 $ccdconfhash { $key }[ 1 ] = $baseaddress . "/" . $subcidr ;
484 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
486 $cgiparams { 'ccdname' }= '' ;
487 $cgiparams { 'ccdsubnet' }= '' ;
499 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
500 foreach my $key ( keys %ccdconfhash ) {
501 if ( $ccdconfhash { $key }[ 0 ] eq $oldname ) {
502 foreach my $key1 ( keys %ccdconfhash ) {
503 if ( $ccdconfhash { $key1 }[ 0 ] eq $newname ){
504 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err netadrexist' };
507 $ccdconfhash { $key }[ 0 ]= $newname ;
508 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
515 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
516 foreach my $key ( keys %ccdhash ) {
517 if ( $ccdhash { $key }[ 32 ] eq $oldname ) {
518 $ccdhash { $key }[ 32 ]= $newname ;
519 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
528 my $ccdnetwork = $_ [ 0 ];
531 @octets = split ( "\/" , $ccdnetwork );
532 @subnet = split /\./ , & General
:: cidrtosub
( $octets [ 1 ]);
545 my ( $ip1 , $ip2 , $ip3 , $ip4 )= split /\./ , $ipin ;
553 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
554 $iprange [ 0 ]= $ip1 . "." . $ip2 . "." . $ip3 . "." .2 ;
555 for ( my $i = 1 ; $i <= $count ; $i ++) {
556 my $tmpip = $iprange [ $i - 1 ];
558 $iprange [ $i ]= & General
:: getnextip
( $tmpip , 4 );
561 foreach my $key ( keys %ccdhash ) {
563 foreach my $tmp ( @iprange ){
564 my ( $net , $sub ) = split ( /\/ /, $ccdhash { $key }[ 33 ]);
566 if ( $hasip ne $ccdhash { $key }[ 33 ] ){
567 splice ( @iprange , $r , 1 );
579 my ( $ccdip , $subcidr ) = split ( "/" , $_ [ 0 ]);
581 my @allccdips =& getccdadresses
( $ccdip , $subcidr ,& ccdmaxclients
( $ccdip . "/" . $subcidr ), $tz );
582 print "<select name=' $boxname ' STYLE='font-family : arial; font-size : 9pt; width:130px;' >" ;
583 foreach ( @allccdips ) {
586 print "<option value=' $ip ' " ;
587 if ( $ip eq $cgiparams { $boxname } ){
590 print "> $ip </option>" ;
600 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
601 foreach my $key ( keys %ccdhash ) {
602 if ( $ccdhash { $key }[ 32 ] eq $name ){ $i ++;}
607 sub check_routes_push
610 my ( $ip , $cidr ) = split ( /\/ /, $val );
611 ##check for existing routes in routes_push
612 if (- e
"${General::swroot}/ovpn/routes_push" ) {
613 open ( FILE
, "${General::swroot}/ovpn/routes_push" );
617 my ( $ip2 , $cidr2 ) = split ( /\/ /, " $_ " );
618 my $val2 = $ip2 . "/" .& General
:: iporsubtodec
( $cidr2 );
624 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: iporsubtodec
( $cidr2 ))){
637 my ( $ip , $cidr ) = split ( /\/ /, $val );
638 #check for existing routes in ccdroute
639 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
640 foreach my $key ( keys %ccdroutehash ) {
641 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
642 if (& General
:: iporsubtodec
( $val ) eq $ccdroutehash { $key }[ $i ] && $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' }){
645 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
647 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )&& $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' } ){
658 my ( $ip , $cidr ) = split ( /\/ /, $val );
659 #check for existing routes in ccdroute
660 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
661 foreach my $key ( keys %ccdconfhash ) {
662 if (& General
:: iporsubtocidr
( $val ) eq $ccdconfhash { $key }[ 1 ]){
665 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdconfhash { $key }[ 1 ]);
667 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: cidrtosub
( $cidr2 ))){
681 my $ipdotmask = $_ [ 0 ];
682 if (& General
:: validip
( $ipdotmask )) { return 0 ; }
683 if (!( $ipdotmask =~ /^(.*?)\/ (.* ?
)$/)) { }
685 if (( $mask =~ /\./ )) { return 0 ; }
689 # -------------------------------------------------------------------
691 sub write_routepushfile
693 open ( FILE
, "> $routes_push_file " );
695 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
696 print FILE
$vpnsettings { 'ROUTES_PUSH' };
701 sub read_routepushfile
703 if (- e
" $routes_push_file " ) {
704 open ( FILE
, " $routes_push_file " );
705 delete $vpnsettings { 'ROUTES_PUSH' };
706 while (< FILE
>) { $vpnsettings { 'ROUTES_PUSH' } .= $_ };
708 $cgiparams { 'ROUTES_PUSH' } = $vpnsettings { 'ROUTES_PUSH' };
714 #hier die refresh page
715 if ( - e
"${General::swroot}/ovpn/gencanow" ) {
717 $refresh = "<meta http-equiv='refresh' content='15;' />" ;
718 & Header
:: showhttpheaders
();
719 & Header
:: openpage
( $Lang :: tr
{ 'OVPN' }, 1 , $refresh );
720 & Header
:: openbigbox
( '100%' , 'center' );
721 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
722 print "<tr> \n <td align='center'><img src='/images/clock.gif' alt='' /></td> \n " ;
723 print "<td colspan='2'><font color='red'>Please be patient this realy can take some time on older hardware...</font></td></tr> \n " ;
725 & Header
:: closebigbox
();
726 & Header
:: closepage
();
729 ##hier die refresh page
733 ### OpenVPN Server Control
735 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' } ||
736 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' } ||
737 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart ovpn server' }) {
738 #start openvpn server
739 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' }){
741 system ( '/usr/local/bin/openvpnctrl' , '-s' );
744 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' }){
745 system ( '/usr/local/bin/openvpnctrl' , '-k' );
748 # #restart openvpn server
749 # if ($cgiparams{'ACTION'} eq $Lang::tr{'restart ovpn server'}){
750 #workarund, till SIGHUP also works when running as nobody
751 # system('/usr/local/bin/openvpnctrl', '-r');
757 ### Save Advanced options
760 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save-adv-options' }) {
761 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
762 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
763 #DAN this value has to leave.
764 #new settings for daemon
765 $vpnsettings { 'LOG_VERB' } = $cgiparams { 'LOG_VERB' };
766 $vpnsettings { 'KEEPALIVE_1' } = $cgiparams { 'KEEPALIVE_1' };
767 $vpnsettings { 'KEEPALIVE_2' } = $cgiparams { 'KEEPALIVE_2' };
768 $vpnsettings { 'MAX_CLIENTS' } = $cgiparams { 'MAX_CLIENTS' };
769 $vpnsettings { 'REDIRECT_GW_DEF1' } = $cgiparams { 'REDIRECT_GW_DEF1' };
770 $vpnsettings { 'CLIENT2CLIENT' } = $cgiparams { 'CLIENT2CLIENT' };
771 $vpnsettings { 'DHCP_DOMAIN' } = $cgiparams { 'DHCP_DOMAIN' };
772 $vpnsettings { 'DHCP_DNS' } = $cgiparams { 'DHCP_DNS' };
773 $vpnsettings { 'DHCP_WINS' } = $cgiparams { 'DHCP_WINS' };
774 $vpnsettings { 'ROUTES_PUSH' } = $cgiparams { 'ROUTES_PUSH' };
775 $vpnsettings { 'PMTU_DISCOVERY' } = $cgiparams { 'PMTU_DISCOVERY' };
778 if ( $cgiparams { 'FRAGMENT' } eq '' ) {
779 delete $vpnsettings { 'FRAGMENT' };
781 if ( $cgiparams { 'FRAGMENT' } !~ /^[0-9]+$/ ) {
782 $errormessage = "Incorrect value, please insert only numbers." ;
785 $vpnsettings { 'FRAGMENT' } = $cgiparams { 'FRAGMENT' };
788 if ( $cgiparams { 'MSSFIX' } ne 'on' ) {
789 delete $vpnsettings { 'MSSFIX' };
791 $vpnsettings { 'MSSFIX' } = $cgiparams { 'MSSFIX' };
794 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
795 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
796 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
798 if (( $cgiparams { 'MSSFIX' } eq 'on' ) || ( $cgiparams { 'FRAGMENT' } ne '' )) {
799 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
804 if ( $cgiparams { 'DHCP_DOMAIN' } ne '' ){
805 unless (& General
:: validdomainname
( $cgiparams { 'DHCP_DOMAIN' }) || & General
:: validip
( $cgiparams { 'DHCP_DOMAIN' })) {
806 $errormessage = $Lang :: tr
{ 'invalid input for dhcp domain' };
810 if ( $cgiparams { 'DHCP_DNS' } ne '' ){
811 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_DNS' }) || & General
:: validip
( $cgiparams { 'DHCP_DNS' })) {
812 $errormessage = $Lang :: tr
{ 'invalid input for dhcp dns' };
816 if ( $cgiparams { 'DHCP_WINS' } ne '' ){
817 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_WINS' }) || & General
:: validip
( $cgiparams { 'DHCP_WINS' })) {
818 $errormessage = $Lang :: tr
{ 'invalid input for dhcp wins' };
822 if ( $cgiparams { 'ROUTES_PUSH' } ne '' ){
823 @temp = split ( /\n/ , $cgiparams { 'ROUTES_PUSH' });
824 undef $vpnsettings { 'ROUTES_PUSH' };
826 foreach my $tmpip ( @temp )
828 s/^\s+//g ; s/\s+$//g ;
833 unless (& General
:: validipandmask
( $tmpip )) {
834 $errormessage = " $tmpip " . $Lang :: tr
{ 'ovpn errmsg invalid ip or mask' };
837 my ( $ip , $cidr ) = split ( "\/" ,& General
:: ipcidr2msk
( $tmpip ));
839 if ( $ip eq $netsettings { 'GREEN_NETADDRESS' } && $cidr eq $netsettings { 'GREEN_NETMASK' }) {
840 $errormessage = $Lang :: tr
{ 'ovpn errmsg green already pushed' };
845 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
846 foreach my $key ( keys %ccdroutehash ) {
847 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
848 if ( $ip . "/" . $cidr eq $ccdroutehash { $key }[ $i ] ){
849 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
852 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
853 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )){
854 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
862 $vpnsettings { 'ROUTES_PUSH' } .= $tmpip . " \n " ;
865 & write_routepushfile
;
866 undef $vpnsettings { 'ROUTES_PUSH' };
869 undef $vpnsettings { 'ROUTES_PUSH' };
870 & write_routepushfile
;
872 if (( length ( $cgiparams { 'MAX_CLIENTS' }) == 0 ) || (( $cgiparams { 'MAX_CLIENTS' }) < 1 ) || (( $cgiparams { 'MAX_CLIENTS' }) > 255 )) {
873 $errormessage = $Lang :: tr
{ 'invalid input for max clients' };
876 if ( $cgiparams { 'KEEPALIVE_1' } ne '' ) {
877 if ( $cgiparams { 'KEEPALIVE_1' } !~ /^[0-9]+$/ ) {
878 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1' };
882 if ( $cgiparams { 'KEEPALIVE_2' } ne '' ){
883 if ( $cgiparams { 'KEEPALIVE_2' } !~ /^[0-9]+$/ ) {
884 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 2' };
888 if ( $cgiparams { 'KEEPALIVE_2' } < ( $cgiparams { 'KEEPALIVE_1' } * 2 )){
889 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1:2' };
893 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
894 & writeserverconf
(); #hier ok
901 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'server' )
904 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
905 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
906 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
909 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
910 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
912 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: $!" ;
915 print SERVERCONF
"# IPFire n2n Open VPN Server Config by ummeegge und m.a.d \n " ;
916 print SERVERCONF
" \n " ;
917 print SERVERCONF
"# User Security \n " ;
918 print SERVERCONF
"user nobody \n " ;
919 print SERVERCONF
"group nobody \n " ;
920 print SERVERCONF
"persist-tun \n " ;
921 print SERVERCONF
"persist-key \n " ;
922 print SERVERCONF
"script-security 2 \n " ;
923 print SERVERCONF
"# IP/DNS for remote Server Gateway \n " ;
925 if ( $cgiparams { 'REMOTE' } ne '' ) {
926 print SERVERCONF
"remote $cgiparams {'REMOTE'} \n " ;
929 print SERVERCONF
"float \n " ;
930 print SERVERCONF
"# IP adresses of the VPN Subnet \n " ;
931 print SERVERCONF
"ifconfig $ovsubnet .1 $ovsubnet .2 \n " ;
932 print SERVERCONF
"# Client Gateway Network \n " ;
933 print SERVERCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
934 print SERVERCONF
"# tun Device \n " ;
935 print SERVERCONF
"dev tun \n " ;
936 print SERVERCONF
"# Port and Protokol \n " ;
937 print SERVERCONF
"port $cgiparams {'DEST_PORT'} \n " ;
939 if ( $cgiparams { 'PROTOCOL' } eq 'tcp' ) {
940 print SERVERCONF
"proto tcp-server \n " ;
941 print SERVERCONF
"# Packet size \n " ;
942 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1400' } else { $tunmtu = $cgiparams { 'MTU' }};
943 print SERVERCONF
"tun-mtu $tunmtu \n " ;
946 if ( $cgiparams { 'PROTOCOL' } eq 'udp' ) {
947 print SERVERCONF
"proto udp \n " ;
948 print SERVERCONF
"# Paketsize \n " ;
949 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
950 print SERVERCONF
"tun-mtu $tunmtu \n " ;
951 if ( $cgiparams { 'FRAGMENT' } ne '' ) { print SERVERCONF
"fragment $cgiparams {'FRAGMENT'} \n " ;}
952 if ( $cgiparams { 'MSSFIX' } eq 'on' ) { print SERVERCONF
"mssfix \n " ; };
955 # Check if a valid operating mode has been choosen and use it.
956 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
957 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
958 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
959 if (( $cgiparams { 'MSSFIX' } ne 'on' ) || ( $cgiparams { 'FRAGMENT' } eq '' )) {
960 if ( $cgiparams { 'MTU' } eq '1500' ) {
961 print SERVERCONF
"mtu-disc $cgiparams {'PMTU_DISCOVERY'} \n " ;
965 print SERVERCONF
"# Auth. Server \n " ;
966 print SERVERCONF
"tls-server \n " ;
967 print SERVERCONF
"ca ${General::swroot}/ovpn/ca/cacert.pem \n " ;
968 print SERVERCONF
"cert ${General::swroot}/ovpn/certs/servercert.pem \n " ;
969 print SERVERCONF
"key ${General::swroot}/ovpn/certs/serverkey.pem \n " ;
970 print SERVERCONF
"dh ${General::swroot}/ovpn/ca/dh1024.pem \n " ;
971 print SERVERCONF
"# Cipher \n " ;
972 print SERVERCONF
"cipher AES-256-CBC \n " ;
973 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
974 print SERVERCONF
"# Enable Compression \n " ;
975 print SERVERCONF
"comp-lzo \r\n " ;
977 print SERVERCONF
"# Debug Level \n " ;
978 print SERVERCONF
"verb 3 \n " ;
979 print SERVERCONF
"# Tunnel check \n " ;
980 print SERVERCONF
"keepalive 10 60 \n " ;
981 print SERVERCONF
"# Start as daemon \n " ;
982 print SERVERCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
983 print SERVERCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
984 print SERVERCONF
"# Activate Management Interface and Port \n " ;
985 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) { print SERVERCONF
"management localhost $cgiparams {'DEST_PORT'} \n " }
986 else { print SERVERCONF
"management localhost $cgiparams {'OVPN_MGMT'} \n " };
995 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'client' )
997 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
998 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
999 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
1002 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
1003 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
1005 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: $!" ;
1007 flock CLIENTCONF
, 2 ;
1008 print CLIENTCONF
"# IPFire rewritten n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
1009 print CLIENTCONF
"# \n " ;
1010 print CLIENTCONF
"# User Security \n " ;
1011 print CLIENTCONF
"user nobody \n " ;
1012 print CLIENTCONF
"group nobody \n " ;
1013 print CLIENTCONF
"persist-tun \n " ;
1014 print CLIENTCONF
"persist-key \n " ;
1015 print CLIENTCONF
"script-security 2 \n " ;
1016 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
1017 print CLIENTCONF
"remote $cgiparams {'REMOTE'} \n " ;
1018 print CLIENTCONF
"float \n " ;
1019 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
1020 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
1021 print CLIENTCONF
"# Server Gateway Network \n " ;
1022 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
1023 print CLIENTCONF
"# tun Device \n " ;
1024 print CLIENTCONF
"dev tun \n " ;
1025 print CLIENTCONF
"# Port and Protokol \n " ;
1026 print CLIENTCONF
"port $cgiparams {'DEST_PORT'} \n " ;
1028 if ( $cgiparams { 'PROTOCOL' } eq 'tcp' ) {
1029 print CLIENTCONF
"proto tcp-client \n " ;
1030 print CLIENTCONF
"# Packet size \n " ;
1031 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1400' } else { $tunmtu = $cgiparams { 'MTU' }};
1032 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
1035 if ( $cgiparams { 'PROTOCOL' } eq 'udp' ) {
1036 print CLIENTCONF
"proto udp \n " ;
1037 print CLIENTCONF
"# Paketsize \n " ;
1038 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
1039 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
1040 if ( $cgiparams { 'FRAGMENT' } ne '' ) { print CLIENTCONF
"fragment $cgiparams {'FRAGMENT'} \n " ;}
1041 if ( $cgiparams { 'MSSFIX' } eq 'on' ) { print CLIENTCONF
"mssfix \n " ; };
1044 # Check if a valid operating mode has been choosen and use it.
1045 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
1046 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
1047 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
1048 if (( $cgiparams { 'MSSFIX' } ne 'on' ) || ( $cgiparams { 'FRAGMENT' } eq '' )) {
1049 if ( $cgiparams { 'MTU' } eq '1500' ) {
1050 print CLIENTCONF
"mtu-disc $cgiparams {'PMTU_DISCOVERY'} \n " ;
1055 print CLIENTCONF
"ns-cert-type server \n " ;
1056 print CLIENTCONF
"# Auth. Client \n " ;
1057 print CLIENTCONF
"tls-client \n " ;
1058 print CLIENTCONF
"# Cipher \n " ;
1059 print CLIENTCONF
"cipher AES-256-CBC \n " ;
1060 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12 \r\n " ;
1061 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
1062 print CLIENTCONF
"# Enable Compression \n " ;
1063 print CLIENTCONF
"comp-lzo \r\n " ;
1065 print CLIENTCONF
"# Debug Level \n " ;
1066 print CLIENTCONF
"verb 3 \n " ;
1067 print CLIENTCONF
"# Tunnel check \n " ;
1068 print CLIENTCONF
"keepalive 10 60 \n " ;
1069 print CLIENTCONF
"# Start as daemon \n " ;
1070 print CLIENTCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
1071 print CLIENTCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
1072 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
1073 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) { print CLIENTCONF
"management localhost $cgiparams {'DEST_PORT'} \n " }
1074 else { print CLIENTCONF
"management localhost $cgiparams {'OVPN_MGMT'} \n " };
1080 ### Save main settings
1084 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
1085 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1086 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
1087 #DAN this value has to leave.
1088 if ( $cgiparams { 'ENABLED' } eq 'on' ){
1089 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })) {
1090 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1091 goto SETTINGS_ERROR
;
1094 if ( $cgiparams { 'ENABLED' } eq 'on' ){
1095 & disallowreserved
( $cgiparams { 'DDEST_PORT' }, 0 , $cgiparams { 'DPROTOCOL' }, "dest" );
1097 if ( $errormessage ) { goto SETTINGS_ERROR
; }
1100 if ( $cgiparams { 'ENABLED' } eq 'on' ){
1101 & checkportfw
( $cgiparams { 'DDEST_PORT' }, $cgiparams { 'DPROTOCOL' });
1104 if ( $errormessage ) { goto SETTINGS_ERROR
; }
1106 if (! & General
:: validipandmask
( $cgiparams { 'DOVPN_SUBNET' })) {
1107 $errormessage = $Lang :: tr
{ 'ovpn subnet is invalid' };
1108 goto SETTINGS_ERROR
;
1110 my @tmpovpnsubnet = split ( "\/" , $cgiparams { 'DOVPN_SUBNET' });
1112 if (& General
:: IpInSubnet
( $netsettings { 'RED_ADDRESS' },
1113 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1114 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire RED Network $netsettings {'RED_ADDRESS'}" ;
1115 goto SETTINGS_ERROR
;
1118 if (& General
:: IpInSubnet
( $netsettings { 'GREEN_ADDRESS' },
1119 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1120 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Green Network $netsettings {'GREEN_ADDRESS'}" ;
1121 goto SETTINGS_ERROR
;
1124 if (& General
:: IpInSubnet
( $netsettings { 'BLUE_ADDRESS' },
1125 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1126 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Blue Network $netsettings {'BLUE_ADDRESS'}" ;
1127 goto SETTINGS_ERROR
;
1130 if (& General
:: IpInSubnet
( $netsettings { 'ORANGE_ADDRESS' },
1131 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1132 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Orange Network $netsettings {'ORANGE_ADDRESS'}" ;
1133 goto SETTINGS_ERROR
;
1135 open ( ALIASES
, "${General::swroot}/ethernet/aliases" ) or die 'Unable to open aliases file.' ;
1139 my @tempalias = split ( /\,/ , $_ );
1140 if ( $tempalias [ 1 ] eq 'on' ) {
1141 if (& General
:: IpInSubnet
( $tempalias [ 0 ] ,
1142 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1143 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire alias entry $tempalias [0]" ;
1148 if ( $errormessage ne '' ){
1149 goto SETTINGS_ERROR
;
1151 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1152 $errormessage = $Lang :: tr
{ 'invalid input' };
1153 goto SETTINGS_ERROR
;
1155 if (( length ( $cgiparams { 'DMTU' })== 0 ) || (( $cgiparams { 'DMTU' }) < 1000 )) {
1156 $errormessage = $Lang :: tr
{ 'invalid mtu input' };
1157 goto SETTINGS_ERROR
;
1160 unless (& General
:: validport
( $cgiparams { 'DDEST_PORT' })) {
1161 $errormessage = $Lang :: tr
{ 'invalid port' };
1162 goto SETTINGS_ERROR
;
1164 $vpnsettings { 'ENABLED_BLUE' } = $cgiparams { 'ENABLED_BLUE' };
1165 $vpnsettings { 'ENABLED_ORANGE' } = $cgiparams { 'ENABLED_ORANGE' };
1166 $vpnsettings { 'ENABLED' } = $cgiparams { 'ENABLED' };
1167 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
1168 #new settings for daemon
1169 $vpnsettings { 'DOVPN_SUBNET' } = $cgiparams { 'DOVPN_SUBNET' };
1170 $vpnsettings { 'DDEVICE' } = $cgiparams { 'DDEVICE' };
1171 $vpnsettings { 'DPROTOCOL' } = $cgiparams { 'DPROTOCOL' };
1172 $vpnsettings { 'DDEST_PORT' } = $cgiparams { 'DDEST_PORT' };
1173 $vpnsettings { 'DMTU' } = $cgiparams { 'DMTU' };
1174 $vpnsettings { 'DCOMPLZO' } = $cgiparams { 'DCOMPLZO' };
1175 $vpnsettings { 'DCIPHER' } = $cgiparams { 'DCIPHER' };
1178 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" );}
1179 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" );}
1180 if ( $vpnsettings { 'ENABLED' } eq 'on' ) { system ( "touch ${General::swroot}/ovpn/enable 2>/dev/null" );} else { system ( "unlink ${General::swroot}/ovpn/enable 2>/dev/null" );}
1181 #new settings for daemon
1182 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1183 & writeserverconf
(); #hier ok
1186 ### Reset all step 2
1188 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'reset' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1190 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1192 foreach my $key ( keys %confighash ) {
1193 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
1194 delete $confighash { $cgiparams { ' $key ' }};
1197 while ( $file = glob ( "${General::swroot}/ovpn/ca/*" )) {
1200 while ( $file = glob ( "${General::swroot}/ovpn/certs/*" )) {
1203 while ( $file = glob ( "${General::swroot}/ovpn/crls/*" )) {
1206 & cleanssldatabase
();
1207 if ( open ( FILE
, ">${General::swroot}/ovpn/caconfig" )) {
1211 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1212 #&writeserverconf();
1214 ### Reset all step 1
1216 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'reset' }) {
1217 & Header
:: showhttpheaders
();
1218 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1219 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1220 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'are you sure' });
1222 <table><form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1223 <tr><td align='center'>
1224 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1225 $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}
1226 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'reset'}' />
1227 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td></tr>
1231 & Header
:: closebox
();
1232 & Header
:: closebigbox
();
1233 & Header
:: closepage
();
1237 ### Upload CA Certificate
1239 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
1240 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1242 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1243 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1244 goto UPLOADCA_ERROR
;
1247 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
1248 $errormessage = $Lang :: tr
{ 'name too long' };
1252 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
1253 $errormessage = $Lang :: tr
{ 'name is invalid' };
1254 goto UPLOAD_CA_ERROR
;
1257 # Check if there is no other entry with this name
1258 foreach my $key ( keys %cahash ) {
1259 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
1260 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
1261 goto UPLOADCA_ERROR
;
1265 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1266 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1267 goto UPLOADCA_ERROR
;
1269 # Move uploaded ca to a temporary file
1270 ( my $fh , my $filename ) = tempfile
( );
1271 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1273 goto UPLOADCA_ERROR
;
1275 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
1276 if ( $temp !~ /CA:TRUE/i ) {
1277 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1279 goto UPLOADCA_ERROR
;
1281 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1283 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1285 goto UPLOADCA_ERROR
;
1289 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem` ;
1290 $casubject =~ /Subject: (.*)[\n]/ ;
1292 $casubject =~ s
+/ Email
+, E
+;
1293 $casubject =~ s/ ST=/ S=/ ;
1294 $casubject = & Header
:: cleanhtml
( $casubject );
1296 my $key = & General
:: findhasharraykey
( \
%cahash );
1297 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1298 $cahash { $key }[ 1 ] = $casubject ;
1299 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1300 # system('/usr/local/bin/ipsecctrl', 'R');
1305 ### Display ca certificate
1307 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
1308 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1310 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1311 & Header
:: showhttpheaders
();
1312 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1313 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1314 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ca certificate'}:" );
1315 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1316 $output = & Header
:: cleanhtml
( $output , "y" );
1317 print "<pre> $output </pre> \n " ;
1318 & Header
:: closebox
();
1319 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1320 & Header
:: closebigbox
();
1321 & Header
:: closepage
();
1324 $errormessage = $Lang :: tr
{ 'invalid key' };
1328 ### Download ca certificate
1330 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
1331 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1333 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1334 print "Content-Type: application/octet-stream \r\n " ;
1335 print "Content-Disposition: filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
1336 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1339 $errormessage = $Lang :: tr
{ 'invalid key' };
1343 ### Remove ca certificate (step 2)
1345 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1346 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1347 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1349 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1350 foreach my $key ( keys %confighash ) {
1351 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` ;
1352 if ( $test =~ /: OK/ ) {
1354 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1355 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
1356 # system('/usr/local/bin/ipsecctrl', 'D', $key);
1358 unlink ( "${General::swroot}/ovpn//certs/ $confighash { $key }[1]cert.pem" );
1359 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" );
1360 delete $confighash { $key };
1361 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1362 # &writeipsecfiles();
1365 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1366 delete $cahash { $cgiparams { 'KEY' }};
1367 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1368 # system('/usr/local/bin/ipsecctrl', 'R');
1370 $errormessage = $Lang :: tr
{ 'invalid key' };
1373 ### Remove ca certificate (step 1)
1375 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
1376 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1377 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1379 my $assignedcerts = 0 ;
1380 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1381 foreach my $key ( keys %confighash ) {
1382 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` ;
1383 if ( $test =~ /: OK/ ) {
1387 if ( $assignedcerts ) {
1388 & Header
:: showhttpheaders
();
1389 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1390 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1391 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'are you sure' });
1393 <table><form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1394 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1395 <tr><td align='center'>
1396 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>: $assignedcerts
1397 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}
1398 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
1399 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td></tr>
1403 & Header
:: closebox
();
1404 & Header
:: closebigbox
();
1405 & Header
:: closepage
();
1408 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1409 delete $cahash { $cgiparams { 'KEY' }};
1410 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1411 # system('/usr/local/bin/ipsecctrl', 'R');
1414 $errormessage = $Lang :: tr
{ 'invalid key' };
1418 ### Display root certificate
1420 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
1421 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
1423 & Header
:: showhttpheaders
();
1424 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1425 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1426 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
1427 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'root certificate'}:" );
1428 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1430 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'host certificate'}:" );
1431 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1433 $output = & Header
:: cleanhtml
( $output , "y" );
1434 print "<pre> $output </pre> \n " ;
1435 & Header
:: closebox
();
1436 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1437 & Header
:: closebigbox
();
1438 & Header
:: closepage
();
1442 ### Download root certificate
1444 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
1445 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1446 print "Content-Type: application/octet-stream \r\n " ;
1447 print "Content-Disposition: filename=cacert.pem \r\n\r\n " ;
1448 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1453 ### Download host certificate
1455 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
1456 if ( - f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
1457 print "Content-Type: application/octet-stream \r\n " ;
1458 print "Content-Disposition: filename=servercert.pem \r\n\r\n " ;
1459 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1463 ### Form for generating a root certificate
1465 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
1466 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1468 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1469 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1470 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
1471 $cgiparams { 'ACTION' } = '' ;
1472 goto ROOTCERT_ERROR
;
1475 if (( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) && - e
"${General::swroot}/red/active" ) {
1476 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
1477 my $ipaddr = < IPADDR
>;
1480 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
1481 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
1482 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
1485 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1487 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1488 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1489 goto ROOTCERT_ERROR
;
1492 # Move uploaded certificate request to a temporary file
1493 ( my $fh , my $filename ) = tempfile
( );
1494 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1496 goto ROOTCERT_ERROR
;
1499 # Create a temporary dirctory
1500 my $tempdir = tempdir
( CLEANUP
=> 1 );
1502 # Extract the CA certificate from the file
1503 my $pid = open ( OPENSSL
, "|-" );
1504 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1505 if ( $pid ) { # parent
1506 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1507 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1511 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1513 goto ROOTCERT_ERROR
;
1516 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-cacerts' , '-nokeys' ,
1518 '-out' , " $tempdir /cacert.pem" )) {
1519 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1521 goto ROOTCERT_ERROR
;
1525 # Extract the Host certificate from the file
1526 $pid = open ( OPENSSL
, "|-" );
1527 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1528 if ( $pid ) { # parent
1529 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1530 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1534 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1536 goto ROOTCERT_ERROR
;
1539 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-clcerts' , '-nokeys' ,
1541 '-out' , " $tempdir /hostcert.pem" )) {
1542 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1544 goto ROOTCERT_ERROR
;
1548 # Extract the Host key from the file
1549 $pid = open ( OPENSSL
, "|-" );
1550 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1551 if ( $pid ) { # parent
1552 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1553 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1557 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1559 goto ROOTCERT_ERROR
;
1562 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-nocerts' ,
1565 '-out' , " $tempdir /serverkey.pem" )) {
1566 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1568 goto ROOTCERT_ERROR
;
1572 move
( " $tempdir /cacert.pem" , "${General::swroot}/ovpn/ca/cacert.pem" );
1574 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1576 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1577 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1578 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1579 goto ROOTCERT_ERROR
;
1582 move
( " $tempdir /hostcert.pem" , "${General::swroot}/ovpn/certs/servercert.pem" );
1584 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1586 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1587 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1588 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1589 goto ROOTCERT_ERROR
;
1592 move
( " $tempdir /serverkey.pem" , "${General::swroot}/ovpn/certs/serverkey.pem" );
1594 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1596 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1597 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1598 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1599 goto ROOTCERT_ERROR
;
1602 goto ROOTCERT_SUCCESS
;
1604 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
1606 # Validate input since the form was submitted
1607 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
1608 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
1609 goto ROOTCERT_ERROR
;
1611 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
1612 $errormessage = $Lang :: tr
{ 'organization too long' };
1613 goto ROOTCERT_ERROR
;
1615 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1616 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1617 goto ROOTCERT_ERROR
;
1619 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
1620 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
1621 goto ROOTCERT_ERROR
;
1623 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
1624 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1625 goto ROOTCERT_ERROR
;
1627 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
1628 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1629 goto ROOTCERT_ERROR
;
1631 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
1632 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1633 goto ROOTCERT_ERROR
;
1635 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1636 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1637 goto ROOTCERT_ERROR
;
1639 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1640 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1641 goto ROOTCERT_ERROR
;
1643 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1644 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1645 goto ROOTCERT_ERROR
;
1647 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1648 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1649 goto ROOTCERT_ERROR
;
1652 # Copy the cgisettings to vpnsettings and save the configfile
1653 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
1654 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
1655 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
1656 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
1657 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
1658 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
1659 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
1660 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1662 # Replace empty strings with a .
1663 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
1664 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
1665 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
1668 #system ('/bin/touch', "${General::swroot}/ovpn/gencanow");
1670 # Create the CA certificate
1671 my $pid = open ( OPENSSL
, "|-" );
1672 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1673 if ( $pid ) { # parent
1674 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1675 print OPENSSL
" $state \n " ;
1676 print OPENSSL
" $city \n " ;
1677 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1678 print OPENSSL
" $ou \n " ;
1679 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
1680 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1683 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1684 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1685 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1686 goto ROOTCERT_ERROR
;
1689 unless ( exec ( '/usr/bin/openssl' , 'req' , '-x509' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1690 '-days' , '999999' , '-newkey' , 'rsa:2048' ,
1691 '-keyout' , "${General::swroot}/ovpn/ca/cakey.pem" ,
1692 '-out' , "${General::swroot}/ovpn/ca/cacert.pem" ,
1693 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1694 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1695 goto ROOTCERT_ERROR
;
1699 # Create the Host certificate request
1700 $pid = open ( OPENSSL
, "|-" );
1701 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1702 if ( $pid ) { # parent
1703 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1704 print OPENSSL
" $state \n " ;
1705 print OPENSSL
" $city \n " ;
1706 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1707 print OPENSSL
" $ou \n " ;
1708 print OPENSSL
" $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1709 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1710 print OPENSSL
". \n " ;
1711 print OPENSSL
". \n " ;
1714 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1715 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1716 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1717 goto ROOTCERT_ERROR
;
1720 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1721 '-newkey' , 'rsa:1024' ,
1722 '-keyout' , "${General::swroot}/ovpn/certs/serverkey.pem" ,
1723 '-out' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1724 '-extensions' , 'server' ,
1725 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1726 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1727 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1728 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1729 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1730 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1731 goto ROOTCERT_ERROR
;
1735 # Sign the host certificate request
1736 system ( '/usr/bin/openssl' , 'ca' , '-days' , '999999' ,
1737 '-batch' , '-notext' ,
1738 '-in' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1739 '-out' , "${General::swroot}/ovpn/certs/servercert.pem" ,
1740 '-extensions' , 'server' ,
1741 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1743 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1744 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1745 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1746 unlink ( "${General::swroot}/ovpn/serverkey.pem" );
1747 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1748 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1749 & newcleanssldatabase
();
1750 goto ROOTCERT_ERROR
;
1752 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1753 & deletebackupcert
();
1756 # Create an empty CRL
1757 system ( '/usr/bin/openssl' , 'ca' , '-gencrl' ,
1758 '-out' , "${General::swroot}/ovpn/crls/cacrl.pem" ,
1759 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1761 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1762 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1763 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1764 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1765 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1766 & cleanssldatabase
();
1767 goto ROOTCERT_ERROR
;
1769 # &cleanssldatabase();
1771 # Create Diffie Hellmann Parameter
1772 system ( '/usr/bin/openssl' , 'dhparam' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1773 '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" ,
1776 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1777 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1778 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1779 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1780 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1781 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1782 & cleanssldatabase
();
1783 goto ROOTCERT_ERROR
;
1785 # &cleanssldatabase();
1787 goto ROOTCERT_SUCCESS
;
1790 if ( $cgiparams { 'ACTION' } ne '' ) {
1791 & Header
:: showhttpheaders
();
1792 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1793 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1794 if ( $errormessage ) {
1795 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
1796 print "<class name='base'> $errormessage " ;
1797 print " </class>" ;
1798 & Header
:: closebox
();
1800 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'generate root/host certificates'}:" );
1802 <form method='post' enctype='multipart/form-data'>
1803 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1804 <tr><td width='30%' class='base'> $Lang ::tr{'organization name'}:</td>
1805 <td width='35%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td>
1806 <td width='35%' colspan='2'> </td></tr>
1807 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}:</td>
1808 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td>
1809 <td colspan='2'> </td></tr>
1810 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt'*' /></td>
1811 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td>
1812 <td colspan='2'> </td></tr>
1813 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt'*' /></td>
1814 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td>
1815 <td colspan='2'> </td></tr>
1816 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt'*' /></td>
1817 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td>
1818 <td colspan='2'> </td></tr>
1819 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt'*' /></td>
1820 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td>
1821 <td colspan='2'> </td></tr>
1822 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1823 <td class='base'><select name='ROOTCERT_COUNTRY'>
1827 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1828 print "<option value=' $Countries ::countries{ $country }'" ;
1829 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1830 print " selected='selected'" ;
1832 print "> $country </option>" ;
1836 <td colspan='2'> </td></tr>
1838 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /></td>
1839 <td> </td><td> </td></tr>
1840 <tr><td class='base' colspan='4' align='left'>
1841 <img src='/blob.gif' valign='top' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
1842 <tr><td class='base' colspan='4' align='left'>
1843 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1844 $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'}
1846 <tr><td colspan='4' bgcolor='#000000'><img src='/images/null.gif' width='1' height='1' border='0' /></td></tr>
1847 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
1848 <td nowrap='nowrap'><input type='file' name='FH' size='32'></td>
1849 <td colspan='2'> </td></tr>
1850 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' ></td>
1851 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td>
1852 <td colspan='2'> </td></tr>
1854 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td>
1855 <td colspan='2'> </td></tr>
1856 <tr><td class='base' colspan='4' align='left'>
1857 <img src='/blob.gif' valign='top' al='*' > $Lang ::tr{'this field may be blank'}</td></tr>
1861 & Header
:: closebox
();
1863 & Header
:: closebigbox
();
1864 & Header
:: closepage
();
1869 system ( "chmod 600 ${General::swroot}/ovpn/certs/serverkey.pem" );
1870 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1871 # $vpnsettings{'ENABLE_BLUE'} eq 'on') {
1872 # system('/usr/local/bin/ipsecctrl', 'S');
1876 ### Enable/Disable connection
1883 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
1885 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1886 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1887 # my $n2nactive = '';
1888 my $n2nactive = `/bin/ps ax|grep $confighash { $cgiparams {'KEY'}}[1]|grep -v grep|awk \' {print \ $1 } \' ` ;
1890 if ( $confighash { $cgiparams { 'KEY' }}) {
1891 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
1892 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
1893 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1895 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
1896 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
1900 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
1901 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1903 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
1904 if ( $n2nactive ne '' ){
1905 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
1909 $errormessage = $Lang :: tr
{ 'invalid key' };
1915 ### Download OpenVPN client package
1919 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'dl client arch' }) {
1920 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1921 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1923 my $clientovpn = '' ;
1925 my $tempdir = tempdir
( CLEANUP
=> 1 );
1926 my $zippath = " $tempdir /" ;
1932 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
1934 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-Client.zip" ;
1935 my $zippathname = " $zippath $zipname " ;
1936 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1].conf" ;
1937 my @ovsubnettemp = split ( /\./ , $confighash { $cgiparams { 'KEY' }}[ 27 ]);
1938 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
1940 my @remsubnet = split ( /\/ /, $confighash { $cgiparams { 'KEY' }}[ 8 ]);
1941 my $n2nfragment = '' ;
1943 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
1944 flock CLIENTCONF
, 2 ;
1946 my $zip = Archive
:: Zip
-> new ();
1947 print CLIENTCONF
"# IPFire n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
1948 print CLIENTCONF
"# \n " ;
1949 print CLIENTCONF
"# User Security \n " ;
1950 print CLIENTCONF
"user nobody \n " ;
1951 print CLIENTCONF
"group nobody \n " ;
1952 print CLIENTCONF
"persist-tun \n " ;
1953 print CLIENTCONF
"persist-key \n " ;
1954 print CLIENTCONF
"script-security 2 \n " ;
1955 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
1956 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} \n " ;
1957 print CLIENTCONF
"float \n " ;
1958 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
1959 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
1960 print CLIENTCONF
"# Server Gateway Network \n " ;
1961 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
1962 print CLIENTCONF
"# tun Device \n " ;
1963 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \n " ;
1964 print CLIENTCONF
"# Port and Protokoll \n " ;
1965 print CLIENTCONF
"port $confighash { $cgiparams {'KEY'}}[29] \n " ;
1967 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'tcp' ) {
1968 print CLIENTCONF
"proto tcp-client \n " ;
1969 print CLIENTCONF
"# Packet size \n " ;
1970 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1400' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
1971 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
1974 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'udp' ) {
1975 print CLIENTCONF
"proto udp \n " ;
1976 print CLIENTCONF
"# Paketsize \n " ;
1977 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1500' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
1978 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
1979 if ( $confighash { $cgiparams { 'KEY' }}[ 24 ] ne '' ) { print CLIENTCONF
"fragment $confighash { $cgiparams {'KEY'}}[24] \n " ;}
1980 if ( $confighash { $cgiparams { 'KEY' }}[ 23 ] eq 'on' ) { print CLIENTCONF
"mssfix \n " ;}
1982 if (( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'yes' ) ||
1983 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'maybe' ) ||
1984 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'no' )) {
1985 if (( $confighash { $cgiparams { 'KEY' }}[ 23 ] ne 'on' ) || ( $confighash { $cgiparams { 'KEY' }}[ 24 ] eq '' )) {
1986 if ( $tunmtu eq '1500' ) {
1987 print CLIENTCONF
"mtu-disc $confighash { $cgiparams {'KEY'}}[38] \n " ;
1991 print CLIENTCONF
"ns-cert-type server \n " ;
1992 print CLIENTCONF
"# Auth. Client \n " ;
1993 print CLIENTCONF
"tls-client \n " ;
1994 print CLIENTCONF
"# Cipher \n " ;
1995 print CLIENTCONF
"cipher AES-256-CBC \n " ;
1996 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
1997 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
1998 $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 " ;
2000 if ( $confighash { $cgiparams { 'KEY' }}[ 30 ] eq 'on' ) {
2001 print CLIENTCONF
"# Enable Compression \n " ;
2002 print CLIENTCONF
"comp-lzo \r\n " ;
2004 print CLIENTCONF
"# Debug Level \n " ;
2005 print CLIENTCONF
"verb 3 \n " ;
2006 print CLIENTCONF
"# Tunnel check \n " ;
2007 print CLIENTCONF
"keepalive 10 60 \n " ;
2008 print CLIENTCONF
"# Start as daemon \n " ;
2009 print CLIENTCONF
"daemon $confighash { $cgiparams {'KEY'}}[1]n2n \n " ;
2010 print CLIENTCONF
"writepid /var/run/ $confighash { $cgiparams {'KEY'}}[1]n2n.pid \n " ;
2011 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
2012 if ( $confighash { $cgiparams { 'KEY' }}[ 22 ] eq '' ) { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[29] \n " }
2013 else { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[22] \n " };
2014 print CLIENTCONF
"# remsub $confighash { $cgiparams {'KEY'}}[11] \n " ;
2019 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2020 my $status = $zip -> writeToFileNamed ( $zippathname );
2022 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2023 @fileholder = < DLFILE
>;
2024 print "Content-Type:application/x-download \n " ;
2025 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2031 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.zip" ;
2032 my $zippathname = " $zippath $zipname " ;
2033 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.ovpn" ;
2039 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2040 flock CLIENTCONF
, 2 ;
2042 my $zip = Archive
:: Zip
-> new ();
2044 print CLIENTCONF
"#OpenVPN Client conf \r\n " ;
2045 print CLIENTCONF
"tls-client \r\n " ;
2046 print CLIENTCONF
"client \r\n " ;
2047 print CLIENTCONF
"nobind \r\n " ;
2048 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \r\n " ;
2049 print CLIENTCONF
"proto $vpnsettings {'DPROTOCOL'} \r\n " ;
2051 # Check if we are using fragment, mssfix or mtu-disc and set MTU to 1500
2052 # or use configured value.
2053 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' )
2054 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2055 elsif ( $vpnsettings { MSSFIX
} eq 'on' )
2056 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2057 elsif (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2058 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2059 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' ))
2060 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2062 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu $vpnsettings {'DMTU'} \r\n " ; }
2064 if ( $vpnsettings { 'ENABLED' } eq 'on' ){
2065 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2066 if ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2067 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Blue interface \r\n " ;
2068 print CLIENTCONF
";remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2070 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2071 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2072 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2074 } elsif ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2075 print CLIENTCONF
"remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2076 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2077 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2078 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2080 } elsif ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2081 print CLIENTCONF
"remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2084 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2085 print CLIENTCONF
"pkcs12 $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2086 $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 " ;
2088 print CLIENTCONF
"ca cacert.pem \r\n " ;
2089 print CLIENTCONF
"cert $confighash { $cgiparams {'KEY'}}[1]cert.pem \r\n " ;
2090 print CLIENTCONF
"key $confighash { $cgiparams {'KEY'}}[1].key \r\n " ;
2091 $zip -> addFile ( "${General::swroot}/ovpn/ca/cacert.pem" , "cacert.pem" ) or die "Can't add file cacert.pem \n " ;
2092 $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 " ;
2094 print CLIENTCONF
"cipher $vpnsettings {DCIPHER} \r\n " ;
2095 if ( $vpnsettings { DCOMPLZO
} eq 'on' ) {
2096 print CLIENTCONF
"comp-lzo \r\n " ;
2098 print CLIENTCONF
"verb 3 \r\n " ;
2099 print CLIENTCONF
"ns-cert-type server \r\n " ;
2100 print CLIENTCONF
"tls-remote $vpnsettings {ROOTCERT_HOSTNAME} \r\n " ;
2101 if ( $vpnsettings { MSSFIX
} eq 'on' ) {
2102 print CLIENTCONF
"mssfix \r\n " ;
2104 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' ) {
2105 print CLIENTCONF
"fragment $vpnsettings {'FRAGMENT'} \r\n " ;
2108 # Check if a valid operating mode has been choosen and use it.
2109 if (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2110 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2111 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' )) {
2112 if (( $vpnsettings { MSSFIX
} ne 'on' ) || ( $vpnsettings { FRAGMENT
} eq '' )) {
2113 print CLIENTCONF
"mtu-disc $vpnsettings {'PMTU_DISCOVERY'} \r\n " ;
2118 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2119 my $status = $zip -> writeToFileNamed ( $zippathname );
2121 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2122 @fileholder = < DLFILE
>;
2123 print "Content-Type:application/x-download \n " ;
2124 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2132 ### Remove connection
2136 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
2137 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2138 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2140 if ( $confighash { $cgiparams { 'KEY' }}) {
2141 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2142 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2143 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2146 my $temp = `/usr/bin/openssl ca -revoke ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2152 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
2154 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
2155 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2156 unlink ( $certfile ) or die "Removing $certfile fail: $!" ;
2157 unlink ( $conffile ) or die "Removing $conffile fail: $!" ;
2158 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
2162 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
2163 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2165 # A.Marx CCD delete ccd files and routes
2168 if (- f
"${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" )
2170 unlink "${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" ;
2173 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2174 foreach my $key ( keys %ccdroutehash ) {
2175 if ( $ccdroutehash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2176 delete $ccdroutehash { $key };
2179 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2181 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2182 foreach my $key ( keys %ccdroute2hash ) {
2183 if ( $ccdroute2hash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2184 delete $ccdroute2hash { $key };
2187 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2194 delete $confighash { $cgiparams { 'KEY' }};
2195 my $temp2 = `/usr/bin/openssl ca -gencrl -out ${General::swroot}/ovpn/crls/cacrl.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2196 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2198 #&writeserverconf();
2200 $errormessage = $Lang :: tr
{ 'invalid key' };
2205 ### Download PKCS12 file
2207 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
2208 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2210 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
2211 print "Content-Type: application/octet-stream \r\n\r\n " ;
2212 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
2216 ### Display certificate
2218 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
2219 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2221 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2222 & Header
:: showhttpheaders
();
2223 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2224 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2225 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate'}:" );
2226 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2227 $output = & Header
:: cleanhtml
( $output , "y" );
2228 print "<pre> $output </pre> \n " ;
2229 & Header
:: closebox
();
2230 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2231 & Header
:: closebigbox
();
2232 & Header
:: closepage
();
2236 ### Display Certificate Revoke List
2238 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show crl' }) {
2239 # &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash);
2241 if ( - f
"${General::swroot}/ovpn/crls/cacrl.pem" ) {
2242 & Header
:: showhttpheaders
();
2243 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2244 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2245 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'crl'}:" );
2246 my $output = `/usr/bin/openssl crl -text -noout -in ${General::swroot}/ovpn/crls/cacrl.pem` ;
2247 $output = & Header
:: cleanhtml
( $output , "y" );
2248 print "<pre> $output </pre> \n " ;
2249 & Header
:: closebox
();
2250 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2251 & Header
:: closebigbox
();
2252 & Header
:: closepage
();
2257 ### Advanced Server Settings
2260 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced server' }) {
2265 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
2269 # if ($cgiparams{'CLIENT2CLIENT'} eq '') {
2270 # $cgiparams{'CLIENT2CLIENT'} = 'on';
2273 if ( $cgiparams { 'MAX_CLIENTS' } eq '' ) {
2274 $cgiparams { 'MAX_CLIENTS' } = '100' ;
2276 if ( $cgiparams { 'KEEPALIVE_1' } eq '' ) {
2277 $cgiparams { 'KEEPALIVE_1' } = '10' ;
2279 if ( $cgiparams { 'KEEPALIVE_2' } eq '' ) {
2280 $cgiparams { 'KEEPALIVE_2' } = '60' ;
2282 if ( $cgiparams { 'LOG_VERB' } eq '' ) {
2283 $cgiparams { 'LOG_VERB' } = '3' ;
2285 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
2286 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
2288 $checked { 'CLIENT2CLIENT' }{ 'off' } = '' ;
2289 $checked { 'CLIENT2CLIENT' }{ 'on' } = '' ;
2290 $checked { 'CLIENT2CLIENT' }{ $cgiparams { 'CLIENT2CLIENT' }} = 'CHECKED' ;
2291 $checked { 'REDIRECT_GW_DEF1' }{ 'off' } = '' ;
2292 $checked { 'REDIRECT_GW_DEF1' }{ 'on' } = '' ;
2293 $checked { 'REDIRECT_GW_DEF1' }{ $cgiparams { 'REDIRECT_GW_DEF1' }} = 'CHECKED' ;
2294 $selected { 'ENGINES' }{ $cgiparams { 'ENGINES' }} = 'SELECTED' ;
2295 $checked { 'MSSFIX' }{ 'off' } = '' ;
2296 $checked { 'MSSFIX' }{ 'on' } = '' ;
2297 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
2298 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
2299 $selected { 'LOG_VERB' }{ '1' } = '' ;
2300 $selected { 'LOG_VERB' }{ '2' } = '' ;
2301 $selected { 'LOG_VERB' }{ '3' } = '' ;
2302 $selected { 'LOG_VERB' }{ '4' } = '' ;
2303 $selected { 'LOG_VERB' }{ '5' } = '' ;
2304 $selected { 'LOG_VERB' }{ '6' } = '' ;
2305 $selected { 'LOG_VERB' }{ '7' } = '' ;
2306 $selected { 'LOG_VERB' }{ '8' } = '' ;
2307 $selected { 'LOG_VERB' }{ '9' } = '' ;
2308 $selected { 'LOG_VERB' }{ '10' } = '' ;
2309 $selected { 'LOG_VERB' }{ '11' } = '' ;
2310 $selected { 'LOG_VERB' }{ '0' } = '' ;
2311 $selected { 'LOG_VERB' }{ $cgiparams { 'LOG_VERB' }} = 'SELECTED' ;
2313 & Header
:: showhttpheaders
();
2314 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
2315 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
2316 if ( $errormessage ) {
2317 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2318 print "<class name='base'> $errormessage \n " ;
2319 print " </class> \n " ;
2320 & Header
:: closebox
();
2322 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'advanced server' });
2324 <form method='post' enctype='multipart/form-data'>
2325 <table width='100%' border=0>
2327 <td colspan='4'><b> $Lang ::tr{'dhcp-options'}</b></td>
2330 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2333 <td class='base'>Domain</td>
2334 <td><input type='TEXT' name='DHCP_DOMAIN' value=' $cgiparams {'DHCP_DOMAIN'}' size='30' /></td>
2337 <td class='base'>DNS</td>
2338 <td><input type='TEXT' name='DHCP_DNS' value=' $cgiparams {'DHCP_DNS'}' size='30' /></td>
2341 <td class='base'>WINS</td>
2342 <td><input type='TEXT' name='DHCP_WINS' value=' $cgiparams {'DHCP_WINS'}' size='30' /></td>
2345 <td colspan='4'><b> $Lang ::tr{'ovpn routes push options'}</b></td>
2348 <td class='base'> $Lang ::tr{'ovpn routes push'}</td>
2350 <textarea name='ROUTES_PUSH' cols='26' rows='6' wrap='off'>
2354 if ( $cgiparams { 'ROUTES_PUSH' } ne '' )
2356 print $cgiparams { 'ROUTES_PUSH' };
2365 <table width='100%'>
2367 <td class'base'><b> $Lang ::tr{'misc-options'}</b></td>
2370 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2373 <td class='base'>Client-To-Client</td>
2374 <td><input type='checkbox' name='CLIENT2CLIENT' $checked {'CLIENT2CLIENT'}{'on'} /></td>
2377 <td class='base'>Redirect-Gateway def1</td>
2378 <td><input type='checkbox' name='REDIRECT_GW_DEF1' $checked {'REDIRECT_GW_DEF1'}{'on'} /></td>
2381 <td class='base'>Max-Clients</td>
2382 <td><input type='text' name='MAX_CLIENTS' value=' $cgiparams {'MAX_CLIENTS'}' size='10' /></td>
2385 <td class='base'>Keepalive <br />
2386 (ping/ping-restart)</td>
2387 <td><input type='TEXT' name='KEEPALIVE_1' value=' $cgiparams {'KEEPALIVE_1'}' size='10' /></td>
2388 <td><input type='TEXT' name='KEEPALIVE_2' value=' $cgiparams {'KEEPALIVE_2'}' size='10' /></td>
2391 <td class='base'>fragment <br></td>
2392 <td><input type='TEXT' name='FRAGMENT' value=' $cgiparams {'FRAGMENT'}' size='10' /></td>
2393 <td>Default: <span class="base">1300</span></td>
2396 <td class='base'>mssfix</td>
2397 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
2398 <td>Default: on</td>
2402 <td class='base'> $Lang ::tr{'ovpn mtu-disc'}</td>
2403 <td><input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}</td>
2404 <td><input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}</td>
2405 <td><input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}</td>
2406 <td><input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}</td>
2412 <table width='100%'>
2414 <td class'base'><b>Crypto-Engines</b></td>
2417 <td width='15%'></td> <td width='30%'> </td><td width='25%'> </td><td width='30%'></td>
2419 <tr><td class='base'>Engines:</td>
2420 <td><select name='ENGINES'><option value="none" $selected {'ENGINES'}{'none'}>none</option>
2421 <option value="cryptodev" $selected {'ENGINES'}{'cryptodev'}>cryptodev</option>
2422 <option value="padlock" $selected {'ENGINES'}{'padlock'}>padlock</option>
2428 <table width='100%'>
2430 <td class'base'><b> $Lang ::tr{'log-options'}</b></td>
2433 <td width='15%'></td> <td width='30%'> </td><td width='25%'> </td><td width='30%'></td>
2436 <tr><td class='base'>VERB</td>
2437 <td><select name='LOG_VERB'><option value='1' $selected {'LOG_VERB'}{'1'}>1</option>
2438 <option value='2' $selected {'LOG_VERB'}{'2'}>2</option>
2439 <option value='3' $selected {'LOG_VERB'}{'3'}>3</option>
2440 <option value='4' $selected {'LOG_VERB'}{'4'}>4</option>
2441 <option value='5' $selected {'LOG_VERB'}{'5'}>5</option>
2442 <option value='6' $selected {'LOG_VERB'}{'6'}>6</option>
2443 <option value='7' $selected {'LOG_VERB'}{'7'}>7</option>
2444 <option value='8' $selected {'LOG_VERB'}{'8'}>8</option>
2445 <option value='9' $selected {'LOG_VERB'}{'9'}>9</option>
2446 <option value='10' $selected {'LOG_VERB'}{'10'}>10</option>
2447 <option value='11' $selected {'LOG_VERB'}{'11'}>11</option>
2448 <option value='0' $selected {'LOG_VERB'}{'0'}>0</option></select></td>
2452 if ( - e
"/var/run/openvpn.pid" ){
2453 print " <br><b><font color='#990000'> $Lang ::tr{'attention'}:</b></font><br>
2454 $Lang ::tr{'server restart'}<br><br>
2457 <table width='100%'>
2460 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' disabled='disabled' /></td>
2461 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2473 <table width='100%'>
2476 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' /></td>
2477 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2485 & Header
:: closebox
();
2486 # print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'>$Lang::tr{'back'}</a></div>";
2487 & Header
:: closebigbox
();
2488 & Header
:: closepage
();
2492 # A.Marx CCD Add,delete or edit CCD net
2494 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd net' } ||
2495 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' } ||
2496 $cgiparams { 'ACTION' } eq "kill" ||
2497 $cgiparams { 'ACTION' } eq "edit" ||
2498 $cgiparams { 'ACTION' } eq 'editsave' ){
2499 & Header
:: showhttpheaders
();
2500 & Header
:: openpage
( $Lang :: tr
{ 'ccd net' }, 1 , '' );
2501 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2503 if ( $cgiparams { 'ACTION' } eq "kill" ){
2504 & delccdnet
( $cgiparams { 'net' });
2507 if ( $cgiparams { 'ACTION' } eq 'editsave' ){
2508 my ( $a , $b ) = split ( /\|/ , $cgiparams { 'ccdname' });
2509 if ( $a ne $b ){ & modccdnet
( $a , $b );}
2510 $cgiparams { 'ccdname' }= '' ;
2511 $cgiparams { 'ccdsubnet' }= '' ;
2514 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' }) {
2515 & addccdnet
( $cgiparams { 'ccdname' }, $cgiparams { 'ccdsubnet' });
2517 if ( $errormessage ) {
2518 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2519 print "<class name='base'> $errormessage " ;
2520 print " </class>" ;
2521 & Header
:: closebox
();
2523 if ( $cgiparams { 'ACTION' } eq "edit" ){
2525 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd modify' });
2528 <table width='100%' border=0>
2529 <tr><form method='post'>
2530 <td width='10%' nowrap='nowrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2531 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' readonly /></td></tr>
2532 <tr><td colspan='4' align='right'><hr><input type='submit' value=' $Lang ::tr{'save'}' /><input type='hidden' name='ACTION' value='editsave'/>
2533 <input type='hidden' name='ccdname' value=' $cgiparams {'ccdname'}'/><input type='submit' value=' $Lang ::tr{'cancel'}' />
2538 & Header
:: closebox
();
2540 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2542 <table width='100%' border='0' cellpadding='0' cellspacing='1'>
2544 <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>
2549 if (! - e
"/var/run/openvpn.pid" ){
2550 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd add' });
2552 <table width='100%' border='0'>
2553 <tr><form method='post'>
2554 <td colspan='4'> $Lang ::tr{'ccd hint'}<br><br></td></tr>
2556 <td width='10%' nowrap='nwrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2557 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' /></td></tr>
2558 <tr><td colspan=4><hr /></td></tr><tr>
2559 <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>
2563 & Header
:: closebox
();
2565 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2566 if ( - e
"/var/run/openvpn.pid" ){
2567 print "<b> $Lang ::tr{'attention'}:</b><br>" ;
2568 print " $Lang ::tr{'ccd noaddnet'}<br><hr>" ;
2572 <table width='100%' border='0' cellpadding='0' cellspacing='1'>
2574 <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>
2579 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
2582 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
2583 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
2585 my $ccdhosts = & hostsinnet
( $ccdconf [ 0 ]);
2586 if ( $count % 2 ){ print " <tr bgcolor=' $color {'color22'}'>" ;}
2587 else { print " <tr bgcolor=' $color {'color20'}'>" ;}
2588 print "<td> $ccdconf [0]</td><td align='center'> $ccdconf [1]</td><td align='center'> $ccdhosts /" .(& ccdmaxclients
( $ccdconf [ 1 ])+ 1 ). "</td><td>" ;
2590 <form method='post' />
2591 <input type='image' src='/images/edit.gif' align='middle' alt= $Lang ::tr{'edit'} title= $Lang ::tr{'edit'} />
2592 <input type='hidden' name='ACTION' value='edit'/>
2593 <input type='hidden' name='ccdname' value=' $ccdconf [0]' />
2594 <input type='hidden' name='ccdsubnet' value=' $ccdconf [1]' />
2596 <form method='post' />
2597 <td><input type='hidden' name='ACTION' value='kill'/>
2598 <input type='hidden' name='number' value=' $count ' />
2599 <input type='hidden' name='net' value=' $ccdconf [0]' />
2600 <input type='image' src='/images/delete.gif' align='middle' alt= $Lang ::tr{'remove'} title= $Lang ::tr{'remove'} /></form></td></tr>
2604 print "</table></form>" ;
2605 & Header
:: closebox
();
2606 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2607 & Header
:: closebigbox
();
2608 & Header
:: closepage
();
2614 ### Openvpn Connections Statistics
2616 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ovpn con stat' }) {
2617 & Header
:: showhttpheaders
();
2618 & Header
:: openpage
( $Lang :: tr
{ 'ovpn con stat' }, 1 , '' );
2619 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2620 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ovpn con stat' });
2623 # <td><b>$Lang::tr{'protocol'}</b></td>
2624 # protocol temp removed
2626 <table width='100%' border='0' cellpadding='2' cellspacing='0'>
2628 <td><b> $Lang ::tr{'common name'}</b></td>
2629 <td><b> $Lang ::tr{'real address'}</b></td>
2630 <td><b> $Lang ::tr{'virtual address'}</b></td>
2631 <td><b> $Lang ::tr{'loged in at'}</b></td>
2632 <td><b> $Lang ::tr{'bytes sent'}</b></td>
2633 <td><b> $Lang ::tr{'bytes received'}</b></td>
2634 <td><b> $Lang ::tr{'last activity'}</b></td>
2638 my $filename = "/var/log/ovpnserver.log" ;
2639 open ( FILE
, $filename ) or die 'Unable to open config file.' ;
2640 my @current = < FILE
>;
2649 my %userlookup = ();
2650 foreach my $line ( @current )
2653 if ( $line =~ /^Updated,(.+)/ ){
2654 @match = split ( /^Updated,(.+)/ , $line );
2655 $status = $match [ 1 ];
2658 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
2659 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
2660 if ( $match [ 1 ] ne "Common Name" ) {
2662 $userlookup { $match [ 2 ]} = $uid ;
2663 $users [ $uid ]{ 'CommonName' } = $match [ 1 ];
2664 $users [ $uid ]{ 'RealAddress' } = $match [ 2 ];
2665 $users [ $uid ]{ 'BytesReceived' } = & sizeformat
( $match [ 3 ]);
2666 $users [ $uid ]{ 'BytesSent' } = & sizeformat
( $match [ 4 ]);
2667 $users [ $uid ]{ 'Since' } = $match [ 5 ];
2668 $users [ $uid ]{ 'Proto' } = $proto ;
2672 if ( $line =~ /^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ ) {
2673 @match = split ( m/^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ , $line );
2674 if ( $match [ 1 ] ne "Virtual Address" ) {
2675 $address = $match [ 3 ];
2676 #find the uid in the lookup table
2677 $uid = $userlookup { $address };
2678 $users [ $uid ]{ 'VirtualAddress' } = $match [ 1 ];
2679 $users [ $uid ]{ 'LastRef' } = $match [ 4 ];
2685 for ( my $idx = 1 ; $idx <= $user2 ; $idx ++){
2687 print "<tr bgcolor=' $color {'color20'}'> \n " ;
2689 print "<tr bgcolor=' $color {'color22'}'> \n " ;
2691 print "<td align='left'> $users [ $idx -1]{'CommonName'}</td>" ;
2692 print "<td align='left'> $users [ $idx -1]{'RealAddress'}</td>" ;
2693 print "<td align='left'> $users [ $idx -1]{'VirtualAddress'}</td>" ;
2694 print "<td align='left'> $users [ $idx -1]{'Since'}</td>" ;
2695 print "<td align='left'> $users [ $idx -1]{'BytesSent'}</td>" ;
2696 print "<td align='left'> $users [ $idx -1]{'BytesReceived'}</td>" ;
2697 print "<td align='left'> $users [ $idx -1]{'LastRef'}</td>" ;
2698 # print "<td align='left'>$users[$idx-1]{'Proto'}</td>";
2704 <table width='100%' border='0' cellpadding='2' cellspacing='0'>
2709 <tr><td align='center' > $Lang ::tr{'the statistics were last updated at'} <b> $status </b></td></tr>
2713 & Header
:: closebox
();
2714 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2715 & Header
:: closebigbox
();
2716 & Header
:: closepage
();
2720 ### Download Certificate
2722 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
2723 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2725 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2726 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \r\n " ;
2727 print "Content-Type: application/octet-stream \r\n\r\n " ;
2728 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2733 ### Enable/Disable connection
2736 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
2738 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2739 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2741 if ( $confighash { $cgiparams { 'KEY' }}) {
2742 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
2743 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
2744 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2745 #&writeserverconf();
2746 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2747 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2748 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
2751 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
2752 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2753 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2754 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2756 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2757 #&writeserverconf();
2760 $errormessage = $Lang :: tr
{ 'invalid key' };
2764 ### Restart connection
2766 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
2767 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2768 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2770 if ( $confighash { $cgiparams { 'KEY' }}) {
2771 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2772 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2773 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
2776 $errormessage = $Lang :: tr
{ 'invalid key' };
2780 ### Remove connection
2782 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
2783 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2784 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2786 if ( $confighash { $cgiparams { 'KEY' }}) {
2787 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2788 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2789 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2791 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
2792 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2793 delete $confighash { $cgiparams { 'KEY' }};
2794 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2795 #&writeserverconf();
2797 $errormessage = $Lang :: tr
{ 'invalid key' };
2802 ### Choose between adding a host-net or net-net connection
2809 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
2810 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2811 & Header
:: showhttpheaders
();
2812 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2813 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2814 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection type' });
2816 if ( - s
"${General::swroot}/ovpn/settings" ) {
2819 <b> $Lang ::tr{'connection type'}:</b><br />
2820 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
2821 <tr><td><input type='radio' name='TYPE' value='host' checked /></td>
2822 <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
2823 <tr><td><input type='radio' name='TYPE' value='net' /></td>
2824 <td class='base'> $Lang ::tr{'net to net vpn'}</td></tr>
2825 <tr><td><input type='radio' name='TYPE' value='net2net' /></td>
2826 <td class='base'> $Lang ::tr{'net to net vpn'} (Upload Client Package)</td></tr>
2827 <tr><td> </td><td class='base'><input type='file' name='FH' size='30'></td></tr>
2828 <tr><td> </td><td>Import Connection Name <img src='/blob.gif' /></td></tr>
2829 <tr><td> </td><td class='base'><input type='text' name='n2nname' size='30'>Default : Client Packagename</td></tr>
2830 <tr><td colspan='3'><hr /></td></tr>
2831 <tr><td align='right' colspan='3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
2832 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
2840 <b> $Lang ::tr{'connection type'}:</b><br />
2841 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
2842 <tr><td><input type='radio' name='TYPE' value='host' checked /></td> <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
2843 <tr><td align='right' colspan'3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
2850 & Header
:: closebox
();
2851 & Header
:: closebigbox
();
2852 & Header
:: closepage
();
2859 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2net' )){
2863 my $uplconffilename = '' ;
2864 my $uplconffilename2 = '' ;
2865 my $uplp12name = '' ;
2866 my $uplp12name2 = '' ;
2873 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2875 # Check if a file is uploaded
2877 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
2878 $errormessage = $Lang :: tr
{ 'there was no file upload' };
2882 # Move uploaded IPfire n2n package to temporary file
2884 ( my $fh , my $filename ) = tempfile
( );
2885 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
2890 my $zip = Archive
:: Zip
-> new ();
2891 my $zipName = $filename ;
2892 my $status = $zip -> read ( $zipName );
2893 if ( $status != AZ_OK
) {
2894 $errormessage = "Read of $zipName failed \n " ;
2898 my $tempdir = tempdir
( CLEANUP
=> 1 );
2899 my @files = $zip -> memberNames ();
2901 $zip -> extractMemberWithoutPaths ( $_ , " $tempdir / $_ " );
2903 my $countfiles = @files ;
2905 # Check if we have not more then 2 files
2907 if ( $countfiles == 2 ){
2909 if ( $_ =~ /.conf$/ ){
2910 $uplconffilename = $_ ;
2912 if ( $_ =~ /.p12$/ ){
2916 if (( $uplconffilename eq '' ) || ( $uplp12name eq '' )){
2917 $errormessage = "Either no *.conf or no *.p12 file found \n " ;
2921 open ( FILE
, " $tempdir / $uplconffilename " ) or die 'Unable to open*.conf file' ;
2922 @firen2nconf = < FILE
>;
2924 chomp ( @firen2nconf );
2928 $errormessage = "Filecount does not match only 2 files are allowed \n " ;
2936 if ( $cgiparams { 'n2nname' } ne '' ){
2938 $uplconffilename2 = " $cgiparams {'n2nname'}.conf" ;
2939 $uplp12name2 = " $cgiparams {'n2nname'}.p12" ;
2940 $n2nname [ 0 ] = $cgiparams { 'n2nname' };
2941 my @n2nname2 = split ( /\./ , $uplconffilename );
2942 $n2nname2 [ 0 ] =~ s/\n|\r//g ;
2943 my $input1 = "${General::swroot}/ovpn/certs/ $uplp12name " ;
2944 my $output1 = "${General::swroot}/ovpn/certs/ $uplp12name2 " ;
2945 my $input2 = " $n2nname2 [0]n2n" ;
2946 my $output2 = " $n2nname [0]n2n" ;
2947 my $filename = " $tempdir / $uplconffilename " ;
2948 open ( FILE
, "< $filename " ) or die 'Unable to open config file.' ;
2949 my @current = < FILE
>;
2951 foreach ( @current ) { s/$input1/$output1/g ;}
2952 foreach ( @current ) { s/$input2/$output2/g ;}
2953 open ( OUT
, "> $filename " ) || die 'Unable to open config file.' ;
2958 $uplconffilename2 = $uplconffilename ;
2959 $uplp12name2 = $uplp12name ;
2960 @n2nname = split ( /\./ , $uplconffilename );
2961 $n2nname [ 0 ] =~ s/\n|\r//g ;
2963 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
2964 unless (- d
"${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" , 0770 or die "Unable to create dir $!" ;}
2966 move
( " $tempdir / $uplconffilename " , "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $uplconffilename2 " );
2969 $errormessage = "*.conf move failed: $!" ;
2974 move
( " $tempdir / $uplp12name " , "${General::swroot}/ovpn/certs/ $uplp12name2 " );
2975 chmod 0600 , "${General::swroot}/ovpn/certs/ $uplp12name " ;
2978 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
2986 my @n2nmtudisc = split ( / / , ( grep { /^mtu-disc/ } @firen2nconf )[ 0 ]);;
2987 my @n2nproto2 = split ( / / , ( grep { /^proto/ } @firen2nconf )[ 0 ]);
2988 my @n2nproto = split ( /-/ , $n2nproto2 [ 1 ]);
2989 my @n2nport = split ( / / , ( grep { /^port/ } @firen2nconf )[ 0 ]);
2990 my @n2ntunmtu = split ( / / , ( grep { /^tun-mtu/ } @firen2nconf )[ 0 ]);
2991 my @n2ncomplzo = grep { /^comp-lzo/ } @firen2nconf ;
2992 if ( $n2ncomplzo [ 0 ] =~ /comp-lzo/ ){ $complzoactive = "on" ;} else { $complzoactive = "off" ;}
2993 my @n2nmssfix = grep { /^mssfix/ } @firen2nconf ;
2994 if ( $n2nmssfix [ 0 ] =~ /mssfix/ ){ $mssfixactive = "on" ;} else { $mssfixactive = "off" ;}
2995 #my @n2nmssfix = split(/ /, (grep { /^mssfix/ } @firen2nconf)[0]);
2996 my @n2nfragment = split ( / / , ( grep { /^fragment/ } @firen2nconf )[ 0 ]);
2997 my @n2nremote = split ( / / , ( grep { /^remote/ } @firen2nconf )[ 0 ]);
2998 my @n2novpnsuball = split ( / / , ( grep { /^ifconfig/ } @firen2nconf )[ 0 ]);
2999 my @n2novpnsub = split ( /\./ , $n2novpnsuball [ 1 ]);
3000 my @n2nremsub = split ( / / , ( grep { /^route/ } @firen2nconf )[ 0 ]);
3001 my @n2nmgmt = split ( / / , ( grep { /^management/ } @firen2nconf )[ 0 ]);
3002 my @n2nlocalsub = split ( / / , ( grep { /^# remsub/ } @firen2nconf )[ 0 ]);
3006 # m.a.d delete CR and LF from arrays for this chomp doesnt work
3009 $n2nremote [ 1 ] =~ s/\n|\r//g ;
3010 $n2novpnsub [ 0 ] =~ s/\n|\r//g ;
3011 $n2novpnsub [ 1 ] =~ s/\n|\r//g ;
3012 $n2novpnsub [ 2 ] =~ s/\n|\r//g ;
3013 $n2nproto [ 0 ] =~ s/\n|\r//g ;
3014 $n2nport [ 1 ] =~ s/\n|\r//g ;
3015 $n2ntunmtu [ 1 ] =~ s/\n|\r//g ;
3016 $n2nremsub [ 1 ] =~ s/\n|\r//g ;
3017 $n2nremsub [ 2 ] =~ s/\n|\r//g ;
3018 $n2nlocalsub [ 2 ] =~ s/\n|\r//g ;
3019 $n2nfragment [ 1 ] =~ s/\n|\r//g ;
3020 $n2nmgmt [ 2 ] =~ s/\n|\r//g ;
3021 $n2nmtudisc [ 1 ] =~ s/\n|\r//g ;
3022 chomp ( $complzoactive );
3023 chomp ( $mssfixactive );
3030 # Check if there is no other entry with this name
3033 foreach my $dkey ( keys %confighash ) {
3034 if ( $confighash { $dkey }[ 1 ] eq $n2nname [ 0 ]) {
3035 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3036 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3037 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3038 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3044 # Check if OpenVPN Subnet is valid
3047 foreach my $dkey ( keys %confighash ) {
3048 if ( $confighash { $dkey }[ 27 ] eq " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ) {
3049 $errormessage = 'The OpenVPN Subnet is already in use' ;
3050 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3051 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3052 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3058 # Check im Dest Port is vaild
3061 foreach my $dkey ( keys %confighash ) {
3062 if ( $confighash { $dkey }[ 29 ] eq $n2nport [ 1 ] ) {
3063 $errormessage = 'The OpenVPN Port is already in use' ;
3064 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3065 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3066 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3073 $key = & General
:: findhasharraykey
( \
%confighash );
3075 foreach my $i ( 0 .. 39 ) { $confighash { $key }[ $i ] = "" ;}
3077 $confighash { $key }[ 0 ] = 'off' ;
3078 $confighash { $key }[ 1 ] = $n2nname [ 0 ];
3079 $confighash { $key }[ 2 ] = $n2nname [ 0 ];
3080 $confighash { $key }[ 3 ] = 'net' ;
3081 $confighash { $key }[ 4 ] = 'cert' ;
3082 $confighash { $key }[ 6 ] = 'client' ;
3083 $confighash { $key }[ 8 ] = $n2nlocalsub [ 2 ];
3084 $confighash { $key }[ 10 ] = $n2nremote [ 1 ];
3085 $confighash { $key }[ 11 ] = " $n2nremsub [1]/ $n2nremsub [2]" ;
3086 $confighash { $key }[ 22 ] = $n2nmgmt [ 2 ];
3087 $confighash { $key }[ 23 ] = $mssfixactive ;
3088 $confighash { $key }[ 24 ] = $n2nfragment [ 1 ];
3089 $confighash { $key }[ 25 ] = 'IPFire n2n Client' ;
3090 $confighash { $key }[ 26 ] = 'red' ;
3091 $confighash { $key }[ 27 ] = " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ;
3092 $confighash { $key }[ 28 ] = $n2nproto [ 0 ];
3093 $confighash { $key }[ 29 ] = $n2nport [ 1 ];
3094 $confighash { $key }[ 30 ] = $complzoactive ;
3095 $confighash { $key }[ 31 ] = $n2ntunmtu [ 1 ];
3096 $confighash { $key }[ 38 ] = $n2nmtudisc [ 1 ];
3099 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3103 & Header
:: showhttpheaders
();
3104 & Header
:: openpage
( 'Validate imported configuration' , 1 , '' );
3105 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
3106 if ( $errormessage ) {
3107 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
3108 print "<class name='base'> $errormessage " ;
3109 print " </class>" ;
3110 & Header
:: closebox
();
3114 & Header
:: openbox
( '100%' , 'LEFT' , 'import ipfire net2net config' );
3116 if ( $errormessage eq '' ){
3118 <!-- ipfire net2net config gui -->
3119 <table width='100%'>
3120 <tr><td width='25%'> </td><td width='25%'> </td></tr>
3121 <tr><td class='boldbase'> $Lang ::tr{'name'}:</td><td><b> $n2nname [0]</b></td></tr>
3122 <tr><td> </td><td> </td></tr>
3123 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td><td><b> $confighash { $key }[6]</b></td></tr>
3124 <tr><td class='boldbase' nowrap='nowrap'>Remote Host </td><td><b> $confighash { $key }[10]</b></td></tr>
3125 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td><td><b> $confighash { $key }[8]</b></td></tr>
3126 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td><td><b> $confighash { $key }[11]</b></td></tr>
3127 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td><td><b> $confighash { $key }[27]</b></td></tr>
3128 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td><td><b> $confighash { $key }[28]</b></td></tr>
3129 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'destination port'}:</td><td><b> $confighash { $key }[29]</b></td></tr>
3130 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td><td><b> $confighash { $key }[30]</b></td></tr>
3131 <tr><td class='boldbase' nowrap='nowrap'>MSSFIX </td><td><b> $confighash { $key }[23]</b></td></tr>
3132 <tr><td class='boldbase' nowrap='nowrap'>Fragment </td><td><b> $confighash { $key }[24]</b></td></tr>
3133 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'}</td><td><b> $confighash { $key }[31]</b></td></tr>
3134 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td><td><b> $confighash { $key }[38]</b></td></tr>
3135 <tr><td class='boldbase' nowrap='nowrap'>Management Port </td><td><b> $confighash { $key }[22]</b></td></tr>
3136 <tr><td> </td><td> </td></tr>
3140 & Header
:: closebox
();
3143 if ( $errormessage ) {
3144 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3146 print "<div align='center'><form method='post' ENCTYPE='multipart/form-data'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />" ;
3147 print "<input type='hidden' name='TYPE' value='net2netakn' />" ;
3148 print "<input type='hidden' name='KEY' value=' $key ' />" ;
3149 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
3151 & Header
:: closebigbox
();
3152 & Header
:: closepage
();
3157 ### Accept IPFire n2n Package Settings
3160 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3163 ### Discard and Rollback IPFire n2n Package Settings
3166 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'cancel' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3168 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3170 if ( $confighash { $cgiparams { 'KEY' }}) {
3172 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
3173 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
3174 unlink ( $certfile ) or die "Removing $certfile fail: $!" ;
3175 unlink ( $conffile ) or die "Removing $conffile fail: $!" ;
3176 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
3177 delete $confighash { $cgiparams { 'KEY' }};
3178 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3181 $errormessage = $Lang :: tr
{ 'invalid key' };
3191 ### Adding a new connection
3193 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
3194 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
3195 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
3197 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3198 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
3199 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3201 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
3202 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
3203 $errormessage = $Lang :: tr
{ 'invalid key' };
3206 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
3207 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
3208 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
3209 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
3210 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
3211 $cgiparams { 'SIDE' } = $confighash { $cgiparams { 'KEY' }}[ 6 ];
3212 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
3213 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
3214 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
3215 $cgiparams { 'OVPN_MGMT' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
3216 $cgiparams { 'MSSFIX' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
3217 $cgiparams { 'FRAGMENT' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
3218 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
3219 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
3220 $cgiparams { 'OVPN_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
3221 $cgiparams { 'PROTOCOL' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
3222 $cgiparams { 'DEST_PORT' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
3223 $cgiparams { 'COMPLZO' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
3224 $cgiparams { 'MTU' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
3225 $cgiparams { 'CHECK1' } = $confighash { $cgiparams { 'KEY' }}[ 32 ];
3226 $name = $cgiparams { 'CHECK1' } ;
3227 $cgiparams { $name } = $confighash { $cgiparams { 'KEY' }}[ 33 ];
3228 $cgiparams { 'RG' } = $confighash { $cgiparams { 'KEY' }}[ 34 ];
3229 $cgiparams { 'CCD_DNS1' } = $confighash { $cgiparams { 'KEY' }}[ 35 ];
3230 $cgiparams { 'CCD_DNS2' } = $confighash { $cgiparams { 'KEY' }}[ 36 ];
3231 $cgiparams { 'CCD_WINS' } = $confighash { $cgiparams { 'KEY' }}[ 37 ];
3232 $cgiparams { 'PMTU_DISCOVERY' } = $confighash { $cgiparams { 'KEY' }}[ 38 ];
3233 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
3234 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
3236 #A.Marx CCD check iroute field and convert it to decimal
3237 if ( $cgiparams { 'TYPE' } eq 'host' ) {
3239 my %ccdroutehash =();
3243 if ( $cgiparams { 'IR' } ne '' ){
3244 @temp = split ( " \n " , $cgiparams { 'IR' });
3245 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3247 foreach my $key ( keys %ccdroutehash ) {
3248 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3250 delete $ccdroutehash { $key };
3252 $keypoint = & General
:: findhasharraykey
( \
%ccdroutehash );
3255 $ccdroutehash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3258 foreach $val ( @temp ){
3261 #check if iroute exists in ccdroute or if new iroute is part of an existing one
3262 foreach my $key ( keys %ccdroutehash ) {
3263 foreach my $oldiroute ( 1 .. $ #{$ccdroutehash{$key}}){
3264 if ( $ccdroutehash { $key }[ $oldiroute ] eq " $val " ) {
3265 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3268 my ( $ip1 , $cidr1 ) = split ( /\/ /, $val );
3269 $ip1 = & General
:: getnetworkip
( $ip1 ,& General
:: iporsubtocidr
( $cidr1 ));
3270 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $oldiroute ]);
3271 if (& General
:: IpInSubnet
( $ip1 , $ip2 , $cidr2 )){
3272 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3278 if (!& General
:: validipandmask
( $val )){
3279 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3282 ( $ip , $cidr ) = split ( /\/ /, $val );
3283 $ip =& General
:: getnetworkip
( $ip ,& General
:: iporsubtocidr
( $cidr ));
3284 $cidr =& General
:: iporsubtodec
( $cidr );
3285 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3289 #check for existing network IP's
3290 if (& General
:: IpInSubnet
( $ip , $netsettings { GREEN_NETADDRESS
}, $netsettings { GREEN_NETMASK
}) && $netsettings { GREEN_NETADDRESS
} ne '0.0.0.0' )
3292 $errormessage = $Lang :: tr
{ 'ccd err green' };
3294 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { RED_NETADDRESS
}, $netsettings { RED_NETMASK
}) && $netsettings { RED_NETADDRESS
} ne '0.0.0.0' )
3296 $errormessage = $Lang :: tr
{ 'ccd err red' };
3298 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { BLUE_NETADDRESS
}, $netsettings { BLUE_NETMASK
}) && $netsettings { BLUE_NETADDRESS
} ne '0.0.0.0' && $netsettings { BLUE_NETADDRESS
} gt '' )
3300 $errormessage = $Lang :: tr
{ 'ccd err blue' };
3302 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { ORANGE_NETADDRESS
}, $netsettings { ORANGE_NETMASK
}) && $netsettings { ORANGE_NETADDRESS
} ne '0.0.0.0' && $netsettings { ORANGE_NETADDRESS
} gt '' )
3304 $errormessage = $Lang :: tr
{ 'ccd err orange' };
3308 if (& General
:: validipandmask
( $val )){
3309 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3311 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $ip / $cidr )" ;
3316 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3319 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3320 foreach my $key ( keys %ccdroutehash ) {
3321 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3322 delete $ccdroutehash { $key };
3323 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3329 #check route field and convert it to decimal
3332 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3334 foreach my $key ( keys %ccdroute2hash ) {
3335 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3337 delete $ccdroute2hash { $key };
3339 $keypoint = & General
:: findhasharraykey
( \
%ccdroute2hash );
3340 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3344 $ccdroute2hash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3345 if ( $cgiparams { 'IFROUTE' } eq '' ){ $cgiparams { 'IFROUTE' } = $Lang :: tr
{ 'ccd none' };}
3346 @temp = split ( /\|/ , $cgiparams { 'IFROUTE' });
3348 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%ownnet );
3349 foreach $val ( @temp ){
3352 if ( $val eq $Lang :: tr
{ 'green' })
3354 $val = $ownnet { GREEN_NETADDRESS
}. "/" . $ownnet { GREEN_NETMASK
};
3356 if ( $val eq $Lang :: tr
{ 'blue' })
3358 $val = $ownnet { BLUE_NETADDRESS
}. "/" . $ownnet { BLUE_NETMASK
};
3360 if ( $val eq $Lang :: tr
{ 'orange' })
3362 $val = $ownnet { ORANGE_NETADDRESS
}. "/" . $ownnet { ORANGE_NETMASK
};
3364 my ( $ip , $cidr ) = split ( /\/ /, $val );
3366 if ( $val ne $Lang :: tr
{ 'ccd none' })
3368 if (! & check_routes_push
( $val )){ $errormessage = $errormessage . "Route $val " . $Lang :: tr
{ 'ccd err routeovpn2' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3369 if (! & check_ccdroute
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err inuse' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3370 if (! & check_ccdconf
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err routeovpn' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3371 if (& General
:: validipandmask
( $val )){
3372 $val = $ip . "/" .& General
:: iporsubtodec
( $cidr );
3373 $ccdroute2hash { $keypoint }[ $i ] = $val ;
3375 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3379 $ccdroute2hash { $keypoint }[ $i ]= '' ;
3383 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3386 if ( $cgiparams { 'CCD_DNS1' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS1' })) {
3387 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 1" ;
3391 if ( $cgiparams { 'CCD_DNS2' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS2' })) {
3392 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 2" ;
3396 if ( $cgiparams { 'CCD_WINS' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_WINS' })) {
3397 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp wins' };
3405 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
3406 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
3407 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3408 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3409 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3415 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
3416 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
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 ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
3425 $errormessage = $Lang :: tr
{ 'name is invalid' };
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: $!" ;
3433 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
3434 $errormessage = $Lang :: tr
{ 'name too long' };
3435 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3436 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3437 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3446 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3447 if ( $cgiparams { 'DEST_PORT' } eq $vpnsettings { 'DDEST_PORT' }) {
3448 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3449 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3450 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3454 foreach my $key ( sort keys %confighash ){
3455 if ( ( $confighash { $key }[ 22 ] eq $cgiparams { 'DEST_PORT' } && $cgiparams { 'NAME' } ne $confighash { $key }[ 1 ]) || ( $confighash { $key }[ 29 ] eq $cgiparams { 'DEST_PORT' } && $cgiparams { 'NAME' } ne $confighash { $key }[ 1 ])){
3456 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3457 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3458 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3462 if ( $cgiparams { 'DEST_PORT' } eq '' ) {
3463 $errormessage = $Lang :: tr
{ 'invalid port' };
3464 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3465 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3469 # Check if the input for the transfer net is valid.
3470 if (!& General
:: validipandmask
( $cgiparams { 'OVPN_SUBNET' })){
3471 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
3472 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3473 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3477 if ( $cgiparams { 'OVPN_SUBNET' } eq $vpnsettings { 'DOVPN_SUBNET' }) {
3478 $errormessage = $Lang :: tr
{ 'openvpn subnet is used' };
3479 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3480 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3484 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3485 $errormessage = $Lang :: tr
{ 'openvpn mssfix allowed with udp' };
3486 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3487 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3491 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'FRAGMENT' } ne '' )) {
3492 $errormessage = $Lang :: tr
{ 'openvpn fragment allowed with udp' };
3493 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3494 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3498 if ( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) {
3499 if (( $cgiparams { 'FRAGMENT' } ne '' ) || ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3500 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
3501 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3502 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3507 if (( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) && ( $cgiparams { 'MTU' } ne '1500' )) {
3508 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc and mtu not 1500' };
3509 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3510 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3514 if ( & validdotmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3515 $errormessage = $Lang :: tr
{ 'openvpn prefix local subnet' };
3516 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3517 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3521 if ( & validdotmask
( $cgiparams { 'OVPN_SUBNET' })) {
3522 $errormessage = $Lang :: tr
{ 'openvpn prefix openvpn subnet' };
3523 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3524 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3528 if ( & validdotmask
( $cgiparams { 'REMOTE_SUBNET' })) {
3529 $errormessage = $Lang :: tr
{ 'openvpn prefix remote subnet' };
3530 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3531 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3535 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
3536 $cgiparams { 'OVPN_MGMT' } = $cgiparams { 'DEST_PORT' };
3541 # if (($cgiparams{'TYPE'} eq 'net') && ($cgiparams{'SIDE'} !~ /^(left|right)$/)) {
3542 # $errormessage = $Lang::tr{'ipfire side is invalid'};
3543 # goto VPNCONF_ERROR;
3546 # Check if there is no other entry with this name
3547 if (! $cgiparams { 'KEY' }) {
3548 foreach my $key ( keys %confighash ) {
3549 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
3550 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3551 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3552 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3553 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3560 # Check if a remote host/IP has been set for the client.
3561 if ( $cgiparams { 'REMOTE' } eq '' && $cgiparams { 'SIDE' } ne 'server' ) {
3562 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3564 # Check if this is a N2N connection and drop temporary config.
3565 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3566 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3567 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3572 # Check if a remote host/IP has been configured - the field can be empty on the server side.
3573 if ( $cgiparams { 'REMOTE' } ne '' ) {
3575 # Check if the given IP is valid - otherwise check if it is a valid domain.
3576 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
3578 # Check for a valid domain.
3579 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
3580 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3582 # Check if this is a N2N connection and drop temporary config.
3583 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3584 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3585 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3592 if ( $cgiparams { 'TYPE' } ne 'host' ) {
3593 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3594 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
3595 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3596 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3597 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3599 goto VPNCONF_ERROR
;}
3601 # Check if there is no other entry without IP-address and PSK
3602 if ( $cgiparams { 'REMOTE' } eq '' ) {
3603 foreach my $key ( keys %confighash ) {
3604 if (( $cgiparams { 'KEY' } ne $key ) &&
3605 ( $confighash { $key }[ 4 ] eq 'psk' || $cgiparams { 'AUTH' } eq 'psk' ) &&
3606 $confighash { $key }[ 10 ] eq '' ) {
3607 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
3612 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
3613 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
3614 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3615 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3619 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
3620 $errormessage = $Lang :: tr
{ 'invalid input' };
3623 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
3624 $errormessage = $Lang :: tr
{ 'invalid input' };
3629 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
3630 # if (! length($cgiparams{'PSK'}) ) {
3631 # $errormessage = $Lang::tr{'pre-shared key is too short'};
3632 # goto VPNCONF_ERROR;
3634 # if ($cgiparams{'PSK'} =~ /['",&]/) {
3635 # $errormessage = $Lang::tr{'invalid characters found in pre-shared key'};
3636 # goto VPNCONF_ERROR;
3638 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
3639 if ( $cgiparams { 'KEY' }) {
3640 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3643 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3644 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3648 # Move uploaded certificate request to a temporary file
3649 ( my $fh , my $filename ) = tempfile
( );
3650 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3655 # Sign the certificate request and move it
3656 # Sign the host certificate request
3657 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
3658 '-batch' , '-notext' ,
3660 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
3661 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
3663 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3665 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3666 & newcleanssldatabase
();
3670 & deletebackupcert
();
3673 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
3674 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
3676 $temp =~ s
+/ Email
+, E
+;
3677 $temp =~ s/ ST=/ S=/ ;
3678 $cgiparams { 'CERT_NAME' } = $temp ;
3679 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
3680 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
3681 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
3682 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
3685 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
3686 if ( $cgiparams { 'KEY' }) {
3687 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3690 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3691 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3694 # Move uploaded certificate to a temporary file
3695 ( my $fh , my $filename ) = tempfile
( );
3696 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3701 # Verify the certificate has a valid CA and move it
3703 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/cacert.pem $filename ` ;
3704 if ( $test =~ /: OK/ ) {
3707 foreach my $key ( keys %cahash ) {
3708 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $key }[0]cert.pem $filename ` ;
3709 if ( $test =~ /: OK/ ) {
3715 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
3719 move
( $filename , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3721 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
3727 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
3728 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
3730 $temp =~ s
+/ Email
+, E
+;
3731 $temp =~ s/ ST=/ S=/ ;
3732 $cgiparams { 'CERT_NAME' } = $temp ;
3733 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
3734 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
3735 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
3736 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3737 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
3740 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
3741 if ( $cgiparams { 'KEY' }) {
3742 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3745 # Validate input since the form was submitted
3746 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
3747 $errormessage = $Lang :: tr
{ 'name too long' };
3750 if ( $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
3751 $errormessage = $Lang :: tr
{ 'invalid input for name' };
3754 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
3755 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
3758 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
3759 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
3762 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
3763 $errormessage = $Lang :: tr
{ 'invalid input for department' };
3766 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
3767 $errormessage = $Lang :: tr
{ 'organization too long' };
3770 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
3771 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
3774 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
3775 $errormessage = $Lang :: tr
{ 'invalid input for city' };
3778 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
3779 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
3782 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
3783 $errormessage = $Lang :: tr
{ 'invalid input for country' };
3786 if ( $cgiparams { 'CERT_PASS1' } ne '' && $cgiparams { 'CERT_PASS2' } ne '' ){
3787 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
3788 $errormessage = $Lang :: tr
{ 'password too short' };
3792 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
3793 $errormessage = $Lang :: tr
{ 'passwords do not match' };
3797 # Replace empty strings with a .
3798 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
3799 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
3800 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
3802 # Create the Host certificate request client
3803 my $pid = open ( OPENSSL
, "|-" );
3804 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto VPNCONF_ERROR
;};
3805 if ( $pid ) { # parent
3806 print OPENSSL
" $cgiparams {'CERT_COUNTRY'} \n " ;
3807 print OPENSSL
" $state \n " ;
3808 print OPENSSL
" $city \n " ;
3809 print OPENSSL
" $cgiparams {'CERT_ORGANIZATION'} \n " ;
3810 print OPENSSL
" $ou \n " ;
3811 print OPENSSL
" $cgiparams {'CERT_NAME'} \n " ;
3812 print OPENSSL
" $cgiparams {'CERT_EMAIL'} \n " ;
3813 print OPENSSL
". \n " ;
3814 print OPENSSL
". \n " ;
3817 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3818 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}key.pem" );
3819 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}req.pem" );
3823 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
3824 '-newkey' , 'rsa:1024' ,
3825 '-keyout' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
3826 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
3827 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
3828 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
3829 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
3830 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
3835 # Sign the host certificate request
3836 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
3837 '-batch' , '-notext' ,
3838 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
3839 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
3840 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
3842 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3843 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
3844 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
3845 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3846 & newcleanssldatabase
();
3849 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
3850 & deletebackupcert
();
3853 # Create the pkcs12 file
3854 system ( '/usr/bin/openssl' , 'pkcs12' , '-export' ,
3855 '-inkey' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
3856 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
3857 '-name' , $cgiparams { 'NAME' },
3858 '-passout' , "pass: $cgiparams {'CERT_PASS1'}" ,
3859 '-certfile' , "${General::swroot}/ovpn/ca/cacert.pem" ,
3860 '-caname' , " $vpnsettings {'ROOTCERT_ORGANIZATION'} CA" ,
3861 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
3863 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3864 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
3865 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3866 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
3869 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
3871 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
3872 ; # Nothing, just editing
3874 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
3878 # Check if there is no other entry with this common name
3879 if ((! $cgiparams { 'KEY' }) && ( $cgiparams { 'AUTH' } ne 'psk' )) {
3880 foreach my $key ( keys %confighash ) {
3881 if ( $confighash { $key }[ 2 ] eq $cgiparams { 'CERT_NAME' }) {
3882 $errormessage = $Lang :: tr
{ 'a connection with this common name already exists' };
3889 my $key = $cgiparams { 'KEY' };
3892 $key = & General
:: findhasharraykey
( \
%confighash );
3893 foreach my $i ( 0 .. 38 ) { $confighash { $key }[ $i ] = "" ;}
3895 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
3896 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
3897 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
3898 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
3901 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
3902 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
3903 $confighash { $key }[ 4 ] = 'psk' ;
3904 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
3906 $confighash { $key }[ 4 ] = 'cert' ;
3908 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3909 $confighash { $key }[ 6 ] = $cgiparams { 'SIDE' };
3910 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
3912 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
3913 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
3914 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
3915 $confighash { $key }[ 22 ] = $confighash { $key }[ 29 ];
3917 $confighash { $key }[ 22 ] = $cgiparams { 'OVPN_MGMT' };
3919 $confighash { $key }[ 23 ] = $cgiparams { 'MSSFIX' };
3920 $confighash { $key }[ 24 ] = $cgiparams { 'FRAGMENT' };
3921 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
3922 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
3924 $confighash { $key }[ 27 ] = $cgiparams { 'OVPN_SUBNET' };
3925 $confighash { $key }[ 28 ] = $cgiparams { 'PROTOCOL' };
3926 $confighash { $key }[ 29 ] = $cgiparams { 'DEST_PORT' };
3927 $confighash { $key }[ 30 ] = $cgiparams { 'COMPLZO' };
3928 $confighash { $key }[ 31 ] = $cgiparams { 'MTU' };
3929 $confighash { $key }[ 32 ] = $cgiparams { 'CHECK1' };
3930 $name = $cgiparams { 'CHECK1' };
3931 $confighash { $key }[ 33 ] = $cgiparams { $name };
3932 $confighash { $key }[ 34 ] = $cgiparams { 'RG' };
3933 $confighash { $key }[ 35 ] = $cgiparams { 'CCD_DNS1' };
3934 $confighash { $key }[ 36 ] = $cgiparams { 'CCD_DNS2' };
3935 $confighash { $key }[ 37 ] = $cgiparams { 'CCD_WINS' };
3936 $confighash { $key }[ 38 ] = $cgiparams { 'PMTU_DISCOVERY' };
3939 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3941 if ( $cgiparams { 'CHECK1' } ){
3943 my ( $ccdip , $ccdsub )= split "/" , $cgiparams { $name };
3944 my ( $a , $b , $c , $d ) = split ( /\./ , $ccdip );
3945 if ( - e
"${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ){
3946 unlink "${General::swroot}/ovpn/ccd/ $cgiparams {'CERT_NAME'}" ;
3948 $confighash { $key }[ 2 ] =~ s/ /_/gi ;
3949 open ( CCDRWCONF
, '>' , "${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ) or die "Unable to create clientconfigfile $!" ;
3950 print CCDRWCONF
"# OpenVPN clientconfig from ccd extension by Copymaster# \n\n " ;
3951 if ( $cgiparams { 'CHECK1' } eq 'dynamic' ){
3952 print CCDRWCONF
"#This client uses the dynamic pool \n " ;
3954 print CCDRWCONF
"#Ip address client and server \n " ;
3955 print CCDRWCONF
"ifconfig-push $ccdip " .& General
:: getlastip
( $ccdip , 1 ). " \n " ;
3957 if ( $confighash { $key }[ 34 ] eq 'on' ){
3958 print CCDRWCONF
" \n #Redirect Gateway: \n #All IP traffic is redirected through the vpn \n " ;
3959 print CCDRWCONF
"push redirect-gateway \n " ;
3961 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3962 if ( $cgiparams { 'IR' } ne '' ){
3963 print CCDRWCONF
" \n #Client routes these networks (behind Client) \n " ;
3964 foreach my $key ( keys %ccdroutehash ){
3965 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
3966 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
3967 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
3968 print CCDRWCONF
"iroute $a $b \n " ;
3973 if ( $cgiparams { 'IFROUTE' } eq $Lang :: tr
{ 'ccd none' } ){ $cgiparams { 'IFROUTE' }= '' ;}
3974 if ( $cgiparams { 'IFROUTE' } ne '' ){
3975 print CCDRWCONF
" \n #Client gets routes to these networks (behind IPFire) \n " ;
3976 foreach my $key ( keys %ccdroute2hash ){
3977 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
3978 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}){
3979 if ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'blue' }){
3981 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%blue );
3982 print CCDRWCONF
"push \" route $blue {BLUE_ADDRESS} $blue {BLUE_NETMASK} \n " ;
3983 } elsif ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'orange' }){
3985 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%orange );
3986 print CCDRWCONF
"push \" route $orange {ORANGE_ADDRESS} $orange {ORANGE_NETMASK} \n " ;
3988 my ( $a , $b )= split ( /\/ /, $ccdroute2hash { $key }[ $i ]);
3989 print CCDRWCONF
"push \" route $a $b \"\n " ;
3995 if (( $cgiparams { 'CCD_DNS1' } eq '' ) && ( $cgiparams { 'CCD_DNS1' } ne '' )){ $cgiparams { 'CCD_DNS1' } = $cgiparams { 'CCD_DNS2' }; $cgiparams { 'CCD_DNS2' }= '' ;}
3996 if ( $cgiparams { 'CCD_DNS1' } ne '' ){
3997 print CCDRWCONF
" \n #Client gets these nameservers \n " ;
3998 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS1'} \" \n " ;
4000 if ( $cgiparams { 'CCD_DNS2' } ne '' ){
4001 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS2'} \" \n " ;
4003 if ( $cgiparams { 'CCD_WINS' } ne '' ){
4004 print CCDRWCONF
" \n #Client gets this WINS server \n " ;
4005 print CCDRWCONF
"push \" dhcp-option WINS $cgiparams {'CCD_WINS'} \" \n " ;
4014 if ( $cgiparams { 'TYPE' } eq 'net' ) {
4016 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
4017 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4019 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4020 my $key = $cgiparams { 'KEY' };
4022 $key = & General
:: findhasharraykey
( \
%confighash );
4023 foreach my $i ( 0 .. 31 ) { $confighash { $key }[ $i ] = "" ;}
4025 $confighash { $key }[ 0 ] = 'on' ;
4026 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4028 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4036 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
4037 $cgiparams { 'KEY' } = $key ;
4038 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
4042 $cgiparams { 'ENABLED' } = 'on' ;
4046 $cgiparams { 'MSSFIX' } = 'on' ;
4047 $cgiparams { 'FRAGMENT' } = '1300' ;
4048 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4052 $cgiparams { 'SIDE' } = 'left' ;
4053 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) {
4054 $cgiparams { 'AUTH' } = 'psk' ;
4055 } elsif ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4056 $cgiparams { 'AUTH' } = 'certfile' ;
4058 $cgiparams { 'AUTH' } = 'certgen' ;
4060 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
4061 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
4062 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
4063 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
4064 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
4068 $checked { 'ENABLED' }{ 'off' } = '' ;
4069 $checked { 'ENABLED' }{ 'on' } = '' ;
4070 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4071 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4072 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4073 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4074 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4075 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4076 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4079 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
4080 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
4081 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = 'CHECKED' ;
4083 $selected { 'SIDE' }{ 'server' } = '' ;
4084 $selected { 'SIDE' }{ 'client' } = '' ;
4085 $selected { 'SIDE' }{ $cgiparams { 'SIDE' }} = 'SELECTED' ;
4087 $selected { 'PROTOCOL' }{ 'udp' } = '' ;
4088 $selected { 'PROTOCOL' }{ 'tcp' } = '' ;
4089 $selected { 'PROTOCOL' }{ $cgiparams { 'PROTOCOL' }} = 'SELECTED' ;
4092 $checked { 'AUTH' }{ 'psk' } = '' ;
4093 $checked { 'AUTH' }{ 'certreq' } = '' ;
4094 $checked { 'AUTH' }{ 'certgen' } = '' ;
4095 $checked { 'AUTH' }{ 'certfile' } = '' ;
4096 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = 'CHECKED' ;
4098 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = 'SELECTED' ;
4100 $checked { 'COMPLZO' }{ 'off' } = '' ;
4101 $checked { 'COMPLZO' }{ 'on' } = '' ;
4102 $checked { 'COMPLZO' }{ $cgiparams { 'COMPLZO' }} = 'CHECKED' ;
4104 $checked { 'MSSFIX' }{ 'off' } = '' ;
4105 $checked { 'MSSFIX' }{ 'on' } = '' ;
4106 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4108 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
4109 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4111 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
4115 & Header
:: showhttpheaders
();
4116 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
4117 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4118 if ( $errormessage ) {
4119 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4120 print "<class name='base'> $errormessage " ;
4121 print " </class>" ;
4122 & Header
:: closebox
();
4126 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'warning messages'}:" );
4127 print "<class name='base'> $warnmessage " ;
4128 print " </class>" ;
4129 & Header
:: closebox
();
4132 print "<form method='post' enctype='multipart/form-data'>" ;
4133 print "<input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />" ;
4135 if ( $cgiparams { 'KEY' }) {
4136 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
4137 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
4140 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'connection'}:" );
4141 print "<table width='100%' border='0'> \n " ;
4145 print "<tr><td width='14%' class='boldbase'> $Lang ::tr{'name'}: </td>" ;
4147 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4148 if ( $cgiparams { 'KEY' }) {
4149 print "<td width='35%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4152 print "<td width='35%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' size='30' /></td>" ;
4154 # print "<tr><td>$Lang::tr{'interface'}</td>";
4155 # print "<td><select name='INTERFACE'>";
4156 # print "<option value='RED' $selected{'INTERFACE'}{'RED'}>RED</option>";
4157 # if ($netsettings{'BLUE_DEV'} ne '') {
4158 # print "<option value='BLUE' $selected{'INTERFACE'}{'BLUE'}>BLUE</option>";
4160 # print "<option value='GREEN' $selected{'INTERFACE'}{'GREEN'}>GREEN</option>";
4161 # print "<option value='ORANGE' $selected{'INTERFACE'}{'ORANGE'}>ORANGE</option>";
4162 # print "</select></td></tr>";
4165 print "<input type='hidden' name='INTERFACE' value='red' />" ;
4166 if ( $cgiparams { 'KEY' }) {
4167 print "<td width='25%' class='base' nowrap='nowrap'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4169 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' /></td>" ;
4175 <td width='25%'> </td>
4176 <td width='25%'> </td></tr>
4177 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td>
4178 <td><select name='SIDE'><option value='server' $selected {'SIDE'}{'server'}> $Lang ::tr{'openvpn server'}</option>
4179 <option value='client' $selected {'SIDE'}{'client'}> $Lang ::tr{'openvpn client'}</option></select></td>
4180 <td class='boldbase'> $Lang ::tr{'remote host/ip'}:</td>
4181 <td><input type='TEXT' name='REMOTE' value=' $cgiparams {'REMOTE'}' /></td></tr>
4182 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
4183 <td><input type='TEXT' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' /></td>
4184 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
4185 <td><input type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' /></td></tr>
4186 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td>
4187 <td><input type='TEXT' name='OVPN_SUBNET' value=' $cgiparams {'OVPN_SUBNET'}' /></td></tr>
4188 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
4190 <td><select name='PROTOCOL'><option value='udp' $selected {'PROTOCOL'}{'udp'}>UDP</option>
4191 <option value='tcp' $selected {'PROTOCOL'}{'tcp'}>TCP</option></select></td>
4193 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
4194 <td><input type='TEXT' name='DEST_PORT' value=' $cgiparams {'DEST_PORT'}' size='5' /></td></tr>
4195 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'} <img src='/blob.gif'</td>
4196 <td><input type='checkbox' name='COMPLZO' $checked {'COMPLZO'}{'on'} /></td>
4198 <tr><td class='boldbase' nowrap='nowrap'>mssfix <img src='/blob.gif' /></td>
4199 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
4200 <td> $Lang ::tr{'openvpn default'}: <span class="base">on</span></td>
4202 <tr><td class='boldbase' nowrap='nowrap'>fragment <img src='/blob.gif' /></td>
4203 <td><input type='TEXT' name='FRAGMENT' VALUE=' $cgiparams {'FRAGMENT'}'size='5' /></td>
4204 <td> $Lang ::tr{'openvpn default'}: <span class="base">1300</span></td>
4206 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} <img src='/blob.gif' /></td>
4207 <td> <input type='TEXT' name='MTU' VALUE=' $cgiparams {'MTU'}'size='5' /></td>
4208 <td colspan='2'> $Lang ::tr{'openvpn default'}: udp/tcp <span class="base">1500/1400</span></td>
4210 <tr><td class='boldbase' nowrap='nowrap'>Management Port <img src='/blob.gif' /></td>
4211 <td> <input type='TEXT' name='OVPN_MGMT' VALUE=' $cgiparams {'OVPN_MGMT'}'size='5' /></td>
4212 <td colspan='2'> $Lang ::tr{'openvpn default'}: <span class="base"> $Lang ::tr{'destination port'}</span></td>
4215 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td>
4217 <input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}
4218 <input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}
4219 <input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}
4220 <input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}
4228 print "<tr><td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' /></td>" ;
4229 print "<td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td></tr></table>" ;
4231 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4232 print "<tr><td> $Lang ::tr{'enabled'} <input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>" ;
4235 print "</tr></table><br><br>" ;
4236 #A.Marx CCD new client
4237 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4238 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>" ;
4241 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnnet );
4242 $vpnip = $vpnnet { 'DOVPN_SUBNET' };
4243 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
4247 $checked { 'check1' }{ 'off' } = '' ;
4248 $checked { 'check1' }{ 'on' } = '' ;
4249 $checked { 'check1' }{ $cgiparams { 'CHECK1' }} = 'CHECKED' ;
4250 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%'>" ;
4251 print "</td></tr></table><br><br>" ;
4252 my $name = $cgiparams { 'CHECK1' };
4253 $checked { 'RG' }{ $cgiparams { 'RG' }} = 'CHECKED' ;
4255 if (! - z
"${General::swroot}/ovpn/ccd.conf" ){
4256 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>" ;
4257 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
4259 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
4260 if ( $count % 2 ){ print "<tr bgcolor=' $color {'color22'}'>" ;} else { print "<tr bgcolor=' $color {'color20'}'>" ;}
4261 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%'>" ;
4262 & fillselectbox
( $ccdconf [ 1 ], $ccdconf [ 0 ], $cgiparams { $name });
4265 print "</table><br><br><hr><br><br>" ;
4269 & Header
:: closebox
();
4270 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
4272 } elsif (! $cgiparams { 'KEY' }) {
4276 my $cakeydisabled = '' ;
4277 my $cacrtdisabled = '' ;
4278 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) { $cakeydisabled = "disabled='disabled'" } else { $cakeydisabled = "" };
4279 if ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) { $cacrtdisabled = "disabled='disabled'" } else { $cacrtdisabled = "" };
4281 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'authentication' });
4284 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4287 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4289 <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>
4290 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td><td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
4291 <tr><td colspan='3'> </td></tr>
4292 <tr><td colspan='3'><hr /></td></tr>
4293 <tr><td colspan='3'> </td></tr>
4294 <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>
4295 <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>
4296 <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>
4297 <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>
4298 <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>
4299 <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>
4300 <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>
4301 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4312 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4314 <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>
4315 <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>
4316 <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>
4317 <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>
4318 <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>
4319 <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>
4320 <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>
4321 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4333 foreach my $country ( sort keys %{ Countries
:: countries
}) {
4334 print "<option value=' $Countries ::countries{ $country }'" ;
4335 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
4336 print " selected='selected'" ;
4338 print "> $country </option>" ;
4344 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4348 <td> </td><td class='base'> $Lang ::tr{'valid till'} (days):</td>
4349 <td class='base' nowrap='nowrap'><input type='text' name='DAYS_VALID' value=' $cgiparams {'DAYS_VALID'}' size='32' $cakeydisabled /></td></tr>
4351 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
4352 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
4353 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:<BR>( $Lang ::tr{'confirmation'})</td>
4354 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
4355 <tr><td colspan='3'> </td></tr>
4356 <tr><td colspan='3'><hr /></td></tr>
4357 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4363 <tr><td> </td><td> </td><td> </td></tr>
4364 <tr><td> </td><td> </td><td> </td></tr>
4365 <tr><td colspan='3'><hr /></td></tr>
4366 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4376 & Header
:: closebox
();
4380 #A.Marx CCD new client
4381 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4383 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ccd client options'}:" );
4387 <table border='0' width='100%'>
4388 <tr><td width='20%'>Redirect Gateway:</td><td colspan='3'><input type='checkbox' name='RG' $checked {'RG'}{'on'} /></td></tr>
4389 <tr><td colspan='4'><b><br> $Lang ::tr{'ccd routes'}</b></td></tr>
4390 <tr><td colspan='4'> </td></tr>
4391 <tr><td valign='top'> $Lang ::tr{'ccd iroute'}</td><td align='left' width='30%'><textarea name='IR' cols='26' rows='6' wrap='off'>
4394 if ( $cgiparams { 'IR' } ne '' ){
4395 print $cgiparams { 'IR' };
4397 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4398 foreach my $key ( keys %ccdroutehash ) {
4399 if ( $cgiparams { 'NAME' } eq $ccdroutehash { $key }[ 0 ]){
4400 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
4401 if ( $ccdroutehash { $key }[ $i ] ne '' ){
4402 print $ccdroutehash { $key }[ $i ]. " \n " ;
4404 $cgiparams { 'IR' } .= $ccdroutehash { $key }[ $i ];
4411 </textarea></td><td valign='top' colspan='2'> $Lang ::tr{'ccd iroutehint'}</td></tr>
4412 <tr><td colspan='4'><br></td></tr>
4413 <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>
4427 open ( FILE
, "${General::swroot}/main/routing" ) ;
4430 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
4432 foreach my $key ( keys %ccdroute2hash ) {
4433 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4434 if ( $ccdroute2hash { $key }[ 1 ] eq '' ){
4441 print "<option> $Lang ::tr{'ccd none'}</option>" ;
4443 print "<option selected> $Lang ::tr{'ccd none'}</option>" ;
4445 #check if static routes are defined for client
4446 foreach my $line ( @current ) {
4448 $line =~ s/\s*$//g ; # remove newline
4449 @temp = split ( /\,/ , $line );
4450 $temp [ 1 ] = '' unless defined $temp [ 1 ]; # not always populated
4451 my ( $a , $b ) = split ( /\/ /, $temp [ 1 ]);
4452 $temp [ 1 ] = $a . "/" .& General
:: iporsubtocidr
( $b );
4453 foreach my $key ( keys %ccdroute2hash ) {
4454 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4455 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4456 if ( $ccdroute2hash { $key }[ $i ] eq $a . "/" .& General
:: iporsubtodec
( $b )){
4462 if ( $set == '1' && $#temp != - 1 ){ print "<option selected> $temp [1]</option>" ; $set = 0 ;} elsif ( $set == '0' && $#temp != - 1 ){ print "<option> $temp [1]</option>" ;}
4464 #check if green,blue,orange are defined for client
4465 foreach my $key ( keys %ccdroute2hash ) {
4466 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4468 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4469 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'GREEN_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'GREEN_NETMASK' })){
4472 if (& haveBlueNet
()){
4473 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'BLUE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'BLUE_NETMASK' })) {
4477 if (& haveOrangeNet
()){
4478 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'ORANGE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'ORANGE_NETMASK' }) ) {
4485 if (& haveBlueNet
() && $selblue == '1' ){ print "<option selected> $Lang ::tr{'blue'}</option>" ; $selblue = 0 ;} elsif (& haveBlueNet
() && $selblue == '0' ){ print "<option> $Lang ::tr{'blue'}</option>" ;}
4486 if (& haveOrangeNet
() && $selorange == '1' ){ print "<option selected> $Lang ::tr{'orange'}</option>" ; $selorange = 0 ;} elsif (& haveOrangeNet
() && $selorange == '0' ){ print "<option> $Lang ::tr{'orange'}</option>" ;}
4487 if ( $selgreen == '1' || $other == '0' ){ print "<option selected> $Lang ::tr{'green'}</option>" ; $set = 0 ;} else { print "<option> $Lang ::tr{'green'}</option>" ;};
4490 </select></td><td valign='top'>DNS1:</td><td valign='top'><input type='TEXT' name='CCD_DNS1' value=' $cgiparams {'CCD_DNS1'}' size='30' /></td></tr>
4491 <tr valign='top'><td>DNS2:</td><td><input type='TEXT' name='CCD_DNS2' value=' $cgiparams {'CCD_DNS2'}' size='30' /></td></tr>
4492 <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>
4496 & Header
:: closebox
();
4498 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
4499 if ( $cgiparams { 'KEY' }) {
4500 # print "<input type='submit' name='ACTION' value='$Lang::tr{'advanced'}' />";
4502 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
4503 & Header
:: closebigbox
();
4504 & Header
:: closepage
();
4512 ### Default status page
4517 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
4518 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
4519 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4521 my @status = `/bin/cat /var/log/ovpnserver.log` ;
4523 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
4524 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
4525 my $ipaddr = < IPADDR
>;
4528 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
4529 if ( $cgiparams { 'VPN_IP' } eq '' ) {
4530 $cgiparams { 'VPN_IP' } = $ipaddr ;
4536 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4537 $cgiparams { 'DCIPHER' } = 'BF-CBC' ;
4539 if ( $cgiparams { 'DDEST_PORT' } eq '' ) {
4540 $cgiparams { 'DDEST_PORT' } = '1194' ;
4542 if ( $cgiparams { 'DMTU' } eq '' ) {
4543 $cgiparams { 'DMTU' } = '1400' ;
4545 if ( $cgiparams { 'DOVPN_SUBNET' } eq '' ) {
4546 $cgiparams { 'DOVPN_SUBNET' } = '10.' . int ( rand ( 256 )) . '.' . int ( rand ( 256 )) . '.0/255.255.255.0' ;
4548 $checked { 'ENABLED' }{ 'off' } = '' ;
4549 $checked { 'ENABLED' }{ 'on' } = '' ;
4550 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4551 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4552 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4553 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4554 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4555 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4556 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4557 $selected { 'DDEVICE' }{ 'tun' } = '' ;
4558 $selected { 'DDEVICE' }{ 'tap' } = '' ;
4559 $selected { 'DDEVICE' }{ $cgiparams { 'DDEVICE' }} = 'SELECTED' ;
4561 $selected { 'DPROTOCOL' }{ 'udp' } = '' ;
4562 $selected { 'DPROTOCOL' }{ 'tcp' } = '' ;
4563 $selected { 'DPROTOCOL' }{ $cgiparams { 'DPROTOCOL' }} = 'SELECTED' ;
4565 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4566 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4567 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4568 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4569 $selected { 'DCIPHER' }{ 'RC2-CBC' } = '' ;
4570 $selected { 'DCIPHER' }{ 'RC2-40-CBC' } = '' ;
4571 $selected { 'DCIPHER' }{ 'RC2-64-CBC' } = '' ;
4572 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4573 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4574 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4575 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4576 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4577 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4578 $checked { 'DCOMPLZO' }{ 'off' } = '' ;
4579 $checked { 'DCOMPLZO' }{ 'on' } = '' ;
4580 $checked { 'DCOMPLZO' }{ $cgiparams { 'DCOMPLZO' }} = 'CHECKED' ;
4582 $checked { 'MSSFIX' }{ 'off' } = '' ;
4583 $checked { 'MSSFIX' }{ 'on' } = '' ;
4584 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4586 & Header
:: showhttpheaders
();
4587 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
4588 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4590 if ( $errormessage ) {
4591 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4592 print "<class name='base'> $errormessage \n " ;
4593 print " </class> \n " ;
4594 & Header
:: closebox
();
4597 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>" ;
4598 my $srunning = "no" ;
4599 my $activeonrun = "" ;
4600 if ( - e
"/var/run/openvpn.pid" ){
4601 $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>" ;
4605 $activeonrun = "disabled='disabled'" ;
4607 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'global settings' });
4609 <table width='100%' border=0>
4610 <form method='post'>
4611 <td width='25%'> </td>
4612 <td width='25%'> </td>
4613 <td width='25%'> </td></tr>
4614 <tr><td class='boldbase'> $Lang ::tr{'ovpn server status'}</td>
4615 <td align='left'> $sactive </td>
4616 <tr><td class='boldbase'> $Lang ::tr{'ovpn on red'}</td>
4617 <td><input type='checkbox' name='ENABLED' $checked {'ENABLED'}{'on'} /></td>
4620 if (& haveBlueNet
()) {
4621 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on blue'}</td>" ;
4622 print "<td><input type='checkbox' name='ENABLED_BLUE' $checked {'ENABLED_BLUE'}{'on'} /></td>" ;
4624 if (& haveOrangeNet
()) {
4625 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on orange'}</td>" ;
4626 print "<td><input type='checkbox' name='ENABLED_ORANGE' $checked {'ENABLED_ORANGE'}{'on'} /></td>" ;
4629 <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>
4630 <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>
4631 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn device'}</td>
4632 <td><select name='DDEVICE' ><option value='tun' $selected {'DDEVICE'}{'tun'}>TUN</option>
4633 <!-- this is still not working
4634 <option value='tap' $selected {'DDEVICE'}{'tap'}>TAP</option></select>--> </td>
4635 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
4636 <td><select name='DPROTOCOL'><option value='udp' $selected {'DPROTOCOL'}{'udp'}>UDP</option>
4637 <option value='tcp' $selected {'DPROTOCOL'}{'tcp'}>TCP</option></select></td>
4638 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
4639 <td><input type='TEXT' name='DDEST_PORT' value=' $cgiparams {'DDEST_PORT'}' size='5' /></td></tr>
4640 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} </td>
4641 <td> <input type='TEXT' name='DMTU' VALUE=' $cgiparams {'DMTU'}'size='5' /></TD>
4642 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td>
4643 <td><input type='checkbox' name='DCOMPLZO' $checked {'DCOMPLZO'}{'on'} /></td>
4644 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td>
4645 <td><select name='DCIPHER'><option value='DES-CBC' $selected {'DCIPHER'}{'DES-CBC'}>DES-CBC</option>
4646 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC</option>
4647 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC</option>
4648 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC</option>
4649 <option value='RC2-CBC' $selected {'DCIPHER'}{'RC2-CBC'}>RC2-CBC</option>
4650 <option value='RC2-40-CBC' $selected {'DCIPHER'}{'RC2-40-CBC'}>RC2-40-CBC</option>
4651 <option value='RC2-64-CBC' $selected {'DCIPHER'}{'RC2-64-CBC'}>RC2-64-CBC</option>
4652 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC</option>
4653 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC</option>
4654 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-128-CBC</option>
4655 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-192-CBC</option>
4656 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-256-CBC</option></select></td></tr>
4657 <tr><td colspan='4'><hr /></td></tr>
4661 if ( $srunning eq "yes" ) {
4662 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' disabled='disabled' />" ;
4663 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
4664 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
4665 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'stop ovpn server'}' /></td></tr>" ;
4667 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
4668 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
4669 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
4670 if (( - e
"${General::swroot}/ovpn/ca/cacert.pem" &&
4671 - e
"${General::swroot}/ovpn/ca/dh1024.pem" &&
4672 - e
"${General::swroot}/ovpn/certs/servercert.pem" &&
4673 - e
"${General::swroot}/ovpn/certs/serverkey.pem" ) &&
4674 (( $cgiparams { 'ENABLED' } eq 'on' ) ||
4675 ( $cgiparams { 'ENABLED_BLUE' } eq 'on' ) ||
4676 ( $cgiparams { 'ENABLED_ORANGE' } eq 'on' ))){
4677 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' /></td></tr>" ;
4679 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' disabled='disabled' /></td></tr>" ;
4682 print "</form></table>" ;
4683 & Header
:: closebox
();
4684 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate authorities'}:" );
4686 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
4688 <td width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
4689 <td width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></td>
4690 <td width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></td>
4694 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4695 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
4696 $casubject =~ /Subject: (.*)[\n]/ ;
4698 $casubject =~ s
+/ Email
+, E
+;
4699 $casubject =~ s/ ST=/ S=/ ;
4702 <tr bgcolor=' $color {'color22'}'>
4703 <td class='base'> $Lang ::tr{'root certificate'}</td>
4704 <td class='base'> $casubject </td>
4705 <form method='post' name='frmrootcrta'><td width='3%' align='center'>
4706 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
4707 <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' />
4709 <form method='post' name='frmrootcrtb'><td width='3%' align='center'>
4710 <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' />
4711 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
4713 <td width='4%'> </td></tr>
4717 # display rootcert generation buttons
4719 <tr bgcolor=' $color {'color22'}'>
4720 <td class='base'> $Lang ::tr{'root certificate'}:</td>
4721 <td class='base'> $Lang ::tr{'not present'}</td>
4722 <td colspan='3'> </td></tr>
4727 if (- f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
4728 my $hostsubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
4729 $hostsubject =~ /Subject: (.*)[\n]/ ;
4731 $hostsubject =~ s
+/ Email
+, E
+;
4732 $hostsubject =~ s/ ST=/ S=/ ;
4735 <tr bgcolor=' $color {'color20'}'>
4736 <td class='base'> $Lang ::tr{'host certificate'}</td>
4737 <td class='base'> $hostsubject </td>
4738 <form method='post' name='frmhostcrta'><td width='3%' align='center'>
4739 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
4740 <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' />
4742 <form method='post' name='frmhostcrtb'><td width='3%' align='center'>
4743 <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' />
4744 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download host certificate'}' />
4746 <td width='4%'> </td></tr>
4752 <tr bgcolor=' $color {'color20'}'>
4753 <td width='25%' class='base'> $Lang ::tr{'host certificate'}:</td>
4754 <td class='base'> $Lang ::tr{'not present'}</td>
4755 </td><td colspan='3'> </td></tr>
4760 if (! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4761 print "<tr><td colspan='5' align='center'><form method='post'>" ;
4762 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' />" ;
4763 print "</form></td></tr> \n " ;
4766 if ( keys %cahash > 0 ) {
4767 foreach my $key ( keys %cahash ) {
4768 if (( $key + 1 ) % 2 ) {
4769 print "<tr bgcolor=' $color {'color20'}'> \n " ;
4771 print "<tr bgcolor=' $color {'color22'}'> \n " ;
4773 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
4774 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
4776 <form method='post' name='cafrm${key}a'><td align='center'>
4777 <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' />
4778 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
4779 <input type='hidden' name='KEY' value=' $key ' />
4781 <form method='post' name='cafrm${key}b'><td align='center'>
4782 <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' />
4783 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
4784 <input type='hidden' name='KEY' value=' $key ' />
4786 <form method='post' name='cafrm${key}c'><td align='center'>
4787 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
4788 <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' />
4789 <input type='hidden' name='KEY' value=' $key ' />
4798 # If the file contains entries, print Key to action icons
4799 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4803 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
4804 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
4805 <td class='base'> $Lang ::tr{'show certificate'}</td>
4806 <td> <img src='/images/media-floppy.png' alt=' $Lang ::tr{'download certificate'}' /></td>
4807 <td class='base'> $Lang ::tr{'download certificate'}</td>
4815 <form method='post' enctype='multipart/form-data'>
4816 <table width='100%' border='0'>
4817 <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>
4818 <tr><td colspan='4'><hr /></td></tr>
4819 <tr align='right'><td colspan='4' align='right' width='80%'><input type='submit' name='ACTION' value=' $Lang ::tr{'show crl'}' /></td></tr>
4825 & Header
:: closebox
();
4826 if ( $srunning eq "yes" ) {
4827 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'reset'}' disabled='disabled' /></div></form> \n " ;
4829 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'reset'}' /></div></form> \n " ;
4831 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4835 #<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>
4838 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'Client status and controlc' });
4842 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
4844 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
4845 <td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></td>
4846 <td width='22%' class='boldbase' align='center'><b> $Lang ::tr{'network'}</b></td>
4847 <td width='20%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></td>
4848 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></td>
4849 <td width='5%' class='boldbase' colspan='6' align='center'><b> $Lang ::tr{'action'}</b></td>
4855 foreach my $key ( sort { uc ( $confighash { $a }[ 1 ]) cmp uc ( $confighash { $b }[ 1 ]) } keys %confighash ) {
4856 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
4859 print "<tr bgcolor=' $color {'color20'}'> \n " ;
4861 print "<tr bgcolor=' $color {'color22'}'> \n " ;
4863 print "<td align='center' nowrap='nowrap'> $confighash { $key }[1]</td>" ;
4864 print "<td align='center' nowrap='nowrap'>" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
4865 #if ($confighash{$key}[4] eq 'cert') {
4866 #print "<td align='left' nowrap='nowrap'>$confighash{$key}[2]</td>";
4868 #print "<td align='left'> </td>";
4870 my $cavalid = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
4871 $cavalid =~ /Not After : (.*)[\n]/ ;
4873 if ( $confighash { $key }[ 32 ] eq "" && $confighash { $key }[ 3 ] eq 'net' ){ $confighash { $key }[ 32 ]= "net-2-net" ;}
4874 if ( $confighash { $key }[ 32 ] eq "" && $confighash { $key }[ 3 ] eq 'host' ){ $confighash { $key }[ 32 ]= "dynamic" ;}
4875 print "<td align='center'> $confighash { $key }[32]</td>" ;
4876 print "<td align='center'> $confighash { $key }[25]</td>" ;
4878 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>" ;
4880 if ( $confighash { $key }[ 0 ] eq 'off' ) {
4881 $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>" ;
4888 if ( $confighash { $key }[ 3 ] eq 'net' ) {
4890 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
4893 my $tport = $confighash { $key }[ 22 ];
4894 my $tnet = new Net
:: Telnet
( Timeout
=> 5 , Errmode
=> 'return' , Port
=> $tport );
4896 $tnet -> open ( '127.0.0.1' );
4897 @output = $tnet -> cmd ( String
=> 'state' , Prompt
=> '/(END.* \n |ERROR:.* \n )/' );
4898 @tustate = split ( /\,/ , $output [ 1 ]);
4900 #CONNECTING -- OpenVPN's initial state.
4901 #WAIT -- (Client only) Waiting for initial response from server.
4902 #AUTH -- (Client only) Authenticating with server.
4903 #GET_CONFIG -- (Client only) Downloading configuration options from server.
4904 #ASSIGN_IP -- Assigning IP address to virtual network interface.
4905 #ADD_ROUTES -- Adding routes to system.
4906 #CONNECTED -- Initialization Sequence Completed.
4907 #RECONNECTING -- A restart has occurred.
4908 #EXITING -- A graceful exit is in progress.
4911 if ( $tustate [ 1 ] eq 'CONNECTED' ) {
4912 $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>" ;
4914 $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>" ;
4922 foreach my $line ( @status ) {
4924 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
4925 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
4926 if ( $match [ 1 ] ne "Common Name" ) {
4930 if ( $cn eq " $confighash { $key }[2]" ) {
4931 $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>" ;
4941 <td align='center'> $active </td>
4943 <form method='post' name='frm${key}a'><td align='center'>
4944 <input type='image' name=' $Lang ::tr{'dl client arch'}' src='/images/openvpn.png' alt=' $Lang ::tr{'dl client arch'}' title=' $Lang ::tr{'dl client arch'}' border='0' />
4945 <input type='hidden' name='ACTION' value=' $Lang ::tr{'dl client arch'}' />
4946 <input type='hidden' name='KEY' value=' $key ' />
4950 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
4952 <form method='post' name='frm${key}b'><td align='center'>
4953 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' border='0' />
4954 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
4955 <input type='hidden' name='KEY' value=' $key ' />
4959 print "<td> </td>" ;
4961 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" ) {
4963 <form method='post' name='frm${key}c'><td align='center'>
4964 <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' />
4965 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
4966 <input type='hidden' name='KEY' value=' $key ' />
4969 ; } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
4971 <form method='post' name='frm${key}c'><td align='center'>
4972 <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' />
4973 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
4974 <input type='hidden' name='KEY' value=' $key ' />
4978 print "<td> </td>" ;
4981 <form method='post' name='frm${key}d'><td align='center'>
4982 <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' />
4983 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
4984 <input type='hidden' name='KEY' value=' $key ' />
4987 <form method='post' name='frm${key}e'><td align='center'>
4988 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
4989 <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'/>
4990 <input type='hidden' name='KEY' value=' $key ' />
4992 <form method='post' name='frm${key}f'><td align='center'>
4993 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
4994 <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' />
4995 <input type='hidden' name='KEY' value=' $key ' />
5004 # If the config file contains entries, print Key to action icons
5009 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5010 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
5011 <td class='base'> $Lang ::tr{'click to disable'}</td>
5012 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
5013 <td class='base'> $Lang ::tr{'show certificate'}</td>
5014 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
5015 <td class='base'> $Lang ::tr{'edit'}</td>
5016 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
5017 <td class='base'> $Lang ::tr{'remove'}</td>
5021 <td> <img src='/images/off.gif' alt='?OFF' /></td>
5022 <td class='base'> $Lang ::tr{'click to enable'}</td>
5023 <td> <img src='/images/media-floppy.png' alt='?FLOPPY' /></td>
5024 <td class='base'> $Lang ::tr{'download certificate'}</td>
5025 <td> <img src='/images/openvpn.png' alt='?RELOAD'/></td>
5026 <td class='base'> $Lang ::tr{'dl client arch'}</td>
5034 <table width='100%'>
5035 <form method='post'>
5036 <tr><td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
5037 <input type='submit' name='ACTION' value=' $Lang ::tr{'ovpn con stat'}' $activeonrun /></td></tr>
5042 & Header
:: closebox
();
5044 & Header
:: closepage
();