]>
git.ipfire.org Git - 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 my $local_serverconf = "${General::swroot}/ovpn/scripts/server.conf.local" ;
74 my $local_clientconf = "${General::swroot}/ovpn/scripts/client.conf.local" ;
76 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
77 $cgiparams { 'ENABLED' } = 'off' ;
78 $cgiparams { 'ENABLED_BLUE' } = 'off' ;
79 $cgiparams { 'ENABLED_ORANGE' } = 'off' ;
80 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
81 $cgiparams { 'NAT' } = 'off' ;
82 $cgiparams { 'COMPRESSION' } = 'off' ;
83 $cgiparams { 'ONLY_PROPOSED' } = 'off' ;
84 $cgiparams { 'ACTION' } = '' ;
85 $cgiparams { 'CA_NAME' } = '' ;
86 $cgiparams { 'DH_NAME' } = 'dh1024.pem' ;
87 $cgiparams { 'DHLENGHT' } = '' ;
88 $cgiparams { 'DHCP_DOMAIN' } = '' ;
89 $cgiparams { 'DHCP_DNS' } = '' ;
90 $cgiparams { 'DHCP_WINS' } = '' ;
91 $cgiparams { 'ROUTES_PUSH' } = '' ;
92 $cgiparams { 'DCOMPLZO' } = 'off' ;
93 $cgiparams { 'MSSFIX' } = '' ;
94 $cgiparams { 'number' } = '' ;
95 $cgiparams { 'PMTU_DISCOVERY' } = '' ;
96 $cgiparams { 'DCIPHER' } = '' ;
97 $cgiparams { 'DAUTH' } = '' ;
98 $cgiparams { 'TLSAUTH' } = '' ;
99 $routes_push_file = "${General::swroot}/ovpn/routes_push" ;
101 # Add CCD files if not already presant
102 unless (- e
$routes_push_file ) {
103 open ( RPF
, "> $routes_push_file " );
106 unless (- e
"${General::swroot}/ovpn/ccd.conf" ) {
107 open ( CCDC
, ">${General::swroot}/ovpn/ccd.conf" );
110 unless (- e
"${General::swroot}/ovpn/ccdroute" ) {
111 open ( CCDR
, ">${General::swroot}/ovpn/ccdroute" );
114 unless (- e
"${General::swroot}/ovpn/ccdroute2" ) {
115 open ( CCDRT
, ">${General::swroot}/ovpn/ccdroute2" );
118 # Add additional configs if not already presant
119 unless (- e
" $local_serverconf " ) {
120 open ( LSC
, "> $local_serverconf " );
123 unless (- e
" $local_clientconf " ) {
124 open ( LCC
, "> $local_clientconf " );
128 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
130 # prepare openvpn config file
136 if ( $netsettings { 'CONFIG_TYPE' } == 2 ) { return 1 ;}
137 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
143 if ( $netsettings { 'CONFIG_TYPE' } == 3 ) { return 1 ;}
144 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
149 my $bytesize = shift ;
152 while ( abs ( $bytesize ) >= 1024 ){
153 $bytesize = $bytesize / 1024 ;
158 my @units = ( "Bytes" , "KB" , "MB" , "GB" , "TB" , "PB" , "EB" );
159 my $newsize =( int ( $bytesize * 100 + 0.5 ))/ 100 ;
160 return ( " $newsize $units [ $i ]" );
165 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/serial" )) {
169 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/index.txt" )) {
173 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
174 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
175 unlink ( "${General::swroot}/ovpn/certs/01.pem" );
178 sub newcleanssldatabase
180 if (! - s
"${General::swroot}/ovpn/certs/serial" ) {
181 open ( FILE
, ">${General::swroot}(ovpn/certs/serial" );
185 if (! - s
">${General::swroot}/ovpn/certs/index.txt" ) {
186 system ( "touch ${General::swroot}/ovpn/certs/index.txt" );
188 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
189 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
194 if ( open ( FILE
, "${General::swroot}/ovpn/certs/serial.old" )) {
195 my $hexvalue = < FILE
>;
198 unlink ( "${General::swroot}/ovpn/certs/ $hexvalue .pem" );
202 sub writeserverconf
{
203 my %sovpnsettings = ();
205 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%sovpnsettings );
208 open ( CONF
, ">${General::swroot}/ovpn/server.conf" ) or die "Unable to open ${General::swroot}/ovpn/server.conf: $!" ;
210 print CONF
"#OpenVPN Server conf \n " ;
212 print CONF
"daemon openvpnserver \n " ;
213 print CONF
"writepid /var/run/openvpn.pid \n " ;
214 print CONF
"#DAN prepare OpenVPN for listening on blue and orange \n " ;
215 print CONF
";local $sovpnsettings {'VPN_IP'} \n " ;
216 print CONF
"dev $sovpnsettings {'DDEVICE'} \n " ;
217 print CONF
"proto $sovpnsettings {'DPROTOCOL'} \n " ;
218 print CONF
"port $sovpnsettings {'DDEST_PORT'} \n " ;
219 print CONF
"script-security 3 system \n " ;
220 print CONF
"ifconfig-pool-persist /var/ipfire/ovpn/ovpn-leases.db 3600 \n " ;
221 print CONF
"client-config-dir /var/ipfire/ovpn/ccd \n " ;
222 print CONF
"tls-server \n " ;
223 print CONF
"ca ${General::swroot}/ovpn/ca/cacert.pem \n " ;
224 print CONF
"cert ${General::swroot}/ovpn/certs/servercert.pem \n " ;
225 print CONF
"key ${General::swroot}/ovpn/certs/serverkey.pem \n " ;
226 print CONF
"dh ${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'} \n " ;
227 my @tempovpnsubnet = split ( "\/" , $sovpnsettings { 'DOVPN_SUBNET' });
228 print CONF
"server $tempovpnsubnet [0] $tempovpnsubnet [1] \n " ;
229 #print CONF "push \"route $netsettings{'GREEN_NETADDRESS'} $netsettings{'GREEN_NETMASK'}\"\n";
231 # Check if we are using mssfix, fragment or mtu-disc and set the corretct mtu of 1500.
232 # If we doesn't use one of them, we can use the configured mtu value.
233 if ( $sovpnsettings { 'MSSFIX' } eq 'on' )
234 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
235 elsif ( $sovpnsettings { 'FRAGMENT' } ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' )
236 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
237 elsif (( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
238 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
239 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'no' ))
240 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
242 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu $sovpnsettings {'DMTU'} \n " ; }
244 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
245 @temp = split ( /\n/ , $vpnsettings { 'ROUTES_PUSH' });
248 @tempovpnsubnet = split ( "\/" ,& General
:: ipcidr2msk
( $_ ));
249 print CONF
"push \" route " . $tempovpnsubnet [ 0 ]. " " . $tempovpnsubnet [ 1 ] . " \"\n " ;
254 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
255 foreach my $key ( keys %ccdconfhash ) {
256 my $a = $ccdconfhash { $key }[ 1 ];
257 my ( $b , $c ) = split ( /\/ /, $a );
258 print CONF
"route $b " .& General
:: cidrtosub
( $c ). " \n " ;
261 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
262 foreach my $key ( keys %ccdroutehash ) {
263 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
264 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
265 print CONF
"route $a $b \n " ;
270 if ( $sovpnsettings { CLIENT2CLIENT
} eq 'on' ) {
271 print CONF
"client-to-client \n " ;
273 if ( $sovpnsettings { MSSFIX
} eq 'on' ) {
274 print CONF
"mssfix \n " ;
276 if ( $sovpnsettings { FRAGMENT
} ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' ) {
277 print CONF
"fragment $sovpnsettings {'FRAGMENT'} \n " ;
280 # Check if a valid operating mode has been choosen and use it.
281 if (( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
282 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
283 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'no' )) {
284 print CONF
"mtu-disc $sovpnsettings {'PMTU_DISCOVERY'} \n " ;
287 if ( $sovpnsettings { KEEPALIVE_1
} > 0 && $sovpnsettings { KEEPALIVE_2
} > 0 ) {
288 print CONF
"keepalive $sovpnsettings {'KEEPALIVE_1'} $sovpnsettings {'KEEPALIVE_2'} \n " ;
290 print CONF
"status-version 1 \n " ;
291 print CONF
"status /var/log/ovpnserver.log 30 \n " ;
292 print CONF
"cipher $sovpnsettings {DCIPHER} \n " ;
293 if ( $sovpnsettings { 'DAUTH' } eq '' ) {
296 print CONF
"auth $sovpnsettings {'DAUTH'} \n " ;
298 if ( $sovpnsettings { 'TLSAUTH' } eq 'on' ) {
299 print CONF
"tls-auth ${General::swroot}/ovpn/certs/ta.key \n " ;
301 if ( $sovpnsettings { DCOMPLZO
} eq 'on' ) {
302 print CONF
"comp-lzo \n " ;
304 if ( $sovpnsettings { REDIRECT_GW_DEF1
} eq 'on' ) {
305 print CONF
"push \" redirect-gateway def1 \"\n " ;
307 if ( $sovpnsettings { DHCP_DOMAIN
} ne '' ) {
308 print CONF
"push \" dhcp-option DOMAIN $sovpnsettings {DHCP_DOMAIN} \"\n " ;
311 if ( $sovpnsettings { DHCP_DNS
} ne '' ) {
312 print CONF
"push \" dhcp-option DNS $sovpnsettings {DHCP_DNS} \"\n " ;
315 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
316 print CONF
"push \" dhcp-option WINS $sovpnsettings {DHCP_WINS} \"\n " ;
319 if ( $sovpnsettings { DHCP_WINS
} eq '' ) {
320 print CONF
"max-clients 100 \n " ;
322 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
323 print CONF
"max-clients $sovpnsettings {MAX_CLIENTS} \n " ;
325 print CONF
"tls-verify /usr/lib/openvpn/verify \n " ;
326 print CONF
"crl-verify /var/ipfire/ovpn/crls/cacrl.pem \n " ;
327 print CONF
"user nobody \n " ;
328 print CONF
"group nobody \n " ;
329 print CONF
"persist-key \n " ;
330 print CONF
"persist-tun \n " ;
331 if ( $sovpnsettings { LOG_VERB
} ne '' ) {
332 print CONF
"verb $sovpnsettings {LOG_VERB} \n " ;
334 print CONF
"verb 3 \n " ;
336 # Print server.conf.local if entries exist to server.conf
337 if ( !- z
$local_serverconf && $sovpnsettings { 'ADDITIONAL_CONFIGS' } eq 'on' ) {
338 open ( LSC
, " $local_serverconf " );
339 print CONF
" \n #--------------------------- \n " ;
340 print CONF
"# Start of custom directives \n " ;
341 print CONF
"# from server.conf.local \n " ;
342 print CONF
"#--------------------------- \n\n " ;
346 print CONF
" \n #----------------------------- \n " ;
347 print CONF
"# End of custom directives \n " ;
348 print CONF
"#----------------------------- \n " ;
357 if ( open ( FILE
, ">/var/log/ovpnserver.log" )) {
367 my %ccdconfhash = ();
369 my $ccdnetname = $_ [ 0 ];
370 if (- f
"${General::swroot}/ovpn/ovpnconfig" ){
371 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
372 foreach my $key ( keys %ccdhash ) {
373 if ( $ccdhash { $key }[ 32 ] eq $ccdnetname ) {
374 $errormessage = $Lang :: tr
{ 'ccd err hostinnet' };
379 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
380 foreach my $key ( keys %ccdconfhash ) {
381 if ( $ccdconfhash { $key }[ 0 ] eq $ccdnetname ){
382 delete $ccdconfhash { $key };
385 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
407 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err name' }. "<br>" ;
411 if (!& General
:: validhostname
( $ccdname ))
413 $errormessage = $Lang :: tr
{ 'ccd err invalidname' };
417 ( $ccdip , $subcidr ) = split ( /\/ /, $ccdnet );
418 $subcidr =& General
:: iporsubtocidr
( $subcidr );
422 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
426 if (!& General
:: validipandmask
( $ccdnet )){
427 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
431 $errormessage =& General
:: checksubnets
( $ccdname , $ccdnet );
434 if (! $errormessage ) {
436 $baseaddress =& General
:: getnetworkip
( $ccdip , $subcidr );
437 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
438 my $key = & General
:: findhasharraykey
( \
%ccdconfhash );
439 foreach my $i ( 0 .. 1 ) { $ccdconfhash { $key }[ $i ] = "" ;}
440 $ccdconfhash { $key }[ 0 ] = $ccdname ;
441 $ccdconfhash { $key }[ 1 ] = $baseaddress . "/" . $subcidr ;
442 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
444 $cgiparams { 'ccdname' }= '' ;
445 $cgiparams { 'ccdsubnet' }= '' ;
457 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
458 foreach my $key ( keys %ccdconfhash ) {
459 if ( $ccdconfhash { $key }[ 0 ] eq $oldname ) {
460 foreach my $key1 ( keys %ccdconfhash ) {
461 if ( $ccdconfhash { $key1 }[ 0 ] eq $newname ){
462 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err netadrexist' };
465 $ccdconfhash { $key }[ 0 ]= $newname ;
466 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
473 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
474 foreach my $key ( keys %ccdhash ) {
475 if ( $ccdhash { $key }[ 32 ] eq $oldname ) {
476 $ccdhash { $key }[ 32 ]= $newname ;
477 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
486 my $ccdnetwork = $_ [ 0 ];
489 @octets = split ( "\/" , $ccdnetwork );
490 @subnet = split /\./ , & General
:: cidrtosub
( $octets [ 1 ]);
503 my ( $ip1 , $ip2 , $ip3 , $ip4 )= split /\./ , $ipin ;
511 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
512 $iprange [ 0 ]= $ip1 . "." . $ip2 . "." . $ip3 . "." .( $ip4 + 2 );
513 for ( my $i = 1 ; $i <= $count ; $i ++) {
514 my $tmpip = $iprange [ $i - 1 ];
516 $iprange [ $i ]= & General
:: getnextip
( $tmpip , 4 );
519 foreach my $key ( keys %ccdhash ) {
521 foreach my $tmp ( @iprange ){
522 my ( $net , $sub ) = split ( /\/ /, $ccdhash { $key }[ 33 ]);
524 if ( $hasip ne $ccdhash { $key }[ 33 ] ){
525 splice ( @iprange , $r , 1 );
537 my ( $ccdip , $subcidr ) = split ( "/" , $_ [ 0 ]);
539 my @allccdips =& getccdadresses
( $ccdip , $subcidr ,& ccdmaxclients
( $ccdip . "/" . $subcidr ), $tz );
540 print "<select name=' $boxname ' STYLE='font-family : arial; font-size : 9pt; width:130px;' >" ;
541 foreach ( @allccdips ) {
544 print "<option value=' $ip ' " ;
545 if ( $ip eq $cgiparams { $boxname } ){
548 print "> $ip </option>" ;
558 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
559 foreach my $key ( keys %ccdhash ) {
560 if ( $ccdhash { $key }[ 32 ] eq $name ){ $i ++;}
565 sub check_routes_push
568 my ( $ip , $cidr ) = split ( /\/ /, $val );
569 ##check for existing routes in routes_push
570 if (- e
"${General::swroot}/ovpn/routes_push" ) {
571 open ( FILE
, "${General::swroot}/ovpn/routes_push" );
575 my ( $ip2 , $cidr2 ) = split ( /\/ /, " $_ " );
576 my $val2 = $ip2 . "/" .& General
:: iporsubtodec
( $cidr2 );
582 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: iporsubtodec
( $cidr2 ))){
595 my ( $ip , $cidr ) = split ( /\/ /, $val );
596 #check for existing routes in ccdroute
597 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
598 foreach my $key ( keys %ccdroutehash ) {
599 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
600 if (& General
:: iporsubtodec
( $val ) eq $ccdroutehash { $key }[ $i ] && $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' }){
603 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
605 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )&& $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' } ){
616 my ( $ip , $cidr ) = split ( /\/ /, $val );
617 #check for existing routes in ccdroute
618 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
619 foreach my $key ( keys %ccdconfhash ) {
620 if (& General
:: iporsubtocidr
( $val ) eq $ccdconfhash { $key }[ 1 ]){
623 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdconfhash { $key }[ 1 ]);
625 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: cidrtosub
( $cidr2 ))){
639 my $ipdotmask = $_ [ 0 ];
640 if (& General
:: validip
( $ipdotmask )) { return 0 ; }
641 if (!( $ipdotmask =~ /^(.*?)\/ (.* ?
)$/)) { }
643 if (( $mask =~ /\./ )) { return 0 ; }
647 # -------------------------------------------------------------------
649 sub write_routepushfile
651 open ( FILE
, "> $routes_push_file " );
653 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
654 print FILE
$vpnsettings { 'ROUTES_PUSH' };
659 sub read_routepushfile
661 if (- e
" $routes_push_file " ) {
662 open ( FILE
, " $routes_push_file " );
663 delete $vpnsettings { 'ROUTES_PUSH' };
664 while (< FILE
>) { $vpnsettings { 'ROUTES_PUSH' } .= $_ };
666 $cgiparams { 'ROUTES_PUSH' } = $vpnsettings { 'ROUTES_PUSH' };
672 #hier die refresh page
673 if ( - e
"${General::swroot}/ovpn/gencanow" ) {
675 $refresh = "<meta http-equiv='refresh' content='15;' />" ;
676 & Header
:: showhttpheaders
();
677 & Header
:: openpage
( $Lang :: tr
{ 'OVPN' }, 1 , $refresh );
678 & Header
:: openbigbox
( '100%' , 'center' );
679 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
680 print "<tr> \n <td align='center'><img src='/images/clock.gif' alt='' /></td> \n " ;
681 print "<td colspan='2'><font color='red'>Please be patient this realy can take some time on older hardware...</font></td></tr> \n " ;
683 & Header
:: closebigbox
();
684 & Header
:: closepage
();
687 ##hier die refresh page
691 ### OpenVPN Server Control
693 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' } ||
694 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' } ||
695 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart ovpn server' }) {
696 #start openvpn server
697 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' }){
699 system ( '/usr/local/bin/openvpnctrl' , '-s' );
702 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' }){
703 system ( '/usr/local/bin/openvpnctrl' , '-k' );
706 # #restart openvpn server
707 # if ($cgiparams{'ACTION'} eq $Lang::tr{'restart ovpn server'}){
708 #workarund, till SIGHUP also works when running as nobody
709 # system('/usr/local/bin/openvpnctrl', '-r');
715 ### Save Advanced options
718 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save-adv-options' }) {
719 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
720 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
721 #DAN this value has to leave.
722 #new settings for daemon
723 $vpnsettings { 'LOG_VERB' } = $cgiparams { 'LOG_VERB' };
724 $vpnsettings { 'KEEPALIVE_1' } = $cgiparams { 'KEEPALIVE_1' };
725 $vpnsettings { 'KEEPALIVE_2' } = $cgiparams { 'KEEPALIVE_2' };
726 $vpnsettings { 'MAX_CLIENTS' } = $cgiparams { 'MAX_CLIENTS' };
727 $vpnsettings { 'REDIRECT_GW_DEF1' } = $cgiparams { 'REDIRECT_GW_DEF1' };
728 $vpnsettings { 'CLIENT2CLIENT' } = $cgiparams { 'CLIENT2CLIENT' };
729 $vpnsettings { 'ADDITIONAL_CONFIGS' } = $cgiparams { 'ADDITIONAL_CONFIGS' };
730 $vpnsettings { 'DHCP_DOMAIN' } = $cgiparams { 'DHCP_DOMAIN' };
731 $vpnsettings { 'DHCP_DNS' } = $cgiparams { 'DHCP_DNS' };
732 $vpnsettings { 'DHCP_WINS' } = $cgiparams { 'DHCP_WINS' };
733 $vpnsettings { 'ROUTES_PUSH' } = $cgiparams { 'ROUTES_PUSH' };
734 $vpnsettings { 'PMTU_DISCOVERY' } = $cgiparams { 'PMTU_DISCOVERY' };
735 $vpnsettings { 'DAUTH' } = $cgiparams { 'DAUTH' };
736 $vpnsettings { 'TLSAUTH' } = $cgiparams { 'TLSAUTH' };
739 if ( $cgiparams { 'FRAGMENT' } eq '' ) {
740 delete $vpnsettings { 'FRAGMENT' };
742 if ( $cgiparams { 'FRAGMENT' } !~ /^[0-9]+$/ ) {
743 $errormessage = "Incorrect value, please insert only numbers." ;
746 $vpnsettings { 'FRAGMENT' } = $cgiparams { 'FRAGMENT' };
750 if ( $cgiparams { 'MSSFIX' } ne 'on' ) {
751 delete $vpnsettings { 'MSSFIX' };
753 $vpnsettings { 'MSSFIX' } = $cgiparams { 'MSSFIX' };
756 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
757 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
758 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
760 if (( $cgiparams { 'MSSFIX' } eq 'on' ) || ( $cgiparams { 'FRAGMENT' } ne '' )) {
761 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
766 if ( $cgiparams { 'DHCP_DOMAIN' } ne '' ){
767 unless (& General
:: validdomainname
( $cgiparams { 'DHCP_DOMAIN' }) || & General
:: validip
( $cgiparams { 'DHCP_DOMAIN' })) {
768 $errormessage = $Lang :: tr
{ 'invalid input for dhcp domain' };
772 if ( $cgiparams { 'DHCP_DNS' } ne '' ){
773 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_DNS' }) || & General
:: validip
( $cgiparams { 'DHCP_DNS' })) {
774 $errormessage = $Lang :: tr
{ 'invalid input for dhcp dns' };
778 if ( $cgiparams { 'DHCP_WINS' } ne '' ){
779 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_WINS' }) || & General
:: validip
( $cgiparams { 'DHCP_WINS' })) {
780 $errormessage = $Lang :: tr
{ 'invalid input for dhcp wins' };
784 if ( $cgiparams { 'ROUTES_PUSH' } ne '' ){
785 @temp = split ( /\n/ , $cgiparams { 'ROUTES_PUSH' });
786 undef $vpnsettings { 'ROUTES_PUSH' };
788 foreach my $tmpip ( @temp )
790 s/^\s+//g ; s/\s+$//g ;
795 unless (& General
:: validipandmask
( $tmpip )) {
796 $errormessage = " $tmpip " . $Lang :: tr
{ 'ovpn errmsg invalid ip or mask' };
799 my ( $ip , $cidr ) = split ( "\/" ,& General
:: ipcidr2msk
( $tmpip ));
801 if ( $ip eq $netsettings { 'GREEN_NETADDRESS' } && $cidr eq $netsettings { 'GREEN_NETMASK' }) {
802 $errormessage = $Lang :: tr
{ 'ovpn errmsg green already pushed' };
807 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
808 foreach my $key ( keys %ccdroutehash ) {
809 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
810 if ( $ip . "/" . $cidr eq $ccdroutehash { $key }[ $i ] ){
811 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
814 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
815 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )){
816 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
824 $vpnsettings { 'ROUTES_PUSH' } .= $tmpip . " \n " ;
827 & write_routepushfile
;
828 undef $vpnsettings { 'ROUTES_PUSH' };
831 undef $vpnsettings { 'ROUTES_PUSH' };
832 & write_routepushfile
;
834 if (( length ( $cgiparams { 'MAX_CLIENTS' }) == 0 ) || (( $cgiparams { 'MAX_CLIENTS' }) < 1 ) || (( $cgiparams { 'MAX_CLIENTS' }) > 255 )) {
835 $errormessage = $Lang :: tr
{ 'invalid input for max clients' };
838 if ( $cgiparams { 'KEEPALIVE_1' } ne '' ) {
839 if ( $cgiparams { 'KEEPALIVE_1' } !~ /^[0-9]+$/ ) {
840 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1' };
844 if ( $cgiparams { 'KEEPALIVE_2' } ne '' ){
845 if ( $cgiparams { 'KEEPALIVE_2' } !~ /^[0-9]+$/ ) {
846 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 2' };
850 if ( $cgiparams { 'KEEPALIVE_2' } < ( $cgiparams { 'KEEPALIVE_1' } * 2 )){
851 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1:2' };
854 # Create ta.key for tls-auth if not presant
855 if ( $cgiparams { 'TLSAUTH' } eq 'on' ) {
856 if ( ! - e
"${General::swroot}/ovpn/certs/ta.key" ) {
857 system ( '/usr/sbin/openvpn' , '--genkey' , '--secret' , "${General::swroot}/ovpn/certs/ta.key" );
859 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
865 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
866 & writeserverconf
(); #hier ok
873 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'server' )
876 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
877 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
878 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
881 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
882 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
884 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: $!" ;
887 print SERVERCONF
"# IPFire n2n Open VPN Server Config by ummeegge und m.a.d \n " ;
888 print SERVERCONF
" \n " ;
889 print SERVERCONF
"# User Security \n " ;
890 print SERVERCONF
"user nobody \n " ;
891 print SERVERCONF
"group nobody \n " ;
892 print SERVERCONF
"persist-tun \n " ;
893 print SERVERCONF
"persist-key \n " ;
894 print SERVERCONF
"script-security 2 \n " ;
895 print SERVERCONF
"# IP/DNS for remote Server Gateway \n " ;
897 if ( $cgiparams { 'REMOTE' } ne '' ) {
898 print SERVERCONF
"remote $cgiparams {'REMOTE'} \n " ;
901 print SERVERCONF
"float \n " ;
902 print SERVERCONF
"# IP adresses of the VPN Subnet \n " ;
903 print SERVERCONF
"ifconfig $ovsubnet .1 $ovsubnet .2 \n " ;
904 print SERVERCONF
"# Client Gateway Network \n " ;
905 print SERVERCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
906 print SERVERCONF
"# tun Device \n " ;
907 print SERVERCONF
"dev tun \n " ;
908 print SERVERCONF
"# Port and Protokol \n " ;
909 print SERVERCONF
"port $cgiparams {'DEST_PORT'} \n " ;
911 if ( $cgiparams { 'PROTOCOL' } eq 'tcp' ) {
912 print SERVERCONF
"proto tcp-server \n " ;
913 print SERVERCONF
"# Packet size \n " ;
914 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1400' } else { $tunmtu = $cgiparams { 'MTU' }};
915 print SERVERCONF
"tun-mtu $tunmtu \n " ;
918 if ( $cgiparams { 'PROTOCOL' } eq 'udp' ) {
919 print SERVERCONF
"proto udp \n " ;
920 print SERVERCONF
"# Paketsize \n " ;
921 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
922 print SERVERCONF
"tun-mtu $tunmtu \n " ;
923 if ( $cgiparams { 'FRAGMENT' } ne '' ) { print SERVERCONF
"fragment $cgiparams {'FRAGMENT'} \n " ;}
924 if ( $cgiparams { 'MSSFIX' } eq 'on' ) { print SERVERCONF
"mssfix \n " ; };
927 # Check if a valid operating mode has been choosen and use it.
928 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
929 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
930 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
931 if (( $cgiparams { 'MSSFIX' } ne 'on' ) || ( $cgiparams { 'FRAGMENT' } eq '' )) {
932 if ( $cgiparams { 'MTU' } eq '1500' ) {
933 print SERVERCONF
"mtu-disc $cgiparams {'PMTU_DISCOVERY'} \n " ;
937 print SERVERCONF
"# Auth. Server \n " ;
938 print SERVERCONF
"tls-server \n " ;
939 print SERVERCONF
"ca ${General::swroot}/ovpn/ca/cacert.pem \n " ;
940 print SERVERCONF
"cert ${General::swroot}/ovpn/certs/servercert.pem \n " ;
941 print SERVERCONF
"key ${General::swroot}/ovpn/certs/serverkey.pem \n " ;
942 print SERVERCONF
"dh ${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'} \n " ;
943 print SERVERCONF
"# Cipher \n " ;
944 print SERVERCONF
"cipher $cgiparams {'DCIPHER'} \n " ;
945 if ( $cgiparams { 'DAUTH' } eq '' ) {
946 print SERVERCONF
"auth SHA1 \n " ;
948 print SERVERCONF
"# HMAC algorithm \n " ;
949 print SERVERCONF
"auth $cgiparams {'DAUTH'} \n " ;
951 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
952 print SERVERCONF
"# Enable Compression \n " ;
953 print SERVERCONF
"comp-lzo \n " ;
955 print SERVERCONF
"# Debug Level \n " ;
956 print SERVERCONF
"verb 3 \n " ;
957 print SERVERCONF
"# Tunnel check \n " ;
958 print SERVERCONF
"keepalive 10 60 \n " ;
959 print SERVERCONF
"# Start as daemon \n " ;
960 print SERVERCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
961 print SERVERCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
962 print SERVERCONF
"# Activate Management Interface and Port \n " ;
963 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) { print SERVERCONF
"management localhost $cgiparams {'DEST_PORT'} \n " }
964 else { print SERVERCONF
"management localhost $cgiparams {'OVPN_MGMT'} \n " };
973 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'client' )
976 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
977 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
978 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
981 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
982 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
984 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: $!" ;
987 print CLIENTCONF
"# IPFire rewritten n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
988 print CLIENTCONF
"# \n " ;
989 print CLIENTCONF
"# User Security \n " ;
990 print CLIENTCONF
"user nobody \n " ;
991 print CLIENTCONF
"group nobody \n " ;
992 print CLIENTCONF
"persist-tun \n " ;
993 print CLIENTCONF
"persist-key \n " ;
994 print CLIENTCONF
"script-security 2 \n " ;
995 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
996 print CLIENTCONF
"remote $cgiparams {'REMOTE'} \n " ;
997 print CLIENTCONF
"float \n " ;
998 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
999 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
1000 print CLIENTCONF
"# Server Gateway Network \n " ;
1001 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
1002 print CLIENTCONF
"# tun Device \n " ;
1003 print CLIENTCONF
"dev tun \n " ;
1004 print CLIENTCONF
"# Port and Protokol \n " ;
1005 print CLIENTCONF
"port $cgiparams {'DEST_PORT'} \n " ;
1007 if ( $cgiparams { 'PROTOCOL' } eq 'tcp' ) {
1008 print CLIENTCONF
"proto tcp-client \n " ;
1009 print CLIENTCONF
"# Packet size \n " ;
1010 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1400' } else { $tunmtu = $cgiparams { 'MTU' }};
1011 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
1014 if ( $cgiparams { 'PROTOCOL' } eq 'udp' ) {
1015 print CLIENTCONF
"proto udp \n " ;
1016 print CLIENTCONF
"# Paketsize \n " ;
1017 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
1018 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
1019 if ( $cgiparams { 'FRAGMENT' } ne '' ) { print CLIENTCONF
"fragment $cgiparams {'FRAGMENT'} \n " ;}
1020 if ( $cgiparams { 'MSSFIX' } eq 'on' ) { print CLIENTCONF
"mssfix \n " ; };
1023 # Check if a valid operating mode has been choosen and use it.
1024 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
1025 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
1026 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
1027 if (( $cgiparams { 'MSSFIX' } ne 'on' ) || ( $cgiparams { 'FRAGMENT' } eq '' )) {
1028 if ( $cgiparams { 'MTU' } eq '1500' ) {
1029 print CLIENTCONF
"mtu-disc $cgiparams {'PMTU_DISCOVERY'} \n " ;
1034 print CLIENTCONF
"ns-cert-type server \n " ;
1035 print CLIENTCONF
"# Auth. Client \n " ;
1036 print CLIENTCONF
"tls-client \n " ;
1037 print CLIENTCONF
"# Cipher \n " ;
1038 print CLIENTCONF
"cipher $cgiparams {'DCIPHER'} \n " ;
1039 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12 \r\n " ;
1040 if ( $cgiparams { 'DAUTH' } eq '' ) {
1041 print CLIENTCONF
"auth SHA1 \n " ;
1043 print CLIENTCONF
"# HMAC algorithm \n " ;
1044 print CLIENTCONF
"auth $cgiparams {'DAUTH'} \n " ;
1046 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
1047 print CLIENTCONF
"# Enable Compression \n " ;
1048 print CLIENTCONF
"comp-lzo \n " ;
1050 print CLIENTCONF
"# Debug Level \n " ;
1051 print CLIENTCONF
"verb 3 \n " ;
1052 print CLIENTCONF
"# Tunnel check \n " ;
1053 print CLIENTCONF
"keepalive 10 60 \n " ;
1054 print CLIENTCONF
"# Start as daemon \n " ;
1055 print CLIENTCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
1056 print CLIENTCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
1057 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
1058 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) { print CLIENTCONF
"management localhost $cgiparams {'DEST_PORT'} \n " }
1059 else { print CLIENTCONF
"management localhost $cgiparams {'OVPN_MGMT'} \n " };
1065 ### Save main settings
1068 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
1069 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1070 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
1071 #DAN this value has to leave.
1072 if ( $cgiparams { 'ENABLED' } eq 'on' ){
1073 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })) {
1074 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1075 goto SETTINGS_ERROR
;
1079 if (! & General
:: validipandmask
( $cgiparams { 'DOVPN_SUBNET' })) {
1080 $errormessage = $Lang :: tr
{ 'ovpn subnet is invalid' };
1081 goto SETTINGS_ERROR
;
1083 my @tmpovpnsubnet = split ( "\/" , $cgiparams { 'DOVPN_SUBNET' });
1085 if (& General
:: IpInSubnet
( $netsettings { 'RED_ADDRESS' },
1086 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1087 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire RED Network $netsettings {'RED_ADDRESS'}" ;
1088 goto SETTINGS_ERROR
;
1091 if (& General
:: IpInSubnet
( $netsettings { 'GREEN_ADDRESS' },
1092 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1093 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Green Network $netsettings {'GREEN_ADDRESS'}" ;
1094 goto SETTINGS_ERROR
;
1097 if (& General
:: IpInSubnet
( $netsettings { 'BLUE_ADDRESS' },
1098 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1099 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Blue Network $netsettings {'BLUE_ADDRESS'}" ;
1100 goto SETTINGS_ERROR
;
1103 if (& General
:: IpInSubnet
( $netsettings { 'ORANGE_ADDRESS' },
1104 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1105 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Orange Network $netsettings {'ORANGE_ADDRESS'}" ;
1106 goto SETTINGS_ERROR
;
1108 open ( ALIASES
, "${General::swroot}/ethernet/aliases" ) or die 'Unable to open aliases file.' ;
1112 my @tempalias = split ( /\,/ , $_ );
1113 if ( $tempalias [ 1 ] eq 'on' ) {
1114 if (& General
:: IpInSubnet
( $tempalias [ 0 ] ,
1115 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1116 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire alias entry $tempalias [0]" ;
1121 if ( $errormessage ne '' ){
1122 goto SETTINGS_ERROR
;
1124 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1125 $errormessage = $Lang :: tr
{ 'invalid input' };
1126 goto SETTINGS_ERROR
;
1128 if (( length ( $cgiparams { 'DMTU' })== 0 ) || (( $cgiparams { 'DMTU' }) < 1000 )) {
1129 $errormessage = $Lang :: tr
{ 'invalid mtu input' };
1130 goto SETTINGS_ERROR
;
1133 unless (& General
:: validport
( $cgiparams { 'DDEST_PORT' })) {
1134 $errormessage = $Lang :: tr
{ 'invalid port' };
1135 goto SETTINGS_ERROR
;
1138 $vpnsettings { 'ENABLED_BLUE' } = $cgiparams { 'ENABLED_BLUE' };
1139 $vpnsettings { 'ENABLED_ORANGE' } = $cgiparams { 'ENABLED_ORANGE' };
1140 $vpnsettings { 'ENABLED' } = $cgiparams { 'ENABLED' };
1141 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
1142 #new settings for daemon
1143 $vpnsettings { 'DOVPN_SUBNET' } = $cgiparams { 'DOVPN_SUBNET' };
1144 $vpnsettings { 'DDEVICE' } = $cgiparams { 'DDEVICE' };
1145 $vpnsettings { 'DPROTOCOL' } = $cgiparams { 'DPROTOCOL' };
1146 $vpnsettings { 'DDEST_PORT' } = $cgiparams { 'DDEST_PORT' };
1147 $vpnsettings { 'DMTU' } = $cgiparams { 'DMTU' };
1148 $vpnsettings { 'DCOMPLZO' } = $cgiparams { 'DCOMPLZO' };
1149 $vpnsettings { 'DCIPHER' } = $cgiparams { 'DCIPHER' };
1152 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" );}
1153 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" );}
1154 if ( $vpnsettings { 'ENABLED' } eq 'on' ) { system ( "touch ${General::swroot}/ovpn/enable 2>/dev/null" );} else { system ( "unlink ${General::swroot}/ovpn/enable 2>/dev/null" );}
1155 #new settings for daemon
1156 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1157 & writeserverconf
(); #hier ok
1160 ### Reset all step 2
1162 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1164 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1166 foreach my $key ( keys %confighash ) {
1167 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
1168 delete $confighash { $cgiparams { ' $key ' }};
1171 while ( $file = glob ( "${General::swroot}/ovpn/ca/*" )) {
1174 while ( $file = glob ( "${General::swroot}/ovpn/certs/*" )) {
1177 while ( $file = glob ( "${General::swroot}/ovpn/crls/*" )) {
1180 & cleanssldatabase
();
1181 if ( open ( FILE
, ">${General::swroot}/ovpn/caconfig" )) {
1185 if ( open ( FILE
, ">${General::swroot}/ovpn/ccdroute" )) {
1189 if ( open ( FILE
, ">${General::swroot}/ovpn/ccdroute2" )) {
1193 while ( $file = glob ( "${General::swroot}/ovpn/ccd/*" )) {
1196 if ( open ( FILE
, ">${General::swroot}/ovpn/ovpn-leases.db" )) {
1200 if ( open ( FILE
, ">${General::swroot}/ovpn/ovpnconfig" )) {
1204 while ( $file = glob ( "${General::swroot}/ovpn/n2nconf/*" )) {
1205 system ( "rm -rf $file " );
1208 #&writeserverconf();
1210 ### Reset all step 1
1212 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' }) {
1213 & Header
:: showhttpheaders
();
1214 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1215 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1216 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
1218 <form method='post'>
1219 <table width='100%'>
1222 <input type='hidden' name='AREUSURE' value='yes' />
1223 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1224 $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}</td>
1227 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' />
1228 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
1234 & Header
:: closebox
();
1235 & Header
:: closebigbox
();
1236 & Header
:: closepage
();
1240 ### Generate DH key step 2
1242 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate dh key' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1243 # Delete if old key exists
1244 if (- f
"${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ) {
1245 unlink "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ;
1247 # Create Diffie Hellmann Parameter
1248 system ( '/usr/bin/openssl' , 'dhparam' , '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" , " $cgiparams {'DHLENGHT'}" );
1250 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1251 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1255 ### Generate DH key step 1
1257 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate dh key' }) {
1258 & Header
:: showhttpheaders
();
1259 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1260 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1261 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'gen dh'}:" );
1263 <table width='100%'>
1265 <td width='20%'> </td> <td width='15%'></td> <td width='65%'></td>
1268 <td class='base'> $Lang ::tr{'ovpn dh'}:</td>
1270 <form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1271 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1272 <select name='DHLENGHT'>
1273 <option value='1024' $selected {'DHLENGHT'}{'1024'}>1024 $Lang ::tr{'bit'}</option>
1274 <option value='2048' $selected {'DHLENGHT'}{'2048'}>2048 $Lang ::tr{'bit'}</option>
1275 <option value='3072' $selected {'DHLENGHT'}{'3072'}>3072 $Lang ::tr{'bit'}</option>
1276 <option value='4096' $selected {'DHLENGHT'}{'4096'}>4096 $Lang ::tr{'bit'}</option>
1280 <tr><td colspan='4'><br></td></tr>
1282 <table width='100%'>
1284 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}: </font></b> $Lang ::tr{'dh key warn'}
1287 <td class='base'> $Lang ::tr{'dh key warn1'}</td>
1289 <tr><td colspan='2'><br></td></tr>
1291 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'generate dh key'}' /></td>
1298 & Header
:: closebox
();
1299 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1300 & Header
:: closebigbox
();
1301 & Header
:: closepage
();
1307 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload dh key' }) {
1308 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1309 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1310 goto UPLOADCA_ERROR
;
1312 # Move uploaded dh key to a temporary file
1313 ( my $fh , my $filename ) = tempfile
( );
1314 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1316 goto UPLOADCA_ERROR
;
1318 my $temp = `/usr/bin/openssl dhparam -text -in $filename ` ;
1319 if ( $temp !~ /DH Parameters: \((1024|2048|3072|4096) bit\)/ ) {
1320 $errormessage = $Lang :: tr
{ 'not a valid dh key' };
1322 goto UPLOADCA_ERROR
;
1324 # Delete if old key exists
1325 if (- f
"${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ) {
1326 unlink "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ;
1328 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" );
1330 $errormessage = " $Lang ::tr{'dh key move failed'}: $!" ;
1332 goto UPLOADCA_ERROR
;
1337 ### Upload CA Certificate
1339 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
1340 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1342 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1343 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1344 goto UPLOADCA_ERROR
;
1347 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
1348 $errormessage = $Lang :: tr
{ 'name too long' };
1352 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
1353 $errormessage = $Lang :: tr
{ 'name is invalid' };
1354 goto UPLOADCA_ERROR
;
1357 # Check if there is no other entry with this name
1358 foreach my $key ( keys %cahash ) {
1359 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
1360 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
1361 goto UPLOADCA_ERROR
;
1365 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1366 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1367 goto UPLOADCA_ERROR
;
1369 # Move uploaded ca to a temporary file
1370 ( my $fh , my $filename ) = tempfile
( );
1371 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1373 goto UPLOADCA_ERROR
;
1375 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
1376 if ( $temp !~ /CA:TRUE/i ) {
1377 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1379 goto UPLOADCA_ERROR
;
1381 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1383 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1385 goto UPLOADCA_ERROR
;
1389 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem` ;
1390 $casubject =~ /Subject: (.*)[\n]/ ;
1392 $casubject =~ s
+/ Email
+, E
+;
1393 $casubject =~ s/ ST=/ S=/ ;
1394 $casubject = & Header
:: cleanhtml
( $casubject );
1396 my $key = & General
:: findhasharraykey
( \
%cahash );
1397 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1398 $cahash { $key }[ 1 ] = $casubject ;
1399 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1400 # system('/usr/local/bin/ipsecctrl', 'R');
1405 ### Display ca certificate
1407 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
1408 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1410 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1411 & Header
:: showhttpheaders
();
1412 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1413 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1414 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ca certificate'}:" );
1415 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1416 $output = & Header
:: cleanhtml
( $output , "y" );
1417 print "<pre> $output </pre> \n " ;
1418 & Header
:: closebox
();
1419 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1420 & Header
:: closebigbox
();
1421 & Header
:: closepage
();
1424 $errormessage = $Lang :: tr
{ 'invalid key' };
1428 ### Download ca certificate
1430 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
1431 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1433 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1434 print "Content-Type: application/octet-stream \r\n " ;
1435 print "Content-Disposition: filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
1436 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1439 $errormessage = $Lang :: tr
{ 'invalid key' };
1443 ### Remove ca certificate (step 2)
1445 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1446 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1447 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1449 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1450 foreach my $key ( keys %confighash ) {
1451 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` ;
1452 if ( $test =~ /: OK/ ) {
1454 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1455 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
1456 # system('/usr/local/bin/ipsecctrl', 'D', $key);
1458 unlink ( "${General::swroot}/ovpn//certs/ $confighash { $key }[1]cert.pem" );
1459 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" );
1460 delete $confighash { $key };
1461 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1462 # &writeipsecfiles();
1465 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1466 delete $cahash { $cgiparams { 'KEY' }};
1467 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1468 # system('/usr/local/bin/ipsecctrl', 'R');
1470 $errormessage = $Lang :: tr
{ 'invalid key' };
1473 ### Remove ca certificate (step 1)
1475 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
1476 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1477 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1479 my $assignedcerts = 0 ;
1480 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1481 foreach my $key ( keys %confighash ) {
1482 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` ;
1483 if ( $test =~ /: OK/ ) {
1487 if ( $assignedcerts ) {
1488 & Header
:: showhttpheaders
();
1489 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1490 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1491 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'are you sure' });
1493 <table><form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1494 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1495 <tr><td align='center'>
1496 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>: $assignedcerts
1497 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}
1498 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
1499 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td></tr>
1503 & Header
:: closebox
();
1504 & Header
:: closebigbox
();
1505 & Header
:: closepage
();
1508 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1509 delete $cahash { $cgiparams { 'KEY' }};
1510 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1511 # system('/usr/local/bin/ipsecctrl', 'R');
1514 $errormessage = $Lang :: tr
{ 'invalid key' };
1518 ### Display root certificate
1520 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
1521 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
1523 & Header
:: showhttpheaders
();
1524 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1525 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1526 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
1527 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'root certificate'}:" );
1528 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1530 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'host certificate'}:" );
1531 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1533 $output = & Header
:: cleanhtml
( $output , "y" );
1534 print "<pre> $output </pre> \n " ;
1535 & Header
:: closebox
();
1536 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1537 & Header
:: closebigbox
();
1538 & Header
:: closepage
();
1542 ### Download root certificate
1544 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
1545 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1546 print "Content-Type: application/octet-stream \r\n " ;
1547 print "Content-Disposition: filename=cacert.pem \r\n\r\n " ;
1548 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1553 ### Download host certificate
1555 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
1556 if ( - f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
1557 print "Content-Type: application/octet-stream \r\n " ;
1558 print "Content-Disposition: filename=servercert.pem \r\n\r\n " ;
1559 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1564 ### Download tls-auth key
1566 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download tls-auth key' }) {
1567 if ( - f
"${General::swroot}/ovpn/certs/ta.key" ) {
1568 print "Content-Type: application/octet-stream \r\n " ;
1569 print "Content-Disposition: filename=ta.key \r\n\r\n " ;
1570 print `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
1575 ### Form for generating a root certificate
1577 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
1578 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1580 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1581 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1582 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
1583 $cgiparams { 'ACTION' } = '' ;
1584 goto ROOTCERT_ERROR
;
1587 if (( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) && - e
"${General::swroot}/red/active" ) {
1588 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
1589 my $ipaddr = < IPADDR
>;
1592 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
1593 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
1594 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
1597 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1599 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1600 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1601 goto ROOTCERT_ERROR
;
1604 # Move uploaded certificate request to a temporary file
1605 ( my $fh , my $filename ) = tempfile
( );
1606 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1608 goto ROOTCERT_ERROR
;
1611 # Create a temporary dirctory
1612 my $tempdir = tempdir
( CLEANUP
=> 1 );
1614 # Extract the CA certificate from the file
1615 my $pid = open ( OPENSSL
, "|-" );
1616 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1617 if ( $pid ) { # parent
1618 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1619 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1623 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1625 goto ROOTCERT_ERROR
;
1628 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-cacerts' , '-nokeys' ,
1630 '-out' , " $tempdir /cacert.pem" )) {
1631 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1633 goto ROOTCERT_ERROR
;
1637 # Extract the Host certificate from the file
1638 $pid = open ( OPENSSL
, "|-" );
1639 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1640 if ( $pid ) { # parent
1641 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1642 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1646 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1648 goto ROOTCERT_ERROR
;
1651 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-clcerts' , '-nokeys' ,
1653 '-out' , " $tempdir /hostcert.pem" )) {
1654 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1656 goto ROOTCERT_ERROR
;
1660 # Extract the Host key from the file
1661 $pid = open ( OPENSSL
, "|-" );
1662 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1663 if ( $pid ) { # parent
1664 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1665 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1669 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1671 goto ROOTCERT_ERROR
;
1674 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-nocerts' ,
1677 '-out' , " $tempdir /serverkey.pem" )) {
1678 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1680 goto ROOTCERT_ERROR
;
1684 move
( " $tempdir /cacert.pem" , "${General::swroot}/ovpn/ca/cacert.pem" );
1686 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1688 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1689 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1690 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1691 goto ROOTCERT_ERROR
;
1694 move
( " $tempdir /hostcert.pem" , "${General::swroot}/ovpn/certs/servercert.pem" );
1696 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1698 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1699 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1700 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1701 goto ROOTCERT_ERROR
;
1704 move
( " $tempdir /serverkey.pem" , "${General::swroot}/ovpn/certs/serverkey.pem" );
1706 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1708 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1709 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1710 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1711 goto ROOTCERT_ERROR
;
1714 goto ROOTCERT_SUCCESS
;
1716 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
1718 # Validate input since the form was submitted
1719 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
1720 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
1721 goto ROOTCERT_ERROR
;
1723 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
1724 $errormessage = $Lang :: tr
{ 'organization too long' };
1725 goto ROOTCERT_ERROR
;
1727 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1728 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1729 goto ROOTCERT_ERROR
;
1731 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
1732 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
1733 goto ROOTCERT_ERROR
;
1735 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
1736 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1737 goto ROOTCERT_ERROR
;
1739 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
1740 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1741 goto ROOTCERT_ERROR
;
1743 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
1744 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1745 goto ROOTCERT_ERROR
;
1747 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1748 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1749 goto ROOTCERT_ERROR
;
1751 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1752 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1753 goto ROOTCERT_ERROR
;
1755 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1756 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1757 goto ROOTCERT_ERROR
;
1759 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1760 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1761 goto ROOTCERT_ERROR
;
1764 # Copy the cgisettings to vpnsettings and save the configfile
1765 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
1766 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
1767 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
1768 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
1769 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
1770 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
1771 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
1772 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1774 # Replace empty strings with a .
1775 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
1776 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
1777 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
1780 #system ('/bin/touch', "${General::swroot}/ovpn/gencanow");
1782 # Create the CA certificate
1783 my $pid = open ( OPENSSL
, "|-" );
1784 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1785 if ( $pid ) { # parent
1786 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1787 print OPENSSL
" $state \n " ;
1788 print OPENSSL
" $city \n " ;
1789 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1790 print OPENSSL
" $ou \n " ;
1791 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
1792 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1795 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1796 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1797 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1798 goto ROOTCERT_ERROR
;
1801 unless ( exec ( '/usr/bin/openssl' , 'req' , '-x509' , '-nodes' ,
1802 '-days' , '999999' , '-newkey' , 'rsa:4096' , '-sha512' ,
1803 '-keyout' , "${General::swroot}/ovpn/ca/cakey.pem" ,
1804 '-out' , "${General::swroot}/ovpn/ca/cacert.pem" ,
1805 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1806 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1807 goto ROOTCERT_ERROR
;
1811 # Create the Host certificate request
1812 $pid = open ( OPENSSL
, "|-" );
1813 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1814 if ( $pid ) { # parent
1815 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1816 print OPENSSL
" $state \n " ;
1817 print OPENSSL
" $city \n " ;
1818 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1819 print OPENSSL
" $ou \n " ;
1820 print OPENSSL
" $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1821 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1822 print OPENSSL
". \n " ;
1823 print OPENSSL
". \n " ;
1826 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1827 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1828 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1829 goto ROOTCERT_ERROR
;
1832 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' ,
1833 '-newkey' , 'rsa:2048' ,
1834 '-keyout' , "${General::swroot}/ovpn/certs/serverkey.pem" ,
1835 '-out' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1836 '-extensions' , 'server' ,
1837 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1838 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1839 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1840 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1841 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1842 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1843 goto ROOTCERT_ERROR
;
1847 # Sign the host certificate request
1848 system ( '/usr/bin/openssl' , 'ca' , '-days' , '999999' ,
1849 '-batch' , '-notext' ,
1850 '-in' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1851 '-out' , "${General::swroot}/ovpn/certs/servercert.pem" ,
1852 '-extensions' , 'server' ,
1853 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1855 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1856 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1857 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1858 unlink ( "${General::swroot}/ovpn/serverkey.pem" );
1859 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1860 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1861 & newcleanssldatabase
();
1862 goto ROOTCERT_ERROR
;
1864 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1865 & deletebackupcert
();
1868 # Create an empty CRL
1869 system ( '/usr/bin/openssl' , 'ca' , '-gencrl' ,
1870 '-out' , "${General::swroot}/ovpn/crls/cacrl.pem" ,
1871 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1873 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1874 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1875 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1876 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1877 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1878 & cleanssldatabase
();
1879 goto ROOTCERT_ERROR
;
1881 # &cleanssldatabase();
1883 # Create Diffie Hellmann Parameter
1884 system ( '/usr/bin/openssl' , 'dhparam' , '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" , " $cgiparams {'DHLENGHT'}" );
1886 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1887 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1888 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1889 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1890 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1891 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1892 & cleanssldatabase
();
1893 goto ROOTCERT_ERROR
;
1895 # &cleanssldatabase();
1897 # Create ta.key for tls-auth
1898 system ( '/usr/sbin/openvpn' , '--genkey' , '--secret' , "${General::swroot}/ovpn/certs/ta.key" );
1900 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1901 & cleanssldatabase
();
1902 goto ROOTCERT_ERROR
;
1904 goto ROOTCERT_SUCCESS
;
1907 if ( $cgiparams { 'ACTION' } ne '' ) {
1908 & Header
:: showhttpheaders
();
1909 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1910 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1911 if ( $errormessage ) {
1912 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
1913 print "<class name='base'> $errormessage " ;
1914 print " </class>" ;
1915 & Header
:: closebox
();
1917 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'generate root/host certificates'}:" );
1919 <form method='post' enctype='multipart/form-data'>
1920 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1921 <tr><td width='30%' class='base'> $Lang ::tr{'organization name'}:</td>
1922 <td width='35%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td>
1923 <td width='35%' colspan='2'> </td></tr>
1924 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}:</td>
1925 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td>
1926 <td colspan='2'> </td></tr>
1927 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt'*' /></td>
1928 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td>
1929 <td colspan='2'> </td></tr>
1930 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt'*' /></td>
1931 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td>
1932 <td colspan='2'> </td></tr>
1933 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt'*' /></td>
1934 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td>
1935 <td colspan='2'> </td></tr>
1936 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt'*' /></td>
1937 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td>
1938 <td colspan='2'> </td></tr>
1939 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1940 <td class='base'><select name='ROOTCERT_COUNTRY'>
1944 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1945 print "<option value=' $Countries ::countries{ $country }'" ;
1946 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1947 print " selected='selected'" ;
1949 print "> $country </option>" ;
1953 <tr><td class='base'> $Lang ::tr{'ovpn dh'}:</td>
1954 <td class='base'><select name='DHLENGHT'>
1955 <option value='1024' $selected {'DHLENGHT'}{'1024'}>1024 $Lang ::tr{'bit'}</option>
1956 <option value='2048' $selected {'DHLENGHT'}{'2048'}>2048 $Lang ::tr{'bit'}</option>
1957 <option value='3072' $selected {'DHLENGHT'}{'3072'}>3072 $Lang ::tr{'bit'}</option>
1958 <option value='4096' $selected {'DHLENGHT'}{'4096'}>4096 $Lang ::tr{'bit'}</option>
1964 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /></td>
1965 <td> </td><td> </td></tr>
1966 <tr><td class='base' colspan='4' align='left'>
1967 <img src='/blob.gif' valign='top' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
1968 <tr><td colspan='2'><br></td></tr>
1969 <table width='100%'>
1971 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}: </font></b> $Lang ::tr{'ovpn generating the root and host certificates'}
1972 <td class='base'> $Lang ::tr{'dh key warn'}</td>
1975 <td class='base'> $Lang ::tr{'dh key warn1'}</td>
1977 <tr><td colspan='2'><br></td></tr>
1981 <table width='100%'>
1982 <tr><td colspan='4'><hr></td></tr>
1983 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
1984 <td nowrap='nowrap'><input type='file' name='FH' size='32'></td>
1985 <td colspan='2'> </td></tr>
1986 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' ></td>
1987 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td>
1988 <td colspan='2'> </td></tr>
1990 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td>
1991 <td colspan='2'> </td></tr>
1992 <tr><td class='base' colspan='4' align='left'>
1993 <img src='/blob.gif' valign='top' al='*' > $Lang ::tr{'this field may be blank'}</td>
1998 & Header
:: closebox
();
1999 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2000 & Header
:: closebigbox
();
2001 & Header
:: closepage
();
2006 system ( "chmod 600 ${General::swroot}/ovpn/certs/serverkey.pem" );
2007 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2008 # $vpnsettings{'ENABLE_BLUE'} eq 'on') {
2009 # system('/usr/local/bin/ipsecctrl', 'S');
2013 ### Enable/Disable connection
2020 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
2022 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2023 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2024 # my $n2nactive = '';
2025 my $n2nactive = `/bin/ps ax|grep $confighash { $cgiparams {'KEY'}}[1]|grep -v grep|awk \' {print \ $1 } \' ` ;
2027 if ( $confighash { $cgiparams { 'KEY' }}) {
2028 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
2029 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
2030 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2032 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2033 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
2037 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
2038 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2040 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2041 if ( $n2nactive ne '' ){
2042 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
2046 $errormessage = $Lang :: tr
{ 'invalid key' };
2052 ### Download OpenVPN client package
2056 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'dl client arch' }) {
2057 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2058 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2060 my $clientovpn = '' ;
2062 my $tempdir = tempdir
( CLEANUP
=> 1 );
2063 my $zippath = " $tempdir /" ;
2069 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2071 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-Client.zip" ;
2072 my $zippathname = " $zippath $zipname " ;
2073 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1].conf" ;
2074 my @ovsubnettemp = split ( /\./ , $confighash { $cgiparams { 'KEY' }}[ 27 ]);
2075 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
2077 my @remsubnet = split ( /\/ /, $confighash { $cgiparams { 'KEY' }}[ 8 ]);
2078 my $n2nfragment = '' ;
2080 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2081 flock CLIENTCONF
, 2 ;
2083 my $zip = Archive
:: Zip
-> new ();
2084 print CLIENTCONF
"# IPFire n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
2085 print CLIENTCONF
"# \n " ;
2086 print CLIENTCONF
"# User Security \n " ;
2087 print CLIENTCONF
"user nobody \n " ;
2088 print CLIENTCONF
"group nobody \n " ;
2089 print CLIENTCONF
"persist-tun \n " ;
2090 print CLIENTCONF
"persist-key \n " ;
2091 print CLIENTCONF
"script-security 2 \n " ;
2092 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
2093 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} \n " ;
2094 print CLIENTCONF
"float \n " ;
2095 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
2096 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
2097 print CLIENTCONF
"# Server Gateway Network \n " ;
2098 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
2099 print CLIENTCONF
"# tun Device \n " ;
2100 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \n " ;
2101 print CLIENTCONF
"# Port and Protokoll \n " ;
2102 print CLIENTCONF
"port $confighash { $cgiparams {'KEY'}}[29] \n " ;
2104 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'tcp' ) {
2105 print CLIENTCONF
"proto tcp-client \n " ;
2106 print CLIENTCONF
"# Packet size \n " ;
2107 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1400' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2108 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2111 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'udp' ) {
2112 print CLIENTCONF
"proto udp \n " ;
2113 print CLIENTCONF
"# Paketsize \n " ;
2114 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1500' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2115 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2116 if ( $confighash { $cgiparams { 'KEY' }}[ 24 ] ne '' ) { print CLIENTCONF
"fragment $confighash { $cgiparams {'KEY'}}[24] \n " ;}
2117 if ( $confighash { $cgiparams { 'KEY' }}[ 23 ] eq 'on' ) { print CLIENTCONF
"mssfix \n " ;}
2119 if (( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'yes' ) ||
2120 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'maybe' ) ||
2121 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'no' )) {
2122 if (( $confighash { $cgiparams { 'KEY' }}[ 23 ] ne 'on' ) || ( $confighash { $cgiparams { 'KEY' }}[ 24 ] eq '' )) {
2123 if ( $tunmtu eq '1500' ) {
2124 print CLIENTCONF
"mtu-disc $confighash { $cgiparams {'KEY'}}[38] \n " ;
2128 print CLIENTCONF
"ns-cert-type server \n " ;
2129 print CLIENTCONF
"# Auth. Client \n " ;
2130 print CLIENTCONF
"tls-client \n " ;
2131 print CLIENTCONF
"# Cipher \n " ;
2132 print CLIENTCONF
"cipher $confighash { $cgiparams {'KEY'}}[40] \n " ;
2133 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2134 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2135 $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 " ;
2137 if ( $confighash { $cgiparams { 'KEY' }}[ 39 ] eq '' ) {
2138 print CLIENTCONF
"# HMAC algorithm \n " ;
2139 print CLIENTCONF
"auth SHA1 \n " ;
2141 print CLIENTCONF
"# HMAC algorithm \n " ;
2142 print CLIENTCONF
"auth $confighash { $cgiparams {'KEY'}}[39] \n " ;
2144 if ( $confighash { $cgiparams { 'KEY' }}[ 30 ] eq 'on' ) {
2145 print CLIENTCONF
"# Enable Compression \n " ;
2146 print CLIENTCONF
"comp-lzo \n " ;
2148 print CLIENTCONF
"# Debug Level \n " ;
2149 print CLIENTCONF
"verb 3 \n " ;
2150 print CLIENTCONF
"# Tunnel check \n " ;
2151 print CLIENTCONF
"keepalive 10 60 \n " ;
2152 print CLIENTCONF
"# Start as daemon \n " ;
2153 print CLIENTCONF
"daemon $confighash { $cgiparams {'KEY'}}[1]n2n \n " ;
2154 print CLIENTCONF
"writepid /var/run/ $confighash { $cgiparams {'KEY'}}[1]n2n.pid \n " ;
2155 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
2156 if ( $confighash { $cgiparams { 'KEY' }}[ 22 ] eq '' ) { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[29] \n " }
2157 else { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[22] \n " };
2158 print CLIENTCONF
"# remsub $confighash { $cgiparams {'KEY'}}[11] \n " ;
2163 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2164 my $status = $zip -> writeToFileNamed ( $zippathname );
2166 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2167 @fileholder = < DLFILE
>;
2168 print "Content-Type:application/x-download \n " ;
2169 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2175 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.zip" ;
2176 my $zippathname = " $zippath $zipname " ;
2177 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.ovpn" ;
2183 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2184 flock CLIENTCONF
, 2 ;
2186 my $zip = Archive
:: Zip
-> new ();
2188 print CLIENTCONF
"#OpenVPN Client conf \r\n " ;
2189 print CLIENTCONF
"tls-client \r\n " ;
2190 print CLIENTCONF
"client \r\n " ;
2191 print CLIENTCONF
"nobind \r\n " ;
2192 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \r\n " ;
2193 print CLIENTCONF
"proto $vpnsettings {'DPROTOCOL'} \r\n " ;
2195 # Check if we are using fragment, mssfix or mtu-disc and set MTU to 1500
2196 # or use configured value.
2197 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' )
2198 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2199 elsif ( $vpnsettings { MSSFIX
} eq 'on' )
2200 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2201 elsif (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2202 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2203 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' ))
2204 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2206 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu $vpnsettings {'DMTU'} \r\n " ; }
2208 if ( $vpnsettings { 'ENABLED' } eq 'on' ){
2209 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2210 if ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2211 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Blue interface \r\n " ;
2212 print CLIENTCONF
";remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2214 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2215 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2216 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2218 } elsif ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2219 print CLIENTCONF
"remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2220 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2221 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2222 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2224 } elsif ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2225 print CLIENTCONF
"remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2228 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2229 print CLIENTCONF
"pkcs12 $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2230 $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 " ;
2232 print CLIENTCONF
"ca cacert.pem \r\n " ;
2233 print CLIENTCONF
"cert $confighash { $cgiparams {'KEY'}}[1]cert.pem \r\n " ;
2234 print CLIENTCONF
"key $confighash { $cgiparams {'KEY'}}[1].key \r\n " ;
2235 $zip -> addFile ( "${General::swroot}/ovpn/ca/cacert.pem" , "cacert.pem" ) or die "Can't add file cacert.pem \n " ;
2236 $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 " ;
2238 print CLIENTCONF
"cipher $vpnsettings {DCIPHER} \r\n " ;
2239 if ( $vpnsettings { 'DAUTH' } eq '' ) {
2240 print CLIENTCONF
"" ;
2242 print CLIENTCONF
"auth $vpnsettings {'DAUTH'} \r\n " ;
2244 if ( $vpnsettings { 'TLSAUTH' } eq 'on' ) {
2245 print CLIENTCONF
"tls-auth ta.key \r\n " ;
2246 $zip -> addFile ( "${General::swroot}/ovpn/certs/ta.key" , "ta.key" ) or die "Can't add file ta.key \n " ;
2248 if ( $vpnsettings { DCOMPLZO
} eq 'on' ) {
2249 print CLIENTCONF
"comp-lzo \r\n " ;
2251 print CLIENTCONF
"verb 3 \r\n " ;
2252 print CLIENTCONF
"ns-cert-type server \r\n " ;
2253 print CLIENTCONF
"tls-remote $vpnsettings {ROOTCERT_HOSTNAME} \r\n " ;
2254 if ( $vpnsettings { MSSFIX
} eq 'on' ) {
2255 print CLIENTCONF
"mssfix \r\n " ;
2257 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' ) {
2258 print CLIENTCONF
"fragment $vpnsettings {'FRAGMENT'} \r\n " ;
2261 # Check if a valid operating mode has been choosen and use it.
2262 if (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2263 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2264 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' )) {
2265 if (( $vpnsettings { MSSFIX
} ne 'on' ) || ( $vpnsettings { FRAGMENT
} eq '' )) {
2266 print CLIENTCONF
"mtu-disc $vpnsettings {'PMTU_DISCOVERY'} \r\n " ;
2269 # Print client.conf.local if entries exist to client.ovpn
2270 if (!- z
$local_clientconf && $vpnsettings { 'ADDITIONAL_CONFIGS' } eq 'on' ) {
2271 open ( LCC
, " $local_clientconf " );
2272 print CLIENTCONF
" \n #--------------------------- \n " ;
2273 print CLIENTCONF
"# Start of custom directives \n " ;
2274 print CLIENTCONF
"# from client.conf.local \n " ;
2275 print CLIENTCONF
"#--------------------------- \n\n " ;
2277 print CLIENTCONF
$_ ;
2279 print CLIENTCONF
" \n #--------------------------- \n " ;
2280 print CLIENTCONF
"# End of custom directives \n " ;
2281 print CLIENTCONF
"#--------------------------- \n\n " ;
2286 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2287 my $status = $zip -> writeToFileNamed ( $zippathname );
2289 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2290 @fileholder = < DLFILE
>;
2291 print "Content-Type:application/x-download \n " ;
2292 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2300 ### Remove connection
2304 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
2305 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2306 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2308 if ( $confighash { $cgiparams { 'KEY' }}) {
2309 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2310 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2311 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2314 my $temp = `/usr/bin/openssl ca -revoke ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2320 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
2321 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
2322 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2326 if (- e
"${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) {
2327 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
2331 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
2332 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2334 # A.Marx CCD delete ccd files and routes
2337 if (- f
"${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" )
2339 unlink "${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" ;
2342 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2343 foreach my $key ( keys %ccdroutehash ) {
2344 if ( $ccdroutehash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2345 delete $ccdroutehash { $key };
2348 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2350 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2351 foreach my $key ( keys %ccdroute2hash ) {
2352 if ( $ccdroute2hash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2353 delete $ccdroute2hash { $key };
2356 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2363 delete $confighash { $cgiparams { 'KEY' }};
2364 my $temp2 = `/usr/bin/openssl ca -gencrl -out ${General::swroot}/ovpn/crls/cacrl.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2365 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2367 #&writeserverconf();
2369 $errormessage = $Lang :: tr
{ 'invalid key' };
2371 & General
:: firewall_reload
();
2374 ### Download PKCS12 file
2376 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
2377 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2379 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
2380 print "Content-Type: application/octet-stream \r\n\r\n " ;
2381 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
2385 ### Display certificate
2387 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
2388 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2390 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2391 & Header
:: showhttpheaders
();
2392 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2393 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2394 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate'}:" );
2395 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2396 $output = & Header
:: cleanhtml
( $output , "y" );
2397 print "<pre> $output </pre> \n " ;
2398 & Header
:: closebox
();
2399 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2400 & Header
:: closebigbox
();
2401 & Header
:: closepage
();
2406 ### Display Diffie-Hellman key
2408 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show dh' }) {
2410 if (! - e
"${General::swroot}/ovpn/ca/dh1024.pem" ) {
2411 $errormessage = $Lang :: tr
{ 'not present' };
2413 & Header
:: showhttpheaders
();
2414 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2415 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2416 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'dh'}:" );
2417 my $output = `/usr/bin/openssl dhparam -text -in ${General::swroot}/ovpn/ca/dh1024.pem` ;
2418 $output = & Header
:: cleanhtml
( $output , "y" );
2419 print "<pre> $output </pre> \n " ;
2420 & Header
:: closebox
();
2421 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2422 & Header
:: closebigbox
();
2423 & Header
:: closepage
();
2428 ### Display tls-auth key
2430 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show tls-auth key' }) {
2432 if (! - e
"${General::swroot}/ovpn/certs/ta.key" ) {
2433 $errormessage = $Lang :: tr
{ 'not present' };
2435 & Header
:: showhttpheaders
();
2436 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2437 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2438 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ta key'}:" );
2439 my $output = `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
2440 $output = & Header
:: cleanhtml
( $output , "y" );
2441 print "<pre> $output </pre> \n " ;
2442 & Header
:: closebox
();
2443 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2444 & Header
:: closebigbox
();
2445 & Header
:: closepage
();
2450 ### Display Certificate Revoke List
2452 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show crl' }) {
2453 # &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash);
2455 if (! - e
"${General::swroot}/ovpn/crls/cacrl.pem" ) {
2456 $errormessage = $Lang :: tr
{ 'not present' };
2458 & Header
:: showhttpheaders
();
2459 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2460 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2461 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'crl'}:" );
2462 my $output = `/usr/bin/openssl crl -text -noout -in ${General::swroot}/ovpn/crls/cacrl.pem` ;
2463 $output = & Header
:: cleanhtml
( $output , "y" );
2464 print "<pre> $output </pre> \n " ;
2465 & Header
:: closebox
();
2466 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2467 & Header
:: closebigbox
();
2468 & Header
:: closepage
();
2473 ### Advanced Server Settings
2476 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced server' }) {
2481 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
2485 # if ($cgiparams{'CLIENT2CLIENT'} eq '') {
2486 # $cgiparams{'CLIENT2CLIENT'} = 'on';
2489 if ( $cgiparams { 'MAX_CLIENTS' } eq '' ) {
2490 $cgiparams { 'MAX_CLIENTS' } = '100' ;
2492 if ( $cgiparams { 'KEEPALIVE_1' } eq '' ) {
2493 $cgiparams { 'KEEPALIVE_1' } = '10' ;
2495 if ( $cgiparams { 'KEEPALIVE_2' } eq '' ) {
2496 $cgiparams { 'KEEPALIVE_2' } = '60' ;
2498 if ( $cgiparams { 'LOG_VERB' } eq '' ) {
2499 $cgiparams { 'LOG_VERB' } = '3' ;
2501 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
2502 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
2504 if ( $cgiparams { 'DAUTH' } eq '' ) {
2505 $cgiparams { 'DAUTH' } = 'SHA1' ;
2507 if ( $cgiparams { 'TLSAUTH' } eq '' ) {
2508 $cgiparams { 'TLSAUTH' } = 'off' ;
2510 $checked { 'CLIENT2CLIENT' }{ 'off' } = '' ;
2511 $checked { 'CLIENT2CLIENT' }{ 'on' } = '' ;
2512 $checked { 'CLIENT2CLIENT' }{ $cgiparams { 'CLIENT2CLIENT' }} = 'CHECKED' ;
2513 $checked { 'REDIRECT_GW_DEF1' }{ 'off' } = '' ;
2514 $checked { 'REDIRECT_GW_DEF1' }{ 'on' } = '' ;
2515 $checked { 'REDIRECT_GW_DEF1' }{ $cgiparams { 'REDIRECT_GW_DEF1' }} = 'CHECKED' ;
2516 $checked { 'ADDITIONAL_CONFIGS' }{ 'off' } = '' ;
2517 $checked { 'ADDITIONAL_CONFIGS' }{ 'on' } = '' ;
2518 $checked { 'ADDITIONAL_CONFIGS' }{ $cgiparams { 'ADDITIONAL_CONFIGS' }} = 'CHECKED' ;
2519 $checked { 'MSSFIX' }{ 'off' } = '' ;
2520 $checked { 'MSSFIX' }{ 'on' } = '' ;
2521 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
2522 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
2523 $selected { 'LOG_VERB' }{ '0' } = '' ;
2524 $selected { 'LOG_VERB' }{ '1' } = '' ;
2525 $selected { 'LOG_VERB' }{ '2' } = '' ;
2526 $selected { 'LOG_VERB' }{ '3' } = '' ;
2527 $selected { 'LOG_VERB' }{ '4' } = '' ;
2528 $selected { 'LOG_VERB' }{ '5' } = '' ;
2529 $selected { 'LOG_VERB' }{ '6' } = '' ;
2530 $selected { 'LOG_VERB' }{ '7' } = '' ;
2531 $selected { 'LOG_VERB' }{ '8' } = '' ;
2532 $selected { 'LOG_VERB' }{ '9' } = '' ;
2533 $selected { 'LOG_VERB' }{ '10' } = '' ;
2534 $selected { 'LOG_VERB' }{ '11' } = '' ;
2535 $selected { 'LOG_VERB' }{ $cgiparams { 'LOG_VERB' }} = 'SELECTED' ;
2536 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
2537 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
2538 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
2539 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
2540 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
2541 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
2542 $checked { 'TLSAUTH' }{ 'off' } = '' ;
2543 $checked { 'TLSAUTH' }{ 'on' } = '' ;
2544 $checked { 'TLSAUTH' }{ $cgiparams { 'TLSAUTH' }} = 'CHECKED' ;
2546 & Header
:: showhttpheaders
();
2547 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
2548 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
2549 if ( $errormessage ) {
2550 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2551 print "<class name='base'> $errormessage \n " ;
2552 print " </class> \n " ;
2553 & Header
:: closebox
();
2555 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'advanced server' });
2557 <form method='post' enctype='multipart/form-data'>
2558 <table width='100%' border=0>
2560 <td colspan='4'><b> $Lang ::tr{'dhcp-options'}</b></td>
2563 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2566 <td class='base'>Domain</td>
2567 <td><input type='TEXT' name='DHCP_DOMAIN' value=' $cgiparams {'DHCP_DOMAIN'}' size='30' /></td>
2570 <td class='base'>DNS</td>
2571 <td><input type='TEXT' name='DHCP_DNS' value=' $cgiparams {'DHCP_DNS'}' size='30' /></td>
2574 <td class='base'>WINS</td>
2575 <td><input type='TEXT' name='DHCP_WINS' value=' $cgiparams {'DHCP_WINS'}' size='30' /></td>
2578 <td colspan='4'><b> $Lang ::tr{'ovpn routes push options'}</b></td>
2581 <td class='base'> $Lang ::tr{'ovpn routes push'}</td>
2583 <textarea name='ROUTES_PUSH' cols='26' rows='6' wrap='off'>
2587 if ( $cgiparams { 'ROUTES_PUSH' } ne '' )
2589 print $cgiparams { 'ROUTES_PUSH' };
2598 <table width='100%'>
2600 <td class'base'><b> $Lang ::tr{'misc-options'}</b></td>
2604 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2608 <td class='base'>Client-To-Client</td>
2609 <td><input type='checkbox' name='CLIENT2CLIENT' $checked {'CLIENT2CLIENT'}{'on'} /></td>
2613 <td class='base'>Redirect-Gateway def1</td>
2614 <td><input type='checkbox' name='REDIRECT_GW_DEF1' $checked {'REDIRECT_GW_DEF1'}{'on'} /></td>
2618 <td class='base'> $Lang ::tr{'ovpn add conf'}</td>
2619 <td><input type='checkbox' name='ADDITIONAL_CONFIGS' $checked {'ADDITIONAL_CONFIGS'}{'on'} /></td>
2620 <td> $Lang ::tr{'openvpn default'}: off</td>
2624 <td class='base'>mssfix</td>
2625 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
2626 <td> $Lang ::tr{'openvpn default'}: off</td>
2630 <td class='base'>fragment <br></td>
2631 <td><input type='TEXT' name='FRAGMENT' value=' $cgiparams {'FRAGMENT'}' size='10' /></td>
2636 <td class='base'>Max-Clients</td>
2637 <td><input type='text' name='MAX_CLIENTS' value=' $cgiparams {'MAX_CLIENTS'}' size='10' /></td>
2640 <td class='base'>Keepalive <br />
2641 (ping/ping-restart)</td>
2642 <td><input type='TEXT' name='KEEPALIVE_1' value=' $cgiparams {'KEEPALIVE_1'}' size='10' /></td>
2643 <td><input type='TEXT' name='KEEPALIVE_2' value=' $cgiparams {'KEEPALIVE_2'}' size='10' /></td>
2647 <td class='base'> $Lang ::tr{'ovpn mtu-disc'}</td>
2648 <td><input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}</td>
2649 <td><input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}</td>
2650 <td><input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}</td>
2651 <td><input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}</td>
2656 <table width='100%'>
2658 <td class'base'><b> $Lang ::tr{'log-options'}</b></td>
2661 <td width='20%'></td> <td width='30%'> </td><td width='25%'> </td><td width='25%'></td>
2664 <tr><td class='base'>VERB</td>
2665 <td><select name='LOG_VERB'>
2666 <option value='0' $selected {'LOG_VERB'}{'0'}>0</option>
2667 <option value='1' $selected {'LOG_VERB'}{'1'}>1</option>
2668 <option value='2' $selected {'LOG_VERB'}{'2'}>2</option>
2669 <option value='3' $selected {'LOG_VERB'}{'3'}>3</option>
2670 <option value='4' $selected {'LOG_VERB'}{'4'}>4</option>
2671 <option value='5' $selected {'LOG_VERB'}{'5'}>5</option>
2672 <option value='6' $selected {'LOG_VERB'}{'6'}>6</option>
2673 <option value='7' $selected {'LOG_VERB'}{'7'}>7</option>
2674 <option value='8' $selected {'LOG_VERB'}{'8'}>8</option>
2675 <option value='9' $selected {'LOG_VERB'}{'9'}>9</option>
2676 <option value='10' $selected {'LOG_VERB'}{'10'}>10</option>
2677 <option value='11' $selected {'LOG_VERB'}{'11'}>11</option>
2682 <table width='100%'>
2684 <td class'base'><b> $Lang ::tr{'ovpn crypt options'}</b></td>
2687 <td width='20%'></td> <td width='30%'> </td><td width='25%'> </td><td width='25%'></td>
2689 <tr><td class='base'> $Lang ::tr{'ovpn ha'}</td>
2690 <td><select name='DAUTH'>
2691 <option value='whirlpool' $selected {'DAUTH'}{'whirlpool'}>Whirlpool (512 $Lang ::tr{'bit'})</option>
2692 <option value='SHA512' $selected {'DAUTH'}{'SHA512'}>SHA2 (512 $Lang ::tr{'bit'})</option>
2693 <option value='SHA384' $selected {'DAUTH'}{'SHA384'}>SHA2 (384 $Lang ::tr{'bit'})</option>
2694 <option value='SHA256' $selected {'DAUTH'}{'SHA256'}>SHA2 (256 $Lang ::tr{'bit'})</option>
2695 <option value='SHA1' $selected {'DAUTH'}{'SHA1'}>SHA1 (160 $Lang ::tr{'bit'})</option>
2698 <td> $Lang ::tr{'openvpn default'}: <span class="base">SHA1 (160 $Lang ::tr{'bit'})</span></td>
2702 <table width='100%'>
2704 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2708 <td class='base'>HMAC tls-auth</td>
2709 <td><input type='checkbox' name='TLSAUTH' $checked {'TLSAUTH'}{'on'} /></td>
2714 if ( - e
"/var/run/openvpn.pid" ){
2715 print " <br><b><font color='#990000'> $Lang ::tr{'attention'}:</b></font><br>
2716 $Lang ::tr{'server restart'}<br><br>
2719 <table width='100%'>
2722 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' disabled='disabled' /></td>
2723 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2735 <table width='100%'>
2738 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' /></td>
2739 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2747 & Header
:: closebox
();
2748 # print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'>$Lang::tr{'back'}</a></div>";
2749 & Header
:: closebigbox
();
2750 & Header
:: closepage
();
2754 # A.Marx CCD Add,delete or edit CCD net
2756 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd net' } ||
2757 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' } ||
2758 $cgiparams { 'ACTION' } eq "kill" ||
2759 $cgiparams { 'ACTION' } eq "edit" ||
2760 $cgiparams { 'ACTION' } eq 'editsave' ){
2761 & Header
:: showhttpheaders
();
2762 & Header
:: openpage
( $Lang :: tr
{ 'ccd net' }, 1 , '' );
2763 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2765 if ( $cgiparams { 'ACTION' } eq "kill" ){
2766 & delccdnet
( $cgiparams { 'net' });
2769 if ( $cgiparams { 'ACTION' } eq 'editsave' ){
2770 my ( $a , $b ) = split ( /\|/ , $cgiparams { 'ccdname' });
2771 if ( $a ne $b ){ & modccdnet
( $a , $b );}
2772 $cgiparams { 'ccdname' }= '' ;
2773 $cgiparams { 'ccdsubnet' }= '' ;
2776 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' }) {
2777 & addccdnet
( $cgiparams { 'ccdname' }, $cgiparams { 'ccdsubnet' });
2779 if ( $errormessage ) {
2780 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2781 print "<class name='base'> $errormessage " ;
2782 print " </class>" ;
2783 & Header
:: closebox
();
2785 if ( $cgiparams { 'ACTION' } eq "edit" ){
2787 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd modify' });
2790 <table width='100%' border='0'>
2791 <tr><form method='post'>
2792 <td width='10%' nowrap='nowrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2793 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' readonly='readonly' /></td></tr>
2794 <tr><td colspan='4' align='right'><hr><input type='submit' value=' $Lang ::tr{'save'}' /><input type='hidden' name='ACTION' value='editsave'/>
2795 <input type='hidden' name='ccdname' value=' $cgiparams {'ccdname'}'/><input type='submit' value=' $Lang ::tr{'cancel'}' />
2800 & Header
:: closebox
();
2802 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2804 <table width='100%' border='0' cellpadding='0' cellspacing='1'>
2806 <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>
2811 if (! - e
"/var/run/openvpn.pid" ){
2812 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd add' });
2814 <table width='100%' border='0'>
2815 <tr><form method='post'>
2816 <td colspan='4'> $Lang ::tr{'ccd hint'}<br><br></td></tr>
2818 <td width='10%' nowrap='nwrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2819 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' /></td></tr>
2820 <tr><td colspan=4><hr /></td></tr><tr>
2821 <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>
2825 & Header
:: closebox
();
2827 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2828 if ( - e
"/var/run/openvpn.pid" ){
2829 print "<b> $Lang ::tr{'attention'}:</b><br>" ;
2830 print " $Lang ::tr{'ccd noaddnet'}<br><hr>" ;
2834 <table width='100%' cellpadding='0' cellspacing='1'>
2836 <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>
2841 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
2844 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
2845 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
2847 my $ccdhosts = & hostsinnet
( $ccdconf [ 0 ]);
2848 if ( $count % 2 ){ print " <tr bgcolor=' $color {'color22'}'>" ;}
2849 else { print " <tr bgcolor=' $color {'color20'}'>" ;}
2850 print "<td> $ccdconf [0]</td><td align='center'> $ccdconf [1]</td><td align='center'> $ccdhosts /" .(& ccdmaxclients
( $ccdconf [ 1 ])+ 1 ). "</td><td>" ;
2852 <form method='post' />
2853 <input type='image' src='/images/edit.gif' align='middle' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
2854 <input type='hidden' name='ACTION' value='edit'/>
2855 <input type='hidden' name='ccdname' value=' $ccdconf [0]' />
2856 <input type='hidden' name='ccdsubnet' value=' $ccdconf [1]' />
2858 <form method='post' />
2859 <td><input type='hidden' name='ACTION' value='kill'/>
2860 <input type='hidden' name='number' value=' $count ' />
2861 <input type='hidden' name='net' value=' $ccdconf [0]' />
2862 <input type='image' src='/images/delete.gif' align='middle' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' /></form></td></tr>
2866 print "</table></form>" ;
2867 & Header
:: closebox
();
2868 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2869 & Header
:: closebigbox
();
2870 & Header
:: closepage
();
2876 ### Openvpn Connections Statistics
2878 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ovpn con stat' }) {
2879 & Header
:: showhttpheaders
();
2880 & Header
:: openpage
( $Lang :: tr
{ 'ovpn con stat' }, 1 , '' );
2881 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2882 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ovpn con stat' });
2885 # <td><b>$Lang::tr{'protocol'}</b></td>
2886 # protocol temp removed
2888 <table width='100%' cellpadding='2' cellspacing='0' class='tbl'>
2890 <th><b> $Lang ::tr{'common name'}</b></th>
2891 <th><b> $Lang ::tr{'real address'}</b></th>
2892 <th><b> $Lang ::tr{'virtual address'}</b></th>
2893 <th><b> $Lang ::tr{'loged in at'}</b></th>
2894 <th><b> $Lang ::tr{'bytes sent'}</b></th>
2895 <th><b> $Lang ::tr{'bytes received'}</b></th>
2896 <th><b> $Lang ::tr{'last activity'}</b></th>
2900 my $filename = "/var/log/ovpnserver.log" ;
2901 open ( FILE
, $filename ) or die 'Unable to open config file.' ;
2902 my @current = < FILE
>;
2911 my %userlookup = ();
2912 foreach my $line ( @current )
2915 if ( $line =~ /^Updated,(.+)/ ){
2916 @match = split ( /^Updated,(.+)/ , $line );
2917 $status = $match [ 1 ];
2920 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
2921 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
2922 if ( $match [ 1 ] ne "Common Name" ) {
2924 $userlookup { $match [ 2 ]} = $uid ;
2925 $users [ $uid ]{ 'CommonName' } = $match [ 1 ];
2926 $users [ $uid ]{ 'RealAddress' } = $match [ 2 ];
2927 $users [ $uid ]{ 'BytesReceived' } = & sizeformat
( $match [ 3 ]);
2928 $users [ $uid ]{ 'BytesSent' } = & sizeformat
( $match [ 4 ]);
2929 $users [ $uid ]{ 'Since' } = $match [ 5 ];
2930 $users [ $uid ]{ 'Proto' } = $proto ;
2934 if ( $line =~ /^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ ) {
2935 @match = split ( m/^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ , $line );
2936 if ( $match [ 1 ] ne "Virtual Address" ) {
2937 $address = $match [ 3 ];
2938 #find the uid in the lookup table
2939 $uid = $userlookup { $address };
2940 $users [ $uid ]{ 'VirtualAddress' } = $match [ 1 ];
2941 $users [ $uid ]{ 'LastRef' } = $match [ 4 ];
2947 for ( my $idx = 1 ; $idx <= $user2 ; $idx ++){
2950 $col = "bgcolor=' $color {'color22'}'" ;
2953 $col = "bgcolor=' $color {'color20'}'" ;
2955 print "<td align='left' $col > $users [ $idx -1]{'CommonName'}</td>" ;
2956 print "<td align='left' $col > $users [ $idx -1]{'RealAddress'}</td>" ;
2957 print "<td align='left' $col > $users [ $idx -1]{'VirtualAddress'}</td>" ;
2958 print "<td align='left' $col > $users [ $idx -1]{'Since'}</td>" ;
2959 print "<td align='left' $col > $users [ $idx -1]{'BytesSent'}</td>" ;
2960 print "<td align='left' $col > $users [ $idx -1]{'BytesReceived'}</td>" ;
2961 print "<td align='left' $col > $users [ $idx -1]{'LastRef'}</td>" ;
2967 <table width='100%' border='0' cellpadding='2' cellspacing='0'>
2972 <tr><td align='center' > $Lang ::tr{'the statistics were last updated at'} <b> $status </b></td></tr>
2976 & Header
:: closebox
();
2977 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2978 & Header
:: closebigbox
();
2979 & Header
:: closepage
();
2983 ### Download Certificate
2985 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
2986 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2988 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2989 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \r\n " ;
2990 print "Content-Type: application/octet-stream \r\n\r\n " ;
2991 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2996 ### Enable/Disable connection
2999 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
3001 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3002 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3004 if ( $confighash { $cgiparams { 'KEY' }}) {
3005 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
3006 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
3007 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3008 #&writeserverconf();
3009 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3010 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3011 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
3014 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
3015 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3016 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3017 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
3019 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3020 #&writeserverconf();
3023 $errormessage = $Lang :: tr
{ 'invalid key' };
3027 ### Restart connection
3029 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
3030 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3031 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3033 if ( $confighash { $cgiparams { 'KEY' }}) {
3034 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3035 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3036 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
3039 $errormessage = $Lang :: tr
{ 'invalid key' };
3043 ### Remove connection
3045 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
3046 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3047 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3049 if ( $confighash { $cgiparams { 'KEY' }}) {
3050 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3051 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3052 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
3054 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
3055 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
3056 delete $confighash { $cgiparams { 'KEY' }};
3057 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3058 #&writeserverconf();
3060 $errormessage = $Lang :: tr
{ 'invalid key' };
3065 ### Choose between adding a host-net or net-net connection
3072 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
3073 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3074 & Header
:: showhttpheaders
();
3075 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
3076 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
3077 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection type' });
3079 if ( - s
"${General::swroot}/ovpn/settings" ) {
3082 <b> $Lang ::tr{'connection type'}:</b><br />
3083 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
3084 <tr><td><input type='radio' name='TYPE' value='host' checked /></td>
3085 <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
3086 <tr><td><input type='radio' name='TYPE' value='net' /></td>
3087 <td class='base'> $Lang ::tr{'net to net vpn'}</td></tr>
3088 <tr><td><input type='radio' name='TYPE' value='net2net' /></td>
3089 <td class='base'> $Lang ::tr{'net to net vpn'} (Upload Client Package)</td></tr>
3090 <tr><td> </td><td class='base'><input type='file' name='FH' size='30'></td></tr>
3091 <tr><td> </td><td>Import Connection Name <img src='/blob.gif' /></td></tr>
3092 <tr><td> </td><td class='base'><input type='text' name='n2nname' size='30'> $Lang ::tr{'openvpn default'}: Client Packagename</td></tr>
3093 <tr><td colspan='3'><hr /></td></tr>
3094 <tr><td align='right' colspan='3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
3095 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
3103 <b> $Lang ::tr{'connection type'}:</b><br />
3104 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
3105 <tr><td><input type='radio' name='TYPE' value='host' checked /></td> <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
3106 <tr><td align='right' colspan'3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
3113 & Header
:: closebox
();
3114 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3115 & Header
:: closebigbox
();
3116 & Header
:: closepage
();
3123 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2net' )){
3127 my $uplconffilename = '' ;
3128 my $uplconffilename2 = '' ;
3129 my $uplp12name = '' ;
3130 my $uplp12name2 = '' ;
3137 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3139 # Check if a file is uploaded
3141 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3142 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3146 # Move uploaded IPfire n2n package to temporary file
3148 ( my $fh , my $filename ) = tempfile
( );
3149 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3154 my $zip = Archive
:: Zip
-> new ();
3155 my $zipName = $filename ;
3156 my $status = $zip -> read ( $zipName );
3157 if ( $status != AZ_OK
) {
3158 $errormessage = "Read of $zipName failed \n " ;
3162 my $tempdir = tempdir
( CLEANUP
=> 1 );
3163 my @files = $zip -> memberNames ();
3165 $zip -> extractMemberWithoutPaths ( $_ , " $tempdir / $_ " );
3167 my $countfiles = @files ;
3169 # Check if we have not more then 2 files
3171 if ( $countfiles == 2 ){
3173 if ( $_ =~ /.conf$/ ){
3174 $uplconffilename = $_ ;
3176 if ( $_ =~ /.p12$/ ){
3180 if (( $uplconffilename eq '' ) || ( $uplp12name eq '' )){
3181 $errormessage = "Either no *.conf or no *.p12 file found \n " ;
3185 open ( FILE
, " $tempdir / $uplconffilename " ) or die 'Unable to open*.conf file' ;
3186 @firen2nconf = < FILE
>;
3188 chomp ( @firen2nconf );
3192 $errormessage = "Filecount does not match only 2 files are allowed \n " ;
3200 if ( $cgiparams { 'n2nname' } ne '' ){
3202 $uplconffilename2 = " $cgiparams {'n2nname'}.conf" ;
3203 $uplp12name2 = " $cgiparams {'n2nname'}.p12" ;
3204 $n2nname [ 0 ] = $cgiparams { 'n2nname' };
3205 my @n2nname2 = split ( /\./ , $uplconffilename );
3206 $n2nname2 [ 0 ] =~ s/\n|\r//g ;
3207 my $input1 = "${General::swroot}/ovpn/certs/ $uplp12name " ;
3208 my $output1 = "${General::swroot}/ovpn/certs/ $uplp12name2 " ;
3209 my $input2 = " $n2nname2 [0]n2n" ;
3210 my $output2 = " $n2nname [0]n2n" ;
3211 my $filename = " $tempdir / $uplconffilename " ;
3212 open ( FILE
, "< $filename " ) or die 'Unable to open config file.' ;
3213 my @current = < FILE
>;
3215 foreach ( @current ) { s/$input1/$output1/g ;}
3216 foreach ( @current ) { s/$input2/$output2/g ;}
3217 open ( OUT
, "> $filename " ) || die 'Unable to open config file.' ;
3222 $uplconffilename2 = $uplconffilename ;
3223 $uplp12name2 = $uplp12name ;
3224 @n2nname = split ( /\./ , $uplconffilename );
3225 $n2nname [ 0 ] =~ s/\n|\r//g ;
3227 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
3228 unless (- d
"${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" , 0770 or die "Unable to create dir $!" ;}
3230 move
( " $tempdir / $uplconffilename " , "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $uplconffilename2 " );
3233 $errormessage = "*.conf move failed: $!" ;
3238 move
( " $tempdir / $uplp12name " , "${General::swroot}/ovpn/certs/ $uplp12name2 " );
3239 chmod 0600 , "${General::swroot}/ovpn/certs/ $uplp12name " ;
3242 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
3251 my @n2nmtudisc = split ( / / , ( grep { /^mtu-disc/ } @firen2nconf )[ 0 ]);
3252 my @n2nproto2 = split ( / / , ( grep { /^proto/ } @firen2nconf )[ 0 ]);
3253 my @n2nproto = split ( /-/ , $n2nproto2 [ 1 ]);
3254 my @n2nport = split ( / / , ( grep { /^port/ } @firen2nconf )[ 0 ]);
3255 my @n2ntunmtu = split ( / / , ( grep { /^tun-mtu/ } @firen2nconf )[ 0 ]);
3256 my @n2ncomplzo = grep { /^comp-lzo/ } @firen2nconf ;
3257 if ( $n2ncomplzo [ 0 ] =~ /comp-lzo/ ){ $complzoactive = "on" ;} else { $complzoactive = "off" ;}
3258 my @n2nmssfix = grep { /^mssfix/ } @firen2nconf ;
3259 if ( $n2nmssfix [ 0 ] =~ /mssfix/ ){ $mssfixactive = "on" ;} else { $mssfixactive = "off" ;}
3260 #my @n2nmssfix = split(/ /, (grep { /^mssfix/ } @firen2nconf)[0]);
3261 my @n2nfragment = split ( / / , ( grep { /^fragment/ } @firen2nconf )[ 0 ]);
3262 my @n2nremote = split ( / / , ( grep { /^remote/ } @firen2nconf )[ 0 ]);
3263 my @n2novpnsuball = split ( / / , ( grep { /^ifconfig/ } @firen2nconf )[ 0 ]);
3264 my @n2novpnsub = split ( /\./ , $n2novpnsuball [ 1 ]);
3265 my @n2nremsub = split ( / / , ( grep { /^route/ } @firen2nconf )[ 0 ]);
3266 my @n2nmgmt = split ( / / , ( grep { /^management/ } @firen2nconf )[ 0 ]);
3267 my @n2nlocalsub = split ( / / , ( grep { /^# remsub/ } @firen2nconf )[ 0 ]);
3268 my @n2ncipher = split ( / / , ( grep { /^cipher/ } @firen2nconf )[ 0 ]);
3269 my @n2nauth = split ( / / , ( grep { /^auth/ } @firen2nconf )[ 0 ]);;
3272 # m.a.d delete CR and LF from arrays for this chomp doesnt work
3275 $n2nremote [ 1 ] =~ s/\n|\r//g ;
3276 $n2novpnsub [ 0 ] =~ s/\n|\r//g ;
3277 $n2novpnsub [ 1 ] =~ s/\n|\r//g ;
3278 $n2novpnsub [ 2 ] =~ s/\n|\r//g ;
3279 $n2nproto [ 0 ] =~ s/\n|\r//g ;
3280 $n2nport [ 1 ] =~ s/\n|\r//g ;
3281 $n2ntunmtu [ 1 ] =~ s/\n|\r//g ;
3282 $n2nremsub [ 1 ] =~ s/\n|\r//g ;
3283 $n2nremsub [ 2 ] =~ s/\n|\r//g ;
3284 $n2nlocalsub [ 2 ] =~ s/\n|\r//g ;
3285 $n2nfragment [ 1 ] =~ s/\n|\r//g ;
3286 $n2nmgmt [ 2 ] =~ s/\n|\r//g ;
3287 $n2nmtudisc [ 1 ] =~ s/\n|\r//g ;
3288 $n2ncipher [ 1 ] =~ s/\n|\r//g ;
3289 $n2nauth [ 1 ] =~ s/\n|\r//g ;
3290 chomp ( $complzoactive );
3291 chomp ( $mssfixactive );
3298 # Check if there is no other entry with this name
3301 foreach my $dkey ( keys %confighash ) {
3302 if ( $confighash { $dkey }[ 1 ] eq $n2nname [ 0 ]) {
3303 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3304 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3305 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3306 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3312 # Check if OpenVPN Subnet is valid
3315 foreach my $dkey ( keys %confighash ) {
3316 if ( $confighash { $dkey }[ 27 ] eq " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ) {
3317 $errormessage = 'The OpenVPN Subnet is already in use' ;
3318 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3319 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3320 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3326 # Check if Dest Port is vaild
3329 foreach my $dkey ( keys %confighash ) {
3330 if ( $confighash { $dkey }[ 29 ] eq $n2nport [ 1 ] ) {
3331 $errormessage = 'The OpenVPN Port is already in use' ;
3332 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3333 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3334 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3341 $key = & General
:: findhasharraykey
( \
%confighash );
3343 foreach my $i ( 0 .. 42 ) { $confighash { $key }[ $i ] = "" ;}
3345 $confighash { $key }[ 0 ] = 'off' ;
3346 $confighash { $key }[ 1 ] = $n2nname [ 0 ];
3347 $confighash { $key }[ 2 ] = $n2nname [ 0 ];
3348 $confighash { $key }[ 3 ] = 'net' ;
3349 $confighash { $key }[ 4 ] = 'cert' ;
3350 $confighash { $key }[ 6 ] = 'client' ;
3351 $confighash { $key }[ 8 ] = $n2nlocalsub [ 2 ];
3352 $confighash { $key }[ 10 ] = $n2nremote [ 1 ];
3353 $confighash { $key }[ 11 ] = " $n2nremsub [1]/ $n2nremsub [2]" ;
3354 $confighash { $key }[ 22 ] = $n2nmgmt [ 2 ];
3355 $confighash { $key }[ 23 ] = $mssfixactive ;
3356 $confighash { $key }[ 24 ] = $n2nfragment [ 1 ];
3357 $confighash { $key }[ 25 ] = 'IPFire n2n Client' ;
3358 $confighash { $key }[ 26 ] = 'red' ;
3359 $confighash { $key }[ 27 ] = " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ;
3360 $confighash { $key }[ 28 ] = $n2nproto [ 0 ];
3361 $confighash { $key }[ 29 ] = $n2nport [ 1 ];
3362 $confighash { $key }[ 30 ] = $complzoactive ;
3363 $confighash { $key }[ 31 ] = $n2ntunmtu [ 1 ];
3364 $confighash { $key }[ 38 ] = $n2nmtudisc [ 1 ];
3365 $confighash { $key }[ 39 ] = $n2nauth [ 1 ];
3366 $confighash { $key }[ 40 ] = $n2ncipher [ 1 ];
3367 $confighash { $key }[ 41 ] = 'disabled' ;
3369 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3373 & Header
:: showhttpheaders
();
3374 & Header
:: openpage
( 'Validate imported configuration' , 1 , '' );
3375 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
3376 if ( $errormessage ) {
3377 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
3378 print "<class name='base'> $errormessage " ;
3379 print " </class>" ;
3380 & Header
:: closebox
();
3384 & Header
:: openbox
( '100%' , 'LEFT' , 'import ipfire net2net config' );
3386 if ( $errormessage eq '' ){
3388 <!-- ipfire net2net config gui -->
3389 <table width='100%'>
3390 <tr><td width='25%'> </td><td width='25%'> </td></tr>
3391 <tr><td class='boldbase'> $Lang ::tr{'name'}:</td><td><b> $n2nname [0]</b></td></tr>
3392 <tr><td> </td><td> </td></tr>
3393 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td><td><b> $confighash { $key }[6]</b></td></tr>
3394 <tr><td class='boldbase' nowrap='nowrap'>Remote Host </td><td><b> $confighash { $key }[10]</b></td></tr>
3395 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td><td><b> $confighash { $key }[8]</b></td></tr>
3396 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}:</td><td><b> $confighash { $key }[11]</b></td></tr>
3397 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td><td><b> $confighash { $key }[27]</b></td></tr>
3398 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td><td><b> $confighash { $key }[28]</b></td></tr>
3399 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'destination port'}:</td><td><b> $confighash { $key }[29]</b></td></tr>
3400 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td><td><b> $confighash { $key }[30]</b></td></tr>
3401 <tr><td class='boldbase' nowrap='nowrap'>MSSFIX:</td><td><b> $confighash { $key }[23]</b></td></tr>
3402 <tr><td class='boldbase' nowrap='nowrap'>Fragment:</td><td><b> $confighash { $key }[24]</b></td></tr>
3403 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'}</td><td><b> $confighash { $key }[31]</b></td></tr>
3404 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td><td><b> $confighash { $key }[38]</b></td></tr>
3405 <tr><td class='boldbase' nowrap='nowrap'>Management Port </td><td><b> $confighash { $key }[22]</b></td></tr>
3406 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn hmac'}:</td><td><b> $confighash { $key }[39]</b></td></tr>
3407 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td><td><b> $confighash { $key }[40]</b></td></tr>
3408 <tr><td> </td><td> </td></tr>
3412 & Header
:: closebox
();
3415 if ( $errormessage ) {
3416 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3418 print "<div align='center'><form method='post' ENCTYPE='multipart/form-data'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />" ;
3419 print "<input type='hidden' name='TYPE' value='net2netakn' />" ;
3420 print "<input type='hidden' name='KEY' value=' $key ' />" ;
3421 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
3423 & Header
:: closebigbox
();
3424 & Header
:: closepage
();
3429 ### Accept IPFire n2n Package Settings
3432 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3435 ### Discard and Rollback IPFire n2n Package Settings
3438 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'cancel' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3440 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3442 if ( $confighash { $cgiparams { 'KEY' }}) {
3444 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
3445 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
3446 unlink ( $certfile ) or die "Removing $certfile fail: $!" ;
3447 unlink ( $conffile ) or die "Removing $conffile fail: $!" ;
3448 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
3449 delete $confighash { $cgiparams { 'KEY' }};
3450 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3453 $errormessage = $Lang :: tr
{ 'invalid key' };
3463 ### Adding a new connection
3465 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
3466 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
3467 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
3469 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3470 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
3471 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3473 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
3474 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
3475 $errormessage = $Lang :: tr
{ 'invalid key' };
3478 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
3479 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
3480 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
3481 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
3482 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
3483 $cgiparams { 'SIDE' } = $confighash { $cgiparams { 'KEY' }}[ 6 ];
3484 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
3485 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
3486 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
3487 $cgiparams { 'OVPN_MGMT' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
3488 $cgiparams { 'MSSFIX' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
3489 $cgiparams { 'FRAGMENT' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
3490 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
3491 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
3492 $cgiparams { 'OVPN_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
3493 $cgiparams { 'PROTOCOL' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
3494 $cgiparams { 'DEST_PORT' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
3495 $cgiparams { 'COMPLZO' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
3496 $cgiparams { 'MTU' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
3497 $cgiparams { 'CHECK1' } = $confighash { $cgiparams { 'KEY' }}[ 32 ];
3498 $name = $cgiparams { 'CHECK1' } ;
3499 $cgiparams { $name } = $confighash { $cgiparams { 'KEY' }}[ 33 ];
3500 $cgiparams { 'RG' } = $confighash { $cgiparams { 'KEY' }}[ 34 ];
3501 $cgiparams { 'CCD_DNS1' } = $confighash { $cgiparams { 'KEY' }}[ 35 ];
3502 $cgiparams { 'CCD_DNS2' } = $confighash { $cgiparams { 'KEY' }}[ 36 ];
3503 $cgiparams { 'CCD_WINS' } = $confighash { $cgiparams { 'KEY' }}[ 37 ];
3504 $cgiparams { 'PMTU_DISCOVERY' } = $confighash { $cgiparams { 'KEY' }}[ 38 ];
3505 $cgiparams { 'DAUTH' } = $confighash { $cgiparams { 'KEY' }}[ 39 ];
3506 $cgiparams { 'DCIPHER' } = $confighash { $cgiparams { 'KEY' }}[ 40 ];
3507 $cgiparams { 'TLSAUTH' } = $confighash { $cgiparams { 'KEY' }}[ 41 ];
3508 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
3509 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
3511 #A.Marx CCD check iroute field and convert it to decimal
3512 if ( $cgiparams { 'TYPE' } eq 'host' ) {
3514 my %ccdroutehash =();
3518 if ( $cgiparams { 'IR' } ne '' ){
3519 @temp = split ( " \n " , $cgiparams { 'IR' });
3520 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3522 foreach my $key ( keys %ccdroutehash ) {
3523 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3525 delete $ccdroutehash { $key };
3527 $keypoint = & General
:: findhasharraykey
( \
%ccdroutehash );
3530 $ccdroutehash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3533 foreach $val ( @temp ){
3536 #check if iroute exists in ccdroute or if new iroute is part of an existing one
3537 foreach my $key ( keys %ccdroutehash ) {
3538 foreach my $oldiroute ( 1 .. $ #{$ccdroutehash{$key}}){
3539 if ( $ccdroutehash { $key }[ $oldiroute ] eq " $val " ) {
3540 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3543 my ( $ip1 , $cidr1 ) = split ( /\/ /, $val );
3544 $ip1 = & General
:: getnetworkip
( $ip1 ,& General
:: iporsubtocidr
( $cidr1 ));
3545 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $oldiroute ]);
3546 if (& General
:: IpInSubnet
( $ip1 , $ip2 , $cidr2 )){
3547 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3553 if (!& General
:: validipandmask
( $val )){
3554 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3557 ( $ip , $cidr ) = split ( /\/ /, $val );
3558 $ip =& General
:: getnetworkip
( $ip ,& General
:: iporsubtocidr
( $cidr ));
3559 $cidr =& General
:: iporsubtodec
( $cidr );
3560 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3564 #check for existing network IP's
3565 if (& General
:: IpInSubnet
( $ip , $netsettings { GREEN_NETADDRESS
}, $netsettings { GREEN_NETMASK
}) && $netsettings { GREEN_NETADDRESS
} ne '0.0.0.0' )
3567 $errormessage = $Lang :: tr
{ 'ccd err green' };
3569 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { RED_NETADDRESS
}, $netsettings { RED_NETMASK
}) && $netsettings { RED_NETADDRESS
} ne '0.0.0.0' )
3571 $errormessage = $Lang :: tr
{ 'ccd err red' };
3573 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { BLUE_NETADDRESS
}, $netsettings { BLUE_NETMASK
}) && $netsettings { BLUE_NETADDRESS
} ne '0.0.0.0' && $netsettings { BLUE_NETADDRESS
} gt '' )
3575 $errormessage = $Lang :: tr
{ 'ccd err blue' };
3577 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { ORANGE_NETADDRESS
}, $netsettings { ORANGE_NETMASK
}) && $netsettings { ORANGE_NETADDRESS
} ne '0.0.0.0' && $netsettings { ORANGE_NETADDRESS
} gt '' )
3579 $errormessage = $Lang :: tr
{ 'ccd err orange' };
3583 if (& General
:: validipandmask
( $val )){
3584 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3586 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $ip / $cidr )" ;
3591 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3594 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3595 foreach my $key ( keys %ccdroutehash ) {
3596 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3597 delete $ccdroutehash { $key };
3598 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3604 #check route field and convert it to decimal
3607 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3609 foreach my $key ( keys %ccdroute2hash ) {
3610 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3612 delete $ccdroute2hash { $key };
3614 $keypoint = & General
:: findhasharraykey
( \
%ccdroute2hash );
3615 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3619 $ccdroute2hash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3620 if ( $cgiparams { 'IFROUTE' } eq '' ){ $cgiparams { 'IFROUTE' } = $Lang :: tr
{ 'ccd none' };}
3621 @temp = split ( /\|/ , $cgiparams { 'IFROUTE' });
3623 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%ownnet );
3624 foreach $val ( @temp ){
3627 if ( $val eq $Lang :: tr
{ 'green' })
3629 $val = $ownnet { GREEN_NETADDRESS
}. "/" . $ownnet { GREEN_NETMASK
};
3631 if ( $val eq $Lang :: tr
{ 'blue' })
3633 $val = $ownnet { BLUE_NETADDRESS
}. "/" . $ownnet { BLUE_NETMASK
};
3635 if ( $val eq $Lang :: tr
{ 'orange' })
3637 $val = $ownnet { ORANGE_NETADDRESS
}. "/" . $ownnet { ORANGE_NETMASK
};
3639 my ( $ip , $cidr ) = split ( /\/ /, $val );
3641 if ( $val ne $Lang :: tr
{ 'ccd none' })
3643 if (! & check_routes_push
( $val )){ $errormessage = $errormessage . "Route $val " . $Lang :: tr
{ 'ccd err routeovpn2' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3644 if (! & check_ccdroute
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err inuse' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3645 if (! & check_ccdconf
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err routeovpn' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3646 if (& General
:: validipandmask
( $val )){
3647 $val = $ip . "/" .& General
:: iporsubtodec
( $cidr );
3648 $ccdroute2hash { $keypoint }[ $i ] = $val ;
3650 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3654 $ccdroute2hash { $keypoint }[ $i ]= '' ;
3658 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3661 if ( $cgiparams { 'CCD_DNS1' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS1' })) {
3662 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 1" ;
3666 if ( $cgiparams { 'CCD_DNS2' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS2' })) {
3667 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 2" ;
3671 if ( $cgiparams { 'CCD_WINS' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_WINS' })) {
3672 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp wins' };
3680 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
3681 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
3682 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3683 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3684 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3690 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
3691 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
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 ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
3700 $errormessage = $Lang :: tr
{ 'name is invalid' };
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: $!" ;
3708 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
3709 $errormessage = $Lang :: tr
{ 'name too long' };
3710 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3711 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3712 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3721 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3722 if ( $cgiparams { 'DEST_PORT' } eq $vpnsettings { 'DDEST_PORT' }) {
3723 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3724 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3725 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3729 foreach my $key ( sort keys %confighash ){
3730 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 ])){
3731 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3732 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3733 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3737 if ( $cgiparams { 'DEST_PORT' } eq '' ) {
3738 $errormessage = $Lang :: tr
{ 'invalid port' };
3739 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3740 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3744 # Check if the input for the transfer net is valid.
3745 if (!& General
:: validipandmask
( $cgiparams { 'OVPN_SUBNET' })){
3746 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
3747 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3748 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3752 if ( $cgiparams { 'OVPN_SUBNET' } eq $vpnsettings { 'DOVPN_SUBNET' }) {
3753 $errormessage = $Lang :: tr
{ 'openvpn subnet is used' };
3754 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3755 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3759 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3760 $errormessage = $Lang :: tr
{ 'openvpn mssfix allowed with udp' };
3761 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3762 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3766 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'FRAGMENT' } ne '' )) {
3767 $errormessage = $Lang :: tr
{ 'openvpn fragment allowed with udp' };
3768 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3769 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3773 if ( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) {
3774 if (( $cgiparams { 'FRAGMENT' } ne '' ) || ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3775 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
3776 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3777 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3782 if (( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) && ( $cgiparams { 'MTU' } ne '1500' )) {
3783 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc and mtu not 1500' };
3784 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3785 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3789 if ( & validdotmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3790 $errormessage = $Lang :: tr
{ 'openvpn prefix local subnet' };
3791 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3792 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3796 if ( & validdotmask
( $cgiparams { 'OVPN_SUBNET' })) {
3797 $errormessage = $Lang :: tr
{ 'openvpn prefix openvpn subnet' };
3798 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3799 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3803 if ( & validdotmask
( $cgiparams { 'REMOTE_SUBNET' })) {
3804 $errormessage = $Lang :: tr
{ 'openvpn prefix remote subnet' };
3805 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3806 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3810 if ( $cgiparams { 'DEST_PORT' } <= 1023 ) {
3811 $errormessage = $Lang :: tr
{ 'ovpn port in root range' };
3812 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3813 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3817 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
3818 $cgiparams { 'OVPN_MGMT' } = $cgiparams { 'DEST_PORT' };
3821 if ( $cgiparams { 'OVPN_MGMT' } <= 1023 ) {
3822 $errormessage = $Lang :: tr
{ 'ovpn mgmt in root range' };
3823 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3824 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3827 #Check if remote subnet is used elsewhere
3828 my ( $n2nip , $n2nsub )= split ( "/" , $cgiparams { 'REMOTE_SUBNET' });
3829 $warnmessage =& General
:: checksubnets
( '' , $n2nip , 'ovpn' );
3831 $warnmessage = $Lang :: tr
{ 'remote subnet' }. " ( $cgiparams {'REMOTE_SUBNET'}) <br>" . $warnmessage ;
3835 # if (($cgiparams{'TYPE'} eq 'net') && ($cgiparams{'SIDE'} !~ /^(left|right)$/)) {
3836 # $errormessage = $Lang::tr{'ipfire side is invalid'};
3837 # goto VPNCONF_ERROR;
3840 # Check if there is no other entry with this name
3841 if (! $cgiparams { 'KEY' }) {
3842 foreach my $key ( keys %confighash ) {
3843 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
3844 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3845 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3846 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3847 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3854 # Check if a remote host/IP has been set for the client.
3855 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3856 if ( $cgiparams { 'SIDE' } ne 'server' && $cgiparams { 'REMOTE' } eq '' ) {
3857 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3859 # Check if this is a N2N connection and drop temporary config.
3860 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3861 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3866 # Check if a remote host/IP has been configured - the field can be empty on the server side.
3867 if ( $cgiparams { 'REMOTE' } ne '' ) {
3868 # Check if the given IP is valid - otherwise check if it is a valid domain.
3869 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
3870 # Check for a valid domain.
3871 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
3872 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3874 # Check if this is a N2N connection and drop temporary config.
3875 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3876 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3884 if ( $cgiparams { 'TYPE' } ne 'host' ) {
3885 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3886 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
3887 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3888 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3889 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3891 goto VPNCONF_ERROR
;}
3893 # Check if there is no other entry without IP-address and PSK
3894 if ( $cgiparams { 'REMOTE' } eq '' ) {
3895 foreach my $key ( keys %confighash ) {
3896 if (( $cgiparams { 'KEY' } ne $key ) &&
3897 ( $confighash { $key }[ 4 ] eq 'psk' || $cgiparams { 'AUTH' } eq 'psk' ) &&
3898 $confighash { $key }[ 10 ] eq '' ) {
3899 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
3904 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
3905 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
3906 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3907 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3911 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
3912 $errormessage = $Lang :: tr
{ 'invalid input' };
3915 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
3916 $errormessage = $Lang :: tr
{ 'invalid input' };
3921 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
3922 # if (! length($cgiparams{'PSK'}) ) {
3923 # $errormessage = $Lang::tr{'pre-shared key is too short'};
3924 # goto VPNCONF_ERROR;
3926 # if ($cgiparams{'PSK'} =~ /['",&]/) {
3927 # $errormessage = $Lang::tr{'invalid characters found in pre-shared key'};
3928 # goto VPNCONF_ERROR;
3930 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
3931 if ( $cgiparams { 'KEY' }) {
3932 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3935 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3936 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3940 # Move uploaded certificate request to a temporary file
3941 ( my $fh , my $filename ) = tempfile
( );
3942 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3947 # Sign the certificate request and move it
3948 # Sign the host certificate request
3949 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
3950 '-batch' , '-notext' ,
3952 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
3953 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
3955 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3957 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3958 & newcleanssldatabase
();
3962 & deletebackupcert
();
3965 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
3966 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
3968 $temp =~ s
+/ Email
+, E
+;
3969 $temp =~ s/ ST=/ S=/ ;
3970 $cgiparams { 'CERT_NAME' } = $temp ;
3971 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
3972 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
3973 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
3974 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
3977 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
3978 if ( $cgiparams { 'KEY' }) {
3979 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3982 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3983 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3986 # Move uploaded certificate to a temporary file
3987 ( my $fh , my $filename ) = tempfile
( );
3988 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3993 # Verify the certificate has a valid CA and move it
3995 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/cacert.pem $filename ` ;
3996 if ( $test =~ /: OK/ ) {
3999 foreach my $key ( keys %cahash ) {
4000 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $key }[0]cert.pem $filename ` ;
4001 if ( $test =~ /: OK/ ) {
4007 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
4011 move
( $filename , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4013 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
4019 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
4020 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
4022 $temp =~ s
+/ Email
+, E
+;
4023 $temp =~ s/ ST=/ S=/ ;
4024 $cgiparams { 'CERT_NAME' } = $temp ;
4025 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
4026 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
4027 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
4028 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4029 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
4032 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
4033 if ( $cgiparams { 'KEY' }) {
4034 $errormessage = $Lang :: tr
{ 'cant change certificates' };
4037 # Validate input since the form was submitted
4038 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
4039 $errormessage = $Lang :: tr
{ 'name too long' };
4042 if ( $cgiparams { 'CERT_NAME' } eq '' || $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
4043 $errormessage = $Lang :: tr
{ 'invalid input for name' };
4046 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
4047 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
4050 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
4051 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
4054 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4055 $errormessage = $Lang :: tr
{ 'invalid input for department' };
4058 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
4059 $errormessage = $Lang :: tr
{ 'organization too long' };
4062 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
4063 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
4066 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4067 $errormessage = $Lang :: tr
{ 'invalid input for city' };
4070 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4071 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
4074 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
4075 $errormessage = $Lang :: tr
{ 'invalid input for country' };
4078 if ( $cgiparams { 'CERT_PASS1' } ne '' && $cgiparams { 'CERT_PASS2' } ne '' ){
4079 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
4080 $errormessage = $Lang :: tr
{ 'password too short' };
4084 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
4085 $errormessage = $Lang :: tr
{ 'passwords do not match' };
4088 if ( $cgiparams { 'DAYS_VALID' } ne '' && $cgiparams { 'DAYS_VALID' } !~ /^[0-9]+$/ ) {
4089 $errormessage = $Lang :: tr
{ 'invalid input for valid till days' };
4093 # Replace empty strings with a .
4094 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
4095 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
4096 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
4098 # Create the Host certificate request client
4099 my $pid = open ( OPENSSL
, "|-" );
4100 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto VPNCONF_ERROR
;};
4101 if ( $pid ) { # parent
4102 print OPENSSL
" $cgiparams {'CERT_COUNTRY'} \n " ;
4103 print OPENSSL
" $state \n " ;
4104 print OPENSSL
" $city \n " ;
4105 print OPENSSL
" $cgiparams {'CERT_ORGANIZATION'} \n " ;
4106 print OPENSSL
" $ou \n " ;
4107 print OPENSSL
" $cgiparams {'CERT_NAME'} \n " ;
4108 print OPENSSL
" $cgiparams {'CERT_EMAIL'} \n " ;
4109 print OPENSSL
". \n " ;
4110 print OPENSSL
". \n " ;
4113 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4114 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4115 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4119 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' ,
4120 '-newkey' , 'rsa:2048' ,
4121 '-keyout' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
4122 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
4123 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
4124 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
4125 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4126 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4131 # Sign the host certificate request
4132 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
4133 '-batch' , '-notext' ,
4134 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
4135 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
4136 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
4138 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4139 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4140 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4141 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4142 & newcleanssldatabase
();
4145 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4146 & deletebackupcert
();
4149 # Create the pkcs12 file
4150 system ( '/usr/bin/openssl' , 'pkcs12' , '-export' ,
4151 '-inkey' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
4152 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
4153 '-name' , $cgiparams { 'NAME' },
4154 '-passout' , "pass: $cgiparams {'CERT_PASS1'}" ,
4155 '-certfile' , "${General::swroot}/ovpn/ca/cacert.pem" ,
4156 '-caname' , " $vpnsettings {'ROOTCERT_ORGANIZATION'} CA" ,
4157 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
4159 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4160 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4161 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4162 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
4165 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4167 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
4168 ; # Nothing, just editing
4170 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
4174 # Check if there is no other entry with this common name
4175 if ((! $cgiparams { 'KEY' }) && ( $cgiparams { 'AUTH' } ne 'psk' )) {
4176 foreach my $key ( keys %confighash ) {
4177 if ( $confighash { $key }[ 2 ] eq $cgiparams { 'CERT_NAME' }) {
4178 $errormessage = $Lang :: tr
{ 'a connection with this common name already exists' };
4185 my $key = $cgiparams { 'KEY' };
4188 $key = & General
:: findhasharraykey
( \
%confighash );
4189 foreach my $i ( 0 .. 43 ) { $confighash { $key }[ $i ] = "" ;}
4191 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
4192 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
4193 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
4194 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
4197 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
4198 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
4199 $confighash { $key }[ 4 ] = 'psk' ;
4200 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
4202 $confighash { $key }[ 4 ] = 'cert' ;
4204 if ( $cgiparams { 'TYPE' } eq 'net' ) {
4205 $confighash { $key }[ 6 ] = $cgiparams { 'SIDE' };
4206 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
4208 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
4209 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
4210 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
4211 $confighash { $key }[ 22 ] = $confighash { $key }[ 29 ];
4213 $confighash { $key }[ 22 ] = $cgiparams { 'OVPN_MGMT' };
4215 $confighash { $key }[ 23 ] = $cgiparams { 'MSSFIX' };
4216 $confighash { $key }[ 24 ] = $cgiparams { 'FRAGMENT' };
4217 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
4218 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
4220 $confighash { $key }[ 27 ] = $cgiparams { 'OVPN_SUBNET' };
4221 $confighash { $key }[ 28 ] = $cgiparams { 'PROTOCOL' };
4222 $confighash { $key }[ 29 ] = $cgiparams { 'DEST_PORT' };
4223 $confighash { $key }[ 30 ] = $cgiparams { 'COMPLZO' };
4224 $confighash { $key }[ 31 ] = $cgiparams { 'MTU' };
4225 $confighash { $key }[ 32 ] = $cgiparams { 'CHECK1' };
4226 $name = $cgiparams { 'CHECK1' };
4227 $confighash { $key }[ 33 ] = $cgiparams { $name };
4228 $confighash { $key }[ 34 ] = $cgiparams { 'RG' };
4229 $confighash { $key }[ 35 ] = $cgiparams { 'CCD_DNS1' };
4230 $confighash { $key }[ 36 ] = $cgiparams { 'CCD_DNS2' };
4231 $confighash { $key }[ 37 ] = $cgiparams { 'CCD_WINS' };
4232 $confighash { $key }[ 38 ] = $cgiparams { 'PMTU_DISCOVERY' };
4233 $confighash { $key }[ 39 ] = $cgiparams { 'DAUTH' };
4234 $confighash { $key }[ 40 ] = $cgiparams { 'DCIPHER' };
4236 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4238 if ( $cgiparams { 'CHECK1' } ){
4240 my ( $ccdip , $ccdsub )= split "/" , $cgiparams { $name };
4241 my ( $a , $b , $c , $d ) = split ( /\./ , $ccdip );
4242 if ( - e
"${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ){
4243 unlink "${General::swroot}/ovpn/ccd/ $cgiparams {'CERT_NAME'}" ;
4245 open ( CCDRWCONF
, '>' , "${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ) or die "Unable to create clientconfigfile $!" ;
4246 print CCDRWCONF
"# OpenVPN clientconfig from ccd extension by Copymaster# \n\n " ;
4247 if ( $cgiparams { 'CHECK1' } eq 'dynamic' ){
4248 print CCDRWCONF
"#This client uses the dynamic pool \n " ;
4250 print CCDRWCONF
"#Ip address client and server \n " ;
4251 print CCDRWCONF
"ifconfig-push $ccdip " .& General
:: getlastip
( $ccdip , 1 ). " \n " ;
4253 if ( $confighash { $key }[ 34 ] eq 'on' ){
4254 print CCDRWCONF
" \n #Redirect Gateway: \n #All IP traffic is redirected through the vpn \n " ;
4255 print CCDRWCONF
"push redirect-gateway \n " ;
4257 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4258 if ( $cgiparams { 'IR' } ne '' ){
4259 print CCDRWCONF
" \n #Client routes these networks (behind Client) \n " ;
4260 foreach my $key ( keys %ccdroutehash ){
4261 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4262 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
4263 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
4264 print CCDRWCONF
"iroute $a $b \n " ;
4269 if ( $cgiparams { 'IFROUTE' } eq $Lang :: tr
{ 'ccd none' } ){ $cgiparams { 'IFROUTE' }= '' ;}
4270 if ( $cgiparams { 'IFROUTE' } ne '' ){
4271 print CCDRWCONF
" \n #Client gets routes to these networks (behind IPFire) \n " ;
4272 foreach my $key ( keys %ccdroute2hash ){
4273 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4274 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}){
4275 if ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'blue' }){
4277 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%blue );
4278 print CCDRWCONF
"push \" route $blue {BLUE_ADDRESS} $blue {BLUE_NETMASK} \n " ;
4279 } elsif ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'orange' }){
4281 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%orange );
4282 print CCDRWCONF
"push \" route $orange {ORANGE_ADDRESS} $orange {ORANGE_NETMASK} \n " ;
4284 my ( $a , $b )= split ( /\/ /, $ccdroute2hash { $key }[ $i ]);
4285 print CCDRWCONF
"push \" route $a $b \"\n " ;
4291 if (( $cgiparams { 'CCD_DNS1' } eq '' ) && ( $cgiparams { 'CCD_DNS1' } ne '' )){ $cgiparams { 'CCD_DNS1' } = $cgiparams { 'CCD_DNS2' }; $cgiparams { 'CCD_DNS2' }= '' ;}
4292 if ( $cgiparams { 'CCD_DNS1' } ne '' ){
4293 print CCDRWCONF
" \n #Client gets these nameservers \n " ;
4294 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS1'} \" \n " ;
4296 if ( $cgiparams { 'CCD_DNS2' } ne '' ){
4297 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS2'} \" \n " ;
4299 if ( $cgiparams { 'CCD_WINS' } ne '' ){
4300 print CCDRWCONF
" \n #Client gets this WINS server \n " ;
4301 print CCDRWCONF
"push \" dhcp-option WINS $cgiparams {'CCD_WINS'} \" \n " ;
4310 if ( $cgiparams { 'TYPE' } eq 'net' ) {
4312 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
4313 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4315 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4316 my $key = $cgiparams { 'KEY' };
4318 $key = & General
:: findhasharraykey
( \
%confighash );
4319 foreach my $i ( 0 .. 31 ) { $confighash { $key }[ $i ] = "" ;}
4321 $confighash { $key }[ 0 ] = 'on' ;
4322 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4324 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4332 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
4333 $cgiparams { 'KEY' } = $key ;
4334 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
4338 $cgiparams { 'ENABLED' } = 'on' ;
4342 $cgiparams { 'MSSFIX' } = 'on' ;
4343 $cgiparams { 'FRAGMENT' } = '1300' ;
4344 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4345 $cgiparams { 'DAUTH' } = 'SHA1' ;
4349 $cgiparams { 'SIDE' } = 'left' ;
4350 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) {
4351 $cgiparams { 'AUTH' } = 'psk' ;
4352 } elsif ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4353 $cgiparams { 'AUTH' } = 'certfile' ;
4355 $cgiparams { 'AUTH' } = 'certgen' ;
4357 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
4358 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
4359 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
4360 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
4361 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
4362 $cgiparams { 'DAYS_VALID' } = $vpnsettings { 'DAYS_VALID' };
4366 $checked { 'ENABLED' }{ 'off' } = '' ;
4367 $checked { 'ENABLED' }{ 'on' } = '' ;
4368 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4369 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4370 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4371 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4372 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4373 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4374 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4377 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
4378 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
4379 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = 'CHECKED' ;
4381 $selected { 'SIDE' }{ 'server' } = '' ;
4382 $selected { 'SIDE' }{ 'client' } = '' ;
4383 $selected { 'SIDE' }{ $cgiparams { 'SIDE' }} = 'SELECTED' ;
4385 $selected { 'PROTOCOL' }{ 'udp' } = '' ;
4386 $selected { 'PROTOCOL' }{ 'tcp' } = '' ;
4387 $selected { 'PROTOCOL' }{ $cgiparams { 'PROTOCOL' }} = 'SELECTED' ;
4390 $checked { 'AUTH' }{ 'psk' } = '' ;
4391 $checked { 'AUTH' }{ 'certreq' } = '' ;
4392 $checked { 'AUTH' }{ 'certgen' } = '' ;
4393 $checked { 'AUTH' }{ 'certfile' } = '' ;
4394 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = 'CHECKED' ;
4396 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = 'SELECTED' ;
4398 $checked { 'COMPLZO' }{ 'off' } = '' ;
4399 $checked { 'COMPLZO' }{ 'on' } = '' ;
4400 $checked { 'COMPLZO' }{ $cgiparams { 'COMPLZO' }} = 'CHECKED' ;
4402 $checked { 'MSSFIX' }{ 'off' } = '' ;
4403 $checked { 'MSSFIX' }{ 'on' } = '' ;
4404 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4406 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
4407 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4409 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
4411 $selected { 'DCIPHER' }{ 'CAMELLIA-256-CBC' } = '' ;
4412 $selected { 'DCIPHER' }{ 'CAMELLIA-192-CBC' } = '' ;
4413 $selected { 'DCIPHER' }{ 'CAMELLIA-128-CBC' } = '' ;
4414 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4415 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4416 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4417 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4418 $selected { 'DCIPHER' }{ 'SEED-CBC' } = '' ;
4419 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4420 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4421 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4422 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4423 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4424 # If no cipher has been chossen yet, select
4425 # the old default (AES-256-CBC) for compatiblity reasons.
4426 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4427 $cgiparams { 'DCIPHER' } = 'AES-256-CBC' ;
4429 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4430 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
4431 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
4432 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
4433 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
4434 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
4435 # If no hash algorythm has been choosen yet, select
4436 # the old default value (SHA1) for compatiblity reasons.
4437 if ( $cgiparams { 'DAUTH' } eq '' ) {
4438 $cgiparams { 'DAUTH' } = 'SHA1' ;
4440 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
4443 & Header
:: showhttpheaders
();
4444 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
4445 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4446 if ( $errormessage ) {
4447 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4448 print "<class name='base'> $errormessage " ;
4449 print " </class>" ;
4450 & Header
:: closebox
();
4454 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'warning messages'}:" );
4455 print "<class name='base'> $warnmessage " ;
4456 print " </class>" ;
4457 & Header
:: closebox
();
4460 print "<form method='post' enctype='multipart/form-data'>" ;
4461 print "<input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />" ;
4463 if ( $cgiparams { 'KEY' }) {
4464 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
4465 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
4468 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'connection'}:" );
4469 print "<table width='100%' border='0'> \n " ;
4471 print "<tr><td width='14%' class='boldbase'> $Lang ::tr{'name'}: </td>" ;
4473 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4474 if ( $cgiparams { 'KEY' }) {
4475 print "<td width='35%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4477 print "<td width='35%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' size='30' /></td>" ;
4479 # print "<tr><td>$Lang::tr{'interface'}</td>";
4480 # print "<td><select name='INTERFACE'>";
4481 # print "<option value='RED' $selected{'INTERFACE'}{'RED'}>RED</option>";
4482 # if ($netsettings{'BLUE_DEV'} ne '') {
4483 # print "<option value='BLUE' $selected{'INTERFACE'}{'BLUE'}>BLUE</option>";
4485 # print "<option value='GREEN' $selected{'INTERFACE'}{'GREEN'}>GREEN</option>";
4486 # print "<option value='ORANGE' $selected{'INTERFACE'}{'ORANGE'}>ORANGE</option>";
4487 # print "</select></td></tr>";
4490 print "<input type='hidden' name='INTERFACE' value='red' />" ;
4491 if ( $cgiparams { 'KEY' }) {
4492 print "<td width='25%' class='base' nowrap='nowrap'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4494 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' /></td>" ;
4497 <td width='25%'> </td>
4498 <td width='25%'> </td></tr>
4499 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td>
4500 <td><select name='SIDE'>
4501 <option value='server' $selected {'SIDE'}{'server'}> $Lang ::tr{'openvpn server'}</option>
4502 <option value='client' $selected {'SIDE'}{'client'}> $Lang ::tr{'openvpn client'}</option>
4506 <td class='boldbase'> $Lang ::tr{'remote host/ip'}:</td>
4507 <td><input type='TEXT' name='REMOTE' value=' $cgiparams {'REMOTE'}' /></td>
4510 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
4511 <td><input type='TEXT' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' /></td>
4513 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
4514 <td><input type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' /></td>
4517 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td>
4518 <td><input type='TEXT' name='OVPN_SUBNET' value=' $cgiparams {'OVPN_SUBNET'}' /></td>
4520 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
4521 <td><select name='PROTOCOL'>
4522 <option value='udp' $selected {'PROTOCOL'}{'udp'}>UDP</option>
4523 <option value='tcp' $selected {'PROTOCOL'}{'tcp'}>TCP</option></select></td>
4527 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
4528 <td><input type='TEXT' name='DEST_PORT' value=' $cgiparams {'DEST_PORT'}' size='5' /></td>
4530 <td class='boldbase' nowrap='nowrap'>Management Port ( $Lang ::tr{'openvpn default'}: <span class="base"> $Lang ::tr{'destination port'}): <img src='/blob.gif' /></td>
4531 <td> <input type='TEXT' name='OVPN_MGMT' VALUE=' $cgiparams {'OVPN_MGMT'}'size='5' /></td>
4534 <tr><td colspan=4><hr /></td></tr><tr>
4537 <td class'base'><b> $Lang ::tr{'MTU settings'}</b></td>
4540 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} <img src='/blob.gif' /></td>
4541 <td><input type='TEXT' name='MTU' VALUE=' $cgiparams {'MTU'}'size='5' /></td>
4542 <td colspan='2'> $Lang ::tr{'openvpn default'}: udp/tcp <span class="base">1500/1400</span></td>
4545 <tr><td class='boldbase' nowrap='nowrap'>fragment <img src='/blob.gif' /></td>
4546 <td><input type='TEXT' name='FRAGMENT' VALUE=' $cgiparams {'FRAGMENT'}'size='5' /></td>
4547 <td> $Lang ::tr{'openvpn default'}: <span class="base">1300</span></td>
4550 <tr><td class='boldbase' nowrap='nowrap'>mssfix <img src='/blob.gif' /></td>
4551 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
4552 <td> $Lang ::tr{'openvpn default'}: <span class="base">on</span></td>
4555 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'} <img src='/blob.gif'</td>
4556 <td><input type='checkbox' name='COMPLZO' $checked {'COMPLZO'}{'on'} /></td>
4559 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td>
4561 <input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}
4562 <input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}
4563 <input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}
4564 <input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}
4568 <tr><td colspan=4><hr /></td></tr><tr>
4570 <td class'base'><b> $Lang ::tr{'ovpn crypt options'}:</b></td>
4573 <tr><td class='boldbase'> $Lang ::tr{'cipher'}</td>
4574 <td><select name='DCIPHER'>
4575 <option value='CAMELLIA-256-CBC' $selected {'DCIPHER'}{'CAMELLIA-256-CBC'}>CAMELLIA-CBC (256 $Lang ::tr{'bit'})</option>
4576 <option value='CAMELLIA-192-CBC' $selected {'DCIPHER'}{'CAMELLIA-192-CBC'}>CAMELLIA-CBC (192 $Lang ::tr{'bit'})</option>
4577 <option value='CAMELLIA-128-CBC' $selected {'DCIPHER'}{'CAMELLIA-128-CBC'}>CAMELLIA-CBC (128 $Lang ::tr{'bit'})</option>
4578 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-CBC (256 $Lang ::tr{'bit'}, $Lang ::tr{'default'})</option>
4579 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-CBC (192 $Lang ::tr{'bit'})</option>
4580 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-CBC (128 $Lang ::tr{'bit'})</option>
4581 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC (192 $Lang ::tr{'bit'})</option>
4582 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC (192 $Lang ::tr{'bit'})</option>
4583 <option value='SEED-CBC' $selected {'DCIPHER'}{'SEED-CBC'}>SEED-CBC (128 $Lang ::tr{'bit'})</option>
4584 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC (128 $Lang ::tr{'bit'})</option>
4585 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC (128 $Lang ::tr{'bit'})</option>
4586 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC (128 $Lang ::tr{'bit'})</option>
4590 <td class='boldbase'> $Lang ::tr{'ovpn ha'}:</td>
4591 <td><select name='DAUTH'>
4592 <option value='whirlpool' $selected {'DAUTH'}{'whirlpool'}>Whirlpool (512 $Lang ::tr{'bit'})</option>
4593 <option value='SHA512' $selected {'DAUTH'}{'SHA512'}>SHA2 (512 $Lang ::tr{'bit'})</option>
4594 <option value='SHA384' $selected {'DAUTH'}{'SHA384'}>SHA2 (384 $Lang ::tr{'bit'})</option>
4595 <option value='SHA256' $selected {'DAUTH'}{'SHA256'}>SHA2 (256 $Lang ::tr{'bit'})</option>
4596 <option value='SHA1' $selected {'DAUTH'}{'SHA1'}>SHA1 (160 $Lang ::tr{'bit'} Default)</option>
4600 <tr><td colspan=4><hr /></td></tr><tr>
4606 print "<tr><td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' /></td>" ;
4607 print "<td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td></tr></table>" ;
4609 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4610 print "<tr><td> $Lang ::tr{'enabled'} <input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>" ;
4613 print "</tr></table><br><br>" ;
4614 #A.Marx CCD new client
4615 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4616 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>" ;
4619 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnnet );
4620 $vpnip = $vpnnet { 'DOVPN_SUBNET' };
4621 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
4625 $checked { 'check1' }{ 'off' } = '' ;
4626 $checked { 'check1' }{ 'on' } = '' ;
4627 $checked { 'check1' }{ $cgiparams { 'CHECK1' }} = 'CHECKED' ;
4628 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%'>" ;
4629 print "</td></tr></table><br><br>" ;
4630 my $name = $cgiparams { 'CHECK1' };
4631 $checked { 'RG' }{ $cgiparams { 'RG' }} = 'CHECKED' ;
4633 if (! - z
"${General::swroot}/ovpn/ccd.conf" ){
4634 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>" ;
4635 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
4637 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
4638 if ( $count % 2 ){ print "<tr bgcolor=' $color {'color22'}'>" ;} else { print "<tr bgcolor=' $color {'color20'}'>" ;}
4639 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%'>" ;
4640 & fillselectbox
( $ccdconf [ 1 ], $ccdconf [ 0 ], $cgiparams { $name });
4643 print "</table><br><br><hr><br><br>" ;
4647 & Header
:: closebox
();
4648 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
4650 } elsif (! $cgiparams { 'KEY' }) {
4654 my $cakeydisabled = '' ;
4655 my $cacrtdisabled = '' ;
4656 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) { $cakeydisabled = "disabled='disabled'" } else { $cakeydisabled = "" };
4657 if ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) { $cacrtdisabled = "disabled='disabled'" } else { $cacrtdisabled = "" };
4659 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'authentication' });
4662 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4665 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4667 <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>
4668 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td><td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
4669 <tr><td colspan='3'> </td></tr>
4670 <tr><td colspan='3'><hr /></td></tr>
4671 <tr><td colspan='3'> </td></tr>
4672 <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>
4673 <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>
4674 <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>
4675 <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>
4676 <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>
4677 <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>
4678 <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>
4679 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4690 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4692 <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>
4693 <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>
4694 <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>
4695 <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>
4696 <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>
4697 <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>
4698 <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>
4699 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4711 foreach my $country ( sort keys %{ Countries
:: countries
}) {
4712 print "<option value=' $Countries ::countries{ $country }'" ;
4713 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
4714 print " selected='selected'" ;
4716 print "> $country </option>" ;
4722 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4725 <td> </td><td class='base'> $Lang ::tr{'valid till'} (days):</td>
4726 <td class='base' nowrap='nowrap'><input type='text' name='DAYS_VALID' value=' $cgiparams {'DAYS_VALID'}' size='32' $cakeydisabled /></td></tr>
4728 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
4729 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
4730 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:<br>( $Lang ::tr{'confirmation'})</td>
4731 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
4732 <tr><td colspan='3'> </td></tr>
4733 <tr><td colspan='3'><hr /></td></tr>
4734 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4740 <td> </td><td class='base'> $Lang ::tr{'valid till'} (days):</td>
4741 <td class='base' nowrap='nowrap'><input type='text' name='DAYS_VALID' value=' $cgiparams {'DAYS_VALID'}' size='32' $cakeydisabled /></td></tr>
4742 <tr><td> </td><td> </td><td> </td></tr>
4743 <tr><td> </td><td> </td><td> </td></tr>
4744 <tr><td colspan='3'><hr /></td></tr>
4745 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4755 & Header
:: closebox
();
4759 #A.Marx CCD new client
4760 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4762 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ccd client options'}:" );
4766 <table border='0' width='100%'>
4767 <tr><td width='20%'>Redirect Gateway:</td><td colspan='3'><input type='checkbox' name='RG' $checked {'RG'}{'on'} /></td></tr>
4768 <tr><td colspan='4'><b><br> $Lang ::tr{'ccd routes'}</b></td></tr>
4769 <tr><td colspan='4'> </td></tr>
4770 <tr><td valign='top'> $Lang ::tr{'ccd iroute'}</td><td align='left' width='30%'><textarea name='IR' cols='26' rows='6' wrap='off'>
4773 if ( $cgiparams { 'IR' } ne '' ){
4774 print $cgiparams { 'IR' };
4776 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4777 foreach my $key ( keys %ccdroutehash ) {
4778 if ( $cgiparams { 'NAME' } eq $ccdroutehash { $key }[ 0 ]){
4779 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
4780 if ( $ccdroutehash { $key }[ $i ] ne '' ){
4781 print $ccdroutehash { $key }[ $i ]. " \n " ;
4783 $cgiparams { 'IR' } .= $ccdroutehash { $key }[ $i ];
4790 </textarea></td><td valign='top' colspan='2'> $Lang ::tr{'ccd iroutehint'}</td></tr>
4791 <tr><td colspan='4'><br></td></tr>
4792 <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>
4806 open ( FILE
, "${General::swroot}/main/routing" ) ;
4809 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
4811 foreach my $key ( keys %ccdroute2hash ) {
4812 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4813 if ( $ccdroute2hash { $key }[ 1 ] eq '' ){
4820 print "<option> $Lang ::tr{'ccd none'}</option>" ;
4822 print "<option selected> $Lang ::tr{'ccd none'}</option>" ;
4824 #check if static routes are defined for client
4825 foreach my $line ( @current ) {
4827 $line =~ s/\s*$//g ; # remove newline
4828 @temp = split ( /\,/ , $line );
4829 $temp [ 1 ] = '' unless defined $temp [ 1 ]; # not always populated
4830 my ( $a , $b ) = split ( /\/ /, $temp [ 1 ]);
4831 $temp [ 1 ] = $a . "/" .& General
:: iporsubtocidr
( $b );
4832 foreach my $key ( keys %ccdroute2hash ) {
4833 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4834 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4835 if ( $ccdroute2hash { $key }[ $i ] eq $a . "/" .& General
:: iporsubtodec
( $b )){
4841 if ( $set == '1' && $#temp != - 1 ){ print "<option selected> $temp [1]</option>" ; $set = 0 ;} elsif ( $set == '0' && $#temp != - 1 ){ print "<option> $temp [1]</option>" ;}
4843 #check if green,blue,orange are defined for client
4844 foreach my $key ( keys %ccdroute2hash ) {
4845 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4847 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4848 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'GREEN_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'GREEN_NETMASK' })){
4851 if (& haveBlueNet
()){
4852 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'BLUE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'BLUE_NETMASK' })) {
4856 if (& haveOrangeNet
()){
4857 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'ORANGE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'ORANGE_NETMASK' }) ) {
4864 if (& haveBlueNet
() && $selblue == '1' ){ print "<option selected> $Lang ::tr{'blue'}</option>" ; $selblue = 0 ;} elsif (& haveBlueNet
() && $selblue == '0' ){ print "<option> $Lang ::tr{'blue'}</option>" ;}
4865 if (& haveOrangeNet
() && $selorange == '1' ){ print "<option selected> $Lang ::tr{'orange'}</option>" ; $selorange = 0 ;} elsif (& haveOrangeNet
() && $selorange == '0' ){ print "<option> $Lang ::tr{'orange'}</option>" ;}
4866 if ( $selgreen == '1' || $other == '0' ){ print "<option selected> $Lang ::tr{'green'}</option>" ; $set = 0 ;} else { print "<option> $Lang ::tr{'green'}</option>" ;};
4869 </select></td><td valign='top'>DNS1:</td><td valign='top'><input type='TEXT' name='CCD_DNS1' value=' $cgiparams {'CCD_DNS1'}' size='30' /></td></tr>
4870 <tr valign='top'><td>DNS2:</td><td><input type='TEXT' name='CCD_DNS2' value=' $cgiparams {'CCD_DNS2'}' size='30' /></td></tr>
4871 <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>
4875 & Header
:: closebox
();
4877 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
4878 if ( $cgiparams { 'KEY' }) {
4879 # print "<input type='submit' name='ACTION' value='$Lang::tr{'advanced'}' />";
4881 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
4882 & Header
:: closebigbox
();
4883 & Header
:: closepage
();
4891 ### Default status page
4896 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
4897 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
4898 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4900 my @status = `/bin/cat /var/log/ovpnserver.log` ;
4902 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
4903 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
4904 my $ipaddr = < IPADDR
>;
4907 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
4908 if ( $cgiparams { 'VPN_IP' } eq '' ) {
4909 $cgiparams { 'VPN_IP' } = $ipaddr ;
4915 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4916 $cgiparams { 'DCIPHER' } = 'AES-256-CBC' ;
4918 if ( $cgiparams { 'DDEST_PORT' } eq '' ) {
4919 $cgiparams { 'DDEST_PORT' } = '1194' ;
4921 if ( $cgiparams { 'DMTU' } eq '' ) {
4922 $cgiparams { 'DMTU' } = '1400' ;
4924 if ( $cgiparams { 'MSSFIX' } eq '' ) {
4925 $cgiparams { 'MSSFIX' } = 'off' ;
4927 if ( $cgiparams { 'DAUTH' } eq '' ) {
4928 $cgiparams { 'DAUTH' } = 'SHA1' ;
4930 if ( $cgiparams { 'DOVPN_SUBNET' } eq '' ) {
4931 $cgiparams { 'DOVPN_SUBNET' } = '10.' . int ( rand ( 256 )) . '.' . int ( rand ( 256 )) . '.0/255.255.255.0' ;
4933 $checked { 'ENABLED' }{ 'off' } = '' ;
4934 $checked { 'ENABLED' }{ 'on' } = '' ;
4935 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4936 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4937 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4938 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4939 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4940 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4941 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4942 $selected { 'DDEVICE' }{ 'tun' } = '' ;
4943 $selected { 'DDEVICE' }{ 'tap' } = '' ;
4944 $selected { 'DDEVICE' }{ $cgiparams { 'DDEVICE' }} = 'SELECTED' ;
4946 $selected { 'DPROTOCOL' }{ 'udp' } = '' ;
4947 $selected { 'DPROTOCOL' }{ 'tcp' } = '' ;
4948 $selected { 'DPROTOCOL' }{ $cgiparams { 'DPROTOCOL' }} = 'SELECTED' ;
4950 $selected { 'DCIPHER' }{ 'CAMELLIA-256-CBC' } = '' ;
4951 $selected { 'DCIPHER' }{ 'CAMELLIA-192-CBC' } = '' ;
4952 $selected { 'DCIPHER' }{ 'CAMELLIA-128-CBC' } = '' ;
4953 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4954 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4955 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4956 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4957 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4958 $selected { 'DCIPHER' }{ 'SEED-CBC' } = '' ;
4959 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4960 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4961 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4962 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4963 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4965 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
4966 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
4967 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
4968 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
4969 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
4970 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
4972 $checked { 'DCOMPLZO' }{ 'off' } = '' ;
4973 $checked { 'DCOMPLZO' }{ 'on' } = '' ;
4974 $checked { 'DCOMPLZO' }{ $cgiparams { 'DCOMPLZO' }} = 'CHECKED' ;
4977 $checked { 'MSSFIX' }{ 'off' } = '' ;
4978 $checked { 'MSSFIX' }{ 'on' } = '' ;
4979 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4981 & Header
:: showhttpheaders
();
4982 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
4983 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4985 if ( $errormessage ) {
4986 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4987 print "<class name='base'> $errormessage \n " ;
4988 print " </class> \n " ;
4989 & Header
:: closebox
();
4993 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'warning messages' });
4994 print " $warnmessage <br>" ;
4995 print " $Lang ::tr{'fwdfw warn1'}<br>" ;
4996 & Header
:: closebox
();
4997 print "<center><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'ok'}' style='width: 5em;'></form>" ;
4998 & Header
:: closepage
();
5002 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>" ;
5003 my $srunning = "no" ;
5004 my $activeonrun = "" ;
5005 if ( - e
"/var/run/openvpn.pid" ){
5006 $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>" ;
5010 $activeonrun = "disabled='disabled'" ;
5012 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'global settings' });
5014 <table width='100%' border='0'>
5015 <form method='post'>
5016 <td width='25%'> </td>
5017 <td width='25%'> </td>
5018 <td width='25%'> </td></tr>
5019 <tr><td class='boldbase'> $Lang ::tr{'ovpn server status'}</td>
5020 <td align='left'> $sactive </td>
5021 <tr><td class='boldbase'> $Lang ::tr{'ovpn on red'}</td>
5022 <td><input type='checkbox' name='ENABLED' $checked {'ENABLED'}{'on'} /></td>
5025 if (& haveBlueNet
()) {
5026 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on blue'}</td>" ;
5027 print "<td><input type='checkbox' name='ENABLED_BLUE' $checked {'ENABLED_BLUE'}{'on'} /></td>" ;
5029 if (& haveOrangeNet
()) {
5030 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on orange'}</td>" ;
5031 print "<td><input type='checkbox' name='ENABLED_ORANGE' $checked {'ENABLED_ORANGE'}{'on'} /></td>" ;
5034 <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>
5035 <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>
5036 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn device'}</td>
5037 <td><select name='DDEVICE' ><option value='tun' $selected {'DDEVICE'}{'tun'}>TUN</option>
5038 <!-- this is still not working
5039 <option value='tap' $selected {'DDEVICE'}{'tap'}>TAP</option></select>--> </td>
5040 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
5041 <td><select name='DPROTOCOL'><option value='udp' $selected {'DPROTOCOL'}{'udp'}>UDP</option>
5042 <option value='tcp' $selected {'DPROTOCOL'}{'tcp'}>TCP</option></select></td>
5043 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
5044 <td><input type='TEXT' name='DDEST_PORT' value=' $cgiparams {'DDEST_PORT'}' size='5' /></td></tr>
5045 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} </td>
5046 <td> <input type='TEXT' name='DMTU' VALUE=' $cgiparams {'DMTU'}' size='5' /></td>
5048 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td>
5049 <td><select name='DCIPHER'>
5050 <option value='CAMELLIA-256-CBC' $selected {'DCIPHER'}{'CAMELLIA-256-CBC'}>CAMELLIA-CBC (256 $Lang ::tr{'bit'})</option>
5051 <option value='CAMELLIA-192-CBC' $selected {'DCIPHER'}{'CAMELLIA-192-CBC'}>CAMELLIA-CBC (192 $Lang ::tr{'bit'})</option>
5052 <option value='CAMELLIA-128-CBC' $selected {'DCIPHER'}{'CAMELLIA-128-CBC'}>CAMELLIA-CBC (128 $Lang ::tr{'bit'})</option>
5053 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-CBC (256 $Lang ::tr{'bit'})</option>
5054 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-CBC (192 $Lang ::tr{'bit'})</option>
5055 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-CBC (128 $Lang ::tr{'bit'})</option>
5056 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC (192 $Lang ::tr{'bit'})</option>
5057 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC (192 $Lang ::tr{'bit'})</option>
5058 <option value='SEED-CBC' $selected {'DCIPHER'}{'SEED-CBC'}>SEED-CBC (128 $Lang ::tr{'bit'})</option>
5059 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC (128 $Lang ::tr{'bit'})</option>
5060 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC (128 $Lang ::tr{'bit'})</option>
5061 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC (128 $Lang ::tr{'bit'})</option>
5064 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td>
5065 <td><input type='checkbox' name='DCOMPLZO' $checked {'DCOMPLZO'}{'on'} /></td>
5067 <tr><td colspan='4'><br><br></td></tr>
5071 if ( $srunning eq "yes" ) {
5072 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' disabled='disabled' />" ;
5073 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
5074 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
5075 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'stop ovpn server'}' /></td></tr>" ;
5077 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
5078 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
5079 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
5080 if (( - e
"${General::swroot}/ovpn/ca/cacert.pem" &&
5081 - e
"${General::swroot}/ovpn/ca/dh1024.pem" &&
5082 - e
"${General::swroot}/ovpn/certs/servercert.pem" &&
5083 - e
"${General::swroot}/ovpn/certs/serverkey.pem" ) &&
5084 (( $cgiparams { 'ENABLED' } eq 'on' ) ||
5085 ( $cgiparams { 'ENABLED_BLUE' } eq 'on' ) ||
5086 ( $cgiparams { 'ENABLED_ORANGE' } eq 'on' ))){
5087 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' /></td></tr>" ;
5089 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' disabled='disabled' /></td></tr>" ;
5092 print "</form></table>" ;
5093 & Header
:: closebox
();
5095 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5098 #<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>
5101 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection status and controlc' });
5107 foreach my $key ( sort { ncmp
( $confighash { $a }[ 32 ], $confighash { $b }[ 32 ]) } sort { ncmp
( $confighash { $a }[ 1 ], $confighash { $b }[ 1 ]) } keys %confighash ) {
5108 if ( $confighash { $key }[ 32 ] eq "" && $confighash { $key }[ 3 ] eq 'net' ){ $confighash { $key }[ 32 ]= $Lang :: tr
{ 'fwhost OpenVPN N-2-N' };}
5109 if ( $confighash { $key }[ 32 ] eq "dynamic" ){ $confighash { $key }[ 32 ]= $Lang :: tr
{ 'ccd dynrange' };}
5111 print "<b> $confighash { $key }[32]</b>" ;
5113 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5115 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5116 <th width='15%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></th>
5117 <th width='20%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></th>
5118 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></th>
5119 <th width='5%' class='boldbase' colspan='6' align='center'><b> $Lang ::tr{'action'}</b></th>
5123 if ( $id > 0 && $lastnet ne $confighash { $key }[ 32 ]){
5124 print "</table><br>" ;
5125 print "<b> $confighash { $key }[32]</b>" ;
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='20%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></th>
5132 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></th>
5133 <th width='5%' class='boldbase' colspan='6' align='center'><b> $Lang ::tr{'action'}</b></th>
5137 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
5140 $col = "bgcolor=' $color {'color20'}'" ;
5143 $col = "bgcolor=' $color {'color22'}'" ;
5145 print "<td align='center' nowrap='nowrap' $col > $confighash { $key }[1]</td>" ;
5146 print "<td align='center' nowrap='nowrap' $col >" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
5147 #if ($confighash{$key}[4] eq 'cert') {
5148 #print "<td align='left' nowrap='nowrap'>$confighash{$key}[2]</td>";
5150 #print "<td align='left'> </td>";
5152 my $cavalid = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
5153 $cavalid =~ /Not After : (.*)[\n]/ ;
5155 print "<td align='center' $col > $confighash { $key }[25]</td>" ;
5156 $col1 = "bgcolor='${Header::colourred}'" ;
5157 my $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
5159 if ( $confighash { $key }[ 0 ] eq 'off' ) {
5160 $col1 = "bgcolor='${Header::colourblue}'" ;
5161 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
5168 if ( $confighash { $key }[ 3 ] eq 'net' ) {
5170 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
5173 my $tport = $confighash { $key }[ 22 ];
5174 my $tnet = new Net
:: Telnet
( Timeout
=> 5 , Errmode
=> 'return' , Port
=> $tport );
5176 $tnet -> open ( '127.0.0.1' );
5177 @output = $tnet -> cmd ( String
=> 'state' , Prompt
=> '/(END.* \n |ERROR:.* \n )/' );
5178 @tustate = split ( /\,/ , $output [ 1 ]);
5180 #CONNECTING -- OpenVPN's initial state.
5181 #WAIT -- (Client only) Waiting for initial response from server.
5182 #AUTH -- (Client only) Authenticating with server.
5183 #GET_CONFIG -- (Client only) Downloading configuration options from server.
5184 #ASSIGN_IP -- Assigning IP address to virtual network interface.
5185 #ADD_ROUTES -- Adding routes to system.
5186 #CONNECTED -- Initialization Sequence Completed.
5187 #RECONNECTING -- A restart has occurred.
5188 #EXITING -- A graceful exit is in progress.
5191 if (( $tustate [ 1 ] eq 'CONNECTED' ) || ( $tustate [ 1 ] eq 'WAIT' )) {
5192 $col1 = "bgcolor='${Header::colourgreen}'" ;
5193 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
5195 $col1 = "bgcolor='${Header::colourred}'" ;
5196 $active = "<b><font color='#FFFFFF'> $tustate [1]</font></b>" ;
5204 foreach my $line ( @status ) {
5206 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
5207 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
5208 if ( $match [ 1 ] ne "Common Name" ) {
5212 if ( $cn eq " $confighash { $key }[2]" ) {
5213 $col1 = "bgcolor='${Header::colourgreen}'" ;
5214 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
5223 <td align='center' $col1 > $active </td>
5225 <form method='post' name='frm${key}a'><td align='center' $col >
5226 <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' />
5227 <input type='hidden' name='ACTION' value=' $Lang ::tr{'dl client arch'}' />
5228 <input type='hidden' name='KEY' value=' $key ' />
5232 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
5234 <form method='post' name='frm${key}b'><td align='center' $col >
5235 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' border='0' />
5236 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
5237 <input type='hidden' name='KEY' value=' $key ' />
5241 print "<td> </td>" ;
5243 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" ) {
5245 <form method='post' name='frm${key}c'><td align='center' $col >
5246 <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' />
5247 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
5248 <input type='hidden' name='KEY' value=' $key ' />
5251 ; } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
5253 <form method='post' name='frm${key}c'><td align='center' $col >
5254 <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' />
5255 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
5256 <input type='hidden' name='KEY' value=' $key ' />
5260 print "<td> </td>" ;
5263 <form method='post' name='frm${key}d'><td align='center' $col >
5264 <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' />
5265 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
5266 <input type='hidden' name='KEY' value=' $key ' />
5269 <form method='post' name='frm${key}e'><td align='center' $col >
5270 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
5271 <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'/>
5272 <input type='hidden' name='KEY' value=' $key ' />
5274 <form method='post' name='frm${key}f'><td align='center' $col >
5275 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
5276 <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' />
5277 <input type='hidden' name='KEY' value=' $key ' />
5283 $lastnet = $confighash { $key }[ 32 ];
5288 # If the config file contains entries, print Key to action icons
5293 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5294 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
5295 <td class='base'> $Lang ::tr{'click to disable'}</td>
5296 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
5297 <td class='base'> $Lang ::tr{'show certificate'}</td>
5298 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
5299 <td class='base'> $Lang ::tr{'edit'}</td>
5300 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
5301 <td class='base'> $Lang ::tr{'remove'}</td>
5305 <td> <img src='/images/off.gif' alt='?OFF' /></td>
5306 <td class='base'> $Lang ::tr{'click to enable'}</td>
5307 <td> <img src='/images/media-floppy.png' alt='?FLOPPY' /></td>
5308 <td class='base'> $Lang ::tr{'download certificate'}</td>
5309 <td> <img src='/images/openvpn.png' alt='?RELOAD'/></td>
5310 <td class='base'> $Lang ::tr{'dl client arch'}</td>
5318 <table width='100%'>
5319 <form method='post'>
5320 <tr><td align='right'>
5321 <input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
5322 <input type='submit' name='ACTION' value=' $Lang ::tr{'ovpn con stat'}' $activeonrun /></td>
5328 & Header
:: closebox
();
5332 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate authorities'}" );
5334 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5336 <th width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5337 <th width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></th>
5338 <th width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></th>
5342 my $col1 = "bgcolor=' $color {'color22'}'" ;
5343 my $col2 = "bgcolor=' $color {'color20'}'" ;
5345 my $col3 = "bgcolor=' $color {'color22'}'" ;
5347 my $col4 = "bgcolor=' $color {'color20'}'" ;
5349 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5350 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
5351 $casubject =~ /Subject: (.*)[\n]/ ;
5353 $casubject =~ s
+/ Email
+, E
+;
5354 $casubject =~ s/ ST=/ S=/ ;
5357 <td class='base' $col1 > $Lang ::tr{'root certificate'}</td>
5358 <td class='base' $col1 > $casubject </td>
5359 <form method='post' name='frmrootcrta'><td width='3%' align='center' $col1 >
5360 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
5361 <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' />
5363 <form method='post' name='frmrootcrtb'><td width='3%' align='center' $col1 >
5364 <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' />
5365 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
5367 <td width='4%' $col1 > </td>
5372 # display rootcert generation buttons
5375 <td class='base' $col1 > $Lang ::tr{'root certificate'}:</td>
5376 <td class='base' $col1 > $Lang ::tr{'not present'}</td>
5377 <td colspan='3' $col1 > </td>
5383 if (- f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
5384 my $hostsubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
5385 $hostsubject =~ /Subject: (.*)[\n]/ ;
5387 $hostsubject =~ s
+/ Email
+, E
+;
5388 $hostsubject =~ s/ ST=/ S=/ ;
5392 <td class='base' $col2 > $Lang ::tr{'host certificate'}</td>
5393 <td class='base' $col2 > $hostsubject </td>
5394 <form method='post' name='frmhostcrta'><td width='3%' align='center' $col2 >
5395 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
5396 <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' />
5398 <form method='post' name='frmhostcrtb'><td width='3%' align='center' $col2 >
5399 <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' />
5400 <input type='hidden' name='ACTION' value=" $Lang ::tr{'download host certificate'}" />
5402 <td width='4%' $col2 > </td>
5410 <td width='25%' class='base' $col2 > $Lang ::tr{'host certificate'}:</td>
5411 <td class='base' $col2 > $Lang ::tr{'not present'}</td>
5412 </td><td colspan='3' $col2 > </td>
5418 # Adding DH parameter to chart
5419 if (- f
"${General::swroot}/ovpn/ca/dh1024.pem" ) {
5420 my $dhsubject = `/usr/bin/openssl dhparam -text -in ${General::swroot}/ovpn/ca/dh1024.pem` ;
5421 $dhsubject =~ / (.*)[\n]/ ;
5427 <td class='base' $col3 > $Lang ::tr{'dh parameter'}</td>
5428 <td class='base' $col3 > $dhsubject </td>
5429 <form method='post' name='frmdhparam'><td width='3%' align='center' $col3 >
5430 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show dh'}' />
5431 <input type='image' name=' $Lang ::tr{'show dh'}' src='/images/info.gif' alt=' $Lang ::tr{'show dh'}' title=' $Lang ::tr{'show dh'}' width='20' height='20' border='0' />
5433 <form method='post' name='frmdhparam'><td width='3%' align='center' $col3 >
5435 <td width='4%' $col3 > </td>
5443 <td width='25%' class='base' $col3 > $Lang ::tr{'dh parameter'}:</td>
5444 <td class='base' $col3 > $Lang ::tr{'not present'}</td>
5445 </td><td colspan='3' $col3 > </td>
5451 # Adding ta.key to chart
5452 if (- f
"${General::swroot}/ovpn/certs/ta.key" ) {
5453 my $tasubject = `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
5454 $tasubject =~ /# (.*)[\n]/ ;
5459 <td class='base' $col4 > $Lang ::tr{'ta key'}</td>
5460 <td class='base' $col4 > $tasubject </td>
5461 <form method='post' name='frmtakey'><td width='3%' align='center' $col4 >
5462 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show tls-auth key'}' />
5463 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/info.gif' alt=' $Lang ::tr{'show tls-auth key'}' title=' $Lang ::tr{'show tls-auth key'}' width='20' height='20' border='0' />
5465 <form method='post' name='frmtakey'><td width='3%' align='center' $col4 >
5466 <input type='image' name=' $Lang ::tr{'download tls-auth key'}' src='/images/media-floppy.png' alt=' $Lang ::tr{'download tls-auth key'}' title=' $Lang ::tr{'download tls-auth key'}' border='0' />
5467 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download tls-auth key'}' />
5469 <td width='4%' $col4 > </td>
5477 <td width='25%' class='base' $col4 > $Lang ::tr{'ta key'}:</td>
5478 <td class='base' $col4 > $Lang ::tr{'not present'}</td>
5479 <td colspan='3' $col4 > </td>
5485 if (! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5486 print "<tr><td colspan='5' align='center'><form method='post'>" ;
5487 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' />" ;
5488 print "</form></td></tr> \n " ;
5491 if ( keys %cahash > 0 ) {
5492 foreach my $key ( keys %cahash ) {
5493 if (( $key + 1 ) % 2 ) {
5494 print "<tr bgcolor=' $color {'color20'}'> \n " ;
5496 print "<tr bgcolor=' $color {'color22'}'> \n " ;
5498 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
5499 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
5501 <form method='post' name='cafrm${key}a'><td align='center'>
5502 <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' />
5503 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
5504 <input type='hidden' name='KEY' value=' $key ' />
5506 <form method='post' name='cafrm${key}b'><td align='center'>
5507 <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' />
5508 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
5509 <input type='hidden' name='KEY' value=' $key ' />
5511 <form method='post' name='cafrm${key}c'><td align='center'>
5512 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
5513 <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' />
5514 <input type='hidden' name='KEY' value=' $key ' />
5523 # If the file contains entries, print Key to action icons
5524 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5528 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5529 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
5530 <td class='base'> $Lang ::tr{'show certificate'}</td>
5531 <td> <img src='/images/media-floppy.png' alt=' $Lang ::tr{'download certificate'}' /></td>
5532 <td class='base'> $Lang ::tr{'download certificate'}</td>
5541 <form method='post' enctype='multipart/form-data'>
5542 <table width='100%' border='0'cellspacing='1' cellpadding='0'>
5544 <td class'base'><b> $Lang ::tr{'upload ca certificate'}</b></td>
5547 <td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}:</td>
5548 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' align='left'/></td>
5549 <td nowrap='nowrap'><input type='file' name='FH' size='25' />
5550 <td nowrap='nowrap' align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td>
5554 <td colspan='4' align='right' width='80%'><input type='submit' name='ACTION' value=' $Lang ::tr{'show crl'}' /></td>
5557 <tr><td colspan=4><hr /></td></tr><tr>
5559 <td class'base'><b> $Lang ::tr{'ovpn dh parameters'}</b></td>
5563 <td class='base' nowrap='nowrap'> $Lang ::tr{'ovpn dh upload'}:</td>
5564 <td nowrap='nowrap'><size='15' align='left'/></td>
5565 <td nowrap='nowrap'><input type='file' name='FH' size='25' />
5566 <td colspan='4' align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload dh key'}' /></td>
5569 <td class='base' nowrap='nowrap'> $Lang ::tr{'ovpn dh new key'}:</td>
5570 <td nowrap='nowrap'><size='15' align='left'/></td>
5571 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'generate dh key'}' /></td>
5575 <tr><td colspan=4><hr /></td></tr><tr>
5579 if ( $srunning eq "yes" ) {
5580 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' disabled='disabled' /></div></form> \n " ;
5582 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' /></div></form> \n " ;
5584 & Header
:: closebox
();
5588 & Header
:: closepage
();