]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/ovpnmain.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2014 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 # Based on IPFireCore 77
25 use CGI qw
/:standard/ ;
30 use File
:: Temp qw
/ tempfile tempdir / ;
32 use Archive
:: Zip
qw(:ERROR_CODES :CONSTANTS) ;
34 require '/var/ipfire/general-functions.pl' ;
35 require "${General::swroot}/lang.pl" ;
36 require "${General::swroot}/header.pl" ;
37 require "${General::swroot}/countries.pl" ;
39 # enable only the following on debugging purpose
41 #use CGI::Carp 'fatalsToBrowser';
42 #workaround to suppress a warning when a variable is used only once
43 my @dummy = ( ${ Header
:: colourgreen
}, ${ Header
:: colourblue
} );
47 my %mainsettings = ();
48 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
49 & General
:: readhash
( "/srv/web/ipfire/html/themes/" . $mainsettings { 'THEME' }. "/include/colors.txt" , \
%color );
52 ### Initialize variables
65 my $errormessage = '' ;
67 my $routes_push_file = '' ;
68 my $confighost = "${General::swroot}/fwhosts/customhosts" ;
69 my $configgrp = "${General::swroot}/fwhosts/customgroups" ;
70 my $customnet = "${General::swroot}/fwhosts/customnetworks" ;
73 my $local_serverconf = "${General::swroot}/ovpn/scripts/server.conf.local" ;
74 my $local_clientconf = "${General::swroot}/ovpn/scripts/client.conf.local" ;
76 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
77 $cgiparams { 'ENABLED' } = 'off' ;
78 $cgiparams { 'ENABLED_BLUE' } = 'off' ;
79 $cgiparams { 'ENABLED_ORANGE' } = 'off' ;
80 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
81 $cgiparams { 'NAT' } = 'off' ;
82 $cgiparams { 'COMPRESSION' } = 'off' ;
83 $cgiparams { 'ONLY_PROPOSED' } = 'off' ;
84 $cgiparams { 'ACTION' } = '' ;
85 $cgiparams { 'CA_NAME' } = '' ;
86 $cgiparams { 'DH_NAME' } = 'dh1024.pem' ;
87 $cgiparams { 'DHLENGHT' } = '' ;
88 $cgiparams { 'DHCP_DOMAIN' } = '' ;
89 $cgiparams { 'DHCP_DNS' } = '' ;
90 $cgiparams { 'DHCP_WINS' } = '' ;
91 $cgiparams { 'ROUTES_PUSH' } = '' ;
92 $cgiparams { 'DCOMPLZO' } = 'off' ;
93 $cgiparams { 'MSSFIX' } = '' ;
94 $cgiparams { 'number' } = '' ;
95 $cgiparams { 'PMTU_DISCOVERY' } = '' ;
96 $cgiparams { 'DCIPHER' } = '' ;
97 $cgiparams { 'DAUTH' } = '' ;
98 $cgiparams { 'TLSAUTH' } = '' ;
99 $routes_push_file = "${General::swroot}/ovpn/routes_push" ;
101 # Add CCD files if not already presant
102 unless (- e
$routes_push_file ) {
103 open ( RPF
, "> $routes_push_file " );
106 unless (- e
"${General::swroot}/ovpn/ccd.conf" ) {
107 open ( CCDC
, ">${General::swroot}/ovpn/ccd.conf" );
110 unless (- e
"${General::swroot}/ovpn/ccdroute" ) {
111 open ( CCDR
, ">${General::swroot}/ovpn/ccdroute" );
114 unless (- e
"${General::swroot}/ovpn/ccdroute2" ) {
115 open ( CCDRT
, ">${General::swroot}/ovpn/ccdroute2" );
118 # Add additional configs if not already presant
119 unless (- e
" $local_serverconf " ) {
120 open ( LSC
, "> $local_serverconf " );
123 unless (- e
" $local_clientconf " ) {
124 open ( LCC
, "> $local_clientconf " );
128 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
130 # prepare openvpn config file
136 if ( $netsettings { 'CONFIG_TYPE' } == 2 ) { return 1 ;}
137 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
143 if ( $netsettings { 'CONFIG_TYPE' } == 3 ) { return 1 ;}
144 if ( $netsettings { 'CONFIG_TYPE' } == 4 ) { return 1 ;}
149 my $bytesize = shift ;
152 while ( abs ( $bytesize ) >= 1024 ){
153 $bytesize = $bytesize / 1024 ;
158 my @units = ( "Bytes" , "KB" , "MB" , "GB" , "TB" , "PB" , "EB" );
159 my $newsize =( int ( $bytesize * 100 + 0.5 ))/ 100 ;
160 return ( " $newsize $units [ $i ]" );
165 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/serial" )) {
169 if ( open ( FILE
, ">${General::swroot}/ovpn/certs/index.txt" )) {
173 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
174 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
175 unlink ( "${General::swroot}/ovpn/certs/01.pem" );
178 sub newcleanssldatabase
180 if (! - s
"${General::swroot}/ovpn/certs/serial" ) {
181 open ( FILE
, ">${General::swroot}(ovpn/certs/serial" );
185 if (! - s
">${General::swroot}/ovpn/certs/index.txt" ) {
186 system ( "touch ${General::swroot}/ovpn/certs/index.txt" );
188 unlink ( "${General::swroot}/ovpn/certs/index.txt.old" );
189 unlink ( "${General::swroot}/ovpn/certs/serial.old" );
194 if ( open ( FILE
, "${General::swroot}/ovpn/certs/serial.old" )) {
195 my $hexvalue = < FILE
>;
198 unlink ( "${General::swroot}/ovpn/certs/ $hexvalue .pem" );
202 sub writeserverconf
{
203 my %sovpnsettings = ();
205 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%sovpnsettings );
208 open ( CONF
, ">${General::swroot}/ovpn/server.conf" ) or die "Unable to open ${General::swroot}/ovpn/server.conf: $!" ;
210 print CONF
"#OpenVPN Server conf \n " ;
212 print CONF
"daemon openvpnserver \n " ;
213 print CONF
"writepid /var/run/openvpn.pid \n " ;
214 print CONF
"#DAN prepare OpenVPN for listening on blue and orange \n " ;
215 print CONF
";local $sovpnsettings {'VPN_IP'} \n " ;
216 print CONF
"dev $sovpnsettings {'DDEVICE'} \n " ;
217 print CONF
"proto $sovpnsettings {'DPROTOCOL'} \n " ;
218 print CONF
"port $sovpnsettings {'DDEST_PORT'} \n " ;
219 print CONF
"script-security 3 system \n " ;
220 print CONF
"ifconfig-pool-persist /var/ipfire/ovpn/ovpn-leases.db 3600 \n " ;
221 print CONF
"client-config-dir /var/ipfire/ovpn/ccd \n " ;
222 print CONF
"tls-server \n " ;
223 print CONF
"ca ${General::swroot}/ovpn/ca/cacert.pem \n " ;
224 print CONF
"cert ${General::swroot}/ovpn/certs/servercert.pem \n " ;
225 print CONF
"key ${General::swroot}/ovpn/certs/serverkey.pem \n " ;
226 print CONF
"dh ${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'} \n " ;
227 my @tempovpnsubnet = split ( "\/" , $sovpnsettings { 'DOVPN_SUBNET' });
228 print CONF
"server $tempovpnsubnet [0] $tempovpnsubnet [1] \n " ;
229 #print CONF "push \"route $netsettings{'GREEN_NETADDRESS'} $netsettings{'GREEN_NETMASK'}\"\n";
231 # Check if we are using mssfix, fragment or mtu-disc and set the corretct mtu of 1500.
232 # If we doesn't use one of them, we can use the configured mtu value.
233 if ( $sovpnsettings { 'MSSFIX' } eq 'on' )
234 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
235 elsif ( $sovpnsettings { 'FRAGMENT' } ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' )
236 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
237 elsif (( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
238 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
239 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'no' ))
240 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu 1500 \n " ; }
242 { print CONF
" $sovpnsettings {'DDEVICE'}-mtu $sovpnsettings {'DMTU'} \n " ; }
244 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
245 @temp = split ( /\n/ , $vpnsettings { 'ROUTES_PUSH' });
248 @tempovpnsubnet = split ( "\/" ,& General
:: ipcidr2msk
( $_ ));
249 print CONF
"push \" route " . $tempovpnsubnet [ 0 ]. " " . $tempovpnsubnet [ 1 ] . " \"\n " ;
254 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
255 foreach my $key ( keys %ccdconfhash ) {
256 my $a = $ccdconfhash { $key }[ 1 ];
257 my ( $b , $c ) = split ( /\/ /, $a );
258 print CONF
"route $b " .& General
:: cidrtosub
( $c ). " \n " ;
261 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
262 foreach my $key ( keys %ccdroutehash ) {
263 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
264 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
265 print CONF
"route $a $b \n " ;
270 if ( $sovpnsettings { CLIENT2CLIENT
} eq 'on' ) {
271 print CONF
"client-to-client \n " ;
273 if ( $sovpnsettings { MSSFIX
} eq 'on' ) {
274 print CONF
"mssfix \n " ;
276 if ( $sovpnsettings { FRAGMENT
} ne '' && $sovpnsettings { 'DPROTOCOL' } ne 'tcp' ) {
277 print CONF
"fragment $sovpnsettings {'FRAGMENT'} \n " ;
280 # Check if a valid operating mode has been choosen and use it.
281 if (( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
282 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
283 ( $sovpnsettings { 'PMTU_DISCOVERY' } eq 'no' )) {
284 print CONF
"mtu-disc $sovpnsettings {'PMTU_DISCOVERY'} \n " ;
287 if ( $sovpnsettings { KEEPALIVE_1
} > 0 && $sovpnsettings { KEEPALIVE_2
} > 0 ) {
288 print CONF
"keepalive $sovpnsettings {'KEEPALIVE_1'} $sovpnsettings {'KEEPALIVE_2'} \n " ;
290 print CONF
"status-version 1 \n " ;
291 print CONF
"status /var/run/ovpnserver.log 30 \n " ;
292 print CONF
"cipher $sovpnsettings {DCIPHER} \n " ;
293 if ( $sovpnsettings { 'DAUTH' } eq '' ) {
296 print CONF
"auth $sovpnsettings {'DAUTH'} \n " ;
298 if ( $sovpnsettings { 'TLSAUTH' } eq 'on' ) {
299 print CONF
"tls-auth ${General::swroot}/ovpn/certs/ta.key \n " ;
301 if ( $sovpnsettings { DCOMPLZO
} eq 'on' ) {
302 print CONF
"comp-lzo \n " ;
304 if ( $sovpnsettings { REDIRECT_GW_DEF1
} eq 'on' ) {
305 print CONF
"push \" redirect-gateway def1 \"\n " ;
307 if ( $sovpnsettings { DHCP_DOMAIN
} ne '' ) {
308 print CONF
"push \" dhcp-option DOMAIN $sovpnsettings {DHCP_DOMAIN} \"\n " ;
311 if ( $sovpnsettings { DHCP_DNS
} ne '' ) {
312 print CONF
"push \" dhcp-option DNS $sovpnsettings {DHCP_DNS} \"\n " ;
315 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
316 print CONF
"push \" dhcp-option WINS $sovpnsettings {DHCP_WINS} \"\n " ;
319 if ( $sovpnsettings { DHCP_WINS
} eq '' ) {
320 print CONF
"max-clients 100 \n " ;
322 if ( $sovpnsettings { DHCP_WINS
} ne '' ) {
323 print CONF
"max-clients $sovpnsettings {MAX_CLIENTS} \n " ;
325 print CONF
"tls-verify /usr/lib/openvpn/verify \n " ;
326 print CONF
"crl-verify /var/ipfire/ovpn/crls/cacrl.pem \n " ;
327 print CONF
"user nobody \n " ;
328 print CONF
"group nobody \n " ;
329 print CONF
"persist-key \n " ;
330 print CONF
"persist-tun \n " ;
331 if ( $sovpnsettings { LOG_VERB
} ne '' ) {
332 print CONF
"verb $sovpnsettings {LOG_VERB} \n " ;
334 print CONF
"verb 3 \n " ;
336 # Print server.conf.local if entries exist to server.conf
337 if ( !- z
$local_serverconf && $sovpnsettings { 'ADDITIONAL_CONFIGS' } eq 'on' ) {
338 open ( LSC
, " $local_serverconf " );
339 print CONF
" \n #--------------------------- \n " ;
340 print CONF
"# Start of custom directives \n " ;
341 print CONF
"# from server.conf.local \n " ;
342 print CONF
"#--------------------------- \n\n " ;
346 print CONF
" \n #----------------------------- \n " ;
347 print CONF
"# End of custom directives \n " ;
348 print CONF
"#----------------------------- \n " ;
357 if ( open ( FILE
, ">/var/run/ovpnserver.log" )) {
367 my %ccdconfhash = ();
369 my $ccdnetname = $_ [ 0 ];
370 if (- f
"${General::swroot}/ovpn/ovpnconfig" ){
371 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
372 foreach my $key ( keys %ccdhash ) {
373 if ( $ccdhash { $key }[ 32 ] eq $ccdnetname ) {
374 $errormessage = $Lang :: tr
{ 'ccd err hostinnet' };
379 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
380 foreach my $key ( keys %ccdconfhash ) {
381 if ( $ccdconfhash { $key }[ 0 ] eq $ccdnetname ){
382 delete $ccdconfhash { $key };
385 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
407 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err name' }. "<br>" ;
411 if (!& General
:: validhostname
( $ccdname ))
413 $errormessage = $Lang :: tr
{ 'ccd err invalidname' };
417 ( $ccdip , $subcidr ) = split ( /\/ /, $ccdnet );
418 $subcidr =& General
:: iporsubtocidr
( $subcidr );
422 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
426 if (!& General
:: validipandmask
( $ccdnet )){
427 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
431 $errormessage =& General
:: checksubnets
( $ccdname , $ccdnet );
434 if (! $errormessage ) {
436 $baseaddress =& General
:: getnetworkip
( $ccdip , $subcidr );
437 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
438 my $key = & General
:: findhasharraykey
( \
%ccdconfhash );
439 foreach my $i ( 0 .. 1 ) { $ccdconfhash { $key }[ $i ] = "" ;}
440 $ccdconfhash { $key }[ 0 ] = $ccdname ;
441 $ccdconfhash { $key }[ 1 ] = $baseaddress . "/" . $subcidr ;
442 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
444 $cgiparams { 'ccdname' }= '' ;
445 $cgiparams { 'ccdsubnet' }= '' ;
457 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
458 foreach my $key ( keys %ccdconfhash ) {
459 if ( $ccdconfhash { $key }[ 0 ] eq $oldname ) {
460 foreach my $key1 ( keys %ccdconfhash ) {
461 if ( $ccdconfhash { $key1 }[ 0 ] eq $newname ){
462 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err netadrexist' };
465 $ccdconfhash { $key }[ 0 ]= $newname ;
466 & General
:: writehasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
473 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
474 foreach my $key ( keys %ccdhash ) {
475 if ( $ccdhash { $key }[ 32 ] eq $oldname ) {
476 $ccdhash { $key }[ 32 ]= $newname ;
477 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
486 my $ccdnetwork = $_ [ 0 ];
489 @octets = split ( "\/" , $ccdnetwork );
490 @subnet = split /\./ , & General
:: cidrtosub
( $octets [ 1 ]);
503 my ( $ip1 , $ip2 , $ip3 , $ip4 )= split /\./ , $ipin ;
511 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
512 $iprange [ 0 ]= $ip1 . "." . $ip2 . "." . $ip3 . "." .( $ip4 + 2 );
513 for ( my $i = 1 ; $i <= $count ; $i ++) {
514 my $tmpip = $iprange [ $i - 1 ];
516 $iprange [ $i ]= & General
:: getnextip
( $tmpip , 4 );
519 foreach my $key ( keys %ccdhash ) {
521 foreach my $tmp ( @iprange ){
522 my ( $net , $sub ) = split ( /\/ /, $ccdhash { $key }[ 33 ]);
524 if ( $hasip ne $ccdhash { $key }[ 33 ] ){
525 splice ( @iprange , $r , 1 );
537 my ( $ccdip , $subcidr ) = split ( "/" , $_ [ 0 ]);
539 my @allccdips =& getccdadresses
( $ccdip , $subcidr ,& ccdmaxclients
( $ccdip . "/" . $subcidr ), $tz );
540 print "<select name=' $boxname ' STYLE='font-family : arial; font-size : 9pt; width:130px;' >" ;
541 foreach ( @allccdips ) {
544 print "<option value=' $ip ' " ;
545 if ( $ip eq $cgiparams { $boxname } ){
548 print "> $ip </option>" ;
558 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
559 foreach my $key ( keys %ccdhash ) {
560 if ( $ccdhash { $key }[ 32 ] eq $name ){ $i ++;}
565 sub check_routes_push
568 my ( $ip , $cidr ) = split ( /\/ /, $val );
569 ##check for existing routes in routes_push
570 if (- e
"${General::swroot}/ovpn/routes_push" ) {
571 open ( FILE
, "${General::swroot}/ovpn/routes_push" );
575 my ( $ip2 , $cidr2 ) = split ( /\/ /, " $_ " );
576 my $val2 = $ip2 . "/" .& General
:: iporsubtodec
( $cidr2 );
582 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: iporsubtodec
( $cidr2 ))){
595 my ( $ip , $cidr ) = split ( /\/ /, $val );
596 #check for existing routes in ccdroute
597 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
598 foreach my $key ( keys %ccdroutehash ) {
599 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
600 if (& General
:: iporsubtodec
( $val ) eq $ccdroutehash { $key }[ $i ] && $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' }){
603 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
605 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )&& $ccdroutehash { $key }[ 0 ] ne $cgiparams { 'NAME' } ){
616 my ( $ip , $cidr ) = split ( /\/ /, $val );
617 #check for existing routes in ccdroute
618 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
619 foreach my $key ( keys %ccdconfhash ) {
620 if (& General
:: iporsubtocidr
( $val ) eq $ccdconfhash { $key }[ 1 ]){
623 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdconfhash { $key }[ 1 ]);
625 if (& General
:: IpInSubnet
( $ip , $ip2 ,& General
:: cidrtosub
( $cidr2 ))){
639 my $ipdotmask = $_ [ 0 ];
640 if (& General
:: validip
( $ipdotmask )) { return 0 ; }
641 if (!( $ipdotmask =~ /^(.*?)\/ (.* ?
)$/)) { }
643 if (( $mask =~ /\./ )) { return 0 ; }
647 # -------------------------------------------------------------------
649 sub write_routepushfile
651 open ( FILE
, "> $routes_push_file " );
653 if ( $vpnsettings { 'ROUTES_PUSH' } ne '' ) {
654 print FILE
$vpnsettings { 'ROUTES_PUSH' };
659 sub read_routepushfile
661 if (- e
" $routes_push_file " ) {
662 open ( FILE
, " $routes_push_file " );
663 delete $vpnsettings { 'ROUTES_PUSH' };
664 while (< FILE
>) { $vpnsettings { 'ROUTES_PUSH' } .= $_ };
666 $cgiparams { 'ROUTES_PUSH' } = $vpnsettings { 'ROUTES_PUSH' };
671 sub writecollectdconf
{
675 open ( COLLECTDVPN
, ">${General::swroot}/ovpn/collectd.vpn" ) or die "Unable to open collectd.vpn: $!" ;
676 print COLLECTDVPN
"Loadplugin openvpn \n " ;
677 print COLLECTDVPN
" \n " ;
678 print COLLECTDVPN
"<Plugin openvpn> \n " ;
679 print COLLECTDVPN
"Statusfile \" /var/run/ovpnserver.log \"\n " ;
681 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%ccdhash );
682 foreach my $key ( keys %ccdhash ) {
683 if ( $ccdhash { $key }[ 0 ] eq 'on' && $ccdhash { $key }[ 3 ] eq 'net' ) {
684 print COLLECTDVPN
"Statusfile \" /var/run/openvpn/ $ccdhash { $key }[1]-n2n \"\n " ;
688 print COLLECTDVPN
"</Plugin> \n " ;
691 # Reload collectd afterwards
692 system ( "/usr/local/bin/collectdctrl restart &>/dev/null" );
695 #hier die refresh page
696 if ( - e
"${General::swroot}/ovpn/gencanow" ) {
698 $refresh = "<meta http-equiv='refresh' content='15;' />" ;
699 & Header
:: showhttpheaders
();
700 & Header
:: openpage
( $Lang :: tr
{ 'OVPN' }, 1 , $refresh );
701 & Header
:: openbigbox
( '100%' , 'center' );
702 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
703 print "<tr> \n <td align='center'><img src='/images/clock.gif' alt='' /></td> \n " ;
704 print "<td colspan='2'><font color='red'>Please be patient this realy can take some time on older hardware...</font></td></tr> \n " ;
706 & Header
:: closebigbox
();
707 & Header
:: closepage
();
710 ##hier die refresh page
714 ### OpenVPN Server Control
716 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' } ||
717 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' } ||
718 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart ovpn server' }) {
719 #start openvpn server
720 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'start ovpn server' }){
722 system ( '/usr/local/bin/openvpnctrl' , '-s' );
725 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'stop ovpn server' }){
726 system ( '/usr/local/bin/openvpnctrl' , '-k' );
729 # #restart openvpn server
730 # if ($cgiparams{'ACTION'} eq $Lang::tr{'restart ovpn server'}){
731 #workarund, till SIGHUP also works when running as nobody
732 # system('/usr/local/bin/openvpnctrl', '-r');
738 ### Save Advanced options
741 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save-adv-options' }) {
742 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
743 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
744 #DAN this value has to leave.
745 #new settings for daemon
746 $vpnsettings { 'LOG_VERB' } = $cgiparams { 'LOG_VERB' };
747 $vpnsettings { 'KEEPALIVE_1' } = $cgiparams { 'KEEPALIVE_1' };
748 $vpnsettings { 'KEEPALIVE_2' } = $cgiparams { 'KEEPALIVE_2' };
749 $vpnsettings { 'MAX_CLIENTS' } = $cgiparams { 'MAX_CLIENTS' };
750 $vpnsettings { 'REDIRECT_GW_DEF1' } = $cgiparams { 'REDIRECT_GW_DEF1' };
751 $vpnsettings { 'CLIENT2CLIENT' } = $cgiparams { 'CLIENT2CLIENT' };
752 $vpnsettings { 'ADDITIONAL_CONFIGS' } = $cgiparams { 'ADDITIONAL_CONFIGS' };
753 $vpnsettings { 'DHCP_DOMAIN' } = $cgiparams { 'DHCP_DOMAIN' };
754 $vpnsettings { 'DHCP_DNS' } = $cgiparams { 'DHCP_DNS' };
755 $vpnsettings { 'DHCP_WINS' } = $cgiparams { 'DHCP_WINS' };
756 $vpnsettings { 'ROUTES_PUSH' } = $cgiparams { 'ROUTES_PUSH' };
757 $vpnsettings { 'PMTU_DISCOVERY' } = $cgiparams { 'PMTU_DISCOVERY' };
758 $vpnsettings { 'DAUTH' } = $cgiparams { 'DAUTH' };
759 $vpnsettings { 'TLSAUTH' } = $cgiparams { 'TLSAUTH' };
762 if ( $cgiparams { 'FRAGMENT' } eq '' ) {
763 delete $vpnsettings { 'FRAGMENT' };
765 if ( $cgiparams { 'FRAGMENT' } !~ /^[0-9]+$/ ) {
766 $errormessage = "Incorrect value, please insert only numbers." ;
769 $vpnsettings { 'FRAGMENT' } = $cgiparams { 'FRAGMENT' };
773 if ( $cgiparams { 'MSSFIX' } ne 'on' ) {
774 delete $vpnsettings { 'MSSFIX' };
776 $vpnsettings { 'MSSFIX' } = $cgiparams { 'MSSFIX' };
779 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
780 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
781 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
783 if (( $cgiparams { 'MSSFIX' } eq 'on' ) || ( $cgiparams { 'FRAGMENT' } ne '' )) {
784 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
789 if ( $cgiparams { 'DHCP_DOMAIN' } ne '' ){
790 unless (& General
:: validdomainname
( $cgiparams { 'DHCP_DOMAIN' }) || & General
:: validip
( $cgiparams { 'DHCP_DOMAIN' })) {
791 $errormessage = $Lang :: tr
{ 'invalid input for dhcp domain' };
795 if ( $cgiparams { 'DHCP_DNS' } ne '' ){
796 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_DNS' }) || & General
:: validip
( $cgiparams { 'DHCP_DNS' })) {
797 $errormessage = $Lang :: tr
{ 'invalid input for dhcp dns' };
801 if ( $cgiparams { 'DHCP_WINS' } ne '' ){
802 unless (& General
:: validfqdn
( $cgiparams { 'DHCP_WINS' }) || & General
:: validip
( $cgiparams { 'DHCP_WINS' })) {
803 $errormessage = $Lang :: tr
{ 'invalid input for dhcp wins' };
807 if ( $cgiparams { 'ROUTES_PUSH' } ne '' ){
808 @temp = split ( /\n/ , $cgiparams { 'ROUTES_PUSH' });
809 undef $vpnsettings { 'ROUTES_PUSH' };
811 foreach my $tmpip ( @temp )
813 s/^\s+//g ; s/\s+$//g ;
818 unless (& General
:: validipandmask
( $tmpip )) {
819 $errormessage = " $tmpip " . $Lang :: tr
{ 'ovpn errmsg invalid ip or mask' };
822 my ( $ip , $cidr ) = split ( "\/" ,& General
:: ipcidr2msk
( $tmpip ));
824 if ( $ip eq $netsettings { 'GREEN_NETADDRESS' } && $cidr eq $netsettings { 'GREEN_NETMASK' }) {
825 $errormessage = $Lang :: tr
{ 'ovpn errmsg green already pushed' };
830 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
831 foreach my $key ( keys %ccdroutehash ) {
832 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
833 if ( $ip . "/" . $cidr eq $ccdroutehash { $key }[ $i ] ){
834 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
837 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $i ]);
838 if (& General
:: IpInSubnet
( $ip , $ip2 , $cidr2 )){
839 $errormessage = "Route $ip \/ $cidr " . $Lang :: tr
{ 'ccd err inuse' }. " $ccdroutehash { $key }[0]" ;
847 $vpnsettings { 'ROUTES_PUSH' } .= $tmpip . " \n " ;
850 & write_routepushfile
;
851 undef $vpnsettings { 'ROUTES_PUSH' };
854 undef $vpnsettings { 'ROUTES_PUSH' };
855 & write_routepushfile
;
857 if (( length ( $cgiparams { 'MAX_CLIENTS' }) == 0 ) || (( $cgiparams { 'MAX_CLIENTS' }) < 1 ) || (( $cgiparams { 'MAX_CLIENTS' }) > 255 )) {
858 $errormessage = $Lang :: tr
{ 'invalid input for max clients' };
861 if ( $cgiparams { 'KEEPALIVE_1' } ne '' ) {
862 if ( $cgiparams { 'KEEPALIVE_1' } !~ /^[0-9]+$/ ) {
863 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1' };
867 if ( $cgiparams { 'KEEPALIVE_2' } ne '' ){
868 if ( $cgiparams { 'KEEPALIVE_2' } !~ /^[0-9]+$/ ) {
869 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 2' };
873 if ( $cgiparams { 'KEEPALIVE_2' } < ( $cgiparams { 'KEEPALIVE_1' } * 2 )){
874 $errormessage = $Lang :: tr
{ 'invalid input for keepalive 1:2' };
877 # Create ta.key for tls-auth if not presant
878 if ( $cgiparams { 'TLSAUTH' } eq 'on' ) {
879 if ( ! - e
"${General::swroot}/ovpn/certs/ta.key" ) {
880 system ( '/usr/sbin/openvpn' , '--genkey' , '--secret' , "${General::swroot}/ovpn/certs/ta.key" );
882 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
888 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
889 & writeserverconf
(); #hier ok
896 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'server' )
899 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
900 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
901 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
904 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
905 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
907 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: $!" ;
910 print SERVERCONF
"# IPFire n2n Open VPN Server Config by ummeegge und m.a.d \n " ;
911 print SERVERCONF
" \n " ;
912 print SERVERCONF
"# User Security \n " ;
913 print SERVERCONF
"user nobody \n " ;
914 print SERVERCONF
"group nobody \n " ;
915 print SERVERCONF
"persist-tun \n " ;
916 print SERVERCONF
"persist-key \n " ;
917 print SERVERCONF
"script-security 2 \n " ;
918 print SERVERCONF
"# IP/DNS for remote Server Gateway \n " ;
920 if ( $cgiparams { 'REMOTE' } ne '' ) {
921 print SERVERCONF
"remote $cgiparams {'REMOTE'} \n " ;
924 print SERVERCONF
"float \n " ;
925 print SERVERCONF
"# IP adresses of the VPN Subnet \n " ;
926 print SERVERCONF
"ifconfig $ovsubnet .1 $ovsubnet .2 \n " ;
927 print SERVERCONF
"# Client Gateway Network \n " ;
928 print SERVERCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
929 print SERVERCONF
"# tun Device \n " ;
930 print SERVERCONF
"dev tun \n " ;
931 print SERVERCONF
"#Logfile for statistics \n " ;
932 print SERVERCONF
"status-version 1 \n " ;
933 print SERVERCONF
"status /var/run/openvpn/ $cgiparams {'NAME'}-n2n 10 \n " ;
934 print SERVERCONF
"# Port and Protokol \n " ;
935 print SERVERCONF
"port $cgiparams {'DEST_PORT'} \n " ;
937 if ( $cgiparams { 'PROTOCOL' } eq 'tcp' ) {
938 print SERVERCONF
"proto tcp-server \n " ;
939 print SERVERCONF
"# Packet size \n " ;
940 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1400' } else { $tunmtu = $cgiparams { 'MTU' }};
941 print SERVERCONF
"tun-mtu $tunmtu \n " ;
944 if ( $cgiparams { 'PROTOCOL' } eq 'udp' ) {
945 print SERVERCONF
"proto udp \n " ;
946 print SERVERCONF
"# Paketsize \n " ;
947 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
948 print SERVERCONF
"tun-mtu $tunmtu \n " ;
949 if ( $cgiparams { 'FRAGMENT' } ne '' ) { print SERVERCONF
"fragment $cgiparams {'FRAGMENT'} \n " ;}
950 if ( $cgiparams { 'MSSFIX' } eq 'on' ) { print SERVERCONF
"mssfix \n " ; };
953 # Check if a valid operating mode has been choosen and use it.
954 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
955 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
956 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
957 if (( $cgiparams { 'MSSFIX' } ne 'on' ) || ( $cgiparams { 'FRAGMENT' } eq '' )) {
958 if ( $cgiparams { 'MTU' } eq '1500' ) {
959 print SERVERCONF
"mtu-disc $cgiparams {'PMTU_DISCOVERY'} \n " ;
963 print SERVERCONF
"# Auth. Server \n " ;
964 print SERVERCONF
"tls-server \n " ;
965 print SERVERCONF
"ca ${General::swroot}/ovpn/ca/cacert.pem \n " ;
966 print SERVERCONF
"cert ${General::swroot}/ovpn/certs/servercert.pem \n " ;
967 print SERVERCONF
"key ${General::swroot}/ovpn/certs/serverkey.pem \n " ;
968 print SERVERCONF
"dh ${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'} \n " ;
969 print SERVERCONF
"# Cipher \n " ;
970 print SERVERCONF
"cipher $cgiparams {'DCIPHER'} \n " ;
971 if ( $cgiparams { 'DAUTH' } eq '' ) {
972 print SERVERCONF
"auth SHA1 \n " ;
974 print SERVERCONF
"# HMAC algorithm \n " ;
975 print SERVERCONF
"auth $cgiparams {'DAUTH'} \n " ;
977 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
978 print SERVERCONF
"# Enable Compression \n " ;
979 print SERVERCONF
"comp-lzo \n " ;
981 print SERVERCONF
"# Debug Level \n " ;
982 print SERVERCONF
"verb 3 \n " ;
983 print SERVERCONF
"# Tunnel check \n " ;
984 print SERVERCONF
"keepalive 10 60 \n " ;
985 print SERVERCONF
"# Start as daemon \n " ;
986 print SERVERCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
987 print SERVERCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
988 print SERVERCONF
"# Activate Management Interface and Port \n " ;
989 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) { print SERVERCONF
"management localhost $cgiparams {'DEST_PORT'} \n " }
990 else { print SERVERCONF
"management localhost $cgiparams {'OVPN_MGMT'} \n " };
999 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq 'net' && $cgiparams { 'SIDE' } eq 'client' )
1002 my @ovsubnettemp = split ( /\./ , $cgiparams { 'OVPN_SUBNET' });
1003 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
1004 my @remsubnet = split ( /\/ /, $cgiparams { 'REMOTE_SUBNET' });
1007 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
1008 unless (- d
"${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" , 0770 or die "Unable to create dir $!" ;}
1010 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: $!" ;
1012 flock CLIENTCONF
, 2 ;
1013 print CLIENTCONF
"# IPFire rewritten n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
1014 print CLIENTCONF
"# \n " ;
1015 print CLIENTCONF
"# User Security \n " ;
1016 print CLIENTCONF
"user nobody \n " ;
1017 print CLIENTCONF
"group nobody \n " ;
1018 print CLIENTCONF
"persist-tun \n " ;
1019 print CLIENTCONF
"persist-key \n " ;
1020 print CLIENTCONF
"script-security 2 \n " ;
1021 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
1022 print CLIENTCONF
"remote $cgiparams {'REMOTE'} \n " ;
1023 print CLIENTCONF
"float \n " ;
1024 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
1025 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
1026 print CLIENTCONF
"# Server Gateway Network \n " ;
1027 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
1028 print CLIENTCONF
"# tun Device \n " ;
1029 print CLIENTCONF
"dev tun \n " ;
1030 print CLIENTCONF
"# Port and Protokol \n " ;
1031 print CLIENTCONF
"port $cgiparams {'DEST_PORT'} \n " ;
1033 if ( $cgiparams { 'PROTOCOL' } eq 'tcp' ) {
1034 print CLIENTCONF
"proto tcp-client \n " ;
1035 print CLIENTCONF
"# Packet size \n " ;
1036 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1400' } else { $tunmtu = $cgiparams { 'MTU' }};
1037 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
1040 if ( $cgiparams { 'PROTOCOL' } eq 'udp' ) {
1041 print CLIENTCONF
"proto udp \n " ;
1042 print CLIENTCONF
"# Paketsize \n " ;
1043 if ( $cgiparams { 'MTU' } eq '' ) { $tunmtu = '1500' } else { $tunmtu = $cgiparams { 'MTU' }};
1044 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
1045 if ( $cgiparams { 'FRAGMENT' } ne '' ) { print CLIENTCONF
"fragment $cgiparams {'FRAGMENT'} \n " ;}
1046 if ( $cgiparams { 'MSSFIX' } eq 'on' ) { print CLIENTCONF
"mssfix \n " ; };
1049 # Check if a valid operating mode has been choosen and use it.
1050 if (( $cgiparams { 'PMTU_DISCOVERY' } eq 'yes' ) ||
1051 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
1052 ( $cgiparams { 'PMTU_DISCOVERY' } eq 'no' )) {
1053 if (( $cgiparams { 'MSSFIX' } ne 'on' ) || ( $cgiparams { 'FRAGMENT' } eq '' )) {
1054 if ( $cgiparams { 'MTU' } eq '1500' ) {
1055 print CLIENTCONF
"mtu-disc $cgiparams {'PMTU_DISCOVERY'} \n " ;
1060 print CLIENTCONF
"ns-cert-type server \n " ;
1061 print CLIENTCONF
"# Auth. Client \n " ;
1062 print CLIENTCONF
"tls-client \n " ;
1063 print CLIENTCONF
"# Cipher \n " ;
1064 print CLIENTCONF
"cipher $cgiparams {'DCIPHER'} \n " ;
1065 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12 \r\n " ;
1066 if ( $cgiparams { 'DAUTH' } eq '' ) {
1067 print CLIENTCONF
"auth SHA1 \n " ;
1069 print CLIENTCONF
"# HMAC algorithm \n " ;
1070 print CLIENTCONF
"auth $cgiparams {'DAUTH'} \n " ;
1072 if ( $cgiparams { 'COMPLZO' } eq 'on' ) {
1073 print CLIENTCONF
"# Enable Compression \n " ;
1074 print CLIENTCONF
"comp-lzo \n " ;
1076 print CLIENTCONF
"# Debug Level \n " ;
1077 print CLIENTCONF
"verb 3 \n " ;
1078 print CLIENTCONF
"# Tunnel check \n " ;
1079 print CLIENTCONF
"keepalive 10 60 \n " ;
1080 print CLIENTCONF
"# Start as daemon \n " ;
1081 print CLIENTCONF
"daemon $cgiparams {'NAME'}n2n \n " ;
1082 print CLIENTCONF
"writepid /var/run/ $cgiparams {'NAME'}n2n.pid \n " ;
1083 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
1084 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) { print CLIENTCONF
"management localhost $cgiparams {'DEST_PORT'} \n " }
1085 else { print CLIENTCONF
"management localhost $cgiparams {'OVPN_MGMT'} \n " };
1091 ### Save main settings
1094 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
1095 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1096 #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too,
1097 #DAN this value has to leave.
1098 if ( $cgiparams { 'ENABLED' } eq 'on' ){
1099 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })) {
1100 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1101 goto SETTINGS_ERROR
;
1105 if (! & General
:: validipandmask
( $cgiparams { 'DOVPN_SUBNET' })) {
1106 $errormessage = $Lang :: tr
{ 'ovpn subnet is invalid' };
1107 goto SETTINGS_ERROR
;
1109 my @tmpovpnsubnet = split ( "\/" , $cgiparams { 'DOVPN_SUBNET' });
1111 if (& General
:: IpInSubnet
( $netsettings { 'RED_ADDRESS' },
1112 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1113 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire RED Network $netsettings {'RED_ADDRESS'}" ;
1114 goto SETTINGS_ERROR
;
1117 if (& General
:: IpInSubnet
( $netsettings { 'GREEN_ADDRESS' },
1118 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1119 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Green Network $netsettings {'GREEN_ADDRESS'}" ;
1120 goto SETTINGS_ERROR
;
1123 if (& General
:: IpInSubnet
( $netsettings { 'BLUE_ADDRESS' },
1124 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1125 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Blue Network $netsettings {'BLUE_ADDRESS'}" ;
1126 goto SETTINGS_ERROR
;
1129 if (& General
:: IpInSubnet
( $netsettings { 'ORANGE_ADDRESS' },
1130 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1131 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire Orange Network $netsettings {'ORANGE_ADDRESS'}" ;
1132 goto SETTINGS_ERROR
;
1134 open ( ALIASES
, "${General::swroot}/ethernet/aliases" ) or die 'Unable to open aliases file.' ;
1138 my @tempalias = split ( /\,/ , $_ );
1139 if ( $tempalias [ 1 ] eq 'on' ) {
1140 if (& General
:: IpInSubnet
( $tempalias [ 0 ] ,
1141 $tmpovpnsubnet [ 0 ], $tmpovpnsubnet [ 1 ])) {
1142 $errormessage = " $Lang ::tr{'ovpn subnet overlap'} IPFire alias entry $tempalias [0]" ;
1147 if ( $errormessage ne '' ){
1148 goto SETTINGS_ERROR
;
1150 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1151 $errormessage = $Lang :: tr
{ 'invalid input' };
1152 goto SETTINGS_ERROR
;
1154 if (( length ( $cgiparams { 'DMTU' })== 0 ) || (( $cgiparams { 'DMTU' }) < 1000 )) {
1155 $errormessage = $Lang :: tr
{ 'invalid mtu input' };
1156 goto SETTINGS_ERROR
;
1159 unless (& General
:: validport
( $cgiparams { 'DDEST_PORT' })) {
1160 $errormessage = $Lang :: tr
{ 'invalid port' };
1161 goto SETTINGS_ERROR
;
1164 $vpnsettings { 'ENABLED_BLUE' } = $cgiparams { 'ENABLED_BLUE' };
1165 $vpnsettings { 'ENABLED_ORANGE' } = $cgiparams { 'ENABLED_ORANGE' };
1166 $vpnsettings { 'ENABLED' } = $cgiparams { 'ENABLED' };
1167 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
1168 #new settings for daemon
1169 $vpnsettings { 'DOVPN_SUBNET' } = $cgiparams { 'DOVPN_SUBNET' };
1170 $vpnsettings { 'DDEVICE' } = $cgiparams { 'DDEVICE' };
1171 $vpnsettings { 'DPROTOCOL' } = $cgiparams { 'DPROTOCOL' };
1172 $vpnsettings { 'DDEST_PORT' } = $cgiparams { 'DDEST_PORT' };
1173 $vpnsettings { 'DMTU' } = $cgiparams { 'DMTU' };
1174 $vpnsettings { 'DCOMPLZO' } = $cgiparams { 'DCOMPLZO' };
1175 $vpnsettings { 'DCIPHER' } = $cgiparams { 'DCIPHER' };
1178 if ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' ) { system ( "touch ${General::swroot}/ovpn/enable_blue 2>/dev/null" );} else { system ( "unlink ${General::swroot}/ovpn/enable_blue 2>/dev/null" );}
1179 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' ) { system ( "touch ${General::swroot}/ovpn/enable_orange 2>/dev/null" );} else { system ( "unlink ${General::swroot}/ovpn/enable_orange 2>/dev/null" );}
1180 if ( $vpnsettings { 'ENABLED' } eq 'on' ) { system ( "touch ${General::swroot}/ovpn/enable 2>/dev/null" );} else { system ( "unlink ${General::swroot}/ovpn/enable 2>/dev/null" );}
1181 #new settings for daemon
1182 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1183 & writeserverconf
(); #hier ok
1186 ### Reset all step 2
1188 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1190 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1192 foreach my $key ( keys %confighash ) {
1193 my $name = $confighash { $cgiparams { ' $key ' }}[ 1 ];
1195 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
1196 delete $confighash { $cgiparams { ' $key ' }};
1199 system ( "/usr/local/bin/openvpnctrl -drrd $name " );
1201 while ( $file = glob ( "${General::swroot}/ovpn/ca/*" )) {
1204 while ( $file = glob ( "${General::swroot}/ovpn/certs/*" )) {
1207 while ( $file = glob ( "${General::swroot}/ovpn/crls/*" )) {
1210 & cleanssldatabase
();
1211 if ( open ( FILE
, ">${General::swroot}/ovpn/caconfig" )) {
1215 if ( open ( FILE
, ">${General::swroot}/ovpn/ccdroute" )) {
1219 if ( open ( FILE
, ">${General::swroot}/ovpn/ccdroute2" )) {
1223 while ( $file = glob ( "${General::swroot}/ovpn/ccd/*" )) {
1226 while ( $file = glob ( "${General::swroot}/ovpn/ccd/*" )) {
1229 if ( open ( FILE
, ">${General::swroot}/ovpn/ovpn-leases.db" )) {
1233 if ( open ( FILE
, ">${General::swroot}/ovpn/ovpnconfig" )) {
1237 while ( $file = glob ( "${General::swroot}/ovpn/n2nconf/*" )) {
1238 system ( "rm -rf $file " );
1241 # Remove everything from the collectd configuration
1242 & writecollectdconf
();
1244 #&writeserverconf();
1246 ### Reset all step 1
1248 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' }) {
1249 & Header
:: showhttpheaders
();
1250 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1251 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1252 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
1254 <form method='post'>
1255 <table width='100%'>
1258 <input type='hidden' name='AREUSURE' value='yes' />
1259 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1260 $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}</td>
1263 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' />
1264 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
1270 & Header
:: closebox
();
1271 & Header
:: closebigbox
();
1272 & Header
:: closepage
();
1276 ### Generate DH key step 2
1278 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate dh key' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1279 # Delete if old key exists
1280 if (- f
"${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ) {
1281 unlink "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ;
1283 # Create Diffie Hellmann Parameter
1284 system ( '/usr/bin/openssl' , 'dhparam' , '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" , " $cgiparams {'DHLENGHT'}" );
1286 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1287 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1291 ### Generate DH key step 1
1293 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate dh key' }) {
1294 & Header
:: showhttpheaders
();
1295 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1296 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1297 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'gen dh'}:" );
1299 <table width='100%'>
1301 <td width='20%'> </td> <td width='15%'></td> <td width='65%'></td>
1304 <td class='base'> $Lang ::tr{'ovpn dh'}:</td>
1306 <form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1307 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1308 <select name='DHLENGHT'>
1309 <option value='1024' $selected {'DHLENGHT'}{'1024'}>1024 $Lang ::tr{'bit'}</option>
1310 <option value='2048' $selected {'DHLENGHT'}{'2048'}>2048 $Lang ::tr{'bit'}</option>
1311 <option value='3072' $selected {'DHLENGHT'}{'3072'}>3072 $Lang ::tr{'bit'}</option>
1312 <option value='4096' $selected {'DHLENGHT'}{'4096'}>4096 $Lang ::tr{'bit'}</option>
1316 <tr><td colspan='4'><br></td></tr>
1318 <table width='100%'>
1320 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}: </font></b> $Lang ::tr{'dh key warn'}
1323 <td class='base'> $Lang ::tr{'dh key warn1'}</td>
1325 <tr><td colspan='2'><br></td></tr>
1327 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'generate dh key'}' /></td>
1334 & Header
:: closebox
();
1335 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1336 & Header
:: closebigbox
();
1337 & Header
:: closepage
();
1343 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload dh key' }) {
1344 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1345 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1346 goto UPLOADCA_ERROR
;
1348 # Move uploaded dh key to a temporary file
1349 ( my $fh , my $filename ) = tempfile
( );
1350 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1352 goto UPLOADCA_ERROR
;
1354 my $temp = `/usr/bin/openssl dhparam -text -in $filename ` ;
1355 if ( $temp !~ /DH Parameters: \((1024|2048|3072|4096) bit\)/ ) {
1356 $errormessage = $Lang :: tr
{ 'not a valid dh key' };
1358 goto UPLOADCA_ERROR
;
1360 # Delete if old key exists
1361 if (- f
"${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ) {
1362 unlink "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ;
1364 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" );
1366 $errormessage = " $Lang ::tr{'dh key move failed'}: $!" ;
1368 goto UPLOADCA_ERROR
;
1373 ### Upload CA Certificate
1375 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
1376 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1378 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1379 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1380 goto UPLOADCA_ERROR
;
1383 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
1384 $errormessage = $Lang :: tr
{ 'name too long' };
1388 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
1389 $errormessage = $Lang :: tr
{ 'name is invalid' };
1390 goto UPLOADCA_ERROR
;
1393 # Check if there is no other entry with this name
1394 foreach my $key ( keys %cahash ) {
1395 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
1396 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
1397 goto UPLOADCA_ERROR
;
1401 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1402 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1403 goto UPLOADCA_ERROR
;
1405 # Move uploaded ca to a temporary file
1406 ( my $fh , my $filename ) = tempfile
( );
1407 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1409 goto UPLOADCA_ERROR
;
1411 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
1412 if ( $temp !~ /CA:TRUE/i ) {
1413 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1415 goto UPLOADCA_ERROR
;
1417 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1419 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1421 goto UPLOADCA_ERROR
;
1425 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem` ;
1426 $casubject =~ /Subject: (.*)[\n]/ ;
1428 $casubject =~ s
+/ Email
+, E
+;
1429 $casubject =~ s/ ST=/ S=/ ;
1430 $casubject = & Header
:: cleanhtml
( $casubject );
1432 my $key = & General
:: findhasharraykey
( \
%cahash );
1433 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1434 $cahash { $key }[ 1 ] = $casubject ;
1435 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1436 # system('/usr/local/bin/ipsecctrl', 'R');
1441 ### Display ca certificate
1443 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
1444 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1446 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1447 & Header
:: showhttpheaders
();
1448 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1449 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1450 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ca certificate'}:" );
1451 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1452 $output = & Header
:: cleanhtml
( $output , "y" );
1453 print "<pre> $output </pre> \n " ;
1454 & Header
:: closebox
();
1455 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1456 & Header
:: closebigbox
();
1457 & Header
:: closepage
();
1460 $errormessage = $Lang :: tr
{ 'invalid key' };
1464 ### Download ca certificate
1466 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
1467 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1469 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1470 print "Content-Type: application/octet-stream \r\n " ;
1471 print "Content-Disposition: filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
1472 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1475 $errormessage = $Lang :: tr
{ 'invalid key' };
1479 ### Remove ca certificate (step 2)
1481 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1482 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1483 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1485 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1486 foreach my $key ( keys %confighash ) {
1487 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
1488 if ( $test =~ /: OK/ ) {
1490 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1491 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
1492 # system('/usr/local/bin/ipsecctrl', 'D', $key);
1494 unlink ( "${General::swroot}/ovpn//certs/ $confighash { $key }[1]cert.pem" );
1495 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" );
1496 delete $confighash { $key };
1497 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1498 # &writeipsecfiles();
1501 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1502 delete $cahash { $cgiparams { 'KEY' }};
1503 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1504 # system('/usr/local/bin/ipsecctrl', 'R');
1506 $errormessage = $Lang :: tr
{ 'invalid key' };
1509 ### Remove ca certificate (step 1)
1511 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
1512 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1513 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1515 my $assignedcerts = 0 ;
1516 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1517 foreach my $key ( keys %confighash ) {
1518 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
1519 if ( $test =~ /: OK/ ) {
1523 if ( $assignedcerts ) {
1524 & Header
:: showhttpheaders
();
1525 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1526 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1527 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'are you sure' });
1529 <table><form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1530 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1531 <tr><td align='center'>
1532 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>: $assignedcerts
1533 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}
1534 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
1535 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td></tr>
1539 & Header
:: closebox
();
1540 & Header
:: closebigbox
();
1541 & Header
:: closepage
();
1544 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1545 delete $cahash { $cgiparams { 'KEY' }};
1546 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1547 # system('/usr/local/bin/ipsecctrl', 'R');
1550 $errormessage = $Lang :: tr
{ 'invalid key' };
1554 ### Display root certificate
1556 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
1557 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
1559 & Header
:: showhttpheaders
();
1560 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1561 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1562 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
1563 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'root certificate'}:" );
1564 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1566 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'host certificate'}:" );
1567 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1569 $output = & Header
:: cleanhtml
( $output , "y" );
1570 print "<pre> $output </pre> \n " ;
1571 & Header
:: closebox
();
1572 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1573 & Header
:: closebigbox
();
1574 & Header
:: closepage
();
1578 ### Download root certificate
1580 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
1581 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1582 print "Content-Type: application/octet-stream \r\n " ;
1583 print "Content-Disposition: filename=cacert.pem \r\n\r\n " ;
1584 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1589 ### Download host certificate
1591 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
1592 if ( - f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
1593 print "Content-Type: application/octet-stream \r\n " ;
1594 print "Content-Disposition: filename=servercert.pem \r\n\r\n " ;
1595 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1600 ### Download tls-auth key
1602 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download tls-auth key' }) {
1603 if ( - f
"${General::swroot}/ovpn/certs/ta.key" ) {
1604 print "Content-Type: application/octet-stream \r\n " ;
1605 print "Content-Disposition: filename=ta.key \r\n\r\n " ;
1606 print `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
1611 ### Form for generating a root certificate
1613 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
1614 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1616 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1617 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1618 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
1619 $cgiparams { 'ACTION' } = '' ;
1620 goto ROOTCERT_ERROR
;
1623 if (( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) && - e
"${General::swroot}/red/active" ) {
1624 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
1625 my $ipaddr = < IPADDR
>;
1628 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
1629 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
1630 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
1633 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1635 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1636 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1637 goto ROOTCERT_ERROR
;
1640 # Move uploaded certificate request to a temporary file
1641 ( my $fh , my $filename ) = tempfile
( );
1642 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1644 goto ROOTCERT_ERROR
;
1647 # Create a temporary dirctory
1648 my $tempdir = tempdir
( CLEANUP
=> 1 );
1650 # Extract the CA certificate from the file
1651 my $pid = open ( OPENSSL
, "|-" );
1652 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1653 if ( $pid ) { # parent
1654 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1655 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1659 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1661 goto ROOTCERT_ERROR
;
1664 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-cacerts' , '-nokeys' ,
1666 '-out' , " $tempdir /cacert.pem" )) {
1667 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1669 goto ROOTCERT_ERROR
;
1673 # Extract the Host certificate from the file
1674 $pid = open ( OPENSSL
, "|-" );
1675 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1676 if ( $pid ) { # parent
1677 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1678 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1682 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1684 goto ROOTCERT_ERROR
;
1687 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-clcerts' , '-nokeys' ,
1689 '-out' , " $tempdir /hostcert.pem" )) {
1690 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1692 goto ROOTCERT_ERROR
;
1696 # Extract the Host key from the file
1697 $pid = open ( OPENSSL
, "|-" );
1698 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1699 if ( $pid ) { # parent
1700 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1701 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1705 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1707 goto ROOTCERT_ERROR
;
1710 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-nocerts' ,
1713 '-out' , " $tempdir /serverkey.pem" )) {
1714 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1716 goto ROOTCERT_ERROR
;
1720 move
( " $tempdir /cacert.pem" , "${General::swroot}/ovpn/ca/cacert.pem" );
1722 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1724 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1725 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1726 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1727 goto ROOTCERT_ERROR
;
1730 move
( " $tempdir /hostcert.pem" , "${General::swroot}/ovpn/certs/servercert.pem" );
1732 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1734 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1735 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1736 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1737 goto ROOTCERT_ERROR
;
1740 move
( " $tempdir /serverkey.pem" , "${General::swroot}/ovpn/certs/serverkey.pem" );
1742 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1744 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1745 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1746 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1747 goto ROOTCERT_ERROR
;
1750 goto ROOTCERT_SUCCESS
;
1752 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
1754 # Validate input since the form was submitted
1755 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
1756 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
1757 goto ROOTCERT_ERROR
;
1759 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
1760 $errormessage = $Lang :: tr
{ 'organization too long' };
1761 goto ROOTCERT_ERROR
;
1763 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1764 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1765 goto ROOTCERT_ERROR
;
1767 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
1768 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
1769 goto ROOTCERT_ERROR
;
1771 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
1772 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1773 goto ROOTCERT_ERROR
;
1775 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
1776 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1777 goto ROOTCERT_ERROR
;
1779 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
1780 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1781 goto ROOTCERT_ERROR
;
1783 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1784 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1785 goto ROOTCERT_ERROR
;
1787 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1788 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1789 goto ROOTCERT_ERROR
;
1791 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1792 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1793 goto ROOTCERT_ERROR
;
1795 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1796 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1797 goto ROOTCERT_ERROR
;
1800 # Copy the cgisettings to vpnsettings and save the configfile
1801 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
1802 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
1803 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
1804 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
1805 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
1806 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
1807 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
1808 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1810 # Replace empty strings with a .
1811 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
1812 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
1813 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
1816 #system ('/bin/touch', "${General::swroot}/ovpn/gencanow");
1818 # Create the CA certificate
1819 my $pid = open ( OPENSSL
, "|-" );
1820 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1821 if ( $pid ) { # parent
1822 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1823 print OPENSSL
" $state \n " ;
1824 print OPENSSL
" $city \n " ;
1825 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1826 print OPENSSL
" $ou \n " ;
1827 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
1828 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1831 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1832 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1833 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1834 goto ROOTCERT_ERROR
;
1837 unless ( exec ( '/usr/bin/openssl' , 'req' , '-x509' , '-nodes' ,
1838 '-days' , '999999' , '-newkey' , 'rsa:4096' , '-sha512' ,
1839 '-keyout' , "${General::swroot}/ovpn/ca/cakey.pem" ,
1840 '-out' , "${General::swroot}/ovpn/ca/cacert.pem" ,
1841 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1842 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1843 goto ROOTCERT_ERROR
;
1847 # Create the Host certificate request
1848 $pid = open ( OPENSSL
, "|-" );
1849 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1850 if ( $pid ) { # parent
1851 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1852 print OPENSSL
" $state \n " ;
1853 print OPENSSL
" $city \n " ;
1854 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1855 print OPENSSL
" $ou \n " ;
1856 print OPENSSL
" $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1857 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1858 print OPENSSL
". \n " ;
1859 print OPENSSL
". \n " ;
1862 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1863 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1864 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1865 goto ROOTCERT_ERROR
;
1868 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' ,
1869 '-newkey' , 'rsa:2048' ,
1870 '-keyout' , "${General::swroot}/ovpn/certs/serverkey.pem" ,
1871 '-out' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1872 '-extensions' , 'server' ,
1873 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1874 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1875 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1876 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1877 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1878 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1879 goto ROOTCERT_ERROR
;
1883 # Sign the host certificate request
1884 system ( '/usr/bin/openssl' , 'ca' , '-days' , '999999' ,
1885 '-batch' , '-notext' ,
1886 '-in' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1887 '-out' , "${General::swroot}/ovpn/certs/servercert.pem" ,
1888 '-extensions' , 'server' ,
1889 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1891 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1892 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1893 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1894 unlink ( "${General::swroot}/ovpn/serverkey.pem" );
1895 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1896 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1897 & newcleanssldatabase
();
1898 goto ROOTCERT_ERROR
;
1900 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1901 & deletebackupcert
();
1904 # Create an empty CRL
1905 system ( '/usr/bin/openssl' , 'ca' , '-gencrl' ,
1906 '-out' , "${General::swroot}/ovpn/crls/cacrl.pem" ,
1907 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1909 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1910 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1911 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1912 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1913 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1914 & cleanssldatabase
();
1915 goto ROOTCERT_ERROR
;
1917 # &cleanssldatabase();
1919 # Create Diffie Hellmann Parameter
1920 system ( '/usr/bin/openssl' , 'dhparam' , '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" , " $cgiparams {'DHLENGHT'}" );
1922 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1923 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1924 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1925 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1926 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1927 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1928 & cleanssldatabase
();
1929 goto ROOTCERT_ERROR
;
1931 # &cleanssldatabase();
1933 # Create ta.key for tls-auth
1934 system ( '/usr/sbin/openvpn' , '--genkey' , '--secret' , "${General::swroot}/ovpn/certs/ta.key" );
1936 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1937 & cleanssldatabase
();
1938 goto ROOTCERT_ERROR
;
1940 goto ROOTCERT_SUCCESS
;
1943 if ( $cgiparams { 'ACTION' } ne '' ) {
1944 & Header
:: showhttpheaders
();
1945 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1946 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1947 if ( $errormessage ) {
1948 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
1949 print "<class name='base'> $errormessage " ;
1950 print " </class>" ;
1951 & Header
:: closebox
();
1953 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'generate root/host certificates'}:" );
1955 <form method='post' enctype='multipart/form-data'>
1956 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1957 <tr><td width='30%' class='base'> $Lang ::tr{'organization name'}:</td>
1958 <td width='35%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td>
1959 <td width='35%' colspan='2'> </td></tr>
1960 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}:</td>
1961 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td>
1962 <td colspan='2'> </td></tr>
1963 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt'*' /></td>
1964 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td>
1965 <td colspan='2'> </td></tr>
1966 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt'*' /></td>
1967 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td>
1968 <td colspan='2'> </td></tr>
1969 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt'*' /></td>
1970 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td>
1971 <td colspan='2'> </td></tr>
1972 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt'*' /></td>
1973 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td>
1974 <td colspan='2'> </td></tr>
1975 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1976 <td class='base'><select name='ROOTCERT_COUNTRY'>
1980 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1981 print "<option value=' $Countries ::countries{ $country }'" ;
1982 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1983 print " selected='selected'" ;
1985 print "> $country </option>" ;
1989 <tr><td class='base'> $Lang ::tr{'ovpn dh'}:</td>
1990 <td class='base'><select name='DHLENGHT'>
1991 <option value='1024' $selected {'DHLENGHT'}{'1024'}>1024 $Lang ::tr{'bit'}</option>
1992 <option value='2048' $selected {'DHLENGHT'}{'2048'}>2048 $Lang ::tr{'bit'}</option>
1993 <option value='3072' $selected {'DHLENGHT'}{'3072'}>3072 $Lang ::tr{'bit'}</option>
1994 <option value='4096' $selected {'DHLENGHT'}{'4096'}>4096 $Lang ::tr{'bit'}</option>
2000 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /></td>
2001 <td> </td><td> </td></tr>
2002 <tr><td class='base' colspan='4' align='left'>
2003 <img src='/blob.gif' valign='top' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
2004 <tr><td colspan='2'><br></td></tr>
2005 <table width='100%'>
2007 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}: </font></b> $Lang ::tr{'ovpn generating the root and host certificates'}
2008 <td class='base'> $Lang ::tr{'dh key warn'}</td>
2011 <td class='base'> $Lang ::tr{'dh key warn1'}</td>
2013 <tr><td colspan='2'><br></td></tr>
2017 <table width='100%'>
2018 <tr><td colspan='4'><hr></td></tr>
2019 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
2020 <td nowrap='nowrap'><input type='file' name='FH' size='32'></td>
2021 <td colspan='2'> </td></tr>
2022 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' ></td>
2023 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td>
2024 <td colspan='2'> </td></tr>
2026 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td>
2027 <td colspan='2'> </td></tr>
2028 <tr><td class='base' colspan='4' align='left'>
2029 <img src='/blob.gif' valign='top' al='*' > $Lang ::tr{'this field may be blank'}</td>
2034 & Header
:: closebox
();
2035 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2036 & Header
:: closebigbox
();
2037 & Header
:: closepage
();
2042 system ( "chmod 600 ${General::swroot}/ovpn/certs/serverkey.pem" );
2043 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2044 # $vpnsettings{'ENABLE_BLUE'} eq 'on') {
2045 # system('/usr/local/bin/ipsecctrl', 'S');
2049 ### Enable/Disable connection
2056 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
2058 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2059 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2060 # my $n2nactive = '';
2061 my $n2nactive = `/bin/ps ax|grep $confighash { $cgiparams {'KEY'}}[1]|grep -v grep|awk \' {print \ $1 } \' ` ;
2063 if ( $confighash { $cgiparams { 'KEY' }}) {
2064 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
2065 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
2066 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2068 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2069 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
2070 & writecollectdconf
();
2074 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
2075 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2077 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2078 if ( $n2nactive ne '' ) {
2079 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
2080 & writecollectdconf
();
2084 $errormessage = $Lang :: tr
{ 'invalid key' };
2090 ### Download OpenVPN client package
2094 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'dl client arch' }) {
2095 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2096 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2098 my $clientovpn = '' ;
2100 my $tempdir = tempdir
( CLEANUP
=> 1 );
2101 my $zippath = " $tempdir /" ;
2107 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2109 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-Client.zip" ;
2110 my $zippathname = " $zippath $zipname " ;
2111 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1].conf" ;
2112 my @ovsubnettemp = split ( /\./ , $confighash { $cgiparams { 'KEY' }}[ 27 ]);
2113 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
2115 my @remsubnet = split ( /\/ /, $confighash { $cgiparams { 'KEY' }}[ 8 ]);
2116 my $n2nfragment = '' ;
2118 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2119 flock CLIENTCONF
, 2 ;
2121 my $zip = Archive
:: Zip
-> new ();
2122 print CLIENTCONF
"# IPFire n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
2123 print CLIENTCONF
"# \n " ;
2124 print CLIENTCONF
"# User Security \n " ;
2125 print CLIENTCONF
"user nobody \n " ;
2126 print CLIENTCONF
"group nobody \n " ;
2127 print CLIENTCONF
"persist-tun \n " ;
2128 print CLIENTCONF
"persist-key \n " ;
2129 print CLIENTCONF
"script-security 2 \n " ;
2130 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
2131 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} \n " ;
2132 print CLIENTCONF
"float \n " ;
2133 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
2134 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
2135 print CLIENTCONF
"# Server Gateway Network \n " ;
2136 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
2137 print CLIENTCONF
"# tun Device \n " ;
2138 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \n " ;
2139 print CLIENTCONF
"# Port and Protokoll \n " ;
2140 print CLIENTCONF
"port $confighash { $cgiparams {'KEY'}}[29] \n " ;
2142 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'tcp' ) {
2143 print CLIENTCONF
"proto tcp-client \n " ;
2144 print CLIENTCONF
"# Packet size \n " ;
2145 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1400' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2146 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2149 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'udp' ) {
2150 print CLIENTCONF
"proto udp \n " ;
2151 print CLIENTCONF
"# Paketsize \n " ;
2152 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1500' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2153 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2154 if ( $confighash { $cgiparams { 'KEY' }}[ 24 ] ne '' ) { print CLIENTCONF
"fragment $confighash { $cgiparams {'KEY'}}[24] \n " ;}
2155 if ( $confighash { $cgiparams { 'KEY' }}[ 23 ] eq 'on' ) { print CLIENTCONF
"mssfix \n " ;}
2157 if (( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'yes' ) ||
2158 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'maybe' ) ||
2159 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'no' )) {
2160 if (( $confighash { $cgiparams { 'KEY' }}[ 23 ] ne 'on' ) || ( $confighash { $cgiparams { 'KEY' }}[ 24 ] eq '' )) {
2161 if ( $tunmtu eq '1500' ) {
2162 print CLIENTCONF
"mtu-disc $confighash { $cgiparams {'KEY'}}[38] \n " ;
2166 print CLIENTCONF
"ns-cert-type server \n " ;
2167 print CLIENTCONF
"# Auth. Client \n " ;
2168 print CLIENTCONF
"tls-client \n " ;
2169 print CLIENTCONF
"# Cipher \n " ;
2170 print CLIENTCONF
"cipher $confighash { $cgiparams {'KEY'}}[40] \n " ;
2171 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2172 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2173 $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 " ;
2175 if ( $confighash { $cgiparams { 'KEY' }}[ 39 ] eq '' ) {
2176 print CLIENTCONF
"# HMAC algorithm \n " ;
2177 print CLIENTCONF
"auth SHA1 \n " ;
2179 print CLIENTCONF
"# HMAC algorithm \n " ;
2180 print CLIENTCONF
"auth $confighash { $cgiparams {'KEY'}}[39] \n " ;
2182 if ( $confighash { $cgiparams { 'KEY' }}[ 30 ] eq 'on' ) {
2183 print CLIENTCONF
"# Enable Compression \n " ;
2184 print CLIENTCONF
"comp-lzo \n " ;
2186 print CLIENTCONF
"# Debug Level \n " ;
2187 print CLIENTCONF
"verb 3 \n " ;
2188 print CLIENTCONF
"# Tunnel check \n " ;
2189 print CLIENTCONF
"keepalive 10 60 \n " ;
2190 print CLIENTCONF
"# Start as daemon \n " ;
2191 print CLIENTCONF
"daemon $confighash { $cgiparams {'KEY'}}[1]n2n \n " ;
2192 print CLIENTCONF
"writepid /var/run/ $confighash { $cgiparams {'KEY'}}[1]n2n.pid \n " ;
2193 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
2194 if ( $confighash { $cgiparams { 'KEY' }}[ 22 ] eq '' ) { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[29] \n " }
2195 else { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[22] \n " };
2196 print CLIENTCONF
"# remsub $confighash { $cgiparams {'KEY'}}[11] \n " ;
2201 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2202 my $status = $zip -> writeToFileNamed ( $zippathname );
2204 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2205 @fileholder = < DLFILE
>;
2206 print "Content-Type:application/x-download \n " ;
2207 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2213 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.zip" ;
2214 my $zippathname = " $zippath $zipname " ;
2215 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.ovpn" ;
2221 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2222 flock CLIENTCONF
, 2 ;
2224 my $zip = Archive
:: Zip
-> new ();
2226 print CLIENTCONF
"#OpenVPN Client conf \r\n " ;
2227 print CLIENTCONF
"tls-client \r\n " ;
2228 print CLIENTCONF
"client \r\n " ;
2229 print CLIENTCONF
"nobind \r\n " ;
2230 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \r\n " ;
2231 print CLIENTCONF
"proto $vpnsettings {'DPROTOCOL'} \r\n " ;
2233 # Check if we are using fragment, mssfix or mtu-disc and set MTU to 1500
2234 # or use configured value.
2235 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' )
2236 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2237 elsif ( $vpnsettings { MSSFIX
} eq 'on' )
2238 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2239 elsif (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2240 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2241 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' ))
2242 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2244 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu $vpnsettings {'DMTU'} \r\n " ; }
2246 if ( $vpnsettings { 'ENABLED' } eq 'on' ){
2247 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2248 if ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2249 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Blue interface \r\n " ;
2250 print CLIENTCONF
";remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2252 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2253 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2254 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2256 } elsif ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2257 print CLIENTCONF
"remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2258 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2259 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2260 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2262 } elsif ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2263 print CLIENTCONF
"remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2266 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2267 print CLIENTCONF
"pkcs12 $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2268 $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 " ;
2270 print CLIENTCONF
"ca cacert.pem \r\n " ;
2271 print CLIENTCONF
"cert $confighash { $cgiparams {'KEY'}}[1]cert.pem \r\n " ;
2272 print CLIENTCONF
"key $confighash { $cgiparams {'KEY'}}[1].key \r\n " ;
2273 $zip -> addFile ( "${General::swroot}/ovpn/ca/cacert.pem" , "cacert.pem" ) or die "Can't add file cacert.pem \n " ;
2274 $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 " ;
2276 print CLIENTCONF
"cipher $vpnsettings {DCIPHER} \r\n " ;
2277 if ( $vpnsettings { 'DAUTH' } eq '' ) {
2278 print CLIENTCONF
"" ;
2280 print CLIENTCONF
"auth $vpnsettings {'DAUTH'} \r\n " ;
2282 if ( $vpnsettings { 'TLSAUTH' } eq 'on' ) {
2283 print CLIENTCONF
"tls-auth ta.key \r\n " ;
2284 $zip -> addFile ( "${General::swroot}/ovpn/certs/ta.key" , "ta.key" ) or die "Can't add file ta.key \n " ;
2286 if ( $vpnsettings { DCOMPLZO
} eq 'on' ) {
2287 print CLIENTCONF
"comp-lzo \r\n " ;
2289 print CLIENTCONF
"verb 3 \r\n " ;
2290 print CLIENTCONF
"ns-cert-type server \r\n " ;
2291 print CLIENTCONF
"tls-remote $vpnsettings {ROOTCERT_HOSTNAME} \r\n " ;
2292 if ( $vpnsettings { MSSFIX
} eq 'on' ) {
2293 print CLIENTCONF
"mssfix \r\n " ;
2295 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' ) {
2296 print CLIENTCONF
"fragment $vpnsettings {'FRAGMENT'} \r\n " ;
2299 # Check if a valid operating mode has been choosen and use it.
2300 if (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2301 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2302 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' )) {
2303 if (( $vpnsettings { MSSFIX
} ne 'on' ) || ( $vpnsettings { FRAGMENT
} eq '' )) {
2304 print CLIENTCONF
"mtu-disc $vpnsettings {'PMTU_DISCOVERY'} \r\n " ;
2307 # Print client.conf.local if entries exist to client.ovpn
2308 if (!- z
$local_clientconf && $vpnsettings { 'ADDITIONAL_CONFIGS' } eq 'on' ) {
2309 open ( LCC
, " $local_clientconf " );
2310 print CLIENTCONF
" \n #--------------------------- \n " ;
2311 print CLIENTCONF
"# Start of custom directives \n " ;
2312 print CLIENTCONF
"# from client.conf.local \n " ;
2313 print CLIENTCONF
"#--------------------------- \n\n " ;
2315 print CLIENTCONF
$_ ;
2317 print CLIENTCONF
" \n #--------------------------- \n " ;
2318 print CLIENTCONF
"# End of custom directives \n " ;
2319 print CLIENTCONF
"#--------------------------- \n\n " ;
2324 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2325 my $status = $zip -> writeToFileNamed ( $zippathname );
2327 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2328 @fileholder = < DLFILE
>;
2329 print "Content-Type:application/x-download \n " ;
2330 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2338 ### Remove connection
2342 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
2343 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2344 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2346 if ( $confighash { $cgiparams { 'KEY' }}) {
2347 my $temp = `/usr/bin/openssl ca -revoke ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2353 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
2354 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
2355 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2359 if (- e
"${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) {
2360 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
2364 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
2365 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2367 # A.Marx CCD delete ccd files and routes
2369 if (- f
"${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" )
2371 unlink "${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" ;
2374 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2375 foreach my $key ( keys %ccdroutehash ) {
2376 if ( $ccdroutehash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2377 delete $ccdroutehash { $key };
2380 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2382 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2383 foreach my $key ( keys %ccdroute2hash ) {
2384 if ( $ccdroute2hash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2385 delete $ccdroute2hash { $key };
2388 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2392 # Update collectd configuration and delete all RRD files of the removed connection
2393 & writecollectdconf
();
2394 system ( "/usr/local/bin/openvpnctrl -drrd $confighash { $cgiparams {'KEY'}}[1]" );
2396 delete $confighash { $cgiparams { 'KEY' }};
2397 my $temp2 = `/usr/bin/openssl ca -gencrl -out ${General::swroot}/ovpn/crls/cacrl.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2398 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2401 $errormessage = $Lang :: tr
{ 'invalid key' };
2403 & General
:: firewall_reload
();
2406 ### Download PKCS12 file
2408 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
2409 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2411 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
2412 print "Content-Type: application/octet-stream \r\n\r\n " ;
2413 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
2417 ### Display certificate
2419 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
2420 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2422 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2423 & Header
:: showhttpheaders
();
2424 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2425 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2426 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate'}:" );
2427 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2428 $output = & Header
:: cleanhtml
( $output , "y" );
2429 print "<pre> $output </pre> \n " ;
2430 & Header
:: closebox
();
2431 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2432 & Header
:: closebigbox
();
2433 & Header
:: closepage
();
2438 ### Display Diffie-Hellman key
2440 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show dh' }) {
2442 if (! - e
"${General::swroot}/ovpn/ca/dh1024.pem" ) {
2443 $errormessage = $Lang :: tr
{ 'not present' };
2445 & Header
:: showhttpheaders
();
2446 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2447 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2448 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'dh'}:" );
2449 my $output = `/usr/bin/openssl dhparam -text -in ${General::swroot}/ovpn/ca/dh1024.pem` ;
2450 $output = & Header
:: cleanhtml
( $output , "y" );
2451 print "<pre> $output </pre> \n " ;
2452 & Header
:: closebox
();
2453 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2454 & Header
:: closebigbox
();
2455 & Header
:: closepage
();
2460 ### Display tls-auth key
2462 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show tls-auth key' }) {
2464 if (! - e
"${General::swroot}/ovpn/certs/ta.key" ) {
2465 $errormessage = $Lang :: tr
{ 'not present' };
2467 & Header
:: showhttpheaders
();
2468 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2469 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2470 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ta key'}:" );
2471 my $output = `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
2472 $output = & Header
:: cleanhtml
( $output , "y" );
2473 print "<pre> $output </pre> \n " ;
2474 & Header
:: closebox
();
2475 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2476 & Header
:: closebigbox
();
2477 & Header
:: closepage
();
2482 ### Display Certificate Revoke List
2484 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show crl' }) {
2485 # &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash);
2487 if (! - e
"${General::swroot}/ovpn/crls/cacrl.pem" ) {
2488 $errormessage = $Lang :: tr
{ 'not present' };
2490 & Header
:: showhttpheaders
();
2491 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2492 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2493 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'crl'}:" );
2494 my $output = `/usr/bin/openssl crl -text -noout -in ${General::swroot}/ovpn/crls/cacrl.pem` ;
2495 $output = & Header
:: cleanhtml
( $output , "y" );
2496 print "<pre> $output </pre> \n " ;
2497 & Header
:: closebox
();
2498 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2499 & Header
:: closebigbox
();
2500 & Header
:: closepage
();
2505 ### Advanced Server Settings
2508 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced server' }) {
2513 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
2517 # if ($cgiparams{'CLIENT2CLIENT'} eq '') {
2518 # $cgiparams{'CLIENT2CLIENT'} = 'on';
2521 if ( $cgiparams { 'MAX_CLIENTS' } eq '' ) {
2522 $cgiparams { 'MAX_CLIENTS' } = '100' ;
2524 if ( $cgiparams { 'KEEPALIVE_1' } eq '' ) {
2525 $cgiparams { 'KEEPALIVE_1' } = '10' ;
2527 if ( $cgiparams { 'KEEPALIVE_2' } eq '' ) {
2528 $cgiparams { 'KEEPALIVE_2' } = '60' ;
2530 if ( $cgiparams { 'LOG_VERB' } eq '' ) {
2531 $cgiparams { 'LOG_VERB' } = '3' ;
2533 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
2534 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
2536 if ( $cgiparams { 'DAUTH' } eq '' ) {
2537 $cgiparams { 'DAUTH' } = 'SHA1' ;
2539 if ( $cgiparams { 'TLSAUTH' } eq '' ) {
2540 $cgiparams { 'TLSAUTH' } = 'off' ;
2542 $checked { 'CLIENT2CLIENT' }{ 'off' } = '' ;
2543 $checked { 'CLIENT2CLIENT' }{ 'on' } = '' ;
2544 $checked { 'CLIENT2CLIENT' }{ $cgiparams { 'CLIENT2CLIENT' }} = 'CHECKED' ;
2545 $checked { 'REDIRECT_GW_DEF1' }{ 'off' } = '' ;
2546 $checked { 'REDIRECT_GW_DEF1' }{ 'on' } = '' ;
2547 $checked { 'REDIRECT_GW_DEF1' }{ $cgiparams { 'REDIRECT_GW_DEF1' }} = 'CHECKED' ;
2548 $checked { 'ADDITIONAL_CONFIGS' }{ 'off' } = '' ;
2549 $checked { 'ADDITIONAL_CONFIGS' }{ 'on' } = '' ;
2550 $checked { 'ADDITIONAL_CONFIGS' }{ $cgiparams { 'ADDITIONAL_CONFIGS' }} = 'CHECKED' ;
2551 $checked { 'MSSFIX' }{ 'off' } = '' ;
2552 $checked { 'MSSFIX' }{ 'on' } = '' ;
2553 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
2554 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
2555 $selected { 'LOG_VERB' }{ '0' } = '' ;
2556 $selected { 'LOG_VERB' }{ '1' } = '' ;
2557 $selected { 'LOG_VERB' }{ '2' } = '' ;
2558 $selected { 'LOG_VERB' }{ '3' } = '' ;
2559 $selected { 'LOG_VERB' }{ '4' } = '' ;
2560 $selected { 'LOG_VERB' }{ '5' } = '' ;
2561 $selected { 'LOG_VERB' }{ '6' } = '' ;
2562 $selected { 'LOG_VERB' }{ '7' } = '' ;
2563 $selected { 'LOG_VERB' }{ '8' } = '' ;
2564 $selected { 'LOG_VERB' }{ '9' } = '' ;
2565 $selected { 'LOG_VERB' }{ '10' } = '' ;
2566 $selected { 'LOG_VERB' }{ '11' } = '' ;
2567 $selected { 'LOG_VERB' }{ $cgiparams { 'LOG_VERB' }} = 'SELECTED' ;
2568 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
2569 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
2570 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
2571 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
2572 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
2573 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
2574 $checked { 'TLSAUTH' }{ 'off' } = '' ;
2575 $checked { 'TLSAUTH' }{ 'on' } = '' ;
2576 $checked { 'TLSAUTH' }{ $cgiparams { 'TLSAUTH' }} = 'CHECKED' ;
2578 & Header
:: showhttpheaders
();
2579 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
2580 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
2581 if ( $errormessage ) {
2582 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2583 print "<class name='base'> $errormessage \n " ;
2584 print " </class> \n " ;
2585 & Header
:: closebox
();
2587 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'advanced server' });
2589 <form method='post' enctype='multipart/form-data'>
2590 <table width='100%' border=0>
2592 <td colspan='4'><b> $Lang ::tr{'dhcp-options'}</b></td>
2595 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2598 <td class='base'>Domain</td>
2599 <td><input type='TEXT' name='DHCP_DOMAIN' value=' $cgiparams {'DHCP_DOMAIN'}' size='30' /></td>
2602 <td class='base'>DNS</td>
2603 <td><input type='TEXT' name='DHCP_DNS' value=' $cgiparams {'DHCP_DNS'}' size='30' /></td>
2606 <td class='base'>WINS</td>
2607 <td><input type='TEXT' name='DHCP_WINS' value=' $cgiparams {'DHCP_WINS'}' size='30' /></td>
2610 <td colspan='4'><b> $Lang ::tr{'ovpn routes push options'}</b></td>
2613 <td class='base'> $Lang ::tr{'ovpn routes push'}</td>
2615 <textarea name='ROUTES_PUSH' cols='26' rows='6' wrap='off'>
2619 if ( $cgiparams { 'ROUTES_PUSH' } ne '' )
2621 print $cgiparams { 'ROUTES_PUSH' };
2630 <table width='100%'>
2632 <td class'base'><b> $Lang ::tr{'misc-options'}</b></td>
2636 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2640 <td class='base'>Client-To-Client</td>
2641 <td><input type='checkbox' name='CLIENT2CLIENT' $checked {'CLIENT2CLIENT'}{'on'} /></td>
2645 <td class='base'>Redirect-Gateway def1</td>
2646 <td><input type='checkbox' name='REDIRECT_GW_DEF1' $checked {'REDIRECT_GW_DEF1'}{'on'} /></td>
2650 <td class='base'> $Lang ::tr{'ovpn add conf'}</td>
2651 <td><input type='checkbox' name='ADDITIONAL_CONFIGS' $checked {'ADDITIONAL_CONFIGS'}{'on'} /></td>
2652 <td> $Lang ::tr{'openvpn default'}: off</td>
2656 <td class='base'>mssfix</td>
2657 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
2658 <td> $Lang ::tr{'openvpn default'}: off</td>
2662 <td class='base'>fragment <br></td>
2663 <td><input type='TEXT' name='FRAGMENT' value=' $cgiparams {'FRAGMENT'}' size='10' /></td>
2668 <td class='base'>Max-Clients</td>
2669 <td><input type='text' name='MAX_CLIENTS' value=' $cgiparams {'MAX_CLIENTS'}' size='10' /></td>
2672 <td class='base'>Keepalive <br />
2673 (ping/ping-restart)</td>
2674 <td><input type='TEXT' name='KEEPALIVE_1' value=' $cgiparams {'KEEPALIVE_1'}' size='10' /></td>
2675 <td><input type='TEXT' name='KEEPALIVE_2' value=' $cgiparams {'KEEPALIVE_2'}' size='10' /></td>
2679 <td class='base'> $Lang ::tr{'ovpn mtu-disc'}</td>
2680 <td><input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}</td>
2681 <td><input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}</td>
2682 <td><input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}</td>
2683 <td><input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}</td>
2688 <table width='100%'>
2690 <td class'base'><b> $Lang ::tr{'log-options'}</b></td>
2693 <td width='20%'></td> <td width='30%'> </td><td width='25%'> </td><td width='25%'></td>
2696 <tr><td class='base'>VERB</td>
2697 <td><select name='LOG_VERB'>
2698 <option value='0' $selected {'LOG_VERB'}{'0'}>0</option>
2699 <option value='1' $selected {'LOG_VERB'}{'1'}>1</option>
2700 <option value='2' $selected {'LOG_VERB'}{'2'}>2</option>
2701 <option value='3' $selected {'LOG_VERB'}{'3'}>3</option>
2702 <option value='4' $selected {'LOG_VERB'}{'4'}>4</option>
2703 <option value='5' $selected {'LOG_VERB'}{'5'}>5</option>
2704 <option value='6' $selected {'LOG_VERB'}{'6'}>6</option>
2705 <option value='7' $selected {'LOG_VERB'}{'7'}>7</option>
2706 <option value='8' $selected {'LOG_VERB'}{'8'}>8</option>
2707 <option value='9' $selected {'LOG_VERB'}{'9'}>9</option>
2708 <option value='10' $selected {'LOG_VERB'}{'10'}>10</option>
2709 <option value='11' $selected {'LOG_VERB'}{'11'}>11</option>
2714 <table width='100%'>
2716 <td class'base'><b> $Lang ::tr{'ovpn crypt options'}</b></td>
2719 <td width='20%'></td> <td width='30%'> </td><td width='25%'> </td><td width='25%'></td>
2721 <tr><td class='base'> $Lang ::tr{'ovpn ha'}</td>
2722 <td><select name='DAUTH'>
2723 <option value='whirlpool' $selected {'DAUTH'}{'whirlpool'}>Whirlpool (512 $Lang ::tr{'bit'})</option>
2724 <option value='SHA512' $selected {'DAUTH'}{'SHA512'}>SHA2 (512 $Lang ::tr{'bit'})</option>
2725 <option value='SHA384' $selected {'DAUTH'}{'SHA384'}>SHA2 (384 $Lang ::tr{'bit'})</option>
2726 <option value='SHA256' $selected {'DAUTH'}{'SHA256'}>SHA2 (256 $Lang ::tr{'bit'})</option>
2727 <option value='SHA1' $selected {'DAUTH'}{'SHA1'}>SHA1 (160 $Lang ::tr{'bit'})</option>
2730 <td> $Lang ::tr{'openvpn default'}: <span class="base">SHA1 (160 $Lang ::tr{'bit'})</span></td>
2734 <table width='100%'>
2736 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2740 <td class='base'>HMAC tls-auth</td>
2741 <td><input type='checkbox' name='TLSAUTH' $checked {'TLSAUTH'}{'on'} /></td>
2746 if ( - e
"/var/run/openvpn.pid" ){
2747 print " <br><b><font color='#990000'> $Lang ::tr{'attention'}:</b></font><br>
2748 $Lang ::tr{'server restart'}<br><br>
2751 <table width='100%'>
2754 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' disabled='disabled' /></td>
2755 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2767 <table width='100%'>
2770 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' /></td>
2771 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2779 & Header
:: closebox
();
2780 # print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'>$Lang::tr{'back'}</a></div>";
2781 & Header
:: closebigbox
();
2782 & Header
:: closepage
();
2786 # A.Marx CCD Add,delete or edit CCD net
2788 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd net' } ||
2789 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' } ||
2790 $cgiparams { 'ACTION' } eq "kill" ||
2791 $cgiparams { 'ACTION' } eq "edit" ||
2792 $cgiparams { 'ACTION' } eq 'editsave' ){
2793 & Header
:: showhttpheaders
();
2794 & Header
:: openpage
( $Lang :: tr
{ 'ccd net' }, 1 , '' );
2795 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2797 if ( $cgiparams { 'ACTION' } eq "kill" ){
2798 & delccdnet
( $cgiparams { 'net' });
2801 if ( $cgiparams { 'ACTION' } eq 'editsave' ){
2802 my ( $a , $b ) = split ( /\|/ , $cgiparams { 'ccdname' });
2803 if ( $a ne $b ){ & modccdnet
( $a , $b );}
2804 $cgiparams { 'ccdname' }= '' ;
2805 $cgiparams { 'ccdsubnet' }= '' ;
2808 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' }) {
2809 & addccdnet
( $cgiparams { 'ccdname' }, $cgiparams { 'ccdsubnet' });
2811 if ( $errormessage ) {
2812 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2813 print "<class name='base'> $errormessage " ;
2814 print " </class>" ;
2815 & Header
:: closebox
();
2817 if ( $cgiparams { 'ACTION' } eq "edit" ){
2819 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd modify' });
2822 <table width='100%' border='0'>
2823 <tr><form method='post'>
2824 <td width='10%' nowrap='nowrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2825 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' readonly='readonly' /></td></tr>
2826 <tr><td colspan='4' align='right'><hr><input type='submit' value=' $Lang ::tr{'save'}' /><input type='hidden' name='ACTION' value='editsave'/>
2827 <input type='hidden' name='ccdname' value=' $cgiparams {'ccdname'}'/><input type='submit' value=' $Lang ::tr{'cancel'}' />
2832 & Header
:: closebox
();
2834 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2836 <table width='100%' border='0' cellpadding='0' cellspacing='1'>
2838 <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>
2843 if (! - e
"/var/run/openvpn.pid" ){
2844 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd add' });
2846 <table width='100%' border='0'>
2847 <tr><form method='post'>
2848 <td colspan='4'> $Lang ::tr{'ccd hint'}<br><br></td></tr>
2850 <td width='10%' nowrap='nwrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2851 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' /></td></tr>
2852 <tr><td colspan=4><hr /></td></tr><tr>
2853 <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>
2857 & Header
:: closebox
();
2859 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2860 if ( - e
"/var/run/openvpn.pid" ){
2861 print "<b> $Lang ::tr{'attention'}:</b><br>" ;
2862 print " $Lang ::tr{'ccd noaddnet'}<br><hr>" ;
2866 <table width='100%' cellpadding='0' cellspacing='1'>
2868 <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>
2873 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
2876 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
2877 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
2879 my $ccdhosts = & hostsinnet
( $ccdconf [ 0 ]);
2880 if ( $count % 2 ){ print " <tr bgcolor=' $color {'color22'}'>" ;}
2881 else { print " <tr bgcolor=' $color {'color20'}'>" ;}
2882 print "<td> $ccdconf [0]</td><td align='center'> $ccdconf [1]</td><td align='center'> $ccdhosts /" .(& ccdmaxclients
( $ccdconf [ 1 ])+ 1 ). "</td><td>" ;
2884 <form method='post' />
2885 <input type='image' src='/images/edit.gif' align='middle' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
2886 <input type='hidden' name='ACTION' value='edit'/>
2887 <input type='hidden' name='ccdname' value=' $ccdconf [0]' />
2888 <input type='hidden' name='ccdsubnet' value=' $ccdconf [1]' />
2890 <form method='post' />
2891 <td><input type='hidden' name='ACTION' value='kill'/>
2892 <input type='hidden' name='number' value=' $count ' />
2893 <input type='hidden' name='net' value=' $ccdconf [0]' />
2894 <input type='image' src='/images/delete.gif' align='middle' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' /></form></td></tr>
2898 print "</table></form>" ;
2899 & Header
:: closebox
();
2900 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2901 & Header
:: closebigbox
();
2902 & Header
:: closepage
();
2908 ### Openvpn Connections Statistics
2910 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ovpn con stat' }) {
2911 & Header
:: showhttpheaders
();
2912 & Header
:: openpage
( $Lang :: tr
{ 'ovpn con stat' }, 1 , '' );
2913 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2914 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ovpn con stat' });
2917 # <td><b>$Lang::tr{'protocol'}</b></td>
2918 # protocol temp removed
2920 <table width='100%' cellpadding='2' cellspacing='0' class='tbl'>
2922 <th><b> $Lang ::tr{'common name'}</b></th>
2923 <th><b> $Lang ::tr{'real address'}</b></th>
2924 <th><b> $Lang ::tr{'virtual address'}</b></th>
2925 <th><b> $Lang ::tr{'loged in at'}</b></th>
2926 <th><b> $Lang ::tr{'bytes sent'}</b></th>
2927 <th><b> $Lang ::tr{'bytes received'}</b></th>
2928 <th><b> $Lang ::tr{'last activity'}</b></th>
2932 my $filename = "/var/run/ovpnserver.log" ;
2933 open ( FILE
, $filename ) or die 'Unable to open config file.' ;
2934 my @current = < FILE
>;
2943 my %userlookup = ();
2944 foreach my $line ( @current )
2947 if ( $line =~ /^Updated,(.+)/ ){
2948 @match = split ( /^Updated,(.+)/ , $line );
2949 $status = $match [ 1 ];
2952 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
2953 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
2954 if ( $match [ 1 ] ne "Common Name" ) {
2956 $userlookup { $match [ 2 ]} = $uid ;
2957 $users [ $uid ]{ 'CommonName' } = $match [ 1 ];
2958 $users [ $uid ]{ 'RealAddress' } = $match [ 2 ];
2959 $users [ $uid ]{ 'BytesReceived' } = & sizeformat
( $match [ 3 ]);
2960 $users [ $uid ]{ 'BytesSent' } = & sizeformat
( $match [ 4 ]);
2961 $users [ $uid ]{ 'Since' } = $match [ 5 ];
2962 $users [ $uid ]{ 'Proto' } = $proto ;
2966 if ( $line =~ /^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ ) {
2967 @match = split ( m/^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ , $line );
2968 if ( $match [ 1 ] ne "Virtual Address" ) {
2969 $address = $match [ 3 ];
2970 #find the uid in the lookup table
2971 $uid = $userlookup { $address };
2972 $users [ $uid ]{ 'VirtualAddress' } = $match [ 1 ];
2973 $users [ $uid ]{ 'LastRef' } = $match [ 4 ];
2979 for ( my $idx = 1 ; $idx <= $user2 ; $idx ++){
2982 $col = "bgcolor=' $color {'color22'}'" ;
2985 $col = "bgcolor=' $color {'color20'}'" ;
2987 print "<td align='left' $col > $users [ $idx -1]{'CommonName'}</td>" ;
2988 print "<td align='left' $col > $users [ $idx -1]{'RealAddress'}</td>" ;
2989 print "<td align='left' $col > $users [ $idx -1]{'VirtualAddress'}</td>" ;
2990 print "<td align='left' $col > $users [ $idx -1]{'Since'}</td>" ;
2991 print "<td align='left' $col > $users [ $idx -1]{'BytesSent'}</td>" ;
2992 print "<td align='left' $col > $users [ $idx -1]{'BytesReceived'}</td>" ;
2993 print "<td align='left' $col > $users [ $idx -1]{'LastRef'}</td>" ;
2999 <table width='100%' border='0' cellpadding='2' cellspacing='0'>
3004 <tr><td align='center' > $Lang ::tr{'the statistics were last updated at'} <b> $status </b></td></tr>
3008 & Header
:: closebox
();
3009 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3010 & Header
:: closebigbox
();
3011 & Header
:: closepage
();
3015 ### Download Certificate
3017 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
3018 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3020 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
3021 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \r\n " ;
3022 print "Content-Type: application/octet-stream \r\n\r\n " ;
3023 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
3028 ### Enable/Disable connection
3031 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
3033 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3034 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3036 if ( $confighash { $cgiparams { 'KEY' }}) {
3037 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
3038 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
3039 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3040 #&writeserverconf();
3041 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3042 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3043 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
3046 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
3047 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3048 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3049 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
3051 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3052 #&writeserverconf();
3055 $errormessage = $Lang :: tr
{ 'invalid key' };
3059 ### Restart connection
3061 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
3062 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3063 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3065 if ( $confighash { $cgiparams { 'KEY' }}) {
3066 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3067 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3068 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
3071 $errormessage = $Lang :: tr
{ 'invalid key' };
3078 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
3079 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3080 & Header
:: showhttpheaders
();
3081 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
3082 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
3083 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection type' });
3085 if ( - s
"${General::swroot}/ovpn/settings" ) {
3088 <b> $Lang ::tr{'connection type'}:</b><br />
3089 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
3090 <tr><td><input type='radio' name='TYPE' value='host' checked /></td>
3091 <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
3092 <tr><td><input type='radio' name='TYPE' value='net' /></td>
3093 <td class='base'> $Lang ::tr{'net to net vpn'}</td></tr>
3094 <tr><td><input type='radio' name='TYPE' value='net2net' /></td>
3095 <td class='base'> $Lang ::tr{'net to net vpn'} (Upload Client Package)</td></tr>
3096 <tr><td> </td><td class='base'><input type='file' name='FH' size='30'></td></tr>
3097 <tr><td> </td><td>Import Connection Name <img src='/blob.gif' /></td></tr>
3098 <tr><td> </td><td class='base'><input type='text' name='n2nname' size='30'> $Lang ::tr{'openvpn default'}: Client Packagename</td></tr>
3099 <tr><td colspan='3'><hr /></td></tr>
3100 <tr><td align='right' colspan='3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
3101 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
3109 <b> $Lang ::tr{'connection type'}:</b><br />
3110 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
3111 <tr><td><input type='radio' name='TYPE' value='host' checked /></td> <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
3112 <tr><td align='right' colspan'3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
3119 & Header
:: closebox
();
3120 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3121 & Header
:: closebigbox
();
3122 & Header
:: closepage
();
3129 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2net' )){
3133 my $uplconffilename = '' ;
3134 my $uplconffilename2 = '' ;
3135 my $uplp12name = '' ;
3136 my $uplp12name2 = '' ;
3143 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3145 # Check if a file is uploaded
3147 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3148 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3152 # Move uploaded IPfire n2n package to temporary file
3154 ( my $fh , my $filename ) = tempfile
( );
3155 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3160 my $zip = Archive
:: Zip
-> new ();
3161 my $zipName = $filename ;
3162 my $status = $zip -> read ( $zipName );
3163 if ( $status != AZ_OK
) {
3164 $errormessage = "Read of $zipName failed \n " ;
3168 my $tempdir = tempdir
( CLEANUP
=> 1 );
3169 my @files = $zip -> memberNames ();
3171 $zip -> extractMemberWithoutPaths ( $_ , " $tempdir / $_ " );
3173 my $countfiles = @files ;
3175 # Check if we have not more then 2 files
3177 if ( $countfiles == 2 ){
3179 if ( $_ =~ /.conf$/ ){
3180 $uplconffilename = $_ ;
3182 if ( $_ =~ /.p12$/ ){
3186 if (( $uplconffilename eq '' ) || ( $uplp12name eq '' )){
3187 $errormessage = "Either no *.conf or no *.p12 file found \n " ;
3191 open ( FILE
, " $tempdir / $uplconffilename " ) or die 'Unable to open*.conf file' ;
3192 @firen2nconf = < FILE
>;
3194 chomp ( @firen2nconf );
3198 $errormessage = "Filecount does not match only 2 files are allowed \n " ;
3206 if ( $cgiparams { 'n2nname' } ne '' ){
3208 $uplconffilename2 = " $cgiparams {'n2nname'}.conf" ;
3209 $uplp12name2 = " $cgiparams {'n2nname'}.p12" ;
3210 $n2nname [ 0 ] = $cgiparams { 'n2nname' };
3211 my @n2nname2 = split ( /\./ , $uplconffilename );
3212 $n2nname2 [ 0 ] =~ s/\n|\r//g ;
3213 my $input1 = "${General::swroot}/ovpn/certs/ $uplp12name " ;
3214 my $output1 = "${General::swroot}/ovpn/certs/ $uplp12name2 " ;
3215 my $input2 = " $n2nname2 [0]n2n" ;
3216 my $output2 = " $n2nname [0]n2n" ;
3217 my $filename = " $tempdir / $uplconffilename " ;
3218 open ( FILE
, "< $filename " ) or die 'Unable to open config file.' ;
3219 my @current = < FILE
>;
3221 foreach ( @current ) { s/$input1/$output1/g ;}
3222 foreach ( @current ) { s/$input2/$output2/g ;}
3223 open ( OUT
, "> $filename " ) || die 'Unable to open config file.' ;
3228 $uplconffilename2 = $uplconffilename ;
3229 $uplp12name2 = $uplp12name ;
3230 @n2nname = split ( /\./ , $uplconffilename );
3231 $n2nname [ 0 ] =~ s/\n|\r//g ;
3233 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
3234 unless (- d
"${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" , 0770 or die "Unable to create dir $!" ;}
3236 move
( " $tempdir / $uplconffilename " , "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $uplconffilename2 " );
3239 $errormessage = "*.conf move failed: $!" ;
3244 move
( " $tempdir / $uplp12name " , "${General::swroot}/ovpn/certs/ $uplp12name2 " );
3245 chmod 0600 , "${General::swroot}/ovpn/certs/ $uplp12name " ;
3248 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
3257 my @n2nmtudisc = split ( / / , ( grep { /^mtu-disc/ } @firen2nconf )[ 0 ]);
3258 my @n2nproto2 = split ( / / , ( grep { /^proto/ } @firen2nconf )[ 0 ]);
3259 my @n2nproto = split ( /-/ , $n2nproto2 [ 1 ]);
3260 my @n2nport = split ( / / , ( grep { /^port/ } @firen2nconf )[ 0 ]);
3261 my @n2ntunmtu = split ( / / , ( grep { /^tun-mtu/ } @firen2nconf )[ 0 ]);
3262 my @n2ncomplzo = grep { /^comp-lzo/ } @firen2nconf ;
3263 if ( $n2ncomplzo [ 0 ] =~ /comp-lzo/ ){ $complzoactive = "on" ;} else { $complzoactive = "off" ;}
3264 my @n2nmssfix = grep { /^mssfix/ } @firen2nconf ;
3265 if ( $n2nmssfix [ 0 ] =~ /mssfix/ ){ $mssfixactive = "on" ;} else { $mssfixactive = "off" ;}
3266 #my @n2nmssfix = split(/ /, (grep { /^mssfix/ } @firen2nconf)[0]);
3267 my @n2nfragment = split ( / / , ( grep { /^fragment/ } @firen2nconf )[ 0 ]);
3268 my @n2nremote = split ( / / , ( grep { /^remote/ } @firen2nconf )[ 0 ]);
3269 my @n2novpnsuball = split ( / / , ( grep { /^ifconfig/ } @firen2nconf )[ 0 ]);
3270 my @n2novpnsub = split ( /\./ , $n2novpnsuball [ 1 ]);
3271 my @n2nremsub = split ( / / , ( grep { /^route/ } @firen2nconf )[ 0 ]);
3272 my @n2nmgmt = split ( / / , ( grep { /^management/ } @firen2nconf )[ 0 ]);
3273 my @n2nlocalsub = split ( / / , ( grep { /^# remsub/ } @firen2nconf )[ 0 ]);
3274 my @n2ncipher = split ( / / , ( grep { /^cipher/ } @firen2nconf )[ 0 ]);
3275 my @n2nauth = split ( / / , ( grep { /^auth/ } @firen2nconf )[ 0 ]);;
3278 # m.a.d delete CR and LF from arrays for this chomp doesnt work
3281 $n2nremote [ 1 ] =~ s/\n|\r//g ;
3282 $n2novpnsub [ 0 ] =~ s/\n|\r//g ;
3283 $n2novpnsub [ 1 ] =~ s/\n|\r//g ;
3284 $n2novpnsub [ 2 ] =~ s/\n|\r//g ;
3285 $n2nproto [ 0 ] =~ s/\n|\r//g ;
3286 $n2nport [ 1 ] =~ s/\n|\r//g ;
3287 $n2ntunmtu [ 1 ] =~ s/\n|\r//g ;
3288 $n2nremsub [ 1 ] =~ s/\n|\r//g ;
3289 $n2nremsub [ 2 ] =~ s/\n|\r//g ;
3290 $n2nlocalsub [ 2 ] =~ s/\n|\r//g ;
3291 $n2nfragment [ 1 ] =~ s/\n|\r//g ;
3292 $n2nmgmt [ 2 ] =~ s/\n|\r//g ;
3293 $n2nmtudisc [ 1 ] =~ s/\n|\r//g ;
3294 $n2ncipher [ 1 ] =~ s/\n|\r//g ;
3295 $n2nauth [ 1 ] =~ s/\n|\r//g ;
3296 chomp ( $complzoactive );
3297 chomp ( $mssfixactive );
3304 # Check if there is no other entry with this name
3307 foreach my $dkey ( keys %confighash ) {
3308 if ( $confighash { $dkey }[ 1 ] eq $n2nname [ 0 ]) {
3309 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3310 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3311 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3312 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3318 # Check if OpenVPN Subnet is valid
3321 foreach my $dkey ( keys %confighash ) {
3322 if ( $confighash { $dkey }[ 27 ] eq " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ) {
3323 $errormessage = 'The OpenVPN Subnet is already in use' ;
3324 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3325 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3326 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3332 # Check if Dest Port is vaild
3335 foreach my $dkey ( keys %confighash ) {
3336 if ( $confighash { $dkey }[ 29 ] eq $n2nport [ 1 ] ) {
3337 $errormessage = 'The OpenVPN Port is already in use' ;
3338 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3339 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3340 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3347 $key = & General
:: findhasharraykey
( \
%confighash );
3349 foreach my $i ( 0 .. 42 ) { $confighash { $key }[ $i ] = "" ;}
3351 $confighash { $key }[ 0 ] = 'off' ;
3352 $confighash { $key }[ 1 ] = $n2nname [ 0 ];
3353 $confighash { $key }[ 2 ] = $n2nname [ 0 ];
3354 $confighash { $key }[ 3 ] = 'net' ;
3355 $confighash { $key }[ 4 ] = 'cert' ;
3356 $confighash { $key }[ 6 ] = 'client' ;
3357 $confighash { $key }[ 8 ] = $n2nlocalsub [ 2 ];
3358 $confighash { $key }[ 10 ] = $n2nremote [ 1 ];
3359 $confighash { $key }[ 11 ] = " $n2nremsub [1]/ $n2nremsub [2]" ;
3360 $confighash { $key }[ 22 ] = $n2nmgmt [ 2 ];
3361 $confighash { $key }[ 23 ] = $mssfixactive ;
3362 $confighash { $key }[ 24 ] = $n2nfragment [ 1 ];
3363 $confighash { $key }[ 25 ] = 'IPFire n2n Client' ;
3364 $confighash { $key }[ 26 ] = 'red' ;
3365 $confighash { $key }[ 27 ] = " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ;
3366 $confighash { $key }[ 28 ] = $n2nproto [ 0 ];
3367 $confighash { $key }[ 29 ] = $n2nport [ 1 ];
3368 $confighash { $key }[ 30 ] = $complzoactive ;
3369 $confighash { $key }[ 31 ] = $n2ntunmtu [ 1 ];
3370 $confighash { $key }[ 38 ] = $n2nmtudisc [ 1 ];
3371 $confighash { $key }[ 39 ] = $n2nauth [ 1 ];
3372 $confighash { $key }[ 40 ] = $n2ncipher [ 1 ];
3373 $confighash { $key }[ 41 ] = 'disabled' ;
3375 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3379 & Header
:: showhttpheaders
();
3380 & Header
:: openpage
( 'Validate imported configuration' , 1 , '' );
3381 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
3382 if ( $errormessage ) {
3383 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
3384 print "<class name='base'> $errormessage " ;
3385 print " </class>" ;
3386 & Header
:: closebox
();
3390 & Header
:: openbox
( '100%' , 'LEFT' , 'import ipfire net2net config' );
3392 if ( $errormessage eq '' ){
3394 <!-- ipfire net2net config gui -->
3395 <table width='100%'>
3396 <tr><td width='25%'> </td><td width='25%'> </td></tr>
3397 <tr><td class='boldbase'> $Lang ::tr{'name'}:</td><td><b> $n2nname [0]</b></td></tr>
3398 <tr><td> </td><td> </td></tr>
3399 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td><td><b> $confighash { $key }[6]</b></td></tr>
3400 <tr><td class='boldbase' nowrap='nowrap'>Remote Host </td><td><b> $confighash { $key }[10]</b></td></tr>
3401 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td><td><b> $confighash { $key }[8]</b></td></tr>
3402 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}:</td><td><b> $confighash { $key }[11]</b></td></tr>
3403 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td><td><b> $confighash { $key }[27]</b></td></tr>
3404 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td><td><b> $confighash { $key }[28]</b></td></tr>
3405 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'destination port'}:</td><td><b> $confighash { $key }[29]</b></td></tr>
3406 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td><td><b> $confighash { $key }[30]</b></td></tr>
3407 <tr><td class='boldbase' nowrap='nowrap'>MSSFIX:</td><td><b> $confighash { $key }[23]</b></td></tr>
3408 <tr><td class='boldbase' nowrap='nowrap'>Fragment:</td><td><b> $confighash { $key }[24]</b></td></tr>
3409 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'}</td><td><b> $confighash { $key }[31]</b></td></tr>
3410 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td><td><b> $confighash { $key }[38]</b></td></tr>
3411 <tr><td class='boldbase' nowrap='nowrap'>Management Port </td><td><b> $confighash { $key }[22]</b></td></tr>
3412 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn hmac'}:</td><td><b> $confighash { $key }[39]</b></td></tr>
3413 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td><td><b> $confighash { $key }[40]</b></td></tr>
3414 <tr><td> </td><td> </td></tr>
3418 & Header
:: closebox
();
3421 if ( $errormessage ) {
3422 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3424 print "<div align='center'><form method='post' ENCTYPE='multipart/form-data'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />" ;
3425 print "<input type='hidden' name='TYPE' value='net2netakn' />" ;
3426 print "<input type='hidden' name='KEY' value=' $key ' />" ;
3427 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
3429 & Header
:: closebigbox
();
3430 & Header
:: closepage
();
3435 ### Accept IPFire n2n Package Settings
3438 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3441 ### Discard and Rollback IPFire n2n Package Settings
3444 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'cancel' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3446 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3448 if ( $confighash { $cgiparams { 'KEY' }}) {
3450 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
3451 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
3452 unlink ( $certfile ) or die "Removing $certfile fail: $!" ;
3453 unlink ( $conffile ) or die "Removing $conffile fail: $!" ;
3454 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
3455 delete $confighash { $cgiparams { 'KEY' }};
3456 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3459 $errormessage = $Lang :: tr
{ 'invalid key' };
3469 ### Adding a new connection
3471 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
3472 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
3473 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
3475 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3476 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
3477 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3479 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
3480 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
3481 $errormessage = $Lang :: tr
{ 'invalid key' };
3484 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
3485 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
3486 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
3487 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
3488 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
3489 $cgiparams { 'SIDE' } = $confighash { $cgiparams { 'KEY' }}[ 6 ];
3490 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
3491 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
3492 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
3493 $cgiparams { 'OVPN_MGMT' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
3494 $cgiparams { 'MSSFIX' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
3495 $cgiparams { 'FRAGMENT' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
3496 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
3497 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
3498 $cgiparams { 'OVPN_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
3499 $cgiparams { 'PROTOCOL' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
3500 $cgiparams { 'DEST_PORT' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
3501 $cgiparams { 'COMPLZO' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
3502 $cgiparams { 'MTU' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
3503 $cgiparams { 'CHECK1' } = $confighash { $cgiparams { 'KEY' }}[ 32 ];
3504 $name = $cgiparams { 'CHECK1' } ;
3505 $cgiparams { $name } = $confighash { $cgiparams { 'KEY' }}[ 33 ];
3506 $cgiparams { 'RG' } = $confighash { $cgiparams { 'KEY' }}[ 34 ];
3507 $cgiparams { 'CCD_DNS1' } = $confighash { $cgiparams { 'KEY' }}[ 35 ];
3508 $cgiparams { 'CCD_DNS2' } = $confighash { $cgiparams { 'KEY' }}[ 36 ];
3509 $cgiparams { 'CCD_WINS' } = $confighash { $cgiparams { 'KEY' }}[ 37 ];
3510 $cgiparams { 'PMTU_DISCOVERY' } = $confighash { $cgiparams { 'KEY' }}[ 38 ];
3511 $cgiparams { 'DAUTH' } = $confighash { $cgiparams { 'KEY' }}[ 39 ];
3512 $cgiparams { 'DCIPHER' } = $confighash { $cgiparams { 'KEY' }}[ 40 ];
3513 $cgiparams { 'TLSAUTH' } = $confighash { $cgiparams { 'KEY' }}[ 41 ];
3514 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
3515 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
3517 #A.Marx CCD check iroute field and convert it to decimal
3518 if ( $cgiparams { 'TYPE' } eq 'host' ) {
3520 my %ccdroutehash =();
3524 if ( $cgiparams { 'IR' } ne '' ){
3525 @temp = split ( " \n " , $cgiparams { 'IR' });
3526 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3528 foreach my $key ( keys %ccdroutehash ) {
3529 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3531 delete $ccdroutehash { $key };
3533 $keypoint = & General
:: findhasharraykey
( \
%ccdroutehash );
3536 $ccdroutehash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3539 foreach $val ( @temp ){
3542 #check if iroute exists in ccdroute or if new iroute is part of an existing one
3543 foreach my $key ( keys %ccdroutehash ) {
3544 foreach my $oldiroute ( 1 .. $ #{$ccdroutehash{$key}}){
3545 if ( $ccdroutehash { $key }[ $oldiroute ] eq " $val " ) {
3546 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3549 my ( $ip1 , $cidr1 ) = split ( /\/ /, $val );
3550 $ip1 = & General
:: getnetworkip
( $ip1 ,& General
:: iporsubtocidr
( $cidr1 ));
3551 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $oldiroute ]);
3552 if (& General
:: IpInSubnet
( $ip1 , $ip2 , $cidr2 )){
3553 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3559 if (!& General
:: validipandmask
( $val )){
3560 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3563 ( $ip , $cidr ) = split ( /\/ /, $val );
3564 $ip =& General
:: getnetworkip
( $ip ,& General
:: iporsubtocidr
( $cidr ));
3565 $cidr =& General
:: iporsubtodec
( $cidr );
3566 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3570 #check for existing network IP's
3571 if (& General
:: IpInSubnet
( $ip , $netsettings { GREEN_NETADDRESS
}, $netsettings { GREEN_NETMASK
}) && $netsettings { GREEN_NETADDRESS
} ne '0.0.0.0' )
3573 $errormessage = $Lang :: tr
{ 'ccd err green' };
3575 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { RED_NETADDRESS
}, $netsettings { RED_NETMASK
}) && $netsettings { RED_NETADDRESS
} ne '0.0.0.0' )
3577 $errormessage = $Lang :: tr
{ 'ccd err red' };
3579 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { BLUE_NETADDRESS
}, $netsettings { BLUE_NETMASK
}) && $netsettings { BLUE_NETADDRESS
} ne '0.0.0.0' && $netsettings { BLUE_NETADDRESS
} gt '' )
3581 $errormessage = $Lang :: tr
{ 'ccd err blue' };
3583 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { ORANGE_NETADDRESS
}, $netsettings { ORANGE_NETMASK
}) && $netsettings { ORANGE_NETADDRESS
} ne '0.0.0.0' && $netsettings { ORANGE_NETADDRESS
} gt '' )
3585 $errormessage = $Lang :: tr
{ 'ccd err orange' };
3589 if (& General
:: validipandmask
( $val )){
3590 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3592 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $ip / $cidr )" ;
3597 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3600 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3601 foreach my $key ( keys %ccdroutehash ) {
3602 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3603 delete $ccdroutehash { $key };
3604 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3610 #check route field and convert it to decimal
3613 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3615 foreach my $key ( keys %ccdroute2hash ) {
3616 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3618 delete $ccdroute2hash { $key };
3620 $keypoint = & General
:: findhasharraykey
( \
%ccdroute2hash );
3621 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3625 $ccdroute2hash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3626 if ( $cgiparams { 'IFROUTE' } eq '' ){ $cgiparams { 'IFROUTE' } = $Lang :: tr
{ 'ccd none' };}
3627 @temp = split ( /\|/ , $cgiparams { 'IFROUTE' });
3629 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%ownnet );
3630 foreach $val ( @temp ){
3633 if ( $val eq $Lang :: tr
{ 'green' })
3635 $val = $ownnet { GREEN_NETADDRESS
}. "/" . $ownnet { GREEN_NETMASK
};
3637 if ( $val eq $Lang :: tr
{ 'blue' })
3639 $val = $ownnet { BLUE_NETADDRESS
}. "/" . $ownnet { BLUE_NETMASK
};
3641 if ( $val eq $Lang :: tr
{ 'orange' })
3643 $val = $ownnet { ORANGE_NETADDRESS
}. "/" . $ownnet { ORANGE_NETMASK
};
3645 my ( $ip , $cidr ) = split ( /\/ /, $val );
3647 if ( $val ne $Lang :: tr
{ 'ccd none' })
3649 if (! & check_routes_push
( $val )){ $errormessage = $errormessage . "Route $val " . $Lang :: tr
{ 'ccd err routeovpn2' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3650 if (! & check_ccdroute
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err inuse' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3651 if (! & check_ccdconf
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err routeovpn' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3652 if (& General
:: validipandmask
( $val )){
3653 $val = $ip . "/" .& General
:: iporsubtodec
( $cidr );
3654 $ccdroute2hash { $keypoint }[ $i ] = $val ;
3656 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3660 $ccdroute2hash { $keypoint }[ $i ]= '' ;
3664 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3667 if ( $cgiparams { 'CCD_DNS1' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS1' })) {
3668 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 1" ;
3672 if ( $cgiparams { 'CCD_DNS2' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS2' })) {
3673 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 2" ;
3677 if ( $cgiparams { 'CCD_WINS' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_WINS' })) {
3678 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp wins' };
3686 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
3687 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
3688 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3689 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3690 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3696 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
3697 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
3698 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3699 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3700 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3705 if ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
3706 $errormessage = $Lang :: tr
{ 'name is invalid' };
3707 if ( $cgiparams { 'TYPE' } eq 'net' ) {
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: $!" ;
3714 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
3715 $errormessage = $Lang :: tr
{ 'name too long' };
3716 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3717 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3718 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3727 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3728 if ( $cgiparams { 'DEST_PORT' } eq $vpnsettings { 'DDEST_PORT' }) {
3729 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3730 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3731 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3735 foreach my $key ( sort keys %confighash ){
3736 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 ])){
3737 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3738 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3739 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3743 if ( $cgiparams { 'DEST_PORT' } eq '' ) {
3744 $errormessage = $Lang :: tr
{ 'invalid port' };
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 # Check if the input for the transfer net is valid.
3751 if (!& General
:: validipandmask
( $cgiparams { 'OVPN_SUBNET' })){
3752 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
3753 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3754 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3758 if ( $cgiparams { 'OVPN_SUBNET' } eq $vpnsettings { 'DOVPN_SUBNET' }) {
3759 $errormessage = $Lang :: tr
{ 'openvpn subnet is used' };
3760 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3761 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3765 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3766 $errormessage = $Lang :: tr
{ 'openvpn mssfix allowed with udp' };
3767 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3768 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3772 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'FRAGMENT' } ne '' )) {
3773 $errormessage = $Lang :: tr
{ 'openvpn fragment allowed with udp' };
3774 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3775 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3779 if ( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) {
3780 if (( $cgiparams { 'FRAGMENT' } ne '' ) || ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3781 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
3782 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3783 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3788 if (( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) && ( $cgiparams { 'MTU' } ne '1500' )) {
3789 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc and mtu not 1500' };
3790 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3791 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3795 if ( & validdotmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3796 $errormessage = $Lang :: tr
{ 'openvpn prefix local subnet' };
3797 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3798 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3802 if ( & validdotmask
( $cgiparams { 'OVPN_SUBNET' })) {
3803 $errormessage = $Lang :: tr
{ 'openvpn prefix openvpn subnet' };
3804 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3805 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3809 if ( & validdotmask
( $cgiparams { 'REMOTE_SUBNET' })) {
3810 $errormessage = $Lang :: tr
{ 'openvpn prefix remote subnet' };
3811 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3812 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3816 if ( $cgiparams { 'DEST_PORT' } <= 1023 ) {
3817 $errormessage = $Lang :: tr
{ 'ovpn port in root range' };
3818 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3819 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3823 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
3824 $cgiparams { 'OVPN_MGMT' } = $cgiparams { 'DEST_PORT' };
3827 if ( $cgiparams { 'OVPN_MGMT' } <= 1023 ) {
3828 $errormessage = $Lang :: tr
{ 'ovpn mgmt in root range' };
3829 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3830 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3833 #Check if remote subnet is used elsewhere
3834 my ( $n2nip , $n2nsub )= split ( "/" , $cgiparams { 'REMOTE_SUBNET' });
3835 $warnmessage =& General
:: checksubnets
( '' , $n2nip , 'ovpn' );
3837 $warnmessage = $Lang :: tr
{ 'remote subnet' }. " ( $cgiparams {'REMOTE_SUBNET'}) <br>" . $warnmessage ;
3841 # if (($cgiparams{'TYPE'} eq 'net') && ($cgiparams{'SIDE'} !~ /^(left|right)$/)) {
3842 # $errormessage = $Lang::tr{'ipfire side is invalid'};
3843 # goto VPNCONF_ERROR;
3846 # Check if there is no other entry with this name
3847 if (! $cgiparams { 'KEY' }) {
3848 foreach my $key ( keys %confighash ) {
3849 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
3850 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3851 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3852 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3853 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3860 # Check if a remote host/IP has been set for the client.
3861 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3862 if ( $cgiparams { 'SIDE' } ne 'server' && $cgiparams { 'REMOTE' } eq '' ) {
3863 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3865 # Check if this is a N2N connection and drop temporary config.
3866 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3867 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3872 # Check if a remote host/IP has been configured - the field can be empty on the server side.
3873 if ( $cgiparams { 'REMOTE' } ne '' ) {
3874 # Check if the given IP is valid - otherwise check if it is a valid domain.
3875 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
3876 # Check for a valid domain.
3877 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
3878 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3880 # Check if this is a N2N connection and drop temporary config.
3881 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3882 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3890 if ( $cgiparams { 'TYPE' } ne 'host' ) {
3891 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3892 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
3893 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3894 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3895 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3897 goto VPNCONF_ERROR
;}
3899 # Check if there is no other entry without IP-address and PSK
3900 if ( $cgiparams { 'REMOTE' } eq '' ) {
3901 foreach my $key ( keys %confighash ) {
3902 if (( $cgiparams { 'KEY' } ne $key ) &&
3903 ( $confighash { $key }[ 4 ] eq 'psk' || $cgiparams { 'AUTH' } eq 'psk' ) &&
3904 $confighash { $key }[ 10 ] eq '' ) {
3905 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
3910 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
3911 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
3912 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3913 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3917 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
3918 $errormessage = $Lang :: tr
{ 'invalid input' };
3921 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
3922 $errormessage = $Lang :: tr
{ 'invalid input' };
3927 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
3928 # if (! length($cgiparams{'PSK'}) ) {
3929 # $errormessage = $Lang::tr{'pre-shared key is too short'};
3930 # goto VPNCONF_ERROR;
3932 # if ($cgiparams{'PSK'} =~ /['",&]/) {
3933 # $errormessage = $Lang::tr{'invalid characters found in pre-shared key'};
3934 # goto VPNCONF_ERROR;
3936 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
3937 if ( $cgiparams { 'KEY' }) {
3938 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3941 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3942 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3946 # Move uploaded certificate request to a temporary file
3947 ( my $fh , my $filename ) = tempfile
( );
3948 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3953 # Sign the certificate request and move it
3954 # Sign the host certificate request
3955 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
3956 '-batch' , '-notext' ,
3958 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
3959 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
3961 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3963 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3964 & newcleanssldatabase
();
3968 & deletebackupcert
();
3971 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
3972 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
3974 $temp =~ s
+/ Email
+, E
+;
3975 $temp =~ s/ ST=/ S=/ ;
3976 $cgiparams { 'CERT_NAME' } = $temp ;
3977 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
3978 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
3979 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
3980 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
3983 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
3984 if ( $cgiparams { 'KEY' }) {
3985 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3988 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3989 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3992 # Move uploaded certificate to a temporary file
3993 ( my $fh , my $filename ) = tempfile
( );
3994 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3999 # Verify the certificate has a valid CA and move it
4001 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/cacert.pem $filename ` ;
4002 if ( $test =~ /: OK/ ) {
4005 foreach my $key ( keys %cahash ) {
4006 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $key }[0]cert.pem $filename ` ;
4007 if ( $test =~ /: OK/ ) {
4013 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
4017 move
( $filename , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4019 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
4025 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
4026 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
4028 $temp =~ s
+/ Email
+, E
+;
4029 $temp =~ s/ ST=/ S=/ ;
4030 $cgiparams { 'CERT_NAME' } = $temp ;
4031 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
4032 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
4033 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
4034 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4035 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
4038 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
4039 if ( $cgiparams { 'KEY' }) {
4040 $errormessage = $Lang :: tr
{ 'cant change certificates' };
4043 # Validate input since the form was submitted
4044 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
4045 $errormessage = $Lang :: tr
{ 'name too long' };
4048 if ( $cgiparams { 'CERT_NAME' } eq '' || $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
4049 $errormessage = $Lang :: tr
{ 'invalid input for name' };
4052 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
4053 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
4056 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
4057 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
4060 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4061 $errormessage = $Lang :: tr
{ 'invalid input for department' };
4064 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
4065 $errormessage = $Lang :: tr
{ 'organization too long' };
4068 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
4069 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
4072 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4073 $errormessage = $Lang :: tr
{ 'invalid input for city' };
4076 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4077 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
4080 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
4081 $errormessage = $Lang :: tr
{ 'invalid input for country' };
4084 if ( $cgiparams { 'CERT_PASS1' } ne '' && $cgiparams { 'CERT_PASS2' } ne '' ){
4085 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
4086 $errormessage = $Lang :: tr
{ 'password too short' };
4090 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
4091 $errormessage = $Lang :: tr
{ 'passwords do not match' };
4094 if ( $cgiparams { 'DAYS_VALID' } ne '' && $cgiparams { 'DAYS_VALID' } !~ /^[0-9]+$/ ) {
4095 $errormessage = $Lang :: tr
{ 'invalid input for valid till days' };
4099 # Replace empty strings with a .
4100 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
4101 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
4102 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
4104 # Create the Host certificate request client
4105 my $pid = open ( OPENSSL
, "|-" );
4106 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto VPNCONF_ERROR
;};
4107 if ( $pid ) { # parent
4108 print OPENSSL
" $cgiparams {'CERT_COUNTRY'} \n " ;
4109 print OPENSSL
" $state \n " ;
4110 print OPENSSL
" $city \n " ;
4111 print OPENSSL
" $cgiparams {'CERT_ORGANIZATION'} \n " ;
4112 print OPENSSL
" $ou \n " ;
4113 print OPENSSL
" $cgiparams {'CERT_NAME'} \n " ;
4114 print OPENSSL
" $cgiparams {'CERT_EMAIL'} \n " ;
4115 print OPENSSL
". \n " ;
4116 print OPENSSL
". \n " ;
4119 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4120 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4121 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4125 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' ,
4126 '-newkey' , 'rsa:2048' ,
4127 '-keyout' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
4128 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
4129 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
4130 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
4131 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4132 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4137 # Sign the host certificate request
4138 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
4139 '-batch' , '-notext' ,
4140 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
4141 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
4142 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
4144 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4145 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4146 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4147 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4148 & newcleanssldatabase
();
4151 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4152 & deletebackupcert
();
4155 # Create the pkcs12 file
4156 system ( '/usr/bin/openssl' , 'pkcs12' , '-export' ,
4157 '-inkey' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
4158 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
4159 '-name' , $cgiparams { 'NAME' },
4160 '-passout' , "pass: $cgiparams {'CERT_PASS1'}" ,
4161 '-certfile' , "${General::swroot}/ovpn/ca/cacert.pem" ,
4162 '-caname' , " $vpnsettings {'ROOTCERT_ORGANIZATION'} CA" ,
4163 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
4165 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4166 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4167 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4168 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
4171 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4173 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
4174 ; # Nothing, just editing
4176 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
4180 # Check if there is no other entry with this common name
4181 if ((! $cgiparams { 'KEY' }) && ( $cgiparams { 'AUTH' } ne 'psk' )) {
4182 foreach my $key ( keys %confighash ) {
4183 if ( $confighash { $key }[ 2 ] eq $cgiparams { 'CERT_NAME' }) {
4184 $errormessage = $Lang :: tr
{ 'a connection with this common name already exists' };
4191 my $key = $cgiparams { 'KEY' };
4194 $key = & General
:: findhasharraykey
( \
%confighash );
4195 foreach my $i ( 0 .. 43 ) { $confighash { $key }[ $i ] = "" ;}
4197 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
4198 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
4199 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
4200 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
4203 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
4204 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
4205 $confighash { $key }[ 4 ] = 'psk' ;
4206 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
4208 $confighash { $key }[ 4 ] = 'cert' ;
4210 if ( $cgiparams { 'TYPE' } eq 'net' ) {
4211 $confighash { $key }[ 6 ] = $cgiparams { 'SIDE' };
4212 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
4214 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
4215 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
4216 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
4217 $confighash { $key }[ 22 ] = $confighash { $key }[ 29 ];
4219 $confighash { $key }[ 22 ] = $cgiparams { 'OVPN_MGMT' };
4221 $confighash { $key }[ 23 ] = $cgiparams { 'MSSFIX' };
4222 $confighash { $key }[ 24 ] = $cgiparams { 'FRAGMENT' };
4223 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
4224 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
4226 $confighash { $key }[ 27 ] = $cgiparams { 'OVPN_SUBNET' };
4227 $confighash { $key }[ 28 ] = $cgiparams { 'PROTOCOL' };
4228 $confighash { $key }[ 29 ] = $cgiparams { 'DEST_PORT' };
4229 $confighash { $key }[ 30 ] = $cgiparams { 'COMPLZO' };
4230 $confighash { $key }[ 31 ] = $cgiparams { 'MTU' };
4231 $confighash { $key }[ 32 ] = $cgiparams { 'CHECK1' };
4232 $name = $cgiparams { 'CHECK1' };
4233 $confighash { $key }[ 33 ] = $cgiparams { $name };
4234 $confighash { $key }[ 34 ] = $cgiparams { 'RG' };
4235 $confighash { $key }[ 35 ] = $cgiparams { 'CCD_DNS1' };
4236 $confighash { $key }[ 36 ] = $cgiparams { 'CCD_DNS2' };
4237 $confighash { $key }[ 37 ] = $cgiparams { 'CCD_WINS' };
4238 $confighash { $key }[ 38 ] = $cgiparams { 'PMTU_DISCOVERY' };
4239 $confighash { $key }[ 39 ] = $cgiparams { 'DAUTH' };
4240 $confighash { $key }[ 40 ] = $cgiparams { 'DCIPHER' };
4242 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4244 if ( $cgiparams { 'CHECK1' } ){
4246 my ( $ccdip , $ccdsub )= split "/" , $cgiparams { $name };
4247 my ( $a , $b , $c , $d ) = split ( /\./ , $ccdip );
4248 if ( - e
"${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ){
4249 unlink "${General::swroot}/ovpn/ccd/ $cgiparams {'CERT_NAME'}" ;
4251 open ( CCDRWCONF
, '>' , "${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ) or die "Unable to create clientconfigfile $!" ;
4252 print CCDRWCONF
"# OpenVPN clientconfig from ccd extension by Copymaster# \n\n " ;
4253 if ( $cgiparams { 'CHECK1' } eq 'dynamic' ){
4254 print CCDRWCONF
"#This client uses the dynamic pool \n " ;
4256 print CCDRWCONF
"#Ip address client and server \n " ;
4257 print CCDRWCONF
"ifconfig-push $ccdip " .& General
:: getlastip
( $ccdip , 1 ). " \n " ;
4259 if ( $confighash { $key }[ 34 ] eq 'on' ){
4260 print CCDRWCONF
" \n #Redirect Gateway: \n #All IP traffic is redirected through the vpn \n " ;
4261 print CCDRWCONF
"push redirect-gateway \n " ;
4263 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4264 if ( $cgiparams { 'IR' } ne '' ){
4265 print CCDRWCONF
" \n #Client routes these networks (behind Client) \n " ;
4266 foreach my $key ( keys %ccdroutehash ){
4267 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4268 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
4269 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
4270 print CCDRWCONF
"iroute $a $b \n " ;
4275 if ( $cgiparams { 'IFROUTE' } eq $Lang :: tr
{ 'ccd none' } ){ $cgiparams { 'IFROUTE' }= '' ;}
4276 if ( $cgiparams { 'IFROUTE' } ne '' ){
4277 print CCDRWCONF
" \n #Client gets routes to these networks (behind IPFire) \n " ;
4278 foreach my $key ( keys %ccdroute2hash ){
4279 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4280 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}){
4281 if ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'blue' }){
4283 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%blue );
4284 print CCDRWCONF
"push \" route $blue {BLUE_ADDRESS} $blue {BLUE_NETMASK} \n " ;
4285 } elsif ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'orange' }){
4287 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%orange );
4288 print CCDRWCONF
"push \" route $orange {ORANGE_ADDRESS} $orange {ORANGE_NETMASK} \n " ;
4290 my ( $a , $b )= split ( /\/ /, $ccdroute2hash { $key }[ $i ]);
4291 print CCDRWCONF
"push \" route $a $b \"\n " ;
4297 if (( $cgiparams { 'CCD_DNS1' } eq '' ) && ( $cgiparams { 'CCD_DNS1' } ne '' )){ $cgiparams { 'CCD_DNS1' } = $cgiparams { 'CCD_DNS2' }; $cgiparams { 'CCD_DNS2' }= '' ;}
4298 if ( $cgiparams { 'CCD_DNS1' } ne '' ){
4299 print CCDRWCONF
" \n #Client gets these nameservers \n " ;
4300 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS1'} \" \n " ;
4302 if ( $cgiparams { 'CCD_DNS2' } ne '' ){
4303 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS2'} \" \n " ;
4305 if ( $cgiparams { 'CCD_WINS' } ne '' ){
4306 print CCDRWCONF
" \n #Client gets this WINS server \n " ;
4307 print CCDRWCONF
"push \" dhcp-option WINS $cgiparams {'CCD_WINS'} \" \n " ;
4316 if ( $cgiparams { 'TYPE' } eq 'net' ) {
4318 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
4319 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4321 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4322 my $key = $cgiparams { 'KEY' };
4324 $key = & General
:: findhasharraykey
( \
%confighash );
4325 foreach my $i ( 0 .. 31 ) { $confighash { $key }[ $i ] = "" ;}
4327 $confighash { $key }[ 0 ] = 'on' ;
4328 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4330 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4338 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
4339 $cgiparams { 'KEY' } = $key ;
4340 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
4344 $cgiparams { 'ENABLED' } = 'on' ;
4348 $cgiparams { 'MSSFIX' } = 'on' ;
4349 $cgiparams { 'FRAGMENT' } = '1300' ;
4350 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4351 $cgiparams { 'DAUTH' } = 'SHA1' ;
4355 $cgiparams { 'SIDE' } = 'left' ;
4356 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) {
4357 $cgiparams { 'AUTH' } = 'psk' ;
4358 } elsif ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4359 $cgiparams { 'AUTH' } = 'certfile' ;
4361 $cgiparams { 'AUTH' } = 'certgen' ;
4363 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
4364 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
4365 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
4366 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
4367 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
4368 $cgiparams { 'DAYS_VALID' } = $vpnsettings { 'DAYS_VALID' };
4372 $checked { 'ENABLED' }{ 'off' } = '' ;
4373 $checked { 'ENABLED' }{ 'on' } = '' ;
4374 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4375 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4376 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4377 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4378 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4379 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4380 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4383 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
4384 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
4385 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = 'CHECKED' ;
4387 $selected { 'SIDE' }{ 'server' } = '' ;
4388 $selected { 'SIDE' }{ 'client' } = '' ;
4389 $selected { 'SIDE' }{ $cgiparams { 'SIDE' }} = 'SELECTED' ;
4391 $selected { 'PROTOCOL' }{ 'udp' } = '' ;
4392 $selected { 'PROTOCOL' }{ 'tcp' } = '' ;
4393 $selected { 'PROTOCOL' }{ $cgiparams { 'PROTOCOL' }} = 'SELECTED' ;
4396 $checked { 'AUTH' }{ 'psk' } = '' ;
4397 $checked { 'AUTH' }{ 'certreq' } = '' ;
4398 $checked { 'AUTH' }{ 'certgen' } = '' ;
4399 $checked { 'AUTH' }{ 'certfile' } = '' ;
4400 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = 'CHECKED' ;
4402 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = 'SELECTED' ;
4404 $checked { 'COMPLZO' }{ 'off' } = '' ;
4405 $checked { 'COMPLZO' }{ 'on' } = '' ;
4406 $checked { 'COMPLZO' }{ $cgiparams { 'COMPLZO' }} = 'CHECKED' ;
4408 $checked { 'MSSFIX' }{ 'off' } = '' ;
4409 $checked { 'MSSFIX' }{ 'on' } = '' ;
4410 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4412 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
4413 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4415 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
4417 $selected { 'DCIPHER' }{ 'CAMELLIA-256-CBC' } = '' ;
4418 $selected { 'DCIPHER' }{ 'CAMELLIA-192-CBC' } = '' ;
4419 $selected { 'DCIPHER' }{ 'CAMELLIA-128-CBC' } = '' ;
4420 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4421 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4422 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4423 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4424 $selected { 'DCIPHER' }{ 'SEED-CBC' } = '' ;
4425 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4426 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4427 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4428 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4429 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4430 # If no cipher has been chossen yet, select
4431 # the old default (AES-256-CBC) for compatiblity reasons.
4432 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4433 $cgiparams { 'DCIPHER' } = 'AES-256-CBC' ;
4435 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4436 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
4437 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
4438 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
4439 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
4440 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
4441 # If no hash algorythm has been choosen yet, select
4442 # the old default value (SHA1) for compatiblity reasons.
4443 if ( $cgiparams { 'DAUTH' } eq '' ) {
4444 $cgiparams { 'DAUTH' } = 'SHA1' ;
4446 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
4449 & Header
:: showhttpheaders
();
4450 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
4451 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4452 if ( $errormessage ) {
4453 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4454 print "<class name='base'> $errormessage " ;
4455 print " </class>" ;
4456 & Header
:: closebox
();
4460 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'warning messages'}:" );
4461 print "<class name='base'> $warnmessage " ;
4462 print " </class>" ;
4463 & Header
:: closebox
();
4466 print "<form method='post' enctype='multipart/form-data'>" ;
4467 print "<input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />" ;
4469 if ( $cgiparams { 'KEY' }) {
4470 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
4471 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
4474 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'connection'}:" );
4475 print "<table width='100%' border='0'> \n " ;
4477 print "<tr><td width='14%' class='boldbase'> $Lang ::tr{'name'}: </td>" ;
4479 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4480 if ( $cgiparams { 'KEY' }) {
4481 print "<td width='35%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4483 print "<td width='35%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' size='30' /></td>" ;
4485 # print "<tr><td>$Lang::tr{'interface'}</td>";
4486 # print "<td><select name='INTERFACE'>";
4487 # print "<option value='RED' $selected{'INTERFACE'}{'RED'}>RED</option>";
4488 # if ($netsettings{'BLUE_DEV'} ne '') {
4489 # print "<option value='BLUE' $selected{'INTERFACE'}{'BLUE'}>BLUE</option>";
4491 # print "<option value='GREEN' $selected{'INTERFACE'}{'GREEN'}>GREEN</option>";
4492 # print "<option value='ORANGE' $selected{'INTERFACE'}{'ORANGE'}>ORANGE</option>";
4493 # print "</select></td></tr>";
4496 print "<input type='hidden' name='INTERFACE' value='red' />" ;
4497 if ( $cgiparams { 'KEY' }) {
4498 print "<td width='25%' class='base' nowrap='nowrap'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4500 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' /></td>" ;
4503 <td width='25%'> </td>
4504 <td width='25%'> </td></tr>
4505 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td>
4506 <td><select name='SIDE'>
4507 <option value='server' $selected {'SIDE'}{'server'}> $Lang ::tr{'openvpn server'}</option>
4508 <option value='client' $selected {'SIDE'}{'client'}> $Lang ::tr{'openvpn client'}</option>
4512 <td class='boldbase'> $Lang ::tr{'remote host/ip'}:</td>
4513 <td><input type='TEXT' name='REMOTE' value=' $cgiparams {'REMOTE'}' /></td>
4516 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
4517 <td><input type='TEXT' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' /></td>
4519 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
4520 <td><input type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' /></td>
4523 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td>
4524 <td><input type='TEXT' name='OVPN_SUBNET' value=' $cgiparams {'OVPN_SUBNET'}' /></td>
4526 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
4527 <td><select name='PROTOCOL'>
4528 <option value='udp' $selected {'PROTOCOL'}{'udp'}>UDP</option>
4529 <option value='tcp' $selected {'PROTOCOL'}{'tcp'}>TCP</option></select></td>
4533 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
4534 <td><input type='TEXT' name='DEST_PORT' value=' $cgiparams {'DEST_PORT'}' size='5' /></td>
4536 <td class='boldbase' nowrap='nowrap'>Management Port ( $Lang ::tr{'openvpn default'}: <span class="base"> $Lang ::tr{'destination port'}): <img src='/blob.gif' /></td>
4537 <td> <input type='TEXT' name='OVPN_MGMT' VALUE=' $cgiparams {'OVPN_MGMT'}'size='5' /></td>
4540 <tr><td colspan=4><hr /></td></tr><tr>
4543 <td class'base'><b> $Lang ::tr{'MTU settings'}</b></td>
4546 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} <img src='/blob.gif' /></td>
4547 <td><input type='TEXT' name='MTU' VALUE=' $cgiparams {'MTU'}'size='5' /></td>
4548 <td colspan='2'> $Lang ::tr{'openvpn default'}: udp/tcp <span class="base">1500/1400</span></td>
4551 <tr><td class='boldbase' nowrap='nowrap'>fragment <img src='/blob.gif' /></td>
4552 <td><input type='TEXT' name='FRAGMENT' VALUE=' $cgiparams {'FRAGMENT'}'size='5' /></td>
4553 <td> $Lang ::tr{'openvpn default'}: <span class="base">1300</span></td>
4556 <tr><td class='boldbase' nowrap='nowrap'>mssfix <img src='/blob.gif' /></td>
4557 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
4558 <td> $Lang ::tr{'openvpn default'}: <span class="base">on</span></td>
4561 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'} <img src='/blob.gif'</td>
4562 <td><input type='checkbox' name='COMPLZO' $checked {'COMPLZO'}{'on'} /></td>
4565 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td>
4567 <input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}
4568 <input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}
4569 <input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}
4570 <input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}
4574 <tr><td colspan=4><hr /></td></tr><tr>
4576 <td class'base'><b> $Lang ::tr{'ovpn crypt options'}:</b></td>
4579 <tr><td class='boldbase'> $Lang ::tr{'cipher'}</td>
4580 <td><select name='DCIPHER'>
4581 <option value='CAMELLIA-256-CBC' $selected {'DCIPHER'}{'CAMELLIA-256-CBC'}>CAMELLIA-CBC (256 $Lang ::tr{'bit'})</option>
4582 <option value='CAMELLIA-192-CBC' $selected {'DCIPHER'}{'CAMELLIA-192-CBC'}>CAMELLIA-CBC (192 $Lang ::tr{'bit'})</option>
4583 <option value='CAMELLIA-128-CBC' $selected {'DCIPHER'}{'CAMELLIA-128-CBC'}>CAMELLIA-CBC (128 $Lang ::tr{'bit'})</option>
4584 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-CBC (256 $Lang ::tr{'bit'}, $Lang ::tr{'default'})</option>
4585 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-CBC (192 $Lang ::tr{'bit'})</option>
4586 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-CBC (128 $Lang ::tr{'bit'})</option>
4587 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC (192 $Lang ::tr{'bit'})</option>
4588 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC (192 $Lang ::tr{'bit'})</option>
4589 <option value='SEED-CBC' $selected {'DCIPHER'}{'SEED-CBC'}>SEED-CBC (128 $Lang ::tr{'bit'})</option>
4590 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC (128 $Lang ::tr{'bit'})</option>
4591 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC (128 $Lang ::tr{'bit'})</option>
4592 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC (128 $Lang ::tr{'bit'})</option>
4596 <td class='boldbase'> $Lang ::tr{'ovpn ha'}:</td>
4597 <td><select name='DAUTH'>
4598 <option value='whirlpool' $selected {'DAUTH'}{'whirlpool'}>Whirlpool (512 $Lang ::tr{'bit'})</option>
4599 <option value='SHA512' $selected {'DAUTH'}{'SHA512'}>SHA2 (512 $Lang ::tr{'bit'})</option>
4600 <option value='SHA384' $selected {'DAUTH'}{'SHA384'}>SHA2 (384 $Lang ::tr{'bit'})</option>
4601 <option value='SHA256' $selected {'DAUTH'}{'SHA256'}>SHA2 (256 $Lang ::tr{'bit'})</option>
4602 <option value='SHA1' $selected {'DAUTH'}{'SHA1'}>SHA1 (160 $Lang ::tr{'bit'} Default)</option>
4606 <tr><td colspan=4><hr /></td></tr><tr>
4612 print "<tr><td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' /></td>" ;
4613 print "<td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td></tr></table>" ;
4615 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4616 print "<tr><td> $Lang ::tr{'enabled'} <input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>" ;
4619 print "</tr></table><br><br>" ;
4620 #A.Marx CCD new client
4621 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4622 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>" ;
4625 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnnet );
4626 $vpnip = $vpnnet { 'DOVPN_SUBNET' };
4627 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
4631 $checked { 'check1' }{ 'off' } = '' ;
4632 $checked { 'check1' }{ 'on' } = '' ;
4633 $checked { 'check1' }{ $cgiparams { 'CHECK1' }} = 'CHECKED' ;
4634 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%'>" ;
4635 print "</td></tr></table><br><br>" ;
4636 my $name = $cgiparams { 'CHECK1' };
4637 $checked { 'RG' }{ $cgiparams { 'RG' }} = 'CHECKED' ;
4639 if (! - z
"${General::swroot}/ovpn/ccd.conf" ){
4640 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>" ;
4641 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
4643 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
4644 if ( $count % 2 ){ print "<tr bgcolor=' $color {'color22'}'>" ;} else { print "<tr bgcolor=' $color {'color20'}'>" ;}
4645 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%'>" ;
4646 & fillselectbox
( $ccdconf [ 1 ], $ccdconf [ 0 ], $cgiparams { $name });
4649 print "</table><br><br><hr><br><br>" ;
4653 & Header
:: closebox
();
4654 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
4656 } elsif (! $cgiparams { 'KEY' }) {
4660 my $cakeydisabled = '' ;
4661 my $cacrtdisabled = '' ;
4662 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) { $cakeydisabled = "disabled='disabled'" } else { $cakeydisabled = "" };
4663 if ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) { $cacrtdisabled = "disabled='disabled'" } else { $cacrtdisabled = "" };
4665 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'authentication' });
4668 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4671 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4673 <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>
4674 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td><td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
4675 <tr><td colspan='3'> </td></tr>
4676 <tr><td colspan='3'><hr /></td></tr>
4677 <tr><td colspan='3'> </td></tr>
4678 <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>
4679 <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>
4680 <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>
4681 <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>
4682 <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>
4683 <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>
4684 <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>
4685 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4696 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4698 <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>
4699 <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>
4700 <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>
4701 <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>
4702 <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>
4703 <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>
4704 <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>
4705 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4717 foreach my $country ( sort keys %{ Countries
:: countries
}) {
4718 print "<option value=' $Countries ::countries{ $country }'" ;
4719 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
4720 print " selected='selected'" ;
4722 print "> $country </option>" ;
4728 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4731 <td> </td><td class='base'> $Lang ::tr{'valid till'} (days):</td>
4732 <td class='base' nowrap='nowrap'><input type='text' name='DAYS_VALID' value=' $cgiparams {'DAYS_VALID'}' size='32' $cakeydisabled /></td></tr>
4734 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
4735 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
4736 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:<br>( $Lang ::tr{'confirmation'})</td>
4737 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
4738 <tr><td colspan='3'> </td></tr>
4739 <tr><td colspan='3'><hr /></td></tr>
4740 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4746 <td> </td><td class='base'> $Lang ::tr{'valid till'} (days):</td>
4747 <td class='base' nowrap='nowrap'><input type='text' name='DAYS_VALID' value=' $cgiparams {'DAYS_VALID'}' size='32' $cakeydisabled /></td></tr>
4748 <tr><td> </td><td> </td><td> </td></tr>
4749 <tr><td> </td><td> </td><td> </td></tr>
4750 <tr><td colspan='3'><hr /></td></tr>
4751 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4761 & Header
:: closebox
();
4765 #A.Marx CCD new client
4766 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4768 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ccd client options'}:" );
4772 <table border='0' width='100%'>
4773 <tr><td width='20%'>Redirect Gateway:</td><td colspan='3'><input type='checkbox' name='RG' $checked {'RG'}{'on'} /></td></tr>
4774 <tr><td colspan='4'><b><br> $Lang ::tr{'ccd routes'}</b></td></tr>
4775 <tr><td colspan='4'> </td></tr>
4776 <tr><td valign='top'> $Lang ::tr{'ccd iroute'}</td><td align='left' width='30%'><textarea name='IR' cols='26' rows='6' wrap='off'>
4779 if ( $cgiparams { 'IR' } ne '' ){
4780 print $cgiparams { 'IR' };
4782 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4783 foreach my $key ( keys %ccdroutehash ) {
4784 if ( $cgiparams { 'NAME' } eq $ccdroutehash { $key }[ 0 ]){
4785 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
4786 if ( $ccdroutehash { $key }[ $i ] ne '' ){
4787 print $ccdroutehash { $key }[ $i ]. " \n " ;
4789 $cgiparams { 'IR' } .= $ccdroutehash { $key }[ $i ];
4796 </textarea></td><td valign='top' colspan='2'> $Lang ::tr{'ccd iroutehint'}</td></tr>
4797 <tr><td colspan='4'><br></td></tr>
4798 <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>
4812 open ( FILE
, "${General::swroot}/main/routing" ) ;
4815 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
4817 foreach my $key ( keys %ccdroute2hash ) {
4818 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4819 if ( $ccdroute2hash { $key }[ 1 ] eq '' ){
4826 print "<option> $Lang ::tr{'ccd none'}</option>" ;
4828 print "<option selected> $Lang ::tr{'ccd none'}</option>" ;
4830 #check if static routes are defined for client
4831 foreach my $line ( @current ) {
4833 $line =~ s/\s*$//g ; # remove newline
4834 @temp = split ( /\,/ , $line );
4835 $temp [ 1 ] = '' unless defined $temp [ 1 ]; # not always populated
4836 my ( $a , $b ) = split ( /\/ /, $temp [ 1 ]);
4837 $temp [ 1 ] = $a . "/" .& General
:: iporsubtocidr
( $b );
4838 foreach my $key ( keys %ccdroute2hash ) {
4839 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4840 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4841 if ( $ccdroute2hash { $key }[ $i ] eq $a . "/" .& General
:: iporsubtodec
( $b )){
4847 if ( $set == '1' && $#temp != - 1 ){ print "<option selected> $temp [1]</option>" ; $set = 0 ;} elsif ( $set == '0' && $#temp != - 1 ){ print "<option> $temp [1]</option>" ;}
4849 #check if green,blue,orange are defined for client
4850 foreach my $key ( keys %ccdroute2hash ) {
4851 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4853 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4854 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'GREEN_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'GREEN_NETMASK' })){
4857 if (& haveBlueNet
()){
4858 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'BLUE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'BLUE_NETMASK' })) {
4862 if (& haveOrangeNet
()){
4863 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'ORANGE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'ORANGE_NETMASK' }) ) {
4870 if (& haveBlueNet
() && $selblue == '1' ){ print "<option selected> $Lang ::tr{'blue'}</option>" ; $selblue = 0 ;} elsif (& haveBlueNet
() && $selblue == '0' ){ print "<option> $Lang ::tr{'blue'}</option>" ;}
4871 if (& haveOrangeNet
() && $selorange == '1' ){ print "<option selected> $Lang ::tr{'orange'}</option>" ; $selorange = 0 ;} elsif (& haveOrangeNet
() && $selorange == '0' ){ print "<option> $Lang ::tr{'orange'}</option>" ;}
4872 if ( $selgreen == '1' || $other == '0' ){ print "<option selected> $Lang ::tr{'green'}</option>" ; $set = 0 ;} else { print "<option> $Lang ::tr{'green'}</option>" ;};
4875 </select></td><td valign='top'>DNS1:</td><td valign='top'><input type='TEXT' name='CCD_DNS1' value=' $cgiparams {'CCD_DNS1'}' size='30' /></td></tr>
4876 <tr valign='top'><td>DNS2:</td><td><input type='TEXT' name='CCD_DNS2' value=' $cgiparams {'CCD_DNS2'}' size='30' /></td></tr>
4877 <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>
4881 & Header
:: closebox
();
4883 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
4884 if ( $cgiparams { 'KEY' }) {
4885 # print "<input type='submit' name='ACTION' value='$Lang::tr{'advanced'}' />";
4887 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
4888 & Header
:: closebigbox
();
4889 & Header
:: closepage
();
4897 ### Default status page
4902 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
4903 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
4904 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4906 my @status = `/bin/cat /var/run/ovpnserver.log` ;
4908 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
4909 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
4910 my $ipaddr = < IPADDR
>;
4913 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
4914 if ( $cgiparams { 'VPN_IP' } eq '' ) {
4915 $cgiparams { 'VPN_IP' } = $ipaddr ;
4921 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4922 $cgiparams { 'DCIPHER' } = 'AES-256-CBC' ;
4924 if ( $cgiparams { 'DDEST_PORT' } eq '' ) {
4925 $cgiparams { 'DDEST_PORT' } = '1194' ;
4927 if ( $cgiparams { 'DMTU' } eq '' ) {
4928 $cgiparams { 'DMTU' } = '1400' ;
4930 if ( $cgiparams { 'MSSFIX' } eq '' ) {
4931 $cgiparams { 'MSSFIX' } = 'off' ;
4933 if ( $cgiparams { 'DAUTH' } eq '' ) {
4934 $cgiparams { 'DAUTH' } = 'SHA1' ;
4936 if ( $cgiparams { 'DOVPN_SUBNET' } eq '' ) {
4937 $cgiparams { 'DOVPN_SUBNET' } = '10.' . int ( rand ( 256 )) . '.' . int ( rand ( 256 )) . '.0/255.255.255.0' ;
4939 $checked { 'ENABLED' }{ 'off' } = '' ;
4940 $checked { 'ENABLED' }{ 'on' } = '' ;
4941 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4942 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4943 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4944 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4945 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4946 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4947 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4948 $selected { 'DDEVICE' }{ 'tun' } = '' ;
4949 $selected { 'DDEVICE' }{ 'tap' } = '' ;
4950 $selected { 'DDEVICE' }{ $cgiparams { 'DDEVICE' }} = 'SELECTED' ;
4952 $selected { 'DPROTOCOL' }{ 'udp' } = '' ;
4953 $selected { 'DPROTOCOL' }{ 'tcp' } = '' ;
4954 $selected { 'DPROTOCOL' }{ $cgiparams { 'DPROTOCOL' }} = 'SELECTED' ;
4956 $selected { 'DCIPHER' }{ 'CAMELLIA-256-CBC' } = '' ;
4957 $selected { 'DCIPHER' }{ 'CAMELLIA-192-CBC' } = '' ;
4958 $selected { 'DCIPHER' }{ 'CAMELLIA-128-CBC' } = '' ;
4959 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4960 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4961 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4962 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4963 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4964 $selected { 'DCIPHER' }{ 'SEED-CBC' } = '' ;
4965 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4966 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4967 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4968 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4969 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4971 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
4972 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
4973 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
4974 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
4975 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
4976 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
4978 $checked { 'DCOMPLZO' }{ 'off' } = '' ;
4979 $checked { 'DCOMPLZO' }{ 'on' } = '' ;
4980 $checked { 'DCOMPLZO' }{ $cgiparams { 'DCOMPLZO' }} = 'CHECKED' ;
4983 $checked { 'MSSFIX' }{ 'off' } = '' ;
4984 $checked { 'MSSFIX' }{ 'on' } = '' ;
4985 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4987 & Header
:: showhttpheaders
();
4988 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
4989 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4991 if ( $errormessage ) {
4992 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4993 print "<class name='base'> $errormessage \n " ;
4994 print " </class> \n " ;
4995 & Header
:: closebox
();
4999 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'warning messages' });
5000 print " $warnmessage <br>" ;
5001 print " $Lang ::tr{'fwdfw warn1'}<br>" ;
5002 & Header
:: closebox
();
5003 print "<center><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'ok'}' style='width: 5em;'></form>" ;
5004 & Header
:: closepage
();
5008 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>" ;
5009 my $srunning = "no" ;
5010 my $activeonrun = "" ;
5011 if ( - e
"/var/run/openvpn.pid" ){
5012 $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>" ;
5016 $activeonrun = "disabled='disabled'" ;
5018 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'global settings' });
5020 <table width='100%' border='0'>
5021 <form method='post'>
5022 <td width='25%'> </td>
5023 <td width='25%'> </td>
5024 <td width='25%'> </td></tr>
5025 <tr><td class='boldbase'> $Lang ::tr{'ovpn server status'}</td>
5026 <td align='left'> $sactive </td>
5027 <tr><td class='boldbase'> $Lang ::tr{'ovpn on red'}</td>
5028 <td><input type='checkbox' name='ENABLED' $checked {'ENABLED'}{'on'} /></td>
5031 if (& haveBlueNet
()) {
5032 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on blue'}</td>" ;
5033 print "<td><input type='checkbox' name='ENABLED_BLUE' $checked {'ENABLED_BLUE'}{'on'} /></td>" ;
5035 if (& haveOrangeNet
()) {
5036 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on orange'}</td>" ;
5037 print "<td><input type='checkbox' name='ENABLED_ORANGE' $checked {'ENABLED_ORANGE'}{'on'} /></td>" ;
5040 <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>
5041 <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>
5042 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn device'}</td>
5043 <td><select name='DDEVICE' ><option value='tun' $selected {'DDEVICE'}{'tun'}>TUN</option>
5044 <!-- this is still not working
5045 <option value='tap' $selected {'DDEVICE'}{'tap'}>TAP</option></select>--> </td>
5046 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
5047 <td><select name='DPROTOCOL'><option value='udp' $selected {'DPROTOCOL'}{'udp'}>UDP</option>
5048 <option value='tcp' $selected {'DPROTOCOL'}{'tcp'}>TCP</option></select></td>
5049 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
5050 <td><input type='TEXT' name='DDEST_PORT' value=' $cgiparams {'DDEST_PORT'}' size='5' /></td></tr>
5051 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} </td>
5052 <td> <input type='TEXT' name='DMTU' VALUE=' $cgiparams {'DMTU'}' size='5' /></td>
5054 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td>
5055 <td><select name='DCIPHER'>
5056 <option value='CAMELLIA-256-CBC' $selected {'DCIPHER'}{'CAMELLIA-256-CBC'}>CAMELLIA-CBC (256 $Lang ::tr{'bit'})</option>
5057 <option value='CAMELLIA-192-CBC' $selected {'DCIPHER'}{'CAMELLIA-192-CBC'}>CAMELLIA-CBC (192 $Lang ::tr{'bit'})</option>
5058 <option value='CAMELLIA-128-CBC' $selected {'DCIPHER'}{'CAMELLIA-128-CBC'}>CAMELLIA-CBC (128 $Lang ::tr{'bit'})</option>
5059 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-CBC (256 $Lang ::tr{'bit'})</option>
5060 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-CBC (192 $Lang ::tr{'bit'})</option>
5061 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-CBC (128 $Lang ::tr{'bit'})</option>
5062 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC (192 $Lang ::tr{'bit'})</option>
5063 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC (192 $Lang ::tr{'bit'})</option>
5064 <option value='SEED-CBC' $selected {'DCIPHER'}{'SEED-CBC'}>SEED-CBC (128 $Lang ::tr{'bit'})</option>
5065 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC (128 $Lang ::tr{'bit'})</option>
5066 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC (128 $Lang ::tr{'bit'})</option>
5067 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC (128 $Lang ::tr{'bit'})</option>
5070 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td>
5071 <td><input type='checkbox' name='DCOMPLZO' $checked {'DCOMPLZO'}{'on'} /></td>
5073 <tr><td colspan='4'><br><br></td></tr>
5077 if ( $srunning eq "yes" ) {
5078 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' disabled='disabled' />" ;
5079 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
5080 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
5081 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'stop ovpn server'}' /></td></tr>" ;
5083 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
5084 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
5085 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
5086 if (( - e
"${General::swroot}/ovpn/ca/cacert.pem" &&
5087 - e
"${General::swroot}/ovpn/ca/dh1024.pem" &&
5088 - e
"${General::swroot}/ovpn/certs/servercert.pem" &&
5089 - e
"${General::swroot}/ovpn/certs/serverkey.pem" ) &&
5090 (( $cgiparams { 'ENABLED' } eq 'on' ) ||
5091 ( $cgiparams { 'ENABLED_BLUE' } eq 'on' ) ||
5092 ( $cgiparams { 'ENABLED_ORANGE' } eq 'on' ))){
5093 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' /></td></tr>" ;
5095 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' disabled='disabled' /></td></tr>" ;
5098 print "</form></table>" ;
5099 & Header
:: closebox
();
5101 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5104 #<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>
5107 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection status and controlc' });
5113 foreach my $key ( sort { ncmp
( $confighash { $a }[ 32 ], $confighash { $b }[ 32 ]) } sort { ncmp
( $confighash { $a }[ 1 ], $confighash { $b }[ 1 ]) } keys %confighash ) {
5114 if ( $confighash { $key }[ 32 ] eq "" && $confighash { $key }[ 3 ] eq 'net' ){ $confighash { $key }[ 32 ]= $Lang :: tr
{ 'fwhost OpenVPN N-2-N' };}
5115 if ( $confighash { $key }[ 32 ] eq "dynamic" ){ $confighash { $key }[ 32 ]= $Lang :: tr
{ 'ccd dynrange' };}
5117 print "<b> $confighash { $key }[32]</b>" ;
5119 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5121 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5122 <th width='15%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></th>
5123 <th width='20%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></th>
5124 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></th>
5125 <th width='5%' class='boldbase' colspan='6' align='center'><b> $Lang ::tr{'action'}</b></th>
5129 if ( $id > 0 && $lastnet ne $confighash { $key }[ 32 ]){
5130 print "</table><br>" ;
5131 print "<b> $confighash { $key }[32]</b>" ;
5133 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5135 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5136 <th width='15%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></th>
5137 <th width='20%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></th>
5138 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></th>
5139 <th width='5%' class='boldbase' colspan='6' align='center'><b> $Lang ::tr{'action'}</b></th>
5143 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
5146 $col = "bgcolor=' $color {'color20'}'" ;
5149 $col = "bgcolor=' $color {'color22'}'" ;
5151 print "<td align='center' nowrap='nowrap' $col > $confighash { $key }[1]</td>" ;
5152 print "<td align='center' nowrap='nowrap' $col >" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
5153 #if ($confighash{$key}[4] eq 'cert') {
5154 #print "<td align='left' nowrap='nowrap'>$confighash{$key}[2]</td>";
5156 #print "<td align='left'> </td>";
5158 my $cavalid = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
5159 $cavalid =~ /Not After : (.*)[\n]/ ;
5161 print "<td align='center' $col > $confighash { $key }[25]</td>" ;
5162 $col1 = "bgcolor='${Header::colourred}'" ;
5163 my $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
5165 if ( $confighash { $key }[ 0 ] eq 'off' ) {
5166 $col1 = "bgcolor='${Header::colourblue}'" ;
5167 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
5174 if ( $confighash { $key }[ 3 ] eq 'net' ) {
5176 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
5179 my $tport = $confighash { $key }[ 22 ];
5180 my $tnet = new Net
:: Telnet
( Timeout
=> 5 , Errmode
=> 'return' , Port
=> $tport );
5182 $tnet -> open ( '127.0.0.1' );
5183 @output = $tnet -> cmd ( String
=> 'state' , Prompt
=> '/(END.* \n |ERROR:.* \n )/' );
5184 @tustate = split ( /\,/ , $output [ 1 ]);
5186 #CONNECTING -- OpenVPN's initial state.
5187 #WAIT -- (Client only) Waiting for initial response from server.
5188 #AUTH -- (Client only) Authenticating with server.
5189 #GET_CONFIG -- (Client only) Downloading configuration options from server.
5190 #ASSIGN_IP -- Assigning IP address to virtual network interface.
5191 #ADD_ROUTES -- Adding routes to system.
5192 #CONNECTED -- Initialization Sequence Completed.
5193 #RECONNECTING -- A restart has occurred.
5194 #EXITING -- A graceful exit is in progress.
5197 if (( $tustate [ 1 ] eq 'CONNECTED' ) || ( $tustate [ 1 ] eq 'WAIT' )) {
5198 $col1 = "bgcolor='${Header::colourgreen}'" ;
5199 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
5201 $col1 = "bgcolor='${Header::colourred}'" ;
5202 $active = "<b><font color='#FFFFFF'> $tustate [1]</font></b>" ;
5210 foreach my $line ( @status ) {
5212 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
5213 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
5214 if ( $match [ 1 ] ne "Common Name" ) {
5218 if ( $cn eq " $confighash { $key }[2]" ) {
5219 $col1 = "bgcolor='${Header::colourgreen}'" ;
5220 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
5229 <td align='center' $col1 > $active </td>
5231 <form method='post' name='frm${key}a'><td align='center' $col >
5232 <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' />
5233 <input type='hidden' name='ACTION' value=' $Lang ::tr{'dl client arch'}' />
5234 <input type='hidden' name='KEY' value=' $key ' />
5238 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
5240 <form method='post' name='frm${key}b'><td align='center' $col >
5241 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' border='0' />
5242 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
5243 <input type='hidden' name='KEY' value=' $key ' />
5247 print "<td> </td>" ;
5249 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" ) {
5251 <form method='post' name='frm${key}c'><td align='center' $col >
5252 <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' />
5253 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
5254 <input type='hidden' name='KEY' value=' $key ' />
5257 ; } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
5259 <form method='post' name='frm${key}c'><td align='center' $col >
5260 <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' />
5261 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
5262 <input type='hidden' name='KEY' value=' $key ' />
5266 print "<td> </td>" ;
5269 <form method='post' name='frm${key}d'><td align='center' $col >
5270 <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' />
5271 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
5272 <input type='hidden' name='KEY' value=' $key ' />
5275 <form method='post' name='frm${key}e'><td align='center' $col >
5276 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
5277 <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'/>
5278 <input type='hidden' name='KEY' value=' $key ' />
5280 <form method='post' name='frm${key}f'><td align='center' $col >
5281 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
5282 <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' />
5283 <input type='hidden' name='KEY' value=' $key ' />
5289 $lastnet = $confighash { $key }[ 32 ];
5294 # If the config file contains entries, print Key to action icons
5299 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5300 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
5301 <td class='base'> $Lang ::tr{'click to disable'}</td>
5302 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
5303 <td class='base'> $Lang ::tr{'show certificate'}</td>
5304 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
5305 <td class='base'> $Lang ::tr{'edit'}</td>
5306 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
5307 <td class='base'> $Lang ::tr{'remove'}</td>
5311 <td> <img src='/images/off.gif' alt='?OFF' /></td>
5312 <td class='base'> $Lang ::tr{'click to enable'}</td>
5313 <td> <img src='/images/media-floppy.png' alt='?FLOPPY' /></td>
5314 <td class='base'> $Lang ::tr{'download certificate'}</td>
5315 <td> <img src='/images/openvpn.png' alt='?RELOAD'/></td>
5316 <td class='base'> $Lang ::tr{'dl client arch'}</td>
5324 <table width='100%'>
5325 <form method='post'>
5326 <tr><td align='right'>
5327 <input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
5328 <input type='submit' name='ACTION' value=' $Lang ::tr{'ovpn con stat'}' $activeonrun /></td>
5334 & Header
:: closebox
();
5338 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate authorities'}" );
5340 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5342 <th width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5343 <th width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></th>
5344 <th width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></th>
5348 my $col1 = "bgcolor=' $color {'color22'}'" ;
5349 my $col2 = "bgcolor=' $color {'color20'}'" ;
5351 my $col3 = "bgcolor=' $color {'color22'}'" ;
5353 my $col4 = "bgcolor=' $color {'color20'}'" ;
5355 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5356 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
5357 $casubject =~ /Subject: (.*)[\n]/ ;
5359 $casubject =~ s
+/ Email
+, E
+;
5360 $casubject =~ s/ ST=/ S=/ ;
5363 <td class='base' $col1 > $Lang ::tr{'root certificate'}</td>
5364 <td class='base' $col1 > $casubject </td>
5365 <form method='post' name='frmrootcrta'><td width='3%' align='center' $col1 >
5366 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
5367 <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' />
5369 <form method='post' name='frmrootcrtb'><td width='3%' align='center' $col1 >
5370 <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' />
5371 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
5373 <td width='4%' $col1 > </td>
5378 # display rootcert generation buttons
5381 <td class='base' $col1 > $Lang ::tr{'root certificate'}:</td>
5382 <td class='base' $col1 > $Lang ::tr{'not present'}</td>
5383 <td colspan='3' $col1 > </td>
5389 if (- f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
5390 my $hostsubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
5391 $hostsubject =~ /Subject: (.*)[\n]/ ;
5393 $hostsubject =~ s
+/ Email
+, E
+;
5394 $hostsubject =~ s/ ST=/ S=/ ;
5398 <td class='base' $col2 > $Lang ::tr{'host certificate'}</td>
5399 <td class='base' $col2 > $hostsubject </td>
5400 <form method='post' name='frmhostcrta'><td width='3%' align='center' $col2 >
5401 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
5402 <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' />
5404 <form method='post' name='frmhostcrtb'><td width='3%' align='center' $col2 >
5405 <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' />
5406 <input type='hidden' name='ACTION' value=" $Lang ::tr{'download host certificate'}" />
5408 <td width='4%' $col2 > </td>
5416 <td width='25%' class='base' $col2 > $Lang ::tr{'host certificate'}:</td>
5417 <td class='base' $col2 > $Lang ::tr{'not present'}</td>
5418 </td><td colspan='3' $col2 > </td>
5424 # Adding DH parameter to chart
5425 if (- f
"${General::swroot}/ovpn/ca/dh1024.pem" ) {
5426 my $dhsubject = `/usr/bin/openssl dhparam -text -in ${General::swroot}/ovpn/ca/dh1024.pem` ;
5427 $dhsubject =~ / (.*)[\n]/ ;
5433 <td class='base' $col3 > $Lang ::tr{'dh parameter'}</td>
5434 <td class='base' $col3 > $dhsubject </td>
5435 <form method='post' name='frmdhparam'><td width='3%' align='center' $col3 >
5436 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show dh'}' />
5437 <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' />
5439 <form method='post' name='frmdhparam'><td width='3%' align='center' $col3 >
5441 <td width='4%' $col3 > </td>
5449 <td width='25%' class='base' $col3 > $Lang ::tr{'dh parameter'}:</td>
5450 <td class='base' $col3 > $Lang ::tr{'not present'}</td>
5451 </td><td colspan='3' $col3 > </td>
5457 # Adding ta.key to chart
5458 if (- f
"${General::swroot}/ovpn/certs/ta.key" ) {
5459 my $tasubject = `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
5460 $tasubject =~ /# (.*)[\n]/ ;
5465 <td class='base' $col4 > $Lang ::tr{'ta key'}</td>
5466 <td class='base' $col4 > $tasubject </td>
5467 <form method='post' name='frmtakey'><td width='3%' align='center' $col4 >
5468 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show tls-auth key'}' />
5469 <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' />
5471 <form method='post' name='frmtakey'><td width='3%' align='center' $col4 >
5472 <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' />
5473 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download tls-auth key'}' />
5475 <td width='4%' $col4 > </td>
5483 <td width='25%' class='base' $col4 > $Lang ::tr{'ta key'}:</td>
5484 <td class='base' $col4 > $Lang ::tr{'not present'}</td>
5485 <td colspan='3' $col4 > </td>
5491 if (! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5492 print "<tr><td colspan='5' align='center'><form method='post'>" ;
5493 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' />" ;
5494 print "</form></td></tr> \n " ;
5497 if ( keys %cahash > 0 ) {
5498 foreach my $key ( keys %cahash ) {
5499 if (( $key + 1 ) % 2 ) {
5500 print "<tr bgcolor=' $color {'color20'}'> \n " ;
5502 print "<tr bgcolor=' $color {'color22'}'> \n " ;
5504 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
5505 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
5507 <form method='post' name='cafrm${key}a'><td align='center'>
5508 <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' />
5509 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
5510 <input type='hidden' name='KEY' value=' $key ' />
5512 <form method='post' name='cafrm${key}b'><td align='center'>
5513 <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' />
5514 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
5515 <input type='hidden' name='KEY' value=' $key ' />
5517 <form method='post' name='cafrm${key}c'><td align='center'>
5518 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
5519 <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' />
5520 <input type='hidden' name='KEY' value=' $key ' />
5529 # If the file contains entries, print Key to action icons
5530 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5534 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5535 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
5536 <td class='base'> $Lang ::tr{'show certificate'}</td>
5537 <td> <img src='/images/media-floppy.png' alt=' $Lang ::tr{'download certificate'}' /></td>
5538 <td class='base'> $Lang ::tr{'download certificate'}</td>
5547 <form method='post' enctype='multipart/form-data'>
5548 <table width='100%' border='0'cellspacing='1' cellpadding='0'>
5550 <td class'base'><b> $Lang ::tr{'upload ca certificate'}</b></td>
5553 <td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}:</td>
5554 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' align='left'/></td>
5555 <td nowrap='nowrap'><input type='file' name='FH' size='25' />
5556 <td nowrap='nowrap' align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td>
5560 <td colspan='4' align='right' width='80%'><input type='submit' name='ACTION' value=' $Lang ::tr{'show crl'}' /></td>
5563 <tr><td colspan=4><hr /></td></tr><tr>
5565 <td class'base'><b> $Lang ::tr{'ovpn dh parameters'}</b></td>
5569 <td class='base' nowrap='nowrap'> $Lang ::tr{'ovpn dh upload'}:</td>
5570 <td nowrap='nowrap'><size='15' align='left'/></td>
5571 <td nowrap='nowrap'><input type='file' name='FH' size='25' />
5572 <td colspan='4' align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload dh key'}' /></td>
5575 <td class='base' nowrap='nowrap'> $Lang ::tr{'ovpn dh new key'}:</td>
5576 <td nowrap='nowrap'><size='15' align='left'/></td>
5577 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'generate dh key'}' /></td>
5581 <tr><td colspan=4><hr /></td></tr><tr>
5585 if ( $srunning eq "yes" ) {
5586 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' disabled='disabled' /></div></form> \n " ;
5588 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' /></div></form> \n " ;
5590 & Header
:: closebox
();
5594 & Header
:: closepage
();