]>
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 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
74 $cgiparams { 'ENABLED' } = 'off' ;
75 $cgiparams { 'ENABLED_BLUE' } = 'off' ;
76 $cgiparams { 'ENABLED_ORANGE' } = 'off' ;
77 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
78 $cgiparams { 'NAT' } = 'off' ;
79 $cgiparams { 'COMPRESSION' } = 'off' ;
80 $cgiparams { 'ONLY_PROPOSED' } = 'off' ;
81 $cgiparams { 'ACTION' } = '' ;
82 $cgiparams { 'CA_NAME' } = '' ;
83 $cgiparams { 'DH_NAME' } = 'dh1024.pem' ;
84 $cgiparams { 'DHLENGHT' } = '' ;
85 $cgiparams { 'DHCP_DOMAIN' } = '' ;
86 $cgiparams { 'DHCP_DNS' } = '' ;
87 $cgiparams { 'DHCP_WINS' } = '' ;
88 $cgiparams { 'ROUTES_PUSH' } = '' ;
89 $cgiparams { 'DCOMPLZO' } = 'off' ;
90 $cgiparams { 'MSSFIX' } = '' ;
91 $cgiparams { 'number' } = '' ;
92 $cgiparams { 'PMTU_DISCOVERY' } = '' ;
93 $cgiparams { 'DCIPHER' } = '' ;
94 $cgiparams { 'DAUTH' } = '' ;
95 $cgiparams { 'TLSAUTH' } = '' ;
96 $routes_push_file = "${General::swroot}/ovpn/routes_push" ;
97 unless (- e
$routes_push_file ) { system ( "touch $routes_push_file " ); }
98 unless (- e
"${General::swroot}/ovpn/ccd.conf" ) { system ( "touch ${General::swroot}/ovpn/ccd.conf" ); }
99 unless (- e
"${General::swroot}/ovpn/ccdroute" ) { system ( "touch ${General::swroot}/ovpn/ccdroute" ); }
100 unless (- e
"${General::swroot}/ovpn/ccdroute2" ) { system ( "touch ${General::swroot}/ovpn/ccdroute2" ); }
102 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
104 # prepare openvpn config file
110 if ( $netsettings { 'CONFIG_TYPE' } == 2 ) { return 1 ;}
111 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
117 if ( $netsettings { 'CONFIG_TYPE' } == 3 ) { return 1 ;}
118 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
123 my $bytesize = shift ;
126 while ( abs ( $bytesize ) >= 1024 ){
127 $bytesize = $bytesize / 1024 ;
132 my @units = ( "Bytes" , "KB" , "MB" , "GB" , "TB" , "PB" , "EB" );
133 my $newsize =( int ( $bytesize * 100 + 0.5 ))/ 100 ;
134 return ( " $newsize $units [ $i ]" );
139 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/serial" )) {
143 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/index.txt" )) {
147 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
148 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
149 unlink ( "${General::swroot}/ovpn/certs/01.pem" );
152 sub newcleanssldatabase
154 if (! - s
"${General::swroot}/ovpn/certs/serial" ) {
155 open ( FILE
, ">${General::swroot}(ovpn/certs/serial" );
159 if (! - s
">${General::swroot}/ovpn/certs/index.txt" ) {
160 system ( "touch ${General::swroot}/ovpn/certs/index.txt" );
162 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
163 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
168 if ( open ( FILE
, "${General::swroot}/ovpn/certs/serial.old" )) {
169 my $hexvalue = < FILE
>;
172 unlink ( "${General::swroot}/ovpn/certs/ $hexvalue .pem" );
176 sub writeserverconf
{
177 my %sovpnsettings = ();
179 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%sovpnsettings );
182 open ( CONF
, ">${General::swroot}/ovpn/server.conf" ) or die "Unable to open ${General::swroot}/ovpn/server.conf: $!" ;
184 print CONF
"#OpenVPN Server conf \n " ;
186 print CONF
"daemon openvpnserver \n " ;
187 print CONF
"writepid /var/run/openvpn.pid \n " ;
188 print CONF
"#DAN prepare OpenVPN for listening on blue and orange \n " ;
189 print CONF
";local $sovpnsettings {'VPN_IP'} \n " ;
190 print CONF
"dev $sovpnsettings {'DDEVICE'} \n " ;
191 print CONF
"proto $sovpnsettings {'DPROTOCOL'} \n " ;
192 print CONF
"port $sovpnsettings {'DDEST_PORT'} \n " ;
193 print CONF
"script-security 3 system \n " ;
194 print CONF
"ifconfig-pool-persist /var/ipfire/ovpn/ovpn-leases.db 3600 \n " ;
195 print CONF
"client-config-dir /var/ipfire/ovpn/ccd \n " ;
196 print CONF
"tls-server \n " ;
197 print CONF
"ca ${General::swroot}/ovpn/ca/cacert.pem \n " ;
198 print CONF
"cert ${General::swroot}/ovpn/certs/servercert.pem \n " ;
199 print CONF
"key ${General::swroot}/ovpn/certs/serverkey.pem \n " ;
200 print CONF
"dh ${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'} \n " ;
201 my @tempovpnsubnet = split ( "\/" , $sovpnsettings { 'DOVPN_SUBNET' });
202 print CONF
"server $tempovpnsubnet [0] $tempovpnsubnet [1] \n " ;
203 #print CONF "push \"route $netsettings{'GREEN_NETADDRESS'} $netsettings{'GREEN_NETMASK'}\"\n";
205 # Check if we are using mssfix, fragment or mtu-disc and set the corretct mtu of 1500.
206 # If we doesn't use one of them, we can use the configured mtu value.
207 if ( $sovpnsettings { 'MSSFIX' } eq 'on' )
208 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
209 elsif ( $sovpnsettings { 'FRAGMENT' } ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' )
210 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
211 elsif (( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
212 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
213 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'no' ))
214 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
216 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu $sovpnsettings {'DMTU'} \n " ; }
218 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
219 @temp = split ( /\n/ , $vpnsettings { 'ROUTES_PUSH' });
222 @tempovpnsubnet = split ( "\/" ,& General
:: ipcidr2msk
( $_ ));
223 print CONF
"push \" route " . $tempovpnsubnet [ 0 ]. " " . $tempovpnsubnet [ 1 ] . " \"\n " ;
228 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
229 foreach my $key ( keys %ccdconfhash ) {
230 my $a = $ccdconfhash { $key }[ 1 ];
231 my ( $b , $c ) = split ( /\/ /, $a );
232 print CONF
"route $b " .& General
:: cidrtosub
( $c ). " \n " ;
235 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
236 foreach my $key ( keys %ccdroutehash ) {
237 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
238 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
239 print CONF
"route $a $b \n " ;
244 if ( $sovpnsettings { CLIENT2CLIENT
} eq 'on' ) {
245 print CONF
"client-to-client \n " ;
247 if ( $sovpnsettings { MSSFIX
} eq 'on' ) {
248 print CONF
"mssfix \n " ;
250 if ( $sovpnsettings { FRAGMENT
} ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' ) {
251 print CONF
"fragment $sovpnsettings {'FRAGMENT'} \n " ;
254 # Check if a valid operating mode has been choosen and use it.
255 if (( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
256 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
257 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'no' )) {
258 print CONF
"mtu-disc $sovpnsettings {'PMTU_DISCOVERY'} \n " ;
261 if ( $sovpnsettings { KEEPALIVE_1
} > 0 && $sovpnsettings { KEEPALIVE_2
} > 0 ) {
262 print CONF
"keepalive $sovpnsettings {'KEEPALIVE_1'} $sovpnsettings {'KEEPALIVE_2'} \n " ;
264 print CONF
"status-version 1 \n " ;
265 print CONF
"status /var/log/ovpnserver.log 30 \n " ;
266 print CONF
"cipher $sovpnsettings {DCIPHER} \n " ;
267 if ( $sovpnsettings { 'DAUTH' } eq '' ) {
270 print CONF
"auth $sovpnsettings {'DAUTH'} \n " ;
272 if ( $sovpnsettings { 'TLSAUTH' } eq 'on' ) {
273 print CONF
"tls-auth ${General::swroot}/ovpn/certs/ta.key \n " ;
275 if ( $sovpnsettings { DCOMPLZO
} eq 'on' ) {
276 print CONF
"comp-lzo \n " ;
278 if ( $sovpnsettings { REDIRECT_GW_DEF1
} eq 'on' ) {
279 print CONF
"push \" redirect-gateway def1 \"\n " ;
281 if ( $sovpnsettings { DHCP_DOMAIN
} ne '' ) {
282 print CONF
"push \" dhcp-option DOMAIN $sovpnsettings {DHCP_DOMAIN} \"\n " ;
285 if ( $sovpnsettings { DHCP_DNS
} ne '' ) {
286 print CONF
"push \" dhcp-option DNS $sovpnsettings {DHCP_DNS} \"\n " ;
289 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
290 print CONF
"push \" dhcp-option WINS $sovpnsettings {DHCP_WINS} \"\n " ;
293 if ( $sovpnsettings { DHCP_WINS
} eq '' ) {
294 print CONF
"max-clients 100 \n " ;
296 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
297 print CONF
"max-clients $sovpnsettings {MAX_CLIENTS} \n " ;
299 print CONF
"tls-verify /usr/lib/openvpn/verify \n " ;
300 print CONF
"crl-verify /var/ipfire/ovpn/crls/cacrl.pem \n " ;
301 print CONF
"user nobody \n " ;
302 print CONF
"group nobody \n " ;
303 print CONF
"persist-key \n " ;
304 print CONF
"persist-tun \n " ;
305 if ( $sovpnsettings { LOG_VERB
} ne '' ) {
306 print CONF
"verb $sovpnsettings {LOG_VERB} \n " ;
308 print CONF
"verb 3 \n " ;
316 if ( open ( FILE
, ">/var/log/ovpnserver.log" )) {
326 my %ccdconfhash = ();
328 my $ccdnetname = $_ [ 0 ];
329 if (- f
"${General::swroot}/ovpn/ovpnconfig" ){
330 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
331 foreach my $key ( keys %ccdhash ) {
332 if ( $ccdhash { $key }[ 32 ] eq $ccdnetname ) {
333 $errormessage = $Lang :: tr
{ 'ccd err hostinnet' };
338 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
339 foreach my $key ( keys %ccdconfhash ) {
340 if ( $ccdconfhash { $key }[ 0 ] eq $ccdnetname ){
341 delete $ccdconfhash { $key };
344 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
366 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err name' }. "<br>" ;
370 if (!& General
:: validhostname
( $ccdname ))
372 $errormessage = $Lang :: tr
{ 'ccd err invalidname' };
376 ( $ccdip , $subcidr ) = split ( /\/ /, $ccdnet );
377 $subcidr =& General
:: iporsubtocidr
( $subcidr );
381 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
385 if (!& General
:: validipandmask
( $ccdnet )){
386 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
390 $errormessage =& General
:: checksubnets
( $ccdname , $ccdnet );
393 if (! $errormessage ) {
395 $baseaddress =& General
:: getnetworkip
( $ccdip , $subcidr );
396 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
397 my $key = & General
:: findhasharraykey
( \
%ccdconfhash );
398 foreach my $i ( 0 .. 1 ) { $ccdconfhash { $key }[ $i ] = "" ;}
399 $ccdconfhash { $key }[ 0 ] = $ccdname ;
400 $ccdconfhash { $key }[ 1 ] = $baseaddress . "/" . $subcidr ;
401 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
403 $cgiparams { 'ccdname' }= '' ;
404 $cgiparams { 'ccdsubnet' }= '' ;
416 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
417 foreach my $key ( keys %ccdconfhash ) {
418 if ( $ccdconfhash { $key }[ 0 ] eq $oldname ) {
419 foreach my $key1 ( keys %ccdconfhash ) {
420 if ( $ccdconfhash { $key1 }[ 0 ] eq $newname ){
421 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err netadrexist' };
424 $ccdconfhash { $key }[ 0 ]= $newname ;
425 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
432 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
433 foreach my $key ( keys %ccdhash ) {
434 if ( $ccdhash { $key }[ 32 ] eq $oldname ) {
435 $ccdhash { $key }[ 32 ]= $newname ;
436 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
445 my $ccdnetwork = $_ [ 0 ];
448 @octets = split ( "\/" , $ccdnetwork );
449 @subnet = split /\./ , & General
:: cidrtosub
( $octets [ 1 ]);
462 my ( $ip1 , $ip2 , $ip3 , $ip4 )= split /\./ , $ipin ;
470 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
471 $iprange [ 0 ]= $ip1 . "." . $ip2 . "." . $ip3 . "." .( $ip4 + 2 );
472 for ( my $i = 1 ; $i <= $count ; $i ++) {
473 my $tmpip = $iprange [ $i - 1 ];
475 $iprange [ $i ]= & General
:: getnextip
( $tmpip , 4 );
478 foreach my $key ( keys %ccdhash ) {
480 foreach my $tmp ( @iprange ){
481 my ( $net , $sub ) = split ( /\/ /, $ccdhash { $key }[ 33 ]);
483 if ( $hasip ne $ccdhash { $key }[ 33 ] ){
484 splice ( @iprange , $r , 1 );
496 my ( $ccdip , $subcidr ) = split ( "/" , $_ [ 0 ]);
498 my @allccdips =& getccdadresses
( $ccdip , $subcidr ,& ccdmaxclients
( $ccdip . "/" . $subcidr ), $tz );
499 print "<select name=' $boxname ' STYLE='font-family : arial; font-size : 9pt; width:130px;' >" ;
500 foreach ( @allccdips ) {
503 print "<option value=' $ip ' " ;
504 if ( $ip eq $cgiparams { $boxname } ){
507 print "> $ip </option>" ;
517 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
518 foreach my $key ( keys %ccdhash ) {
519 if ( $ccdhash { $key }[ 32 ] eq $name ){ $i ++;}
524 sub check_routes_push
527 my ( $ip , $cidr ) = split ( /\/ /, $val );
528 ##check for existing routes in routes_push
529 if (- e
"${General::swroot}/ovpn/routes_push" ) {
530 open ( FILE
, "${General::swroot}/ovpn/routes_push" );
534 my ( $ip2 , $cidr2 ) = split ( /\/ /, " $_ " );
535 my $val2 = $ip2 . "/" .& General
:: iporsubtodec
( $cidr2 );
541 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: iporsubtodec
( $cidr2 ))){
554 my ( $ip , $cidr ) = split ( /\/ /, $val );
555 #check for existing routes in ccdroute
556 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
557 foreach my $key ( keys %ccdroutehash ) {
558 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
559 if (& General
:: iporsubtodec
( $val ) eq $ccdroutehash { $key }[ $i ] && $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' }){
562 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
564 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )&& $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' } ){
575 my ( $ip , $cidr ) = split ( /\/ /, $val );
576 #check for existing routes in ccdroute
577 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
578 foreach my $key ( keys %ccdconfhash ) {
579 if (& General
:: iporsubtocidr
( $val ) eq $ccdconfhash { $key }[ 1 ]){
582 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdconfhash { $key }[ 1 ]);
584 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: cidrtosub
( $cidr2 ))){
598 my $ipdotmask = $_ [ 0 ];
599 if (& General
:: validip
( $ipdotmask )) { return 0 ; }
600 if (!( $ipdotmask =~ /^(.*?)\/ (.* ?
)$/)) { }
602 if (( $mask =~ /\./ )) { return 0 ; }
606 # -------------------------------------------------------------------
608 sub write_routepushfile
610 open ( FILE
, "> $routes_push_file " );
612 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
613 print FILE
$vpnsettings { 'ROUTES_PUSH' };
618 sub read_routepushfile
620 if (- e
" $routes_push_file " ) {
621 open ( FILE
, " $routes_push_file " );
622 delete $vpnsettings { 'ROUTES_PUSH' };
623 while (< FILE
>) { $vpnsettings { 'ROUTES_PUSH' } .= $_ };
625 $cgiparams { 'ROUTES_PUSH' } = $vpnsettings { 'ROUTES_PUSH' };
631 #hier die refresh page
632 if ( - e
"${General::swroot}/ovpn/gencanow" ) {
634 $refresh = "<meta http-equiv='refresh' content='15;' />" ;
635 & Header
:: showhttpheaders
();
636 & Header
:: openpage
( $Lang :: tr
{ 'OVPN' }, 1 , $refresh );
637 & Header
:: openbigbox
( '100%' , 'center' );
638 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
639 print "<tr> \n <td align='center'><img src='/images/clock.gif' alt='' /></td> \n " ;
640 print "<td colspan='2'><font color='red'>Please be patient this realy can take some time on older hardware...</font></td></tr> \n " ;
642 & Header
:: closebigbox
();
643 & Header
:: closepage
();
646 ##hier die refresh page
650 ### OpenVPN Server Control
652 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' } ||
653 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' } ||
654 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart ovpn server' }) {
655 #start openvpn server
656 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' }){
658 system ( '/usr/local/bin/openvpnctrl' , '-s' );
661 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' }){
662 system ( '/usr/local/bin/openvpnctrl' , '-k' );
665 # #restart openvpn server
666 # if ($cgiparams{'ACTION'} eq $Lang::tr{'restart ovpn server'}){
667 #workarund, till SIGHUP also works when running as nobody
668 # system('/usr/local/bin/openvpnctrl', '-r');
674 ### Save Advanced options
677 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save-adv-options' }) {
678 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
679 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
680 #DAN this value has to leave.
681 #new settings for daemon
682 $vpnsettings { 'LOG_VERB' } = $cgiparams { 'LOG_VERB' };
683 $vpnsettings { 'KEEPALIVE_1' } = $cgiparams { 'KEEPALIVE_1' };
684 $vpnsettings { 'KEEPALIVE_2' } = $cgiparams { 'KEEPALIVE_2' };
685 $vpnsettings { 'MAX_CLIENTS' } = $cgiparams { 'MAX_CLIENTS' };
686 $vpnsettings { 'REDIRECT_GW_DEF1' } = $cgiparams { 'REDIRECT_GW_DEF1' };
687 $vpnsettings { 'CLIENT2CLIENT' } = $cgiparams { 'CLIENT2CLIENT' };
688 $vpnsettings { 'DHCP_DOMAIN' } = $cgiparams { 'DHCP_DOMAIN' };
689 $vpnsettings { 'DHCP_DNS' } = $cgiparams { 'DHCP_DNS' };
690 $vpnsettings { 'DHCP_WINS' } = $cgiparams { 'DHCP_WINS' };
691 $vpnsettings { 'ROUTES_PUSH' } = $cgiparams { 'ROUTES_PUSH' };
692 $vpnsettings { 'PMTU_DISCOVERY' } = $cgiparams { 'PMTU_DISCOVERY' };
693 $vpnsettings { 'DAUTH' } = $cgiparams { 'DAUTH' };
694 $vpnsettings { 'TLSAUTH' } = $cgiparams { 'TLSAUTH' };
697 if ( $cgiparams { 'FRAGMENT' } eq '' ) {
698 delete $vpnsettings { 'FRAGMENT' };
700 if ( $cgiparams { 'FRAGMENT' } !~ /^[0-9]+$/ ) {
701 $errormessage = "Incorrect value, please insert only numbers." ;
704 $vpnsettings { 'FRAGMENT' } = $cgiparams { 'FRAGMENT' };
708 if ( $cgiparams { 'MSSFIX' } ne 'on' ) {
709 delete $vpnsettings { 'MSSFIX' };
711 $vpnsettings { 'MSSFIX' } = $cgiparams { 'MSSFIX' };
714 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
715 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
716 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
718 if (( $cgiparams { 'MSSFIX' } eq 'on' ) || ( $cgiparams { 'FRAGMENT' } ne '' )) {
719 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
724 if ( $cgiparams { 'DHCP_DOMAIN' } ne '' ){
725 unless (& General
:: validdomainname
( $cgiparams { 'DHCP_DOMAIN' }) || & General
:: validip
( $cgiparams { 'DHCP_DOMAIN' })) {
726 $errormessage = $Lang :: tr
{ 'invalid input for dhcp domain' };
730 if ( $cgiparams { 'DHCP_DNS' } ne '' ){
731 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_DNS' }) || & General
:: validip
( $cgiparams { 'DHCP_DNS' })) {
732 $errormessage = $Lang :: tr
{ 'invalid input for dhcp dns' };
736 if ( $cgiparams { 'DHCP_WINS' } ne '' ){
737 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_WINS' }) || & General
:: validip
( $cgiparams { 'DHCP_WINS' })) {
738 $errormessage = $Lang :: tr
{ 'invalid input for dhcp wins' };
742 if ( $cgiparams { 'ROUTES_PUSH' } ne '' ){
743 @temp = split ( /\n/ , $cgiparams { 'ROUTES_PUSH' });
744 undef $vpnsettings { 'ROUTES_PUSH' };
746 foreach my $tmpip ( @temp )
748 s/^\s+//g ; s/\s+$//g ;
753 unless (& General
:: validipandmask
( $tmpip )) {
754 $errormessage = " $tmpip " . $Lang :: tr
{ 'ovpn errmsg invalid ip or mask' };
757 my ( $ip , $cidr ) = split ( "\/" ,& General
:: ipcidr2msk
( $tmpip ));
759 if ( $ip eq $netsettings { 'GREEN_NETADDRESS' } && $cidr eq $netsettings { 'GREEN_NETMASK' }) {
760 $errormessage = $Lang :: tr
{ 'ovpn errmsg green already pushed' };
765 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
766 foreach my $key ( keys %ccdroutehash ) {
767 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
768 if ( $ip . "/" . $cidr eq $ccdroutehash { $key }[ $i ] ){
769 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
772 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
773 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )){
774 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
782 $vpnsettings { 'ROUTES_PUSH' } .= $tmpip . " \n " ;
785 & write_routepushfile
;
786 undef $vpnsettings { 'ROUTES_PUSH' };
789 undef $vpnsettings { 'ROUTES_PUSH' };
790 & write_routepushfile
;
792 if (( length ( $cgiparams { 'MAX_CLIENTS' }) == 0 ) || (( $cgiparams { 'MAX_CLIENTS' }) < 1 ) || (( $cgiparams { 'MAX_CLIENTS' }) > 255 )) {
793 $errormessage = $Lang :: tr
{ 'invalid input for max clients' };
796 if ( $cgiparams { 'KEEPALIVE_1' } ne '' ) {
797 if ( $cgiparams { 'KEEPALIVE_1' } !~ /^[0-9]+$/ ) {
798 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1' };
802 if ( $cgiparams { 'KEEPALIVE_2' } ne '' ){
803 if ( $cgiparams { 'KEEPALIVE_2' } !~ /^[0-9]+$/ ) {
804 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 2' };
808 if ( $cgiparams { 'KEEPALIVE_2' } < ( $cgiparams { 'KEEPALIVE_1' } * 2 )){
809 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1:2' };
812 # Create ta.key for tls-auth if not presant
813 if ( $cgiparams { 'TLSAUTH' } eq 'on' ) {
814 if ( ! - e
"${General::swroot}/ovpn/certs/ta.key" ) {
815 system ( '/usr/sbin/openvpn' , '--genkey' , '--secret' , "${General::swroot}/ovpn/certs/ta.key" );
817 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
823 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
824 & writeserverconf
(); #hier ok
831 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'server' )
834 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
835 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
836 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
839 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
840 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
842 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: $!" ;
845 print SERVERCONF
"# IPFire n2n Open VPN Server Config by ummeegge und m.a.d \n " ;
846 print SERVERCONF
" \n " ;
847 print SERVERCONF
"# User Security \n " ;
848 print SERVERCONF
"user nobody \n " ;
849 print SERVERCONF
"group nobody \n " ;
850 print SERVERCONF
"persist-tun \n " ;
851 print SERVERCONF
"persist-key \n " ;
852 print SERVERCONF
"script-security 2 \n " ;
853 print SERVERCONF
"# IP/DNS for remote Server Gateway \n " ;
855 if ( $cgiparams { 'REMOTE' } ne '' ) {
856 print SERVERCONF
"remote $cgiparams {'REMOTE'} \n " ;
859 print SERVERCONF
"float \n " ;
860 print SERVERCONF
"# IP adresses of the VPN Subnet \n " ;
861 print SERVERCONF
"ifconfig $ovsubnet .1 $ovsubnet .2 \n " ;
862 print SERVERCONF
"# Client Gateway Network \n " ;
863 print SERVERCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
864 print SERVERCONF
"# tun Device \n " ;
865 print SERVERCONF
"dev tun \n " ;
866 print SERVERCONF
"# Port and Protokol \n " ;
867 print SERVERCONF
"port $cgiparams {'DEST_PORT'} \n " ;
869 if ( $cgiparams { 'PROTOCOL' } eq 'tcp' ) {
870 print SERVERCONF
"proto tcp-server \n " ;
871 print SERVERCONF
"# Packet size \n " ;
872 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1400' } else { $tunmtu = $cgiparams { 'MTU' }};
873 print SERVERCONF
"tun-mtu $tunmtu \n " ;
876 if ( $cgiparams { 'PROTOCOL' } eq 'udp' ) {
877 print SERVERCONF
"proto udp \n " ;
878 print SERVERCONF
"# Paketsize \n " ;
879 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
880 print SERVERCONF
"tun-mtu $tunmtu \n " ;
881 if ( $cgiparams { 'FRAGMENT' } ne '' ) { print SERVERCONF
"fragment $cgiparams {'FRAGMENT'} \n " ;}
882 if ( $cgiparams { 'MSSFIX' } eq 'on' ) { print SERVERCONF
"mssfix \n " ; };
885 # Check if a valid operating mode has been choosen and use it.
886 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
887 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
888 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
889 if (( $cgiparams { 'MSSFIX' } ne 'on' ) || ( $cgiparams { 'FRAGMENT' } eq '' )) {
890 if ( $cgiparams { 'MTU' } eq '1500' ) {
891 print SERVERCONF
"mtu-disc $cgiparams {'PMTU_DISCOVERY'} \n " ;
895 print SERVERCONF
"# Auth. Server \n " ;
896 print SERVERCONF
"tls-server \n " ;
897 print SERVERCONF
"ca ${General::swroot}/ovpn/ca/cacert.pem \n " ;
898 print SERVERCONF
"cert ${General::swroot}/ovpn/certs/servercert.pem \n " ;
899 print SERVERCONF
"key ${General::swroot}/ovpn/certs/serverkey.pem \n " ;
900 print SERVERCONF
"dh ${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'} \n " ;
901 print SERVERCONF
"# Cipher \n " ;
902 print SERVERCONF
"cipher $cgiparams {'DCIPHER'} \n " ;
903 if ( $cgiparams { 'DAUTH' } eq '' ) {
904 print SERVERCONF
"auth SHA1 \n " ;
906 print SERVERCONF
"# HMAC algorithm \n " ;
907 print SERVERCONF
"auth $cgiparams {'DAUTH'} \n " ;
909 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
910 print SERVERCONF
"# Enable Compression \n " ;
911 print SERVERCONF
"comp-lzo \r\n " ;
913 print SERVERCONF
"# Debug Level \n " ;
914 print SERVERCONF
"verb 3 \n " ;
915 print SERVERCONF
"# Tunnel check \n " ;
916 print SERVERCONF
"keepalive 10 60 \n " ;
917 print SERVERCONF
"# Start as daemon \n " ;
918 print SERVERCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
919 print SERVERCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
920 print SERVERCONF
"# Activate Management Interface and Port \n " ;
921 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) { print SERVERCONF
"management localhost $cgiparams {'DEST_PORT'} \n " }
922 else { print SERVERCONF
"management localhost $cgiparams {'OVPN_MGMT'} \n " };
931 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'client' )
934 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
935 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
936 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
939 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
940 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
942 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: $!" ;
945 print CLIENTCONF
"# IPFire rewritten n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
946 print CLIENTCONF
"# \n " ;
947 print CLIENTCONF
"# User Security \n " ;
948 print CLIENTCONF
"user nobody \n " ;
949 print CLIENTCONF
"group nobody \n " ;
950 print CLIENTCONF
"persist-tun \n " ;
951 print CLIENTCONF
"persist-key \n " ;
952 print CLIENTCONF
"script-security 2 \n " ;
953 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
954 print CLIENTCONF
"remote $cgiparams {'REMOTE'} \n " ;
955 print CLIENTCONF
"float \n " ;
956 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
957 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
958 print CLIENTCONF
"# Server Gateway Network \n " ;
959 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
960 print CLIENTCONF
"# tun Device \n " ;
961 print CLIENTCONF
"dev tun \n " ;
962 print CLIENTCONF
"# Port and Protokol \n " ;
963 print CLIENTCONF
"port $cgiparams {'DEST_PORT'} \n " ;
965 if ( $cgiparams { 'PROTOCOL' } eq 'tcp' ) {
966 print CLIENTCONF
"proto tcp-client \n " ;
967 print CLIENTCONF
"# Packet size \n " ;
968 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1400' } else { $tunmtu = $cgiparams { 'MTU' }};
969 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
972 if ( $cgiparams { 'PROTOCOL' } eq 'udp' ) {
973 print CLIENTCONF
"proto udp \n " ;
974 print CLIENTCONF
"# Paketsize \n " ;
975 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
976 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
977 if ( $cgiparams { 'FRAGMENT' } ne '' ) { print CLIENTCONF
"fragment $cgiparams {'FRAGMENT'} \n " ;}
978 if ( $cgiparams { 'MSSFIX' } eq 'on' ) { print CLIENTCONF
"mssfix \n " ; };
981 # Check if a valid operating mode has been choosen and use it.
982 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
983 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
984 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
985 if (( $cgiparams { 'MSSFIX' } ne 'on' ) || ( $cgiparams { 'FRAGMENT' } eq '' )) {
986 if ( $cgiparams { 'MTU' } eq '1500' ) {
987 print CLIENTCONF
"mtu-disc $cgiparams {'PMTU_DISCOVERY'} \n " ;
992 print CLIENTCONF
"ns-cert-type server \n " ;
993 print CLIENTCONF
"# Auth. Client \n " ;
994 print CLIENTCONF
"tls-client \n " ;
995 print CLIENTCONF
"# Cipher \n " ;
996 print CLIENTCONF
"cipher $cgiparams {'DCIPHER'} \n " ;
997 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12 \r\n " ;
998 if ( $cgiparams { 'DAUTH' } eq '' ) {
999 print CLIENTCONF
"auth SHA1 \n " ;
1001 print CLIENTCONF
"# HMAC algorithm \n " ;
1002 print CLIENTCONF
"auth $cgiparams {'DAUTH'} \n " ;
1004 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
1005 print CLIENTCONF
"# Enable Compression \n " ;
1006 print CLIENTCONF
"comp-lzo \r\n " ;
1008 print CLIENTCONF
"# Debug Level \n " ;
1009 print CLIENTCONF
"verb 3 \n " ;
1010 print CLIENTCONF
"# Tunnel check \n " ;
1011 print CLIENTCONF
"keepalive 10 60 \n " ;
1012 print CLIENTCONF
"# Start as daemon \n " ;
1013 print CLIENTCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
1014 print CLIENTCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
1015 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
1016 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) { print CLIENTCONF
"management localhost $cgiparams {'DEST_PORT'} \n " }
1017 else { print CLIENTCONF
"management localhost $cgiparams {'OVPN_MGMT'} \n " };
1023 ### Save main settings
1026 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
1027 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1028 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
1029 #DAN this value has to leave.
1030 if ( $cgiparams { 'ENABLED' } eq 'on' ){
1031 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })) {
1032 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1033 goto SETTINGS_ERROR
;
1037 if (! & General
:: validipandmask
( $cgiparams { 'DOVPN_SUBNET' })) {
1038 $errormessage = $Lang :: tr
{ 'ovpn subnet is invalid' };
1039 goto SETTINGS_ERROR
;
1041 my @tmpovpnsubnet = split ( "\/" , $cgiparams { 'DOVPN_SUBNET' });
1043 if (& General
:: IpInSubnet
( $netsettings { 'RED_ADDRESS' },
1044 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1045 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire RED Network $netsettings {'RED_ADDRESS'}" ;
1046 goto SETTINGS_ERROR
;
1049 if (& General
:: IpInSubnet
( $netsettings { 'GREEN_ADDRESS' },
1050 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1051 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Green Network $netsettings {'GREEN_ADDRESS'}" ;
1052 goto SETTINGS_ERROR
;
1055 if (& General
:: IpInSubnet
( $netsettings { 'BLUE_ADDRESS' },
1056 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1057 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Blue Network $netsettings {'BLUE_ADDRESS'}" ;
1058 goto SETTINGS_ERROR
;
1061 if (& General
:: IpInSubnet
( $netsettings { 'ORANGE_ADDRESS' },
1062 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1063 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Orange Network $netsettings {'ORANGE_ADDRESS'}" ;
1064 goto SETTINGS_ERROR
;
1066 open ( ALIASES
, "${General::swroot}/ethernet/aliases" ) or die 'Unable to open aliases file.' ;
1070 my @tempalias = split ( /\,/ , $_ );
1071 if ( $tempalias [ 1 ] eq 'on' ) {
1072 if (& General
:: IpInSubnet
( $tempalias [ 0 ] ,
1073 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1074 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire alias entry $tempalias [0]" ;
1079 if ( $errormessage ne '' ){
1080 goto SETTINGS_ERROR
;
1082 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1083 $errormessage = $Lang :: tr
{ 'invalid input' };
1084 goto SETTINGS_ERROR
;
1086 if (( length ( $cgiparams { 'DMTU' })== 0 ) || (( $cgiparams { 'DMTU' }) < 1000 )) {
1087 $errormessage = $Lang :: tr
{ 'invalid mtu input' };
1088 goto SETTINGS_ERROR
;
1091 unless (& General
:: validport
( $cgiparams { 'DDEST_PORT' })) {
1092 $errormessage = $Lang :: tr
{ 'invalid port' };
1093 goto SETTINGS_ERROR
;
1096 $vpnsettings { 'ENABLED_BLUE' } = $cgiparams { 'ENABLED_BLUE' };
1097 $vpnsettings { 'ENABLED_ORANGE' } = $cgiparams { 'ENABLED_ORANGE' };
1098 $vpnsettings { 'ENABLED' } = $cgiparams { 'ENABLED' };
1099 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
1100 #new settings for daemon
1101 $vpnsettings { 'DOVPN_SUBNET' } = $cgiparams { 'DOVPN_SUBNET' };
1102 $vpnsettings { 'DDEVICE' } = $cgiparams { 'DDEVICE' };
1103 $vpnsettings { 'DPROTOCOL' } = $cgiparams { 'DPROTOCOL' };
1104 $vpnsettings { 'DDEST_PORT' } = $cgiparams { 'DDEST_PORT' };
1105 $vpnsettings { 'DMTU' } = $cgiparams { 'DMTU' };
1106 $vpnsettings { 'DCOMPLZO' } = $cgiparams { 'DCOMPLZO' };
1107 $vpnsettings { 'DCIPHER' } = $cgiparams { 'DCIPHER' };
1110 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" );}
1111 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" );}
1112 if ( $vpnsettings { 'ENABLED' } eq 'on' ) { system ( "touch ${General::swroot}/ovpn/enable 2>/dev/null" );} else { system ( "unlink ${General::swroot}/ovpn/enable 2>/dev/null" );}
1113 #new settings for daemon
1114 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1115 & writeserverconf
(); #hier ok
1118 ### Reset all step 2
1120 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1122 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1124 foreach my $key ( keys %confighash ) {
1125 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
1126 delete $confighash { $cgiparams { ' $key ' }};
1129 while ( $file = glob ( "${General::swroot}/ovpn/ca/*" )) {
1132 while ( $file = glob ( "${General::swroot}/ovpn/certs/*" )) {
1135 while ( $file = glob ( "${General::swroot}/ovpn/crls/*" )) {
1138 & cleanssldatabase
();
1139 if ( open ( FILE
, ">${General::swroot}/ovpn/caconfig" )) {
1143 if ( open ( FILE
, ">${General::swroot}/ovpn/ccdroute" )) {
1147 if ( open ( FILE
, ">${General::swroot}/ovpn/ccdroute2" )) {
1151 while ( $file = glob ( "${General::swroot}/ovpn/ccd/*" )) {
1154 if ( open ( FILE
, ">${General::swroot}/ovpn/ovpn-leases.db" )) {
1158 if ( open ( FILE
, ">${General::swroot}/ovpn/ovpnconfig" )) {
1162 while ( $file = glob ( "${General::swroot}/ovpn/n2nconf/*" )) {
1163 system ( "rm -rf $file " );
1166 #&writeserverconf();
1168 ### Reset all step 1
1170 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' }) {
1171 & Header
:: showhttpheaders
();
1172 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1173 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1174 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
1176 <form method='post'>
1177 <table width='100%'>
1180 <input type='hidden' name='AREUSURE' value='yes' />
1181 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1182 $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}</td>
1185 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' />
1186 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
1192 & Header
:: closebox
();
1193 & Header
:: closebigbox
();
1194 & Header
:: closepage
();
1198 ### Generate DH key step 2
1200 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate dh key' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1201 # Delete if old key exists
1202 if (- f
"${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ) {
1203 unlink "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ;
1205 # Create Diffie Hellmann Parameter
1206 system ( '/usr/bin/openssl' , 'dhparam' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1207 '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" , " $cgiparams {'DHLENGHT'}" );
1209 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1210 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1214 ### Generate DH key step 1
1216 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate dh key' }) {
1217 & Header
:: showhttpheaders
();
1218 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1219 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1220 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'gen dh'}:" );
1222 <table width='100%'>
1224 <td width='20%'> </td> <td width='15%'></td> <td width='65%'></td>
1227 <td class='base'> $Lang ::tr{'ovpn dh'}:</td>
1229 <form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1230 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1231 <select name='DHLENGHT'>
1232 <option value='1024' $selected {'DHLENGHT'}{'1024'}>1024 $Lang ::tr{'bit'}</option>
1233 <option value='2048' $selected {'DHLENGHT'}{'2048'}>2048 $Lang ::tr{'bit'}</option>
1234 <option value='3072' $selected {'DHLENGHT'}{'3072'}>3072 $Lang ::tr{'bit'}</option>
1235 <option value='4096' $selected {'DHLENGHT'}{'4096'}>4096 $Lang ::tr{'bit'}</option>
1239 <tr><td colspan='4'><br></td></tr>
1241 <table width='100%'>
1243 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}: </font></b> $Lang ::tr{'dh key warn'}
1246 <td class='base'> $Lang ::tr{'dh key warn1'}</td>
1248 <tr><td colspan='2'><br></td></tr>
1250 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'generate dh key'}' /></td>
1257 & Header
:: closebox
();
1258 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1259 & Header
:: closebigbox
();
1260 & Header
:: closepage
();
1266 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload dh key' }) {
1267 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1268 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1269 goto UPLOADCA_ERROR
;
1271 # Move uploaded dh key to a temporary file
1272 ( my $fh , my $filename ) = tempfile
( );
1273 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1275 goto UPLOADCA_ERROR
;
1277 my $temp = `/usr/bin/openssl dhparam -text -in $filename ` ;
1278 if ( $temp !~ /DH Parameters: \((1024|2048|3072|4096) bit\)/ ) {
1279 $errormessage = $Lang :: tr
{ 'not a valid dh key' };
1281 goto UPLOADCA_ERROR
;
1283 # Delete if old key exists
1284 if (- f
"${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ) {
1285 unlink "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ;
1287 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" );
1289 $errormessage = " $Lang ::tr{'dh key move failed'}: $!" ;
1291 goto UPLOADCA_ERROR
;
1296 ### Upload CA Certificate
1298 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
1299 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1301 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1302 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1303 goto UPLOADCA_ERROR
;
1306 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
1307 $errormessage = $Lang :: tr
{ 'name too long' };
1311 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
1312 $errormessage = $Lang :: tr
{ 'name is invalid' };
1313 goto UPLOADCA_ERROR
;
1316 # Check if there is no other entry with this name
1317 foreach my $key ( keys %cahash ) {
1318 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
1319 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
1320 goto UPLOADCA_ERROR
;
1324 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1325 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1326 goto UPLOADCA_ERROR
;
1328 # Move uploaded ca to a temporary file
1329 ( my $fh , my $filename ) = tempfile
( );
1330 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1332 goto UPLOADCA_ERROR
;
1334 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
1335 if ( $temp !~ /CA:TRUE/i ) {
1336 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1338 goto UPLOADCA_ERROR
;
1340 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1342 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1344 goto UPLOADCA_ERROR
;
1348 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem` ;
1349 $casubject =~ /Subject: (.*)[\n]/ ;
1351 $casubject =~ s
+/ Email
+, E
+;
1352 $casubject =~ s/ ST=/ S=/ ;
1353 $casubject = & Header
:: cleanhtml
( $casubject );
1355 my $key = & General
:: findhasharraykey
( \
%cahash );
1356 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1357 $cahash { $key }[ 1 ] = $casubject ;
1358 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1359 # system('/usr/local/bin/ipsecctrl', 'R');
1364 ### Display ca certificate
1366 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
1367 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1369 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1370 & Header
:: showhttpheaders
();
1371 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1372 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1373 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ca certificate'}:" );
1374 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1375 $output = & Header
:: cleanhtml
( $output , "y" );
1376 print "<pre> $output </pre> \n " ;
1377 & Header
:: closebox
();
1378 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1379 & Header
:: closebigbox
();
1380 & Header
:: closepage
();
1383 $errormessage = $Lang :: tr
{ 'invalid key' };
1387 ### Download ca certificate
1389 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
1390 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1392 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1393 print "Content-Type: application/octet-stream \r\n " ;
1394 print "Content-Disposition: filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
1395 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1398 $errormessage = $Lang :: tr
{ 'invalid key' };
1402 ### Remove ca certificate (step 2)
1404 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1405 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1406 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1408 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1409 foreach my $key ( keys %confighash ) {
1410 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` ;
1411 if ( $test =~ /: OK/ ) {
1413 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1414 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
1415 # system('/usr/local/bin/ipsecctrl', 'D', $key);
1417 unlink ( "${General::swroot}/ovpn//certs/ $confighash { $key }[1]cert.pem" );
1418 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" );
1419 delete $confighash { $key };
1420 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1421 # &writeipsecfiles();
1424 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1425 delete $cahash { $cgiparams { 'KEY' }};
1426 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1427 # system('/usr/local/bin/ipsecctrl', 'R');
1429 $errormessage = $Lang :: tr
{ 'invalid key' };
1432 ### Remove ca certificate (step 1)
1434 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
1435 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1436 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1438 my $assignedcerts = 0 ;
1439 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1440 foreach my $key ( keys %confighash ) {
1441 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` ;
1442 if ( $test =~ /: OK/ ) {
1446 if ( $assignedcerts ) {
1447 & Header
:: showhttpheaders
();
1448 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1449 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1450 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'are you sure' });
1452 <table><form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1453 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1454 <tr><td align='center'>
1455 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>: $assignedcerts
1456 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}
1457 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
1458 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td></tr>
1462 & Header
:: closebox
();
1463 & Header
:: closebigbox
();
1464 & Header
:: closepage
();
1467 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1468 delete $cahash { $cgiparams { 'KEY' }};
1469 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1470 # system('/usr/local/bin/ipsecctrl', 'R');
1473 $errormessage = $Lang :: tr
{ 'invalid key' };
1477 ### Display root certificate
1479 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
1480 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
1482 & Header
:: showhttpheaders
();
1483 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1484 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1485 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
1486 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'root certificate'}:" );
1487 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1489 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'host certificate'}:" );
1490 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1492 $output = & Header
:: cleanhtml
( $output , "y" );
1493 print "<pre> $output </pre> \n " ;
1494 & Header
:: closebox
();
1495 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1496 & Header
:: closebigbox
();
1497 & Header
:: closepage
();
1501 ### Download root certificate
1503 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
1504 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1505 print "Content-Type: application/octet-stream \r\n " ;
1506 print "Content-Disposition: filename=cacert.pem \r\n\r\n " ;
1507 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1512 ### Download host certificate
1514 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
1515 if ( - f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
1516 print "Content-Type: application/octet-stream \r\n " ;
1517 print "Content-Disposition: filename=servercert.pem \r\n\r\n " ;
1518 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1523 ### Download Diffie-Hellman parameter
1525 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download dh parameter' }) {
1526 if ( - f
"${General::swroot}/ovpn/ca/dh1024.pem" ) {
1527 print "Content-Type: application/octet-stream \r\n " ;
1528 print "Content-Disposition: filename=dh1024.pem \r\n\r\n " ;
1529 print `/usr/bin/openssl dhparam -in ${General::swroot}/ovpn/ca/dh1024.pem` ;
1534 ### Download tls-auth key
1536 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download tls-auth key' }) {
1537 if ( - f
"${General::swroot}/ovpn/certs/ta.key" ) {
1538 print "Content-Type: application/octet-stream \r\n " ;
1539 print "Content-Disposition: filename=ta.key \r\n\r\n " ;
1540 print `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
1545 ### Form for generating a root certificate
1547 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
1548 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1550 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1551 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1552 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
1553 $cgiparams { 'ACTION' } = '' ;
1554 goto ROOTCERT_ERROR
;
1557 if (( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) && - e
"${General::swroot}/red/active" ) {
1558 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
1559 my $ipaddr = < IPADDR
>;
1562 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
1563 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
1564 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
1567 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1569 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1570 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1571 goto ROOTCERT_ERROR
;
1574 # Move uploaded certificate request to a temporary file
1575 ( my $fh , my $filename ) = tempfile
( );
1576 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1578 goto ROOTCERT_ERROR
;
1581 # Create a temporary dirctory
1582 my $tempdir = tempdir
( CLEANUP
=> 1 );
1584 # Extract the CA certificate from the file
1585 my $pid = open ( OPENSSL
, "|-" );
1586 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1587 if ( $pid ) { # parent
1588 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1589 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1593 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1595 goto ROOTCERT_ERROR
;
1598 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-cacerts' , '-nokeys' ,
1600 '-out' , " $tempdir /cacert.pem" )) {
1601 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1603 goto ROOTCERT_ERROR
;
1607 # Extract the Host certificate from the file
1608 $pid = open ( OPENSSL
, "|-" );
1609 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1610 if ( $pid ) { # parent
1611 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1612 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1616 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1618 goto ROOTCERT_ERROR
;
1621 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-clcerts' , '-nokeys' ,
1623 '-out' , " $tempdir /hostcert.pem" )) {
1624 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1626 goto ROOTCERT_ERROR
;
1630 # Extract the Host key from the file
1631 $pid = open ( OPENSSL
, "|-" );
1632 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1633 if ( $pid ) { # parent
1634 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1635 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1639 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1641 goto ROOTCERT_ERROR
;
1644 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-nocerts' ,
1647 '-out' , " $tempdir /serverkey.pem" )) {
1648 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1650 goto ROOTCERT_ERROR
;
1654 move
( " $tempdir /cacert.pem" , "${General::swroot}/ovpn/ca/cacert.pem" );
1656 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1658 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1659 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1660 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1661 goto ROOTCERT_ERROR
;
1664 move
( " $tempdir /hostcert.pem" , "${General::swroot}/ovpn/certs/servercert.pem" );
1666 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1668 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1669 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1670 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1671 goto ROOTCERT_ERROR
;
1674 move
( " $tempdir /serverkey.pem" , "${General::swroot}/ovpn/certs/serverkey.pem" );
1676 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1678 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1679 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1680 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1681 goto ROOTCERT_ERROR
;
1684 goto ROOTCERT_SUCCESS
;
1686 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
1688 # Validate input since the form was submitted
1689 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
1690 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
1691 goto ROOTCERT_ERROR
;
1693 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
1694 $errormessage = $Lang :: tr
{ 'organization too long' };
1695 goto ROOTCERT_ERROR
;
1697 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1698 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1699 goto ROOTCERT_ERROR
;
1701 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
1702 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
1703 goto ROOTCERT_ERROR
;
1705 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
1706 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1707 goto ROOTCERT_ERROR
;
1709 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
1710 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1711 goto ROOTCERT_ERROR
;
1713 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
1714 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1715 goto ROOTCERT_ERROR
;
1717 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1718 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1719 goto ROOTCERT_ERROR
;
1721 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1722 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1723 goto ROOTCERT_ERROR
;
1725 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1726 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1727 goto ROOTCERT_ERROR
;
1729 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1730 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1731 goto ROOTCERT_ERROR
;
1734 # Copy the cgisettings to vpnsettings and save the configfile
1735 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
1736 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
1737 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
1738 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
1739 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
1740 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
1741 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
1742 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1744 # Replace empty strings with a .
1745 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
1746 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
1747 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
1750 #system ('/bin/touch', "${General::swroot}/ovpn/gencanow");
1752 # Create the CA certificate
1753 my $pid = open ( OPENSSL
, "|-" );
1754 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1755 if ( $pid ) { # parent
1756 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1757 print OPENSSL
" $state \n " ;
1758 print OPENSSL
" $city \n " ;
1759 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1760 print OPENSSL
" $ou \n " ;
1761 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
1762 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1765 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1766 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1767 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1768 goto ROOTCERT_ERROR
;
1771 unless ( exec ( '/usr/bin/openssl' , 'req' , '-x509' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1772 '-days' , '999999' , '-newkey' , 'rsa:4096' , '-sha512' ,
1773 '-keyout' , "${General::swroot}/ovpn/ca/cakey.pem" ,
1774 '-out' , "${General::swroot}/ovpn/ca/cacert.pem" ,
1775 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1776 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1777 goto ROOTCERT_ERROR
;
1781 # Create the Host certificate request
1782 $pid = open ( OPENSSL
, "|-" );
1783 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1784 if ( $pid ) { # parent
1785 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1786 print OPENSSL
" $state \n " ;
1787 print OPENSSL
" $city \n " ;
1788 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1789 print OPENSSL
" $ou \n " ;
1790 print OPENSSL
" $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1791 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1792 print OPENSSL
". \n " ;
1793 print OPENSSL
". \n " ;
1796 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1797 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1798 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1799 goto ROOTCERT_ERROR
;
1802 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1803 '-newkey' , 'rsa:2048' ,
1804 '-keyout' , "${General::swroot}/ovpn/certs/serverkey.pem" ,
1805 '-out' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1806 '-extensions' , 'server' ,
1807 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1808 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1809 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1810 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1811 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1812 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1813 goto ROOTCERT_ERROR
;
1817 # Sign the host certificate request
1818 system ( '/usr/bin/openssl' , 'ca' , '-days' , '999999' ,
1819 '-batch' , '-notext' ,
1820 '-in' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1821 '-out' , "${General::swroot}/ovpn/certs/servercert.pem" ,
1822 '-extensions' , 'server' ,
1823 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1825 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1826 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1827 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1828 unlink ( "${General::swroot}/ovpn/serverkey.pem" );
1829 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1830 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1831 & newcleanssldatabase
();
1832 goto ROOTCERT_ERROR
;
1834 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1835 & deletebackupcert
();
1838 # Create an empty CRL
1839 system ( '/usr/bin/openssl' , 'ca' , '-gencrl' ,
1840 '-out' , "${General::swroot}/ovpn/crls/cacrl.pem" ,
1841 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1843 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1844 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1845 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1846 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1847 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1848 & cleanssldatabase
();
1849 goto ROOTCERT_ERROR
;
1851 # &cleanssldatabase();
1853 # Create Diffie Hellmann Parameter
1854 system ( '/usr/bin/openssl' , 'dhparam' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
1855 '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" , " $cgiparams {'DHLENGHT'}" );
1857 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1858 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1859 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1860 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1861 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1862 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1863 & cleanssldatabase
();
1864 goto ROOTCERT_ERROR
;
1866 # &cleanssldatabase();
1868 # Create ta.key for tls-auth
1869 system ( '/usr/sbin/openvpn' , '--genkey' , '--secret' , "${General::swroot}/ovpn/certs/ta.key" );
1871 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1872 & cleanssldatabase
();
1873 goto ROOTCERT_ERROR
;
1875 goto ROOTCERT_SUCCESS
;
1878 if ( $cgiparams { 'ACTION' } ne '' ) {
1879 & Header
:: showhttpheaders
();
1880 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1881 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1882 if ( $errormessage ) {
1883 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
1884 print "<class name='base'> $errormessage " ;
1885 print " </class>" ;
1886 & Header
:: closebox
();
1888 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'generate root/host certificates'}:" );
1890 <form method='post' enctype='multipart/form-data'>
1891 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1892 <tr><td width='30%' class='base'> $Lang ::tr{'organization name'}:</td>
1893 <td width='35%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td>
1894 <td width='35%' colspan='2'> </td></tr>
1895 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}:</td>
1896 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td>
1897 <td colspan='2'> </td></tr>
1898 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt'*' /></td>
1899 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td>
1900 <td colspan='2'> </td></tr>
1901 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt'*' /></td>
1902 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td>
1903 <td colspan='2'> </td></tr>
1904 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt'*' /></td>
1905 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td>
1906 <td colspan='2'> </td></tr>
1907 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt'*' /></td>
1908 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td>
1909 <td colspan='2'> </td></tr>
1910 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1911 <td class='base'><select name='ROOTCERT_COUNTRY'>
1915 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1916 print "<option value=' $Countries ::countries{ $country }'" ;
1917 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1918 print " selected='selected'" ;
1920 print "> $country </option>" ;
1924 <tr><td class='base'> $Lang ::tr{'ovpn dh'}:</td>
1925 <td class='base'><select name='DHLENGHT'>
1926 <option value='1024' $selected {'DHLENGHT'}{'1024'}>1024 $Lang ::tr{'bit'}</option>
1927 <option value='2048' $selected {'DHLENGHT'}{'2048'}>2048 $Lang ::tr{'bit'}</option>
1928 <option value='3072' $selected {'DHLENGHT'}{'3072'}>3072 $Lang ::tr{'bit'}</option>
1929 <option value='4096' $selected {'DHLENGHT'}{'4096'}>4096 $Lang ::tr{'bit'}</option>
1935 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /></td>
1936 <td> </td><td> </td></tr>
1937 <tr><td class='base' colspan='4' align='left'>
1938 <img src='/blob.gif' valign='top' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
1939 <tr><td colspan='2'><br></td></tr>
1940 <table width='100%'>
1942 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}: </font></b> $Lang ::tr{'ovpn generating the root and host certificates'}
1943 <td class='base'> $Lang ::tr{'dh key warn'}</td>
1946 <td class='base'> $Lang ::tr{'dh key warn1'}</td>
1948 <tr><td colspan='2'><br></td></tr>
1952 <table width='100%'>
1953 <tr><td colspan='4'><hr></td></tr>
1954 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
1955 <td nowrap='nowrap'><input type='file' name='FH' size='32'></td>
1956 <td colspan='2'> </td></tr>
1957 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' ></td>
1958 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td>
1959 <td colspan='2'> </td></tr>
1961 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td>
1962 <td colspan='2'> </td></tr>
1963 <tr><td class='base' colspan='4' align='left'>
1964 <img src='/blob.gif' valign='top' al='*' > $Lang ::tr{'this field may be blank'}</td>
1969 & Header
:: closebox
();
1970 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1971 & Header
:: closebigbox
();
1972 & Header
:: closepage
();
1977 system ( "chmod 600 ${General::swroot}/ovpn/certs/serverkey.pem" );
1978 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1979 # $vpnsettings{'ENABLE_BLUE'} eq 'on') {
1980 # system('/usr/local/bin/ipsecctrl', 'S');
1984 ### Enable/Disable connection
1991 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
1993 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1994 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1995 # my $n2nactive = '';
1996 my $n2nactive = `/bin/ps ax|grep $confighash { $cgiparams {'KEY'}}[1]|grep -v grep|awk \' {print \ $1 } \' ` ;
1998 if ( $confighash { $cgiparams { 'KEY' }}) {
1999 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
2000 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
2001 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2003 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2004 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
2008 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
2009 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2011 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2012 if ( $n2nactive ne '' ){
2013 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
2017 $errormessage = $Lang :: tr
{ 'invalid key' };
2023 ### Download OpenVPN client package
2027 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'dl client arch' }) {
2028 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2029 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2031 my $clientovpn = '' ;
2033 my $tempdir = tempdir
( CLEANUP
=> 1 );
2034 my $zippath = " $tempdir /" ;
2040 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2042 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-Client.zip" ;
2043 my $zippathname = " $zippath $zipname " ;
2044 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1].conf" ;
2045 my @ovsubnettemp = split ( /\./ , $confighash { $cgiparams { 'KEY' }}[ 27 ]);
2046 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
2048 my @remsubnet = split ( /\/ /, $confighash { $cgiparams { 'KEY' }}[ 8 ]);
2049 my $n2nfragment = '' ;
2051 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2052 flock CLIENTCONF
, 2 ;
2054 my $zip = Archive
:: Zip
-> new ();
2055 print CLIENTCONF
"# IPFire n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
2056 print CLIENTCONF
"# \n " ;
2057 print CLIENTCONF
"# User Security \n " ;
2058 print CLIENTCONF
"user nobody \n " ;
2059 print CLIENTCONF
"group nobody \n " ;
2060 print CLIENTCONF
"persist-tun \n " ;
2061 print CLIENTCONF
"persist-key \n " ;
2062 print CLIENTCONF
"script-security 2 \n " ;
2063 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
2064 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} \n " ;
2065 print CLIENTCONF
"float \n " ;
2066 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
2067 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
2068 print CLIENTCONF
"# Server Gateway Network \n " ;
2069 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
2070 print CLIENTCONF
"# tun Device \n " ;
2071 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \n " ;
2072 print CLIENTCONF
"# Port and Protokoll \n " ;
2073 print CLIENTCONF
"port $confighash { $cgiparams {'KEY'}}[29] \n " ;
2075 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'tcp' ) {
2076 print CLIENTCONF
"proto tcp-client \n " ;
2077 print CLIENTCONF
"# Packet size \n " ;
2078 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1400' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2079 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2082 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'udp' ) {
2083 print CLIENTCONF
"proto udp \n " ;
2084 print CLIENTCONF
"# Paketsize \n " ;
2085 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1500' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2086 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2087 if ( $confighash { $cgiparams { 'KEY' }}[ 24 ] ne '' ) { print CLIENTCONF
"fragment $confighash { $cgiparams {'KEY'}}[24] \n " ;}
2088 if ( $confighash { $cgiparams { 'KEY' }}[ 23 ] eq 'on' ) { print CLIENTCONF
"mssfix \n " ;}
2090 if (( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'yes' ) ||
2091 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'maybe' ) ||
2092 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'no' )) {
2093 if (( $confighash { $cgiparams { 'KEY' }}[ 23 ] ne 'on' ) || ( $confighash { $cgiparams { 'KEY' }}[ 24 ] eq '' )) {
2094 if ( $tunmtu eq '1500' ) {
2095 print CLIENTCONF
"mtu-disc $confighash { $cgiparams {'KEY'}}[38] \n " ;
2099 print CLIENTCONF
"ns-cert-type server \n " ;
2100 print CLIENTCONF
"# Auth. Client \n " ;
2101 print CLIENTCONF
"tls-client \n " ;
2102 print CLIENTCONF
"# Cipher \n " ;
2103 print CLIENTCONF
"cipher $confighash { $cgiparams {'KEY'}}[40] \n " ;
2104 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2105 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2106 $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 " ;
2108 if ( $confighash { $cgiparams { 'KEY' }}[ 39 ] eq '' ) {
2109 print CLIENTCONF
"# HMAC algorithm \n " ;
2110 print CLIENTCONF
"auth SHA1 \n " ;
2112 print CLIENTCONF
"# HMAC algorithm \n " ;
2113 print CLIENTCONF
"auth $confighash { $cgiparams {'KEY'}}[39] \n " ;
2115 if ( $confighash { $cgiparams { 'KEY' }}[ 30 ] eq 'on' ) {
2116 print CLIENTCONF
"# Enable Compression \n " ;
2117 print CLIENTCONF
"comp-lzo \r\n " ;
2119 print CLIENTCONF
"# Debug Level \n " ;
2120 print CLIENTCONF
"verb 3 \n " ;
2121 print CLIENTCONF
"# Tunnel check \n " ;
2122 print CLIENTCONF
"keepalive 10 60 \n " ;
2123 print CLIENTCONF
"# Start as daemon \n " ;
2124 print CLIENTCONF
"daemon $confighash { $cgiparams {'KEY'}}[1]n2n \n " ;
2125 print CLIENTCONF
"writepid /var/run/ $confighash { $cgiparams {'KEY'}}[1]n2n.pid \n " ;
2126 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
2127 if ( $confighash { $cgiparams { 'KEY' }}[ 22 ] eq '' ) { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[29] \n " }
2128 else { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[22] \n " };
2129 print CLIENTCONF
"# remsub $confighash { $cgiparams {'KEY'}}[11] \n " ;
2134 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2135 my $status = $zip -> writeToFileNamed ( $zippathname );
2137 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2138 @fileholder = < DLFILE
>;
2139 print "Content-Type:application/x-download \n " ;
2140 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2146 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.zip" ;
2147 my $zippathname = " $zippath $zipname " ;
2148 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.ovpn" ;
2154 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2155 flock CLIENTCONF
, 2 ;
2157 my $zip = Archive
:: Zip
-> new ();
2159 print CLIENTCONF
"#OpenVPN Client conf \r\n " ;
2160 print CLIENTCONF
"tls-client \r\n " ;
2161 print CLIENTCONF
"client \r\n " ;
2162 print CLIENTCONF
"nobind \r\n " ;
2163 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \r\n " ;
2164 print CLIENTCONF
"proto $vpnsettings {'DPROTOCOL'} \r\n " ;
2166 # Check if we are using fragment, mssfix or mtu-disc and set MTU to 1500
2167 # or use configured value.
2168 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' )
2169 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2170 elsif ( $vpnsettings { MSSFIX
} eq 'on' )
2171 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2172 elsif (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2173 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2174 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' ))
2175 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2177 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu $vpnsettings {'DMTU'} \r\n " ; }
2179 if ( $vpnsettings { 'ENABLED' } eq 'on' ){
2180 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2181 if ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2182 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Blue interface \r\n " ;
2183 print CLIENTCONF
";remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2185 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2186 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2187 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2189 } elsif ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2190 print CLIENTCONF
"remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2191 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2192 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2193 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2195 } elsif ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2196 print CLIENTCONF
"remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2199 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2200 print CLIENTCONF
"pkcs12 $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2201 $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 " ;
2203 print CLIENTCONF
"ca cacert.pem \r\n " ;
2204 print CLIENTCONF
"cert $confighash { $cgiparams {'KEY'}}[1]cert.pem \r\n " ;
2205 print CLIENTCONF
"key $confighash { $cgiparams {'KEY'}}[1].key \r\n " ;
2206 $zip -> addFile ( "${General::swroot}/ovpn/ca/cacert.pem" , "cacert.pem" ) or die "Can't add file cacert.pem \n " ;
2207 $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 " ;
2209 print CLIENTCONF
"cipher $vpnsettings {DCIPHER} \r\n " ;
2210 if ( $vpnsettings { 'DAUTH' } eq '' ) {
2211 print CLIENTCONF
"" ;
2213 print CLIENTCONF
"auth $vpnsettings {'DAUTH'} \r\n " ;
2215 if ( $vpnsettings { 'TLSAUTH' } eq 'on' ) {
2216 print CLIENTCONF
"tls-auth ta.key \r\n " ;
2217 $zip -> addFile ( "${General::swroot}/ovpn/certs/ta.key" , "ta.key" ) or die "Can't add file ta.key \n " ;
2219 if ( $vpnsettings { DCOMPLZO
} eq 'on' ) {
2220 print CLIENTCONF
"comp-lzo \r\n " ;
2222 print CLIENTCONF
"verb 3 \r\n " ;
2223 print CLIENTCONF
"ns-cert-type server \r\n " ;
2224 print CLIENTCONF
"tls-remote $vpnsettings {ROOTCERT_HOSTNAME} \r\n " ;
2225 if ( $vpnsettings { MSSFIX
} eq 'on' ) {
2226 print CLIENTCONF
"mssfix \r\n " ;
2228 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' ) {
2229 print CLIENTCONF
"fragment $vpnsettings {'FRAGMENT'} \r\n " ;
2232 # Check if a valid operating mode has been choosen and use it.
2233 if (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2234 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2235 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' )) {
2236 if (( $vpnsettings { MSSFIX
} ne 'on' ) || ( $vpnsettings { FRAGMENT
} eq '' )) {
2237 print CLIENTCONF
"mtu-disc $vpnsettings {'PMTU_DISCOVERY'} \r\n " ;
2242 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2243 my $status = $zip -> writeToFileNamed ( $zippathname );
2245 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2246 @fileholder = < DLFILE
>;
2247 print "Content-Type:application/x-download \n " ;
2248 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2256 ### Remove connection
2260 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
2261 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2262 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2264 if ( $confighash { $cgiparams { 'KEY' }}) {
2265 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2266 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2267 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2270 my $temp = `/usr/bin/openssl ca -revoke ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2276 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
2277 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
2278 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2282 if (- e
"${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) {
2283 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
2287 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
2288 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2290 # A.Marx CCD delete ccd files and routes
2293 if (- f
"${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" )
2295 unlink "${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" ;
2298 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2299 foreach my $key ( keys %ccdroutehash ) {
2300 if ( $ccdroutehash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2301 delete $ccdroutehash { $key };
2304 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2306 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2307 foreach my $key ( keys %ccdroute2hash ) {
2308 if ( $ccdroute2hash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2309 delete $ccdroute2hash { $key };
2312 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2319 delete $confighash { $cgiparams { 'KEY' }};
2320 my $temp2 = `/usr/bin/openssl ca -gencrl -out ${General::swroot}/ovpn/crls/cacrl.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2321 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2323 #&writeserverconf();
2325 $errormessage = $Lang :: tr
{ 'invalid key' };
2327 & General
:: firewall_reload
();
2330 ### Download PKCS12 file
2332 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
2333 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2335 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
2336 print "Content-Type: application/octet-stream \r\n\r\n " ;
2337 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
2341 ### Display certificate
2343 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
2344 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2346 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2347 & Header
:: showhttpheaders
();
2348 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2349 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2350 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate'}:" );
2351 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2352 $output = & Header
:: cleanhtml
( $output , "y" );
2353 print "<pre> $output </pre> \n " ;
2354 & Header
:: closebox
();
2355 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2356 & Header
:: closebigbox
();
2357 & Header
:: closepage
();
2362 ### Display Diffie-Hellman key
2364 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show dh' }) {
2366 if (! - e
"${General::swroot}/ovpn/ca/dh1024.pem" ) {
2367 $errormessage = $Lang :: tr
{ 'not present' };
2369 & Header
:: showhttpheaders
();
2370 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2371 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2372 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'dh'}:" );
2373 my $output = `/usr/bin/openssl dhparam -text -in ${General::swroot}/ovpn/ca/dh1024.pem` ;
2374 $output = & Header
:: cleanhtml
( $output , "y" );
2375 print "<pre> $output </pre> \n " ;
2376 & Header
:: closebox
();
2377 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2378 & Header
:: closebigbox
();
2379 & Header
:: closepage
();
2384 ### Display tls-auth key
2386 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show tls-auth key' }) {
2388 if (! - e
"${General::swroot}/ovpn/certs/ta.key" ) {
2389 $errormessage = $Lang :: tr
{ 'not present' };
2391 & Header
:: showhttpheaders
();
2392 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2393 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2394 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ta key'}:" );
2395 my $output = `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
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 Certificate Revoke List
2408 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show crl' }) {
2409 # &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash);
2411 if (! - e
"${General::swroot}/ovpn/crls/cacrl.pem" ) {
2412 $errormessage = $Lang :: tr
{ 'not present' };
2414 & Header
:: showhttpheaders
();
2415 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2416 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2417 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'crl'}:" );
2418 my $output = `/usr/bin/openssl crl -text -noout -in ${General::swroot}/ovpn/crls/cacrl.pem` ;
2419 $output = & Header
:: cleanhtml
( $output , "y" );
2420 print "<pre> $output </pre> \n " ;
2421 & Header
:: closebox
();
2422 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2423 & Header
:: closebigbox
();
2424 & Header
:: closepage
();
2429 ### Advanced Server Settings
2432 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced server' }) {
2437 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
2441 # if ($cgiparams{'CLIENT2CLIENT'} eq '') {
2442 # $cgiparams{'CLIENT2CLIENT'} = 'on';
2445 if ( $cgiparams { 'MAX_CLIENTS' } eq '' ) {
2446 $cgiparams { 'MAX_CLIENTS' } = '100' ;
2448 if ( $cgiparams { 'KEEPALIVE_1' } eq '' ) {
2449 $cgiparams { 'KEEPALIVE_1' } = '10' ;
2451 if ( $cgiparams { 'KEEPALIVE_2' } eq '' ) {
2452 $cgiparams { 'KEEPALIVE_2' } = '60' ;
2454 if ( $cgiparams { 'LOG_VERB' } eq '' ) {
2455 $cgiparams { 'LOG_VERB' } = '3' ;
2457 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
2458 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
2460 if ( $cgiparams { 'DAUTH' } eq '' ) {
2461 $cgiparams { 'DAUTH' } = 'SHA1' ;
2463 if ( $cgiparams { 'TLSAUTH' } eq '' ) {
2464 $cgiparams { 'TLSAUTH' } = 'off' ;
2466 $checked { 'CLIENT2CLIENT' }{ 'off' } = '' ;
2467 $checked { 'CLIENT2CLIENT' }{ 'on' } = '' ;
2468 $checked { 'CLIENT2CLIENT' }{ $cgiparams { 'CLIENT2CLIENT' }} = 'CHECKED' ;
2469 $checked { 'REDIRECT_GW_DEF1' }{ 'off' } = '' ;
2470 $checked { 'REDIRECT_GW_DEF1' }{ 'on' } = '' ;
2471 $checked { 'REDIRECT_GW_DEF1' }{ $cgiparams { 'REDIRECT_GW_DEF1' }} = 'CHECKED' ;
2472 $checked { 'MSSFIX' }{ 'off' } = '' ;
2473 $checked { 'MSSFIX' }{ 'on' } = '' ;
2474 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
2475 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
2476 $selected { 'LOG_VERB' }{ '0' } = '' ;
2477 $selected { 'LOG_VERB' }{ '1' } = '' ;
2478 $selected { 'LOG_VERB' }{ '2' } = '' ;
2479 $selected { 'LOG_VERB' }{ '3' } = '' ;
2480 $selected { 'LOG_VERB' }{ '4' } = '' ;
2481 $selected { 'LOG_VERB' }{ '5' } = '' ;
2482 $selected { 'LOG_VERB' }{ '6' } = '' ;
2483 $selected { 'LOG_VERB' }{ '7' } = '' ;
2484 $selected { 'LOG_VERB' }{ '8' } = '' ;
2485 $selected { 'LOG_VERB' }{ '9' } = '' ;
2486 $selected { 'LOG_VERB' }{ '10' } = '' ;
2487 $selected { 'LOG_VERB' }{ '11' } = '' ;
2488 $selected { 'LOG_VERB' }{ $cgiparams { 'LOG_VERB' }} = 'SELECTED' ;
2489 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
2490 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
2491 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
2492 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
2493 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
2494 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
2495 $checked { 'TLSAUTH' }{ 'off' } = '' ;
2496 $checked { 'TLSAUTH' }{ 'on' } = '' ;
2497 $checked { 'TLSAUTH' }{ $cgiparams { 'TLSAUTH' }} = 'CHECKED' ;
2499 & Header
:: showhttpheaders
();
2500 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
2501 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
2502 if ( $errormessage ) {
2503 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2504 print "<class name='base'> $errormessage \n " ;
2505 print " </class> \n " ;
2506 & Header
:: closebox
();
2508 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'advanced server' });
2510 <form method='post' enctype='multipart/form-data'>
2511 <table width='100%' border=0>
2513 <td colspan='4'><b> $Lang ::tr{'dhcp-options'}</b></td>
2516 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2519 <td class='base'>Domain</td>
2520 <td><input type='TEXT' name='DHCP_DOMAIN' value=' $cgiparams {'DHCP_DOMAIN'}' size='30' /></td>
2523 <td class='base'>DNS</td>
2524 <td><input type='TEXT' name='DHCP_DNS' value=' $cgiparams {'DHCP_DNS'}' size='30' /></td>
2527 <td class='base'>WINS</td>
2528 <td><input type='TEXT' name='DHCP_WINS' value=' $cgiparams {'DHCP_WINS'}' size='30' /></td>
2531 <td colspan='4'><b> $Lang ::tr{'ovpn routes push options'}</b></td>
2534 <td class='base'> $Lang ::tr{'ovpn routes push'}</td>
2536 <textarea name='ROUTES_PUSH' cols='26' rows='6' wrap='off'>
2540 if ( $cgiparams { 'ROUTES_PUSH' } ne '' )
2542 print $cgiparams { 'ROUTES_PUSH' };
2551 <table width='100%'>
2553 <td class'base'><b> $Lang ::tr{'misc-options'}</b></td>
2556 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2559 <td class='base'>Client-To-Client</td>
2560 <td><input type='checkbox' name='CLIENT2CLIENT' $checked {'CLIENT2CLIENT'}{'on'} /></td>
2563 <td class='base'>Redirect-Gateway def1</td>
2564 <td><input type='checkbox' name='REDIRECT_GW_DEF1' $checked {'REDIRECT_GW_DEF1'}{'on'} /></td>
2567 <td class='base'>Max-Clients</td>
2568 <td><input type='text' name='MAX_CLIENTS' value=' $cgiparams {'MAX_CLIENTS'}' size='10' /></td>
2571 <td class='base'>Keepalive <br />
2572 (ping/ping-restart)</td>
2573 <td><input type='TEXT' name='KEEPALIVE_1' value=' $cgiparams {'KEEPALIVE_1'}' size='10' /></td>
2574 <td><input type='TEXT' name='KEEPALIVE_2' value=' $cgiparams {'KEEPALIVE_2'}' size='10' /></td>
2577 <td class='base'>fragment <br></td>
2578 <td><input type='TEXT' name='FRAGMENT' value=' $cgiparams {'FRAGMENT'}' size='10' /></td>
2581 <td class='base'>mssfix</td>
2582 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
2583 <td> $Lang ::tr{'openvpn default'}: off</td>
2587 <td class='base'> $Lang ::tr{'ovpn mtu-disc'}</td>
2588 <td><input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}</td>
2589 <td><input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}</td>
2590 <td><input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}</td>
2591 <td><input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}</td>
2596 <table width='100%'>
2598 <td class'base'><b> $Lang ::tr{'log-options'}</b></td>
2601 <td width='20%'></td> <td width='30%'> </td><td width='25%'> </td><td width='25%'></td>
2604 <tr><td class='base'>VERB</td>
2605 <td><select name='LOG_VERB'>
2606 <option value='0' $selected {'LOG_VERB'}{'0'}>0</option>
2607 <option value='1' $selected {'LOG_VERB'}{'1'}>1</option>
2608 <option value='2' $selected {'LOG_VERB'}{'2'}>2</option>
2609 <option value='3' $selected {'LOG_VERB'}{'3'}>3</option>
2610 <option value='4' $selected {'LOG_VERB'}{'4'}>4</option>
2611 <option value='5' $selected {'LOG_VERB'}{'5'}>5</option>
2612 <option value='6' $selected {'LOG_VERB'}{'6'}>6</option>
2613 <option value='7' $selected {'LOG_VERB'}{'7'}>7</option>
2614 <option value='8' $selected {'LOG_VERB'}{'8'}>8</option>
2615 <option value='9' $selected {'LOG_VERB'}{'9'}>9</option>
2616 <option value='10' $selected {'LOG_VERB'}{'10'}>10</option>
2617 <option value='11' $selected {'LOG_VERB'}{'11'}>11</option>
2622 <table width='100%'>
2624 <td class'base'><b> $Lang ::tr{'ovpn crypt options'}</b></td>
2627 <td width='20%'></td> <td width='30%'> </td><td width='25%'> </td><td width='25%'></td>
2629 <tr><td class='base'> $Lang ::tr{'ovpn ha'}</td>
2630 <td><select name='DAUTH'>
2631 <option value='whirlpool' $selected {'DAUTH'}{'whirlpool'}>Whirlpool (512 $Lang ::tr{'bit'})</option>
2632 <option value='SHA512' $selected {'DAUTH'}{'SHA512'}>SHA2 (512 $Lang ::tr{'bit'})</option>
2633 <option value='SHA384' $selected {'DAUTH'}{'SHA384'}>SHA2 (384 $Lang ::tr{'bit'})</option>
2634 <option value='SHA256' $selected {'DAUTH'}{'SHA256'}>SHA2 (256 $Lang ::tr{'bit'})</option>
2635 <option value='SHA1' $selected {'DAUTH'}{'SHA1'}>SHA1 (160 $Lang ::tr{'bit'})</option>
2638 <td> $Lang ::tr{'openvpn default'}: <span class="base">SHA1 (160 $Lang ::tr{'bit'})</span></td>
2642 <table width='100%'>
2644 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2648 <td class='base'>HMAC tls-auth</td>
2649 <td><input type='checkbox' name='TLSAUTH' $checked {'TLSAUTH'}{'on'} /></td>
2654 if ( - e
"/var/run/openvpn.pid" ){
2655 print " <br><b><font color='#990000'> $Lang ::tr{'attention'}:</b></font><br>
2656 $Lang ::tr{'server restart'}<br><br>
2659 <table width='100%'>
2662 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' disabled='disabled' /></td>
2663 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2675 <table width='100%'>
2678 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' /></td>
2679 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2687 & Header
:: closebox
();
2688 # print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'>$Lang::tr{'back'}</a></div>";
2689 & Header
:: closebigbox
();
2690 & Header
:: closepage
();
2694 # A.Marx CCD Add,delete or edit CCD net
2696 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd net' } ||
2697 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' } ||
2698 $cgiparams { 'ACTION' } eq "kill" ||
2699 $cgiparams { 'ACTION' } eq "edit" ||
2700 $cgiparams { 'ACTION' } eq 'editsave' ){
2701 & Header
:: showhttpheaders
();
2702 & Header
:: openpage
( $Lang :: tr
{ 'ccd net' }, 1 , '' );
2703 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2705 if ( $cgiparams { 'ACTION' } eq "kill" ){
2706 & delccdnet
( $cgiparams { 'net' });
2709 if ( $cgiparams { 'ACTION' } eq 'editsave' ){
2710 my ( $a , $b ) = split ( /\|/ , $cgiparams { 'ccdname' });
2711 if ( $a ne $b ){ & modccdnet
( $a , $b );}
2712 $cgiparams { 'ccdname' }= '' ;
2713 $cgiparams { 'ccdsubnet' }= '' ;
2716 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' }) {
2717 & addccdnet
( $cgiparams { 'ccdname' }, $cgiparams { 'ccdsubnet' });
2719 if ( $errormessage ) {
2720 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2721 print "<class name='base'> $errormessage " ;
2722 print " </class>" ;
2723 & Header
:: closebox
();
2725 if ( $cgiparams { 'ACTION' } eq "edit" ){
2727 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd modify' });
2730 <table width='100%' border='0'>
2731 <tr><form method='post'>
2732 <td width='10%' nowrap='nowrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2733 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' readonly='readonly' /></td></tr>
2734 <tr><td colspan='4' align='right'><hr><input type='submit' value=' $Lang ::tr{'save'}' /><input type='hidden' name='ACTION' value='editsave'/>
2735 <input type='hidden' name='ccdname' value=' $cgiparams {'ccdname'}'/><input type='submit' value=' $Lang ::tr{'cancel'}' />
2740 & Header
:: closebox
();
2742 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2744 <table width='100%' border='0' cellpadding='0' cellspacing='1'>
2746 <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>
2751 if (! - e
"/var/run/openvpn.pid" ){
2752 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd add' });
2754 <table width='100%' border='0'>
2755 <tr><form method='post'>
2756 <td colspan='4'> $Lang ::tr{'ccd hint'}<br><br></td></tr>
2758 <td width='10%' nowrap='nwrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2759 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' /></td></tr>
2760 <tr><td colspan=4><hr /></td></tr><tr>
2761 <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>
2765 & Header
:: closebox
();
2767 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2768 if ( - e
"/var/run/openvpn.pid" ){
2769 print "<b> $Lang ::tr{'attention'}:</b><br>" ;
2770 print " $Lang ::tr{'ccd noaddnet'}<br><hr>" ;
2774 <table width='100%' cellpadding='0' cellspacing='1'>
2776 <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>
2781 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
2784 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
2785 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
2787 my $ccdhosts = & hostsinnet
( $ccdconf [ 0 ]);
2788 if ( $count % 2 ){ print " <tr bgcolor=' $color {'color22'}'>" ;}
2789 else { print " <tr bgcolor=' $color {'color20'}'>" ;}
2790 print "<td> $ccdconf [0]</td><td align='center'> $ccdconf [1]</td><td align='center'> $ccdhosts /" .(& ccdmaxclients
( $ccdconf [ 1 ])+ 1 ). "</td><td>" ;
2792 <form method='post' />
2793 <input type='image' src='/images/edit.gif' align='middle' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
2794 <input type='hidden' name='ACTION' value='edit'/>
2795 <input type='hidden' name='ccdname' value=' $ccdconf [0]' />
2796 <input type='hidden' name='ccdsubnet' value=' $ccdconf [1]' />
2798 <form method='post' />
2799 <td><input type='hidden' name='ACTION' value='kill'/>
2800 <input type='hidden' name='number' value=' $count ' />
2801 <input type='hidden' name='net' value=' $ccdconf [0]' />
2802 <input type='image' src='/images/delete.gif' align='middle' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' /></form></td></tr>
2806 print "</table></form>" ;
2807 & Header
:: closebox
();
2808 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2809 & Header
:: closebigbox
();
2810 & Header
:: closepage
();
2816 ### Openvpn Connections Statistics
2818 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ovpn con stat' }) {
2819 & Header
:: showhttpheaders
();
2820 & Header
:: openpage
( $Lang :: tr
{ 'ovpn con stat' }, 1 , '' );
2821 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2822 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ovpn con stat' });
2825 # <td><b>$Lang::tr{'protocol'}</b></td>
2826 # protocol temp removed
2828 <table width='100%' cellpadding='2' cellspacing='0' class='tbl'>
2830 <th><b> $Lang ::tr{'common name'}</b></th>
2831 <th><b> $Lang ::tr{'real address'}</b></th>
2832 <th><b> $Lang ::tr{'virtual address'}</b></th>
2833 <th><b> $Lang ::tr{'loged in at'}</b></th>
2834 <th><b> $Lang ::tr{'bytes sent'}</b></th>
2835 <th><b> $Lang ::tr{'bytes received'}</b></th>
2836 <th><b> $Lang ::tr{'last activity'}</b></th>
2840 my $filename = "/var/log/ovpnserver.log" ;
2841 open ( FILE
, $filename ) or die 'Unable to open config file.' ;
2842 my @current = < FILE
>;
2851 my %userlookup = ();
2852 foreach my $line ( @current )
2855 if ( $line =~ /^Updated,(.+)/ ){
2856 @match = split ( /^Updated,(.+)/ , $line );
2857 $status = $match [ 1 ];
2860 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
2861 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
2862 if ( $match [ 1 ] ne "Common Name" ) {
2864 $userlookup { $match [ 2 ]} = $uid ;
2865 $users [ $uid ]{ 'CommonName' } = $match [ 1 ];
2866 $users [ $uid ]{ 'RealAddress' } = $match [ 2 ];
2867 $users [ $uid ]{ 'BytesReceived' } = & sizeformat
( $match [ 3 ]);
2868 $users [ $uid ]{ 'BytesSent' } = & sizeformat
( $match [ 4 ]);
2869 $users [ $uid ]{ 'Since' } = $match [ 5 ];
2870 $users [ $uid ]{ 'Proto' } = $proto ;
2874 if ( $line =~ /^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ ) {
2875 @match = split ( m/^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ , $line );
2876 if ( $match [ 1 ] ne "Virtual Address" ) {
2877 $address = $match [ 3 ];
2878 #find the uid in the lookup table
2879 $uid = $userlookup { $address };
2880 $users [ $uid ]{ 'VirtualAddress' } = $match [ 1 ];
2881 $users [ $uid ]{ 'LastRef' } = $match [ 4 ];
2887 for ( my $idx = 1 ; $idx <= $user2 ; $idx ++){
2890 $col = "bgcolor=' $color {'color22'}'" ;
2893 $col = "bgcolor=' $color {'color20'}'" ;
2895 print "<td align='left' $col > $users [ $idx -1]{'CommonName'}</td>" ;
2896 print "<td align='left' $col > $users [ $idx -1]{'RealAddress'}</td>" ;
2897 print "<td align='left' $col > $users [ $idx -1]{'VirtualAddress'}</td>" ;
2898 print "<td align='left' $col > $users [ $idx -1]{'Since'}</td>" ;
2899 print "<td align='left' $col > $users [ $idx -1]{'BytesSent'}</td>" ;
2900 print "<td align='left' $col > $users [ $idx -1]{'BytesReceived'}</td>" ;
2901 print "<td align='left' $col > $users [ $idx -1]{'LastRef'}</td>" ;
2907 <table width='100%' border='0' cellpadding='2' cellspacing='0'>
2912 <tr><td align='center' > $Lang ::tr{'the statistics were last updated at'} <b> $status </b></td></tr>
2916 & Header
:: closebox
();
2917 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2918 & Header
:: closebigbox
();
2919 & Header
:: closepage
();
2923 ### Download Certificate
2925 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
2926 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2928 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2929 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \r\n " ;
2930 print "Content-Type: application/octet-stream \r\n\r\n " ;
2931 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2936 ### Enable/Disable connection
2939 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
2941 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2942 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2944 if ( $confighash { $cgiparams { 'KEY' }}) {
2945 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
2946 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
2947 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2948 #&writeserverconf();
2949 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2950 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2951 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
2954 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
2955 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2956 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2957 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2959 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2960 #&writeserverconf();
2963 $errormessage = $Lang :: tr
{ 'invalid key' };
2967 ### Restart connection
2969 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
2970 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2971 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2973 if ( $confighash { $cgiparams { 'KEY' }}) {
2974 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2975 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2976 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
2979 $errormessage = $Lang :: tr
{ 'invalid key' };
2983 ### Remove connection
2985 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
2986 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2987 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2989 if ( $confighash { $cgiparams { 'KEY' }}) {
2990 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2991 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
2992 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
2994 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
2995 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2996 delete $confighash { $cgiparams { 'KEY' }};
2997 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2998 #&writeserverconf();
3000 $errormessage = $Lang :: tr
{ 'invalid key' };
3005 ### Choose between adding a host-net or net-net connection
3012 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
3013 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3014 & Header
:: showhttpheaders
();
3015 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
3016 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
3017 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection type' });
3019 if ( - s
"${General::swroot}/ovpn/settings" ) {
3022 <b> $Lang ::tr{'connection type'}:</b><br />
3023 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
3024 <tr><td><input type='radio' name='TYPE' value='host' checked /></td>
3025 <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
3026 <tr><td><input type='radio' name='TYPE' value='net' /></td>
3027 <td class='base'> $Lang ::tr{'net to net vpn'}</td></tr>
3028 <tr><td><input type='radio' name='TYPE' value='net2net' /></td>
3029 <td class='base'> $Lang ::tr{'net to net vpn'} (Upload Client Package)</td></tr>
3030 <tr><td> </td><td class='base'><input type='file' name='FH' size='30'></td></tr>
3031 <tr><td> </td><td>Import Connection Name <img src='/blob.gif' /></td></tr>
3032 <tr><td> </td><td class='base'><input type='text' name='n2nname' size='30'> $Lang ::tr{'openvpn default'}: Client Packagename</td></tr>
3033 <tr><td colspan='3'><hr /></td></tr>
3034 <tr><td align='right' colspan='3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
3035 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
3043 <b> $Lang ::tr{'connection type'}:</b><br />
3044 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
3045 <tr><td><input type='radio' name='TYPE' value='host' checked /></td> <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
3046 <tr><td align='right' colspan'3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
3053 & Header
:: closebox
();
3054 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3055 & Header
:: closebigbox
();
3056 & Header
:: closepage
();
3063 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2net' )){
3067 my $uplconffilename = '' ;
3068 my $uplconffilename2 = '' ;
3069 my $uplp12name = '' ;
3070 my $uplp12name2 = '' ;
3077 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3079 # Check if a file is uploaded
3081 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3082 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3086 # Move uploaded IPfire n2n package to temporary file
3088 ( my $fh , my $filename ) = tempfile
( );
3089 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3094 my $zip = Archive
:: Zip
-> new ();
3095 my $zipName = $filename ;
3096 my $status = $zip -> read ( $zipName );
3097 if ( $status != AZ_OK
) {
3098 $errormessage = "Read of $zipName failed \n " ;
3102 my $tempdir = tempdir
( CLEANUP
=> 1 );
3103 my @files = $zip -> memberNames ();
3105 $zip -> extractMemberWithoutPaths ( $_ , " $tempdir / $_ " );
3107 my $countfiles = @files ;
3109 # Check if we have not more then 2 files
3111 if ( $countfiles == 2 ){
3113 if ( $_ =~ /.conf$/ ){
3114 $uplconffilename = $_ ;
3116 if ( $_ =~ /.p12$/ ){
3120 if (( $uplconffilename eq '' ) || ( $uplp12name eq '' )){
3121 $errormessage = "Either no *.conf or no *.p12 file found \n " ;
3125 open ( FILE
, " $tempdir / $uplconffilename " ) or die 'Unable to open*.conf file' ;
3126 @firen2nconf = < FILE
>;
3128 chomp ( @firen2nconf );
3132 $errormessage = "Filecount does not match only 2 files are allowed \n " ;
3140 if ( $cgiparams { 'n2nname' } ne '' ){
3142 $uplconffilename2 = " $cgiparams {'n2nname'}.conf" ;
3143 $uplp12name2 = " $cgiparams {'n2nname'}.p12" ;
3144 $n2nname [ 0 ] = $cgiparams { 'n2nname' };
3145 my @n2nname2 = split ( /\./ , $uplconffilename );
3146 $n2nname2 [ 0 ] =~ s/\n|\r//g ;
3147 my $input1 = "${General::swroot}/ovpn/certs/ $uplp12name " ;
3148 my $output1 = "${General::swroot}/ovpn/certs/ $uplp12name2 " ;
3149 my $input2 = " $n2nname2 [0]n2n" ;
3150 my $output2 = " $n2nname [0]n2n" ;
3151 my $filename = " $tempdir / $uplconffilename " ;
3152 open ( FILE
, "< $filename " ) or die 'Unable to open config file.' ;
3153 my @current = < FILE
>;
3155 foreach ( @current ) { s/$input1/$output1/g ;}
3156 foreach ( @current ) { s/$input2/$output2/g ;}
3157 open ( OUT
, "> $filename " ) || die 'Unable to open config file.' ;
3162 $uplconffilename2 = $uplconffilename ;
3163 $uplp12name2 = $uplp12name ;
3164 @n2nname = split ( /\./ , $uplconffilename );
3165 $n2nname [ 0 ] =~ s/\n|\r//g ;
3167 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
3168 unless (- d
"${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" , 0770 or die "Unable to create dir $!" ;}
3170 move
( " $tempdir / $uplconffilename " , "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $uplconffilename2 " );
3173 $errormessage = "*.conf move failed: $!" ;
3178 move
( " $tempdir / $uplp12name " , "${General::swroot}/ovpn/certs/ $uplp12name2 " );
3179 chmod 0600 , "${General::swroot}/ovpn/certs/ $uplp12name " ;
3182 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
3191 my @n2nmtudisc = split ( / / , ( grep { /^mtu-disc/ } @firen2nconf )[ 0 ]);
3192 my @n2nproto2 = split ( / / , ( grep { /^proto/ } @firen2nconf )[ 0 ]);
3193 my @n2nproto = split ( /-/ , $n2nproto2 [ 1 ]);
3194 my @n2nport = split ( / / , ( grep { /^port/ } @firen2nconf )[ 0 ]);
3195 my @n2ntunmtu = split ( / / , ( grep { /^tun-mtu/ } @firen2nconf )[ 0 ]);
3196 my @n2ncomplzo = grep { /^comp-lzo/ } @firen2nconf ;
3197 if ( $n2ncomplzo [ 0 ] =~ /comp-lzo/ ){ $complzoactive = "on" ;} else { $complzoactive = "off" ;}
3198 my @n2nmssfix = grep { /^mssfix/ } @firen2nconf ;
3199 if ( $n2nmssfix [ 0 ] =~ /mssfix/ ){ $mssfixactive = "on" ;} else { $mssfixactive = "off" ;}
3200 #my @n2nmssfix = split(/ /, (grep { /^mssfix/ } @firen2nconf)[0]);
3201 my @n2nfragment = split ( / / , ( grep { /^fragment/ } @firen2nconf )[ 0 ]);
3202 my @n2nremote = split ( / / , ( grep { /^remote/ } @firen2nconf )[ 0 ]);
3203 my @n2novpnsuball = split ( / / , ( grep { /^ifconfig/ } @firen2nconf )[ 0 ]);
3204 my @n2novpnsub = split ( /\./ , $n2novpnsuball [ 1 ]);
3205 my @n2nremsub = split ( / / , ( grep { /^route/ } @firen2nconf )[ 0 ]);
3206 my @n2nmgmt = split ( / / , ( grep { /^management/ } @firen2nconf )[ 0 ]);
3207 my @n2nlocalsub = split ( / / , ( grep { /^# remsub/ } @firen2nconf )[ 0 ]);
3208 my @n2ncipher = split ( / / , ( grep { /^cipher/ } @firen2nconf )[ 0 ]);
3209 my @n2nauth = split ( / / , ( grep { /^auth/ } @firen2nconf )[ 0 ]);;
3212 # m.a.d delete CR and LF from arrays for this chomp doesnt work
3215 $n2nremote [ 1 ] =~ s/\n|\r//g ;
3216 $n2novpnsub [ 0 ] =~ s/\n|\r//g ;
3217 $n2novpnsub [ 1 ] =~ s/\n|\r//g ;
3218 $n2novpnsub [ 2 ] =~ s/\n|\r//g ;
3219 $n2nproto [ 0 ] =~ s/\n|\r//g ;
3220 $n2nport [ 1 ] =~ s/\n|\r//g ;
3221 $n2ntunmtu [ 1 ] =~ s/\n|\r//g ;
3222 $n2nremsub [ 1 ] =~ s/\n|\r//g ;
3223 $n2nremsub [ 2 ] =~ s/\n|\r//g ;
3224 $n2nlocalsub [ 2 ] =~ s/\n|\r//g ;
3225 $n2nfragment [ 1 ] =~ s/\n|\r//g ;
3226 $n2nmgmt [ 2 ] =~ s/\n|\r//g ;
3227 $n2nmtudisc [ 1 ] =~ s/\n|\r//g ;
3228 $n2ncipher [ 1 ] =~ s/\n|\r//g ;
3229 $n2nauth [ 1 ] =~ s/\n|\r//g ;
3230 chomp ( $complzoactive );
3231 chomp ( $mssfixactive );
3238 # Check if there is no other entry with this name
3241 foreach my $dkey ( keys %confighash ) {
3242 if ( $confighash { $dkey }[ 1 ] eq $n2nname [ 0 ]) {
3243 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3244 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3245 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3246 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3252 # Check if OpenVPN Subnet is valid
3255 foreach my $dkey ( keys %confighash ) {
3256 if ( $confighash { $dkey }[ 27 ] eq " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ) {
3257 $errormessage = 'The OpenVPN Subnet is already in use' ;
3258 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3259 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3260 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3266 # Check if Dest Port is vaild
3269 foreach my $dkey ( keys %confighash ) {
3270 if ( $confighash { $dkey }[ 29 ] eq $n2nport [ 1 ] ) {
3271 $errormessage = 'The OpenVPN Port is already in use' ;
3272 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3273 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3274 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3281 $key = & General
:: findhasharraykey
( \
%confighash );
3283 foreach my $i ( 0 .. 42 ) { $confighash { $key }[ $i ] = "" ;}
3285 $confighash { $key }[ 0 ] = 'off' ;
3286 $confighash { $key }[ 1 ] = $n2nname [ 0 ];
3287 $confighash { $key }[ 2 ] = $n2nname [ 0 ];
3288 $confighash { $key }[ 3 ] = 'net' ;
3289 $confighash { $key }[ 4 ] = 'cert' ;
3290 $confighash { $key }[ 6 ] = 'client' ;
3291 $confighash { $key }[ 8 ] = $n2nlocalsub [ 2 ];
3292 $confighash { $key }[ 10 ] = $n2nremote [ 1 ];
3293 $confighash { $key }[ 11 ] = " $n2nremsub [1]/ $n2nremsub [2]" ;
3294 $confighash { $key }[ 22 ] = $n2nmgmt [ 2 ];
3295 $confighash { $key }[ 23 ] = $mssfixactive ;
3296 $confighash { $key }[ 24 ] = $n2nfragment [ 1 ];
3297 $confighash { $key }[ 25 ] = 'IPFire n2n Client' ;
3298 $confighash { $key }[ 26 ] = 'red' ;
3299 $confighash { $key }[ 27 ] = " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ;
3300 $confighash { $key }[ 28 ] = $n2nproto [ 0 ];
3301 $confighash { $key }[ 29 ] = $n2nport [ 1 ];
3302 $confighash { $key }[ 30 ] = $complzoactive ;
3303 $confighash { $key }[ 31 ] = $n2ntunmtu [ 1 ];
3304 $confighash { $key }[ 38 ] = $n2nmtudisc [ 1 ];
3305 $confighash { $key }[ 39 ] = $n2nauth [ 1 ];
3306 $confighash { $key }[ 40 ] = $n2ncipher [ 1 ];
3307 $confighash { $key }[ 41 ] = 'disabled' ;
3309 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3313 & Header
:: showhttpheaders
();
3314 & Header
:: openpage
( 'Validate imported configuration' , 1 , '' );
3315 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
3316 if ( $errormessage ) {
3317 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
3318 print "<class name='base'> $errormessage " ;
3319 print " </class>" ;
3320 & Header
:: closebox
();
3324 & Header
:: openbox
( '100%' , 'LEFT' , 'import ipfire net2net config' );
3326 if ( $errormessage eq '' ){
3328 <!-- ipfire net2net config gui -->
3329 <table width='100%'>
3330 <tr><td width='25%'> </td><td width='25%'> </td></tr>
3331 <tr><td class='boldbase'> $Lang ::tr{'name'}:</td><td><b> $n2nname [0]</b></td></tr>
3332 <tr><td> </td><td> </td></tr>
3333 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td><td><b> $confighash { $key }[6]</b></td></tr>
3334 <tr><td class='boldbase' nowrap='nowrap'>Remote Host </td><td><b> $confighash { $key }[10]</b></td></tr>
3335 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td><td><b> $confighash { $key }[8]</b></td></tr>
3336 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}:</td><td><b> $confighash { $key }[11]</b></td></tr>
3337 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td><td><b> $confighash { $key }[27]</b></td></tr>
3338 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td><td><b> $confighash { $key }[28]</b></td></tr>
3339 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'destination port'}:</td><td><b> $confighash { $key }[29]</b></td></tr>
3340 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td><td><b> $confighash { $key }[30]</b></td></tr>
3341 <tr><td class='boldbase' nowrap='nowrap'>MSSFIX:</td><td><b> $confighash { $key }[23]</b></td></tr>
3342 <tr><td class='boldbase' nowrap='nowrap'>Fragment:</td><td><b> $confighash { $key }[24]</b></td></tr>
3343 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'}</td><td><b> $confighash { $key }[31]</b></td></tr>
3344 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td><td><b> $confighash { $key }[38]</b></td></tr>
3345 <tr><td class='boldbase' nowrap='nowrap'>Management Port </td><td><b> $confighash { $key }[22]</b></td></tr>
3346 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn hmac'}:</td><td><b> $confighash { $key }[39]</b></td></tr>
3347 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td><td><b> $confighash { $key }[40]</b></td></tr>
3348 <tr><td> </td><td> </td></tr>
3352 & Header
:: closebox
();
3355 if ( $errormessage ) {
3356 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3358 print "<div align='center'><form method='post' ENCTYPE='multipart/form-data'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />" ;
3359 print "<input type='hidden' name='TYPE' value='net2netakn' />" ;
3360 print "<input type='hidden' name='KEY' value=' $key ' />" ;
3361 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
3363 & Header
:: closebigbox
();
3364 & Header
:: closepage
();
3369 ### Accept IPFire n2n Package Settings
3372 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3375 ### Discard and Rollback IPFire n2n Package Settings
3378 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'cancel' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3380 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3382 if ( $confighash { $cgiparams { 'KEY' }}) {
3384 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
3385 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
3386 unlink ( $certfile ) or die "Removing $certfile fail: $!" ;
3387 unlink ( $conffile ) or die "Removing $conffile fail: $!" ;
3388 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
3389 delete $confighash { $cgiparams { 'KEY' }};
3390 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3393 $errormessage = $Lang :: tr
{ 'invalid key' };
3403 ### Adding a new connection
3405 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
3406 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
3407 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
3409 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3410 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
3411 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3413 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
3414 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
3415 $errormessage = $Lang :: tr
{ 'invalid key' };
3418 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
3419 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
3420 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
3421 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
3422 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
3423 $cgiparams { 'SIDE' } = $confighash { $cgiparams { 'KEY' }}[ 6 ];
3424 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
3425 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
3426 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
3427 $cgiparams { 'OVPN_MGMT' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
3428 $cgiparams { 'MSSFIX' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
3429 $cgiparams { 'FRAGMENT' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
3430 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
3431 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
3432 $cgiparams { 'OVPN_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
3433 $cgiparams { 'PROTOCOL' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
3434 $cgiparams { 'DEST_PORT' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
3435 $cgiparams { 'COMPLZO' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
3436 $cgiparams { 'MTU' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
3437 $cgiparams { 'CHECK1' } = $confighash { $cgiparams { 'KEY' }}[ 32 ];
3438 $name = $cgiparams { 'CHECK1' } ;
3439 $cgiparams { $name } = $confighash { $cgiparams { 'KEY' }}[ 33 ];
3440 $cgiparams { 'RG' } = $confighash { $cgiparams { 'KEY' }}[ 34 ];
3441 $cgiparams { 'CCD_DNS1' } = $confighash { $cgiparams { 'KEY' }}[ 35 ];
3442 $cgiparams { 'CCD_DNS2' } = $confighash { $cgiparams { 'KEY' }}[ 36 ];
3443 $cgiparams { 'CCD_WINS' } = $confighash { $cgiparams { 'KEY' }}[ 37 ];
3444 $cgiparams { 'PMTU_DISCOVERY' } = $confighash { $cgiparams { 'KEY' }}[ 38 ];
3445 $cgiparams { 'DAUTH' } = $confighash { $cgiparams { 'KEY' }}[ 39 ];
3446 $cgiparams { 'DCIPHER' } = $confighash { $cgiparams { 'KEY' }}[ 40 ];
3447 $cgiparams { 'TLSAUTH' } = $confighash { $cgiparams { 'KEY' }}[ 41 ];
3448 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
3449 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
3451 #A.Marx CCD check iroute field and convert it to decimal
3452 if ( $cgiparams { 'TYPE' } eq 'host' ) {
3454 my %ccdroutehash =();
3458 if ( $cgiparams { 'IR' } ne '' ){
3459 @temp = split ( " \n " , $cgiparams { 'IR' });
3460 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3462 foreach my $key ( keys %ccdroutehash ) {
3463 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3465 delete $ccdroutehash { $key };
3467 $keypoint = & General
:: findhasharraykey
( \
%ccdroutehash );
3470 $ccdroutehash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3473 foreach $val ( @temp ){
3476 #check if iroute exists in ccdroute or if new iroute is part of an existing one
3477 foreach my $key ( keys %ccdroutehash ) {
3478 foreach my $oldiroute ( 1 .. $ #{$ccdroutehash{$key}}){
3479 if ( $ccdroutehash { $key }[ $oldiroute ] eq " $val " ) {
3480 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3483 my ( $ip1 , $cidr1 ) = split ( /\/ /, $val );
3484 $ip1 = & General
:: getnetworkip
( $ip1 ,& General
:: iporsubtocidr
( $cidr1 ));
3485 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $oldiroute ]);
3486 if (& General
:: IpInSubnet
( $ip1 , $ip2 , $cidr2 )){
3487 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3493 if (!& General
:: validipandmask
( $val )){
3494 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3497 ( $ip , $cidr ) = split ( /\/ /, $val );
3498 $ip =& General
:: getnetworkip
( $ip ,& General
:: iporsubtocidr
( $cidr ));
3499 $cidr =& General
:: iporsubtodec
( $cidr );
3500 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3504 #check for existing network IP's
3505 if (& General
:: IpInSubnet
( $ip , $netsettings { GREEN_NETADDRESS
}, $netsettings { GREEN_NETMASK
}) && $netsettings { GREEN_NETADDRESS
} ne '0.0.0.0' )
3507 $errormessage = $Lang :: tr
{ 'ccd err green' };
3509 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { RED_NETADDRESS
}, $netsettings { RED_NETMASK
}) && $netsettings { RED_NETADDRESS
} ne '0.0.0.0' )
3511 $errormessage = $Lang :: tr
{ 'ccd err red' };
3513 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { BLUE_NETADDRESS
}, $netsettings { BLUE_NETMASK
}) && $netsettings { BLUE_NETADDRESS
} ne '0.0.0.0' && $netsettings { BLUE_NETADDRESS
} gt '' )
3515 $errormessage = $Lang :: tr
{ 'ccd err blue' };
3517 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { ORANGE_NETADDRESS
}, $netsettings { ORANGE_NETMASK
}) && $netsettings { ORANGE_NETADDRESS
} ne '0.0.0.0' && $netsettings { ORANGE_NETADDRESS
} gt '' )
3519 $errormessage = $Lang :: tr
{ 'ccd err orange' };
3523 if (& General
:: validipandmask
( $val )){
3524 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3526 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $ip / $cidr )" ;
3531 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3534 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3535 foreach my $key ( keys %ccdroutehash ) {
3536 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3537 delete $ccdroutehash { $key };
3538 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3544 #check route field and convert it to decimal
3547 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3549 foreach my $key ( keys %ccdroute2hash ) {
3550 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3552 delete $ccdroute2hash { $key };
3554 $keypoint = & General
:: findhasharraykey
( \
%ccdroute2hash );
3555 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3559 $ccdroute2hash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3560 if ( $cgiparams { 'IFROUTE' } eq '' ){ $cgiparams { 'IFROUTE' } = $Lang :: tr
{ 'ccd none' };}
3561 @temp = split ( /\|/ , $cgiparams { 'IFROUTE' });
3563 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%ownnet );
3564 foreach $val ( @temp ){
3567 if ( $val eq $Lang :: tr
{ 'green' })
3569 $val = $ownnet { GREEN_NETADDRESS
}. "/" . $ownnet { GREEN_NETMASK
};
3571 if ( $val eq $Lang :: tr
{ 'blue' })
3573 $val = $ownnet { BLUE_NETADDRESS
}. "/" . $ownnet { BLUE_NETMASK
};
3575 if ( $val eq $Lang :: tr
{ 'orange' })
3577 $val = $ownnet { ORANGE_NETADDRESS
}. "/" . $ownnet { ORANGE_NETMASK
};
3579 my ( $ip , $cidr ) = split ( /\/ /, $val );
3581 if ( $val ne $Lang :: tr
{ 'ccd none' })
3583 if (! & check_routes_push
( $val )){ $errormessage = $errormessage . "Route $val " . $Lang :: tr
{ 'ccd err routeovpn2' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3584 if (! & check_ccdroute
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err inuse' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3585 if (! & check_ccdconf
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err routeovpn' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3586 if (& General
:: validipandmask
( $val )){
3587 $val = $ip . "/" .& General
:: iporsubtodec
( $cidr );
3588 $ccdroute2hash { $keypoint }[ $i ] = $val ;
3590 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3594 $ccdroute2hash { $keypoint }[ $i ]= '' ;
3598 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3601 if ( $cgiparams { 'CCD_DNS1' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS1' })) {
3602 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 1" ;
3606 if ( $cgiparams { 'CCD_DNS2' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS2' })) {
3607 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 2" ;
3611 if ( $cgiparams { 'CCD_WINS' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_WINS' })) {
3612 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp wins' };
3620 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
3621 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
3622 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3623 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3624 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3630 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
3631 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
3632 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3633 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3634 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3639 if ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
3640 $errormessage = $Lang :: tr
{ 'name is invalid' };
3641 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3642 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3643 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3648 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
3649 $errormessage = $Lang :: tr
{ 'name too long' };
3650 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3651 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3652 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3661 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3662 if ( $cgiparams { 'DEST_PORT' } eq $vpnsettings { 'DDEST_PORT' }) {
3663 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3664 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3665 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3669 foreach my $key ( sort keys %confighash ){
3670 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 ])){
3671 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3672 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3673 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3677 if ( $cgiparams { 'DEST_PORT' } eq '' ) {
3678 $errormessage = $Lang :: tr
{ 'invalid port' };
3679 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3680 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3684 # Check if the input for the transfer net is valid.
3685 if (!& General
:: validipandmask
( $cgiparams { 'OVPN_SUBNET' })){
3686 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
3687 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3688 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3692 if ( $cgiparams { 'OVPN_SUBNET' } eq $vpnsettings { 'DOVPN_SUBNET' }) {
3693 $errormessage = $Lang :: tr
{ 'openvpn subnet is used' };
3694 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3695 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3699 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3700 $errormessage = $Lang :: tr
{ 'openvpn mssfix allowed with udp' };
3701 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3702 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3706 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'FRAGMENT' } ne '' )) {
3707 $errormessage = $Lang :: tr
{ 'openvpn fragment allowed with udp' };
3708 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3709 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3713 if ( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) {
3714 if (( $cgiparams { 'FRAGMENT' } ne '' ) || ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3715 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
3716 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3717 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3722 if (( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) && ( $cgiparams { 'MTU' } ne '1500' )) {
3723 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc and mtu not 1500' };
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 if ( & validdotmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3730 $errormessage = $Lang :: tr
{ 'openvpn prefix local subnet' };
3731 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3732 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3736 if ( & validdotmask
( $cgiparams { 'OVPN_SUBNET' })) {
3737 $errormessage = $Lang :: tr
{ 'openvpn prefix openvpn subnet' };
3738 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3739 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3743 if ( & validdotmask
( $cgiparams { 'REMOTE_SUBNET' })) {
3744 $errormessage = $Lang :: tr
{ 'openvpn prefix remote subnet' };
3745 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3746 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3750 if ( $cgiparams { 'DEST_PORT' } <= 1023 ) {
3751 $errormessage = $Lang :: tr
{ 'ovpn port in root range' };
3752 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3753 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3757 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
3758 $cgiparams { 'OVPN_MGMT' } = $cgiparams { 'DEST_PORT' };
3761 if ( $cgiparams { 'OVPN_MGMT' } <= 1023 ) {
3762 $errormessage = $Lang :: tr
{ 'ovpn mgmt in root range' };
3763 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3764 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3767 #Check if remote subnet is used elsewhere
3768 my ( $n2nip , $n2nsub )= split ( "/" , $cgiparams { 'REMOTE_SUBNET' });
3769 $warnmessage =& General
:: checksubnets
( '' , $n2nip , 'ovpn' );
3771 $warnmessage = $Lang :: tr
{ 'remote subnet' }. " ( $cgiparams {'REMOTE_SUBNET'}) <br>" . $warnmessage ;
3775 # if (($cgiparams{'TYPE'} eq 'net') && ($cgiparams{'SIDE'} !~ /^(left|right)$/)) {
3776 # $errormessage = $Lang::tr{'ipfire side is invalid'};
3777 # goto VPNCONF_ERROR;
3780 # Check if there is no other entry with this name
3781 if (! $cgiparams { 'KEY' }) {
3782 foreach my $key ( keys %confighash ) {
3783 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
3784 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3785 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3786 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3787 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3794 # Check if a remote host/IP has been set for the client.
3795 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3796 if ( $cgiparams { 'SIDE' } ne 'server' && $cgiparams { 'REMOTE' } eq '' ) {
3797 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3799 # Check if this is a N2N connection and drop temporary config.
3800 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3801 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3806 # Check if a remote host/IP has been configured - the field can be empty on the server side.
3807 if ( $cgiparams { 'REMOTE' } ne '' ) {
3808 # Check if the given IP is valid - otherwise check if it is a valid domain.
3809 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
3810 # Check for a valid domain.
3811 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
3812 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3814 # Check if this is a N2N connection and drop temporary config.
3815 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3816 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3824 if ( $cgiparams { 'TYPE' } ne 'host' ) {
3825 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3826 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
3827 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3828 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3829 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3831 goto VPNCONF_ERROR
;}
3833 # Check if there is no other entry without IP-address and PSK
3834 if ( $cgiparams { 'REMOTE' } eq '' ) {
3835 foreach my $key ( keys %confighash ) {
3836 if (( $cgiparams { 'KEY' } ne $key ) &&
3837 ( $confighash { $key }[ 4 ] eq 'psk' || $cgiparams { 'AUTH' } eq 'psk' ) &&
3838 $confighash { $key }[ 10 ] eq '' ) {
3839 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
3844 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
3845 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
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: $!" ;
3851 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
3852 $errormessage = $Lang :: tr
{ 'invalid input' };
3855 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
3856 $errormessage = $Lang :: tr
{ 'invalid input' };
3861 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
3862 # if (! length($cgiparams{'PSK'}) ) {
3863 # $errormessage = $Lang::tr{'pre-shared key is too short'};
3864 # goto VPNCONF_ERROR;
3866 # if ($cgiparams{'PSK'} =~ /['",&]/) {
3867 # $errormessage = $Lang::tr{'invalid characters found in pre-shared key'};
3868 # goto VPNCONF_ERROR;
3870 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
3871 if ( $cgiparams { 'KEY' }) {
3872 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3875 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3876 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3880 # Move uploaded certificate request to a temporary file
3881 ( my $fh , my $filename ) = tempfile
( );
3882 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3887 # Sign the certificate request and move it
3888 # Sign the host certificate request
3889 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
3890 '-batch' , '-notext' ,
3892 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
3893 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
3895 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3897 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3898 & newcleanssldatabase
();
3902 & deletebackupcert
();
3905 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
3906 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
3908 $temp =~ s
+/ Email
+, E
+;
3909 $temp =~ s/ ST=/ S=/ ;
3910 $cgiparams { 'CERT_NAME' } = $temp ;
3911 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
3912 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
3913 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
3914 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
3917 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
3918 if ( $cgiparams { 'KEY' }) {
3919 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3922 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3923 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3926 # Move uploaded certificate to a temporary file
3927 ( my $fh , my $filename ) = tempfile
( );
3928 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3933 # Verify the certificate has a valid CA and move it
3935 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/cacert.pem $filename ` ;
3936 if ( $test =~ /: OK/ ) {
3939 foreach my $key ( keys %cahash ) {
3940 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $key }[0]cert.pem $filename ` ;
3941 if ( $test =~ /: OK/ ) {
3947 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
3951 move
( $filename , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3953 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
3959 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
3960 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
3962 $temp =~ s
+/ Email
+, E
+;
3963 $temp =~ s/ ST=/ S=/ ;
3964 $cgiparams { 'CERT_NAME' } = $temp ;
3965 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
3966 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
3967 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
3968 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3969 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
3972 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
3973 if ( $cgiparams { 'KEY' }) {
3974 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3977 # Validate input since the form was submitted
3978 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
3979 $errormessage = $Lang :: tr
{ 'name too long' };
3982 if ( $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
3983 $errormessage = $Lang :: tr
{ 'invalid input for name' };
3984 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3985 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3988 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
3989 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
3992 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
3993 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
3996 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
3997 $errormessage = $Lang :: tr
{ 'invalid input for department' };
4000 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
4001 $errormessage = $Lang :: tr
{ 'organization too long' };
4004 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
4005 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
4008 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4009 $errormessage = $Lang :: tr
{ 'invalid input for city' };
4012 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4013 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
4016 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
4017 $errormessage = $Lang :: tr
{ 'invalid input for country' };
4020 if ( $cgiparams { 'CERT_PASS1' } ne '' && $cgiparams { 'CERT_PASS2' } ne '' ){
4021 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
4022 $errormessage = $Lang :: tr
{ 'password too short' };
4026 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
4027 $errormessage = $Lang :: tr
{ 'passwords do not match' };
4031 # Replace empty strings with a .
4032 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
4033 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
4034 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
4036 # Create the Host certificate request client
4037 my $pid = open ( OPENSSL
, "|-" );
4038 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto VPNCONF_ERROR
;};
4039 if ( $pid ) { # parent
4040 print OPENSSL
" $cgiparams {'CERT_COUNTRY'} \n " ;
4041 print OPENSSL
" $state \n " ;
4042 print OPENSSL
" $city \n " ;
4043 print OPENSSL
" $cgiparams {'CERT_ORGANIZATION'} \n " ;
4044 print OPENSSL
" $ou \n " ;
4045 print OPENSSL
" $cgiparams {'CERT_NAME'} \n " ;
4046 print OPENSSL
" $cgiparams {'CERT_EMAIL'} \n " ;
4047 print OPENSSL
". \n " ;
4048 print OPENSSL
". \n " ;
4051 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4052 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4053 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4057 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' , '-rand' , '/proc/interrupts:/proc/net/rt_cache' ,
4058 '-newkey' , 'rsa:2048' ,
4059 '-keyout' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
4060 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
4061 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
4062 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
4063 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4064 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4069 # Sign the host certificate request
4070 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
4071 '-batch' , '-notext' ,
4072 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
4073 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
4074 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
4076 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4077 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4078 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4079 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4080 & newcleanssldatabase
();
4083 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4084 & deletebackupcert
();
4087 # Create the pkcs12 file
4088 system ( '/usr/bin/openssl' , 'pkcs12' , '-export' ,
4089 '-inkey' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
4090 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
4091 '-name' , $cgiparams { 'NAME' },
4092 '-passout' , "pass: $cgiparams {'CERT_PASS1'}" ,
4093 '-certfile' , "${General::swroot}/ovpn/ca/cacert.pem" ,
4094 '-caname' , " $vpnsettings {'ROOTCERT_ORGANIZATION'} CA" ,
4095 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
4097 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4098 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4099 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4100 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
4103 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4105 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
4106 ; # Nothing, just editing
4108 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
4112 # Check if there is no other entry with this common name
4113 if ((! $cgiparams { 'KEY' }) && ( $cgiparams { 'AUTH' } ne 'psk' )) {
4114 foreach my $key ( keys %confighash ) {
4115 if ( $confighash { $key }[ 2 ] eq $cgiparams { 'CERT_NAME' }) {
4116 $errormessage = $Lang :: tr
{ 'a connection with this common name already exists' };
4123 my $key = $cgiparams { 'KEY' };
4126 $key = & General
:: findhasharraykey
( \
%confighash );
4127 foreach my $i ( 0 .. 43 ) { $confighash { $key }[ $i ] = "" ;}
4129 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
4130 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
4131 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
4132 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
4135 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
4136 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
4137 $confighash { $key }[ 4 ] = 'psk' ;
4138 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
4140 $confighash { $key }[ 4 ] = 'cert' ;
4142 if ( $cgiparams { 'TYPE' } eq 'net' ) {
4143 $confighash { $key }[ 6 ] = $cgiparams { 'SIDE' };
4144 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
4146 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
4147 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
4148 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
4149 $confighash { $key }[ 22 ] = $confighash { $key }[ 29 ];
4151 $confighash { $key }[ 22 ] = $cgiparams { 'OVPN_MGMT' };
4153 $confighash { $key }[ 23 ] = $cgiparams { 'MSSFIX' };
4154 $confighash { $key }[ 24 ] = $cgiparams { 'FRAGMENT' };
4155 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
4156 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
4158 $confighash { $key }[ 27 ] = $cgiparams { 'OVPN_SUBNET' };
4159 $confighash { $key }[ 28 ] = $cgiparams { 'PROTOCOL' };
4160 $confighash { $key }[ 29 ] = $cgiparams { 'DEST_PORT' };
4161 $confighash { $key }[ 30 ] = $cgiparams { 'COMPLZO' };
4162 $confighash { $key }[ 31 ] = $cgiparams { 'MTU' };
4163 $confighash { $key }[ 32 ] = $cgiparams { 'CHECK1' };
4164 $name = $cgiparams { 'CHECK1' };
4165 $confighash { $key }[ 33 ] = $cgiparams { $name };
4166 $confighash { $key }[ 34 ] = $cgiparams { 'RG' };
4167 $confighash { $key }[ 35 ] = $cgiparams { 'CCD_DNS1' };
4168 $confighash { $key }[ 36 ] = $cgiparams { 'CCD_DNS2' };
4169 $confighash { $key }[ 37 ] = $cgiparams { 'CCD_WINS' };
4170 $confighash { $key }[ 38 ] = $cgiparams { 'PMTU_DISCOVERY' };
4171 $confighash { $key }[ 39 ] = $cgiparams { 'DAUTH' };
4172 $confighash { $key }[ 40 ] = $cgiparams { 'DCIPHER' };
4174 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4176 if ( $cgiparams { 'CHECK1' } ){
4178 my ( $ccdip , $ccdsub )= split "/" , $cgiparams { $name };
4179 my ( $a , $b , $c , $d ) = split ( /\./ , $ccdip );
4180 if ( - e
"${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ){
4181 unlink "${General::swroot}/ovpn/ccd/ $cgiparams {'CERT_NAME'}" ;
4183 open ( CCDRWCONF
, '>' , "${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ) or die "Unable to create clientconfigfile $!" ;
4184 print CCDRWCONF
"# OpenVPN clientconfig from ccd extension by Copymaster# \n\n " ;
4185 if ( $cgiparams { 'CHECK1' } eq 'dynamic' ){
4186 print CCDRWCONF
"#This client uses the dynamic pool \n " ;
4188 print CCDRWCONF
"#Ip address client and server \n " ;
4189 print CCDRWCONF
"ifconfig-push $ccdip " .& General
:: getlastip
( $ccdip , 1 ). " \n " ;
4191 if ( $confighash { $key }[ 34 ] eq 'on' ){
4192 print CCDRWCONF
" \n #Redirect Gateway: \n #All IP traffic is redirected through the vpn \n " ;
4193 print CCDRWCONF
"push redirect-gateway \n " ;
4195 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4196 if ( $cgiparams { 'IR' } ne '' ){
4197 print CCDRWCONF
" \n #Client routes these networks (behind Client) \n " ;
4198 foreach my $key ( keys %ccdroutehash ){
4199 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4200 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
4201 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
4202 print CCDRWCONF
"iroute $a $b \n " ;
4207 if ( $cgiparams { 'IFROUTE' } eq $Lang :: tr
{ 'ccd none' } ){ $cgiparams { 'IFROUTE' }= '' ;}
4208 if ( $cgiparams { 'IFROUTE' } ne '' ){
4209 print CCDRWCONF
" \n #Client gets routes to these networks (behind IPFire) \n " ;
4210 foreach my $key ( keys %ccdroute2hash ){
4211 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4212 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}){
4213 if ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'blue' }){
4215 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%blue );
4216 print CCDRWCONF
"push \" route $blue {BLUE_ADDRESS} $blue {BLUE_NETMASK} \n " ;
4217 } elsif ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'orange' }){
4219 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%orange );
4220 print CCDRWCONF
"push \" route $orange {ORANGE_ADDRESS} $orange {ORANGE_NETMASK} \n " ;
4222 my ( $a , $b )= split ( /\/ /, $ccdroute2hash { $key }[ $i ]);
4223 print CCDRWCONF
"push \" route $a $b \"\n " ;
4229 if (( $cgiparams { 'CCD_DNS1' } eq '' ) && ( $cgiparams { 'CCD_DNS1' } ne '' )){ $cgiparams { 'CCD_DNS1' } = $cgiparams { 'CCD_DNS2' }; $cgiparams { 'CCD_DNS2' }= '' ;}
4230 if ( $cgiparams { 'CCD_DNS1' } ne '' ){
4231 print CCDRWCONF
" \n #Client gets these nameservers \n " ;
4232 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS1'} \" \n " ;
4234 if ( $cgiparams { 'CCD_DNS2' } ne '' ){
4235 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS2'} \" \n " ;
4237 if ( $cgiparams { 'CCD_WINS' } ne '' ){
4238 print CCDRWCONF
" \n #Client gets this WINS server \n " ;
4239 print CCDRWCONF
"push \" dhcp-option WINS $cgiparams {'CCD_WINS'} \" \n " ;
4248 if ( $cgiparams { 'TYPE' } eq 'net' ) {
4250 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
4251 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4253 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4254 my $key = $cgiparams { 'KEY' };
4256 $key = & General
:: findhasharraykey
( \
%confighash );
4257 foreach my $i ( 0 .. 31 ) { $confighash { $key }[ $i ] = "" ;}
4259 $confighash { $key }[ 0 ] = 'on' ;
4260 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4262 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4270 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
4271 $cgiparams { 'KEY' } = $key ;
4272 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
4276 $cgiparams { 'ENABLED' } = 'on' ;
4280 $cgiparams { 'MSSFIX' } = 'on' ;
4281 $cgiparams { 'FRAGMENT' } = '1300' ;
4282 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4283 $cgiparams { 'DAUTH' } = 'SHA1' ;
4287 $cgiparams { 'SIDE' } = 'left' ;
4288 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) {
4289 $cgiparams { 'AUTH' } = 'psk' ;
4290 } elsif ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4291 $cgiparams { 'AUTH' } = 'certfile' ;
4293 $cgiparams { 'AUTH' } = 'certgen' ;
4295 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
4296 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
4297 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
4298 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
4299 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
4303 $checked { 'ENABLED' }{ 'off' } = '' ;
4304 $checked { 'ENABLED' }{ 'on' } = '' ;
4305 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4306 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4307 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4308 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4309 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4310 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4311 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4314 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
4315 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
4316 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = 'CHECKED' ;
4318 $selected { 'SIDE' }{ 'server' } = '' ;
4319 $selected { 'SIDE' }{ 'client' } = '' ;
4320 $selected { 'SIDE' }{ $cgiparams { 'SIDE' }} = 'SELECTED' ;
4322 $selected { 'PROTOCOL' }{ 'udp' } = '' ;
4323 $selected { 'PROTOCOL' }{ 'tcp' } = '' ;
4324 $selected { 'PROTOCOL' }{ $cgiparams { 'PROTOCOL' }} = 'SELECTED' ;
4327 $checked { 'AUTH' }{ 'psk' } = '' ;
4328 $checked { 'AUTH' }{ 'certreq' } = '' ;
4329 $checked { 'AUTH' }{ 'certgen' } = '' ;
4330 $checked { 'AUTH' }{ 'certfile' } = '' ;
4331 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = 'CHECKED' ;
4333 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = 'SELECTED' ;
4335 $checked { 'COMPLZO' }{ 'off' } = '' ;
4336 $checked { 'COMPLZO' }{ 'on' } = '' ;
4337 $checked { 'COMPLZO' }{ $cgiparams { 'COMPLZO' }} = 'CHECKED' ;
4339 $checked { 'MSSFIX' }{ 'off' } = '' ;
4340 $checked { 'MSSFIX' }{ 'on' } = '' ;
4341 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4343 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
4344 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4346 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
4348 $selected { 'DCIPHER' }{ 'CAMELLIA-256-CBC' } = '' ;
4349 $selected { 'DCIPHER' }{ 'CAMELLIA-192-CBC' } = '' ;
4350 $selected { 'DCIPHER' }{ 'CAMELLIA-128-CBC' } = '' ;
4351 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4352 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4353 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4354 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4355 $selected { 'DCIPHER' }{ 'SEED-CBC' } = '' ;
4356 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4357 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4358 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4359 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4360 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4361 # If no cipher has been chossen yet, select
4362 # the old default (AES-256-CBC) for compatiblity reasons.
4363 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4364 $cgiparams { 'DCIPHER' } = 'AES-256-CBC' ;
4366 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4367 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
4368 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
4369 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
4370 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
4371 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
4372 # If no hash algorythm has been choosen yet, select
4373 # the old default value (SHA1) for compatiblity reasons.
4374 if ( $cgiparams { 'DAUTH' } eq '' ) {
4375 $cgiparams { 'DAUTH' } = 'SHA1' ;
4377 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
4380 & Header
:: showhttpheaders
();
4381 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
4382 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4383 if ( $errormessage ) {
4384 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4385 print "<class name='base'> $errormessage " ;
4386 print " </class>" ;
4387 & Header
:: closebox
();
4391 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'warning messages'}:" );
4392 print "<class name='base'> $warnmessage " ;
4393 print " </class>" ;
4394 & Header
:: closebox
();
4397 print "<form method='post' enctype='multipart/form-data'>" ;
4398 print "<input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />" ;
4400 if ( $cgiparams { 'KEY' }) {
4401 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
4402 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
4405 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'connection'}:" );
4406 print "<table width='100%' border='0'> \n " ;
4408 print "<tr><td width='14%' class='boldbase'> $Lang ::tr{'name'}: </td>" ;
4410 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4411 if ( $cgiparams { 'KEY' }) {
4412 print "<td width='35%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4414 print "<td width='35%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' size='30' /></td>" ;
4416 # print "<tr><td>$Lang::tr{'interface'}</td>";
4417 # print "<td><select name='INTERFACE'>";
4418 # print "<option value='RED' $selected{'INTERFACE'}{'RED'}>RED</option>";
4419 # if ($netsettings{'BLUE_DEV'} ne '') {
4420 # print "<option value='BLUE' $selected{'INTERFACE'}{'BLUE'}>BLUE</option>";
4422 # print "<option value='GREEN' $selected{'INTERFACE'}{'GREEN'}>GREEN</option>";
4423 # print "<option value='ORANGE' $selected{'INTERFACE'}{'ORANGE'}>ORANGE</option>";
4424 # print "</select></td></tr>";
4427 print "<input type='hidden' name='INTERFACE' value='red' />" ;
4428 if ( $cgiparams { 'KEY' }) {
4429 print "<td width='25%' class='base' nowrap='nowrap'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4431 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' /></td>" ;
4434 <td width='25%'> </td>
4435 <td width='25%'> </td></tr>
4436 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td>
4437 <td><select name='SIDE'>
4438 <option value='server' $selected {'SIDE'}{'server'}> $Lang ::tr{'openvpn server'}</option>
4439 <option value='client' $selected {'SIDE'}{'client'}> $Lang ::tr{'openvpn client'}</option>
4443 <td class='boldbase'> $Lang ::tr{'remote host/ip'}:</td>
4444 <td><input type='TEXT' name='REMOTE' value=' $cgiparams {'REMOTE'}' /></td>
4447 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
4448 <td><input type='TEXT' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' /></td>
4450 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
4451 <td><input type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' /></td>
4454 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td>
4455 <td><input type='TEXT' name='OVPN_SUBNET' value=' $cgiparams {'OVPN_SUBNET'}' /></td>
4457 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
4458 <td><select name='PROTOCOL'>
4459 <option value='udp' $selected {'PROTOCOL'}{'udp'}>UDP</option>
4460 <option value='tcp' $selected {'PROTOCOL'}{'tcp'}>TCP</option></select></td>
4464 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
4465 <td><input type='TEXT' name='DEST_PORT' value=' $cgiparams {'DEST_PORT'}' size='5' /></td>
4467 <td class='boldbase' nowrap='nowrap'>Management Port ( $Lang ::tr{'openvpn default'}: <span class="base"> $Lang ::tr{'destination port'}): <img src='/blob.gif' /></td>
4468 <td> <input type='TEXT' name='OVPN_MGMT' VALUE=' $cgiparams {'OVPN_MGMT'}'size='5' /></td>
4471 <tr><td colspan=4><hr /></td></tr><tr>
4474 <td class'base'><b> $Lang ::tr{'MTU settings'}</b></td>
4477 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} <img src='/blob.gif' /></td>
4478 <td><input type='TEXT' name='MTU' VALUE=' $cgiparams {'MTU'}'size='5' /></td>
4479 <td colspan='2'> $Lang ::tr{'openvpn default'}: udp/tcp <span class="base">1500/1400</span></td>
4482 <tr><td class='boldbase' nowrap='nowrap'>fragment <img src='/blob.gif' /></td>
4483 <td><input type='TEXT' name='FRAGMENT' VALUE=' $cgiparams {'FRAGMENT'}'size='5' /></td>
4484 <td> $Lang ::tr{'openvpn default'}: <span class="base">1300</span></td>
4487 <tr><td class='boldbase' nowrap='nowrap'>mssfix <img src='/blob.gif' /></td>
4488 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
4489 <td> $Lang ::tr{'openvpn default'}: <span class="base">on</span></td>
4492 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'} <img src='/blob.gif'</td>
4493 <td><input type='checkbox' name='COMPLZO' $checked {'COMPLZO'}{'on'} /></td>
4496 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td>
4498 <input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}
4499 <input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}
4500 <input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}
4501 <input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}
4505 <tr><td colspan=4><hr /></td></tr><tr>
4507 <td class'base'><b> $Lang ::tr{'ovpn crypt options'}:</b></td>
4510 <tr><td class='boldbase'> $Lang ::tr{'cipher'}</td>
4511 <td><select name='DCIPHER'>
4512 <option value='CAMELLIA-256-CBC' $selected {'DCIPHER'}{'CAMELLIA-256-CBC'}>CAMELLIA-CBC (256 $Lang ::tr{'bit'})</option>
4513 <option value='CAMELLIA-192-CBC' $selected {'DCIPHER'}{'CAMELLIA-192-CBC'}>CAMELLIA-CBC (192 $Lang ::tr{'bit'})</option>
4514 <option value='CAMELLIA-128-CBC' $selected {'DCIPHER'}{'CAMELLIA-128-CBC'}>CAMELLIA-CBC (128 $Lang ::tr{'bit'})</option>
4515 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-CBC (256 $Lang ::tr{'bit'}, $Lang ::tr{'default'})</option>
4516 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-CBC (192 $Lang ::tr{'bit'})</option>
4517 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-CBC (128 $Lang ::tr{'bit'})</option>
4518 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC (192 $Lang ::tr{'bit'})</option>
4519 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC (192 $Lang ::tr{'bit'})</option>
4520 <option value='SEED-CBC' $selected {'DCIPHER'}{'SEED-CBC'}>SEED-CBC (128 $Lang ::tr{'bit'})</option>
4521 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC (128 $Lang ::tr{'bit'})</option>
4522 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC (128 $Lang ::tr{'bit'})</option>
4523 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC (128 $Lang ::tr{'bit'})</option>
4527 <td class='boldbase'> $Lang ::tr{'ovpn ha'}:</td>
4528 <td><select name='DAUTH'>
4529 <option value='whirlpool' $selected {'DAUTH'}{'whirlpool'}>Whirlpool (512 $Lang ::tr{'bit'})</option>
4530 <option value='SHA512' $selected {'DAUTH'}{'SHA512'}>SHA2 (512 $Lang ::tr{'bit'})</option>
4531 <option value='SHA384' $selected {'DAUTH'}{'SHA384'}>SHA2 (384 $Lang ::tr{'bit'})</option>
4532 <option value='SHA256' $selected {'DAUTH'}{'SHA256'}>SHA2 (256 $Lang ::tr{'bit'})</option>
4533 <option value='SHA1' $selected {'DAUTH'}{'SHA1'}>SHA1 (160 $Lang ::tr{'bit'} Default)</option>
4537 <tr><td colspan=4><hr /></td></tr><tr>
4543 print "<tr><td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' /></td>" ;
4544 print "<td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td></tr></table>" ;
4546 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4547 print "<tr><td> $Lang ::tr{'enabled'} <input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>" ;
4550 print "</tr></table><br><br>" ;
4551 #A.Marx CCD new client
4552 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4553 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>" ;
4556 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnnet );
4557 $vpnip = $vpnnet { 'DOVPN_SUBNET' };
4558 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
4562 $checked { 'check1' }{ 'off' } = '' ;
4563 $checked { 'check1' }{ 'on' } = '' ;
4564 $checked { 'check1' }{ $cgiparams { 'CHECK1' }} = 'CHECKED' ;
4565 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%'>" ;
4566 print "</td></tr></table><br><br>" ;
4567 my $name = $cgiparams { 'CHECK1' };
4568 $checked { 'RG' }{ $cgiparams { 'RG' }} = 'CHECKED' ;
4570 if (! - z
"${General::swroot}/ovpn/ccd.conf" ){
4571 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>" ;
4572 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
4574 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
4575 if ( $count % 2 ){ print "<tr bgcolor=' $color {'color22'}'>" ;} else { print "<tr bgcolor=' $color {'color20'}'>" ;}
4576 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%'>" ;
4577 & fillselectbox
( $ccdconf [ 1 ], $ccdconf [ 0 ], $cgiparams { $name });
4580 print "</table><br><br><hr><br><br>" ;
4584 & Header
:: closebox
();
4585 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
4587 } elsif (! $cgiparams { 'KEY' }) {
4591 my $cakeydisabled = '' ;
4592 my $cacrtdisabled = '' ;
4593 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) { $cakeydisabled = "disabled='disabled'" } else { $cakeydisabled = "" };
4594 if ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) { $cacrtdisabled = "disabled='disabled'" } else { $cacrtdisabled = "" };
4596 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'authentication' });
4599 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4602 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4604 <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>
4605 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td><td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
4606 <tr><td colspan='3'> </td></tr>
4607 <tr><td colspan='3'><hr /></td></tr>
4608 <tr><td colspan='3'> </td></tr>
4609 <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>
4610 <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>
4611 <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>
4612 <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>
4613 <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>
4614 <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>
4615 <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>
4616 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4627 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4629 <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>
4630 <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>
4631 <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>
4632 <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>
4633 <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>
4634 <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>
4635 <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>
4636 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4648 foreach my $country ( sort keys %{ Countries
:: countries
}) {
4649 print "<option value=' $Countries ::countries{ $country }'" ;
4650 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
4651 print " selected='selected'" ;
4653 print "> $country </option>" ;
4659 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4663 <td> </td><td class='base'> $Lang ::tr{'valid till'} (days):</td>
4664 <td class='base' nowrap='nowrap'><input type='text' name='DAYS_VALID' value=' $cgiparams {'DAYS_VALID'}' size='32' $cakeydisabled /></td></tr>
4666 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
4667 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
4668 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:<br>( $Lang ::tr{'confirmation'})</td>
4669 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
4670 <tr><td colspan='3'> </td></tr>
4671 <tr><td colspan='3'><hr /></td></tr>
4672 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4678 <tr><td> </td><td> </td><td> </td></tr>
4679 <tr><td> </td><td> </td><td> </td></tr>
4680 <tr><td colspan='3'><hr /></td></tr>
4681 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4691 & Header
:: closebox
();
4695 #A.Marx CCD new client
4696 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4698 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ccd client options'}:" );
4702 <table border='0' width='100%'>
4703 <tr><td width='20%'>Redirect Gateway:</td><td colspan='3'><input type='checkbox' name='RG' $checked {'RG'}{'on'} /></td></tr>
4704 <tr><td colspan='4'><b><br> $Lang ::tr{'ccd routes'}</b></td></tr>
4705 <tr><td colspan='4'> </td></tr>
4706 <tr><td valign='top'> $Lang ::tr{'ccd iroute'}</td><td align='left' width='30%'><textarea name='IR' cols='26' rows='6' wrap='off'>
4709 if ( $cgiparams { 'IR' } ne '' ){
4710 print $cgiparams { 'IR' };
4712 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4713 foreach my $key ( keys %ccdroutehash ) {
4714 if ( $cgiparams { 'NAME' } eq $ccdroutehash { $key }[ 0 ]){
4715 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
4716 if ( $ccdroutehash { $key }[ $i ] ne '' ){
4717 print $ccdroutehash { $key }[ $i ]. " \n " ;
4719 $cgiparams { 'IR' } .= $ccdroutehash { $key }[ $i ];
4726 </textarea></td><td valign='top' colspan='2'> $Lang ::tr{'ccd iroutehint'}</td></tr>
4727 <tr><td colspan='4'><br></td></tr>
4728 <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>
4742 open ( FILE
, "${General::swroot}/main/routing" ) ;
4745 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
4747 foreach my $key ( keys %ccdroute2hash ) {
4748 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4749 if ( $ccdroute2hash { $key }[ 1 ] eq '' ){
4756 print "<option> $Lang ::tr{'ccd none'}</option>" ;
4758 print "<option selected> $Lang ::tr{'ccd none'}</option>" ;
4760 #check if static routes are defined for client
4761 foreach my $line ( @current ) {
4763 $line =~ s/\s*$//g ; # remove newline
4764 @temp = split ( /\,/ , $line );
4765 $temp [ 1 ] = '' unless defined $temp [ 1 ]; # not always populated
4766 my ( $a , $b ) = split ( /\/ /, $temp [ 1 ]);
4767 $temp [ 1 ] = $a . "/" .& General
:: iporsubtocidr
( $b );
4768 foreach my $key ( keys %ccdroute2hash ) {
4769 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4770 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4771 if ( $ccdroute2hash { $key }[ $i ] eq $a . "/" .& General
:: iporsubtodec
( $b )){
4777 if ( $set == '1' && $#temp != - 1 ){ print "<option selected> $temp [1]</option>" ; $set = 0 ;} elsif ( $set == '0' && $#temp != - 1 ){ print "<option> $temp [1]</option>" ;}
4779 #check if green,blue,orange are defined for client
4780 foreach my $key ( keys %ccdroute2hash ) {
4781 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4783 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4784 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'GREEN_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'GREEN_NETMASK' })){
4787 if (& haveBlueNet
()){
4788 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'BLUE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'BLUE_NETMASK' })) {
4792 if (& haveOrangeNet
()){
4793 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'ORANGE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'ORANGE_NETMASK' }) ) {
4800 if (& haveBlueNet
() && $selblue == '1' ){ print "<option selected> $Lang ::tr{'blue'}</option>" ; $selblue = 0 ;} elsif (& haveBlueNet
() && $selblue == '0' ){ print "<option> $Lang ::tr{'blue'}</option>" ;}
4801 if (& haveOrangeNet
() && $selorange == '1' ){ print "<option selected> $Lang ::tr{'orange'}</option>" ; $selorange = 0 ;} elsif (& haveOrangeNet
() && $selorange == '0' ){ print "<option> $Lang ::tr{'orange'}</option>" ;}
4802 if ( $selgreen == '1' || $other == '0' ){ print "<option selected> $Lang ::tr{'green'}</option>" ; $set = 0 ;} else { print "<option> $Lang ::tr{'green'}</option>" ;};
4805 </select></td><td valign='top'>DNS1:</td><td valign='top'><input type='TEXT' name='CCD_DNS1' value=' $cgiparams {'CCD_DNS1'}' size='30' /></td></tr>
4806 <tr valign='top'><td>DNS2:</td><td><input type='TEXT' name='CCD_DNS2' value=' $cgiparams {'CCD_DNS2'}' size='30' /></td></tr>
4807 <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>
4811 & Header
:: closebox
();
4813 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
4814 if ( $cgiparams { 'KEY' }) {
4815 # print "<input type='submit' name='ACTION' value='$Lang::tr{'advanced'}' />";
4817 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
4818 & Header
:: closebigbox
();
4819 & Header
:: closepage
();
4827 ### Default status page
4832 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
4833 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
4834 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4836 my @status = `/bin/cat /var/log/ovpnserver.log` ;
4838 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
4839 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
4840 my $ipaddr = < IPADDR
>;
4843 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
4844 if ( $cgiparams { 'VPN_IP' } eq '' ) {
4845 $cgiparams { 'VPN_IP' } = $ipaddr ;
4851 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4852 $cgiparams { 'DCIPHER' } = 'AES-256-CBC' ;
4854 if ( $cgiparams { 'DDEST_PORT' } eq '' ) {
4855 $cgiparams { 'DDEST_PORT' } = '1194' ;
4857 if ( $cgiparams { 'DMTU' } eq '' ) {
4858 $cgiparams { 'DMTU' } = '1400' ;
4860 if ( $cgiparams { 'MSSFIX' } eq '' ) {
4861 $cgiparams { 'MSSFIX' } = 'off' ;
4863 if ( $cgiparams { 'DAUTH' } eq '' ) {
4864 $cgiparams { 'DAUTH' } = 'SHA1' ;
4866 if ( $cgiparams { 'DOVPN_SUBNET' } eq '' ) {
4867 $cgiparams { 'DOVPN_SUBNET' } = '10.' . int ( rand ( 256 )) . '.' . int ( rand ( 256 )) . '.0/255.255.255.0' ;
4869 $checked { 'ENABLED' }{ 'off' } = '' ;
4870 $checked { 'ENABLED' }{ 'on' } = '' ;
4871 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4872 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4873 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4874 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4875 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4876 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4877 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4878 $selected { 'DDEVICE' }{ 'tun' } = '' ;
4879 $selected { 'DDEVICE' }{ 'tap' } = '' ;
4880 $selected { 'DDEVICE' }{ $cgiparams { 'DDEVICE' }} = 'SELECTED' ;
4882 $selected { 'DPROTOCOL' }{ 'udp' } = '' ;
4883 $selected { 'DPROTOCOL' }{ 'tcp' } = '' ;
4884 $selected { 'DPROTOCOL' }{ $cgiparams { 'DPROTOCOL' }} = 'SELECTED' ;
4886 $selected { 'DCIPHER' }{ 'CAMELLIA-256-CBC' } = '' ;
4887 $selected { 'DCIPHER' }{ 'CAMELLIA-192-CBC' } = '' ;
4888 $selected { 'DCIPHER' }{ 'CAMELLIA-128-CBC' } = '' ;
4889 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4890 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4891 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4892 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4893 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4894 $selected { 'DCIPHER' }{ 'SEED-CBC' } = '' ;
4895 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4896 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4897 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4898 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4899 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4901 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
4902 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
4903 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
4904 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
4905 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
4906 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
4908 $checked { 'DCOMPLZO' }{ 'off' } = '' ;
4909 $checked { 'DCOMPLZO' }{ 'on' } = '' ;
4910 $checked { 'DCOMPLZO' }{ $cgiparams { 'DCOMPLZO' }} = 'CHECKED' ;
4913 $checked { 'MSSFIX' }{ 'off' } = '' ;
4914 $checked { 'MSSFIX' }{ 'on' } = '' ;
4915 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4917 & Header
:: showhttpheaders
();
4918 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
4919 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4921 if ( $errormessage ) {
4922 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4923 print "<class name='base'> $errormessage \n " ;
4924 print " </class> \n " ;
4925 & Header
:: closebox
();
4929 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'warning messages' });
4930 print " $warnmessage <br>" ;
4931 print " $Lang ::tr{'fwdfw warn1'}<br>" ;
4932 & Header
:: closebox
();
4933 print "<center><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'ok'}' style='width: 5em;'></form>" ;
4934 & Header
:: closepage
();
4938 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>" ;
4939 my $srunning = "no" ;
4940 my $activeonrun = "" ;
4941 if ( - e
"/var/run/openvpn.pid" ){
4942 $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>" ;
4946 $activeonrun = "disabled='disabled'" ;
4948 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'global settings' });
4950 <table width='100%' border='0'>
4951 <form method='post'>
4952 <td width='25%'> </td>
4953 <td width='25%'> </td>
4954 <td width='25%'> </td></tr>
4955 <tr><td class='boldbase'> $Lang ::tr{'ovpn server status'}</td>
4956 <td align='left'> $sactive </td>
4957 <tr><td class='boldbase'> $Lang ::tr{'ovpn on red'}</td>
4958 <td><input type='checkbox' name='ENABLED' $checked {'ENABLED'}{'on'} /></td>
4961 if (& haveBlueNet
()) {
4962 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on blue'}</td>" ;
4963 print "<td><input type='checkbox' name='ENABLED_BLUE' $checked {'ENABLED_BLUE'}{'on'} /></td>" ;
4965 if (& haveOrangeNet
()) {
4966 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on orange'}</td>" ;
4967 print "<td><input type='checkbox' name='ENABLED_ORANGE' $checked {'ENABLED_ORANGE'}{'on'} /></td>" ;
4970 <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>
4971 <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>
4972 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn device'}</td>
4973 <td><select name='DDEVICE' ><option value='tun' $selected {'DDEVICE'}{'tun'}>TUN</option>
4974 <!-- this is still not working
4975 <option value='tap' $selected {'DDEVICE'}{'tap'}>TAP</option></select>--> </td>
4976 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
4977 <td><select name='DPROTOCOL'><option value='udp' $selected {'DPROTOCOL'}{'udp'}>UDP</option>
4978 <option value='tcp' $selected {'DPROTOCOL'}{'tcp'}>TCP</option></select></td>
4979 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
4980 <td><input type='TEXT' name='DDEST_PORT' value=' $cgiparams {'DDEST_PORT'}' size='5' /></td></tr>
4981 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} </td>
4982 <td> <input type='TEXT' name='DMTU' VALUE=' $cgiparams {'DMTU'}' size='5' /></td>
4984 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td>
4985 <td><select name='DCIPHER'>
4986 <option value='CAMELLIA-256-CBC' $selected {'DCIPHER'}{'CAMELLIA-256-CBC'}>CAMELLIA-CBC (256 $Lang ::tr{'bit'})</option>
4987 <option value='CAMELLIA-192-CBC' $selected {'DCIPHER'}{'CAMELLIA-192-CBC'}>CAMELLIA-CBC (192 $Lang ::tr{'bit'})</option>
4988 <option value='CAMELLIA-128-CBC' $selected {'DCIPHER'}{'CAMELLIA-128-CBC'}>CAMELLIA-CBC (128 $Lang ::tr{'bit'})</option>
4989 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-CBC (256 $Lang ::tr{'bit'})</option>
4990 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-CBC (192 $Lang ::tr{'bit'})</option>
4991 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-CBC (128 $Lang ::tr{'bit'})</option>
4992 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC (192 $Lang ::tr{'bit'})</option>
4993 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC (192 $Lang ::tr{'bit'})</option>
4994 <option value='SEED-CBC' $selected {'DCIPHER'}{'SEED-CBC'}>SEED-CBC (128 $Lang ::tr{'bit'})</option>
4995 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC (128 $Lang ::tr{'bit'})</option>
4996 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC (128 $Lang ::tr{'bit'})</option>
4997 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC (128 $Lang ::tr{'bit'})</option>
5000 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td>
5001 <td><input type='checkbox' name='DCOMPLZO' $checked {'DCOMPLZO'}{'on'} /></td>
5003 <tr><td colspan='4'><br><br></td></tr>
5007 if ( $srunning eq "yes" ) {
5008 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' disabled='disabled' />" ;
5009 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
5010 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
5011 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'stop ovpn server'}' /></td></tr>" ;
5013 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
5014 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
5015 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
5016 if (( - e
"${General::swroot}/ovpn/ca/cacert.pem" &&
5017 - e
"${General::swroot}/ovpn/ca/dh1024.pem" &&
5018 - e
"${General::swroot}/ovpn/certs/servercert.pem" &&
5019 - e
"${General::swroot}/ovpn/certs/serverkey.pem" ) &&
5020 (( $cgiparams { 'ENABLED' } eq 'on' ) ||
5021 ( $cgiparams { 'ENABLED_BLUE' } eq 'on' ) ||
5022 ( $cgiparams { 'ENABLED_ORANGE' } eq 'on' ))){
5023 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' /></td></tr>" ;
5025 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' disabled='disabled' /></td></tr>" ;
5028 print "</form></table>" ;
5029 & Header
:: closebox
();
5031 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5034 #<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>
5037 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection status and controlc' });
5041 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5043 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5044 <th width='15%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></th>
5045 <th width='22%' class='boldbase' align='center'><b> $Lang ::tr{'network'}</b></th>
5046 <th width='20%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></th>
5047 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></th>
5048 <th width='5%' class='boldbase' colspan='6' align='center'><b> $Lang ::tr{'action'}</b></th>
5055 foreach my $key ( sort { ncmp
( $confighash { $a }[ 1 ], $confighash { $b }[ 1 ]) } keys %confighash ) {
5056 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
5059 $col = "bgcolor=' $color {'color20'}'" ;
5062 $col = "bgcolor=' $color {'color22'}'" ;
5064 print "<td align='center' nowrap='nowrap' $col > $confighash { $key }[1]</td>" ;
5065 print "<td align='center' nowrap='nowrap' $col >" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
5066 #if ($confighash{$key}[4] eq 'cert') {
5067 #print "<td align='left' nowrap='nowrap'>$confighash{$key}[2]</td>";
5069 #print "<td align='left'> </td>";
5071 my $cavalid = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
5072 $cavalid =~ /Not After : (.*)[\n]/ ;
5074 if ( $confighash { $key }[ 32 ] eq "" && $confighash { $key }[ 3 ] eq 'net' ){ $confighash { $key }[ 32 ]= "net-2-net" ;}
5075 if ( $confighash { $key }[ 32 ] eq "" && $confighash { $key }[ 3 ] eq 'host' ){ $confighash { $key }[ 32 ]= "dynamic" ;}
5076 print "<td align='center' $col > $confighash { $key }[32]</td>" ;
5077 print "<td align='center' $col > $confighash { $key }[25]</td>" ;
5078 $col1 = "bgcolor='${Header::colourred}'" ;
5079 my $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
5081 if ( $confighash { $key }[ 0 ] eq 'off' ) {
5082 $col1 = "bgcolor='${Header::colourblue}'" ;
5083 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
5090 if ( $confighash { $key }[ 3 ] eq 'net' ) {
5092 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
5095 my $tport = $confighash { $key }[ 22 ];
5096 my $tnet = new Net
:: Telnet
( Timeout
=> 5 , Errmode
=> 'return' , Port
=> $tport );
5098 $tnet -> open ( '127.0.0.1' );
5099 @output = $tnet -> cmd ( String
=> 'state' , Prompt
=> '/(END.* \n |ERROR:.* \n )/' );
5100 @tustate = split ( /\,/ , $output [ 1 ]);
5102 #CONNECTING -- OpenVPN's initial state.
5103 #WAIT -- (Client only) Waiting for initial response from server.
5104 #AUTH -- (Client only) Authenticating with server.
5105 #GET_CONFIG -- (Client only) Downloading configuration options from server.
5106 #ASSIGN_IP -- Assigning IP address to virtual network interface.
5107 #ADD_ROUTES -- Adding routes to system.
5108 #CONNECTED -- Initialization Sequence Completed.
5109 #RECONNECTING -- A restart has occurred.
5110 #EXITING -- A graceful exit is in progress.
5113 if (( $tustate [ 1 ] eq 'CONNECTED' ) || ( $tustate [ 1 ] eq 'WAIT' )) {
5114 $col1 = "bgcolor='${Header::colourgreen}'" ;
5115 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
5117 $col1 = "bgcolor='${Header::colourred}'" ;
5118 $active = "<b><font color='#FFFFFF'> $tustate [1]</font></b>" ;
5126 foreach my $line ( @status ) {
5128 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
5129 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
5130 if ( $match [ 1 ] ne "Common Name" ) {
5134 if ( $cn eq " $confighash { $key }[2]" ) {
5135 $col1 = "bgcolor='${Header::colourgreen}'" ;
5136 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
5145 <td align='center' $col1 > $active </td>
5147 <form method='post' name='frm${key}a'><td align='center' $col >
5148 <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' />
5149 <input type='hidden' name='ACTION' value=' $Lang ::tr{'dl client arch'}' />
5150 <input type='hidden' name='KEY' value=' $key ' />
5154 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
5156 <form method='post' name='frm${key}b'><td align='center' $col >
5157 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' border='0' />
5158 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
5159 <input type='hidden' name='KEY' value=' $key ' />
5163 print "<td> </td>" ;
5165 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" ) {
5167 <form method='post' name='frm${key}c'><td align='center' $col >
5168 <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' />
5169 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
5170 <input type='hidden' name='KEY' value=' $key ' />
5173 ; } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
5175 <form method='post' name='frm${key}c'><td align='center' $col >
5176 <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' />
5177 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
5178 <input type='hidden' name='KEY' value=' $key ' />
5182 print "<td> </td>" ;
5185 <form method='post' name='frm${key}d'><td align='center' $col >
5186 <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' />
5187 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
5188 <input type='hidden' name='KEY' value=' $key ' />
5191 <form method='post' name='frm${key}e'><td align='center' $col >
5192 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
5193 <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'/>
5194 <input type='hidden' name='KEY' value=' $key ' />
5196 <form method='post' name='frm${key}f'><td align='center' $col >
5197 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
5198 <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' />
5199 <input type='hidden' name='KEY' value=' $key ' />
5208 # If the config file contains entries, print Key to action icons
5213 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5214 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
5215 <td class='base'> $Lang ::tr{'click to disable'}</td>
5216 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
5217 <td class='base'> $Lang ::tr{'show certificate'}</td>
5218 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
5219 <td class='base'> $Lang ::tr{'edit'}</td>
5220 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
5221 <td class='base'> $Lang ::tr{'remove'}</td>
5225 <td> <img src='/images/off.gif' alt='?OFF' /></td>
5226 <td class='base'> $Lang ::tr{'click to enable'}</td>
5227 <td> <img src='/images/media-floppy.png' alt='?FLOPPY' /></td>
5228 <td class='base'> $Lang ::tr{'download certificate'}</td>
5229 <td> <img src='/images/openvpn.png' alt='?RELOAD'/></td>
5230 <td class='base'> $Lang ::tr{'dl client arch'}</td>
5238 <table width='100%'>
5239 <form method='post'>
5240 <tr><td align='right'>
5241 <input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
5242 <input type='submit' name='ACTION' value=' $Lang ::tr{'ovpn con stat'}' $activeonrun /></td>
5248 & Header
:: closebox
();
5252 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate authorities'}" );
5254 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5256 <th width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5257 <th width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></th>
5258 <th width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></th>
5262 my $col1 = "bgcolor=' $color {'color22'}'" ;
5263 my $col2 = "bgcolor=' $color {'color20'}'" ;
5265 my $col3 = "bgcolor=' $color {'color22'}'" ;
5267 my $col4 = "bgcolor=' $color {'color20'}'" ;
5269 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5270 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
5271 $casubject =~ /Subject: (.*)[\n]/ ;
5273 $casubject =~ s
+/ Email
+, E
+;
5274 $casubject =~ s/ ST=/ S=/ ;
5277 <td class='base' $col1 > $Lang ::tr{'root certificate'}</td>
5278 <td class='base' $col1 > $casubject </td>
5279 <form method='post' name='frmrootcrta'><td width='3%' align='center' $col1 >
5280 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
5281 <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' />
5283 <form method='post' name='frmrootcrtb'><td width='3%' align='center' $col1 >
5284 <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' />
5285 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
5287 <td width='4%' $col1 > </td>
5292 # display rootcert generation buttons
5295 <td class='base' $col1 > $Lang ::tr{'root certificate'}:</td>
5296 <td class='base' $col1 > $Lang ::tr{'not present'}</td>
5297 <td colspan='3' $col1 > </td>
5303 if (- f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
5304 my $hostsubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
5305 $hostsubject =~ /Subject: (.*)[\n]/ ;
5307 $hostsubject =~ s
+/ Email
+, E
+;
5308 $hostsubject =~ s/ ST=/ S=/ ;
5312 <td class='base' $col2 > $Lang ::tr{'host certificate'}</td>
5313 <td class='base' $col2 > $hostsubject </td>
5314 <form method='post' name='frmhostcrta'><td width='3%' align='center' $col2 >
5315 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
5316 <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' />
5318 <form method='post' name='frmhostcrtb'><td width='3%' align='center' $col2 >
5319 <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' />
5320 <input type='hidden' name='ACTION' value=" $Lang ::tr{'download host certificate'}" />
5322 <td width='4%' $col2 > </td>
5330 <td width='25%' class='base' $col2 > $Lang ::tr{'host certificate'}:</td>
5331 <td class='base' $col2 > $Lang ::tr{'not present'}</td>
5332 </td><td colspan='3' $col2 > </td>
5338 # Adding DH parameter to chart
5339 if (- f
"${General::swroot}/ovpn/ca/dh1024.pem" ) {
5340 my $dhsubject = `/usr/bin/openssl dhparam -text -in ${General::swroot}/ovpn/ca/dh1024.pem` ;
5341 $dhsubject =~ / (.*)[\n]/ ;
5347 <td class='base' $col3 > $Lang ::tr{'dh parameter'}</td>
5348 <td class='base' $col3 > $dhsubject </td>
5349 <form method='post' name='frmdhparam'><td width='3%' align='center' $col3 >
5350 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show dh'}' />
5351 <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' />
5353 <form method='post' name='frmdhparam'><td width='3%' align='center' $col3 >
5354 <input type='image' name=" $Lang ::tr{'download dh parameter'}" src='/images/media-floppy.png' alt=" $Lang ::tr{'download dh parameter'}" title=" $Lang ::tr{'download dh parameter'}" border='0' />
5355 <input type='hidden' name='ACTION' value=" $Lang ::tr{'download dh parameter'}" />
5357 <td width='4%' $col3 > </td>
5365 <td width='25%' class='base' $col3 > $Lang ::tr{'dh parameter'}:</td>
5366 <td class='base' $col3 > $Lang ::tr{'not present'}</td>
5367 </td><td colspan='3' $col3 > </td>
5373 # Adding ta.key to chart
5374 if (- f
"${General::swroot}/ovpn/certs/ta.key" ) {
5375 my $tasubject = `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
5376 $tasubject =~ /# (.*)[\n]/ ;
5381 <td class='base' $col4 > $Lang ::tr{'ta key'}</td>
5382 <td class='base' $col4 > $tasubject </td>
5383 <form method='post' name='frmtakey'><td width='3%' align='center' $col4 >
5384 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show tls-auth key'}' />
5385 <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' />
5387 <form method='post' name='frmtakey'><td width='3%' align='center' $col4 >
5388 <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' />
5389 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download tls-auth key'}' />
5391 <td width='4%' $col4 > </td>
5399 <td width='25%' class='base' $col4 > $Lang ::tr{'ta key'}:</td>
5400 <td class='base' $col4 > $Lang ::tr{'not present'}</td>
5401 <td colspan='3' $col4 > </td>
5407 if (! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5408 print "<tr><td colspan='5' align='center'><form method='post'>" ;
5409 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' />" ;
5410 print "</form></td></tr> \n " ;
5413 if ( keys %cahash > 0 ) {
5414 foreach my $key ( keys %cahash ) {
5415 if (( $key + 1 ) % 2 ) {
5416 print "<tr bgcolor=' $color {'color20'}'> \n " ;
5418 print "<tr bgcolor=' $color {'color22'}'> \n " ;
5420 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
5421 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
5423 <form method='post' name='cafrm${key}a'><td align='center'>
5424 <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' />
5425 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
5426 <input type='hidden' name='KEY' value=' $key ' />
5428 <form method='post' name='cafrm${key}b'><td align='center'>
5429 <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' />
5430 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
5431 <input type='hidden' name='KEY' value=' $key ' />
5433 <form method='post' name='cafrm${key}c'><td align='center'>
5434 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
5435 <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' />
5436 <input type='hidden' name='KEY' value=' $key ' />
5445 # If the file contains entries, print Key to action icons
5446 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5450 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5451 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
5452 <td class='base'> $Lang ::tr{'show certificate'}</td>
5453 <td> <img src='/images/media-floppy.png' alt=' $Lang ::tr{'download certificate'}' /></td>
5454 <td class='base'> $Lang ::tr{'download certificate'}</td>
5463 <form method='post' enctype='multipart/form-data'>
5464 <table width='100%' border='0'cellspacing='1' cellpadding='0'>
5466 <td class'base'><b>CA-Upload</b></td>
5469 <td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}:</td>
5470 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' align='left'/></td>
5471 <td nowrap='nowrap'><input type='file' name='FH' size='25' />
5472 <td nowrap='nowrap' align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td>
5476 <td colspan='4' align='right' width='80%'><input type='submit' name='ACTION' value=' $Lang ::tr{'show crl'}' /></td>
5479 <tr><td colspan=4><hr /></td></tr><tr>
5481 <td class'base'><b> $Lang ::tr{'ovpn dh parameters'}</b></td>
5485 <td class='base' nowrap='nowrap'> $Lang ::tr{'ovpn dh upload'}:</td>
5486 <td nowrap='nowrap'><size='15' align='left'/></td>
5487 <td nowrap='nowrap'><input type='file' name='FH' size='25' />
5488 <td colspan='4' align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload dh key'}' /></td>
5491 <td class='base' nowrap='nowrap'> $Lang ::tr{'ovpn dh new key'}:</td>
5492 <td nowrap='nowrap'><size='15' align='left'/></td>
5493 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'generate dh key'}' /></td>
5497 <tr><td colspan=4><hr /></td></tr><tr>
5501 if ( $srunning eq "yes" ) {
5502 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' disabled='disabled' /></div></form> \n " ;
5504 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' /></div></form> \n " ;
5506 & Header
:: closebox
();
5510 & Header
:: closepage
();