]>
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-2014 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 77
25 use CGI qw
/:standard/ ;
30 use File
:: Temp qw
/ tempfile tempdir / ;
32 use Archive
:: Zip
qw(:ERROR_CODES :CONSTANTS) ;
34 require '/var/ipfire/general-functions.pl' ;
35 require "${General::swroot}/lang.pl" ;
36 require "${General::swroot}/header.pl" ;
37 require "${General::swroot}/countries.pl" ;
39 # enable only the following on debugging purpose
41 #use CGI::Carp 'fatalsToBrowser';
42 #workaround to suppress a warning when a variable is used only once
43 my @dummy = ( ${ Header
:: colourgreen
}, ${ Header
:: colourblue
} );
47 my %mainsettings = ();
48 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
49 & General
:: readhash
( "/srv/web/ipfire/html/themes/" . $mainsettings { 'THEME' }. "/include/colors.txt" , \
%color );
52 ### Initialize variables
65 my $errormessage = '' ;
67 my $routes_push_file = '' ;
68 my $confighost = "${General::swroot}/fwhosts/customhosts" ;
69 my $configgrp = "${General::swroot}/fwhosts/customgroups" ;
70 my $customnet = "${General::swroot}/fwhosts/customnetworks" ;
73 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
74 $cgiparams { 'ENABLED' } = 'off' ;
75 $cgiparams { 'ENABLED_BLUE' } = 'off' ;
76 $cgiparams { 'ENABLED_ORANGE' } = 'off' ;
77 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
78 $cgiparams { 'NAT' } = 'off' ;
79 $cgiparams { 'COMPRESSION' } = 'off' ;
80 $cgiparams { 'ONLY_PROPOSED' } = 'off' ;
81 $cgiparams { 'ACTION' } = '' ;
82 $cgiparams { 'CA_NAME' } = '' ;
83 $cgiparams { 'DH_NAME' } = 'dh1024.pem' ;
84 $cgiparams { 'DHLENGHT' } = '' ;
85 $cgiparams { 'DHCP_DOMAIN' } = '' ;
86 $cgiparams { 'DHCP_DNS' } = '' ;
87 $cgiparams { 'DHCP_WINS' } = '' ;
88 $cgiparams { 'ROUTES_PUSH' } = '' ;
89 $cgiparams { 'DCOMPLZO' } = 'off' ;
90 $cgiparams { 'MSSFIX' } = '' ;
91 $cgiparams { 'number' } = '' ;
92 $cgiparams { 'PMTU_DISCOVERY' } = '' ;
93 $cgiparams { 'DCIPHER' } = '' ;
94 $cgiparams { 'DAUTH' } = '' ;
95 $cgiparams { 'TLSAUTH' } = '' ;
96 $cgiparams { 'ENGINES' } = '' ;
97 $routes_push_file = "${General::swroot}/ovpn/routes_push" ;
98 unless (- e
$routes_push_file ) { system ( "touch $routes_push_file " ); }
99 unless (- e
"${General::swroot}/ovpn/ccd.conf" ) { system ( "touch ${General::swroot}/ovpn/ccd.conf" ); }
100 unless (- e
"${General::swroot}/ovpn/ccdroute" ) { system ( "touch ${General::swroot}/ovpn/ccdroute" ); }
101 unless (- e
"${General::swroot}/ovpn/ccdroute2" ) { system ( "touch ${General::swroot}/ovpn/ccdroute2" ); }
103 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
105 # prepare openvpn config file
111 if ( $netsettings { 'CONFIG_TYPE' } == 2 ) { return 1 ;}
112 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
118 if ( $netsettings { 'CONFIG_TYPE' } == 3 ) { return 1 ;}
119 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
124 my $bytesize = shift ;
127 while ( abs ( $bytesize ) >= 1024 ){
128 $bytesize = $bytesize / 1024 ;
133 my @units = ( "Bytes" , "KB" , "MB" , "GB" , "TB" , "PB" , "EB" );
134 my $newsize =( int ( $bytesize * 100 + 0.5 ))/ 100 ;
135 return ( " $newsize $units [ $i ]" );
140 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/serial" )) {
144 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/index.txt" )) {
148 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
149 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
150 unlink ( "${General::swroot}/ovpn/certs/01.pem" );
153 sub newcleanssldatabase
155 if (! - s
"${General::swroot}/ovpn/certs/serial" ) {
156 open ( FILE
, ">${General::swroot}(ovpn/certs/serial" );
160 if (! - s
">${General::swroot}/ovpn/certs/index.txt" ) {
161 system ( "touch ${General::swroot}/ovpn/certs/index.txt" );
163 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
164 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
169 if ( open ( FILE
, "${General::swroot}/ovpn/certs/serial.old" )) {
170 my $hexvalue = < FILE
>;
173 unlink ( "${General::swroot}/ovpn/certs/ $hexvalue .pem" );
180 my $confignat = "${General::swroot}/firewall/config" ;
182 & General
:: readhasharray
( $confignat , \
%natconfig );
183 foreach my $key ( sort keys %natconfig ){
184 my @portarray = split ( /\|/ , $natconfig { $key }[ 30 ]);
185 foreach my $value ( @portarray ){
187 my ( $a , $b ) = split ( ":" , $value );
188 if ( $DPROT eq $natconfig { $key }[ 12 ] && $DPORT gt $a && $DPORT lt $b ){
189 $errormessage = " $Lang ::tr{'source port in use'} $DPORT " ;
192 if ( $DPROT eq $natconfig { $key }[ 12 ] && $DPORT eq $value ){
193 $errormessage = " $Lang ::tr{'source port in use'} $DPORT " ;
203 my $portrange1 = $_ [ 0 ]; # New port range
204 my $portrange2 = $_ [ 1 ]; # existing port range
205 my @tempr1 = split ( /\:/ , $portrange1 );
206 my @tempr2 = split ( /\:/ , $portrange2 );
208 unless (& checkportinc
( $tempr1 [ 0 ], $portrange2 )){ return 0 ;}
209 unless (& checkportinc
( $tempr1 [ 1 ], $portrange2 )){ return 0 ;}
211 unless (& checkportinc
( $tempr2 [ 0 ], $portrange1 )){ return 0 ;}
212 unless (& checkportinc
( $tempr2 [ 1 ], $portrange1 )){ return 0 ;}
214 return 1 ; # Everything checks out!
217 # Darren Critchley - we want to make sure that a port entry is not within an already existing range
220 my $port1 = $_ [ 0 ]; # Port
221 my $portrange2 = $_ [ 1 ]; # Port range
222 my @tempr1 = split ( /\:/ , $portrange2 );
224 if ( $port1 < $tempr1 [ 0 ] || $port1 > $tempr1 [ 1 ]) {
231 sub writeserverconf
{
232 my %sovpnsettings = ();
234 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%sovpnsettings );
237 open ( CONF
, ">${General::swroot}/ovpn/server.conf" ) or die "Unable to open ${General::swroot}/ovpn/server.conf: $!" ;
239 print CONF
"#OpenVPN Server conf \n " ;
241 print CONF
"daemon openvpnserver \n " ;
242 print CONF
"writepid /var/run/openvpn.pid \n " ;
243 print CONF
"#DAN prepare OpenVPN for listening on blue and orange \n " ;
244 print CONF
";local $sovpnsettings {'VPN_IP'} \n " ;
245 print CONF
"dev $sovpnsettings {'DDEVICE'} \n " ;
246 print CONF
"proto $sovpnsettings {'DPROTOCOL'} \n " ;
247 print CONF
"port $sovpnsettings {'DDEST_PORT'} \n " ;
248 print CONF
"script-security 3 system \n " ;
249 print CONF
"ifconfig-pool-persist /var/ipfire/ovpn/ovpn-leases.db 3600 \n " ;
250 print CONF
"client-config-dir /var/ipfire/ovpn/ccd \n " ;
251 print CONF
"tls-server \n " ;
252 print CONF
"ca ${General::swroot}/ovpn/ca/cacert.pem \n " ;
253 print CONF
"cert ${General::swroot}/ovpn/certs/servercert.pem \n " ;
254 print CONF
"key ${General::swroot}/ovpn/certs/serverkey.pem \n " ;
255 print CONF
"dh ${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'} \n " ;
256 my @tempovpnsubnet = split ( "\/" , $sovpnsettings { 'DOVPN_SUBNET' });
257 print CONF
"server $tempovpnsubnet [0] $tempovpnsubnet [1] \n " ;
258 #print CONF "push \"route $netsettings{'GREEN_NETADDRESS'} $netsettings{'GREEN_NETMASK'}\"\n";
260 # Check if we are using mssfix, fragment or mtu-disc and set the corretct mtu of 1500.
261 # If we doesn't use one of them, we can use the configured mtu value.
262 if ( $sovpnsettings { 'MSSFIX' } eq 'on' )
263 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
264 elsif ( $sovpnsettings { 'FRAGMENT' } ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' )
265 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
266 elsif (( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
267 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
268 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'no' ))
269 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
271 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu $sovpnsettings {'DMTU'} \n " ; }
273 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
274 @temp = split ( /\n/ , $vpnsettings { 'ROUTES_PUSH' });
277 @tempovpnsubnet = split ( "\/" ,& General
:: ipcidr2msk
( $_ ));
278 print CONF
"push \" route " . $tempovpnsubnet [ 0 ]. " " . $tempovpnsubnet [ 1 ] . " \"\n " ;
283 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
284 foreach my $key ( keys %ccdconfhash ) {
285 my $a = $ccdconfhash { $key }[ 1 ];
286 my ( $b , $c ) = split ( /\/ /, $a );
287 print CONF
"route $b " .& General
:: cidrtosub
( $c ). " \n " ;
290 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
291 foreach my $key ( keys %ccdroutehash ) {
292 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
293 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
294 print CONF
"route $a $b \n " ;
299 if ( $sovpnsettings { CLIENT2CLIENT
} eq 'on' ) {
300 print CONF
"client-to-client \n " ;
302 if ( $sovpnsettings { MSSFIX
} eq 'on' ) {
303 print CONF
"mssfix \n " ;
305 if ( $sovpnsettings { FRAGMENT
} ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' ) {
306 print CONF
"fragment $sovpnsettings {'FRAGMENT'} \n " ;
309 # Check if a valid operating mode has been choosen and use it.
310 if (( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
311 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
312 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'no' )) {
313 print CONF
"mtu-disc $sovpnsettings {'PMTU_DISCOVERY'} \n " ;
316 if ( $sovpnsettings { KEEPALIVE_1
} > 0 && $sovpnsettings { KEEPALIVE_2
} > 0 ) {
317 print CONF
"keepalive $sovpnsettings {'KEEPALIVE_1'} $sovpnsettings {'KEEPALIVE_2'} \n " ;
319 print CONF
"status-version 1 \n " ;
320 print CONF
"status /var/log/ovpnserver.log 30 \n " ;
321 print CONF
"cipher $sovpnsettings {DCIPHER} \n " ;
322 if ( $sovpnsettings { 'DAUTH' } eq '' ) {
325 print CONF
"auth $sovpnsettings {'DAUTH'} \n " ;
327 if ( $sovpnsettings { 'TLSAUTH' } eq 'on' ) {
328 print CONF
"tls-auth ${General::swroot}/ovpn/ca/ta.key 0 \n " ;
330 if ( $sovpnsettings { ENGINES
} eq 'disabled' ) {
333 print CONF
"engine $sovpnsettings {ENGINES} \n " ;
335 if ( $sovpnsettings { DCOMPLZO
} eq 'on' ) {
336 print CONF
"comp-lzo \n " ;
338 if ( $sovpnsettings { REDIRECT_GW_DEF1
} eq 'on' ) {
339 print CONF
"push \" redirect-gateway def1 \"\n " ;
341 if ( $sovpnsettings { DHCP_DOMAIN
} ne '' ) {
342 print CONF
"push \" dhcp-option DOMAIN $sovpnsettings {DHCP_DOMAIN} \"\n " ;
345 if ( $sovpnsettings { DHCP_DNS
} ne '' ) {
346 print CONF
"push \" dhcp-option DNS $sovpnsettings {DHCP_DNS} \"\n " ;
349 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
350 print CONF
"push \" dhcp-option WINS $sovpnsettings {DHCP_WINS} \"\n " ;
353 if ( $sovpnsettings { DHCP_WINS
} eq '' ) {
354 print CONF
"max-clients 100 \n " ;
356 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
357 print CONF
"max-clients $sovpnsettings {MAX_CLIENTS} \n " ;
359 print CONF
"tls-verify /usr/lib/openvpn/verify \n " ;
360 print CONF
"crl-verify /var/ipfire/ovpn/crls/cacrl.pem \n " ;
361 print CONF
"user nobody \n " ;
362 print CONF
"group nobody \n " ;
363 print CONF
"persist-key \n " ;
364 print CONF
"persist-tun \n " ;
365 if ( $sovpnsettings { LOG_VERB
} ne '' ) {
366 print CONF
"verb $sovpnsettings {LOG_VERB} \n " ;
368 print CONF
"verb 3 \n " ;
376 if ( open ( FILE
, ">/var/log/ovpnserver.log" )) {
386 my %ccdconfhash = ();
388 my $ccdnetname = $_ [ 0 ];
389 if (- f
"${General::swroot}/ovpn/ovpnconfig" ){
390 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
391 foreach my $key ( keys %ccdhash ) {
392 if ( $ccdhash { $key }[ 32 ] eq $ccdnetname ) {
393 $errormessage = $Lang :: tr
{ 'ccd err hostinnet' };
398 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
399 foreach my $key ( keys %ccdconfhash ) {
400 if ( $ccdconfhash { $key }[ 0 ] eq $ccdnetname ){
401 delete $ccdconfhash { $key };
404 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
426 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err name' }. "<br>" ;
430 if (!& General
:: validhostname
( $ccdname ))
432 $errormessage = $Lang :: tr
{ 'ccd err invalidname' };
436 ( $ccdip , $subcidr ) = split ( /\/ /, $ccdnet );
437 $subcidr =& General
:: iporsubtocidr
( $subcidr );
441 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
445 if (!& General
:: validipandmask
( $ccdnet )){
446 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
450 $errormessage =& General
:: checksubnets
( $ccdname , $ccdnet );
453 if (! $errormessage ) {
455 $baseaddress =& General
:: getnetworkip
( $ccdip , $subcidr );
456 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
457 my $key = & General
:: findhasharraykey
( \
%ccdconfhash );
458 foreach my $i ( 0 .. 1 ) { $ccdconfhash { $key }[ $i ] = "" ;}
459 $ccdconfhash { $key }[ 0 ] = $ccdname ;
460 $ccdconfhash { $key }[ 1 ] = $baseaddress . "/" . $subcidr ;
461 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
463 $cgiparams { 'ccdname' }= '' ;
464 $cgiparams { 'ccdsubnet' }= '' ;
476 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
477 foreach my $key ( keys %ccdconfhash ) {
478 if ( $ccdconfhash { $key }[ 0 ] eq $oldname ) {
479 foreach my $key1 ( keys %ccdconfhash ) {
480 if ( $ccdconfhash { $key1 }[ 0 ] eq $newname ){
481 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err netadrexist' };
484 $ccdconfhash { $key }[ 0 ]= $newname ;
485 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
492 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
493 foreach my $key ( keys %ccdhash ) {
494 if ( $ccdhash { $key }[ 32 ] eq $oldname ) {
495 $ccdhash { $key }[ 32 ]= $newname ;
496 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
505 my $ccdnetwork = $_ [ 0 ];
508 @octets = split ( "\/" , $ccdnetwork );
509 @subnet = split /\./ , & General
:: cidrtosub
( $octets [ 1 ]);
522 my ( $ip1 , $ip2 , $ip3 , $ip4 )= split /\./ , $ipin ;
530 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
531 $iprange [ 0 ]= $ip1 . "." . $ip2 . "." . $ip3 . "." .( $ip4 + 2 );
532 for ( my $i = 1 ; $i <= $count ; $i ++) {
533 my $tmpip = $iprange [ $i - 1 ];
535 $iprange [ $i ]= & General
:: getnextip
( $tmpip , 4 );
538 foreach my $key ( keys %ccdhash ) {
540 foreach my $tmp ( @iprange ){
541 my ( $net , $sub ) = split ( /\/ /, $ccdhash { $key }[ 33 ]);
543 if ( $hasip ne $ccdhash { $key }[ 33 ] ){
544 splice ( @iprange , $r , 1 );
556 my ( $ccdip , $subcidr ) = split ( "/" , $_ [ 0 ]);
558 my @allccdips =& getccdadresses
( $ccdip , $subcidr ,& ccdmaxclients
( $ccdip . "/" . $subcidr ), $tz );
559 print "<select name=' $boxname ' STYLE='font-family : arial; font-size : 9pt; width:130px;' >" ;
560 foreach ( @allccdips ) {
563 print "<option value=' $ip ' " ;
564 if ( $ip eq $cgiparams { $boxname } ){
567 print "> $ip </option>" ;
577 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
578 foreach my $key ( keys %ccdhash ) {
579 if ( $ccdhash { $key }[ 32 ] eq $name ){ $i ++;}
584 sub check_routes_push
587 my ( $ip , $cidr ) = split ( /\/ /, $val );
588 ##check for existing routes in routes_push
589 if (- e
"${General::swroot}/ovpn/routes_push" ) {
590 open ( FILE
, "${General::swroot}/ovpn/routes_push" );
594 my ( $ip2 , $cidr2 ) = split ( /\/ /, " $_ " );
595 my $val2 = $ip2 . "/" .& General
:: iporsubtodec
( $cidr2 );
601 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: iporsubtodec
( $cidr2 ))){
614 my ( $ip , $cidr ) = split ( /\/ /, $val );
615 #check for existing routes in ccdroute
616 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
617 foreach my $key ( keys %ccdroutehash ) {
618 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
619 if (& General
:: iporsubtodec
( $val ) eq $ccdroutehash { $key }[ $i ] && $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' }){
622 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
624 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )&& $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' } ){
635 my ( $ip , $cidr ) = split ( /\/ /, $val );
636 #check for existing routes in ccdroute
637 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
638 foreach my $key ( keys %ccdconfhash ) {
639 if (& General
:: iporsubtocidr
( $val ) eq $ccdconfhash { $key }[ 1 ]){
642 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdconfhash { $key }[ 1 ]);
644 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: cidrtosub
( $cidr2 ))){
658 my $ipdotmask = $_ [ 0 ];
659 if (& General
:: validip
( $ipdotmask )) { return 0 ; }
660 if (!( $ipdotmask =~ /^(.*?)\/ (.* ?
)$/)) { }
662 if (( $mask =~ /\./ )) { return 0 ; }
666 # -------------------------------------------------------------------
668 sub write_routepushfile
670 open ( FILE
, "> $routes_push_file " );
672 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
673 print FILE
$vpnsettings { 'ROUTES_PUSH' };
678 sub read_routepushfile
680 if (- e
" $routes_push_file " ) {
681 open ( FILE
, " $routes_push_file " );
682 delete $vpnsettings { 'ROUTES_PUSH' };
683 while (< FILE
>) { $vpnsettings { 'ROUTES_PUSH' } .= $_ };
685 $cgiparams { 'ROUTES_PUSH' } = $vpnsettings { 'ROUTES_PUSH' };
691 #hier die refresh page
692 if ( - e
"${General::swroot}/ovpn/gencanow" ) {
694 $refresh = "<meta http-equiv='refresh' content='15;' />" ;
695 & Header
:: showhttpheaders
();
696 & Header
:: openpage
( $Lang :: tr
{ 'OVPN' }, 1 , $refresh );
697 & Header
:: openbigbox
( '100%' , 'center' );
698 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
699 print "<tr> \n <td align='center'><img src='/images/clock.gif' alt='' /></td> \n " ;
700 print "<td colspan='2'><font color='red'>Please be patient this realy can take some time on older hardware...</font></td></tr> \n " ;
702 & Header
:: closebigbox
();
703 & Header
:: closepage
();
706 ##hier die refresh page
710 ### OpenVPN Server Control
712 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' } ||
713 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' } ||
714 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart ovpn server' }) {
715 #start openvpn server
716 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' }){
718 system ( '/usr/local/bin/openvpnctrl' , '-s' );
721 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' }){
722 system ( '/usr/local/bin/openvpnctrl' , '-k' );
725 # #restart openvpn server
726 # if ($cgiparams{'ACTION'} eq $Lang::tr{'restart ovpn server'}){
727 #workarund, till SIGHUP also works when running as nobody
728 # system('/usr/local/bin/openvpnctrl', '-r');
734 ### Save Advanced options
737 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save-adv-options' }) {
738 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
739 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
740 #DAN this value has to leave.
741 #new settings for daemon
742 $vpnsettings { 'LOG_VERB' } = $cgiparams { 'LOG_VERB' };
743 $vpnsettings { 'KEEPALIVE_1' } = $cgiparams { 'KEEPALIVE_1' };
744 $vpnsettings { 'KEEPALIVE_2' } = $cgiparams { 'KEEPALIVE_2' };
745 $vpnsettings { 'MAX_CLIENTS' } = $cgiparams { 'MAX_CLIENTS' };
746 $vpnsettings { 'REDIRECT_GW_DEF1' } = $cgiparams { 'REDIRECT_GW_DEF1' };
747 $vpnsettings { 'CLIENT2CLIENT' } = $cgiparams { 'CLIENT2CLIENT' };
748 $vpnsettings { 'DHCP_DOMAIN' } = $cgiparams { 'DHCP_DOMAIN' };
749 $vpnsettings { 'DHCP_DNS' } = $cgiparams { 'DHCP_DNS' };
750 $vpnsettings { 'DHCP_WINS' } = $cgiparams { 'DHCP_WINS' };
751 $vpnsettings { 'ROUTES_PUSH' } = $cgiparams { 'ROUTES_PUSH' };
752 $vpnsettings { 'PMTU_DISCOVERY' } = $cgiparams { 'PMTU_DISCOVERY' };
753 $vpnsettings { 'DAUTH' } = $cgiparams { 'DAUTH' };
754 $vpnsettings { 'TLSAUTH' } = $cgiparams { 'TLSAUTH' };
755 $vpnsettings { 'ENGINES' } = $cgiparams { 'ENGINES' };
758 if ( $cgiparams { 'FRAGMENT' } eq '' ) {
759 delete $vpnsettings { 'FRAGMENT' };
761 if ( $cgiparams { 'FRAGMENT' } !~ /^[0-9]+$/ ) {
762 $errormessage = "Incorrect value, please insert only numbers." ;
765 $vpnsettings { 'FRAGMENT' } = $cgiparams { 'FRAGMENT' };
769 if ( $cgiparams { 'MSSFIX' } ne 'on' ) {
770 delete $vpnsettings { 'MSSFIX' };
772 $vpnsettings { 'MSSFIX' } = $cgiparams { 'MSSFIX' };
775 # Create ta.key for tls-auth if not presant
776 if ( $cgiparams { 'TLSAUTH' } eq 'on' ) {
777 if ( ! - e
"${General::swroot}/ovpn/ca/ta.key" ) {
778 system ( '/usr/sbin/openvpn' , '--genkey' , '--secret' , "${General::swroot}/ovpn/ca/ta.key" )
782 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
783 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
784 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
786 if (( $cgiparams { 'MSSFIX' } eq 'on' ) || ( $cgiparams { 'FRAGMENT' } ne '' )) {
787 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
792 if ( $cgiparams { 'DHCP_DOMAIN' } ne '' ){
793 unless (& General
:: validdomainname
( $cgiparams { 'DHCP_DOMAIN' }) || & General
:: validip
( $cgiparams { 'DHCP_DOMAIN' })) {
794 $errormessage = $Lang :: tr
{ 'invalid input for dhcp domain' };
798 if ( $cgiparams { 'DHCP_DNS' } ne '' ){
799 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_DNS' }) || & General
:: validip
( $cgiparams { 'DHCP_DNS' })) {
800 $errormessage = $Lang :: tr
{ 'invalid input for dhcp dns' };
804 if ( $cgiparams { 'DHCP_WINS' } ne '' ){
805 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_WINS' }) || & General
:: validip
( $cgiparams { 'DHCP_WINS' })) {
806 $errormessage = $Lang :: tr
{ 'invalid input for dhcp wins' };
810 if ( $cgiparams { 'ROUTES_PUSH' } ne '' ){
811 @temp = split ( /\n/ , $cgiparams { 'ROUTES_PUSH' });
812 undef $vpnsettings { 'ROUTES_PUSH' };
814 foreach my $tmpip ( @temp )
816 s/^\s+//g ; s/\s+$//g ;
821 unless (& General
:: validipandmask
( $tmpip )) {
822 $errormessage = " $tmpip " . $Lang :: tr
{ 'ovpn errmsg invalid ip or mask' };
825 my ( $ip , $cidr ) = split ( "\/" ,& General
:: ipcidr2msk
( $tmpip ));
827 if ( $ip eq $netsettings { 'GREEN_NETADDRESS' } && $cidr eq $netsettings { 'GREEN_NETMASK' }) {
828 $errormessage = $Lang :: tr
{ 'ovpn errmsg green already pushed' };
833 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
834 foreach my $key ( keys %ccdroutehash ) {
835 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
836 if ( $ip . "/" . $cidr eq $ccdroutehash { $key }[ $i ] ){
837 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
840 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
841 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )){
842 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
850 $vpnsettings { 'ROUTES_PUSH' } .= $tmpip . " \n " ;
853 & write_routepushfile
;
854 undef $vpnsettings { 'ROUTES_PUSH' };
857 undef $vpnsettings { 'ROUTES_PUSH' };
858 & write_routepushfile
;
860 if (( length ( $cgiparams { 'MAX_CLIENTS' }) == 0 ) || (( $cgiparams { 'MAX_CLIENTS' }) < 1 ) || (( $cgiparams { 'MAX_CLIENTS' }) > 255 )) {
861 $errormessage = $Lang :: tr
{ 'invalid input for max clients' };
864 if ( $cgiparams { 'KEEPALIVE_1' } ne '' ) {
865 if ( $cgiparams { 'KEEPALIVE_1' } !~ /^[0-9]+$/ ) {
866 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1' };
870 if ( $cgiparams { 'KEEPALIVE_2' } ne '' ){
871 if ( $cgiparams { 'KEEPALIVE_2' } !~ /^[0-9]+$/ ) {
872 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 2' };
876 if ( $cgiparams { 'KEEPALIVE_2' } < ( $cgiparams { 'KEEPALIVE_1' } * 2 )){
877 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1:2' };
881 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
882 & writeserverconf
(); #hier ok
889 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'server' )
892 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
893 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
894 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
897 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
898 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
900 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: $!" ;
903 print SERVERCONF
"# IPFire n2n Open VPN Server Config by ummeegge und m.a.d \n " ;
904 print SERVERCONF
" \n " ;
905 print SERVERCONF
"# User Security \n " ;
906 print SERVERCONF
"user nobody \n " ;
907 print SERVERCONF
"group nobody \n " ;
908 print SERVERCONF
"persist-tun \n " ;
909 print SERVERCONF
"persist-key \n " ;
910 print SERVERCONF
"script-security 2 \n " ;
911 print SERVERCONF
"# IP/DNS for remote Server Gateway \n " ;
913 if ( $cgiparams { 'REMOTE' } ne '' ) {
914 print SERVERCONF
"remote $cgiparams {'REMOTE'} \n " ;
917 print SERVERCONF
"float \n " ;
918 print SERVERCONF
"# IP adresses of the VPN Subnet \n " ;
919 print SERVERCONF
"ifconfig $ovsubnet .1 $ovsubnet .2 \n " ;
920 print SERVERCONF
"# Client Gateway Network \n " ;
921 print SERVERCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
922 print SERVERCONF
"# tun Device \n " ;
923 print SERVERCONF
"dev tun \n " ;
924 print SERVERCONF
"# Port and Protokol \n " ;
925 print SERVERCONF
"port $cgiparams {'DEST_PORT'} \n " ;
927 if ( $cgiparams { 'PROTOCOL' } eq 'tcp' ) {
928 print SERVERCONF
"proto tcp-server \n " ;
929 print SERVERCONF
"# Packet size \n " ;
930 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1400' } else { $tunmtu = $cgiparams { 'MTU' }};
931 print SERVERCONF
"tun-mtu $tunmtu \n " ;
934 if ( $cgiparams { 'PROTOCOL' } eq 'udp' ) {
935 print SERVERCONF
"proto udp \n " ;
936 print SERVERCONF
"# Paketsize \n " ;
937 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
938 print SERVERCONF
"tun-mtu $tunmtu \n " ;
939 if ( $cgiparams { 'FRAGMENT' } ne '' ) { print SERVERCONF
"fragment $cgiparams {'FRAGMENT'} \n " ;}
940 if ( $cgiparams { 'MSSFIX' } eq 'on' ) { print SERVERCONF
"mssfix \n " ; };
943 # Check if a valid operating mode has been choosen and use it.
944 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
945 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
946 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
947 if (( $cgiparams { 'MSSFIX' } ne 'on' ) || ( $cgiparams { 'FRAGMENT' } eq '' )) {
948 if ( $cgiparams { 'MTU' } eq '1500' ) {
949 print SERVERCONF
"mtu-disc $cgiparams {'PMTU_DISCOVERY'} \n " ;
953 print SERVERCONF
"# Auth. Server \n " ;
954 print SERVERCONF
"tls-server \n " ;
955 print SERVERCONF
"ca ${General::swroot}/ovpn/ca/cacert.pem \n " ;
956 print SERVERCONF
"cert ${General::swroot}/ovpn/certs/servercert.pem \n " ;
957 print SERVERCONF
"key ${General::swroot}/ovpn/certs/serverkey.pem \n " ;
958 print SERVERCONF
"dh ${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'} \n " ;
959 print SERVERCONF
"# Cipher \n " ;
960 print SERVERCONF
"cipher $cgiparams {'DCIPHER'} \n " ;
961 if ( $cgiparams { 'DAUTH' } eq '' ) {
962 print SERVERCONF
"auth SHA1 \n " ;
964 print SERVERCONF
"# HMAC algorithm \n " ;
965 print SERVERCONF
"auth $cgiparams {'DAUTH'} \n " ;
967 if ( $cgiparams { 'ENGINES' } eq 'disabled' ) {
970 print SERVERCONF
"# Crypto engine \n " ;
971 print SERVERCONF
"engine $cgiparams {'ENGINES'} \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 $cgiparams {'DCIPHER'} \n " ;
1060 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12 \r\n " ;
1061 if ( $cgiparams { 'DAUTH' } eq '' ) {
1062 print CLIENTCONF
"auth SHA1 \n " ;
1064 print CLIENTCONF
"# HMAC algorithm \n " ;
1065 print CLIENTCONF
"auth $cgiparams {'DAUTH'} \n " ;
1067 if ( $cgiparams { 'ENGINES' } eq 'disabled' ) {
1068 print CLIENTCONF
"" ;
1070 print CLIENTCONF
"# Crypto engine \n " ;
1071 print CLIENTCONF
"engine $cgiparams {'ENGINES'} \n " ;
1073 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
1074 print CLIENTCONF
"# Enable Compression \n " ;
1075 print CLIENTCONF
"comp-lzo \r\n " ;
1077 print CLIENTCONF
"# Debug Level \n " ;
1078 print CLIENTCONF
"verb 3 \n " ;
1079 print CLIENTCONF
"# Tunnel check \n " ;
1080 print CLIENTCONF
"keepalive 10 60 \n " ;
1081 print CLIENTCONF
"# Start as daemon \n " ;
1082 print CLIENTCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
1083 print CLIENTCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
1084 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
1085 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) { print CLIENTCONF
"management localhost $cgiparams {'DEST_PORT'} \n " }
1086 else { print CLIENTCONF
"management localhost $cgiparams {'OVPN_MGMT'} \n " };
1092 ### Save main settings
1096 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
1097 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1098 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
1099 #DAN this value has to leave.
1100 if ( $cgiparams { 'ENABLED' } eq 'on' ){
1101 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })) {
1102 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1103 goto SETTINGS_ERROR
;
1106 if ( $errormessage ) { goto SETTINGS_ERROR
; }
1108 if ( $cgiparams { 'ENABLED' } eq 'on' ){
1109 & checkportfw
( $cgiparams { 'DDEST_PORT' }, $cgiparams { 'DPROTOCOL' });
1111 if ( $errormessage ) { goto SETTINGS_ERROR
; }
1113 if (! & General
:: validipandmask
( $cgiparams { 'DOVPN_SUBNET' })) {
1114 $errormessage = $Lang :: tr
{ 'ovpn subnet is invalid' };
1115 goto SETTINGS_ERROR
;
1117 my @tmpovpnsubnet = split ( "\/" , $cgiparams { 'DOVPN_SUBNET' });
1119 if (& General
:: IpInSubnet
( $netsettings { 'RED_ADDRESS' },
1120 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1121 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire RED Network $netsettings {'RED_ADDRESS'}" ;
1122 goto SETTINGS_ERROR
;
1125 if (& General
:: IpInSubnet
( $netsettings { 'GREEN_ADDRESS' },
1126 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1127 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Green Network $netsettings {'GREEN_ADDRESS'}" ;
1128 goto SETTINGS_ERROR
;
1131 if (& General
:: IpInSubnet
( $netsettings { 'BLUE_ADDRESS' },
1132 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1133 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Blue Network $netsettings {'BLUE_ADDRESS'}" ;
1134 goto SETTINGS_ERROR
;
1137 if (& General
:: IpInSubnet
( $netsettings { 'ORANGE_ADDRESS' },
1138 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1139 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Orange Network $netsettings {'ORANGE_ADDRESS'}" ;
1140 goto SETTINGS_ERROR
;
1142 open ( ALIASES
, "${General::swroot}/ethernet/aliases" ) or die 'Unable to open aliases file.' ;
1146 my @tempalias = split ( /\,/ , $_ );
1147 if ( $tempalias [ 1 ] eq 'on' ) {
1148 if (& General
:: IpInSubnet
( $tempalias [ 0 ] ,
1149 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1150 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire alias entry $tempalias [0]" ;
1155 if ( $errormessage ne '' ){
1156 goto SETTINGS_ERROR
;
1158 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1159 $errormessage = $Lang :: tr
{ 'invalid input' };
1160 goto SETTINGS_ERROR
;
1162 if (( length ( $cgiparams { 'DMTU' })== 0 ) || (( $cgiparams { 'DMTU' }) < 1000 )) {
1163 $errormessage = $Lang :: tr
{ 'invalid mtu input' };
1164 goto SETTINGS_ERROR
;
1167 unless (& General
:: validport
( $cgiparams { 'DDEST_PORT' })) {
1168 $errormessage = $Lang :: tr
{ 'invalid port' };
1169 goto SETTINGS_ERROR
;
1172 $vpnsettings { 'ENABLED_BLUE' } = $cgiparams { 'ENABLED_BLUE' };
1173 $vpnsettings { 'ENABLED_ORANGE' } = $cgiparams { 'ENABLED_ORANGE' };
1174 $vpnsettings { 'ENABLED' } = $cgiparams { 'ENABLED' };
1175 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
1176 #new settings for daemon
1177 $vpnsettings { 'DOVPN_SUBNET' } = $cgiparams { 'DOVPN_SUBNET' };
1178 $vpnsettings { 'DDEVICE' } = $cgiparams { 'DDEVICE' };
1179 $vpnsettings { 'DPROTOCOL' } = $cgiparams { 'DPROTOCOL' };
1180 $vpnsettings { 'DDEST_PORT' } = $cgiparams { 'DDEST_PORT' };
1181 $vpnsettings { 'DMTU' } = $cgiparams { 'DMTU' };
1182 $vpnsettings { 'DCOMPLZO' } = $cgiparams { 'DCOMPLZO' };
1183 $vpnsettings { 'DCIPHER' } = $cgiparams { 'DCIPHER' };
1186 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" );}
1187 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" );}
1188 if ( $vpnsettings { 'ENABLED' } eq 'on' ) { system ( "touch ${General::swroot}/ovpn/enable 2>/dev/null" );} else { system ( "unlink ${General::swroot}/ovpn/enable 2>/dev/null" );}
1189 #new settings for daemon
1190 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1191 & writeserverconf
(); #hier ok
1194 ### Reset all step 2
1196 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1198 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1200 foreach my $key ( keys %confighash ) {
1201 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
1202 delete $confighash { $cgiparams { ' $key ' }};
1205 while ( $file = glob ( "${General::swroot}/ovpn/ca/*" )) {
1208 while ( $file = glob ( "${General::swroot}/ovpn/certs/*" )) {
1211 while ( $file = glob ( "${General::swroot}/ovpn/crls/*" )) {
1214 & cleanssldatabase
();
1215 if ( open ( FILE
, ">${General::swroot}/ovpn/caconfig" )) {
1219 if ( open ( FILE
, ">${General::swroot}/ovpn/ccdroute" )) {
1223 if ( open ( FILE
, ">${General::swroot}/ovpn/ccdroute2" )) {
1227 while ( $file = glob ( "${General::swroot}/ovpn/ccd/*" )) {
1230 if ( open ( FILE
, ">${General::swroot}/ovpn/ovpn-leases.db" )) {
1234 if ( open ( FILE
, ">${General::swroot}/ovpn/ovpnconfig" )) {
1238 while ( $file = glob ( "${General::swroot}/ovpn/n2nconf/*" )) {
1239 system ( "rm -rf $file " );
1242 #&writeserverconf();
1244 ### Reset all step 1
1246 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' }) {
1247 & Header
:: showhttpheaders
();
1248 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1249 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1250 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
1252 <form method='post'>
1253 <table width='100%'>
1256 <input type='hidden' name='AREUSURE' value='yes' />
1257 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1258 $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}</td>
1261 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' />
1262 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
1269 & Header
:: closebox
();
1270 & Header
:: closebigbox
();
1271 & Header
:: closepage
();
1275 ### Generate DH key step 2
1277 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate dh key' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1278 # Delete if old key exists
1279 if (- f
"${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ) {
1280 unlink "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ;
1282 # Create Diffie Hellmann Parameter
1283 system ( '/usr/bin/openssl' , 'dhparam' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1284 '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" , " $cgiparams {'DHLENGHT'}" );
1286 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1287 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1291 ### Generate DH key step 1
1293 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate dh key' }) {
1294 & Header
:: showhttpheaders
();
1295 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1296 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1297 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'gen dh'}:" );
1299 <table width='100%'>
1301 <td width='15%'> </td> <td width='15%'></td> <td width='65%'></td>
1304 <td class='base'> $Lang ::tr{'ovpn dh'}:</td>
1306 <form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1307 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1308 <select name='DHLENGHT'>
1309 <option value='1024' $selected {'DHLENGHT'}{'1024'}>1024 $Lang ::tr{'bit'}</option>
1310 <option value='2048' $selected {'DHLENGHT'}{'2048'}>2048 $Lang ::tr{'bit'}</option>
1311 <option value='3072' $selected {'DHLENGHT'}{'3072'}>3072 $Lang ::tr{'bit'}</option>
1312 <option value='4096' $selected {'DHLENGHT'}{'4096'}>4096 $Lang ::tr{'bit'}</option>
1316 <tr><td colspan='4'><br></td></tr>
1318 <table width='100%'>
1320 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}: </font></b> $Lang ::tr{'dh key warn'}
1323 <td class='base'> $Lang ::tr{'dh key warn1'}</td>
1325 <tr><td colspan='2'><br></td></tr>
1327 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'generate dh key'}' /></td>
1334 & Header
:: closebox
();
1335 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1336 & Header
:: closebigbox
();
1337 & Header
:: closepage
();
1343 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload dh key' }) {
1344 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1345 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1346 goto UPLOADCA_ERROR
;
1348 # Move uploaded dh key to a temporary file
1349 ( my $fh , my $filename ) = tempfile
( );
1350 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1352 goto UPLOADCA_ERROR
;
1354 my $temp = `/usr/bin/openssl dhparam -text -in $filename ` ;
1355 if ( $temp !~ /DH Parameters: \((1024|2048|3072|4096) bit\)/ ) {
1356 $errormessage = $Lang :: tr
{ 'not a valid dh key' };
1358 goto UPLOADCA_ERROR
;
1360 # Delete if old key exists
1361 if (- f
"${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ) {
1362 unlink "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ;
1364 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" );
1366 $errormessage = " $Lang ::tr{'dh key move failed'}: $!" ;
1368 goto UPLOADCA_ERROR
;
1373 ### Upload CA Certificate
1375 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
1376 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1378 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1379 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1380 goto UPLOADCA_ERROR
;
1383 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
1384 $errormessage = $Lang :: tr
{ 'name too long' };
1388 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
1389 $errormessage = $Lang :: tr
{ 'name is invalid' };
1390 goto UPLOAD_CA_ERROR
;
1393 # Check if there is no other entry with this name
1394 foreach my $key ( keys %cahash ) {
1395 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
1396 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
1397 goto UPLOADCA_ERROR
;
1401 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1402 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1403 goto UPLOADCA_ERROR
;
1405 # Move uploaded ca to a temporary file
1406 ( my $fh , my $filename ) = tempfile
( );
1407 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1409 goto UPLOADCA_ERROR
;
1411 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
1412 if ( $temp !~ /CA:TRUE/i ) {
1413 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1415 goto UPLOADCA_ERROR
;
1417 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1419 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1421 goto UPLOADCA_ERROR
;
1425 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem` ;
1426 $casubject =~ /Subject: (.*)[\n]/ ;
1428 $casubject =~ s
+/ Email
+, E
+;
1429 $casubject =~ s/ ST=/ S=/ ;
1430 $casubject = & Header
:: cleanhtml
( $casubject );
1432 my $key = & General
:: findhasharraykey
( \
%cahash );
1433 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1434 $cahash { $key }[ 1 ] = $casubject ;
1435 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1436 # system('/usr/local/bin/ipsecctrl', 'R');
1441 ### Display ca certificate
1443 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
1444 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1446 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1447 & Header
:: showhttpheaders
();
1448 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1449 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1450 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ca certificate'}:" );
1451 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1452 $output = & Header
:: cleanhtml
( $output , "y" );
1453 print "<pre> $output </pre> \n " ;
1454 & Header
:: closebox
();
1455 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1456 & Header
:: closebigbox
();
1457 & Header
:: closepage
();
1460 $errormessage = $Lang :: tr
{ 'invalid key' };
1464 ### Download ca certificate
1466 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
1467 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1469 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1470 print "Content-Type: application/octet-stream \r\n " ;
1471 print "Content-Disposition: filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
1472 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1475 $errormessage = $Lang :: tr
{ 'invalid key' };
1479 ### Remove ca certificate (step 2)
1481 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1482 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1483 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1485 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1486 foreach my $key ( keys %confighash ) {
1487 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` ;
1488 if ( $test =~ /: OK/ ) {
1490 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1491 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
1492 # system('/usr/local/bin/ipsecctrl', 'D', $key);
1494 unlink ( "${General::swroot}/ovpn//certs/ $confighash { $key }[1]cert.pem" );
1495 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" );
1496 delete $confighash { $key };
1497 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1498 # &writeipsecfiles();
1501 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1502 delete $cahash { $cgiparams { 'KEY' }};
1503 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1504 # system('/usr/local/bin/ipsecctrl', 'R');
1506 $errormessage = $Lang :: tr
{ 'invalid key' };
1509 ### Remove ca certificate (step 1)
1511 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
1512 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1513 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1515 my $assignedcerts = 0 ;
1516 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1517 foreach my $key ( keys %confighash ) {
1518 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` ;
1519 if ( $test =~ /: OK/ ) {
1523 if ( $assignedcerts ) {
1524 & Header
:: showhttpheaders
();
1525 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1526 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1527 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'are you sure' });
1529 <table><form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1530 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1531 <tr><td align='center'>
1532 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>: $assignedcerts
1533 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}
1534 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
1535 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td></tr>
1539 & Header
:: closebox
();
1540 & Header
:: closebigbox
();
1541 & Header
:: closepage
();
1544 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1545 delete $cahash { $cgiparams { 'KEY' }};
1546 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1547 # system('/usr/local/bin/ipsecctrl', 'R');
1550 $errormessage = $Lang :: tr
{ 'invalid key' };
1554 ### Display root certificate
1556 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
1557 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
1559 & Header
:: showhttpheaders
();
1560 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1561 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1562 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
1563 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'root certificate'}:" );
1564 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1566 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'host certificate'}:" );
1567 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1569 $output = & Header
:: cleanhtml
( $output , "y" );
1570 print "<pre> $output </pre> \n " ;
1571 & Header
:: closebox
();
1572 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1573 & Header
:: closebigbox
();
1574 & Header
:: closepage
();
1578 ### Download root certificate
1580 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
1581 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1582 print "Content-Type: application/octet-stream \r\n " ;
1583 print "Content-Disposition: filename=cacert.pem \r\n\r\n " ;
1584 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1589 ### Download host certificate
1591 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
1592 if ( - f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
1593 print "Content-Type: application/octet-stream \r\n " ;
1594 print "Content-Disposition: filename=servercert.pem \r\n\r\n " ;
1595 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1599 ### Form for generating a root certificate
1601 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
1602 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1604 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1605 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1606 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
1607 $cgiparams { 'ACTION' } = '' ;
1608 goto ROOTCERT_ERROR
;
1611 if (( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) && - e
"${General::swroot}/red/active" ) {
1612 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
1613 my $ipaddr = < IPADDR
>;
1616 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
1617 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
1618 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
1621 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1623 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1624 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1625 goto ROOTCERT_ERROR
;
1628 # Move uploaded certificate request to a temporary file
1629 ( my $fh , my $filename ) = tempfile
( );
1630 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1632 goto ROOTCERT_ERROR
;
1635 # Create a temporary dirctory
1636 my $tempdir = tempdir
( CLEANUP
=> 1 );
1638 # Extract the CA certificate from the file
1639 my $pid = open ( OPENSSL
, "|-" );
1640 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1641 if ( $pid ) { # parent
1642 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1643 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1647 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1649 goto ROOTCERT_ERROR
;
1652 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-cacerts' , '-nokeys' ,
1654 '-out' , " $tempdir /cacert.pem" )) {
1655 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1657 goto ROOTCERT_ERROR
;
1661 # Extract the Host certificate from the file
1662 $pid = open ( OPENSSL
, "|-" );
1663 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1664 if ( $pid ) { # parent
1665 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1666 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1670 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1672 goto ROOTCERT_ERROR
;
1675 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-clcerts' , '-nokeys' ,
1677 '-out' , " $tempdir /hostcert.pem" )) {
1678 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1680 goto ROOTCERT_ERROR
;
1684 # Extract the Host key from the file
1685 $pid = open ( OPENSSL
, "|-" );
1686 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1687 if ( $pid ) { # parent
1688 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1689 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1693 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1695 goto ROOTCERT_ERROR
;
1698 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-nocerts' ,
1701 '-out' , " $tempdir /serverkey.pem" )) {
1702 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1704 goto ROOTCERT_ERROR
;
1708 move
( " $tempdir /cacert.pem" , "${General::swroot}/ovpn/ca/cacert.pem" );
1710 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1712 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1713 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1714 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1715 goto ROOTCERT_ERROR
;
1718 move
( " $tempdir /hostcert.pem" , "${General::swroot}/ovpn/certs/servercert.pem" );
1720 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1722 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1723 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1724 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1725 goto ROOTCERT_ERROR
;
1728 move
( " $tempdir /serverkey.pem" , "${General::swroot}/ovpn/certs/serverkey.pem" );
1730 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1732 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1733 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1734 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1735 goto ROOTCERT_ERROR
;
1738 goto ROOTCERT_SUCCESS
;
1740 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
1742 # Validate input since the form was submitted
1743 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
1744 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
1745 goto ROOTCERT_ERROR
;
1747 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
1748 $errormessage = $Lang :: tr
{ 'organization too long' };
1749 goto ROOTCERT_ERROR
;
1751 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1752 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1753 goto ROOTCERT_ERROR
;
1755 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
1756 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
1757 goto ROOTCERT_ERROR
;
1759 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
1760 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1761 goto ROOTCERT_ERROR
;
1763 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
1764 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1765 goto ROOTCERT_ERROR
;
1767 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
1768 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1769 goto ROOTCERT_ERROR
;
1771 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1772 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1773 goto ROOTCERT_ERROR
;
1775 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1776 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1777 goto ROOTCERT_ERROR
;
1779 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1780 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1781 goto ROOTCERT_ERROR
;
1783 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1784 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1785 goto ROOTCERT_ERROR
;
1788 # Copy the cgisettings to vpnsettings and save the configfile
1789 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
1790 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
1791 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
1792 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
1793 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
1794 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
1795 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
1796 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1798 # Replace empty strings with a .
1799 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
1800 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
1801 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
1804 #system ('/bin/touch', "${General::swroot}/ovpn/gencanow");
1806 # Create the CA certificate
1807 my $pid = open ( OPENSSL
, "|-" );
1808 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1809 if ( $pid ) { # parent
1810 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1811 print OPENSSL
" $state \n " ;
1812 print OPENSSL
" $city \n " ;
1813 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1814 print OPENSSL
" $ou \n " ;
1815 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
1816 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1819 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1820 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1821 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1822 goto ROOTCERT_ERROR
;
1825 unless ( exec ( '/usr/bin/openssl' , 'req' , '-x509' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1826 '-days' , '999999' , '-newkey' , 'rsa:4096' , '-sha512' ,
1827 '-keyout' , "${General::swroot}/ovpn/ca/cakey.pem" ,
1828 '-out' , "${General::swroot}/ovpn/ca/cacert.pem" ,
1829 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1830 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1831 goto ROOTCERT_ERROR
;
1835 # Create the Host certificate request
1836 $pid = open ( OPENSSL
, "|-" );
1837 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1838 if ( $pid ) { # parent
1839 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1840 print OPENSSL
" $state \n " ;
1841 print OPENSSL
" $city \n " ;
1842 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1843 print OPENSSL
" $ou \n " ;
1844 print OPENSSL
" $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1845 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1846 print OPENSSL
". \n " ;
1847 print OPENSSL
". \n " ;
1850 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1851 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1852 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1853 goto ROOTCERT_ERROR
;
1856 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1857 '-newkey' , 'rsa:2048' ,
1858 '-keyout' , "${General::swroot}/ovpn/certs/serverkey.pem" ,
1859 '-out' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1860 '-extensions' , 'server' ,
1861 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1862 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1863 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1864 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1865 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1866 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1867 goto ROOTCERT_ERROR
;
1871 # Sign the host certificate request
1872 system ( '/usr/bin/openssl' , 'ca' , '-days' , '999999' ,
1873 '-batch' , '-notext' ,
1874 '-in' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1875 '-out' , "${General::swroot}/ovpn/certs/servercert.pem" ,
1876 '-extensions' , 'server' ,
1877 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1879 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1880 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1881 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1882 unlink ( "${General::swroot}/ovpn/serverkey.pem" );
1883 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1884 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1885 & newcleanssldatabase
();
1886 goto ROOTCERT_ERROR
;
1888 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1889 & deletebackupcert
();
1892 # Create an empty CRL
1893 system ( '/usr/bin/openssl' , 'ca' , '-gencrl' ,
1894 '-out' , "${General::swroot}/ovpn/crls/cacrl.pem" ,
1895 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1897 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1898 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1899 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1900 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1901 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1902 & cleanssldatabase
();
1903 goto ROOTCERT_ERROR
;
1905 # &cleanssldatabase();
1907 # Create Diffie Hellmann Parameter
1908 system ( '/usr/bin/openssl' , 'dhparam' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1909 '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" , " $cgiparams {'DHLENGHT'}" );
1911 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1912 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1913 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1914 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1915 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1916 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1917 & cleanssldatabase
();
1918 goto ROOTCERT_ERROR
;
1920 # &cleanssldatabase();
1922 goto ROOTCERT_SUCCESS
;
1925 if ( $cgiparams { 'ACTION' } ne '' ) {
1926 & Header
:: showhttpheaders
();
1927 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1928 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1929 if ( $errormessage ) {
1930 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
1931 print "<class name='base'> $errormessage " ;
1932 print " </class>" ;
1933 & Header
:: closebox
();
1935 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'generate root/host certificates'}:" );
1937 <form method='post' enctype='multipart/form-data'>
1938 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1939 <tr><td width='30%' class='base'> $Lang ::tr{'organization name'}:</td>
1940 <td width='35%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td>
1941 <td width='35%' colspan='2'> </td></tr>
1942 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}:</td>
1943 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td>
1944 <td colspan='2'> </td></tr>
1945 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt'*' /></td>
1946 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td>
1947 <td colspan='2'> </td></tr>
1948 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt'*' /></td>
1949 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td>
1950 <td colspan='2'> </td></tr>
1951 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt'*' /></td>
1952 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td>
1953 <td colspan='2'> </td></tr>
1954 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt'*' /></td>
1955 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td>
1956 <td colspan='2'> </td></tr>
1957 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1958 <td class='base'><select name='ROOTCERT_COUNTRY'>
1962 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1963 print "<option value=' $Countries ::countries{ $country }'" ;
1964 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1965 print " selected='selected'" ;
1967 print "> $country </option>" ;
1971 <tr><td class='base'> $Lang ::tr{'ovpn dh'}:</td>
1972 <td class='base'><select name='DHLENGHT'>
1973 <option value='1024' $selected {'DHLENGHT'}{'1024'}>1024 $Lang ::tr{'bit'}</option>
1974 <option value='2048' $selected {'DHLENGHT'}{'2048'}>2048 $Lang ::tr{'bit'}</option>
1975 <option value='3072' $selected {'DHLENGHT'}{'3072'}>3072 $Lang ::tr{'bit'}</option>
1976 <option value='4096' $selected {'DHLENGHT'}{'4096'}>4096 $Lang ::tr{'bit'}</option>
1982 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /></td>
1983 <td> </td><td> </td></tr>
1984 <tr><td class='base' colspan='4' align='left'>
1985 <img src='/blob.gif' valign='top' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
1986 <tr><td colspan='2'><br></td></tr>
1987 <table width='100%'>
1989 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}: </font></b> $Lang ::tr{'ovpn generating the root and host certificates'}
1990 <td class='base'> $Lang ::tr{'dh key warn'}</td>
1993 <td class='base'> $Lang ::tr{'dh key warn1'}</td>
1995 <tr><td colspan='2'><br></td></tr>
1999 <table width='100%'>
2000 <tr><td colspan='4'><hr></td></tr>
2001 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
2002 <td nowrap='nowrap'><input type='file' name='FH' size='32'></td>
2003 <td colspan='2'> </td></tr>
2004 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' ></td>
2005 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td>
2006 <td colspan='2'> </td></tr>
2008 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td>
2009 <td colspan='2'> </td></tr>
2010 <tr><td class='base' colspan='4' align='left'>
2011 <img src='/blob.gif' valign='top' al='*' > $Lang ::tr{'this field may be blank'}</td></tr>
2015 & Header
:: closebox
();
2016 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2017 & Header
:: closebigbox
();
2018 & Header
:: closepage
();
2023 system ( "chmod 600 ${General::swroot}/ovpn/certs/serverkey.pem" );
2024 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2025 # $vpnsettings{'ENABLE_BLUE'} eq 'on') {
2026 # system('/usr/local/bin/ipsecctrl', 'S');
2030 ### Enable/Disable connection
2037 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
2039 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2040 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2041 # my $n2nactive = '';
2042 my $n2nactive = `/bin/ps ax|grep $confighash { $cgiparams {'KEY'}}[1]|grep -v grep|awk \' {print \ $1 } \' ` ;
2044 if ( $confighash { $cgiparams { 'KEY' }}) {
2045 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
2046 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
2047 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2049 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2050 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
2054 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
2055 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2057 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2058 if ( $n2nactive ne '' ){
2059 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
2063 $errormessage = $Lang :: tr
{ 'invalid key' };
2069 ### Download OpenVPN client package
2073 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'dl client arch' }) {
2074 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2075 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2077 my $clientovpn = '' ;
2079 my $tempdir = tempdir
( CLEANUP
=> 1 );
2080 my $zippath = " $tempdir /" ;
2086 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2088 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-Client.zip" ;
2089 my $zippathname = " $zippath $zipname " ;
2090 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1].conf" ;
2091 my @ovsubnettemp = split ( /\./ , $confighash { $cgiparams { 'KEY' }}[ 27 ]);
2092 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
2094 my @remsubnet = split ( /\/ /, $confighash { $cgiparams { 'KEY' }}[ 8 ]);
2095 my $n2nfragment = '' ;
2097 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2098 flock CLIENTCONF
, 2 ;
2100 my $zip = Archive
:: Zip
-> new ();
2101 print CLIENTCONF
"# IPFire n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
2102 print CLIENTCONF
"# \n " ;
2103 print CLIENTCONF
"# User Security \n " ;
2104 print CLIENTCONF
"user nobody \n " ;
2105 print CLIENTCONF
"group nobody \n " ;
2106 print CLIENTCONF
"persist-tun \n " ;
2107 print CLIENTCONF
"persist-key \n " ;
2108 print CLIENTCONF
"script-security 2 \n " ;
2109 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
2110 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} \n " ;
2111 print CLIENTCONF
"float \n " ;
2112 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
2113 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
2114 print CLIENTCONF
"# Server Gateway Network \n " ;
2115 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
2116 print CLIENTCONF
"# tun Device \n " ;
2117 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \n " ;
2118 print CLIENTCONF
"# Port and Protokoll \n " ;
2119 print CLIENTCONF
"port $confighash { $cgiparams {'KEY'}}[29] \n " ;
2121 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'tcp' ) {
2122 print CLIENTCONF
"proto tcp-client \n " ;
2123 print CLIENTCONF
"# Packet size \n " ;
2124 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1400' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2125 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2128 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'udp' ) {
2129 print CLIENTCONF
"proto udp \n " ;
2130 print CLIENTCONF
"# Paketsize \n " ;
2131 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1500' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2132 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2133 if ( $confighash { $cgiparams { 'KEY' }}[ 24 ] ne '' ) { print CLIENTCONF
"fragment $confighash { $cgiparams {'KEY'}}[24] \n " ;}
2134 if ( $confighash { $cgiparams { 'KEY' }}[ 23 ] eq 'on' ) { print CLIENTCONF
"mssfix \n " ;}
2136 if (( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'yes' ) ||
2137 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'maybe' ) ||
2138 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'no' )) {
2139 if (( $confighash { $cgiparams { 'KEY' }}[ 23 ] ne 'on' ) || ( $confighash { $cgiparams { 'KEY' }}[ 24 ] eq '' )) {
2140 if ( $tunmtu eq '1500' ) {
2141 print CLIENTCONF
"mtu-disc $confighash { $cgiparams {'KEY'}}[38] \n " ;
2145 print CLIENTCONF
"ns-cert-type server \n " ;
2146 print CLIENTCONF
"# Auth. Client \n " ;
2147 print CLIENTCONF
"tls-client \n " ;
2148 print CLIENTCONF
"# Cipher \n " ;
2149 print CLIENTCONF
"cipher $confighash { $cgiparams {'KEY'}}[40] \n " ;
2150 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2151 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2152 $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 " ;
2154 if ( $confighash { $cgiparams { 'KEY' }}[ 39 ] eq '' ) {
2155 print CLIENTCONF
"# HMAC algorithm \n " ;
2156 print CLIENTCONF
"auth SHA1 \n " ;
2158 print CLIENTCONF
"# HMAC algorithm \n " ;
2159 print CLIENTCONF
"auth $confighash { $cgiparams {'KEY'}}[39] \n " ;
2161 if ( $confighash { $cgiparams { 'KEY' }}[ 30 ] eq 'on' ) {
2162 print CLIENTCONF
"# Enable Compression \n " ;
2163 print CLIENTCONF
"comp-lzo \r\n " ;
2165 print CLIENTCONF
"# Debug Level \n " ;
2166 print CLIENTCONF
"verb 3 \n " ;
2167 print CLIENTCONF
"# Tunnel check \n " ;
2168 print CLIENTCONF
"keepalive 10 60 \n " ;
2169 print CLIENTCONF
"# Start as daemon \n " ;
2170 print CLIENTCONF
"daemon $confighash { $cgiparams {'KEY'}}[1]n2n \n " ;
2171 print CLIENTCONF
"writepid /var/run/ $confighash { $cgiparams {'KEY'}}[1]n2n.pid \n " ;
2172 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
2173 if ( $confighash { $cgiparams { 'KEY' }}[ 22 ] eq '' ) { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[29] \n " }
2174 else { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[22] \n " };
2175 print CLIENTCONF
"# remsub $confighash { $cgiparams {'KEY'}}[11] \n " ;
2180 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2181 my $status = $zip -> writeToFileNamed ( $zippathname );
2183 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2184 @fileholder = < DLFILE
>;
2185 print "Content-Type:application/x-download \n " ;
2186 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2192 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.zip" ;
2193 my $zippathname = " $zippath $zipname " ;
2194 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.ovpn" ;
2200 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2201 flock CLIENTCONF
, 2 ;
2203 my $zip = Archive
:: Zip
-> new ();
2205 print CLIENTCONF
"#OpenVPN Client conf \r\n " ;
2206 print CLIENTCONF
"tls-client \r\n " ;
2207 print CLIENTCONF
"client \r\n " ;
2208 print CLIENTCONF
"nobind \r\n " ;
2209 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \r\n " ;
2210 print CLIENTCONF
"proto $vpnsettings {'DPROTOCOL'} \r\n " ;
2212 # Check if we are using fragment, mssfix or mtu-disc and set MTU to 1500
2213 # or use configured value.
2214 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' )
2215 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2216 elsif ( $vpnsettings { MSSFIX
} eq 'on' )
2217 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2218 elsif (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2219 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2220 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' ))
2221 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2223 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu $vpnsettings {'DMTU'} \r\n " ; }
2225 if ( $vpnsettings { 'ENABLED' } eq 'on' ){
2226 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2227 if ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2228 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Blue interface \r\n " ;
2229 print CLIENTCONF
";remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2231 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2232 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2233 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2235 } elsif ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2236 print CLIENTCONF
"remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2237 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2238 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2239 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2241 } elsif ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2242 print CLIENTCONF
"remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2245 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2246 print CLIENTCONF
"pkcs12 $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2247 $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 " ;
2249 print CLIENTCONF
"ca cacert.pem \r\n " ;
2250 print CLIENTCONF
"cert $confighash { $cgiparams {'KEY'}}[1]cert.pem \r\n " ;
2251 print CLIENTCONF
"key $confighash { $cgiparams {'KEY'}}[1].key \r\n " ;
2252 $zip -> addFile ( "${General::swroot}/ovpn/ca/cacert.pem" , "cacert.pem" ) or die "Can't add file cacert.pem \n " ;
2253 $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 " ;
2255 print CLIENTCONF
"cipher $vpnsettings {DCIPHER} \r\n " ;
2256 if ( $vpnsettings { 'DAUTH' } eq '' ) {
2257 print CLIENTCONF
"" ;
2259 print CLIENTCONF
"auth $vpnsettings {'DAUTH'} \r\n " ;
2261 if ( $vpnsettings { 'TLSAUTH' } eq 'on' ) {
2262 print CLIENTCONF
"tls-auth ta.key 1 \r\n " ;
2263 $zip -> addFile ( "${General::swroot}/ovpn/ca/ta.key" , "ta.key" ) or die "Can't add file ta.key \n " ;
2265 if ( $vpnsettings { DCOMPLZO
} eq 'on' ) {
2266 print CLIENTCONF
"comp-lzo \r\n " ;
2268 print CLIENTCONF
"verb 3 \r\n " ;
2269 print CLIENTCONF
"ns-cert-type server \r\n " ;
2270 print CLIENTCONF
"tls-remote $vpnsettings {ROOTCERT_HOSTNAME} \r\n " ;
2271 if ( $vpnsettings { MSSFIX
} eq 'on' ) {
2272 print CLIENTCONF
"mssfix \r\n " ;
2274 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' ) {
2275 print CLIENTCONF
"fragment $vpnsettings {'FRAGMENT'} \r\n " ;
2278 # Check if a valid operating mode has been choosen and use it.
2279 if (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2280 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2281 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' )) {
2282 if (( $vpnsettings { MSSFIX
} ne 'on' ) || ( $vpnsettings { FRAGMENT
} eq '' )) {
2283 print CLIENTCONF
"mtu-disc $vpnsettings {'PMTU_DISCOVERY'} \r\n " ;
2288 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2289 my $status = $zip -> writeToFileNamed ( $zippathname );
2291 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2292 @fileholder = < DLFILE
>;
2293 print "Content-Type:application/x-download \n " ;
2294 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2302 ### Remove connection
2306 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
2307 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2308 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2310 if ( $confighash { $cgiparams { 'KEY' }}) {
2311 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2312 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2313 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2316 my $temp = `/usr/bin/openssl ca -revoke ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2322 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
2323 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
2324 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2328 if (- e
"${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) {
2329 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
2333 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
2334 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2336 # A.Marx CCD delete ccd files and routes
2339 if (- f
"${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" )
2341 unlink "${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" ;
2344 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2345 foreach my $key ( keys %ccdroutehash ) {
2346 if ( $ccdroutehash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2347 delete $ccdroutehash { $key };
2350 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2352 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2353 foreach my $key ( keys %ccdroute2hash ) {
2354 if ( $ccdroute2hash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2355 delete $ccdroute2hash { $key };
2358 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2365 delete $confighash { $cgiparams { 'KEY' }};
2366 my $temp2 = `/usr/bin/openssl ca -gencrl -out ${General::swroot}/ovpn/crls/cacrl.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2367 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2369 #&writeserverconf();
2371 $errormessage = $Lang :: tr
{ 'invalid key' };
2373 & General
:: firewall_reload
();
2376 ### Download PKCS12 file
2378 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
2379 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2381 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
2382 print "Content-Type: application/octet-stream \r\n\r\n " ;
2383 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
2387 ### Display certificate
2389 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
2390 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2392 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2393 & Header
:: showhttpheaders
();
2394 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2395 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2396 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate'}:" );
2397 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2398 $output = & Header
:: cleanhtml
( $output , "y" );
2399 print "<pre> $output </pre> \n " ;
2400 & Header
:: closebox
();
2401 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2402 & Header
:: closebigbox
();
2403 & Header
:: closepage
();
2408 ### Display Diffie-Hellman key
2410 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show dh' }) {
2412 if (! - e
"${General::swroot}/ovpn/ca/dh1024.pem" ) {
2413 $errormessage = $Lang :: tr
{ 'not present' };
2415 & Header
:: showhttpheaders
();
2416 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2417 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2418 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'dh'}:" );
2419 my $output = `/usr/bin/openssl dhparam -text -in ${General::swroot}/ovpn/ca/dh1024.pem` ;
2420 $output = & Header
:: cleanhtml
( $output , "y" );
2421 print "<pre> $output </pre> \n " ;
2422 & Header
:: closebox
();
2423 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2424 & Header
:: closebigbox
();
2425 & Header
:: closepage
();
2430 ### Display Certificate Revoke List
2432 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show crl' }) {
2433 # &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash);
2435 if (! - e
"${General::swroot}/ovpn/crls/cacrl.pem" ) {
2436 $errormessage = $Lang :: tr
{ 'not present' };
2438 & Header
:: showhttpheaders
();
2439 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2440 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2441 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'crl'}:" );
2442 my $output = `/usr/bin/openssl crl -text -noout -in ${General::swroot}/ovpn/crls/cacrl.pem` ;
2443 $output = & Header
:: cleanhtml
( $output , "y" );
2444 print "<pre> $output </pre> \n " ;
2445 & Header
:: closebox
();
2446 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2447 & Header
:: closebigbox
();
2448 & Header
:: closepage
();
2453 ### Advanced Server Settings
2456 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced server' }) {
2461 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
2465 # if ($cgiparams{'CLIENT2CLIENT'} eq '') {
2466 # $cgiparams{'CLIENT2CLIENT'} = 'on';
2469 if ( $cgiparams { 'MAX_CLIENTS' } eq '' ) {
2470 $cgiparams { 'MAX_CLIENTS' } = '100' ;
2472 if ( $cgiparams { 'KEEPALIVE_1' } eq '' ) {
2473 $cgiparams { 'KEEPALIVE_1' } = '10' ;
2475 if ( $cgiparams { 'KEEPALIVE_2' } eq '' ) {
2476 $cgiparams { 'KEEPALIVE_2' } = '60' ;
2478 if ( $cgiparams { 'LOG_VERB' } eq '' ) {
2479 $cgiparams { 'LOG_VERB' } = '3' ;
2481 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
2482 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
2484 if ( $cgiparams { 'DAUTH' } eq '' ) {
2485 $cgiparams { 'DAUTH' } = 'SHA1' ;
2487 if ( $cgiparams { 'ENGINES' } eq '' ) {
2488 $cgiparams { 'ENGINES' } = 'disabled' ;
2490 if ( $cgiparams { 'TLSAUTH' } eq '' ) {
2491 $cgiparams { 'TLSAUTH' } = 'off' ;
2493 $checked { 'CLIENT2CLIENT' }{ 'off' } = '' ;
2494 $checked { 'CLIENT2CLIENT' }{ 'on' } = '' ;
2495 $checked { 'CLIENT2CLIENT' }{ $cgiparams { 'CLIENT2CLIENT' }} = 'CHECKED' ;
2496 $checked { 'REDIRECT_GW_DEF1' }{ 'off' } = '' ;
2497 $checked { 'REDIRECT_GW_DEF1' }{ 'on' } = '' ;
2498 $checked { 'REDIRECT_GW_DEF1' }{ $cgiparams { 'REDIRECT_GW_DEF1' }} = 'CHECKED' ;
2499 $checked { 'MSSFIX' }{ 'off' } = '' ;
2500 $checked { 'MSSFIX' }{ 'on' } = '' ;
2501 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
2502 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
2503 $selected { 'LOG_VERB' }{ '0' } = '' ;
2504 $selected { 'LOG_VERB' }{ '1' } = '' ;
2505 $selected { 'LOG_VERB' }{ '2' } = '' ;
2506 $selected { 'LOG_VERB' }{ '3' } = '' ;
2507 $selected { 'LOG_VERB' }{ '4' } = '' ;
2508 $selected { 'LOG_VERB' }{ '5' } = '' ;
2509 $selected { 'LOG_VERB' }{ '6' } = '' ;
2510 $selected { 'LOG_VERB' }{ '7' } = '' ;
2511 $selected { 'LOG_VERB' }{ '8' } = '' ;
2512 $selected { 'LOG_VERB' }{ '9' } = '' ;
2513 $selected { 'LOG_VERB' }{ '10' } = '' ;
2514 $selected { 'LOG_VERB' }{ '11' } = '' ;
2515 $selected { 'LOG_VERB' }{ $cgiparams { 'LOG_VERB' }} = 'SELECTED' ;
2516 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
2517 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
2518 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
2519 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
2520 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
2521 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
2522 $checked { 'TLSAUTH' }{ 'off' } = '' ;
2523 $checked { 'TLSAUTH' }{ 'on' } = '' ;
2524 $checked { 'TLSAUTH' }{ $cgiparams { 'TLSAUTH' }} = 'CHECKED' ;
2525 $selected { 'ENGINES' }{ 'cryptodev' } = '' ;
2526 $selected { 'ENGINES' }{ 'dynamic' } = '' ;
2527 $selected { 'ENGINES' }{ 'aesni' } = '' ;
2528 $selected { 'ENGINES' }{ 'padlock' } = '' ;
2529 $selected { 'ENGINES' }{ 'disabled' } = '' ;
2530 $selected { 'ENGINES' }{ $cgiparams { 'ENGINES' }} = 'SELECTED' ;
2532 & Header
:: showhttpheaders
();
2533 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
2534 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
2535 if ( $errormessage ) {
2536 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2537 print "<class name='base'> $errormessage \n " ;
2538 print " </class> \n " ;
2539 & Header
:: closebox
();
2541 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'advanced server' });
2543 <form method='post' enctype='multipart/form-data'>
2544 <table width='100%' border='0'>
2546 <td colspan='4'><b> $Lang ::tr{'dhcp-options'}</b></td>
2549 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2552 <td class='base'>Domain</td>
2553 <td><input type='TEXT' name='DHCP_DOMAIN' value=' $cgiparams {'DHCP_DOMAIN'}' size='30' /></td>
2556 <td class='base'>DNS</td>
2557 <td><input type='TEXT' name='DHCP_DNS' value=' $cgiparams {'DHCP_DNS'}' size='30' /></td>
2560 <td class='base'>WINS</td>
2561 <td><input type='TEXT' name='DHCP_WINS' value=' $cgiparams {'DHCP_WINS'}' size='30' /></td>
2564 <td colspan='4'><b> $Lang ::tr{'ovpn routes push options'}</b></td>
2567 <td class='base'> $Lang ::tr{'ovpn routes push'}</td>
2569 <textarea name='ROUTES_PUSH' cols='26' rows='6' wrap='off'>
2573 if ( $cgiparams { 'ROUTES_PUSH' } ne '' )
2575 print $cgiparams { 'ROUTES_PUSH' };
2584 <table width='100%'>
2586 <td class'base'><b> $Lang ::tr{'misc-options'}</b></td>
2589 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2592 <td class='base'>Client-To-Client</td>
2593 <td><input type='checkbox' name='CLIENT2CLIENT' $checked {'CLIENT2CLIENT'}{'on'} /></td>
2596 <td class='base'>Redirect-Gateway def1</td>
2597 <td><input type='checkbox' name='REDIRECT_GW_DEF1' $checked {'REDIRECT_GW_DEF1'}{'on'} /></td>
2600 <td class='base'>Max-Clients</td>
2601 <td><input type='text' name='MAX_CLIENTS' value=' $cgiparams {'MAX_CLIENTS'}' size='10' /></td>
2604 <td class='base'>Keepalive <br />
2605 (ping/ping-restart)</td>
2606 <td><input type='TEXT' name='KEEPALIVE_1' value=' $cgiparams {'KEEPALIVE_1'}' size='10' /></td>
2607 <td><input type='TEXT' name='KEEPALIVE_2' value=' $cgiparams {'KEEPALIVE_2'}' size='10' /></td>
2610 <td class='base'>fragment <br></td>
2611 <td><input type='TEXT' name='FRAGMENT' value=' $cgiparams {'FRAGMENT'}' size='10' /></td>
2614 <td class='base'>mssfix</td>
2615 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
2616 <td> $Lang ::tr{'openvpn default'}: off</td>
2620 <td class='base'> $Lang ::tr{'ovpn mtu-disc'}</td>
2621 <td><input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}</td>
2622 <td><input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}</td>
2623 <td><input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}</td>
2624 <td><input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}</td>
2629 <table width='100%'>
2631 <td class'base'><b> $Lang ::tr{'log-options'}</b></td>
2634 <td width='20%'></td> <td width='30%'> </td><td width='25%'> </td><td width='25%'></td>
2637 <tr><td class='base'>VERB</td>
2638 <td><select name='LOG_VERB'>
2639 <option value='0' $selected {'LOG_VERB'}{'0'}>0</option>
2640 <option value='1' $selected {'LOG_VERB'}{'1'}>1</option>
2641 <option value='2' $selected {'LOG_VERB'}{'2'}>2</option>
2642 <option value='3' $selected {'LOG_VERB'}{'3'}>3</option>
2643 <option value='4' $selected {'LOG_VERB'}{'4'}>4</option>
2644 <option value='5' $selected {'LOG_VERB'}{'5'}>5</option>
2645 <option value='6' $selected {'LOG_VERB'}{'6'}>6</option>
2646 <option value='7' $selected {'LOG_VERB'}{'7'}>7</option>
2647 <option value='8' $selected {'LOG_VERB'}{'8'}>8</option>
2648 <option value='9' $selected {'LOG_VERB'}{'9'}>9</option>
2649 <option value='10' $selected {'LOG_VERB'}{'10'}>10</option>
2650 <option value='11' $selected {'LOG_VERB'}{'11'}>11</option>
2655 <table width='100%'>
2657 <td class'base'><b> $Lang ::tr{'ovpn crypt options'}</b></td>
2660 <td width='20%'></td> <td width='30%'> </td><td width='25%'> </td><td width='25%'></td>
2662 <tr><td class='base'> $Lang ::tr{'ovpn ha'}</td>
2663 <td><select name='DAUTH'>
2664 <option value='whirlpool' $selected {'DAUTH'}{'whirlpool'}>Whirlpool (512 $Lang ::tr{'bit'})</option>
2665 <option value='SHA512' $selected {'DAUTH'}{'SHA512'}>SHA2 (512 $Lang ::tr{'bit'})</option>
2666 <option value='SHA384' $selected {'DAUTH'}{'SHA384'}>SHA2 (384 $Lang ::tr{'bit'})</option>
2667 <option value='SHA256' $selected {'DAUTH'}{'SHA256'}>SHA2 (256 $Lang ::tr{'bit'})</option>
2668 <option value='SHA1' $selected {'DAUTH'}{'SHA1'}>SHA1 (160 $Lang ::tr{'bit'})</option>
2671 <td>Default: <span class="base">SHA1 (160 $Lang ::tr{'bit'})</span></td>
2674 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn engines'}</td>
2675 <td><select name='ENGINES'>
2676 <option value='cryptodev' $selected {'ENGINES'}{'cryptodev'}>Cryptodev</option>
2677 <option value='dynamic' $selected {'ENGINES'}{'dynamic'}>Dynamic</option>
2678 <option value='aesni' $selected {'ENGINES'}{'aesni'}>AES-NI</option>
2679 <option value='padlock' $selected {'ENGINES'}{'padlock'}>Padlock</option>
2680 <option value='disabled' $selected {'ENGINES'}{'disabled'}> $Lang ::tr{'disabled'}</option>
2683 <td>Default: <span class="base"> $Lang ::tr{'disabled'}</span></td>
2687 <table width='100%'>
2689 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2693 <td class='base'>HMAC tls-auth</td>
2694 <td><input type='checkbox' name='TLSAUTH' $checked {'TLSAUTH'}{'on'} /></td>
2701 if ( - e
"/var/run/openvpn.pid" ){
2702 print " <br><b><font color='#990000'> $Lang ::tr{'attention'}:</b></font><br>
2703 $Lang ::tr{'server restart'}<br><br>
2706 <table width='100%'>
2709 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' disabled='disabled' /></td>
2710 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2722 <table width='100%'>
2725 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' /></td>
2726 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2734 & Header
:: closebox
();
2735 # print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'>$Lang::tr{'back'}</a></div>";
2736 & Header
:: closebigbox
();
2737 & Header
:: closepage
();
2741 # A.Marx CCD Add,delete or edit CCD net
2743 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd net' } ||
2744 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' } ||
2745 $cgiparams { 'ACTION' } eq "kill" ||
2746 $cgiparams { 'ACTION' } eq "edit" ||
2747 $cgiparams { 'ACTION' } eq 'editsave' ){
2748 & Header
:: showhttpheaders
();
2749 & Header
:: openpage
( $Lang :: tr
{ 'ccd net' }, 1 , '' );
2750 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2752 if ( $cgiparams { 'ACTION' } eq "kill" ){
2753 & delccdnet
( $cgiparams { 'net' });
2756 if ( $cgiparams { 'ACTION' } eq 'editsave' ){
2757 my ( $a , $b ) = split ( /\|/ , $cgiparams { 'ccdname' });
2758 if ( $a ne $b ){ & modccdnet
( $a , $b );}
2759 $cgiparams { 'ccdname' }= '' ;
2760 $cgiparams { 'ccdsubnet' }= '' ;
2763 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' }) {
2764 & addccdnet
( $cgiparams { 'ccdname' }, $cgiparams { 'ccdsubnet' });
2766 if ( $errormessage ) {
2767 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2768 print "<class name='base'> $errormessage " ;
2769 print " </class>" ;
2770 & Header
:: closebox
();
2772 if ( $cgiparams { 'ACTION' } eq "edit" ){
2774 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd modify' });
2777 <table width='100%' border='0'>
2778 <tr><form method='post'>
2779 <td width='10%' nowrap='nowrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2780 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' readonly='readonly' /></td></tr>
2781 <tr><td colspan='4' align='right'><hr><input type='submit' value=' $Lang ::tr{'save'}' /><input type='hidden' name='ACTION' value='editsave'/>
2782 <input type='hidden' name='ccdname' value=' $cgiparams {'ccdname'}'/><input type='submit' value=' $Lang ::tr{'cancel'}' />
2787 & Header
:: closebox
();
2789 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2791 <table width='100%' border='0' cellpadding='0' cellspacing='1'>
2793 <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>
2798 if (! - e
"/var/run/openvpn.pid" ){
2799 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd add' });
2801 <table width='100%' border='0'>
2802 <tr><form method='post'>
2803 <td colspan='4'> $Lang ::tr{'ccd hint'}<br><br></td></tr>
2805 <td width='10%' nowrap='nwrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2806 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' /></td></tr>
2807 <tr><td colspan=4><hr /></td></tr><tr>
2808 <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>
2812 & Header
:: closebox
();
2814 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2815 if ( - e
"/var/run/openvpn.pid" ){
2816 print "<b> $Lang ::tr{'attention'}:</b><br>" ;
2817 print " $Lang ::tr{'ccd noaddnet'}<br><hr>" ;
2821 <table width='100%' cellpadding='0' cellspacing='1'>
2823 <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>
2828 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
2831 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
2832 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
2834 my $ccdhosts = & hostsinnet
( $ccdconf [ 0 ]);
2835 if ( $count % 2 ){ print " <tr bgcolor=' $color {'color22'}'>" ;}
2836 else { print " <tr bgcolor=' $color {'color20'}'>" ;}
2837 print "<td> $ccdconf [0]</td><td align='center'> $ccdconf [1]</td><td align='center'> $ccdhosts /" .(& ccdmaxclients
( $ccdconf [ 1 ])+ 1 ). "</td><td>" ;
2839 <form method='post' />
2840 <input type='image' src='/images/edit.gif' align='middle' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
2841 <input type='hidden' name='ACTION' value='edit'/>
2842 <input type='hidden' name='ccdname' value=' $ccdconf [0]' />
2843 <input type='hidden' name='ccdsubnet' value=' $ccdconf [1]' />
2845 <form method='post' />
2846 <td><input type='hidden' name='ACTION' value='kill'/>
2847 <input type='hidden' name='number' value=' $count ' />
2848 <input type='hidden' name='net' value=' $ccdconf [0]' />
2849 <input type='image' src='/images/delete.gif' align='middle' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' /></form></td></tr>
2853 print "</table></form>" ;
2854 & Header
:: closebox
();
2855 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2856 & Header
:: closebigbox
();
2857 & Header
:: closepage
();
2863 ### Openvpn Connections Statistics
2865 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ovpn con stat' }) {
2866 & Header
:: showhttpheaders
();
2867 & Header
:: openpage
( $Lang :: tr
{ 'ovpn con stat' }, 1 , '' );
2868 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2869 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ovpn con stat' });
2872 # <td><b>$Lang::tr{'protocol'}</b></td>
2873 # protocol temp removed
2875 <table width='100%' cellpadding='2' cellspacing='0' class='tbl'>
2877 <th><b> $Lang ::tr{'common name'}</b></th>
2878 <th><b> $Lang ::tr{'real address'}</b></th>
2879 <th><b> $Lang ::tr{'virtual address'}</b></th>
2880 <th><b> $Lang ::tr{'loged in at'}</b></th>
2881 <th><b> $Lang ::tr{'bytes sent'}</b></th>
2882 <th><b> $Lang ::tr{'bytes received'}</b></th>
2883 <th><b> $Lang ::tr{'last activity'}</b></th>
2887 my $filename = "/var/log/ovpnserver.log" ;
2888 open ( FILE
, $filename ) or die 'Unable to open config file.' ;
2889 my @current = < FILE
>;
2898 my %userlookup = ();
2899 foreach my $line ( @current )
2902 if ( $line =~ /^Updated,(.+)/ ){
2903 @match = split ( /^Updated,(.+)/ , $line );
2904 $status = $match [ 1 ];
2907 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
2908 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
2909 if ( $match [ 1 ] ne "Common Name" ) {
2911 $userlookup { $match [ 2 ]} = $uid ;
2912 $users [ $uid ]{ 'CommonName' } = $match [ 1 ];
2913 $users [ $uid ]{ 'RealAddress' } = $match [ 2 ];
2914 $users [ $uid ]{ 'BytesReceived' } = & sizeformat
( $match [ 3 ]);
2915 $users [ $uid ]{ 'BytesSent' } = & sizeformat
( $match [ 4 ]);
2916 $users [ $uid ]{ 'Since' } = $match [ 5 ];
2917 $users [ $uid ]{ 'Proto' } = $proto ;
2921 if ( $line =~ /^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ ) {
2922 @match = split ( m/^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ , $line );
2923 if ( $match [ 1 ] ne "Virtual Address" ) {
2924 $address = $match [ 3 ];
2925 #find the uid in the lookup table
2926 $uid = $userlookup { $address };
2927 $users [ $uid ]{ 'VirtualAddress' } = $match [ 1 ];
2928 $users [ $uid ]{ 'LastRef' } = $match [ 4 ];
2934 for ( my $idx = 1 ; $idx <= $user2 ; $idx ++){
2937 $col = "bgcolor=' $color {'color22'}'" ;
2940 $col = "bgcolor=' $color {'color20'}'" ;
2942 print "<td align='left' $col > $users [ $idx -1]{'CommonName'}</td>" ;
2943 print "<td align='left' $col > $users [ $idx -1]{'RealAddress'}</td>" ;
2944 print "<td align='left' $col > $users [ $idx -1]{'VirtualAddress'}</td>" ;
2945 print "<td align='left' $col > $users [ $idx -1]{'Since'}</td>" ;
2946 print "<td align='left' $col > $users [ $idx -1]{'BytesSent'}</td>" ;
2947 print "<td align='left' $col > $users [ $idx -1]{'BytesReceived'}</td>" ;
2948 print "<td align='left' $col > $users [ $idx -1]{'LastRef'}</td>" ;
2954 <table width='100%' border='0' cellpadding='2' cellspacing='0'>
2959 <tr><td align='center' > $Lang ::tr{'the statistics were last updated at'} <b> $status </b></td></tr>
2963 & Header
:: closebox
();
2964 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2965 & Header
:: closebigbox
();
2966 & Header
:: closepage
();
2970 ### Download Certificate
2972 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
2973 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2975 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2976 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \r\n " ;
2977 print "Content-Type: application/octet-stream \r\n\r\n " ;
2978 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2983 ### Enable/Disable connection
2986 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
2988 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2989 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2991 if ( $confighash { $cgiparams { 'KEY' }}) {
2992 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
2993 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
2994 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2995 #&writeserverconf();
2996 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2997 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2998 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
3001 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
3002 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3003 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3004 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
3006 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3007 #&writeserverconf();
3010 $errormessage = $Lang :: tr
{ 'invalid key' };
3014 ### Restart connection
3016 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
3017 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3018 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3020 if ( $confighash { $cgiparams { 'KEY' }}) {
3021 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3022 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3023 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
3026 $errormessage = $Lang :: tr
{ 'invalid key' };
3030 ### Remove connection
3032 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
3033 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3034 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3036 if ( $confighash { $cgiparams { 'KEY' }}) {
3037 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3038 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3039 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
3041 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
3042 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
3043 delete $confighash { $cgiparams { 'KEY' }};
3044 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3045 #&writeserverconf();
3047 $errormessage = $Lang :: tr
{ 'invalid key' };
3052 ### Choose between adding a host-net or net-net connection
3059 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
3060 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3061 & Header
:: showhttpheaders
();
3062 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
3063 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
3064 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection type' });
3066 if ( - s
"${General::swroot}/ovpn/settings" ) {
3069 <b> $Lang ::tr{'connection type'}:</b><br />
3070 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
3071 <tr><td><input type='radio' name='TYPE' value='host' checked /></td>
3072 <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
3073 <tr><td><input type='radio' name='TYPE' value='net' /></td>
3074 <td class='base'> $Lang ::tr{'net to net vpn'}</td></tr>
3075 <tr><td><input type='radio' name='TYPE' value='net2net' /></td>
3076 <td class='base'> $Lang ::tr{'net to net vpn'} (Upload Client Package)</td></tr>
3077 <tr><td> </td><td class='base'><input type='file' name='FH' size='30'></td></tr>
3078 <tr><td> </td><td>Import Connection Name <img src='/blob.gif' /></td></tr>
3079 <tr><td> </td><td class='base'><input type='text' name='n2nname' size='30'> $Lang ::tr{'openvpn default'}: Client Packagename</td></tr>
3080 <tr><td colspan='3'><hr /></td></tr>
3081 <tr><td align='right' colspan='3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
3082 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
3090 <b> $Lang ::tr{'connection type'}:</b><br />
3091 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
3092 <tr><td><input type='radio' name='TYPE' value='host' checked /></td> <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
3093 <tr><td align='right' colspan'3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
3100 & Header
:: closebox
();
3101 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3102 & Header
:: closebigbox
();
3103 & Header
:: closepage
();
3110 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2net' )){
3114 my $uplconffilename = '' ;
3115 my $uplconffilename2 = '' ;
3116 my $uplp12name = '' ;
3117 my $uplp12name2 = '' ;
3124 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3126 # Check if a file is uploaded
3128 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3129 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3133 # Move uploaded IPfire n2n package to temporary file
3135 ( my $fh , my $filename ) = tempfile
( );
3136 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3141 my $zip = Archive
:: Zip
-> new ();
3142 my $zipName = $filename ;
3143 my $status = $zip -> read ( $zipName );
3144 if ( $status != AZ_OK
) {
3145 $errormessage = "Read of $zipName failed \n " ;
3149 my $tempdir = tempdir
( CLEANUP
=> 1 );
3150 my @files = $zip -> memberNames ();
3152 $zip -> extractMemberWithoutPaths ( $_ , " $tempdir / $_ " );
3154 my $countfiles = @files ;
3156 # Check if we have not more then 2 files
3158 if ( $countfiles == 2 ){
3160 if ( $_ =~ /.conf$/ ){
3161 $uplconffilename = $_ ;
3163 if ( $_ =~ /.p12$/ ){
3167 if (( $uplconffilename eq '' ) || ( $uplp12name eq '' )){
3168 $errormessage = "Either no *.conf or no *.p12 file found \n " ;
3172 open ( FILE
, " $tempdir / $uplconffilename " ) or die 'Unable to open*.conf file' ;
3173 @firen2nconf = < FILE
>;
3175 chomp ( @firen2nconf );
3179 $errormessage = "Filecount does not match only 2 files are allowed \n " ;
3187 if ( $cgiparams { 'n2nname' } ne '' ){
3189 $uplconffilename2 = " $cgiparams {'n2nname'}.conf" ;
3190 $uplp12name2 = " $cgiparams {'n2nname'}.p12" ;
3191 $n2nname [ 0 ] = $cgiparams { 'n2nname' };
3192 my @n2nname2 = split ( /\./ , $uplconffilename );
3193 $n2nname2 [ 0 ] =~ s/\n|\r//g ;
3194 my $input1 = "${General::swroot}/ovpn/certs/ $uplp12name " ;
3195 my $output1 = "${General::swroot}/ovpn/certs/ $uplp12name2 " ;
3196 my $input2 = " $n2nname2 [0]n2n" ;
3197 my $output2 = " $n2nname [0]n2n" ;
3198 my $filename = " $tempdir / $uplconffilename " ;
3199 open ( FILE
, "< $filename " ) or die 'Unable to open config file.' ;
3200 my @current = < FILE
>;
3202 foreach ( @current ) { s/$input1/$output1/g ;}
3203 foreach ( @current ) { s/$input2/$output2/g ;}
3204 open ( OUT
, "> $filename " ) || die 'Unable to open config file.' ;
3209 $uplconffilename2 = $uplconffilename ;
3210 $uplp12name2 = $uplp12name ;
3211 @n2nname = split ( /\./ , $uplconffilename );
3212 $n2nname [ 0 ] =~ s/\n|\r//g ;
3214 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
3215 unless (- d
"${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" , 0770 or die "Unable to create dir $!" ;}
3217 move
( " $tempdir / $uplconffilename " , "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $uplconffilename2 " );
3220 $errormessage = "*.conf move failed: $!" ;
3225 move
( " $tempdir / $uplp12name " , "${General::swroot}/ovpn/certs/ $uplp12name2 " );
3226 chmod 0600 , "${General::swroot}/ovpn/certs/ $uplp12name " ;
3229 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
3238 my @n2nmtudisc = split ( / / , ( grep { /^mtu-disc/ } @firen2nconf )[ 0 ]);
3239 my @n2nproto2 = split ( / / , ( grep { /^proto/ } @firen2nconf )[ 0 ]);
3240 my @n2nproto = split ( /-/ , $n2nproto2 [ 1 ]);
3241 my @n2nport = split ( / / , ( grep { /^port/ } @firen2nconf )[ 0 ]);
3242 my @n2ntunmtu = split ( / / , ( grep { /^tun-mtu/ } @firen2nconf )[ 0 ]);
3243 my @n2ncomplzo = grep { /^comp-lzo/ } @firen2nconf ;
3244 if ( $n2ncomplzo [ 0 ] =~ /comp-lzo/ ){ $complzoactive = "on" ;} else { $complzoactive = "off" ;}
3245 my @n2nmssfix = grep { /^mssfix/ } @firen2nconf ;
3246 if ( $n2nmssfix [ 0 ] =~ /mssfix/ ){ $mssfixactive = "on" ;} else { $mssfixactive = "off" ;}
3247 #my @n2nmssfix = split(/ /, (grep { /^mssfix/ } @firen2nconf)[0]);
3248 my @n2nfragment = split ( / / , ( grep { /^fragment/ } @firen2nconf )[ 0 ]);
3249 my @n2nremote = split ( / / , ( grep { /^remote/ } @firen2nconf )[ 0 ]);
3250 my @n2novpnsuball = split ( / / , ( grep { /^ifconfig/ } @firen2nconf )[ 0 ]);
3251 my @n2novpnsub = split ( /\./ , $n2novpnsuball [ 1 ]);
3252 my @n2nremsub = split ( / / , ( grep { /^route/ } @firen2nconf )[ 0 ]);
3253 my @n2nmgmt = split ( / / , ( grep { /^management/ } @firen2nconf )[ 0 ]);
3254 my @n2nlocalsub = split ( / / , ( grep { /^# remsub/ } @firen2nconf )[ 0 ]);
3255 my @n2ncipher = split ( / / , ( grep { /^cipher/ } @firen2nconf )[ 0 ]);
3256 my @n2nauth = split ( / / , ( grep { /^auth/ } @firen2nconf )[ 0 ]);
3257 my @n2nengine = split ( / / , ( grep { /^engine/ } @firen2nconf )[ 0 ]);;
3260 # m.a.d delete CR and LF from arrays for this chomp doesnt work
3263 $n2nremote [ 1 ] =~ s/\n|\r//g ;
3264 $n2novpnsub [ 0 ] =~ s/\n|\r//g ;
3265 $n2novpnsub [ 1 ] =~ s/\n|\r//g ;
3266 $n2novpnsub [ 2 ] =~ s/\n|\r//g ;
3267 $n2nproto [ 0 ] =~ s/\n|\r//g ;
3268 $n2nport [ 1 ] =~ s/\n|\r//g ;
3269 $n2ntunmtu [ 1 ] =~ s/\n|\r//g ;
3270 $n2nremsub [ 1 ] =~ s/\n|\r//g ;
3271 $n2nremsub [ 2 ] =~ s/\n|\r//g ;
3272 $n2nlocalsub [ 2 ] =~ s/\n|\r//g ;
3273 $n2nfragment [ 1 ] =~ s/\n|\r//g ;
3274 $n2nmgmt [ 2 ] =~ s/\n|\r//g ;
3275 $n2nmtudisc [ 1 ] =~ s/\n|\r//g ;
3276 $n2ncipher [ 1 ] =~ s/\n|\r//g ;
3277 $n2nauth [ 1 ] =~ s/\n|\r//g ;
3278 $n2nengine [ 1 ] =~ s/\n|\r//g ;
3279 chomp ( $complzoactive );
3280 chomp ( $mssfixactive );
3287 # Check if there is no other entry with this name
3290 foreach my $dkey ( keys %confighash ) {
3291 if ( $confighash { $dkey }[ 1 ] eq $n2nname [ 0 ]) {
3292 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3293 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3294 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3295 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3301 # Check if OpenVPN Subnet is valid
3304 foreach my $dkey ( keys %confighash ) {
3305 if ( $confighash { $dkey }[ 27 ] eq " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ) {
3306 $errormessage = 'The OpenVPN Subnet is already in use' ;
3307 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3308 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3309 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3315 # Check if Dest Port is vaild
3318 foreach my $dkey ( keys %confighash ) {
3319 if ( $confighash { $dkey }[ 29 ] eq $n2nport [ 1 ] ) {
3320 $errormessage = 'The OpenVPN Port is already in use' ;
3321 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3322 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3323 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3330 $key = & General
:: findhasharraykey
( \
%confighash );
3332 foreach my $i ( 0 .. 42 ) { $confighash { $key }[ $i ] = "" ;}
3334 $confighash { $key }[ 0 ] = 'off' ;
3335 $confighash { $key }[ 1 ] = $n2nname [ 0 ];
3336 $confighash { $key }[ 2 ] = $n2nname [ 0 ];
3337 $confighash { $key }[ 3 ] = 'net' ;
3338 $confighash { $key }[ 4 ] = 'cert' ;
3339 $confighash { $key }[ 6 ] = 'client' ;
3340 $confighash { $key }[ 8 ] = $n2nlocalsub [ 2 ];
3341 $confighash { $key }[ 10 ] = $n2nremote [ 1 ];
3342 $confighash { $key }[ 11 ] = " $n2nremsub [1]/ $n2nremsub [2]" ;
3343 $confighash { $key }[ 22 ] = $n2nmgmt [ 2 ];
3344 $confighash { $key }[ 23 ] = $mssfixactive ;
3345 $confighash { $key }[ 24 ] = $n2nfragment [ 1 ];
3346 $confighash { $key }[ 25 ] = 'IPFire n2n Client' ;
3347 $confighash { $key }[ 26 ] = 'red' ;
3348 $confighash { $key }[ 27 ] = " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ;
3349 $confighash { $key }[ 28 ] = $n2nproto [ 0 ];
3350 $confighash { $key }[ 29 ] = $n2nport [ 1 ];
3351 $confighash { $key }[ 30 ] = $complzoactive ;
3352 $confighash { $key }[ 31 ] = $n2ntunmtu [ 1 ];
3353 $confighash { $key }[ 38 ] = $n2nmtudisc [ 1 ];
3354 $confighash { $key }[ 39 ] = $n2nauth [ 1 ];
3355 $confighash { $key }[ 40 ] = $n2ncipher [ 1 ];
3356 $confighash { $key }[ 41 ] = 'disabled' ;
3359 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3363 & Header
:: showhttpheaders
();
3364 & Header
:: openpage
( 'Validate imported configuration' , 1 , '' );
3365 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
3366 if ( $errormessage ) {
3367 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
3368 print "<class name='base'> $errormessage " ;
3369 print " </class>" ;
3370 & Header
:: closebox
();
3374 & Header
:: openbox
( '100%' , 'LEFT' , 'import ipfire net2net config' );
3376 if ( $errormessage eq '' ){
3378 <!-- ipfire net2net config gui -->
3379 <table width='100%'>
3380 <tr><td width='25%'> </td><td width='25%'> </td></tr>
3381 <tr><td class='boldbase'> $Lang ::tr{'name'}:</td><td><b> $n2nname [0]</b></td></tr>
3382 <tr><td> </td><td> </td></tr>
3383 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td><td><b> $confighash { $key }[6]</b></td></tr>
3384 <tr><td class='boldbase' nowrap='nowrap'>Remote Host </td><td><b> $confighash { $key }[10]</b></td></tr>
3385 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td><td><b> $confighash { $key }[8]</b></td></tr>
3386 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td><td><b> $confighash { $key }[11]</b></td></tr>
3387 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td><td><b> $confighash { $key }[27]</b></td></tr>
3388 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td><td><b> $confighash { $key }[28]</b></td></tr>
3389 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'destination port'}:</td><td><b> $confighash { $key }[29]</b></td></tr>
3390 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td><td><b> $confighash { $key }[30]</b></td></tr>
3391 <tr><td class='boldbase' nowrap='nowrap'>MSSFIX </td><td><b> $confighash { $key }[23]</b></td></tr>
3392 <tr><td class='boldbase' nowrap='nowrap'>Fragment </td><td><b> $confighash { $key }[24]</b></td></tr>
3393 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'}</td><td><b> $confighash { $key }[31]</b></td></tr>
3394 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td><td><b> $confighash { $key }[38]</b></td></tr>
3395 <tr><td class='boldbase' nowrap='nowrap'>Management Port </td><td><b> $confighash { $key }[22]</b></td></tr>
3396 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn hmac'}:</td><td><b> $confighash { $key }[39]</b></td></tr>
3397 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td><td><b> $confighash { $key }[40]</b></td></tr>
3398 <tr><td> </td><td> </td></tr>
3402 & Header
:: closebox
();
3405 if ( $errormessage ) {
3406 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3408 print "<div align='center'><form method='post' ENCTYPE='multipart/form-data'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />" ;
3409 print "<input type='hidden' name='TYPE' value='net2netakn' />" ;
3410 print "<input type='hidden' name='KEY' value=' $key ' />" ;
3411 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
3413 & Header
:: closebigbox
();
3414 & Header
:: closepage
();
3419 ### Accept IPFire n2n Package Settings
3422 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3425 ### Discard and Rollback IPFire n2n Package Settings
3428 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'cancel' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3430 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3432 if ( $confighash { $cgiparams { 'KEY' }}) {
3434 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
3435 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
3436 unlink ( $certfile ) or die "Removing $certfile fail: $!" ;
3437 unlink ( $conffile ) or die "Removing $conffile fail: $!" ;
3438 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
3439 delete $confighash { $cgiparams { 'KEY' }};
3440 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3443 $errormessage = $Lang :: tr
{ 'invalid key' };
3453 ### Adding a new connection
3455 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
3456 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
3457 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
3459 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3460 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
3461 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3463 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
3464 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
3465 $errormessage = $Lang :: tr
{ 'invalid key' };
3468 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
3469 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
3470 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
3471 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
3472 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
3473 $cgiparams { 'SIDE' } = $confighash { $cgiparams { 'KEY' }}[ 6 ];
3474 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
3475 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
3476 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
3477 $cgiparams { 'OVPN_MGMT' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
3478 $cgiparams { 'MSSFIX' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
3479 $cgiparams { 'FRAGMENT' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
3480 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
3481 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
3482 $cgiparams { 'OVPN_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
3483 $cgiparams { 'PROTOCOL' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
3484 $cgiparams { 'DEST_PORT' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
3485 $cgiparams { 'COMPLZO' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
3486 $cgiparams { 'MTU' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
3487 $cgiparams { 'CHECK1' } = $confighash { $cgiparams { 'KEY' }}[ 32 ];
3488 $name = $cgiparams { 'CHECK1' } ;
3489 $cgiparams { $name } = $confighash { $cgiparams { 'KEY' }}[ 33 ];
3490 $cgiparams { 'RG' } = $confighash { $cgiparams { 'KEY' }}[ 34 ];
3491 $cgiparams { 'CCD_DNS1' } = $confighash { $cgiparams { 'KEY' }}[ 35 ];
3492 $cgiparams { 'CCD_DNS2' } = $confighash { $cgiparams { 'KEY' }}[ 36 ];
3493 $cgiparams { 'CCD_WINS' } = $confighash { $cgiparams { 'KEY' }}[ 37 ];
3494 $cgiparams { 'PMTU_DISCOVERY' } = $confighash { $cgiparams { 'KEY' }}[ 38 ];
3495 $cgiparams { 'DAUTH' } = $confighash { $cgiparams { 'KEY' }}[ 39 ];
3496 $cgiparams { 'DCIPHER' } = $confighash { $cgiparams { 'KEY' }}[ 40 ];
3497 $cgiparams { 'TLSAUTH' } = $confighash { $cgiparams { 'KEY' }}[ 41 ];
3498 $cgiparams { 'ENGINES' } = $confighash { $cgiparams { 'KEY' }}[ 42 ];
3499 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
3500 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
3502 #A.Marx CCD check iroute field and convert it to decimal
3503 if ( $cgiparams { 'TYPE' } eq 'host' ) {
3505 my %ccdroutehash =();
3509 if ( $cgiparams { 'IR' } ne '' ){
3510 @temp = split ( " \n " , $cgiparams { 'IR' });
3511 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3513 foreach my $key ( keys %ccdroutehash ) {
3514 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3516 delete $ccdroutehash { $key };
3518 $keypoint = & General
:: findhasharraykey
( \
%ccdroutehash );
3521 $ccdroutehash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3524 foreach $val ( @temp ){
3527 #check if iroute exists in ccdroute or if new iroute is part of an existing one
3528 foreach my $key ( keys %ccdroutehash ) {
3529 foreach my $oldiroute ( 1 .. $ #{$ccdroutehash{$key}}){
3530 if ( $ccdroutehash { $key }[ $oldiroute ] eq " $val " ) {
3531 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3534 my ( $ip1 , $cidr1 ) = split ( /\/ /, $val );
3535 $ip1 = & General
:: getnetworkip
( $ip1 ,& General
:: iporsubtocidr
( $cidr1 ));
3536 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $oldiroute ]);
3537 if (& General
:: IpInSubnet
( $ip1 , $ip2 , $cidr2 )){
3538 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3544 if (!& General
:: validipandmask
( $val )){
3545 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3548 ( $ip , $cidr ) = split ( /\/ /, $val );
3549 $ip =& General
:: getnetworkip
( $ip ,& General
:: iporsubtocidr
( $cidr ));
3550 $cidr =& General
:: iporsubtodec
( $cidr );
3551 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3555 #check for existing network IP's
3556 if (& General
:: IpInSubnet
( $ip , $netsettings { GREEN_NETADDRESS
}, $netsettings { GREEN_NETMASK
}) && $netsettings { GREEN_NETADDRESS
} ne '0.0.0.0' )
3558 $errormessage = $Lang :: tr
{ 'ccd err green' };
3560 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { RED_NETADDRESS
}, $netsettings { RED_NETMASK
}) && $netsettings { RED_NETADDRESS
} ne '0.0.0.0' )
3562 $errormessage = $Lang :: tr
{ 'ccd err red' };
3564 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { BLUE_NETADDRESS
}, $netsettings { BLUE_NETMASK
}) && $netsettings { BLUE_NETADDRESS
} ne '0.0.0.0' && $netsettings { BLUE_NETADDRESS
} gt '' )
3566 $errormessage = $Lang :: tr
{ 'ccd err blue' };
3568 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { ORANGE_NETADDRESS
}, $netsettings { ORANGE_NETMASK
}) && $netsettings { ORANGE_NETADDRESS
} ne '0.0.0.0' && $netsettings { ORANGE_NETADDRESS
} gt '' )
3570 $errormessage = $Lang :: tr
{ 'ccd err orange' };
3574 if (& General
:: validipandmask
( $val )){
3575 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3577 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $ip / $cidr )" ;
3582 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3585 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3586 foreach my $key ( keys %ccdroutehash ) {
3587 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3588 delete $ccdroutehash { $key };
3589 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3595 #check route field and convert it to decimal
3598 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3600 foreach my $key ( keys %ccdroute2hash ) {
3601 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3603 delete $ccdroute2hash { $key };
3605 $keypoint = & General
:: findhasharraykey
( \
%ccdroute2hash );
3606 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3610 $ccdroute2hash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3611 if ( $cgiparams { 'IFROUTE' } eq '' ){ $cgiparams { 'IFROUTE' } = $Lang :: tr
{ 'ccd none' };}
3612 @temp = split ( /\|/ , $cgiparams { 'IFROUTE' });
3614 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%ownnet );
3615 foreach $val ( @temp ){
3618 if ( $val eq $Lang :: tr
{ 'green' })
3620 $val = $ownnet { GREEN_NETADDRESS
}. "/" . $ownnet { GREEN_NETMASK
};
3622 if ( $val eq $Lang :: tr
{ 'blue' })
3624 $val = $ownnet { BLUE_NETADDRESS
}. "/" . $ownnet { BLUE_NETMASK
};
3626 if ( $val eq $Lang :: tr
{ 'orange' })
3628 $val = $ownnet { ORANGE_NETADDRESS
}. "/" . $ownnet { ORANGE_NETMASK
};
3630 my ( $ip , $cidr ) = split ( /\/ /, $val );
3632 if ( $val ne $Lang :: tr
{ 'ccd none' })
3634 if (! & check_routes_push
( $val )){ $errormessage = $errormessage . "Route $val " . $Lang :: tr
{ 'ccd err routeovpn2' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3635 if (! & check_ccdroute
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err inuse' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3636 if (! & check_ccdconf
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err routeovpn' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3637 if (& General
:: validipandmask
( $val )){
3638 $val = $ip . "/" .& General
:: iporsubtodec
( $cidr );
3639 $ccdroute2hash { $keypoint }[ $i ] = $val ;
3641 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3645 $ccdroute2hash { $keypoint }[ $i ]= '' ;
3649 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3652 if ( $cgiparams { 'CCD_DNS1' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS1' })) {
3653 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 1" ;
3657 if ( $cgiparams { 'CCD_DNS2' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS2' })) {
3658 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 2" ;
3662 if ( $cgiparams { 'CCD_WINS' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_WINS' })) {
3663 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp wins' };
3671 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
3672 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
3673 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3674 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3675 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3681 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
3682 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
3683 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3684 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3685 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3690 if ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
3691 $errormessage = $Lang :: tr
{ 'name is invalid' };
3692 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3693 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3694 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3699 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
3700 $errormessage = $Lang :: tr
{ 'name too long' };
3701 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3702 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3703 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3712 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3713 if ( $cgiparams { 'DEST_PORT' } eq $vpnsettings { 'DDEST_PORT' }) {
3714 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3715 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3716 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3720 foreach my $key ( sort keys %confighash ){
3721 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 ])){
3722 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3723 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3724 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3728 if ( $cgiparams { 'DEST_PORT' } eq '' ) {
3729 $errormessage = $Lang :: tr
{ 'invalid port' };
3730 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3731 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3735 # Check if the input for the transfer net is valid.
3736 if (!& General
:: validipandmask
( $cgiparams { 'OVPN_SUBNET' })){
3737 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
3738 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3739 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3743 if ( $cgiparams { 'OVPN_SUBNET' } eq $vpnsettings { 'DOVPN_SUBNET' }) {
3744 $errormessage = $Lang :: tr
{ 'openvpn subnet is used' };
3745 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3746 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3750 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3751 $errormessage = $Lang :: tr
{ 'openvpn mssfix allowed with udp' };
3752 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3753 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3757 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'FRAGMENT' } ne '' )) {
3758 $errormessage = $Lang :: tr
{ 'openvpn fragment allowed with udp' };
3759 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3760 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3764 if ( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) {
3765 if (( $cgiparams { 'FRAGMENT' } ne '' ) || ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3766 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
3767 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3768 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3773 if (( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) && ( $cgiparams { 'MTU' } ne '1500' )) {
3774 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc and mtu not 1500' };
3775 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3776 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3780 if ( & validdotmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3781 $errormessage = $Lang :: tr
{ 'openvpn prefix local subnet' };
3782 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3783 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3787 if ( & validdotmask
( $cgiparams { 'OVPN_SUBNET' })) {
3788 $errormessage = $Lang :: tr
{ 'openvpn prefix openvpn subnet' };
3789 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3790 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3794 if ( & validdotmask
( $cgiparams { 'REMOTE_SUBNET' })) {
3795 $errormessage = $Lang :: tr
{ 'openvpn prefix remote subnet' };
3796 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3797 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3801 if ( $cgiparams { 'DEST_PORT' } <= 1023 ) {
3802 $errormessage = $Lang :: tr
{ 'ovpn port in root range' };
3803 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3804 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3808 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
3809 $cgiparams { 'OVPN_MGMT' } = $cgiparams { 'DEST_PORT' };
3812 if ( $cgiparams { 'OVPN_MGMT' } <= 1023 ) {
3813 $errormessage = $Lang :: tr
{ 'ovpn mgmt in root range' };
3814 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3815 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3818 #Check if remote subnet is used elsewhere
3819 my ( $n2nip , $n2nsub )= split ( "/" , $cgiparams { 'REMOTE_SUBNET' });
3820 $warnmessage =& General
:: checksubnets
( '' , $n2nip , 'ovpn' );
3822 $warnmessage = $Lang :: tr
{ 'remote subnet' }. " ( $cgiparams {'REMOTE_SUBNET'}) <br>" . $warnmessage ;
3826 # if (($cgiparams{'TYPE'} eq 'net') && ($cgiparams{'SIDE'} !~ /^(left|right)$/)) {
3827 # $errormessage = $Lang::tr{'ipfire side is invalid'};
3828 # goto VPNCONF_ERROR;
3831 # Check if there is no other entry with this name
3832 if (! $cgiparams { 'KEY' }) {
3833 foreach my $key ( keys %confighash ) {
3834 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
3835 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3836 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3837 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3838 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3845 # Check if a remote host/IP has been set for the client.
3846 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3847 if ( $cgiparams { 'SIDE' } ne 'server' && $cgiparams { 'REMOTE' } eq '' ) {
3848 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3850 # Check if this is a N2N connection and drop temporary config.
3851 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3852 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3857 # Check if a remote host/IP has been configured - the field can be empty on the server side.
3858 if ( $cgiparams { 'REMOTE' } ne '' ) {
3859 # Check if the given IP is valid - otherwise check if it is a valid domain.
3860 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
3861 # Check for a valid domain.
3862 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
3863 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3865 # Check if this is a N2N connection and drop temporary config.
3866 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3867 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3875 if ( $cgiparams { 'TYPE' } ne 'host' ) {
3876 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3877 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
3878 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3879 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3880 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3882 goto VPNCONF_ERROR
;}
3884 # Check if there is no other entry without IP-address and PSK
3885 if ( $cgiparams { 'REMOTE' } eq '' ) {
3886 foreach my $key ( keys %confighash ) {
3887 if (( $cgiparams { 'KEY' } ne $key ) &&
3888 ( $confighash { $key }[ 4 ] eq 'psk' || $cgiparams { 'AUTH' } eq 'psk' ) &&
3889 $confighash { $key }[ 10 ] eq '' ) {
3890 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
3895 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
3896 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
3897 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3898 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3902 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
3903 $errormessage = $Lang :: tr
{ 'invalid input' };
3906 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
3907 $errormessage = $Lang :: tr
{ 'invalid input' };
3912 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
3913 # if (! length($cgiparams{'PSK'}) ) {
3914 # $errormessage = $Lang::tr{'pre-shared key is too short'};
3915 # goto VPNCONF_ERROR;
3917 # if ($cgiparams{'PSK'} =~ /['",&]/) {
3918 # $errormessage = $Lang::tr{'invalid characters found in pre-shared key'};
3919 # goto VPNCONF_ERROR;
3921 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
3922 if ( $cgiparams { 'KEY' }) {
3923 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3926 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3927 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3931 # Move uploaded certificate request to a temporary file
3932 ( my $fh , my $filename ) = tempfile
( );
3933 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3938 # Sign the certificate request and move it
3939 # Sign the host certificate request
3940 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
3941 '-batch' , '-notext' ,
3943 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
3944 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
3946 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3948 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3949 & newcleanssldatabase
();
3953 & deletebackupcert
();
3956 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
3957 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
3959 $temp =~ s
+/ Email
+, E
+;
3960 $temp =~ s/ ST=/ S=/ ;
3961 $cgiparams { 'CERT_NAME' } = $temp ;
3962 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
3963 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
3964 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
3965 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
3968 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
3969 if ( $cgiparams { 'KEY' }) {
3970 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3973 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3974 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3977 # Move uploaded certificate to a temporary file
3978 ( my $fh , my $filename ) = tempfile
( );
3979 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3984 # Verify the certificate has a valid CA and move it
3986 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/cacert.pem $filename ` ;
3987 if ( $test =~ /: OK/ ) {
3990 foreach my $key ( keys %cahash ) {
3991 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $key }[0]cert.pem $filename ` ;
3992 if ( $test =~ /: OK/ ) {
3998 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
4002 move
( $filename , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4004 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
4010 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
4011 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
4013 $temp =~ s
+/ Email
+, E
+;
4014 $temp =~ s/ ST=/ S=/ ;
4015 $cgiparams { 'CERT_NAME' } = $temp ;
4016 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
4017 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
4018 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
4019 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4020 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
4023 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
4024 if ( $cgiparams { 'KEY' }) {
4025 $errormessage = $Lang :: tr
{ 'cant change certificates' };
4028 # Validate input since the form was submitted
4029 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
4030 $errormessage = $Lang :: tr
{ 'name too long' };
4033 if ( $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
4034 $errormessage = $Lang :: tr
{ 'invalid input for name' };
4035 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
4036 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
4039 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
4040 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
4043 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
4044 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
4047 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4048 $errormessage = $Lang :: tr
{ 'invalid input for department' };
4051 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
4052 $errormessage = $Lang :: tr
{ 'organization too long' };
4055 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
4056 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
4059 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4060 $errormessage = $Lang :: tr
{ 'invalid input for city' };
4063 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4064 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
4067 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
4068 $errormessage = $Lang :: tr
{ 'invalid input for country' };
4071 if ( $cgiparams { 'CERT_PASS1' } ne '' && $cgiparams { 'CERT_PASS2' } ne '' ){
4072 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
4073 $errormessage = $Lang :: tr
{ 'password too short' };
4077 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
4078 $errormessage = $Lang :: tr
{ 'passwords do not match' };
4082 # Replace empty strings with a .
4083 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
4084 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
4085 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
4087 # Create the Host certificate request client
4088 my $pid = open ( OPENSSL
, "|-" );
4089 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto VPNCONF_ERROR
;};
4090 if ( $pid ) { # parent
4091 print OPENSSL
" $cgiparams {'CERT_COUNTRY'} \n " ;
4092 print OPENSSL
" $state \n " ;
4093 print OPENSSL
" $city \n " ;
4094 print OPENSSL
" $cgiparams {'CERT_ORGANIZATION'} \n " ;
4095 print OPENSSL
" $ou \n " ;
4096 print OPENSSL
" $cgiparams {'CERT_NAME'} \n " ;
4097 print OPENSSL
" $cgiparams {'CERT_EMAIL'} \n " ;
4098 print OPENSSL
". \n " ;
4099 print OPENSSL
". \n " ;
4102 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4103 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4104 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4108 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
4109 '-newkey' , 'rsa:2048' ,
4110 '-keyout' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
4111 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
4112 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
4113 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
4114 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4115 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4120 # Sign the host certificate request
4121 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
4122 '-batch' , '-notext' ,
4123 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
4124 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
4125 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
4127 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4128 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4129 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4130 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4131 & newcleanssldatabase
();
4134 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4135 & deletebackupcert
();
4138 # Create the pkcs12 file
4139 system ( '/usr/bin/openssl' , 'pkcs12' , '-export' ,
4140 '-inkey' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
4141 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
4142 '-name' , $cgiparams { 'NAME' },
4143 '-passout' , "pass: $cgiparams {'CERT_PASS1'}" ,
4144 '-certfile' , "${General::swroot}/ovpn/ca/cacert.pem" ,
4145 '-caname' , " $vpnsettings {'ROOTCERT_ORGANIZATION'} CA" ,
4146 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
4148 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4149 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4150 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4151 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
4154 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4156 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
4157 ; # Nothing, just editing
4159 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
4163 # Check if there is no other entry with this common name
4164 if ((! $cgiparams { 'KEY' }) && ( $cgiparams { 'AUTH' } ne 'psk' )) {
4165 foreach my $key ( keys %confighash ) {
4166 if ( $confighash { $key }[ 2 ] eq $cgiparams { 'CERT_NAME' }) {
4167 $errormessage = $Lang :: tr
{ 'a connection with this common name already exists' };
4174 my $key = $cgiparams { 'KEY' };
4177 $key = & General
:: findhasharraykey
( \
%confighash );
4178 foreach my $i ( 0 .. 43 ) { $confighash { $key }[ $i ] = "" ;}
4180 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
4181 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
4182 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
4183 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
4186 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
4187 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
4188 $confighash { $key }[ 4 ] = 'psk' ;
4189 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
4191 $confighash { $key }[ 4 ] = 'cert' ;
4193 if ( $cgiparams { 'TYPE' } eq 'net' ) {
4194 $confighash { $key }[ 6 ] = $cgiparams { 'SIDE' };
4195 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
4197 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
4198 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
4199 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
4200 $confighash { $key }[ 22 ] = $confighash { $key }[ 29 ];
4202 $confighash { $key }[ 22 ] = $cgiparams { 'OVPN_MGMT' };
4204 $confighash { $key }[ 23 ] = $cgiparams { 'MSSFIX' };
4205 $confighash { $key }[ 24 ] = $cgiparams { 'FRAGMENT' };
4206 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
4207 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
4209 $confighash { $key }[ 27 ] = $cgiparams { 'OVPN_SUBNET' };
4210 $confighash { $key }[ 28 ] = $cgiparams { 'PROTOCOL' };
4211 $confighash { $key }[ 29 ] = $cgiparams { 'DEST_PORT' };
4212 $confighash { $key }[ 30 ] = $cgiparams { 'COMPLZO' };
4213 $confighash { $key }[ 31 ] = $cgiparams { 'MTU' };
4214 $confighash { $key }[ 32 ] = $cgiparams { 'CHECK1' };
4215 $name = $cgiparams { 'CHECK1' };
4216 $confighash { $key }[ 33 ] = $cgiparams { $name };
4217 $confighash { $key }[ 34 ] = $cgiparams { 'RG' };
4218 $confighash { $key }[ 35 ] = $cgiparams { 'CCD_DNS1' };
4219 $confighash { $key }[ 36 ] = $cgiparams { 'CCD_DNS2' };
4220 $confighash { $key }[ 37 ] = $cgiparams { 'CCD_WINS' };
4221 $confighash { $key }[ 38 ] = $cgiparams { 'PMTU_DISCOVERY' };
4222 $confighash { $key }[ 39 ] = $cgiparams { 'DAUTH' };
4223 $confighash { $key }[ 40 ] = $cgiparams { 'DCIPHER' };
4224 $confighash { $key }[ 42 ] = $cgiparams { 'ENGINES' };
4227 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4229 if ( $cgiparams { 'CHECK1' } ){
4231 my ( $ccdip , $ccdsub )= split "/" , $cgiparams { $name };
4232 my ( $a , $b , $c , $d ) = split ( /\./ , $ccdip );
4233 if ( - e
"${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ){
4234 unlink "${General::swroot}/ovpn/ccd/ $cgiparams {'CERT_NAME'}" ;
4236 open ( CCDRWCONF
, '>' , "${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ) or die "Unable to create clientconfigfile $!" ;
4237 print CCDRWCONF
"# OpenVPN clientconfig from ccd extension by Copymaster# \n\n " ;
4238 if ( $cgiparams { 'CHECK1' } eq 'dynamic' ){
4239 print CCDRWCONF
"#This client uses the dynamic pool \n " ;
4241 print CCDRWCONF
"#Ip address client and server \n " ;
4242 print CCDRWCONF
"ifconfig-push $ccdip " .& General
:: getlastip
( $ccdip , 1 ). " \n " ;
4244 if ( $confighash { $key }[ 34 ] eq 'on' ){
4245 print CCDRWCONF
" \n #Redirect Gateway: \n #All IP traffic is redirected through the vpn \n " ;
4246 print CCDRWCONF
"push redirect-gateway \n " ;
4248 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4249 if ( $cgiparams { 'IR' } ne '' ){
4250 print CCDRWCONF
" \n #Client routes these networks (behind Client) \n " ;
4251 foreach my $key ( keys %ccdroutehash ){
4252 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4253 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
4254 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
4255 print CCDRWCONF
"iroute $a $b \n " ;
4260 if ( $cgiparams { 'IFROUTE' } eq $Lang :: tr
{ 'ccd none' } ){ $cgiparams { 'IFROUTE' }= '' ;}
4261 if ( $cgiparams { 'IFROUTE' } ne '' ){
4262 print CCDRWCONF
" \n #Client gets routes to these networks (behind IPFire) \n " ;
4263 foreach my $key ( keys %ccdroute2hash ){
4264 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4265 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}){
4266 if ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'blue' }){
4268 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%blue );
4269 print CCDRWCONF
"push \" route $blue {BLUE_ADDRESS} $blue {BLUE_NETMASK} \n " ;
4270 } elsif ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'orange' }){
4272 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%orange );
4273 print CCDRWCONF
"push \" route $orange {ORANGE_ADDRESS} $orange {ORANGE_NETMASK} \n " ;
4275 my ( $a , $b )= split ( /\/ /, $ccdroute2hash { $key }[ $i ]);
4276 print CCDRWCONF
"push \" route $a $b \"\n " ;
4282 if (( $cgiparams { 'CCD_DNS1' } eq '' ) && ( $cgiparams { 'CCD_DNS1' } ne '' )){ $cgiparams { 'CCD_DNS1' } = $cgiparams { 'CCD_DNS2' }; $cgiparams { 'CCD_DNS2' }= '' ;}
4283 if ( $cgiparams { 'CCD_DNS1' } ne '' ){
4284 print CCDRWCONF
" \n #Client gets these nameservers \n " ;
4285 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS1'} \" \n " ;
4287 if ( $cgiparams { 'CCD_DNS2' } ne '' ){
4288 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS2'} \" \n " ;
4290 if ( $cgiparams { 'CCD_WINS' } ne '' ){
4291 print CCDRWCONF
" \n #Client gets this WINS server \n " ;
4292 print CCDRWCONF
"push \" dhcp-option WINS $cgiparams {'CCD_WINS'} \" \n " ;
4301 if ( $cgiparams { 'TYPE' } eq 'net' ) {
4303 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
4304 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4306 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4307 my $key = $cgiparams { 'KEY' };
4309 $key = & General
:: findhasharraykey
( \
%confighash );
4310 foreach my $i ( 0 .. 31 ) { $confighash { $key }[ $i ] = "" ;}
4312 $confighash { $key }[ 0 ] = 'on' ;
4313 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4315 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4323 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
4324 $cgiparams { 'KEY' } = $key ;
4325 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
4329 $cgiparams { 'ENABLED' } = 'on' ;
4333 $cgiparams { 'MSSFIX' } = 'on' ;
4334 $cgiparams { 'FRAGMENT' } = '1300' ;
4335 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4336 $cgiparams { 'DAUTH' } = 'SHA1' ;
4337 $cgiparams { 'ENGINES' } = 'disabled' ;
4341 $cgiparams { 'SIDE' } = 'left' ;
4342 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) {
4343 $cgiparams { 'AUTH' } = 'psk' ;
4344 } elsif ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4345 $cgiparams { 'AUTH' } = 'certfile' ;
4347 $cgiparams { 'AUTH' } = 'certgen' ;
4349 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
4350 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
4351 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
4352 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
4353 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
4357 $checked { 'ENABLED' }{ 'off' } = '' ;
4358 $checked { 'ENABLED' }{ 'on' } = '' ;
4359 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4360 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4361 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4362 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4363 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4364 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4365 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4368 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
4369 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
4370 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = 'CHECKED' ;
4372 $selected { 'SIDE' }{ 'server' } = '' ;
4373 $selected { 'SIDE' }{ 'client' } = '' ;
4374 $selected { 'SIDE' }{ $cgiparams { 'SIDE' }} = 'SELECTED' ;
4376 $selected { 'PROTOCOL' }{ 'udp' } = '' ;
4377 $selected { 'PROTOCOL' }{ 'tcp' } = '' ;
4378 $selected { 'PROTOCOL' }{ $cgiparams { 'PROTOCOL' }} = 'SELECTED' ;
4381 $checked { 'AUTH' }{ 'psk' } = '' ;
4382 $checked { 'AUTH' }{ 'certreq' } = '' ;
4383 $checked { 'AUTH' }{ 'certgen' } = '' ;
4384 $checked { 'AUTH' }{ 'certfile' } = '' ;
4385 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = 'CHECKED' ;
4387 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = 'SELECTED' ;
4389 $checked { 'COMPLZO' }{ 'off' } = '' ;
4390 $checked { 'COMPLZO' }{ 'on' } = '' ;
4391 $checked { 'COMPLZO' }{ $cgiparams { 'COMPLZO' }} = 'CHECKED' ;
4393 $checked { 'MSSFIX' }{ 'off' } = '' ;
4394 $checked { 'MSSFIX' }{ 'on' } = '' ;
4395 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4397 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
4398 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4400 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
4402 $selected { 'DCIPHER' }{ 'CAMELLIA-256-CBC' } = '' ;
4403 $selected { 'DCIPHER' }{ 'CAMELLIA-192-CBC' } = '' ;
4404 $selected { 'DCIPHER' }{ 'CAMELLIA-128-CBC' } = '' ;
4405 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4406 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4407 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4408 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4409 $selected { 'DCIPHER' }{ 'SEED-CBC' } = '' ;
4410 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4411 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4412 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4413 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4414 $selected { 'DCIPHER' }{ 'RC2-CBC' } = '' ;
4415 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4416 $selected { 'DCIPHER' }{ 'RC2-64-CBC' } = '' ;
4417 $selected { 'DCIPHER' }{ 'RC2-40-CBC' } = '' ;
4418 # If no cipher has been chossen yet, select
4419 # the old default (AES-256-CBC) for compatiblity reasons.
4420 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4421 $cgiparams { 'DCIPHER' } = 'AES-256-CBC' ;
4423 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4424 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
4425 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
4426 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
4427 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
4428 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
4429 # If no hash algorythm has been choosen yet, select
4430 # the old default value (SHA1) for compatiblity reasons.
4431 if ( $cgiparams { 'DAUTH' } eq '' ) {
4432 $cgiparams { 'DAUTH' } = 'SHA1' ;
4434 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
4436 $selected { 'ENGINES' }{ 'disabled' } = '' ;
4437 $selected { 'ENGINES' }{ 'cryptodev' } = '' ;
4438 $selected { 'ENGINES' }{ 'dynamic' } = '' ;
4439 $selected { 'ENGINES' }{ 'aesni' } = '' ;
4440 $selected { 'ENGINES' }{ 'padlock' } = '' ;
4441 # If no engine has been choosen yet, select
4442 # a default one (disabled).
4443 if ( $cgiparams { 'ENGINES' } eq '' ) {
4444 $cgiparams { 'ENGINES' } = 'disabled' ;
4446 $selected { 'ENGINES' }{ $cgiparams { 'ENGINES' }} = 'SELECTED' ;
4449 & Header
:: showhttpheaders
();
4450 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
4451 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4452 if ( $errormessage ) {
4453 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4454 print "<class name='base'> $errormessage " ;
4455 print " </class>" ;
4456 & Header
:: closebox
();
4460 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'warning messages'}:" );
4461 print "<class name='base'> $warnmessage " ;
4462 print " </class>" ;
4463 & Header
:: closebox
();
4466 print "<form method='post' enctype='multipart/form-data'>" ;
4467 print "<input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />" ;
4469 if ( $cgiparams { 'KEY' }) {
4470 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
4471 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
4474 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'connection'}:" );
4475 print "<table width='100%' border='0'> \n " ;
4479 print "<tr><td width='14%' class='boldbase'> $Lang ::tr{'name'}: </td>" ;
4481 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4482 if ( $cgiparams { 'KEY' }) {
4483 print "<td width='35%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4486 print "<td width='35%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' size='30' /></td>" ;
4488 # print "<tr><td>$Lang::tr{'interface'}</td>";
4489 # print "<td><select name='INTERFACE'>";
4490 # print "<option value='RED' $selected{'INTERFACE'}{'RED'}>RED</option>";
4491 # if ($netsettings{'BLUE_DEV'} ne '') {
4492 # print "<option value='BLUE' $selected{'INTERFACE'}{'BLUE'}>BLUE</option>";
4494 # print "<option value='GREEN' $selected{'INTERFACE'}{'GREEN'}>GREEN</option>";
4495 # print "<option value='ORANGE' $selected{'INTERFACE'}{'ORANGE'}>ORANGE</option>";
4496 # print "</select></td></tr>";
4499 print "<input type='hidden' name='INTERFACE' value='red' />" ;
4500 if ( $cgiparams { 'KEY' }) {
4501 print "<td width='25%' class='base' nowrap='nowrap'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4503 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' /></td>" ;
4509 <td width='25%'> </td>
4510 <td width='25%'> </td></tr>
4511 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td>
4512 <td><select name='SIDE'><option value='server' $selected {'SIDE'}{'server'}> $Lang ::tr{'openvpn server'}</option>
4513 <option value='client' $selected {'SIDE'}{'client'}> $Lang ::tr{'openvpn client'}</option></select></td>
4515 <td class='boldbase'> $Lang ::tr{'remote host/ip'}:</td>
4516 <td><input type='TEXT' name='REMOTE' value=' $cgiparams {'REMOTE'}' /></td></tr>
4518 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
4519 <td><input type='TEXT' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' /></td>
4521 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
4522 <td><input type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' /></td></tr>
4524 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td>
4525 <td><input type='TEXT' name='OVPN_SUBNET' value=' $cgiparams {'OVPN_SUBNET'}' /></td></tr>
4528 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
4529 <td><select name='PROTOCOL'><option value='udp' $selected {'PROTOCOL'}{'udp'}>UDP</option>
4530 <option value='tcp' $selected {'PROTOCOL'}{'tcp'}>TCP</option></select></td>
4532 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
4533 <td><input type='TEXT' name='DEST_PORT' value=' $cgiparams {'DEST_PORT'}' size='5' /></td>
4536 <tr><td class='boldbase'> $Lang ::tr{'cipher'}</td>
4537 <td><select name='DCIPHER'>
4538 <option value='CAMELLIA-256-CBC' $selected {'DCIPHER'}{'CAMELLIA-256-CBC'}>CAMELLIA-CBC (256 $Lang ::tr{'bit'})</option>
4539 <option value='CAMELLIA-192-CBC' $selected {'DCIPHER'}{'CAMELLIA-192-CBC'}>CAMELLIA-CBC (196 $Lang ::tr{'bit'})</option>
4540 <option value='CAMELLIA-128-CBC' $selected {'DCIPHER'}{'CAMELLIA-128-CBC'}>CAMELLIA-CBC (128 $Lang ::tr{'bit'})</option>
4541 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-CBC (256 $Lang ::tr{'bit'})</option>
4542 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-CBC (192 $Lang ::tr{'bit'})</option>
4543 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-CBC (128 $Lang ::tr{'bit'})</option>
4544 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC (192 $Lang ::tr{'bit'})</option>
4545 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC (192 $Lang ::tr{'bit'})</option>
4546 <option value='SEED-CBC' $selected {'DCIPHER'}{'SEED-CBC'}>SEED-CBC (128 $Lang ::tr{'bit'})</option>
4547 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC (128 $Lang ::tr{'bit'})</option>
4548 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC (128 $Lang ::tr{'bit'})</option>
4549 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC (128 $Lang ::tr{'bit'})</option>
4550 <option value='RC2-CBC' $selected {'DCIPHER'}{'RC2-CBC'}>RC2-CBC (128 $Lang ::tr{'bit'})</option>
4551 <option value='DES-CBC' $selected {'DCIPHER'}{'DES-CBC'}>DES-CBC (64 $Lang ::tr{'bit'} not recommended)</option>
4552 <option value='RC2-64-CBC' $selected {'DCIPHER'}{'RC2-64-CBC'}>RC2-CBC (64 $Lang ::tr{'bit'} not recommended)</option>
4553 <option value='RC2-40-CBC' $selected {'DCIPHER'}{'RC2-40-CBC'}>RC2-CBC (40 $Lang ::tr{'bit'} not recommended)</option>
4557 <td class='boldbase'> $Lang ::tr{'ovpn ha'}:</td>
4558 <td><select name='DAUTH'>
4559 <option value='whirlpool' $selected {'DAUTH'}{'whirlpool'}>Whirlpool (512 $Lang ::tr{'bit'})</option>
4560 <option value='SHA512' $selected {'DAUTH'}{'SHA512'}>SHA2 (512 $Lang ::tr{'bit'})</option>
4561 <option value='SHA384' $selected {'DAUTH'}{'SHA384'}>SHA2 (384 $Lang ::tr{'bit'})</option>
4562 <option value='SHA256' $selected {'DAUTH'}{'SHA256'}>SHA2 (256 $Lang ::tr{'bit'})</option>
4563 <option value='SHA1' $selected {'DAUTH'}{'SHA1'}>SHA1 (160 $Lang ::tr{'bit'} Default)</option>
4568 <tr> <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn engines'} <img src='/blob.gif'</td>
4569 <td><select name='ENGINES'>
4570 <option value='cryptodev' $selected {'ENGINES'}{'cryptodev'}>Cryptodev</option>
4571 <option value='dynamic' $selected {'ENGINES'}{'dynamic'}>Dynamic</option>
4572 <option value='aesni' $selected {'ENGINES'}{'aesni'}>AES-NI</option>
4573 <option value='padlock' $selected {'ENGINES'}{'padlock'}>Padlock</option>
4574 <option value='disabled' $selected {'ENGINES'}{'disabled'}> $Lang ::tr{'disabled'} (Default)</option>
4579 <tr><td colspan=2><hr /></td></tr><tr>
4581 <tr><td class='boldbase' nowrap='nowrap'>Management Port ( $Lang ::tr{'openvpn default'}: <span class="base"> $Lang ::tr{'destination port'}): <img src='/blob.gif' /></td>
4582 <td> <input type='TEXT' name='OVPN_MGMT' VALUE=' $cgiparams {'OVPN_MGMT'}'size='5' /></td>
4585 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} <img src='/blob.gif' /></td>
4586 <td> <input type='TEXT' name='MTU' VALUE=' $cgiparams {'MTU'}'size='5' /></td>
4587 <td colspan='2'> $Lang ::tr{'openvpn default'}: udp/tcp <span class="base">1500/1400</span></td>
4590 <tr><td class='boldbase' nowrap='nowrap'>fragment <img src='/blob.gif' /></td>
4591 <td><input type='TEXT' name='FRAGMENT' VALUE=' $cgiparams {'FRAGMENT'}'size='5' /></td>
4592 <td> $Lang ::tr{'openvpn default'}: <span class="base">1300</span></td>
4595 <tr><td class='boldbase' nowrap='nowrap'>mssfix <img src='/blob.gif' /></td>
4596 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
4597 <td> $Lang ::tr{'openvpn default'}: <span class="base">on</span></td>
4600 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'} <img src='/blob.gif'</td>
4601 <td><input type='checkbox' name='COMPLZO' $checked {'COMPLZO'}{'on'} /></td>
4604 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td>
4606 <input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}
4607 <input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}
4608 <input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}
4609 <input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}
4617 print "<tr><td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' /></td>" ;
4618 print "<td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td></tr></table>" ;
4620 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4621 print "<tr><td> $Lang ::tr{'enabled'} <input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>" ;
4624 print "</tr></table><br><br>" ;
4625 #A.Marx CCD new client
4626 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4627 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>" ;
4630 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnnet );
4631 $vpnip = $vpnnet { 'DOVPN_SUBNET' };
4632 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
4636 $checked { 'check1' }{ 'off' } = '' ;
4637 $checked { 'check1' }{ 'on' } = '' ;
4638 $checked { 'check1' }{ $cgiparams { 'CHECK1' }} = 'CHECKED' ;
4639 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%'>" ;
4640 print "</td></tr></table><br><br>" ;
4641 my $name = $cgiparams { 'CHECK1' };
4642 $checked { 'RG' }{ $cgiparams { 'RG' }} = 'CHECKED' ;
4644 if (! - z
"${General::swroot}/ovpn/ccd.conf" ){
4645 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>" ;
4646 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
4648 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
4649 if ( $count % 2 ){ print "<tr bgcolor=' $color {'color22'}'>" ;} else { print "<tr bgcolor=' $color {'color20'}'>" ;}
4650 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%'>" ;
4651 & fillselectbox
( $ccdconf [ 1 ], $ccdconf [ 0 ], $cgiparams { $name });
4654 print "</table><br><br><hr><br><br>" ;
4658 & Header
:: closebox
();
4659 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
4661 } elsif (! $cgiparams { 'KEY' }) {
4665 my $cakeydisabled = '' ;
4666 my $cacrtdisabled = '' ;
4667 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) { $cakeydisabled = "disabled='disabled'" } else { $cakeydisabled = "" };
4668 if ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) { $cacrtdisabled = "disabled='disabled'" } else { $cacrtdisabled = "" };
4670 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'authentication' });
4673 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4676 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4678 <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>
4679 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td><td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
4680 <tr><td colspan='3'> </td></tr>
4681 <tr><td colspan='3'><hr /></td></tr>
4682 <tr><td colspan='3'> </td></tr>
4683 <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>
4684 <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>
4685 <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>
4686 <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>
4687 <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>
4688 <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>
4689 <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>
4690 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4701 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4703 <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>
4704 <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>
4705 <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>
4706 <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>
4707 <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>
4708 <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>
4709 <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>
4710 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4722 foreach my $country ( sort keys %{ Countries
:: countries
}) {
4723 print "<option value=' $Countries ::countries{ $country }'" ;
4724 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
4725 print " selected='selected'" ;
4727 print "> $country </option>" ;
4733 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4737 <td> </td><td class='base'> $Lang ::tr{'valid till'} (days):</td>
4738 <td class='base' nowrap='nowrap'><input type='text' name='DAYS_VALID' value=' $cgiparams {'DAYS_VALID'}' size='32' $cakeydisabled /></td></tr>
4740 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
4741 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
4742 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:<br>( $Lang ::tr{'confirmation'})</td>
4743 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
4744 <tr><td colspan='3'> </td></tr>
4745 <tr><td colspan='3'><hr /></td></tr>
4746 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4752 <tr><td> </td><td> </td><td> </td></tr>
4753 <tr><td> </td><td> </td><td> </td></tr>
4754 <tr><td colspan='3'><hr /></td></tr>
4755 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4765 & Header
:: closebox
();
4769 #A.Marx CCD new client
4770 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4772 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ccd client options'}:" );
4776 <table border='0' width='100%'>
4777 <tr><td width='20%'>Redirect Gateway:</td><td colspan='3'><input type='checkbox' name='RG' $checked {'RG'}{'on'} /></td></tr>
4778 <tr><td colspan='4'><b><br> $Lang ::tr{'ccd routes'}</b></td></tr>
4779 <tr><td colspan='4'> </td></tr>
4780 <tr><td valign='top'> $Lang ::tr{'ccd iroute'}</td><td align='left' width='30%'><textarea name='IR' cols='26' rows='6' wrap='off'>
4783 if ( $cgiparams { 'IR' } ne '' ){
4784 print $cgiparams { 'IR' };
4786 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4787 foreach my $key ( keys %ccdroutehash ) {
4788 if ( $cgiparams { 'NAME' } eq $ccdroutehash { $key }[ 0 ]){
4789 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
4790 if ( $ccdroutehash { $key }[ $i ] ne '' ){
4791 print $ccdroutehash { $key }[ $i ]. " \n " ;
4793 $cgiparams { 'IR' } .= $ccdroutehash { $key }[ $i ];
4800 </textarea></td><td valign='top' colspan='2'> $Lang ::tr{'ccd iroutehint'}</td></tr>
4801 <tr><td colspan='4'><br></td></tr>
4802 <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>
4816 open ( FILE
, "${General::swroot}/main/routing" ) ;
4819 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
4821 foreach my $key ( keys %ccdroute2hash ) {
4822 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4823 if ( $ccdroute2hash { $key }[ 1 ] eq '' ){
4830 print "<option> $Lang ::tr{'ccd none'}</option>" ;
4832 print "<option selected> $Lang ::tr{'ccd none'}</option>" ;
4834 #check if static routes are defined for client
4835 foreach my $line ( @current ) {
4837 $line =~ s/\s*$//g ; # remove newline
4838 @temp = split ( /\,/ , $line );
4839 $temp [ 1 ] = '' unless defined $temp [ 1 ]; # not always populated
4840 my ( $a , $b ) = split ( /\/ /, $temp [ 1 ]);
4841 $temp [ 1 ] = $a . "/" .& General
:: iporsubtocidr
( $b );
4842 foreach my $key ( keys %ccdroute2hash ) {
4843 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4844 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4845 if ( $ccdroute2hash { $key }[ $i ] eq $a . "/" .& General
:: iporsubtodec
( $b )){
4851 if ( $set == '1' && $#temp != - 1 ){ print "<option selected> $temp [1]</option>" ; $set = 0 ;} elsif ( $set == '0' && $#temp != - 1 ){ print "<option> $temp [1]</option>" ;}
4853 #check if green,blue,orange are defined for client
4854 foreach my $key ( keys %ccdroute2hash ) {
4855 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4857 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4858 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'GREEN_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'GREEN_NETMASK' })){
4861 if (& haveBlueNet
()){
4862 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'BLUE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'BLUE_NETMASK' })) {
4866 if (& haveOrangeNet
()){
4867 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'ORANGE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'ORANGE_NETMASK' }) ) {
4874 if (& haveBlueNet
() && $selblue == '1' ){ print "<option selected> $Lang ::tr{'blue'}</option>" ; $selblue = 0 ;} elsif (& haveBlueNet
() && $selblue == '0' ){ print "<option> $Lang ::tr{'blue'}</option>" ;}
4875 if (& haveOrangeNet
() && $selorange == '1' ){ print "<option selected> $Lang ::tr{'orange'}</option>" ; $selorange = 0 ;} elsif (& haveOrangeNet
() && $selorange == '0' ){ print "<option> $Lang ::tr{'orange'}</option>" ;}
4876 if ( $selgreen == '1' || $other == '0' ){ print "<option selected> $Lang ::tr{'green'}</option>" ; $set = 0 ;} else { print "<option> $Lang ::tr{'green'}</option>" ;};
4879 </select></td><td valign='top'>DNS1:</td><td valign='top'><input type='TEXT' name='CCD_DNS1' value=' $cgiparams {'CCD_DNS1'}' size='30' /></td></tr>
4880 <tr valign='top'><td>DNS2:</td><td><input type='TEXT' name='CCD_DNS2' value=' $cgiparams {'CCD_DNS2'}' size='30' /></td></tr>
4881 <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>
4885 & Header
:: closebox
();
4887 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
4888 if ( $cgiparams { 'KEY' }) {
4889 # print "<input type='submit' name='ACTION' value='$Lang::tr{'advanced'}' />";
4891 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
4892 & Header
:: closebigbox
();
4893 & Header
:: closepage
();
4901 ### Default status page
4906 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
4907 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
4908 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4910 my @status = `/bin/cat /var/log/ovpnserver.log` ;
4912 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
4913 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
4914 my $ipaddr = < IPADDR
>;
4917 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
4918 if ( $cgiparams { 'VPN_IP' } eq '' ) {
4919 $cgiparams { 'VPN_IP' } = $ipaddr ;
4925 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4926 $cgiparams { 'DCIPHER' } = 'AES-256-CBC' ;
4928 if ( $cgiparams { 'DDEST_PORT' } eq '' ) {
4929 $cgiparams { 'DDEST_PORT' } = '1194' ;
4931 if ( $cgiparams { 'DMTU' } eq '' ) {
4932 $cgiparams { 'DMTU' } = '1400' ;
4934 if ( $cgiparams { 'ENGINES' } eq '' ) {
4935 $cgiparams { 'ENGINES' } = 'disabled' ;
4937 if ( $cgiparams { 'DOVPN_SUBNET' } eq '' ) {
4938 $cgiparams { 'DOVPN_SUBNET' } = '10.' . int ( rand ( 256 )) . '.' . int ( rand ( 256 )) . '.0/255.255.255.0' ;
4940 $checked { 'ENABLED' }{ 'off' } = '' ;
4941 $checked { 'ENABLED' }{ 'on' } = '' ;
4942 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4943 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4944 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4945 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4946 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4947 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4948 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4949 $selected { 'DDEVICE' }{ 'tun' } = '' ;
4950 $selected { 'DDEVICE' }{ 'tap' } = '' ;
4951 $selected { 'DDEVICE' }{ $cgiparams { 'DDEVICE' }} = 'SELECTED' ;
4953 $selected { 'DPROTOCOL' }{ 'udp' } = '' ;
4954 $selected { 'DPROTOCOL' }{ 'tcp' } = '' ;
4955 $selected { 'DPROTOCOL' }{ $cgiparams { 'DPROTOCOL' }} = 'SELECTED' ;
4957 $selected { 'DCIPHER' }{ 'CAMELLIA-256-CBC' } = '' ;
4958 $selected { 'DCIPHER' }{ 'CAMELLIA-192-CBC' } = '' ;
4959 $selected { 'DCIPHER' }{ 'CAMELLIA-128-CBC' } = '' ;
4960 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4961 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4962 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4963 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4964 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4965 $selected { 'DCIPHER' }{ 'SEED-CBC' } = '' ;
4966 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4967 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4968 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4969 $selected { 'DCIPHER' }{ 'RC2-CBC' } = '' ;
4970 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4971 $selected { 'DCIPHER' }{ 'RC2-64-CBC' } = '' ;
4972 $selected { 'DCIPHER' }{ 'RC2-40-CBC' } = '' ;
4973 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4975 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
4976 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
4977 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
4978 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
4979 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
4980 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
4982 $selected { 'ENGINES' }{ 'cryptodev' } = '' ;
4983 $selected { 'ENGINES' }{ 'dynamic' } = '' ;
4984 $selected { 'ENGINES' }{ 'aesni' } = '' ;
4985 $selected { 'ENGINES' }{ 'padlock' } = '' ;
4986 $selected { 'ENGINES' }{ 'disabled' } = '' ;
4987 $selected { 'ENGINES' }{ $cgiparams { 'ENGINES' }} = 'SELECTED' ;
4989 $checked { 'DCOMPLZO' }{ 'off' } = '' ;
4990 $checked { 'DCOMPLZO' }{ 'on' } = '' ;
4991 $checked { 'DCOMPLZO' }{ $cgiparams { 'DCOMPLZO' }} = 'CHECKED' ;
4993 $checked { 'MSSFIX' }{ 'off' } = '' ;
4994 $checked { 'MSSFIX' }{ 'on' } = '' ;
4995 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4997 & Header
:: showhttpheaders
();
4998 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
4999 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
5001 if ( $errormessage ) {
5002 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
5003 print "<class name='base'> $errormessage \n " ;
5004 print " </class> \n " ;
5005 & Header
:: closebox
();
5009 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'warning messages' });
5010 print " $warnmessage <br>" ;
5011 print " $Lang ::tr{'fwdfw warn1'}<br>" ;
5012 & Header
:: closebox
();
5013 print "<center><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'ok'}' style='width: 5em;'></form>" ;
5014 & Header
:: closepage
();
5018 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>" ;
5019 my $srunning = "no" ;
5020 my $activeonrun = "" ;
5021 if ( - e
"/var/run/openvpn.pid" ){
5022 $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>" ;
5026 $activeonrun = "disabled='disabled'" ;
5028 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'global settings' });
5030 <table width='100%' border='0'>
5031 <form method='post'>
5032 <td width='25%'> </td>
5033 <td width='25%'> </td>
5034 <td width='25%'> </td></tr>
5035 <tr><td class='boldbase'> $Lang ::tr{'ovpn server status'}</td>
5036 <td align='left'> $sactive </td>
5037 <tr><td class='boldbase'> $Lang ::tr{'ovpn on red'}</td>
5038 <td><input type='checkbox' name='ENABLED' $checked {'ENABLED'}{'on'} /></td>
5041 if (& haveBlueNet
()) {
5042 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on blue'}</td>" ;
5043 print "<td><input type='checkbox' name='ENABLED_BLUE' $checked {'ENABLED_BLUE'}{'on'} /></td>" ;
5045 if (& haveOrangeNet
()) {
5046 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on orange'}</td>" ;
5047 print "<td><input type='checkbox' name='ENABLED_ORANGE' $checked {'ENABLED_ORANGE'}{'on'} /></td>" ;
5050 <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>
5051 <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>
5052 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn device'}</td>
5053 <td><select name='DDEVICE' ><option value='tun' $selected {'DDEVICE'}{'tun'}>TUN</option>
5054 <!-- this is still not working
5055 <option value='tap' $selected {'DDEVICE'}{'tap'}>TAP</option></select>--> </td>
5056 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
5057 <td><select name='DPROTOCOL'><option value='udp' $selected {'DPROTOCOL'}{'udp'}>UDP</option>
5058 <option value='tcp' $selected {'DPROTOCOL'}{'tcp'}>TCP</option></select></td>
5059 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
5060 <td><input type='TEXT' name='DDEST_PORT' value=' $cgiparams {'DDEST_PORT'}' size='5' /></td></tr>
5061 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} </td>
5062 <td> <input type='TEXT' name='DMTU' VALUE=' $cgiparams {'DMTU'}'size='5' /></td>
5064 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td>
5065 <td><select name='DCIPHER'>
5066 <option value='CAMELLIA-256-CBC' $selected {'DCIPHER'}{'CAMELLIA-256-CBC'}>CAMELLIA-CBC (256 $Lang ::tr{'bit'})</option>
5067 <option value='CAMELLIA-192-CBC' $selected {'DCIPHER'}{'CAMELLIA-192-CBC'}>CAMELLIA-CBC (196 $Lang ::tr{'bit'})</option>
5068 <option value='CAMELLIA-128-CBC' $selected {'DCIPHER'}{'CAMELLIA-128-CBC'}>CAMELLIA-CBC (128 $Lang ::tr{'bit'})</option>
5069 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-CBC (256 $Lang ::tr{'bit'})</option>
5070 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-CBC (192 $Lang ::tr{'bit'})</option>
5071 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-CBC (128 $Lang ::tr{'bit'})</option>
5072 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC (192 $Lang ::tr{'bit'})</option>
5073 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC (192 $Lang ::tr{'bit'})</option>
5074 <option value='SEED-CBC' $selected {'DCIPHER'}{'SEED-CBC'}>SEED-CBC (128 $Lang ::tr{'bit'})</option>
5075 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC (128 $Lang ::tr{'bit'})</option>
5076 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC (128 $Lang ::tr{'bit'})</option>
5077 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC (128 $Lang ::tr{'bit'})</option>
5078 <option value='RC2-CBC' $selected {'DCIPHER'}{'RC2-CBC'}>RC2-CBC (128 $Lang ::tr{'bit'})</option>
5079 <option value='DES-CBC' $selected {'DCIPHER'}{'DES-CBC'}>DES-CBC (64 $Lang ::tr{'bit'} not recommended)</option>
5080 <option value='RC2-64-CBC' $selected {'DCIPHER'}{'RC2-64-CBC'}>RC2-CBC (64 $Lang ::tr{'bit'} not recommended)</option>
5081 <option value='RC2-40-CBC' $selected {'DCIPHER'}{'RC2-40-CBC'}>RC2-CBC (40 $Lang ::tr{'bit'} not recommended)</option>
5084 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td>
5085 <td><input type='checkbox' name='DCOMPLZO' $checked {'DCOMPLZO'}{'on'} /></td>
5088 <tr><td colspan='4'><br><br></td></tr>
5092 if ( $srunning eq "yes" ) {
5093 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' disabled='disabled' />" ;
5094 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
5095 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
5096 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'stop ovpn server'}' /></td></tr>" ;
5098 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
5099 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
5100 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
5101 if (( - e
"${General::swroot}/ovpn/ca/cacert.pem" &&
5102 - e
"${General::swroot}/ovpn/ca/dh1024.pem" &&
5103 - e
"${General::swroot}/ovpn/certs/servercert.pem" &&
5104 - e
"${General::swroot}/ovpn/certs/serverkey.pem" ) &&
5105 (( $cgiparams { 'ENABLED' } eq 'on' ) ||
5106 ( $cgiparams { 'ENABLED_BLUE' } eq 'on' ) ||
5107 ( $cgiparams { 'ENABLED_ORANGE' } eq 'on' ))){
5108 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' /></td></tr>" ;
5110 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' disabled='disabled' /></td></tr>" ;
5113 print "</form></table>" ;
5114 & Header
:: closebox
();
5116 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5120 #<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>
5123 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection status and controlc' });
5127 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5129 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5130 <th width='15%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></th>
5131 <th width='22%' class='boldbase' align='center'><b> $Lang ::tr{'network'}</b></th>
5132 <th width='20%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></th>
5133 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></th>
5134 <th width='5%' class='boldbase' colspan='6' align='center'><b> $Lang ::tr{'action'}</b></th>
5141 foreach my $key ( sort { ncmp
( $confighash { $a }[ 1 ], $confighash { $b }[ 1 ]) } keys %confighash ) {
5142 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
5145 $col = "bgcolor=' $color {'color20'}'" ;
5148 $col = "bgcolor=' $color {'color22'}'" ;
5150 print "<td align='center' nowrap='nowrap' $col > $confighash { $key }[1]</td>" ;
5151 print "<td align='center' nowrap='nowrap' $col >" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
5152 #if ($confighash{$key}[4] eq 'cert') {
5153 #print "<td align='left' nowrap='nowrap'>$confighash{$key}[2]</td>";
5155 #print "<td align='left'> </td>";
5157 my $cavalid = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
5158 $cavalid =~ /Not After : (.*)[\n]/ ;
5160 if ( $confighash { $key }[ 32 ] eq "" && $confighash { $key }[ 3 ] eq 'net' ){ $confighash { $key }[ 32 ]= "net-2-net" ;}
5161 if ( $confighash { $key }[ 32 ] eq "" && $confighash { $key }[ 3 ] eq 'host' ){ $confighash { $key }[ 32 ]= "dynamic" ;}
5162 print "<td align='center' $col > $confighash { $key }[32]</td>" ;
5163 print "<td align='center' $col > $confighash { $key }[25]</td>" ;
5164 $col1 = "bgcolor='${Header::colourred}'" ;
5165 my $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
5167 if ( $confighash { $key }[ 0 ] eq 'off' ) {
5168 $col1 = "bgcolor='${Header::colourblue}'" ;
5169 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
5176 if ( $confighash { $key }[ 3 ] eq 'net' ) {
5178 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
5181 my $tport = $confighash { $key }[ 22 ];
5182 my $tnet = new Net
:: Telnet
( Timeout
=> 5 , Errmode
=> 'return' , Port
=> $tport );
5184 $tnet -> open ( '127.0.0.1' );
5185 @output = $tnet -> cmd ( String
=> 'state' , Prompt
=> '/(END.* \n |ERROR:.* \n )/' );
5186 @tustate = split ( /\,/ , $output [ 1 ]);
5188 #CONNECTING -- OpenVPN's initial state.
5189 #WAIT -- (Client only) Waiting for initial response from server.
5190 #AUTH -- (Client only) Authenticating with server.
5191 #GET_CONFIG -- (Client only) Downloading configuration options from server.
5192 #ASSIGN_IP -- Assigning IP address to virtual network interface.
5193 #ADD_ROUTES -- Adding routes to system.
5194 #CONNECTED -- Initialization Sequence Completed.
5195 #RECONNECTING -- A restart has occurred.
5196 #EXITING -- A graceful exit is in progress.
5199 if ( $tustate [ 1 ] eq 'CONNECTED' ) {
5200 $col1 = "bgcolor='${Header::colourgreen}'" ;
5201 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
5203 $col1 = "bgcolor='${Header::colourred}'" ;
5204 $active = "<b><font color='#FFFFFF'> $tustate [1]</font></b>" ;
5212 foreach my $line ( @status ) {
5214 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
5215 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
5216 if ( $match [ 1 ] ne "Common Name" ) {
5220 if ( $cn eq " $confighash { $key }[2]" ) {
5221 $col1 = "bgcolor='${Header::colourgreen}'" ;
5222 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
5231 <td align='center' $col1 > $active </td>
5233 <form method='post' name='frm${key}a'><td align='center' $col >
5234 <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' />
5235 <input type='hidden' name='ACTION' value=' $Lang ::tr{'dl client arch'}' />
5236 <input type='hidden' name='KEY' value=' $key ' />
5240 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
5242 <form method='post' name='frm${key}b'><td align='center' $col >
5243 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' border='0' />
5244 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
5245 <input type='hidden' name='KEY' value=' $key ' />
5249 print "<td> </td>" ;
5251 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" ) {
5253 <form method='post' name='frm${key}c'><td align='center' $col >
5254 <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' />
5255 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
5256 <input type='hidden' name='KEY' value=' $key ' />
5259 ; } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
5261 <form method='post' name='frm${key}c'><td align='center' $col >
5262 <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' />
5263 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
5264 <input type='hidden' name='KEY' value=' $key ' />
5268 print "<td> </td>" ;
5271 <form method='post' name='frm${key}d'><td align='center' $col >
5272 <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' />
5273 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
5274 <input type='hidden' name='KEY' value=' $key ' />
5277 <form method='post' name='frm${key}e'><td align='center' $col >
5278 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
5279 <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'/>
5280 <input type='hidden' name='KEY' value=' $key ' />
5282 <form method='post' name='frm${key}f'><td align='center' $col >
5283 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
5284 <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' />
5285 <input type='hidden' name='KEY' value=' $key ' />
5294 # If the config file contains entries, print Key to action icons
5299 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5300 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
5301 <td class='base'> $Lang ::tr{'click to disable'}</td>
5302 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
5303 <td class='base'> $Lang ::tr{'show certificate'}</td>
5304 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
5305 <td class='base'> $Lang ::tr{'edit'}</td>
5306 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
5307 <td class='base'> $Lang ::tr{'remove'}</td>
5311 <td> <img src='/images/off.gif' alt='?OFF' /></td>
5312 <td class='base'> $Lang ::tr{'click to enable'}</td>
5313 <td> <img src='/images/media-floppy.png' alt='?FLOPPY' /></td>
5314 <td class='base'> $Lang ::tr{'download certificate'}</td>
5315 <td> <img src='/images/openvpn.png' alt='?RELOAD'/></td>
5316 <td class='base'> $Lang ::tr{'dl client arch'}</td>
5324 <table width='100%'>
5325 <form method='post'>
5326 <tr><td align='right'>
5327 <input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
5328 <input type='submit' name='ACTION' value=' $Lang ::tr{'ovpn con stat'}' $activeonrun /></td>
5334 & Header
:: closebox
();
5336 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate authorities'}" );
5338 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5340 <th width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5341 <th width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></th>
5342 <th width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></th>
5346 my $col1 = "bgcolor=' $color {'color22'}'" ;
5347 my $col2 = "bgcolor=' $color {'color20'}'" ;
5348 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5349 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
5350 $casubject =~ /Subject: (.*)[\n]/ ;
5352 $casubject =~ s
+/ Email
+, E
+;
5353 $casubject =~ s/ ST=/ S=/ ;
5356 <td class='base' $col1 > $Lang ::tr{'root certificate'}</td>
5357 <td class='base' $col1 > $casubject </td>
5358 <form method='post' name='frmrootcrta'><td width='3%' align='center' $col1 >
5359 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
5360 <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' />
5362 <form method='post' name='frmrootcrtb'><td width='3%' align='center' $col1 >
5363 <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' />
5364 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
5366 <td width='4%' $col1 > </td></tr>
5370 # display rootcert generation buttons
5373 <td class='base' $col1 > $Lang ::tr{'root certificate'}:</td>
5374 <td class='base' $col1 > $Lang ::tr{'not present'}</td>
5375 <td colspan='3' $col1 > </td></tr>
5380 if (- f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
5381 my $hostsubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
5382 $hostsubject =~ /Subject: (.*)[\n]/ ;
5384 $hostsubject =~ s
+/ Email
+, E
+;
5385 $hostsubject =~ s/ ST=/ S=/ ;
5389 <td class='base' $col2 > $Lang ::tr{'host certificate'}</td>
5390 <td class='base' $col2 > $hostsubject </td>
5391 <form method='post' name='frmhostcrta'><td width='3%' align='center' $col2 >
5392 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
5393 <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' />
5395 <form method='post' name='frmhostcrtb'><td width='3%' align='center' $col2 >
5396 <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' />
5397 <input type='hidden' name='ACTION' value=" $Lang ::tr{'download host certificate'}" />
5399 <td width='4%' $col2 > </td></tr>
5406 <td width='25%' class='base' $col2 > $Lang ::tr{'host certificate'}:</td>
5407 <td class='base' $col2 > $Lang ::tr{'not present'}</td>
5408 </td><td colspan='3' $col2 > </td></tr>
5413 if (! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5414 print "<tr><td colspan='5' align='center'><form method='post'>" ;
5415 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' />" ;
5416 print "</form></td></tr> \n " ;
5419 if ( keys %cahash > 0 ) {
5420 foreach my $key ( keys %cahash ) {
5421 if (( $key + 1 ) % 2 ) {
5422 print "<tr bgcolor=' $color {'color20'}'> \n " ;
5424 print "<tr bgcolor=' $color {'color22'}'> \n " ;
5426 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
5427 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
5429 <form method='post' name='cafrm${key}a'><td align='center'>
5430 <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' />
5431 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
5432 <input type='hidden' name='KEY' value=' $key ' />
5434 <form method='post' name='cafrm${key}b'><td align='center'>
5435 <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' />
5436 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
5437 <input type='hidden' name='KEY' value=' $key ' />
5439 <form method='post' name='cafrm${key}c'><td align='center'>
5440 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
5441 <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' />
5442 <input type='hidden' name='KEY' value=' $key ' />
5451 # If the file contains entries, print Key to action icons
5452 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5456 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5457 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
5458 <td class='base'> $Lang ::tr{'show certificate'}</td>
5459 <td> <img src='/images/media-floppy.png' alt=' $Lang ::tr{'download certificate'}' /></td>
5460 <td class='base'> $Lang ::tr{'download certificate'}</td>
5469 <form method='post' enctype='multipart/form-data'>
5470 <table width='100%' border='0'cellspacing='1' cellpadding='0'>
5472 <td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}:</td>
5473 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' align='left'/></td>
5474 <td nowrap='nowrap'><input type='file' name='FH' size='25' />
5475 <td nowrap='nowrap' align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td>
5479 <td class='base' nowrap='nowrap'> $Lang ::tr{'ovpn dh upload'}:</td>
5480 <td nowrap='nowrap'><size='15' align='left'/></td>
5481 <td nowrap='nowrap'><input type='file' name='FH' size='25' />
5482 <td colspan='4' align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload dh key'}' /></td>
5484 <tr><td colspan='4'><br></td></tr>
5486 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'generate dh key'}' /></td>
5487 <td colspan='4' align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'show dh'}' /></td>
5491 <td colspan='4' align='right' width='80%'><input type='submit' name='ACTION' value=' $Lang ::tr{'show crl'}' /></td>
5497 if ( $srunning eq "yes" ) {
5498 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' disabled='disabled' /></div></form> \n " ;
5500 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' /></div></form> \n " ;
5502 & Header
:: closebox
();
5506 & Header
:: closepage
();