]>
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 " );
1240 while ( $file = glob ( "/var/run/openvpn/*-n2n" )) {
1244 # Remove everything from the collectd configuration
1245 & writecollectdconf
();
1247 #&writeserverconf();
1249 ### Reset all step 1
1251 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' }) {
1252 & Header
:: showhttpheaders
();
1253 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1254 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1255 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
1257 <form method='post'>
1258 <table width='100%'>
1261 <input type='hidden' name='AREUSURE' value='yes' />
1262 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1263 $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}</td>
1266 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' />
1267 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
1273 & Header
:: closebox
();
1274 & Header
:: closebigbox
();
1275 & Header
:: closepage
();
1279 ### Generate DH key step 2
1281 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate dh key' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1282 # Delete if old key exists
1283 if (- f
"${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ) {
1284 unlink "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ;
1286 # Create Diffie Hellmann Parameter
1287 system ( '/usr/bin/openssl' , 'dhparam' , '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" , " $cgiparams {'DHLENGHT'}" );
1289 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1290 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1294 ### Generate DH key step 1
1296 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate dh key' }) {
1297 & Header
:: showhttpheaders
();
1298 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1299 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1300 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'gen dh'}:" );
1302 <table width='100%'>
1304 <td width='20%'> </td> <td width='15%'></td> <td width='65%'></td>
1307 <td class='base'> $Lang ::tr{'ovpn dh'}:</td>
1309 <form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1310 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1311 <select name='DHLENGHT'>
1312 <option value='1024' $selected {'DHLENGHT'}{'1024'}>1024 $Lang ::tr{'bit'}</option>
1313 <option value='2048' $selected {'DHLENGHT'}{'2048'}>2048 $Lang ::tr{'bit'}</option>
1314 <option value='3072' $selected {'DHLENGHT'}{'3072'}>3072 $Lang ::tr{'bit'}</option>
1315 <option value='4096' $selected {'DHLENGHT'}{'4096'}>4096 $Lang ::tr{'bit'}</option>
1319 <tr><td colspan='4'><br></td></tr>
1321 <table width='100%'>
1323 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}: </font></b> $Lang ::tr{'dh key warn'}
1326 <td class='base'> $Lang ::tr{'dh key warn1'}</td>
1328 <tr><td colspan='2'><br></td></tr>
1330 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'generate dh key'}' /></td>
1337 & Header
:: closebox
();
1338 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1339 & Header
:: closebigbox
();
1340 & Header
:: closepage
();
1346 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload dh key' }) {
1347 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1348 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1349 goto UPLOADCA_ERROR
;
1351 # Move uploaded dh key to a temporary file
1352 ( my $fh , my $filename ) = tempfile
( );
1353 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1355 goto UPLOADCA_ERROR
;
1357 my $temp = `/usr/bin/openssl dhparam -text -in $filename ` ;
1358 if ( $temp !~ /DH Parameters: \((1024|2048|3072|4096) bit\)/ ) {
1359 $errormessage = $Lang :: tr
{ 'not a valid dh key' };
1361 goto UPLOADCA_ERROR
;
1363 # Delete if old key exists
1364 if (- f
"${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ) {
1365 unlink "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" ;
1367 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'DH_NAME'}" );
1369 $errormessage = " $Lang ::tr{'dh key move failed'}: $!" ;
1371 goto UPLOADCA_ERROR
;
1376 ### Upload CA Certificate
1378 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
1379 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1381 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1382 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1383 goto UPLOADCA_ERROR
;
1386 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
1387 $errormessage = $Lang :: tr
{ 'name too long' };
1391 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
1392 $errormessage = $Lang :: tr
{ 'name is invalid' };
1393 goto UPLOADCA_ERROR
;
1396 # Check if there is no other entry with this name
1397 foreach my $key ( keys %cahash ) {
1398 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
1399 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
1400 goto UPLOADCA_ERROR
;
1404 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1405 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1406 goto UPLOADCA_ERROR
;
1408 # Move uploaded ca to a temporary file
1409 ( my $fh , my $filename ) = tempfile
( );
1410 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1412 goto UPLOADCA_ERROR
;
1414 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
1415 if ( $temp !~ /CA:TRUE/i ) {
1416 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1418 goto UPLOADCA_ERROR
;
1420 move
( $filename , "${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1422 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1424 goto UPLOADCA_ERROR
;
1428 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cgiparams {'CA_NAME'}cert.pem` ;
1429 $casubject =~ /Subject: (.*)[\n]/ ;
1431 $casubject =~ s
+/ Email
+, E
+;
1432 $casubject =~ s/ ST=/ S=/ ;
1433 $casubject = & Header
:: cleanhtml
( $casubject );
1435 my $key = & General
:: findhasharraykey
( \
%cahash );
1436 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1437 $cahash { $key }[ 1 ] = $casubject ;
1438 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1439 # system('/usr/local/bin/ipsecctrl', 'R');
1444 ### Display ca certificate
1446 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
1447 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1449 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1450 & Header
:: showhttpheaders
();
1451 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1452 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1453 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ca certificate'}:" );
1454 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1455 $output = & Header
:: cleanhtml
( $output , "y" );
1456 print "<pre> $output </pre> \n " ;
1457 & Header
:: closebox
();
1458 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1459 & Header
:: closebigbox
();
1460 & Header
:: closepage
();
1463 $errormessage = $Lang :: tr
{ 'invalid key' };
1467 ### Download ca certificate
1469 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
1470 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1472 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1473 print "Content-Type: application/octet-stream \r\n " ;
1474 print "Content-Disposition: filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
1475 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
1478 $errormessage = $Lang :: tr
{ 'invalid key' };
1482 ### Remove ca certificate (step 2)
1484 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
1485 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1486 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1488 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1489 foreach my $key ( keys %confighash ) {
1490 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` ;
1491 if ( $test =~ /: OK/ ) {
1493 # if ($vpnsettings{'ENABLED'} eq 'on' ||
1494 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
1495 # system('/usr/local/bin/ipsecctrl', 'D', $key);
1497 unlink ( "${General::swroot}/ovpn//certs/ $confighash { $key }[1]cert.pem" );
1498 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" );
1499 delete $confighash { $key };
1500 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1501 # &writeipsecfiles();
1504 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1505 delete $cahash { $cgiparams { 'KEY' }};
1506 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1507 # system('/usr/local/bin/ipsecctrl', 'R');
1509 $errormessage = $Lang :: tr
{ 'invalid key' };
1512 ### Remove ca certificate (step 1)
1514 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
1515 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
1516 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1518 my $assignedcerts = 0 ;
1519 if ( - f
"${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
1520 foreach my $key ( keys %confighash ) {
1521 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` ;
1522 if ( $test =~ /: OK/ ) {
1526 if ( $assignedcerts ) {
1527 & Header
:: showhttpheaders
();
1528 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1529 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
1530 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'are you sure' });
1532 <table><form method='post'><input type='hidden' name='AREUSURE' value='yes' />
1533 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
1534 <tr><td align='center'>
1535 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>: $assignedcerts
1536 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}
1537 <tr><td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
1538 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td></tr>
1542 & Header
:: closebox
();
1543 & Header
:: closebigbox
();
1544 & Header
:: closepage
();
1547 unlink ( "${General::swroot}/ovpn/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
1548 delete $cahash { $cgiparams { 'KEY' }};
1549 & General
:: writehasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
1550 # system('/usr/local/bin/ipsecctrl', 'R');
1553 $errormessage = $Lang :: tr
{ 'invalid key' };
1557 ### Display root certificate
1559 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
1560 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
1562 & Header
:: showhttpheaders
();
1563 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1564 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1565 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
1566 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'root certificate'}:" );
1567 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1569 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'host certificate'}:" );
1570 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1572 $output = & Header
:: cleanhtml
( $output , "y" );
1573 print "<pre> $output </pre> \n " ;
1574 & Header
:: closebox
();
1575 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1576 & Header
:: closebigbox
();
1577 & Header
:: closepage
();
1581 ### Download root certificate
1583 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
1584 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1585 print "Content-Type: application/octet-stream \r\n " ;
1586 print "Content-Disposition: filename=cacert.pem \r\n\r\n " ;
1587 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/ca/cacert.pem` ;
1592 ### Download host certificate
1594 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
1595 if ( - f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
1596 print "Content-Type: application/octet-stream \r\n " ;
1597 print "Content-Disposition: filename=servercert.pem \r\n\r\n " ;
1598 print `/usr/bin/openssl x509 -in ${General::swroot}/ovpn/certs/servercert.pem` ;
1603 ### Download tls-auth key
1605 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download tls-auth key' }) {
1606 if ( - f
"${General::swroot}/ovpn/certs/ta.key" ) {
1607 print "Content-Type: application/octet-stream \r\n " ;
1608 print "Content-Disposition: filename=ta.key \r\n\r\n " ;
1609 print `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
1614 ### Form for generating a root certificate
1616 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
1617 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1619 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1620 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
1621 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
1622 $cgiparams { 'ACTION' } = '' ;
1623 goto ROOTCERT_ERROR
;
1626 if (( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) && - e
"${General::swroot}/red/active" ) {
1627 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
1628 my $ipaddr = < IPADDR
>;
1631 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
1632 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
1633 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
1636 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
1638 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1639 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1640 goto ROOTCERT_ERROR
;
1643 # Move uploaded certificate request to a temporary file
1644 ( my $fh , my $filename ) = tempfile
( );
1645 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1647 goto ROOTCERT_ERROR
;
1650 # Create a temporary dirctory
1651 my $tempdir = tempdir
( CLEANUP
=> 1 );
1653 # Extract the CA certificate from the file
1654 my $pid = open ( OPENSSL
, "|-" );
1655 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1656 if ( $pid ) { # parent
1657 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1658 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1662 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1664 goto ROOTCERT_ERROR
;
1667 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-cacerts' , '-nokeys' ,
1669 '-out' , " $tempdir /cacert.pem" )) {
1670 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1672 goto ROOTCERT_ERROR
;
1676 # Extract the Host certificate from the file
1677 $pid = open ( OPENSSL
, "|-" );
1678 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1679 if ( $pid ) { # parent
1680 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1681 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1685 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1687 goto ROOTCERT_ERROR
;
1690 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-clcerts' , '-nokeys' ,
1692 '-out' , " $tempdir /hostcert.pem" )) {
1693 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1695 goto ROOTCERT_ERROR
;
1699 # Extract the Host key from the file
1700 $pid = open ( OPENSSL
, "|-" );
1701 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1702 if ( $pid ) { # parent
1703 if ( $cgiparams { 'P12_PASS' } ne '' ) {
1704 print OPENSSL
" $cgiparams {'P12_PASS'} \n " ;
1708 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1710 goto ROOTCERT_ERROR
;
1713 unless ( exec ( '/usr/bin/openssl' , 'pkcs12' , '-nocerts' ,
1716 '-out' , " $tempdir /serverkey.pem" )) {
1717 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1719 goto ROOTCERT_ERROR
;
1723 move
( " $tempdir /cacert.pem" , "${General::swroot}/ovpn/ca/cacert.pem" );
1725 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1727 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1728 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1729 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1730 goto ROOTCERT_ERROR
;
1733 move
( " $tempdir /hostcert.pem" , "${General::swroot}/ovpn/certs/servercert.pem" );
1735 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1737 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1738 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1739 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1740 goto ROOTCERT_ERROR
;
1743 move
( " $tempdir /serverkey.pem" , "${General::swroot}/ovpn/certs/serverkey.pem" );
1745 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1747 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1748 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1749 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1750 goto ROOTCERT_ERROR
;
1753 goto ROOTCERT_SUCCESS
;
1755 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
1757 # Validate input since the form was submitted
1758 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
1759 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
1760 goto ROOTCERT_ERROR
;
1762 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
1763 $errormessage = $Lang :: tr
{ 'organization too long' };
1764 goto ROOTCERT_ERROR
;
1766 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1767 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1768 goto ROOTCERT_ERROR
;
1770 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
1771 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
1772 goto ROOTCERT_ERROR
;
1774 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
1775 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
1776 goto ROOTCERT_ERROR
;
1778 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
1779 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1780 goto ROOTCERT_ERROR
;
1782 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
1783 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1784 goto ROOTCERT_ERROR
;
1786 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1787 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1788 goto ROOTCERT_ERROR
;
1790 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1791 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1792 goto ROOTCERT_ERROR
;
1794 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1795 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1796 goto ROOTCERT_ERROR
;
1798 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1799 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1800 goto ROOTCERT_ERROR
;
1803 # Copy the cgisettings to vpnsettings and save the configfile
1804 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
1805 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
1806 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
1807 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
1808 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
1809 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
1810 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
1811 & General
:: writehash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
1813 # Replace empty strings with a .
1814 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
1815 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
1816 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
1819 #system ('/bin/touch', "${General::swroot}/ovpn/gencanow");
1821 # Create the CA certificate
1822 my $pid = open ( OPENSSL
, "|-" );
1823 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1824 if ( $pid ) { # parent
1825 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1826 print OPENSSL
" $state \n " ;
1827 print OPENSSL
" $city \n " ;
1828 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1829 print OPENSSL
" $ou \n " ;
1830 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
1831 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1834 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1835 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1836 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1837 goto ROOTCERT_ERROR
;
1840 unless ( exec ( '/usr/bin/openssl' , 'req' , '-x509' , '-nodes' ,
1841 '-days' , '999999' , '-newkey' , 'rsa:4096' , '-sha512' ,
1842 '-keyout' , "${General::swroot}/ovpn/ca/cakey.pem" ,
1843 '-out' , "${General::swroot}/ovpn/ca/cacert.pem" ,
1844 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1845 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1846 goto ROOTCERT_ERROR
;
1850 # Create the Host certificate request
1851 $pid = open ( OPENSSL
, "|-" );
1852 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto ROOTCERT_ERROR
;};
1853 if ( $pid ) { # parent
1854 print OPENSSL
" $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1855 print OPENSSL
" $state \n " ;
1856 print OPENSSL
" $city \n " ;
1857 print OPENSSL
" $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1858 print OPENSSL
" $ou \n " ;
1859 print OPENSSL
" $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1860 print OPENSSL
" $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1861 print OPENSSL
". \n " ;
1862 print OPENSSL
". \n " ;
1865 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1866 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1867 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1868 goto ROOTCERT_ERROR
;
1871 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' ,
1872 '-newkey' , 'rsa:2048' ,
1873 '-keyout' , "${General::swroot}/ovpn/certs/serverkey.pem" ,
1874 '-out' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1875 '-extensions' , 'server' ,
1876 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
1877 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
1878 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1879 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1880 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1881 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1882 goto ROOTCERT_ERROR
;
1886 # Sign the host certificate request
1887 system ( '/usr/bin/openssl' , 'ca' , '-days' , '999999' ,
1888 '-batch' , '-notext' ,
1889 '-in' , "${General::swroot}/ovpn/certs/serverreq.pem" ,
1890 '-out' , "${General::swroot}/ovpn/certs/servercert.pem" ,
1891 '-extensions' , 'server' ,
1892 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1894 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1895 unlink ( "${General::swroot}/ovpn/ca/cakey.pem" );
1896 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1897 unlink ( "${General::swroot}/ovpn/serverkey.pem" );
1898 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1899 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1900 & newcleanssldatabase
();
1901 goto ROOTCERT_ERROR
;
1903 unlink ( "${General::swroot}/ovpn/certs/serverreq.pem" );
1904 & deletebackupcert
();
1907 # Create an empty CRL
1908 system ( '/usr/bin/openssl' , 'ca' , '-gencrl' ,
1909 '-out' , "${General::swroot}/ovpn/crls/cacrl.pem" ,
1910 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
1912 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1913 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1914 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1915 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1916 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1917 & cleanssldatabase
();
1918 goto ROOTCERT_ERROR
;
1920 # &cleanssldatabase();
1922 # Create Diffie Hellmann Parameter
1923 system ( '/usr/bin/openssl' , 'dhparam' , '-out' , "${General::swroot}/ovpn/ca/dh1024.pem" , " $cgiparams {'DHLENGHT'}" );
1925 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1926 unlink ( "${General::swroot}/ovpn/certs/serverkey.pem" );
1927 unlink ( "${General::swroot}/ovpn/certs/servercert.pem" );
1928 unlink ( "${General::swroot}/ovpn/ca/cacert.pem" );
1929 unlink ( "${General::swroot}/ovpn/crls/cacrl.pem" );
1930 unlink ( "${General::swroot}/ovpn/ca/dh1024.pem" );
1931 & cleanssldatabase
();
1932 goto ROOTCERT_ERROR
;
1934 # &cleanssldatabase();
1936 # Create ta.key for tls-auth
1937 system ( '/usr/sbin/openvpn' , '--genkey' , '--secret' , "${General::swroot}/ovpn/certs/ta.key" );
1939 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
1940 & cleanssldatabase
();
1941 goto ROOTCERT_ERROR
;
1943 goto ROOTCERT_SUCCESS
;
1946 if ( $cgiparams { 'ACTION' } ne '' ) {
1947 & Header
:: showhttpheaders
();
1948 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
1949 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
1950 if ( $errormessage ) {
1951 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
1952 print "<class name='base'> $errormessage " ;
1953 print " </class>" ;
1954 & Header
:: closebox
();
1956 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'generate root/host certificates'}:" );
1958 <form method='post' enctype='multipart/form-data'>
1959 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1960 <tr><td width='30%' class='base'> $Lang ::tr{'organization name'}:</td>
1961 <td width='35%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td>
1962 <td width='35%' colspan='2'> </td></tr>
1963 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}:</td>
1964 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td>
1965 <td colspan='2'> </td></tr>
1966 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt'*' /></td>
1967 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td>
1968 <td colspan='2'> </td></tr>
1969 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt'*' /></td>
1970 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td>
1971 <td colspan='2'> </td></tr>
1972 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt'*' /></td>
1973 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td>
1974 <td colspan='2'> </td></tr>
1975 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt'*' /></td>
1976 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td>
1977 <td colspan='2'> </td></tr>
1978 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1979 <td class='base'><select name='ROOTCERT_COUNTRY'>
1983 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1984 print "<option value=' $Countries ::countries{ $country }'" ;
1985 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1986 print " selected='selected'" ;
1988 print "> $country </option>" ;
1992 <tr><td class='base'> $Lang ::tr{'ovpn dh'}:</td>
1993 <td class='base'><select name='DHLENGHT'>
1994 <option value='1024' $selected {'DHLENGHT'}{'1024'}>1024 $Lang ::tr{'bit'}</option>
1995 <option value='2048' $selected {'DHLENGHT'}{'2048'}>2048 $Lang ::tr{'bit'}</option>
1996 <option value='3072' $selected {'DHLENGHT'}{'3072'}>3072 $Lang ::tr{'bit'}</option>
1997 <option value='4096' $selected {'DHLENGHT'}{'4096'}>4096 $Lang ::tr{'bit'}</option>
2003 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /></td>
2004 <td> </td><td> </td></tr>
2005 <tr><td class='base' colspan='4' align='left'>
2006 <img src='/blob.gif' valign='top' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
2007 <tr><td colspan='2'><br></td></tr>
2008 <table width='100%'>
2010 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}: </font></b> $Lang ::tr{'ovpn generating the root and host certificates'}
2011 <td class='base'> $Lang ::tr{'dh key warn'}</td>
2014 <td class='base'> $Lang ::tr{'dh key warn1'}</td>
2016 <tr><td colspan='2'><br></td></tr>
2020 <table width='100%'>
2021 <tr><td colspan='4'><hr></td></tr>
2022 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
2023 <td nowrap='nowrap'><input type='file' name='FH' size='32'></td>
2024 <td colspan='2'> </td></tr>
2025 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' ></td>
2026 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td>
2027 <td colspan='2'> </td></tr>
2029 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td>
2030 <td colspan='2'> </td></tr>
2031 <tr><td class='base' colspan='4' align='left'>
2032 <img src='/blob.gif' valign='top' al='*' > $Lang ::tr{'this field may be blank'}</td>
2037 & Header
:: closebox
();
2038 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2039 & Header
:: closebigbox
();
2040 & Header
:: closepage
();
2045 system ( "chmod 600 ${General::swroot}/ovpn/certs/serverkey.pem" );
2046 # if ($vpnsettings{'ENABLED'} eq 'on' ||
2047 # $vpnsettings{'ENABLE_BLUE'} eq 'on') {
2048 # system('/usr/local/bin/ipsecctrl', 'S');
2052 ### Enable/Disable connection
2059 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
2061 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2062 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2063 # my $n2nactive = '';
2064 my $n2nactive = `/bin/ps ax|grep $confighash { $cgiparams {'KEY'}}[1]|grep -v grep|awk \' {print \ $1 } \' ` ;
2066 if ( $confighash { $cgiparams { 'KEY' }}) {
2067 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
2068 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
2069 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2071 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2072 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
2073 & writecollectdconf
();
2077 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
2078 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2080 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2081 if ( $n2nactive ne '' ) {
2082 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
2083 & writecollectdconf
();
2087 $errormessage = $Lang :: tr
{ 'invalid key' };
2093 ### Download OpenVPN client package
2097 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'dl client arch' }) {
2098 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2099 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2101 my $clientovpn = '' ;
2103 my $tempdir = tempdir
( CLEANUP
=> 1 );
2104 my $zippath = " $tempdir /" ;
2110 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ){
2112 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-Client.zip" ;
2113 my $zippathname = " $zippath $zipname " ;
2114 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1].conf" ;
2115 my @ovsubnettemp = split ( /\./ , $confighash { $cgiparams { 'KEY' }}[ 27 ]);
2116 my $ovsubnet = " $ovsubnettemp [0]. $ovsubnettemp [1]. $ovsubnettemp [2]" ;
2118 my @remsubnet = split ( /\/ /, $confighash { $cgiparams { 'KEY' }}[ 8 ]);
2119 my $n2nfragment = '' ;
2121 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2122 flock CLIENTCONF
, 2 ;
2124 my $zip = Archive
:: Zip
-> new ();
2125 print CLIENTCONF
"# IPFire n2n Open VPN Client Config by ummeegge und m.a.d \n " ;
2126 print CLIENTCONF
"# \n " ;
2127 print CLIENTCONF
"# User Security \n " ;
2128 print CLIENTCONF
"user nobody \n " ;
2129 print CLIENTCONF
"group nobody \n " ;
2130 print CLIENTCONF
"persist-tun \n " ;
2131 print CLIENTCONF
"persist-key \n " ;
2132 print CLIENTCONF
"script-security 2 \n " ;
2133 print CLIENTCONF
"# IP/DNS for remote Server Gateway \n " ;
2134 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} \n " ;
2135 print CLIENTCONF
"float \n " ;
2136 print CLIENTCONF
"# IP adresses of the VPN Subnet \n " ;
2137 print CLIENTCONF
"ifconfig $ovsubnet .2 $ovsubnet .1 \n " ;
2138 print CLIENTCONF
"# Server Gateway Network \n " ;
2139 print CLIENTCONF
"route $remsubnet [0] $remsubnet [1] \n " ;
2140 print CLIENTCONF
"# tun Device \n " ;
2141 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \n " ;
2142 print CLIENTCONF
"# Port and Protokoll \n " ;
2143 print CLIENTCONF
"port $confighash { $cgiparams {'KEY'}}[29] \n " ;
2145 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'tcp' ) {
2146 print CLIENTCONF
"proto tcp-client \n " ;
2147 print CLIENTCONF
"# Packet size \n " ;
2148 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1400' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2149 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2152 if ( $confighash { $cgiparams { 'KEY' }}[ 28 ] eq 'udp' ) {
2153 print CLIENTCONF
"proto udp \n " ;
2154 print CLIENTCONF
"# Paketsize \n " ;
2155 if ( $confighash { $cgiparams { 'KEY' }}[ 31 ] eq '' ) { $tunmtu = '1500' } else { $tunmtu = $confighash { $cgiparams { 'KEY' }}[ 31 ]};
2156 print CLIENTCONF
"tun-mtu $tunmtu \n " ;
2157 if ( $confighash { $cgiparams { 'KEY' }}[ 24 ] ne '' ) { print CLIENTCONF
"fragment $confighash { $cgiparams {'KEY'}}[24] \n " ;}
2158 if ( $confighash { $cgiparams { 'KEY' }}[ 23 ] eq 'on' ) { print CLIENTCONF
"mssfix \n " ;}
2160 if (( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'yes' ) ||
2161 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'maybe' ) ||
2162 ( $confighash { $cgiparams { 'KEY' }}[ 38 ] eq 'no' )) {
2163 if (( $confighash { $cgiparams { 'KEY' }}[ 23 ] ne 'on' ) || ( $confighash { $cgiparams { 'KEY' }}[ 24 ] eq '' )) {
2164 if ( $tunmtu eq '1500' ) {
2165 print CLIENTCONF
"mtu-disc $confighash { $cgiparams {'KEY'}}[38] \n " ;
2169 print CLIENTCONF
"ns-cert-type server \n " ;
2170 print CLIENTCONF
"# Auth. Client \n " ;
2171 print CLIENTCONF
"tls-client \n " ;
2172 print CLIENTCONF
"# Cipher \n " ;
2173 print CLIENTCONF
"cipher $confighash { $cgiparams {'KEY'}}[40] \n " ;
2174 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2175 print CLIENTCONF
"pkcs12 ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2176 $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 " ;
2178 if ( $confighash { $cgiparams { 'KEY' }}[ 39 ] eq '' ) {
2179 print CLIENTCONF
"# HMAC algorithm \n " ;
2180 print CLIENTCONF
"auth SHA1 \n " ;
2182 print CLIENTCONF
"# HMAC algorithm \n " ;
2183 print CLIENTCONF
"auth $confighash { $cgiparams {'KEY'}}[39] \n " ;
2185 if ( $confighash { $cgiparams { 'KEY' }}[ 30 ] eq 'on' ) {
2186 print CLIENTCONF
"# Enable Compression \n " ;
2187 print CLIENTCONF
"comp-lzo \n " ;
2189 print CLIENTCONF
"# Debug Level \n " ;
2190 print CLIENTCONF
"verb 3 \n " ;
2191 print CLIENTCONF
"# Tunnel check \n " ;
2192 print CLIENTCONF
"keepalive 10 60 \n " ;
2193 print CLIENTCONF
"# Start as daemon \n " ;
2194 print CLIENTCONF
"daemon $confighash { $cgiparams {'KEY'}}[1]n2n \n " ;
2195 print CLIENTCONF
"writepid /var/run/ $confighash { $cgiparams {'KEY'}}[1]n2n.pid \n " ;
2196 print CLIENTCONF
"# Activate Management Interface and Port \n " ;
2197 if ( $confighash { $cgiparams { 'KEY' }}[ 22 ] eq '' ) { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[29] \n " }
2198 else { print CLIENTCONF
"management localhost $confighash { $cgiparams {'KEY'}}[22] \n " };
2199 print CLIENTCONF
"# remsub $confighash { $cgiparams {'KEY'}}[11] \n " ;
2204 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2205 my $status = $zip -> writeToFileNamed ( $zippathname );
2207 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2208 @fileholder = < DLFILE
>;
2209 print "Content-Type:application/x-download \n " ;
2210 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2216 my $zipname = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.zip" ;
2217 my $zippathname = " $zippath $zipname " ;
2218 $clientovpn = " $confighash { $cgiparams {'KEY'}}[1]-TO-IPFire.ovpn" ;
2224 open ( CLIENTCONF
, "> $tempdir / $clientovpn " ) or die "Unable to open tempfile: $!" ;
2225 flock CLIENTCONF
, 2 ;
2227 my $zip = Archive
:: Zip
-> new ();
2229 print CLIENTCONF
"#OpenVPN Client conf \r\n " ;
2230 print CLIENTCONF
"tls-client \r\n " ;
2231 print CLIENTCONF
"client \r\n " ;
2232 print CLIENTCONF
"nobind \r\n " ;
2233 print CLIENTCONF
"dev $vpnsettings {'DDEVICE'} \r\n " ;
2234 print CLIENTCONF
"proto $vpnsettings {'DPROTOCOL'} \r\n " ;
2236 # Check if we are using fragment, mssfix or mtu-disc and set MTU to 1500
2237 # or use configured value.
2238 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' )
2239 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2240 elsif ( $vpnsettings { MSSFIX
} eq 'on' )
2241 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2242 elsif (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2243 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2244 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' ))
2245 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu 1500 \r\n " ; }
2247 { print CLIENTCONF
" $vpnsettings {'DDEVICE'}-mtu $vpnsettings {'DMTU'} \r\n " ; }
2249 if ( $vpnsettings { 'ENABLED' } eq 'on' ){
2250 print CLIENTCONF
"remote $vpnsettings {'VPN_IP'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2251 if ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2252 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Blue interface \r\n " ;
2253 print CLIENTCONF
";remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2255 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2256 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2257 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2259 } elsif ( $vpnsettings { 'ENABLED_BLUE' } eq 'on' && (& haveBlueNet
())){
2260 print CLIENTCONF
"remote $netsettings {'BLUE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2261 if ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2262 print CLIENTCONF
"#Coment the above line and uncoment the next line, if you want to connect on the Orange interface \r\n " ;
2263 print CLIENTCONF
";remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2265 } elsif ( $vpnsettings { 'ENABLED_ORANGE' } eq 'on' && (& haveOrangeNet
())){
2266 print CLIENTCONF
"remote $netsettings {'ORANGE_ADDRESS'} $vpnsettings {'DDEST_PORT'} \r\n " ;
2269 if ( $confighash { $cgiparams { 'KEY' }}[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" ) {
2270 print CLIENTCONF
"pkcs12 $confighash { $cgiparams {'KEY'}}[1].p12 \r\n " ;
2271 $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 " ;
2273 print CLIENTCONF
"ca cacert.pem \r\n " ;
2274 print CLIENTCONF
"cert $confighash { $cgiparams {'KEY'}}[1]cert.pem \r\n " ;
2275 print CLIENTCONF
"key $confighash { $cgiparams {'KEY'}}[1].key \r\n " ;
2276 $zip -> addFile ( "${General::swroot}/ovpn/ca/cacert.pem" , "cacert.pem" ) or die "Can't add file cacert.pem \n " ;
2277 $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 " ;
2279 print CLIENTCONF
"cipher $vpnsettings {DCIPHER} \r\n " ;
2280 if ( $vpnsettings { 'DAUTH' } eq '' ) {
2281 print CLIENTCONF
"" ;
2283 print CLIENTCONF
"auth $vpnsettings {'DAUTH'} \r\n " ;
2285 if ( $vpnsettings { 'TLSAUTH' } eq 'on' ) {
2286 print CLIENTCONF
"tls-auth ta.key \r\n " ;
2287 $zip -> addFile ( "${General::swroot}/ovpn/certs/ta.key" , "ta.key" ) or die "Can't add file ta.key \n " ;
2289 if ( $vpnsettings { DCOMPLZO
} eq 'on' ) {
2290 print CLIENTCONF
"comp-lzo \r\n " ;
2292 print CLIENTCONF
"verb 3 \r\n " ;
2293 print CLIENTCONF
"ns-cert-type server \r\n " ;
2294 print CLIENTCONF
"tls-remote $vpnsettings {ROOTCERT_HOSTNAME} \r\n " ;
2295 if ( $vpnsettings { MSSFIX
} eq 'on' ) {
2296 print CLIENTCONF
"mssfix \r\n " ;
2298 if ( $vpnsettings { FRAGMENT
} ne '' && $vpnsettings { DPROTOCOL
} ne 'tcp' ) {
2299 print CLIENTCONF
"fragment $vpnsettings {'FRAGMENT'} \r\n " ;
2302 # Check if a valid operating mode has been choosen and use it.
2303 if (( $vpnsettings { 'PMTU_DISCOVERY' } eq 'yes' ) ||
2304 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'maybe' ) ||
2305 ( $vpnsettings { 'PMTU_DISCOVERY' } eq 'no' )) {
2306 if (( $vpnsettings { MSSFIX
} ne 'on' ) || ( $vpnsettings { FRAGMENT
} eq '' )) {
2307 print CLIENTCONF
"mtu-disc $vpnsettings {'PMTU_DISCOVERY'} \r\n " ;
2310 # Print client.conf.local if entries exist to client.ovpn
2311 if (!- z
$local_clientconf && $vpnsettings { 'ADDITIONAL_CONFIGS' } eq 'on' ) {
2312 open ( LCC
, " $local_clientconf " );
2313 print CLIENTCONF
" \n #--------------------------- \n " ;
2314 print CLIENTCONF
"# Start of custom directives \n " ;
2315 print CLIENTCONF
"# from client.conf.local \n " ;
2316 print CLIENTCONF
"#--------------------------- \n\n " ;
2318 print CLIENTCONF
$_ ;
2320 print CLIENTCONF
" \n #--------------------------- \n " ;
2321 print CLIENTCONF
"# End of custom directives \n " ;
2322 print CLIENTCONF
"#--------------------------- \n\n " ;
2327 $zip -> addFile ( " $tempdir / $clientovpn " , $clientovpn ) or die "Can't add file $clientovpn \n " ;
2328 my $status = $zip -> writeToFileNamed ( $zippathname );
2330 open ( DLFILE
, "< $zippathname " ) or die "Unable to open $zippathname : $!" ;
2331 @fileholder = < DLFILE
>;
2332 print "Content-Type:application/x-download \n " ;
2333 print "Content-Disposition:attachment;filename= $zipname \n\n " ;
2341 ### Remove connection
2345 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
2346 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
2347 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2349 if ( $confighash { $cgiparams { 'KEY' }}) {
2350 my $temp = `/usr/bin/openssl ca -revoke ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2356 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
2357 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
2358 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2362 if (- e
"${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) {
2363 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
2366 unlink ( "/var/run/openvpn/ $confighash { $cgiparams {'KEY'}}[1]-n2n" );
2369 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
2370 unlink ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
2372 # A.Marx CCD delete ccd files and routes
2374 if (- f
"${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" )
2376 unlink "${General::swroot}/ovpn/ccd/ $confighash { $cgiparams {'KEY'}}[2]" ;
2379 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2380 foreach my $key ( keys %ccdroutehash ) {
2381 if ( $ccdroutehash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2382 delete $ccdroutehash { $key };
2385 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
2387 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2388 foreach my $key ( keys %ccdroute2hash ) {
2389 if ( $ccdroute2hash { $key }[ 0 ] eq $confighash { $cgiparams { 'KEY' }}[ 1 ]){
2390 delete $ccdroute2hash { $key };
2393 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
2397 # Update collectd configuration and delete all RRD files of the removed connection
2398 & writecollectdconf
();
2399 system ( "/usr/local/bin/openvpnctrl -drrd $confighash { $cgiparams {'KEY'}}[1]" );
2401 delete $confighash { $cgiparams { 'KEY' }};
2402 my $temp2 = `/usr/bin/openssl ca -gencrl -out ${General::swroot}/ovpn/crls/cacrl.pem -config ${General::swroot}/ovpn/openssl/ovpn.cnf` ;
2403 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2406 $errormessage = $Lang :: tr
{ 'invalid key' };
2408 & General
:: firewall_reload
();
2411 ### Download PKCS12 file
2413 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
2414 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2416 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
2417 print "Content-Type: application/octet-stream \r\n\r\n " ;
2418 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
2422 ### Display certificate
2424 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
2425 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
2427 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
2428 & Header
:: showhttpheaders
();
2429 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2430 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2431 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate'}:" );
2432 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
2433 $output = & Header
:: cleanhtml
( $output , "y" );
2434 print "<pre> $output </pre> \n " ;
2435 & Header
:: closebox
();
2436 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2437 & Header
:: closebigbox
();
2438 & Header
:: closepage
();
2443 ### Display Diffie-Hellman key
2445 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show dh' }) {
2447 if (! - e
"${General::swroot}/ovpn/ca/dh1024.pem" ) {
2448 $errormessage = $Lang :: tr
{ 'not present' };
2450 & Header
:: showhttpheaders
();
2451 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2452 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2453 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'dh'}:" );
2454 my $output = `/usr/bin/openssl dhparam -text -in ${General::swroot}/ovpn/ca/dh1024.pem` ;
2455 $output = & Header
:: cleanhtml
( $output , "y" );
2456 print "<pre> $output </pre> \n " ;
2457 & Header
:: closebox
();
2458 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2459 & Header
:: closebigbox
();
2460 & Header
:: closepage
();
2465 ### Display tls-auth key
2467 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show tls-auth key' }) {
2469 if (! - e
"${General::swroot}/ovpn/certs/ta.key" ) {
2470 $errormessage = $Lang :: tr
{ 'not present' };
2472 & Header
:: showhttpheaders
();
2473 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2474 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2475 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ta key'}:" );
2476 my $output = `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
2477 $output = & Header
:: cleanhtml
( $output , "y" );
2478 print "<pre> $output </pre> \n " ;
2479 & Header
:: closebox
();
2480 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2481 & Header
:: closebigbox
();
2482 & Header
:: closepage
();
2487 ### Display Certificate Revoke List
2489 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show crl' }) {
2490 # &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash);
2492 if (! - e
"${General::swroot}/ovpn/crls/cacrl.pem" ) {
2493 $errormessage = $Lang :: tr
{ 'not present' };
2495 & Header
:: showhttpheaders
();
2496 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
2497 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2498 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'crl'}:" );
2499 my $output = `/usr/bin/openssl crl -text -noout -in ${General::swroot}/ovpn/crls/cacrl.pem` ;
2500 $output = & Header
:: cleanhtml
( $output , "y" );
2501 print "<pre> $output </pre> \n " ;
2502 & Header
:: closebox
();
2503 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2504 & Header
:: closebigbox
();
2505 & Header
:: closepage
();
2510 ### Advanced Server Settings
2513 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced server' }) {
2518 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
2522 # if ($cgiparams{'CLIENT2CLIENT'} eq '') {
2523 # $cgiparams{'CLIENT2CLIENT'} = 'on';
2526 if ( $cgiparams { 'MAX_CLIENTS' } eq '' ) {
2527 $cgiparams { 'MAX_CLIENTS' } = '100' ;
2529 if ( $cgiparams { 'KEEPALIVE_1' } eq '' ) {
2530 $cgiparams { 'KEEPALIVE_1' } = '10' ;
2532 if ( $cgiparams { 'KEEPALIVE_2' } eq '' ) {
2533 $cgiparams { 'KEEPALIVE_2' } = '60' ;
2535 if ( $cgiparams { 'LOG_VERB' } eq '' ) {
2536 $cgiparams { 'LOG_VERB' } = '3' ;
2538 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
2539 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
2541 if ( $cgiparams { 'DAUTH' } eq '' ) {
2542 $cgiparams { 'DAUTH' } = 'SHA1' ;
2544 if ( $cgiparams { 'TLSAUTH' } eq '' ) {
2545 $cgiparams { 'TLSAUTH' } = 'off' ;
2547 $checked { 'CLIENT2CLIENT' }{ 'off' } = '' ;
2548 $checked { 'CLIENT2CLIENT' }{ 'on' } = '' ;
2549 $checked { 'CLIENT2CLIENT' }{ $cgiparams { 'CLIENT2CLIENT' }} = 'CHECKED' ;
2550 $checked { 'REDIRECT_GW_DEF1' }{ 'off' } = '' ;
2551 $checked { 'REDIRECT_GW_DEF1' }{ 'on' } = '' ;
2552 $checked { 'REDIRECT_GW_DEF1' }{ $cgiparams { 'REDIRECT_GW_DEF1' }} = 'CHECKED' ;
2553 $checked { 'ADDITIONAL_CONFIGS' }{ 'off' } = '' ;
2554 $checked { 'ADDITIONAL_CONFIGS' }{ 'on' } = '' ;
2555 $checked { 'ADDITIONAL_CONFIGS' }{ $cgiparams { 'ADDITIONAL_CONFIGS' }} = 'CHECKED' ;
2556 $checked { 'MSSFIX' }{ 'off' } = '' ;
2557 $checked { 'MSSFIX' }{ 'on' } = '' ;
2558 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
2559 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
2560 $selected { 'LOG_VERB' }{ '0' } = '' ;
2561 $selected { 'LOG_VERB' }{ '1' } = '' ;
2562 $selected { 'LOG_VERB' }{ '2' } = '' ;
2563 $selected { 'LOG_VERB' }{ '3' } = '' ;
2564 $selected { 'LOG_VERB' }{ '4' } = '' ;
2565 $selected { 'LOG_VERB' }{ '5' } = '' ;
2566 $selected { 'LOG_VERB' }{ '6' } = '' ;
2567 $selected { 'LOG_VERB' }{ '7' } = '' ;
2568 $selected { 'LOG_VERB' }{ '8' } = '' ;
2569 $selected { 'LOG_VERB' }{ '9' } = '' ;
2570 $selected { 'LOG_VERB' }{ '10' } = '' ;
2571 $selected { 'LOG_VERB' }{ '11' } = '' ;
2572 $selected { 'LOG_VERB' }{ $cgiparams { 'LOG_VERB' }} = 'SELECTED' ;
2573 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
2574 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
2575 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
2576 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
2577 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
2578 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
2579 $checked { 'TLSAUTH' }{ 'off' } = '' ;
2580 $checked { 'TLSAUTH' }{ 'on' } = '' ;
2581 $checked { 'TLSAUTH' }{ $cgiparams { 'TLSAUTH' }} = 'CHECKED' ;
2583 & Header
:: showhttpheaders
();
2584 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
2585 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
2586 if ( $errormessage ) {
2587 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2588 print "<class name='base'> $errormessage \n " ;
2589 print " </class> \n " ;
2590 & Header
:: closebox
();
2592 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'advanced server' });
2594 <form method='post' enctype='multipart/form-data'>
2595 <table width='100%' border=0>
2597 <td colspan='4'><b> $Lang ::tr{'dhcp-options'}</b></td>
2600 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2603 <td class='base'>Domain</td>
2604 <td><input type='TEXT' name='DHCP_DOMAIN' value=' $cgiparams {'DHCP_DOMAIN'}' size='30' /></td>
2607 <td class='base'>DNS</td>
2608 <td><input type='TEXT' name='DHCP_DNS' value=' $cgiparams {'DHCP_DNS'}' size='30' /></td>
2611 <td class='base'>WINS</td>
2612 <td><input type='TEXT' name='DHCP_WINS' value=' $cgiparams {'DHCP_WINS'}' size='30' /></td>
2615 <td colspan='4'><b> $Lang ::tr{'ovpn routes push options'}</b></td>
2618 <td class='base'> $Lang ::tr{'ovpn routes push'}</td>
2620 <textarea name='ROUTES_PUSH' cols='26' rows='6' wrap='off'>
2624 if ( $cgiparams { 'ROUTES_PUSH' } ne '' )
2626 print $cgiparams { 'ROUTES_PUSH' };
2635 <table width='100%'>
2637 <td class'base'><b> $Lang ::tr{'misc-options'}</b></td>
2641 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2645 <td class='base'>Client-To-Client</td>
2646 <td><input type='checkbox' name='CLIENT2CLIENT' $checked {'CLIENT2CLIENT'}{'on'} /></td>
2650 <td class='base'>Redirect-Gateway def1</td>
2651 <td><input type='checkbox' name='REDIRECT_GW_DEF1' $checked {'REDIRECT_GW_DEF1'}{'on'} /></td>
2655 <td class='base'> $Lang ::tr{'ovpn add conf'}</td>
2656 <td><input type='checkbox' name='ADDITIONAL_CONFIGS' $checked {'ADDITIONAL_CONFIGS'}{'on'} /></td>
2657 <td> $Lang ::tr{'openvpn default'}: off</td>
2661 <td class='base'>mssfix</td>
2662 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
2663 <td> $Lang ::tr{'openvpn default'}: off</td>
2667 <td class='base'>fragment <br></td>
2668 <td><input type='TEXT' name='FRAGMENT' value=' $cgiparams {'FRAGMENT'}' size='10' /></td>
2673 <td class='base'>Max-Clients</td>
2674 <td><input type='text' name='MAX_CLIENTS' value=' $cgiparams {'MAX_CLIENTS'}' size='10' /></td>
2677 <td class='base'>Keepalive <br />
2678 (ping/ping-restart)</td>
2679 <td><input type='TEXT' name='KEEPALIVE_1' value=' $cgiparams {'KEEPALIVE_1'}' size='10' /></td>
2680 <td><input type='TEXT' name='KEEPALIVE_2' value=' $cgiparams {'KEEPALIVE_2'}' size='10' /></td>
2684 <td class='base'> $Lang ::tr{'ovpn mtu-disc'}</td>
2685 <td><input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}</td>
2686 <td><input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}</td>
2687 <td><input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}</td>
2688 <td><input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}</td>
2693 <table width='100%'>
2695 <td class'base'><b> $Lang ::tr{'log-options'}</b></td>
2698 <td width='20%'></td> <td width='30%'> </td><td width='25%'> </td><td width='25%'></td>
2701 <tr><td class='base'>VERB</td>
2702 <td><select name='LOG_VERB'>
2703 <option value='0' $selected {'LOG_VERB'}{'0'}>0</option>
2704 <option value='1' $selected {'LOG_VERB'}{'1'}>1</option>
2705 <option value='2' $selected {'LOG_VERB'}{'2'}>2</option>
2706 <option value='3' $selected {'LOG_VERB'}{'3'}>3</option>
2707 <option value='4' $selected {'LOG_VERB'}{'4'}>4</option>
2708 <option value='5' $selected {'LOG_VERB'}{'5'}>5</option>
2709 <option value='6' $selected {'LOG_VERB'}{'6'}>6</option>
2710 <option value='7' $selected {'LOG_VERB'}{'7'}>7</option>
2711 <option value='8' $selected {'LOG_VERB'}{'8'}>8</option>
2712 <option value='9' $selected {'LOG_VERB'}{'9'}>9</option>
2713 <option value='10' $selected {'LOG_VERB'}{'10'}>10</option>
2714 <option value='11' $selected {'LOG_VERB'}{'11'}>11</option>
2719 <table width='100%'>
2721 <td class'base'><b> $Lang ::tr{'ovpn crypt options'}</b></td>
2724 <td width='20%'></td> <td width='30%'> </td><td width='25%'> </td><td width='25%'></td>
2726 <tr><td class='base'> $Lang ::tr{'ovpn ha'}</td>
2727 <td><select name='DAUTH'>
2728 <option value='whirlpool' $selected {'DAUTH'}{'whirlpool'}>Whirlpool (512 $Lang ::tr{'bit'})</option>
2729 <option value='SHA512' $selected {'DAUTH'}{'SHA512'}>SHA2 (512 $Lang ::tr{'bit'})</option>
2730 <option value='SHA384' $selected {'DAUTH'}{'SHA384'}>SHA2 (384 $Lang ::tr{'bit'})</option>
2731 <option value='SHA256' $selected {'DAUTH'}{'SHA256'}>SHA2 (256 $Lang ::tr{'bit'})</option>
2732 <option value='SHA1' $selected {'DAUTH'}{'SHA1'}>SHA1 (160 $Lang ::tr{'bit'})</option>
2735 <td> $Lang ::tr{'openvpn default'}: <span class="base">SHA1 (160 $Lang ::tr{'bit'})</span></td>
2739 <table width='100%'>
2741 <td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
2745 <td class='base'>HMAC tls-auth</td>
2746 <td><input type='checkbox' name='TLSAUTH' $checked {'TLSAUTH'}{'on'} /></td>
2751 if ( - e
"/var/run/openvpn.pid" ){
2752 print " <br><b><font color='#990000'> $Lang ::tr{'attention'}:</b></font><br>
2753 $Lang ::tr{'server restart'}<br><br>
2756 <table width='100%'>
2759 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' disabled='disabled' /></td>
2760 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2772 <table width='100%'>
2775 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save-adv-options'}' /></td>
2776 <td allign='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel-adv-options'}' /></td>
2784 & Header
:: closebox
();
2785 # print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'>$Lang::tr{'back'}</a></div>";
2786 & Header
:: closebigbox
();
2787 & Header
:: closepage
();
2791 # A.Marx CCD Add,delete or edit CCD net
2793 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd net' } ||
2794 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' } ||
2795 $cgiparams { 'ACTION' } eq "kill" ||
2796 $cgiparams { 'ACTION' } eq "edit" ||
2797 $cgiparams { 'ACTION' } eq 'editsave' ){
2798 & Header
:: showhttpheaders
();
2799 & Header
:: openpage
( $Lang :: tr
{ 'ccd net' }, 1 , '' );
2800 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2802 if ( $cgiparams { 'ACTION' } eq "kill" ){
2803 & delccdnet
( $cgiparams { 'net' });
2806 if ( $cgiparams { 'ACTION' } eq 'editsave' ){
2807 my ( $a , $b ) = split ( /\|/ , $cgiparams { 'ccdname' });
2808 if ( $a ne $b ){ & modccdnet
( $a , $b );}
2809 $cgiparams { 'ccdname' }= '' ;
2810 $cgiparams { 'ccdsubnet' }= '' ;
2813 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ccd add' }) {
2814 & addccdnet
( $cgiparams { 'ccdname' }, $cgiparams { 'ccdsubnet' });
2816 if ( $errormessage ) {
2817 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
2818 print "<class name='base'> $errormessage " ;
2819 print " </class>" ;
2820 & Header
:: closebox
();
2822 if ( $cgiparams { 'ACTION' } eq "edit" ){
2824 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd modify' });
2827 <table width='100%' border='0'>
2828 <tr><form method='post'>
2829 <td width='10%' nowrap='nowrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2830 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' readonly='readonly' /></td></tr>
2831 <tr><td colspan='4' align='right'><hr><input type='submit' value=' $Lang ::tr{'save'}' /><input type='hidden' name='ACTION' value='editsave'/>
2832 <input type='hidden' name='ccdname' value=' $cgiparams {'ccdname'}'/><input type='submit' value=' $Lang ::tr{'cancel'}' />
2837 & Header
:: closebox
();
2839 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2841 <table width='100%' border='0' cellpadding='0' cellspacing='1'>
2843 <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>
2848 if (! - e
"/var/run/openvpn.pid" ){
2849 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd add' });
2851 <table width='100%' border='0'>
2852 <tr><form method='post'>
2853 <td colspan='4'> $Lang ::tr{'ccd hint'}<br><br></td></tr>
2855 <td width='10%' nowrap='nwrap'> $Lang ::tr{'ccd name'}:</td><td><input type='TEXT' name='ccdname' value=' $cgiparams {'ccdname'}' /></td>
2856 <td width='8%'> $Lang ::tr{'ccd subnet'}:</td><td><input type='TEXT' name='ccdsubnet' value=' $cgiparams {'ccdsubnet'}' /></td></tr>
2857 <tr><td colspan=4><hr /></td></tr><tr>
2858 <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>
2862 & Header
:: closebox
();
2864 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ccd net' } );
2865 if ( - e
"/var/run/openvpn.pid" ){
2866 print "<b> $Lang ::tr{'attention'}:</b><br>" ;
2867 print " $Lang ::tr{'ccd noaddnet'}<br><hr>" ;
2871 <table width='100%' cellpadding='0' cellspacing='1'>
2873 <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>
2878 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
2881 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
2882 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
2884 my $ccdhosts = & hostsinnet
( $ccdconf [ 0 ]);
2885 if ( $count % 2 ){ print " <tr bgcolor=' $color {'color22'}'>" ;}
2886 else { print " <tr bgcolor=' $color {'color20'}'>" ;}
2887 print "<td> $ccdconf [0]</td><td align='center'> $ccdconf [1]</td><td align='center'> $ccdhosts /" .(& ccdmaxclients
( $ccdconf [ 1 ])+ 1 ). "</td><td>" ;
2889 <form method='post' />
2890 <input type='image' src='/images/edit.gif' align='middle' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
2891 <input type='hidden' name='ACTION' value='edit'/>
2892 <input type='hidden' name='ccdname' value=' $ccdconf [0]' />
2893 <input type='hidden' name='ccdsubnet' value=' $ccdconf [1]' />
2895 <form method='post' />
2896 <td><input type='hidden' name='ACTION' value='kill'/>
2897 <input type='hidden' name='number' value=' $count ' />
2898 <input type='hidden' name='net' value=' $ccdconf [0]' />
2899 <input type='image' src='/images/delete.gif' align='middle' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' /></form></td></tr>
2903 print "</table></form>" ;
2904 & Header
:: closebox
();
2905 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
2906 & Header
:: closebigbox
();
2907 & Header
:: closepage
();
2913 ### Openvpn Connections Statistics
2915 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'ovpn con stat' }) {
2916 & Header
:: showhttpheaders
();
2917 & Header
:: openpage
( $Lang :: tr
{ 'ovpn con stat' }, 1 , '' );
2918 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
2919 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'ovpn con stat' });
2922 # <td><b>$Lang::tr{'protocol'}</b></td>
2923 # protocol temp removed
2925 <table width='100%' cellpadding='2' cellspacing='0' class='tbl'>
2927 <th><b> $Lang ::tr{'common name'}</b></th>
2928 <th><b> $Lang ::tr{'real address'}</b></th>
2929 <th><b> $Lang ::tr{'virtual address'}</b></th>
2930 <th><b> $Lang ::tr{'loged in at'}</b></th>
2931 <th><b> $Lang ::tr{'bytes sent'}</b></th>
2932 <th><b> $Lang ::tr{'bytes received'}</b></th>
2933 <th><b> $Lang ::tr{'last activity'}</b></th>
2937 my $filename = "/var/run/ovpnserver.log" ;
2938 open ( FILE
, $filename ) or die 'Unable to open config file.' ;
2939 my @current = < FILE
>;
2948 my %userlookup = ();
2949 foreach my $line ( @current )
2952 if ( $line =~ /^Updated,(.+)/ ){
2953 @match = split ( /^Updated,(.+)/ , $line );
2954 $status = $match [ 1 ];
2957 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
2958 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
2959 if ( $match [ 1 ] ne "Common Name" ) {
2961 $userlookup { $match [ 2 ]} = $uid ;
2962 $users [ $uid ]{ 'CommonName' } = $match [ 1 ];
2963 $users [ $uid ]{ 'RealAddress' } = $match [ 2 ];
2964 $users [ $uid ]{ 'BytesReceived' } = & sizeformat
( $match [ 3 ]);
2965 $users [ $uid ]{ 'BytesSent' } = & sizeformat
( $match [ 4 ]);
2966 $users [ $uid ]{ 'Since' } = $match [ 5 ];
2967 $users [ $uid ]{ 'Proto' } = $proto ;
2971 if ( $line =~ /^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ ) {
2972 @match = split ( m/^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ , $line );
2973 if ( $match [ 1 ] ne "Virtual Address" ) {
2974 $address = $match [ 3 ];
2975 #find the uid in the lookup table
2976 $uid = $userlookup { $address };
2977 $users [ $uid ]{ 'VirtualAddress' } = $match [ 1 ];
2978 $users [ $uid ]{ 'LastRef' } = $match [ 4 ];
2984 for ( my $idx = 1 ; $idx <= $user2 ; $idx ++){
2987 $col = "bgcolor=' $color {'color22'}'" ;
2990 $col = "bgcolor=' $color {'color20'}'" ;
2992 print "<td align='left' $col > $users [ $idx -1]{'CommonName'}</td>" ;
2993 print "<td align='left' $col > $users [ $idx -1]{'RealAddress'}</td>" ;
2994 print "<td align='left' $col > $users [ $idx -1]{'VirtualAddress'}</td>" ;
2995 print "<td align='left' $col > $users [ $idx -1]{'Since'}</td>" ;
2996 print "<td align='left' $col > $users [ $idx -1]{'BytesSent'}</td>" ;
2997 print "<td align='left' $col > $users [ $idx -1]{'BytesReceived'}</td>" ;
2998 print "<td align='left' $col > $users [ $idx -1]{'LastRef'}</td>" ;
3004 <table width='100%' border='0' cellpadding='2' cellspacing='0'>
3009 <tr><td align='center' > $Lang ::tr{'the statistics were last updated at'} <b> $status </b></td></tr>
3013 & Header
:: closebox
();
3014 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3015 & Header
:: closebigbox
();
3016 & Header
:: closepage
();
3020 ### Download Certificate
3022 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
3023 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3025 if ( - f
"${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
3026 print "Content-Disposition: filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \r\n " ;
3027 print "Content-Type: application/octet-stream \r\n\r\n " ;
3028 print `/bin/cat ${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
3033 ### Enable/Disable connection
3036 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
3038 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3039 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3041 if ( $confighash { $cgiparams { 'KEY' }}) {
3042 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
3043 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
3044 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3045 #&writeserverconf();
3046 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3047 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3048 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
3051 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
3052 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3053 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3054 # system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'});
3056 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3057 #&writeserverconf();
3060 $errormessage = $Lang :: tr
{ 'invalid key' };
3064 ### Restart connection
3066 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
3067 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3068 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3070 if ( $confighash { $cgiparams { 'KEY' }}) {
3071 # if ($vpnsettings{'ENABLED'} eq 'on' ||
3072 # $vpnsettings{'ENABLED_BLUE'} eq 'on') {
3073 # system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'});
3076 $errormessage = $Lang :: tr
{ 'invalid key' };
3083 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
3084 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3085 & Header
:: showhttpheaders
();
3086 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
3087 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , '' );
3088 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection type' });
3090 if ( - s
"${General::swroot}/ovpn/settings" ) {
3093 <b> $Lang ::tr{'connection type'}:</b><br />
3094 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
3095 <tr><td><input type='radio' name='TYPE' value='host' checked /></td>
3096 <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
3097 <tr><td><input type='radio' name='TYPE' value='net' /></td>
3098 <td class='base'> $Lang ::tr{'net to net vpn'}</td></tr>
3099 <tr><td><input type='radio' name='TYPE' value='net2net' /></td>
3100 <td class='base'> $Lang ::tr{'net to net vpn'} (Upload Client Package)</td></tr>
3101 <tr><td> </td><td class='base'><input type='file' name='FH' size='30'></td></tr>
3102 <tr><td> </td><td>Import Connection Name <img src='/blob.gif' /></td></tr>
3103 <tr><td> </td><td class='base'><input type='text' name='n2nname' size='30'> $Lang ::tr{'openvpn default'}: Client Packagename</td></tr>
3104 <tr><td colspan='3'><hr /></td></tr>
3105 <tr><td align='right' colspan='3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
3106 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
3114 <b> $Lang ::tr{'connection type'}:</b><br />
3115 <table border='0' width='100%'><form method='post' ENCTYPE="multipart/form-data">
3116 <tr><td><input type='radio' name='TYPE' value='host' checked /></td> <td class='base'> $Lang ::tr{'host to net vpn'}</td></tr>
3117 <tr><td align='right' colspan'3'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td></tr>
3124 & Header
:: closebox
();
3125 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3126 & Header
:: closebigbox
();
3127 & Header
:: closepage
();
3134 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2net' )){
3138 my $uplconffilename = '' ;
3139 my $uplconffilename2 = '' ;
3140 my $uplp12name = '' ;
3141 my $uplp12name2 = '' ;
3148 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3150 # Check if a file is uploaded
3152 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3153 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3157 # Move uploaded IPfire n2n package to temporary file
3159 ( my $fh , my $filename ) = tempfile
( );
3160 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3165 my $zip = Archive
:: Zip
-> new ();
3166 my $zipName = $filename ;
3167 my $status = $zip -> read ( $zipName );
3168 if ( $status != AZ_OK
) {
3169 $errormessage = "Read of $zipName failed \n " ;
3173 my $tempdir = tempdir
( CLEANUP
=> 1 );
3174 my @files = $zip -> memberNames ();
3176 $zip -> extractMemberWithoutPaths ( $_ , " $tempdir / $_ " );
3178 my $countfiles = @files ;
3180 # Check if we have not more then 2 files
3182 if ( $countfiles == 2 ){
3184 if ( $_ =~ /.conf$/ ){
3185 $uplconffilename = $_ ;
3187 if ( $_ =~ /.p12$/ ){
3191 if (( $uplconffilename eq '' ) || ( $uplp12name eq '' )){
3192 $errormessage = "Either no *.conf or no *.p12 file found \n " ;
3196 open ( FILE
, " $tempdir / $uplconffilename " ) or die 'Unable to open*.conf file' ;
3197 @firen2nconf = < FILE
>;
3199 chomp ( @firen2nconf );
3203 $errormessage = "Filecount does not match only 2 files are allowed \n " ;
3211 if ( $cgiparams { 'n2nname' } ne '' ){
3213 $uplconffilename2 = " $cgiparams {'n2nname'}.conf" ;
3214 $uplp12name2 = " $cgiparams {'n2nname'}.p12" ;
3215 $n2nname [ 0 ] = $cgiparams { 'n2nname' };
3216 my @n2nname2 = split ( /\./ , $uplconffilename );
3217 $n2nname2 [ 0 ] =~ s/\n|\r//g ;
3218 my $input1 = "${General::swroot}/ovpn/certs/ $uplp12name " ;
3219 my $output1 = "${General::swroot}/ovpn/certs/ $uplp12name2 " ;
3220 my $input2 = " $n2nname2 [0]n2n" ;
3221 my $output2 = " $n2nname [0]n2n" ;
3222 my $filename = " $tempdir / $uplconffilename " ;
3223 open ( FILE
, "< $filename " ) or die 'Unable to open config file.' ;
3224 my @current = < FILE
>;
3226 foreach ( @current ) { s/$input1/$output1/g ;}
3227 foreach ( @current ) { s/$input2/$output2/g ;}
3228 open ( OUT
, "> $filename " ) || die 'Unable to open config file.' ;
3233 $uplconffilename2 = $uplconffilename ;
3234 $uplp12name2 = $uplp12name ;
3235 @n2nname = split ( /\./ , $uplconffilename );
3236 $n2nname [ 0 ] =~ s/\n|\r//g ;
3238 unless (- d
"${General::swroot}/ovpn/n2nconf/" ){ mkdir "${General::swroot}/ovpn/n2nconf" , 0755 or die "Unable to create dir $!" ;}
3239 unless (- d
"${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ){ mkdir "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" , 0770 or die "Unable to create dir $!" ;}
3241 move
( " $tempdir / $uplconffilename " , "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $uplconffilename2 " );
3244 $errormessage = "*.conf move failed: $!" ;
3249 move
( " $tempdir / $uplp12name " , "${General::swroot}/ovpn/certs/ $uplp12name2 " );
3250 chmod 0600 , "${General::swroot}/ovpn/certs/ $uplp12name " ;
3253 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
3262 my @n2nmtudisc = split ( / / , ( grep { /^mtu-disc/ } @firen2nconf )[ 0 ]);
3263 my @n2nproto2 = split ( / / , ( grep { /^proto/ } @firen2nconf )[ 0 ]);
3264 my @n2nproto = split ( /-/ , $n2nproto2 [ 1 ]);
3265 my @n2nport = split ( / / , ( grep { /^port/ } @firen2nconf )[ 0 ]);
3266 my @n2ntunmtu = split ( / / , ( grep { /^tun-mtu/ } @firen2nconf )[ 0 ]);
3267 my @n2ncomplzo = grep { /^comp-lzo/ } @firen2nconf ;
3268 if ( $n2ncomplzo [ 0 ] =~ /comp-lzo/ ){ $complzoactive = "on" ;} else { $complzoactive = "off" ;}
3269 my @n2nmssfix = grep { /^mssfix/ } @firen2nconf ;
3270 if ( $n2nmssfix [ 0 ] =~ /mssfix/ ){ $mssfixactive = "on" ;} else { $mssfixactive = "off" ;}
3271 #my @n2nmssfix = split(/ /, (grep { /^mssfix/ } @firen2nconf)[0]);
3272 my @n2nfragment = split ( / / , ( grep { /^fragment/ } @firen2nconf )[ 0 ]);
3273 my @n2nremote = split ( / / , ( grep { /^remote/ } @firen2nconf )[ 0 ]);
3274 my @n2novpnsuball = split ( / / , ( grep { /^ifconfig/ } @firen2nconf )[ 0 ]);
3275 my @n2novpnsub = split ( /\./ , $n2novpnsuball [ 1 ]);
3276 my @n2nremsub = split ( / / , ( grep { /^route/ } @firen2nconf )[ 0 ]);
3277 my @n2nmgmt = split ( / / , ( grep { /^management/ } @firen2nconf )[ 0 ]);
3278 my @n2nlocalsub = split ( / / , ( grep { /^# remsub/ } @firen2nconf )[ 0 ]);
3279 my @n2ncipher = split ( / / , ( grep { /^cipher/ } @firen2nconf )[ 0 ]);
3280 my @n2nauth = split ( / / , ( grep { /^auth/ } @firen2nconf )[ 0 ]);;
3283 # m.a.d delete CR and LF from arrays for this chomp doesnt work
3286 $n2nremote [ 1 ] =~ s/\n|\r//g ;
3287 $n2novpnsub [ 0 ] =~ s/\n|\r//g ;
3288 $n2novpnsub [ 1 ] =~ s/\n|\r//g ;
3289 $n2novpnsub [ 2 ] =~ s/\n|\r//g ;
3290 $n2nproto [ 0 ] =~ s/\n|\r//g ;
3291 $n2nport [ 1 ] =~ s/\n|\r//g ;
3292 $n2ntunmtu [ 1 ] =~ s/\n|\r//g ;
3293 $n2nremsub [ 1 ] =~ s/\n|\r//g ;
3294 $n2nremsub [ 2 ] =~ s/\n|\r//g ;
3295 $n2nlocalsub [ 2 ] =~ s/\n|\r//g ;
3296 $n2nfragment [ 1 ] =~ s/\n|\r//g ;
3297 $n2nmgmt [ 2 ] =~ s/\n|\r//g ;
3298 $n2nmtudisc [ 1 ] =~ s/\n|\r//g ;
3299 $n2ncipher [ 1 ] =~ s/\n|\r//g ;
3300 $n2nauth [ 1 ] =~ s/\n|\r//g ;
3301 chomp ( $complzoactive );
3302 chomp ( $mssfixactive );
3309 # Check if there is no other entry with this name
3312 foreach my $dkey ( keys %confighash ) {
3313 if ( $confighash { $dkey }[ 1 ] eq $n2nname [ 0 ]) {
3314 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3315 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3316 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3317 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3323 # Check if OpenVPN Subnet is valid
3326 foreach my $dkey ( keys %confighash ) {
3327 if ( $confighash { $dkey }[ 27 ] eq " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ) {
3328 $errormessage = 'The OpenVPN Subnet is already in use' ;
3329 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3330 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3331 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3337 # Check if Dest Port is vaild
3340 foreach my $dkey ( keys %confighash ) {
3341 if ( $confighash { $dkey }[ 29 ] eq $n2nport [ 1 ] ) {
3342 $errormessage = 'The OpenVPN Port is already in use' ;
3343 unlink ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]/ $n2nname [0].conf" ) or die "Removing Configfile fail: $!" ;
3344 unlink ( "${General::swroot}/ovpn/certs/ $n2nname [0].p12" ) or die "Removing Certfile fail: $!" ;
3345 rmdir ( "${General::swroot}/ovpn/n2nconf/ $n2nname [0]" ) || die "Removing Directory fail: $!" ;
3352 $key = & General
:: findhasharraykey
( \
%confighash );
3354 foreach my $i ( 0 .. 42 ) { $confighash { $key }[ $i ] = "" ;}
3356 $confighash { $key }[ 0 ] = 'off' ;
3357 $confighash { $key }[ 1 ] = $n2nname [ 0 ];
3358 $confighash { $key }[ 2 ] = $n2nname [ 0 ];
3359 $confighash { $key }[ 3 ] = 'net' ;
3360 $confighash { $key }[ 4 ] = 'cert' ;
3361 $confighash { $key }[ 6 ] = 'client' ;
3362 $confighash { $key }[ 8 ] = $n2nlocalsub [ 2 ];
3363 $confighash { $key }[ 10 ] = $n2nremote [ 1 ];
3364 $confighash { $key }[ 11 ] = " $n2nremsub [1]/ $n2nremsub [2]" ;
3365 $confighash { $key }[ 22 ] = $n2nmgmt [ 2 ];
3366 $confighash { $key }[ 23 ] = $mssfixactive ;
3367 $confighash { $key }[ 24 ] = $n2nfragment [ 1 ];
3368 $confighash { $key }[ 25 ] = 'IPFire n2n Client' ;
3369 $confighash { $key }[ 26 ] = 'red' ;
3370 $confighash { $key }[ 27 ] = " $n2novpnsub [0]. $n2novpnsub [1]. $n2novpnsub [2].0/255.255.255.0" ;
3371 $confighash { $key }[ 28 ] = $n2nproto [ 0 ];
3372 $confighash { $key }[ 29 ] = $n2nport [ 1 ];
3373 $confighash { $key }[ 30 ] = $complzoactive ;
3374 $confighash { $key }[ 31 ] = $n2ntunmtu [ 1 ];
3375 $confighash { $key }[ 38 ] = $n2nmtudisc [ 1 ];
3376 $confighash { $key }[ 39 ] = $n2nauth [ 1 ];
3377 $confighash { $key }[ 40 ] = $n2ncipher [ 1 ];
3378 $confighash { $key }[ 41 ] = 'disabled' ;
3380 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3384 & Header
:: showhttpheaders
();
3385 & Header
:: openpage
( 'Validate imported configuration' , 1 , '' );
3386 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
3387 if ( $errormessage ) {
3388 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
3389 print "<class name='base'> $errormessage " ;
3390 print " </class>" ;
3391 & Header
:: closebox
();
3395 & Header
:: openbox
( '100%' , 'LEFT' , 'import ipfire net2net config' );
3397 if ( $errormessage eq '' ){
3399 <!-- ipfire net2net config gui -->
3400 <table width='100%'>
3401 <tr><td width='25%'> </td><td width='25%'> </td></tr>
3402 <tr><td class='boldbase'> $Lang ::tr{'name'}:</td><td><b> $n2nname [0]</b></td></tr>
3403 <tr><td> </td><td> </td></tr>
3404 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td><td><b> $confighash { $key }[6]</b></td></tr>
3405 <tr><td class='boldbase' nowrap='nowrap'>Remote Host </td><td><b> $confighash { $key }[10]</b></td></tr>
3406 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td><td><b> $confighash { $key }[8]</b></td></tr>
3407 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}:</td><td><b> $confighash { $key }[11]</b></td></tr>
3408 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td><td><b> $confighash { $key }[27]</b></td></tr>
3409 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td><td><b> $confighash { $key }[28]</b></td></tr>
3410 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'destination port'}:</td><td><b> $confighash { $key }[29]</b></td></tr>
3411 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td><td><b> $confighash { $key }[30]</b></td></tr>
3412 <tr><td class='boldbase' nowrap='nowrap'>MSSFIX:</td><td><b> $confighash { $key }[23]</b></td></tr>
3413 <tr><td class='boldbase' nowrap='nowrap'>Fragment:</td><td><b> $confighash { $key }[24]</b></td></tr>
3414 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'}</td><td><b> $confighash { $key }[31]</b></td></tr>
3415 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td><td><b> $confighash { $key }[38]</b></td></tr>
3416 <tr><td class='boldbase' nowrap='nowrap'>Management Port </td><td><b> $confighash { $key }[22]</b></td></tr>
3417 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn hmac'}:</td><td><b> $confighash { $key }[39]</b></td></tr>
3418 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td><td><b> $confighash { $key }[40]</b></td></tr>
3419 <tr><td> </td><td> </td></tr>
3423 & Header
:: closebox
();
3426 if ( $errormessage ) {
3427 print "<div align='center'><a href='/cgi-bin/ovpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
3429 print "<div align='center'><form method='post' ENCTYPE='multipart/form-data'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />" ;
3430 print "<input type='hidden' name='TYPE' value='net2netakn' />" ;
3431 print "<input type='hidden' name='KEY' value=' $key ' />" ;
3432 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
3434 & Header
:: closebigbox
();
3435 & Header
:: closepage
();
3440 ### Accept IPFire n2n Package Settings
3443 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3446 ### Discard and Rollback IPFire n2n Package Settings
3449 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'cancel' }) && ( $cgiparams { 'TYPE' } eq 'net2netakn' )){
3451 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3453 if ( $confighash { $cgiparams { 'KEY' }}) {
3455 my $conffile = glob ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]/ $confighash { $cgiparams {'KEY'}}[1].conf" );
3456 my $certfile = glob ( "${General::swroot}/ovpn/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
3457 unlink ( $certfile ) or die "Removing $certfile fail: $!" ;
3458 unlink ( $conffile ) or die "Removing $conffile fail: $!" ;
3459 rmdir ( "${General::swroot}/ovpn/n2nconf/ $confighash { $cgiparams {'KEY'}}[1]" ) || die "Kann Verzeichnis nicht loeschen: $!" ;
3460 delete $confighash { $cgiparams { 'KEY' }};
3461 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3464 $errormessage = $Lang :: tr
{ 'invalid key' };
3474 ### Adding a new connection
3476 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
3477 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
3478 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
3480 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnsettings );
3481 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
3482 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
3484 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
3485 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
3486 $errormessage = $Lang :: tr
{ 'invalid key' };
3489 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
3490 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
3491 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
3492 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
3493 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
3494 $cgiparams { 'SIDE' } = $confighash { $cgiparams { 'KEY' }}[ 6 ];
3495 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
3496 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
3497 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
3498 $cgiparams { 'OVPN_MGMT' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
3499 $cgiparams { 'MSSFIX' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
3500 $cgiparams { 'FRAGMENT' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
3501 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
3502 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
3503 $cgiparams { 'OVPN_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
3504 $cgiparams { 'PROTOCOL' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
3505 $cgiparams { 'DEST_PORT' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
3506 $cgiparams { 'COMPLZO' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
3507 $cgiparams { 'MTU' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
3508 $cgiparams { 'CHECK1' } = $confighash { $cgiparams { 'KEY' }}[ 32 ];
3509 $name = $cgiparams { 'CHECK1' } ;
3510 $cgiparams { $name } = $confighash { $cgiparams { 'KEY' }}[ 33 ];
3511 $cgiparams { 'RG' } = $confighash { $cgiparams { 'KEY' }}[ 34 ];
3512 $cgiparams { 'CCD_DNS1' } = $confighash { $cgiparams { 'KEY' }}[ 35 ];
3513 $cgiparams { 'CCD_DNS2' } = $confighash { $cgiparams { 'KEY' }}[ 36 ];
3514 $cgiparams { 'CCD_WINS' } = $confighash { $cgiparams { 'KEY' }}[ 37 ];
3515 $cgiparams { 'PMTU_DISCOVERY' } = $confighash { $cgiparams { 'KEY' }}[ 38 ];
3516 $cgiparams { 'DAUTH' } = $confighash { $cgiparams { 'KEY' }}[ 39 ];
3517 $cgiparams { 'DCIPHER' } = $confighash { $cgiparams { 'KEY' }}[ 40 ];
3518 $cgiparams { 'TLSAUTH' } = $confighash { $cgiparams { 'KEY' }}[ 41 ];
3519 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
3520 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
3522 #A.Marx CCD check iroute field and convert it to decimal
3523 if ( $cgiparams { 'TYPE' } eq 'host' ) {
3525 my %ccdroutehash =();
3529 if ( $cgiparams { 'IR' } ne '' ){
3530 @temp = split ( " \n " , $cgiparams { 'IR' });
3531 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3533 foreach my $key ( keys %ccdroutehash ) {
3534 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3536 delete $ccdroutehash { $key };
3538 $keypoint = & General
:: findhasharraykey
( \
%ccdroutehash );
3541 $ccdroutehash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3544 foreach $val ( @temp ){
3547 #check if iroute exists in ccdroute or if new iroute is part of an existing one
3548 foreach my $key ( keys %ccdroutehash ) {
3549 foreach my $oldiroute ( 1 .. $ #{$ccdroutehash{$key}}){
3550 if ( $ccdroutehash { $key }[ $oldiroute ] eq " $val " ) {
3551 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3554 my ( $ip1 , $cidr1 ) = split ( /\/ /, $val );
3555 $ip1 = & General
:: getnetworkip
( $ip1 ,& General
:: iporsubtocidr
( $cidr1 ));
3556 my ( $ip2 , $cidr2 ) = split ( /\/ /, $ccdroutehash { $key }[ $oldiroute ]);
3557 if (& General
:: IpInSubnet
( $ip1 , $ip2 , $cidr2 )){
3558 $errormessage = $errormessage . $Lang :: tr
{ 'ccd err irouteexist' };
3564 if (!& General
:: validipandmask
( $val )){
3565 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3568 ( $ip , $cidr ) = split ( /\/ /, $val );
3569 $ip =& General
:: getnetworkip
( $ip ,& General
:: iporsubtocidr
( $cidr ));
3570 $cidr =& General
:: iporsubtodec
( $cidr );
3571 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3575 #check for existing network IP's
3576 if (& General
:: IpInSubnet
( $ip , $netsettings { GREEN_NETADDRESS
}, $netsettings { GREEN_NETMASK
}) && $netsettings { GREEN_NETADDRESS
} ne '0.0.0.0' )
3578 $errormessage = $Lang :: tr
{ 'ccd err green' };
3580 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { RED_NETADDRESS
}, $netsettings { RED_NETMASK
}) && $netsettings { RED_NETADDRESS
} ne '0.0.0.0' )
3582 $errormessage = $Lang :: tr
{ 'ccd err red' };
3584 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { BLUE_NETADDRESS
}, $netsettings { BLUE_NETMASK
}) && $netsettings { BLUE_NETADDRESS
} ne '0.0.0.0' && $netsettings { BLUE_NETADDRESS
} gt '' )
3586 $errormessage = $Lang :: tr
{ 'ccd err blue' };
3588 } elsif (& General
:: IpInSubnet
( $ip , $netsettings { ORANGE_NETADDRESS
}, $netsettings { ORANGE_NETMASK
}) && $netsettings { ORANGE_NETADDRESS
} ne '0.0.0.0' && $netsettings { ORANGE_NETADDRESS
} gt '' )
3590 $errormessage = $Lang :: tr
{ 'ccd err orange' };
3594 if (& General
:: validipandmask
( $val )){
3595 $ccdroutehash { $keypoint }[ $i ] = $ip . "/" . $cidr ;
3597 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $ip / $cidr )" ;
3602 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3605 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3606 foreach my $key ( keys %ccdroutehash ) {
3607 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3608 delete $ccdroutehash { $key };
3609 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3615 #check route field and convert it to decimal
3618 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3620 foreach my $key ( keys %ccdroute2hash ) {
3621 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }) {
3623 delete $ccdroute2hash { $key };
3625 $keypoint = & General
:: findhasharraykey
( \
%ccdroute2hash );
3626 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
3630 $ccdroute2hash { $keypoint }[ 0 ]= $cgiparams { 'NAME' };
3631 if ( $cgiparams { 'IFROUTE' } eq '' ){ $cgiparams { 'IFROUTE' } = $Lang :: tr
{ 'ccd none' };}
3632 @temp = split ( /\|/ , $cgiparams { 'IFROUTE' });
3634 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%ownnet );
3635 foreach $val ( @temp ){
3638 if ( $val eq $Lang :: tr
{ 'green' })
3640 $val = $ownnet { GREEN_NETADDRESS
}. "/" . $ownnet { GREEN_NETMASK
};
3642 if ( $val eq $Lang :: tr
{ 'blue' })
3644 $val = $ownnet { BLUE_NETADDRESS
}. "/" . $ownnet { BLUE_NETMASK
};
3646 if ( $val eq $Lang :: tr
{ 'orange' })
3648 $val = $ownnet { ORANGE_NETADDRESS
}. "/" . $ownnet { ORANGE_NETMASK
};
3650 my ( $ip , $cidr ) = split ( /\/ /, $val );
3652 if ( $val ne $Lang :: tr
{ 'ccd none' })
3654 if (! & check_routes_push
( $val )){ $errormessage = $errormessage . "Route $val " . $Lang :: tr
{ 'ccd err routeovpn2' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3655 if (! & check_ccdroute
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err inuse' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3656 if (! & check_ccdconf
( $val )){ $errormessage = $errormessage . "<br>Route $val " . $Lang :: tr
{ 'ccd err routeovpn' }. " ( $val )" ; goto VPNCONF_ERROR
;}
3657 if (& General
:: validipandmask
( $val )){
3658 $val = $ip . "/" .& General
:: iporsubtodec
( $cidr );
3659 $ccdroute2hash { $keypoint }[ $i ] = $val ;
3661 $errormessage = $errormessage . "Route " . $Lang :: tr
{ 'ccd invalid' }. " ( $val )" ;
3665 $ccdroute2hash { $keypoint }[ $i ]= '' ;
3669 & General
:: writehasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
3672 if ( $cgiparams { 'CCD_DNS1' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS1' })) {
3673 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 1" ;
3677 if ( $cgiparams { 'CCD_DNS2' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_DNS2' })) {
3678 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp dns' }. " 2" ;
3682 if ( $cgiparams { 'CCD_WINS' } ne '' && ! & General
:: validip
( $cgiparams { 'CCD_WINS' })) {
3683 $errormessage = $errormessage . "<br>" . $Lang :: tr
{ 'invalid input for dhcp wins' };
3691 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
3692 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
3693 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3694 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3695 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3701 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
3702 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
3703 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3704 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3705 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3710 if ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
3711 $errormessage = $Lang :: tr
{ 'name is invalid' };
3712 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3713 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3714 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3719 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
3720 $errormessage = $Lang :: tr
{ 'name too long' };
3721 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3722 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3723 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3732 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3733 if ( $cgiparams { 'DEST_PORT' } eq $vpnsettings { 'DDEST_PORT' }) {
3734 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3735 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3736 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3740 foreach my $key ( sort keys %confighash ){
3741 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 ])){
3742 $errormessage = $Lang :: tr
{ 'openvpn destination port used' };
3743 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3744 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3748 if ( $cgiparams { 'DEST_PORT' } eq '' ) {
3749 $errormessage = $Lang :: tr
{ 'invalid port' };
3750 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3751 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3755 # Check if the input for the transfer net is valid.
3756 if (!& General
:: validipandmask
( $cgiparams { 'OVPN_SUBNET' })){
3757 $errormessage = $Lang :: tr
{ 'ccd err invalidnet' };
3758 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3759 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3763 if ( $cgiparams { 'OVPN_SUBNET' } eq $vpnsettings { 'DOVPN_SUBNET' }) {
3764 $errormessage = $Lang :: tr
{ 'openvpn subnet is used' };
3765 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3766 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3770 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3771 $errormessage = $Lang :: tr
{ 'openvpn mssfix allowed with udp' };
3772 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3773 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3777 if (( $cgiparams { 'PROTOCOL' } eq 'tcp' ) && ( $cgiparams { 'FRAGMENT' } ne '' )) {
3778 $errormessage = $Lang :: tr
{ 'openvpn fragment allowed with udp' };
3779 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3780 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3784 if ( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) {
3785 if (( $cgiparams { 'FRAGMENT' } ne '' ) || ( $cgiparams { 'MSSFIX' } eq 'on' )) {
3786 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc with mssfix or fragment' };
3787 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3788 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3793 if (( $cgiparams { 'PMTU_DISCOVERY' } ne 'off' ) && ( $cgiparams { 'MTU' } ne '1500' )) {
3794 $errormessage = $Lang :: tr
{ 'ovpn mtu-disc and mtu not 1500' };
3795 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3796 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3800 if ( & validdotmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3801 $errormessage = $Lang :: tr
{ 'openvpn prefix local subnet' };
3802 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3803 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3807 if ( & validdotmask
( $cgiparams { 'OVPN_SUBNET' })) {
3808 $errormessage = $Lang :: tr
{ 'openvpn prefix openvpn subnet' };
3809 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3810 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3814 if ( & validdotmask
( $cgiparams { 'REMOTE_SUBNET' })) {
3815 $errormessage = $Lang :: tr
{ 'openvpn prefix remote subnet' };
3816 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3817 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3821 if ( $cgiparams { 'DEST_PORT' } <= 1023 ) {
3822 $errormessage = $Lang :: tr
{ 'ovpn port in root range' };
3823 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3824 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3828 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
3829 $cgiparams { 'OVPN_MGMT' } = $cgiparams { 'DEST_PORT' };
3832 if ( $cgiparams { 'OVPN_MGMT' } <= 1023 ) {
3833 $errormessage = $Lang :: tr
{ 'ovpn mgmt in root range' };
3834 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3835 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3838 #Check if remote subnet is used elsewhere
3839 my ( $n2nip , $n2nsub )= split ( "/" , $cgiparams { 'REMOTE_SUBNET' });
3840 $warnmessage =& General
:: checksubnets
( '' , $n2nip , 'ovpn' );
3842 $warnmessage = $Lang :: tr
{ 'remote subnet' }. " ( $cgiparams {'REMOTE_SUBNET'}) <br>" . $warnmessage ;
3846 # if (($cgiparams{'TYPE'} eq 'net') && ($cgiparams{'SIDE'} !~ /^(left|right)$/)) {
3847 # $errormessage = $Lang::tr{'ipfire side is invalid'};
3848 # goto VPNCONF_ERROR;
3851 # Check if there is no other entry with this name
3852 if (! $cgiparams { 'KEY' }) {
3853 foreach my $key ( keys %confighash ) {
3854 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
3855 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
3856 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3857 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3858 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3865 # Check if a remote host/IP has been set for the client.
3866 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3867 if ( $cgiparams { 'SIDE' } ne 'server' && $cgiparams { 'REMOTE' } eq '' ) {
3868 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3870 # Check if this is a N2N connection and drop temporary config.
3871 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3872 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3877 # Check if a remote host/IP has been configured - the field can be empty on the server side.
3878 if ( $cgiparams { 'REMOTE' } ne '' ) {
3879 # Check if the given IP is valid - otherwise check if it is a valid domain.
3880 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
3881 # Check for a valid domain.
3882 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
3883 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
3885 # Check if this is a N2N connection and drop temporary config.
3886 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3887 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3895 if ( $cgiparams { 'TYPE' } ne 'host' ) {
3896 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
3897 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
3898 if ( $cgiparams { 'TYPE' } eq 'net' ) {
3899 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3900 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3902 goto VPNCONF_ERROR
;}
3904 # Check if there is no other entry without IP-address and PSK
3905 if ( $cgiparams { 'REMOTE' } eq '' ) {
3906 foreach my $key ( keys %confighash ) {
3907 if (( $cgiparams { 'KEY' } ne $key ) &&
3908 ( $confighash { $key }[ 4 ] eq 'psk' || $cgiparams { 'AUTH' } eq 'psk' ) &&
3909 $confighash { $key }[ 10 ] eq '' ) {
3910 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
3915 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
3916 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
3917 unlink ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}/ $cgiparams {'NAME'}.conf" ) or die "Removing Configfile fail: $!" ;
3918 rmdir ( "${General::swroot}/ovpn/n2nconf/ $cgiparams {'NAME'}" ) || die "Removing Directory fail: $!" ;
3922 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
3923 $errormessage = $Lang :: tr
{ 'invalid input' };
3926 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
3927 $errormessage = $Lang :: tr
{ 'invalid input' };
3932 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
3933 # if (! length($cgiparams{'PSK'}) ) {
3934 # $errormessage = $Lang::tr{'pre-shared key is too short'};
3935 # goto VPNCONF_ERROR;
3937 # if ($cgiparams{'PSK'} =~ /['",&]/) {
3938 # $errormessage = $Lang::tr{'invalid characters found in pre-shared key'};
3939 # goto VPNCONF_ERROR;
3941 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
3942 if ( $cgiparams { 'KEY' }) {
3943 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3946 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3947 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3951 # Move uploaded certificate request to a temporary file
3952 ( my $fh , my $filename ) = tempfile
( );
3953 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
3958 # Sign the certificate request and move it
3959 # Sign the host certificate request
3960 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
3961 '-batch' , '-notext' ,
3963 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
3964 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
3966 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
3968 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
3969 & newcleanssldatabase
();
3973 & deletebackupcert
();
3976 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
3977 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
3979 $temp =~ s
+/ Email
+, E
+;
3980 $temp =~ s/ ST=/ S=/ ;
3981 $cgiparams { 'CERT_NAME' } = $temp ;
3982 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
3983 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
3984 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
3985 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
3988 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
3989 if ( $cgiparams { 'KEY' }) {
3990 $errormessage = $Lang :: tr
{ 'cant change certificates' };
3993 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
3994 $errormessage = $Lang :: tr
{ 'there was no file upload' };
3997 # Move uploaded certificate to a temporary file
3998 ( my $fh , my $filename ) = tempfile
( );
3999 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
4004 # Verify the certificate has a valid CA and move it
4006 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/cacert.pem $filename ` ;
4007 if ( $test =~ /: OK/ ) {
4010 foreach my $key ( keys %cahash ) {
4011 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ovpn/ca/ $cahash { $key }[0]cert.pem $filename ` ;
4012 if ( $test =~ /: OK/ ) {
4018 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
4022 move
( $filename , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4024 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
4030 my $temp = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem` ;
4031 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
4033 $temp =~ s
+/ Email
+, E
+;
4034 $temp =~ s/ ST=/ S=/ ;
4035 $cgiparams { 'CERT_NAME' } = $temp ;
4036 $cgiparams { 'CERT_NAME' } =~ s/,//g ;
4037 $cgiparams { 'CERT_NAME' } =~ s/\'//g ;
4038 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
4039 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4040 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
4043 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
4044 if ( $cgiparams { 'KEY' }) {
4045 $errormessage = $Lang :: tr
{ 'cant change certificates' };
4048 # Validate input since the form was submitted
4049 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
4050 $errormessage = $Lang :: tr
{ 'name too long' };
4053 if ( $cgiparams { 'CERT_NAME' } eq '' || $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
4054 $errormessage = $Lang :: tr
{ 'invalid input for name' };
4057 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
4058 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
4061 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
4062 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
4065 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4066 $errormessage = $Lang :: tr
{ 'invalid input for department' };
4069 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
4070 $errormessage = $Lang :: tr
{ 'organization too long' };
4073 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
4074 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
4077 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4078 $errormessage = $Lang :: tr
{ 'invalid input for city' };
4081 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
4082 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
4085 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
4086 $errormessage = $Lang :: tr
{ 'invalid input for country' };
4089 if ( $cgiparams { 'CERT_PASS1' } ne '' && $cgiparams { 'CERT_PASS2' } ne '' ){
4090 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
4091 $errormessage = $Lang :: tr
{ 'password too short' };
4095 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
4096 $errormessage = $Lang :: tr
{ 'passwords do not match' };
4099 if ( $cgiparams { 'DAYS_VALID' } ne '' && $cgiparams { 'DAYS_VALID' } !~ /^[0-9]+$/ ) {
4100 $errormessage = $Lang :: tr
{ 'invalid input for valid till days' };
4104 # Replace empty strings with a .
4105 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
4106 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
4107 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
4109 # Create the Host certificate request client
4110 my $pid = open ( OPENSSL
, "|-" );
4111 $SIG { ALRM
} = sub { $errormessage = $Lang :: tr
{ 'broken pipe' }; goto VPNCONF_ERROR
;};
4112 if ( $pid ) { # parent
4113 print OPENSSL
" $cgiparams {'CERT_COUNTRY'} \n " ;
4114 print OPENSSL
" $state \n " ;
4115 print OPENSSL
" $city \n " ;
4116 print OPENSSL
" $cgiparams {'CERT_ORGANIZATION'} \n " ;
4117 print OPENSSL
" $ou \n " ;
4118 print OPENSSL
" $cgiparams {'CERT_NAME'} \n " ;
4119 print OPENSSL
" $cgiparams {'CERT_EMAIL'} \n " ;
4120 print OPENSSL
". \n " ;
4121 print OPENSSL
". \n " ;
4124 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4125 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4126 unlink ( "${General::swroot}ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4130 unless ( exec ( '/usr/bin/openssl' , 'req' , '-nodes' ,
4131 '-newkey' , 'rsa:2048' ,
4132 '-keyout' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
4133 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
4134 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" )) {
4135 $errormessage = " $Lang ::tr{'cant start openssl'}: $!" ;
4136 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4137 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4142 # Sign the host certificate request
4143 system ( '/usr/bin/openssl' , 'ca' , '-days' , " $cgiparams {'DAYS_VALID'}" ,
4144 '-batch' , '-notext' ,
4145 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" ,
4146 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
4147 '-config' , "${General::swroot}/ovpn/openssl/ovpn.cnf" );
4149 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4150 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4151 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4152 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4153 & newcleanssldatabase
();
4156 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}req.pem" );
4157 & deletebackupcert
();
4160 # Create the pkcs12 file
4161 system ( '/usr/bin/openssl' , 'pkcs12' , '-export' ,
4162 '-inkey' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" ,
4163 '-in' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" ,
4164 '-name' , $cgiparams { 'NAME' },
4165 '-passout' , "pass: $cgiparams {'CERT_PASS1'}" ,
4166 '-certfile' , "${General::swroot}/ovpn/ca/cacert.pem" ,
4167 '-caname' , " $vpnsettings {'ROOTCERT_ORGANIZATION'} CA" ,
4168 '-out' , "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
4170 $errormessage = " $Lang ::tr{'openssl produced an error'}: $?" ;
4171 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4172 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}cert.pem" );
4173 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}.p12" );
4176 unlink ( "${General::swroot}/ovpn/certs/ $cgiparams {'NAME'}key.pem" );
4178 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
4179 ; # Nothing, just editing
4181 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
4185 # Check if there is no other entry with this common name
4186 if ((! $cgiparams { 'KEY' }) && ( $cgiparams { 'AUTH' } ne 'psk' )) {
4187 foreach my $key ( keys %confighash ) {
4188 if ( $confighash { $key }[ 2 ] eq $cgiparams { 'CERT_NAME' }) {
4189 $errormessage = $Lang :: tr
{ 'a connection with this common name already exists' };
4196 my $key = $cgiparams { 'KEY' };
4199 $key = & General
:: findhasharraykey
( \
%confighash );
4200 foreach my $i ( 0 .. 43 ) { $confighash { $key }[ $i ] = "" ;}
4202 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
4203 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
4204 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
4205 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
4208 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
4209 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
4210 $confighash { $key }[ 4 ] = 'psk' ;
4211 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
4213 $confighash { $key }[ 4 ] = 'cert' ;
4215 if ( $cgiparams { 'TYPE' } eq 'net' ) {
4216 $confighash { $key }[ 6 ] = $cgiparams { 'SIDE' };
4217 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
4219 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
4220 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
4221 if ( $cgiparams { 'OVPN_MGMT' } eq '' ) {
4222 $confighash { $key }[ 22 ] = $confighash { $key }[ 29 ];
4224 $confighash { $key }[ 22 ] = $cgiparams { 'OVPN_MGMT' };
4226 $confighash { $key }[ 23 ] = $cgiparams { 'MSSFIX' };
4227 $confighash { $key }[ 24 ] = $cgiparams { 'FRAGMENT' };
4228 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
4229 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
4231 $confighash { $key }[ 27 ] = $cgiparams { 'OVPN_SUBNET' };
4232 $confighash { $key }[ 28 ] = $cgiparams { 'PROTOCOL' };
4233 $confighash { $key }[ 29 ] = $cgiparams { 'DEST_PORT' };
4234 $confighash { $key }[ 30 ] = $cgiparams { 'COMPLZO' };
4235 $confighash { $key }[ 31 ] = $cgiparams { 'MTU' };
4236 $confighash { $key }[ 32 ] = $cgiparams { 'CHECK1' };
4237 $name = $cgiparams { 'CHECK1' };
4238 $confighash { $key }[ 33 ] = $cgiparams { $name };
4239 $confighash { $key }[ 34 ] = $cgiparams { 'RG' };
4240 $confighash { $key }[ 35 ] = $cgiparams { 'CCD_DNS1' };
4241 $confighash { $key }[ 36 ] = $cgiparams { 'CCD_DNS2' };
4242 $confighash { $key }[ 37 ] = $cgiparams { 'CCD_WINS' };
4243 $confighash { $key }[ 38 ] = $cgiparams { 'PMTU_DISCOVERY' };
4244 $confighash { $key }[ 39 ] = $cgiparams { 'DAUTH' };
4245 $confighash { $key }[ 40 ] = $cgiparams { 'DCIPHER' };
4247 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4249 if ( $cgiparams { 'CHECK1' } ){
4251 my ( $ccdip , $ccdsub )= split "/" , $cgiparams { $name };
4252 my ( $a , $b , $c , $d ) = split ( /\./ , $ccdip );
4253 if ( - e
"${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ){
4254 unlink "${General::swroot}/ovpn/ccd/ $cgiparams {'CERT_NAME'}" ;
4256 open ( CCDRWCONF
, '>' , "${General::swroot}/ovpn/ccd/ $confighash { $key }[2]" ) or die "Unable to create clientconfigfile $!" ;
4257 print CCDRWCONF
"# OpenVPN clientconfig from ccd extension by Copymaster# \n\n " ;
4258 if ( $cgiparams { 'CHECK1' } eq 'dynamic' ){
4259 print CCDRWCONF
"#This client uses the dynamic pool \n " ;
4261 print CCDRWCONF
"#Ip address client and server \n " ;
4262 print CCDRWCONF
"ifconfig-push $ccdip " .& General
:: getlastip
( $ccdip , 1 ). " \n " ;
4264 if ( $confighash { $key }[ 34 ] eq 'on' ){
4265 print CCDRWCONF
" \n #Redirect Gateway: \n #All IP traffic is redirected through the vpn \n " ;
4266 print CCDRWCONF
"push redirect-gateway \n " ;
4268 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4269 if ( $cgiparams { 'IR' } ne '' ){
4270 print CCDRWCONF
" \n #Client routes these networks (behind Client) \n " ;
4271 foreach my $key ( keys %ccdroutehash ){
4272 if ( $ccdroutehash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4273 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}){
4274 my ( $a , $b )= split ( /\/ /, $ccdroutehash { $key }[ $i ]);
4275 print CCDRWCONF
"iroute $a $b \n " ;
4280 if ( $cgiparams { 'IFROUTE' } eq $Lang :: tr
{ 'ccd none' } ){ $cgiparams { 'IFROUTE' }= '' ;}
4281 if ( $cgiparams { 'IFROUTE' } ne '' ){
4282 print CCDRWCONF
" \n #Client gets routes to these networks (behind IPFire) \n " ;
4283 foreach my $key ( keys %ccdroute2hash ){
4284 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4285 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}){
4286 if ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'blue' }){
4288 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%blue );
4289 print CCDRWCONF
"push \" route $blue {BLUE_ADDRESS} $blue {BLUE_NETMASK} \n " ;
4290 } elsif ( $ccdroute2hash { $key }[ $i ] eq $Lang :: tr
{ 'orange' }){
4292 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%orange );
4293 print CCDRWCONF
"push \" route $orange {ORANGE_ADDRESS} $orange {ORANGE_NETMASK} \n " ;
4295 my ( $a , $b )= split ( /\/ /, $ccdroute2hash { $key }[ $i ]);
4296 print CCDRWCONF
"push \" route $a $b \"\n " ;
4302 if (( $cgiparams { 'CCD_DNS1' } eq '' ) && ( $cgiparams { 'CCD_DNS1' } ne '' )){ $cgiparams { 'CCD_DNS1' } = $cgiparams { 'CCD_DNS2' }; $cgiparams { 'CCD_DNS2' }= '' ;}
4303 if ( $cgiparams { 'CCD_DNS1' } ne '' ){
4304 print CCDRWCONF
" \n #Client gets these nameservers \n " ;
4305 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS1'} \" \n " ;
4307 if ( $cgiparams { 'CCD_DNS2' } ne '' ){
4308 print CCDRWCONF
"push \" dhcp-option DNS $cgiparams {'CCD_DNS2'} \" \n " ;
4310 if ( $cgiparams { 'CCD_WINS' } ne '' ){
4311 print CCDRWCONF
" \n #Client gets this WINS server \n " ;
4312 print CCDRWCONF
"push \" dhcp-option WINS $cgiparams {'CCD_WINS'} \" \n " ;
4321 if ( $cgiparams { 'TYPE' } eq 'net' ) {
4323 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
4324 system ( '/usr/local/bin/openvpnctrl' , '-kn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4326 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4327 my $key = $cgiparams { 'KEY' };
4329 $key = & General
:: findhasharraykey
( \
%confighash );
4330 foreach my $i ( 0 .. 31 ) { $confighash { $key }[ $i ] = "" ;}
4332 $confighash { $key }[ 0 ] = 'on' ;
4333 & General
:: writehasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4335 system ( '/usr/local/bin/openvpnctrl' , '-sn2n' , $confighash { $cgiparams { 'KEY' }}[ 1 ]);
4343 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
4344 $cgiparams { 'KEY' } = $key ;
4345 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
4349 $cgiparams { 'ENABLED' } = 'on' ;
4353 $cgiparams { 'MSSFIX' } = 'on' ;
4354 $cgiparams { 'FRAGMENT' } = '1300' ;
4355 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4356 $cgiparams { 'DAUTH' } = 'SHA1' ;
4360 $cgiparams { 'SIDE' } = 'left' ;
4361 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) {
4362 $cgiparams { 'AUTH' } = 'psk' ;
4363 } elsif ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
4364 $cgiparams { 'AUTH' } = 'certfile' ;
4366 $cgiparams { 'AUTH' } = 'certgen' ;
4368 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
4369 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
4370 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
4371 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
4372 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
4373 $cgiparams { 'DAYS_VALID' } = $vpnsettings { 'DAYS_VALID' };
4377 $checked { 'ENABLED' }{ 'off' } = '' ;
4378 $checked { 'ENABLED' }{ 'on' } = '' ;
4379 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4380 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4381 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4382 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4383 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4384 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4385 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4388 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
4389 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
4390 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = 'CHECKED' ;
4392 $selected { 'SIDE' }{ 'server' } = '' ;
4393 $selected { 'SIDE' }{ 'client' } = '' ;
4394 $selected { 'SIDE' }{ $cgiparams { 'SIDE' }} = 'SELECTED' ;
4396 $selected { 'PROTOCOL' }{ 'udp' } = '' ;
4397 $selected { 'PROTOCOL' }{ 'tcp' } = '' ;
4398 $selected { 'PROTOCOL' }{ $cgiparams { 'PROTOCOL' }} = 'SELECTED' ;
4401 $checked { 'AUTH' }{ 'psk' } = '' ;
4402 $checked { 'AUTH' }{ 'certreq' } = '' ;
4403 $checked { 'AUTH' }{ 'certgen' } = '' ;
4404 $checked { 'AUTH' }{ 'certfile' } = '' ;
4405 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = 'CHECKED' ;
4407 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = 'SELECTED' ;
4409 $checked { 'COMPLZO' }{ 'off' } = '' ;
4410 $checked { 'COMPLZO' }{ 'on' } = '' ;
4411 $checked { 'COMPLZO' }{ $cgiparams { 'COMPLZO' }} = 'CHECKED' ;
4413 $checked { 'MSSFIX' }{ 'off' } = '' ;
4414 $checked { 'MSSFIX' }{ 'on' } = '' ;
4415 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4417 if ( $cgiparams { 'PMTU_DISCOVERY' } eq '' ) {
4418 $cgiparams { 'PMTU_DISCOVERY' } = 'off' ;
4420 $checked { 'PMTU_DISCOVERY' }{ $cgiparams { 'PMTU_DISCOVERY' }} = 'checked= \' checked \' ' ;
4422 $selected { 'DCIPHER' }{ 'CAMELLIA-256-CBC' } = '' ;
4423 $selected { 'DCIPHER' }{ 'CAMELLIA-192-CBC' } = '' ;
4424 $selected { 'DCIPHER' }{ 'CAMELLIA-128-CBC' } = '' ;
4425 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4426 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4427 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4428 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4429 $selected { 'DCIPHER' }{ 'SEED-CBC' } = '' ;
4430 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4431 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4432 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4433 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4434 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4435 # If no cipher has been chossen yet, select
4436 # the old default (AES-256-CBC) for compatiblity reasons.
4437 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4438 $cgiparams { 'DCIPHER' } = 'AES-256-CBC' ;
4440 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4441 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
4442 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
4443 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
4444 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
4445 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
4446 # If no hash algorythm has been choosen yet, select
4447 # the old default value (SHA1) for compatiblity reasons.
4448 if ( $cgiparams { 'DAUTH' } eq '' ) {
4449 $cgiparams { 'DAUTH' } = 'SHA1' ;
4451 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
4454 & Header
:: showhttpheaders
();
4455 & Header
:: openpage
( $Lang :: tr
{ 'ovpn' }, 1 , '' );
4456 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4457 if ( $errormessage ) {
4458 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4459 print "<class name='base'> $errormessage " ;
4460 print " </class>" ;
4461 & Header
:: closebox
();
4465 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'warning messages'}:" );
4466 print "<class name='base'> $warnmessage " ;
4467 print " </class>" ;
4468 & Header
:: closebox
();
4471 print "<form method='post' enctype='multipart/form-data'>" ;
4472 print "<input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />" ;
4474 if ( $cgiparams { 'KEY' }) {
4475 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
4476 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
4479 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'connection'}:" );
4480 print "<table width='100%' border='0'> \n " ;
4482 print "<tr><td width='14%' class='boldbase'> $Lang ::tr{'name'}: </td>" ;
4484 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4485 if ( $cgiparams { 'KEY' }) {
4486 print "<td width='35%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4488 print "<td width='35%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' size='30' /></td>" ;
4490 # print "<tr><td>$Lang::tr{'interface'}</td>";
4491 # print "<td><select name='INTERFACE'>";
4492 # print "<option value='RED' $selected{'INTERFACE'}{'RED'}>RED</option>";
4493 # if ($netsettings{'BLUE_DEV'} ne '') {
4494 # print "<option value='BLUE' $selected{'INTERFACE'}{'BLUE'}>BLUE</option>";
4496 # print "<option value='GREEN' $selected{'INTERFACE'}{'GREEN'}>GREEN</option>";
4497 # print "<option value='ORANGE' $selected{'INTERFACE'}{'ORANGE'}>ORANGE</option>";
4498 # print "</select></td></tr>";
4501 print "<input type='hidden' name='INTERFACE' value='red' />" ;
4502 if ( $cgiparams { 'KEY' }) {
4503 print "<td width='25%' class='base' nowrap='nowrap'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /> $cgiparams {'NAME'}</td>" ;
4505 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' maxlength='20' /></td>" ;
4508 <td width='25%'> </td>
4509 <td width='25%'> </td></tr>
4510 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'Act as'}</td>
4511 <td><select name='SIDE'>
4512 <option value='server' $selected {'SIDE'}{'server'}> $Lang ::tr{'openvpn server'}</option>
4513 <option value='client' $selected {'SIDE'}{'client'}> $Lang ::tr{'openvpn client'}</option>
4517 <td class='boldbase'> $Lang ::tr{'remote host/ip'}:</td>
4518 <td><input type='TEXT' name='REMOTE' value=' $cgiparams {'REMOTE'}' /></td>
4521 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
4522 <td><input type='TEXT' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' /></td>
4524 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
4525 <td><input type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' /></td>
4528 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn subnet'}</td>
4529 <td><input type='TEXT' name='OVPN_SUBNET' value=' $cgiparams {'OVPN_SUBNET'}' /></td>
4531 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
4532 <td><select name='PROTOCOL'>
4533 <option value='udp' $selected {'PROTOCOL'}{'udp'}>UDP</option>
4534 <option value='tcp' $selected {'PROTOCOL'}{'tcp'}>TCP</option></select></td>
4538 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
4539 <td><input type='TEXT' name='DEST_PORT' value=' $cgiparams {'DEST_PORT'}' size='5' /></td>
4541 <td class='boldbase' nowrap='nowrap'>Management Port ( $Lang ::tr{'openvpn default'}: <span class="base"> $Lang ::tr{'destination port'}): <img src='/blob.gif' /></td>
4542 <td> <input type='TEXT' name='OVPN_MGMT' VALUE=' $cgiparams {'OVPN_MGMT'}'size='5' /></td>
4545 <tr><td colspan=4><hr /></td></tr><tr>
4548 <td class'base'><b> $Lang ::tr{'MTU settings'}</b></td>
4551 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} <img src='/blob.gif' /></td>
4552 <td><input type='TEXT' name='MTU' VALUE=' $cgiparams {'MTU'}'size='5' /></td>
4553 <td colspan='2'> $Lang ::tr{'openvpn default'}: udp/tcp <span class="base">1500/1400</span></td>
4556 <tr><td class='boldbase' nowrap='nowrap'>fragment <img src='/blob.gif' /></td>
4557 <td><input type='TEXT' name='FRAGMENT' VALUE=' $cgiparams {'FRAGMENT'}'size='5' /></td>
4558 <td> $Lang ::tr{'openvpn default'}: <span class="base">1300</span></td>
4561 <tr><td class='boldbase' nowrap='nowrap'>mssfix <img src='/blob.gif' /></td>
4562 <td><input type='checkbox' name='MSSFIX' $checked {'MSSFIX'}{'on'} /></td>
4563 <td> $Lang ::tr{'openvpn default'}: <span class="base">on</span></td>
4566 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'} <img src='/blob.gif'</td>
4567 <td><input type='checkbox' name='COMPLZO' $checked {'COMPLZO'}{'on'} /></td>
4570 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn mtu-disc'}</td>
4572 <input type='radio' name='PMTU_DISCOVERY' value='yes' $checked {'PMTU_DISCOVERY'}{'yes'} /> $Lang ::tr{'ovpn mtu-disc yes'}
4573 <input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked {'PMTU_DISCOVERY'}{'maybe'} /> $Lang ::tr{'ovpn mtu-disc maybe'}
4574 <input type='radio' name='PMTU_DISCOVERY' value='no' $checked {'PMTU_DISCOVERY'}{'no'} /> $Lang ::tr{'ovpn mtu-disc no'}
4575 <input type='radio' name='PMTU_DISCOVERY' value='off' $checked {'PMTU_DISCOVERY'}{'off'} /> $Lang ::tr{'ovpn mtu-disc off'}
4579 <tr><td colspan=4><hr /></td></tr><tr>
4581 <td class'base'><b> $Lang ::tr{'ovpn crypt options'}:</b></td>
4584 <tr><td class='boldbase'> $Lang ::tr{'cipher'}</td>
4585 <td><select name='DCIPHER'>
4586 <option value='CAMELLIA-256-CBC' $selected {'DCIPHER'}{'CAMELLIA-256-CBC'}>CAMELLIA-CBC (256 $Lang ::tr{'bit'})</option>
4587 <option value='CAMELLIA-192-CBC' $selected {'DCIPHER'}{'CAMELLIA-192-CBC'}>CAMELLIA-CBC (192 $Lang ::tr{'bit'})</option>
4588 <option value='CAMELLIA-128-CBC' $selected {'DCIPHER'}{'CAMELLIA-128-CBC'}>CAMELLIA-CBC (128 $Lang ::tr{'bit'})</option>
4589 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-CBC (256 $Lang ::tr{'bit'}, $Lang ::tr{'default'})</option>
4590 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-CBC (192 $Lang ::tr{'bit'})</option>
4591 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-CBC (128 $Lang ::tr{'bit'})</option>
4592 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC (192 $Lang ::tr{'bit'})</option>
4593 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC (192 $Lang ::tr{'bit'})</option>
4594 <option value='SEED-CBC' $selected {'DCIPHER'}{'SEED-CBC'}>SEED-CBC (128 $Lang ::tr{'bit'})</option>
4595 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC (128 $Lang ::tr{'bit'})</option>
4596 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC (128 $Lang ::tr{'bit'})</option>
4597 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC (128 $Lang ::tr{'bit'})</option>
4601 <td class='boldbase'> $Lang ::tr{'ovpn ha'}:</td>
4602 <td><select name='DAUTH'>
4603 <option value='whirlpool' $selected {'DAUTH'}{'whirlpool'}>Whirlpool (512 $Lang ::tr{'bit'})</option>
4604 <option value='SHA512' $selected {'DAUTH'}{'SHA512'}>SHA2 (512 $Lang ::tr{'bit'})</option>
4605 <option value='SHA384' $selected {'DAUTH'}{'SHA384'}>SHA2 (384 $Lang ::tr{'bit'})</option>
4606 <option value='SHA256' $selected {'DAUTH'}{'SHA256'}>SHA2 (256 $Lang ::tr{'bit'})</option>
4607 <option value='SHA1' $selected {'DAUTH'}{'SHA1'}>SHA1 (160 $Lang ::tr{'bit'} Default)</option>
4611 <tr><td colspan=4><hr /></td></tr><tr>
4617 print "<tr><td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' /></td>" ;
4618 print "<td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td></tr></table>" ;
4620 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4621 print "<tr><td> $Lang ::tr{'enabled'} <input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>" ;
4624 print "</tr></table><br><br>" ;
4625 #A.Marx CCD new client
4626 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4627 print "<table border='0' width='100%' cellspacing='1' cellpadding='0'><tr><td colspan='3'><hr><br><b> $Lang ::tr{'ccd choose net'}</td></tr><tr><td height='20' colspan='3'></td></tr>" ;
4630 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%vpnnet );
4631 $vpnip = $vpnnet { 'DOVPN_SUBNET' };
4632 & General
:: readhasharray
( "${General::swroot}/ovpn/ccd.conf" , \
%ccdconfhash );
4636 $checked { 'check1' }{ 'off' } = '' ;
4637 $checked { 'check1' }{ 'on' } = '' ;
4638 $checked { 'check1' }{ $cgiparams { 'CHECK1' }} = 'CHECKED' ;
4639 print "<tr><td align='center' width='1%' valign='top'><input type='radio' name='CHECK1' value='dynamic' checked /></td><td align='left' valign='top' width='35%'> $Lang ::tr{'ccd dynrange'} ( $vpnip )</td><td width='30%'>" ;
4640 print "</td></tr></table><br><br>" ;
4641 my $name = $cgiparams { 'CHECK1' };
4642 $checked { 'RG' }{ $cgiparams { 'RG' }} = 'CHECKED' ;
4644 if (! - z
"${General::swroot}/ovpn/ccd.conf" ){
4645 print "<table border='0' width='100%' cellspacing='1' cellpadding='0'><tr><td width='1%'></td><td width='30%' class='boldbase' align='center'><b> $Lang ::tr{'ccd name'}</td><td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'network'}</td><td class='boldbase' align='center' width='18%'><b> $Lang ::tr{'ccd clientip'}</td></tr>" ;
4646 foreach my $key ( sort { uc ( $ccdconfhash { $a }[ 0 ]) cmp uc ( $ccdconfhash { $b }[ 0 ]) } keys %ccdconfhash ) {
4648 @ccdconf =( $ccdconfhash { $key }[ 0 ], $ccdconfhash { $key }[ 1 ]);
4649 if ( $count % 2 ){ print "<tr bgcolor=' $color {'color22'}'>" ;} else { print "<tr bgcolor=' $color {'color20'}'>" ;}
4650 print "<td align='center' width='1%'><input type='radio' name='CHECK1' value=' $ccdconf [0]' $checked {'check1'}{ $ccdconf [0]}/></td><td> $ccdconf [0]</td><td width='40%' align='center'> $ccdconf [1]</td><td align='left' width='10%'>" ;
4651 & fillselectbox
( $ccdconf [ 1 ], $ccdconf [ 0 ], $cgiparams { $name });
4654 print "</table><br><br><hr><br><br>" ;
4658 & Header
:: closebox
();
4659 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
4661 } elsif (! $cgiparams { 'KEY' }) {
4665 my $cakeydisabled = '' ;
4666 my $cacrtdisabled = '' ;
4667 if ( ! - f
"${General::swroot}/ovpn/ca/cakey.pem" ) { $cakeydisabled = "disabled='disabled'" } else { $cakeydisabled = "" };
4668 if ( ! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) { $cacrtdisabled = "disabled='disabled'" } else { $cacrtdisabled = "" };
4670 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'authentication' });
4673 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4676 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4678 <tr><td><input type='radio' name='AUTH' value='certreq' $checked {'AUTH'}{'certreq'} $cakeydisabled /></td><td class='base'> $Lang ::tr{'upload a certificate request'}</td><td class='base' rowspan='2'><input type='file' name='FH' size='30' $cacrtdisabled ></td></tr>
4679 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td><td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
4680 <tr><td colspan='3'> </td></tr>
4681 <tr><td colspan='3'><hr /></td></tr>
4682 <tr><td colspan='3'> </td></tr>
4683 <tr><td><input type='radio' name='AUTH' value='certgen' $checked {'AUTH'}{'certgen'} $cakeydisabled /></td><td class='base'> $Lang ::tr{'generate a certificate'}</td><td> </td></tr>
4684 <tr><td> </td><td class='base'> $Lang ::tr{'users fullname or system hostname'}:</td><td class='base' nowrap='nowrap'><input type='text' name='CERT_NAME' value=' $cgiparams {'CERT_NAME'}' SIZE='32' $cakeydisabled /></td></tr>
4685 <tr><td> </td><td class='base'> $Lang ::tr{'users email'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_EMAIL' value=' $cgiparams {'CERT_EMAIL'}' SIZE='32' $cakeydisabled /></td></tr>
4686 <tr><td> </td><td class='base'> $Lang ::tr{'users department'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_OU' value=' $cgiparams {'CERT_OU'}' SIZE='32' $cakeydisabled /></td></tr>
4687 <tr><td> </td><td class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_ORGANIZATION' value=' $cgiparams {'CERT_ORGANIZATION'}' SIZE='32' $cakeydisabled /></td></tr>
4688 <tr><td> </td><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif'></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_CITY' value=' $cgiparams {'CERT_CITY'}' SIZE='32' $cakeydisabled /></td></tr>
4689 <tr><td> </td><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_STATE' value=' $cgiparams {'CERT_STATE'}' SIZE='32' $cakeydisabled /></td></tr>
4690 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4701 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
4703 <tr><td><input type='radio' name='AUTH' value='certgen' $checked {'AUTH'}{'certgen'} $cakeydisabled /></td><td class='base'> $Lang ::tr{'generate a certificate'}</td><td> </td></tr>
4704 <tr><td> </td><td class='base'> $Lang ::tr{'users fullname or system hostname'}:</td><td class='base' nowrap='nowrap'><input type='text' name='CERT_NAME' value=' $cgiparams {'CERT_NAME'}' SIZE='32' $cakeydisabled /></td></tr>
4705 <tr><td> </td><td class='base'> $Lang ::tr{'users email'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_EMAIL' value=' $cgiparams {'CERT_EMAIL'}' SIZE='32' $cakeydisabled /></td></tr>
4706 <tr><td> </td><td class='base'> $Lang ::tr{'users department'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_OU' value=' $cgiparams {'CERT_OU'}' SIZE='32' $cakeydisabled /></td></tr>
4707 <tr><td> </td><td class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_ORGANIZATION' value=' $cgiparams {'CERT_ORGANIZATION'}' SIZE='32' $cakeydisabled /></td></tr>
4708 <tr><td> </td><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif'></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_CITY' value=' $cgiparams {'CERT_CITY'}' SIZE='32' $cakeydisabled /></td></tr>
4709 <tr><td> </td><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' /></td><td class='base' nowrap='nowrap'><input type='text' name='CERT_STATE' value=' $cgiparams {'CERT_STATE'}' SIZE='32' $cakeydisabled /></td></tr>
4710 <tr><td> </td><td class='base'> $Lang ::tr{'country'}:</td><td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
4722 foreach my $country ( sort keys %{ Countries
:: countries
}) {
4723 print "<option value=' $Countries ::countries{ $country }'" ;
4724 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
4725 print " selected='selected'" ;
4727 print "> $country </option>" ;
4733 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4736 <td> </td><td class='base'> $Lang ::tr{'valid till'} (days):</td>
4737 <td class='base' nowrap='nowrap'><input type='text' name='DAYS_VALID' value=' $cgiparams {'DAYS_VALID'}' size='32' $cakeydisabled /></td></tr>
4739 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
4740 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
4741 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:<br>( $Lang ::tr{'confirmation'})</td>
4742 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
4743 <tr><td colspan='3'> </td></tr>
4744 <tr><td colspan='3'><hr /></td></tr>
4745 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4751 <td> </td><td class='base'> $Lang ::tr{'valid till'} (days):</td>
4752 <td class='base' nowrap='nowrap'><input type='text' name='DAYS_VALID' value=' $cgiparams {'DAYS_VALID'}' size='32' $cakeydisabled /></td></tr>
4753 <tr><td> </td><td> </td><td> </td></tr>
4754 <tr><td> </td><td> </td><td> </td></tr>
4755 <tr><td colspan='3'><hr /></td></tr>
4756 <tr><td class='base' colspan='3' align='left'><img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
4766 & Header
:: closebox
();
4770 #A.Marx CCD new client
4771 if ( $cgiparams { 'TYPE' } eq 'host' ) {
4773 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'ccd client options'}:" );
4777 <table border='0' width='100%'>
4778 <tr><td width='20%'>Redirect Gateway:</td><td colspan='3'><input type='checkbox' name='RG' $checked {'RG'}{'on'} /></td></tr>
4779 <tr><td colspan='4'><b><br> $Lang ::tr{'ccd routes'}</b></td></tr>
4780 <tr><td colspan='4'> </td></tr>
4781 <tr><td valign='top'> $Lang ::tr{'ccd iroute'}</td><td align='left' width='30%'><textarea name='IR' cols='26' rows='6' wrap='off'>
4784 if ( $cgiparams { 'IR' } ne '' ){
4785 print $cgiparams { 'IR' };
4787 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute" , \
%ccdroutehash );
4788 foreach my $key ( keys %ccdroutehash ) {
4789 if ( $cgiparams { 'NAME' } eq $ccdroutehash { $key }[ 0 ]){
4790 foreach my $i ( 1 .. $ #{$ccdroutehash{$key}}) {
4791 if ( $ccdroutehash { $key }[ $i ] ne '' ){
4792 print $ccdroutehash { $key }[ $i ]. " \n " ;
4794 $cgiparams { 'IR' } .= $ccdroutehash { $key }[ $i ];
4801 </textarea></td><td valign='top' colspan='2'> $Lang ::tr{'ccd iroutehint'}</td></tr>
4802 <tr><td colspan='4'><br></td></tr>
4803 <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>
4817 open ( FILE
, "${General::swroot}/main/routing" ) ;
4820 & General
:: readhasharray
( "${General::swroot}/ovpn/ccdroute2" , \
%ccdroute2hash );
4822 foreach my $key ( keys %ccdroute2hash ) {
4823 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4824 if ( $ccdroute2hash { $key }[ 1 ] eq '' ){
4831 print "<option> $Lang ::tr{'ccd none'}</option>" ;
4833 print "<option selected> $Lang ::tr{'ccd none'}</option>" ;
4835 #check if static routes are defined for client
4836 foreach my $line ( @current ) {
4838 $line =~ s/\s*$//g ; # remove newline
4839 @temp = split ( /\,/ , $line );
4840 $temp [ 1 ] = '' unless defined $temp [ 1 ]; # not always populated
4841 my ( $a , $b ) = split ( /\/ /, $temp [ 1 ]);
4842 $temp [ 1 ] = $a . "/" .& General
:: iporsubtocidr
( $b );
4843 foreach my $key ( keys %ccdroute2hash ) {
4844 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4845 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4846 if ( $ccdroute2hash { $key }[ $i ] eq $a . "/" .& General
:: iporsubtodec
( $b )){
4852 if ( $set == '1' && $#temp != - 1 ){ print "<option selected> $temp [1]</option>" ; $set = 0 ;} elsif ( $set == '0' && $#temp != - 1 ){ print "<option> $temp [1]</option>" ;}
4854 #check if green,blue,orange are defined for client
4855 foreach my $key ( keys %ccdroute2hash ) {
4856 if ( $ccdroute2hash { $key }[ 0 ] eq $cgiparams { 'NAME' }){
4858 foreach my $i ( 1 .. $ #{$ccdroute2hash{$key}}) {
4859 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'GREEN_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'GREEN_NETMASK' })){
4862 if (& haveBlueNet
()){
4863 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'BLUE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'BLUE_NETMASK' })) {
4867 if (& haveOrangeNet
()){
4868 if ( $ccdroute2hash { $key }[ $i ] eq $netsettings { 'ORANGE_NETADDRESS' }. "/" .& General
:: iporsubtodec
( $netsettings { 'ORANGE_NETMASK' }) ) {
4875 if (& haveBlueNet
() && $selblue == '1' ){ print "<option selected> $Lang ::tr{'blue'}</option>" ; $selblue = 0 ;} elsif (& haveBlueNet
() && $selblue == '0' ){ print "<option> $Lang ::tr{'blue'}</option>" ;}
4876 if (& haveOrangeNet
() && $selorange == '1' ){ print "<option selected> $Lang ::tr{'orange'}</option>" ; $selorange = 0 ;} elsif (& haveOrangeNet
() && $selorange == '0' ){ print "<option> $Lang ::tr{'orange'}</option>" ;}
4877 if ( $selgreen == '1' || $other == '0' ){ print "<option selected> $Lang ::tr{'green'}</option>" ; $set = 0 ;} else { print "<option> $Lang ::tr{'green'}</option>" ;};
4880 </select></td><td valign='top'>DNS1:</td><td valign='top'><input type='TEXT' name='CCD_DNS1' value=' $cgiparams {'CCD_DNS1'}' size='30' /></td></tr>
4881 <tr valign='top'><td>DNS2:</td><td><input type='TEXT' name='CCD_DNS2' value=' $cgiparams {'CCD_DNS2'}' size='30' /></td></tr>
4882 <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>
4886 & Header
:: closebox
();
4888 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
4889 if ( $cgiparams { 'KEY' }) {
4890 # print "<input type='submit' name='ACTION' value='$Lang::tr{'advanced'}' />";
4892 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
4893 & Header
:: closebigbox
();
4894 & Header
:: closepage
();
4902 ### Default status page
4907 & General
:: readhash
( "${General::swroot}/ovpn/settings" , \
%cgiparams );
4908 & General
:: readhasharray
( "${General::swroot}/ovpn/caconfig" , \
%cahash );
4909 & General
:: readhasharray
( "${General::swroot}/ovpn/ovpnconfig" , \
%confighash );
4911 my @status = `/bin/cat /var/run/ovpnserver.log` ;
4913 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
4914 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
4915 my $ipaddr = < IPADDR
>;
4918 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
4919 if ( $cgiparams { 'VPN_IP' } eq '' ) {
4920 $cgiparams { 'VPN_IP' } = $ipaddr ;
4926 if ( $cgiparams { 'DCIPHER' } eq '' ) {
4927 $cgiparams { 'DCIPHER' } = 'AES-256-CBC' ;
4929 if ( $cgiparams { 'DDEST_PORT' } eq '' ) {
4930 $cgiparams { 'DDEST_PORT' } = '1194' ;
4932 if ( $cgiparams { 'DMTU' } eq '' ) {
4933 $cgiparams { 'DMTU' } = '1400' ;
4935 if ( $cgiparams { 'MSSFIX' } eq '' ) {
4936 $cgiparams { 'MSSFIX' } = 'off' ;
4938 if ( $cgiparams { 'DAUTH' } eq '' ) {
4939 $cgiparams { 'DAUTH' } = 'SHA1' ;
4941 if ( $cgiparams { 'DOVPN_SUBNET' } eq '' ) {
4942 $cgiparams { 'DOVPN_SUBNET' } = '10.' . int ( rand ( 256 )) . '.' . int ( rand ( 256 )) . '.0/255.255.255.0' ;
4944 $checked { 'ENABLED' }{ 'off' } = '' ;
4945 $checked { 'ENABLED' }{ 'on' } = '' ;
4946 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = 'CHECKED' ;
4947 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
4948 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
4949 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = 'CHECKED' ;
4950 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
4951 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
4952 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = 'CHECKED' ;
4953 $selected { 'DDEVICE' }{ 'tun' } = '' ;
4954 $selected { 'DDEVICE' }{ 'tap' } = '' ;
4955 $selected { 'DDEVICE' }{ $cgiparams { 'DDEVICE' }} = 'SELECTED' ;
4957 $selected { 'DPROTOCOL' }{ 'udp' } = '' ;
4958 $selected { 'DPROTOCOL' }{ 'tcp' } = '' ;
4959 $selected { 'DPROTOCOL' }{ $cgiparams { 'DPROTOCOL' }} = 'SELECTED' ;
4961 $selected { 'DCIPHER' }{ 'CAMELLIA-256-CBC' } = '' ;
4962 $selected { 'DCIPHER' }{ 'CAMELLIA-192-CBC' } = '' ;
4963 $selected { 'DCIPHER' }{ 'CAMELLIA-128-CBC' } = '' ;
4964 $selected { 'DCIPHER' }{ 'AES-256-CBC' } = '' ;
4965 $selected { 'DCIPHER' }{ 'AES-192-CBC' } = '' ;
4966 $selected { 'DCIPHER' }{ 'AES-128-CBC' } = '' ;
4967 $selected { 'DCIPHER' }{ 'DES-EDE3-CBC' } = '' ;
4968 $selected { 'DCIPHER' }{ 'DESX-CBC' } = '' ;
4969 $selected { 'DCIPHER' }{ 'SEED-CBC' } = '' ;
4970 $selected { 'DCIPHER' }{ 'DES-EDE-CBC' } = '' ;
4971 $selected { 'DCIPHER' }{ 'CAST5-CBC' } = '' ;
4972 $selected { 'DCIPHER' }{ 'BF-CBC' } = '' ;
4973 $selected { 'DCIPHER' }{ 'DES-CBC' } = '' ;
4974 $selected { 'DCIPHER' }{ $cgiparams { 'DCIPHER' }} = 'SELECTED' ;
4976 $selected { 'DAUTH' }{ 'whirlpool' } = '' ;
4977 $selected { 'DAUTH' }{ 'SHA512' } = '' ;
4978 $selected { 'DAUTH' }{ 'SHA384' } = '' ;
4979 $selected { 'DAUTH' }{ 'SHA256' } = '' ;
4980 $selected { 'DAUTH' }{ 'SHA1' } = '' ;
4981 $selected { 'DAUTH' }{ $cgiparams { 'DAUTH' }} = 'SELECTED' ;
4983 $checked { 'DCOMPLZO' }{ 'off' } = '' ;
4984 $checked { 'DCOMPLZO' }{ 'on' } = '' ;
4985 $checked { 'DCOMPLZO' }{ $cgiparams { 'DCOMPLZO' }} = 'CHECKED' ;
4988 $checked { 'MSSFIX' }{ 'off' } = '' ;
4989 $checked { 'MSSFIX' }{ 'on' } = '' ;
4990 $checked { 'MSSFIX' }{ $cgiparams { 'MSSFIX' }} = 'CHECKED' ;
4992 & Header
:: showhttpheaders
();
4993 & Header
:: openpage
( $Lang :: tr
{ 'status ovpn' }, 1 , '' );
4994 & Header
:: openbigbox
( '100%' , 'LEFT' , '' , $errormessage );
4996 if ( $errormessage ) {
4997 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'error messages' });
4998 print "<class name='base'> $errormessage \n " ;
4999 print " </class> \n " ;
5000 & Header
:: closebox
();
5004 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'warning messages' });
5005 print " $warnmessage <br>" ;
5006 print " $Lang ::tr{'fwdfw warn1'}<br>" ;
5007 & Header
:: closebox
();
5008 print "<center><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'ok'}' style='width: 5em;'></form>" ;
5009 & Header
:: closepage
();
5013 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>" ;
5014 my $srunning = "no" ;
5015 my $activeonrun = "" ;
5016 if ( - e
"/var/run/openvpn.pid" ){
5017 $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>" ;
5021 $activeonrun = "disabled='disabled'" ;
5023 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'global settings' });
5025 <table width='100%' border='0'>
5026 <form method='post'>
5027 <td width='25%'> </td>
5028 <td width='25%'> </td>
5029 <td width='25%'> </td></tr>
5030 <tr><td class='boldbase'> $Lang ::tr{'ovpn server status'}</td>
5031 <td align='left'> $sactive </td>
5032 <tr><td class='boldbase'> $Lang ::tr{'ovpn on red'}</td>
5033 <td><input type='checkbox' name='ENABLED' $checked {'ENABLED'}{'on'} /></td>
5036 if (& haveBlueNet
()) {
5037 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on blue'}</td>" ;
5038 print "<td><input type='checkbox' name='ENABLED_BLUE' $checked {'ENABLED_BLUE'}{'on'} /></td>" ;
5040 if (& haveOrangeNet
()) {
5041 print "<tr><td class='boldbase'> $Lang ::tr{'ovpn on orange'}</td>" ;
5042 print "<td><input type='checkbox' name='ENABLED_ORANGE' $checked {'ENABLED_ORANGE'}{'on'} /></td>" ;
5045 <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>
5046 <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>
5047 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ovpn device'}</td>
5048 <td><select name='DDEVICE' ><option value='tun' $selected {'DDEVICE'}{'tun'}>TUN</option>
5049 <!-- this is still not working
5050 <option value='tap' $selected {'DDEVICE'}{'tap'}>TAP</option></select>--> </td>
5051 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'protocol'}</td>
5052 <td><select name='DPROTOCOL'><option value='udp' $selected {'DPROTOCOL'}{'udp'}>UDP</option>
5053 <option value='tcp' $selected {'DPROTOCOL'}{'tcp'}>TCP</option></select></td>
5054 <td class='boldbase'> $Lang ::tr{'destination port'}:</td>
5055 <td><input type='TEXT' name='DDEST_PORT' value=' $cgiparams {'DDEST_PORT'}' size='5' /></td></tr>
5056 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'MTU'} </td>
5057 <td> <input type='TEXT' name='DMTU' VALUE=' $cgiparams {'DMTU'}' size='5' /></td>
5059 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'cipher'}</td>
5060 <td><select name='DCIPHER'>
5061 <option value='CAMELLIA-256-CBC' $selected {'DCIPHER'}{'CAMELLIA-256-CBC'}>CAMELLIA-CBC (256 $Lang ::tr{'bit'})</option>
5062 <option value='CAMELLIA-192-CBC' $selected {'DCIPHER'}{'CAMELLIA-192-CBC'}>CAMELLIA-CBC (192 $Lang ::tr{'bit'})</option>
5063 <option value='CAMELLIA-128-CBC' $selected {'DCIPHER'}{'CAMELLIA-128-CBC'}>CAMELLIA-CBC (128 $Lang ::tr{'bit'})</option>
5064 <option value='AES-256-CBC' $selected {'DCIPHER'}{'AES-256-CBC'}>AES-CBC (256 $Lang ::tr{'bit'})</option>
5065 <option value='AES-192-CBC' $selected {'DCIPHER'}{'AES-192-CBC'}>AES-CBC (192 $Lang ::tr{'bit'})</option>
5066 <option value='AES-128-CBC' $selected {'DCIPHER'}{'AES-128-CBC'}>AES-CBC (128 $Lang ::tr{'bit'})</option>
5067 <option value='DES-EDE3-CBC' $selected {'DCIPHER'}{'DES-EDE3-CBC'}>DES-EDE3-CBC (192 $Lang ::tr{'bit'})</option>
5068 <option value='DESX-CBC' $selected {'DCIPHER'}{'DESX-CBC'}>DESX-CBC (192 $Lang ::tr{'bit'})</option>
5069 <option value='SEED-CBC' $selected {'DCIPHER'}{'SEED-CBC'}>SEED-CBC (128 $Lang ::tr{'bit'})</option>
5070 <option value='DES-EDE-CBC' $selected {'DCIPHER'}{'DES-EDE-CBC'}>DES-EDE-CBC (128 $Lang ::tr{'bit'})</option>
5071 <option value='BF-CBC' $selected {'DCIPHER'}{'BF-CBC'}>BF-CBC (128 $Lang ::tr{'bit'})</option>
5072 <option value='CAST5-CBC' $selected {'DCIPHER'}{'CAST5-CBC'}>CAST5-CBC (128 $Lang ::tr{'bit'})</option>
5075 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'comp-lzo'}</td>
5076 <td><input type='checkbox' name='DCOMPLZO' $checked {'DCOMPLZO'}{'on'} /></td>
5078 <tr><td colspan='4'><br><br></td></tr>
5082 if ( $srunning eq "yes" ) {
5083 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' disabled='disabled' />" ;
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 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'stop ovpn server'}' /></td></tr>" ;
5088 print "<tr><td align='right' colspan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
5089 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'ccd net'}' />" ;
5090 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced server'}' />" ;
5091 if (( - e
"${General::swroot}/ovpn/ca/cacert.pem" &&
5092 - e
"${General::swroot}/ovpn/ca/dh1024.pem" &&
5093 - e
"${General::swroot}/ovpn/certs/servercert.pem" &&
5094 - e
"${General::swroot}/ovpn/certs/serverkey.pem" ) &&
5095 (( $cgiparams { 'ENABLED' } eq 'on' ) ||
5096 ( $cgiparams { 'ENABLED_BLUE' } eq 'on' ) ||
5097 ( $cgiparams { 'ENABLED_ORANGE' } eq 'on' ))){
5098 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' /></td></tr>" ;
5100 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'start ovpn server'}' disabled='disabled' /></td></tr>" ;
5103 print "</form></table>" ;
5104 & Header
:: closebox
();
5106 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5109 #<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>
5112 & Header
:: openbox
( '100%' , 'LEFT' , $Lang :: tr
{ 'connection status and controlc' });
5118 foreach my $key ( sort { ncmp
( $confighash { $a }[ 32 ], $confighash { $b }[ 32 ]) } sort { ncmp
( $confighash { $a }[ 1 ], $confighash { $b }[ 1 ]) } keys %confighash ) {
5119 if ( $confighash { $key }[ 32 ] eq "" && $confighash { $key }[ 3 ] eq 'net' ){ $confighash { $key }[ 32 ]= $Lang :: tr
{ 'fwhost OpenVPN N-2-N' };}
5120 if ( $confighash { $key }[ 32 ] eq "dynamic" ){ $confighash { $key }[ 32 ]= $Lang :: tr
{ 'ccd dynrange' };}
5122 print "<b> $confighash { $key }[32]</b>" ;
5124 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5126 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5127 <th width='15%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></th>
5128 <th width='20%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></th>
5129 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></th>
5130 <th width='5%' class='boldbase' colspan='6' align='center'><b> $Lang ::tr{'action'}</b></th>
5134 if ( $id > 0 && $lastnet ne $confighash { $key }[ 32 ]){
5135 print "</table><br>" ;
5136 print "<b> $confighash { $key }[32]</b>" ;
5138 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5140 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5141 <th width='15%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></th>
5142 <th width='20%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></th>
5143 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></th>
5144 <th width='5%' class='boldbase' colspan='6' align='center'><b> $Lang ::tr{'action'}</b></th>
5148 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
5151 $col = "bgcolor=' $color {'color20'}'" ;
5154 $col = "bgcolor=' $color {'color22'}'" ;
5156 print "<td align='center' nowrap='nowrap' $col > $confighash { $key }[1]</td>" ;
5157 print "<td align='center' nowrap='nowrap' $col >" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
5158 #if ($confighash{$key}[4] eq 'cert') {
5159 #print "<td align='left' nowrap='nowrap'>$confighash{$key}[2]</td>";
5161 #print "<td align='left'> </td>";
5163 my $cavalid = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/ $confighash { $key }[1]cert.pem` ;
5164 $cavalid =~ /Not After : (.*)[\n]/ ;
5166 print "<td align='center' $col > $confighash { $key }[25]</td>" ;
5167 $col1 = "bgcolor='${Header::colourred}'" ;
5168 my $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
5170 if ( $confighash { $key }[ 0 ] eq 'off' ) {
5171 $col1 = "bgcolor='${Header::colourblue}'" ;
5172 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
5179 if ( $confighash { $key }[ 3 ] eq 'net' ) {
5181 if (- e
"/var/run/ $confighash { $key }[1]n2n.pid" ) {
5184 my $tport = $confighash { $key }[ 22 ];
5185 my $tnet = new Net
:: Telnet
( Timeout
=> 5 , Errmode
=> 'return' , Port
=> $tport );
5187 $tnet -> open ( '127.0.0.1' );
5188 @output = $tnet -> cmd ( String
=> 'state' , Prompt
=> '/(END.* \n |ERROR:.* \n )/' );
5189 @tustate = split ( /\,/ , $output [ 1 ]);
5191 #CONNECTING -- OpenVPN's initial state.
5192 #WAIT -- (Client only) Waiting for initial response from server.
5193 #AUTH -- (Client only) Authenticating with server.
5194 #GET_CONFIG -- (Client only) Downloading configuration options from server.
5195 #ASSIGN_IP -- Assigning IP address to virtual network interface.
5196 #ADD_ROUTES -- Adding routes to system.
5197 #CONNECTED -- Initialization Sequence Completed.
5198 #RECONNECTING -- A restart has occurred.
5199 #EXITING -- A graceful exit is in progress.
5202 if (( $tustate [ 1 ] eq 'CONNECTED' ) || ( $tustate [ 1 ] eq 'WAIT' )) {
5203 $col1 = "bgcolor='${Header::colourgreen}'" ;
5204 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
5206 $col1 = "bgcolor='${Header::colourred}'" ;
5207 $active = "<b><font color='#FFFFFF'> $tustate [1]</font></b>" ;
5215 foreach my $line ( @status ) {
5217 if ( $line =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
5218 @match = split ( m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ , $line );
5219 if ( $match [ 1 ] ne "Common Name" ) {
5223 if ( $cn eq " $confighash { $key }[2]" ) {
5224 $col1 = "bgcolor='${Header::colourgreen}'" ;
5225 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
5234 <td align='center' $col1 > $active </td>
5236 <form method='post' name='frm${key}a'><td align='center' $col >
5237 <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' />
5238 <input type='hidden' name='ACTION' value=' $Lang ::tr{'dl client arch'}' />
5239 <input type='hidden' name='KEY' value=' $key ' />
5243 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
5245 <form method='post' name='frm${key}b'><td align='center' $col >
5246 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' border='0' />
5247 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
5248 <input type='hidden' name='KEY' value=' $key ' />
5252 print "<td> </td>" ;
5254 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/ovpn/certs/ $confighash { $key }[1].p12" ) {
5256 <form method='post' name='frm${key}c'><td align='center' $col >
5257 <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' />
5258 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
5259 <input type='hidden' name='KEY' value=' $key ' />
5262 ; } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
5264 <form method='post' name='frm${key}c'><td align='center' $col >
5265 <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' />
5266 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
5267 <input type='hidden' name='KEY' value=' $key ' />
5271 print "<td> </td>" ;
5274 <form method='post' name='frm${key}d'><td align='center' $col >
5275 <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' />
5276 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
5277 <input type='hidden' name='KEY' value=' $key ' />
5280 <form method='post' name='frm${key}e'><td align='center' $col >
5281 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
5282 <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'/>
5283 <input type='hidden' name='KEY' value=' $key ' />
5285 <form method='post' name='frm${key}f'><td align='center' $col >
5286 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
5287 <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' />
5288 <input type='hidden' name='KEY' value=' $key ' />
5294 $lastnet = $confighash { $key }[ 32 ];
5299 # If the config file contains entries, print Key to action icons
5304 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5305 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
5306 <td class='base'> $Lang ::tr{'click to disable'}</td>
5307 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
5308 <td class='base'> $Lang ::tr{'show certificate'}</td>
5309 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
5310 <td class='base'> $Lang ::tr{'edit'}</td>
5311 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
5312 <td class='base'> $Lang ::tr{'remove'}</td>
5316 <td> <img src='/images/off.gif' alt='?OFF' /></td>
5317 <td class='base'> $Lang ::tr{'click to enable'}</td>
5318 <td> <img src='/images/media-floppy.png' alt='?FLOPPY' /></td>
5319 <td class='base'> $Lang ::tr{'download certificate'}</td>
5320 <td> <img src='/images/openvpn.png' alt='?RELOAD'/></td>
5321 <td class='base'> $Lang ::tr{'dl client arch'}</td>
5329 <table width='100%'>
5330 <form method='post'>
5331 <tr><td align='right'>
5332 <input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
5333 <input type='submit' name='ACTION' value=' $Lang ::tr{'ovpn con stat'}' $activeonrun /></td>
5339 & Header
:: closebox
();
5343 & Header
:: openbox
( '100%' , 'LEFT' , " $Lang ::tr{'certificate authorities'}" );
5345 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
5347 <th width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
5348 <th width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></th>
5349 <th width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></th>
5353 my $col1 = "bgcolor=' $color {'color22'}'" ;
5354 my $col2 = "bgcolor=' $color {'color20'}'" ;
5356 my $col3 = "bgcolor=' $color {'color22'}'" ;
5358 my $col4 = "bgcolor=' $color {'color20'}'" ;
5360 if (- f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5361 my $casubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/ca/cacert.pem` ;
5362 $casubject =~ /Subject: (.*)[\n]/ ;
5364 $casubject =~ s
+/ Email
+, E
+;
5365 $casubject =~ s/ ST=/ S=/ ;
5368 <td class='base' $col1 > $Lang ::tr{'root certificate'}</td>
5369 <td class='base' $col1 > $casubject </td>
5370 <form method='post' name='frmrootcrta'><td width='3%' align='center' $col1 >
5371 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
5372 <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' />
5374 <form method='post' name='frmrootcrtb'><td width='3%' align='center' $col1 >
5375 <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' />
5376 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
5378 <td width='4%' $col1 > </td>
5383 # display rootcert generation buttons
5386 <td class='base' $col1 > $Lang ::tr{'root certificate'}:</td>
5387 <td class='base' $col1 > $Lang ::tr{'not present'}</td>
5388 <td colspan='3' $col1 > </td>
5394 if (- f
"${General::swroot}/ovpn/certs/servercert.pem" ) {
5395 my $hostsubject = `/usr/bin/openssl x509 -text -in ${General::swroot}/ovpn/certs/servercert.pem` ;
5396 $hostsubject =~ /Subject: (.*)[\n]/ ;
5398 $hostsubject =~ s
+/ Email
+, E
+;
5399 $hostsubject =~ s/ ST=/ S=/ ;
5403 <td class='base' $col2 > $Lang ::tr{'host certificate'}</td>
5404 <td class='base' $col2 > $hostsubject </td>
5405 <form method='post' name='frmhostcrta'><td width='3%' align='center' $col2 >
5406 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
5407 <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' />
5409 <form method='post' name='frmhostcrtb'><td width='3%' align='center' $col2 >
5410 <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' />
5411 <input type='hidden' name='ACTION' value=" $Lang ::tr{'download host certificate'}" />
5413 <td width='4%' $col2 > </td>
5421 <td width='25%' class='base' $col2 > $Lang ::tr{'host certificate'}:</td>
5422 <td class='base' $col2 > $Lang ::tr{'not present'}</td>
5423 </td><td colspan='3' $col2 > </td>
5429 # Adding DH parameter to chart
5430 if (- f
"${General::swroot}/ovpn/ca/dh1024.pem" ) {
5431 my $dhsubject = `/usr/bin/openssl dhparam -text -in ${General::swroot}/ovpn/ca/dh1024.pem` ;
5432 $dhsubject =~ / (.*)[\n]/ ;
5438 <td class='base' $col3 > $Lang ::tr{'dh parameter'}</td>
5439 <td class='base' $col3 > $dhsubject </td>
5440 <form method='post' name='frmdhparam'><td width='3%' align='center' $col3 >
5441 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show dh'}' />
5442 <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' />
5444 <form method='post' name='frmdhparam'><td width='3%' align='center' $col3 >
5446 <td width='4%' $col3 > </td>
5454 <td width='25%' class='base' $col3 > $Lang ::tr{'dh parameter'}:</td>
5455 <td class='base' $col3 > $Lang ::tr{'not present'}</td>
5456 </td><td colspan='3' $col3 > </td>
5462 # Adding ta.key to chart
5463 if (- f
"${General::swroot}/ovpn/certs/ta.key" ) {
5464 my $tasubject = `/bin/cat ${General::swroot}/ovpn/certs/ta.key` ;
5465 $tasubject =~ /# (.*)[\n]/ ;
5470 <td class='base' $col4 > $Lang ::tr{'ta key'}</td>
5471 <td class='base' $col4 > $tasubject </td>
5472 <form method='post' name='frmtakey'><td width='3%' align='center' $col4 >
5473 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show tls-auth key'}' />
5474 <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' />
5476 <form method='post' name='frmtakey'><td width='3%' align='center' $col4 >
5477 <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' />
5478 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download tls-auth key'}' />
5480 <td width='4%' $col4 > </td>
5488 <td width='25%' class='base' $col4 > $Lang ::tr{'ta key'}:</td>
5489 <td class='base' $col4 > $Lang ::tr{'not present'}</td>
5490 <td colspan='3' $col4 > </td>
5496 if (! - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5497 print "<tr><td colspan='5' align='center'><form method='post'>" ;
5498 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' />" ;
5499 print "</form></td></tr> \n " ;
5502 if ( keys %cahash > 0 ) {
5503 foreach my $key ( keys %cahash ) {
5504 if (( $key + 1 ) % 2 ) {
5505 print "<tr bgcolor=' $color {'color20'}'> \n " ;
5507 print "<tr bgcolor=' $color {'color22'}'> \n " ;
5509 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
5510 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
5512 <form method='post' name='cafrm${key}a'><td align='center'>
5513 <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' />
5514 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
5515 <input type='hidden' name='KEY' value=' $key ' />
5517 <form method='post' name='cafrm${key}b'><td align='center'>
5518 <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' />
5519 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
5520 <input type='hidden' name='KEY' value=' $key ' />
5522 <form method='post' name='cafrm${key}c'><td align='center'>
5523 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
5524 <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' />
5525 <input type='hidden' name='KEY' value=' $key ' />
5534 # If the file contains entries, print Key to action icons
5535 if ( - f
"${General::swroot}/ovpn/ca/cacert.pem" ) {
5539 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5540 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
5541 <td class='base'> $Lang ::tr{'show certificate'}</td>
5542 <td> <img src='/images/media-floppy.png' alt=' $Lang ::tr{'download certificate'}' /></td>
5543 <td class='base'> $Lang ::tr{'download certificate'}</td>
5552 <form method='post' enctype='multipart/form-data'>
5553 <table width='100%' border='0'cellspacing='1' cellpadding='0'>
5555 <td class'base'><b> $Lang ::tr{'upload ca certificate'}</b></td>
5558 <td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}:</td>
5559 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' align='left'/></td>
5560 <td nowrap='nowrap'><input type='file' name='FH' size='25' />
5561 <td nowrap='nowrap' align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td>
5565 <td colspan='4' align='right' width='80%'><input type='submit' name='ACTION' value=' $Lang ::tr{'show crl'}' /></td>
5568 <tr><td colspan=4><hr /></td></tr><tr>
5570 <td class'base'><b> $Lang ::tr{'ovpn dh parameters'}</b></td>
5574 <td class='base' nowrap='nowrap'> $Lang ::tr{'ovpn dh upload'}:</td>
5575 <td nowrap='nowrap'><size='15' align='left'/></td>
5576 <td nowrap='nowrap'><input type='file' name='FH' size='25' />
5577 <td colspan='4' align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload dh key'}' /></td>
5580 <td class='base' nowrap='nowrap'> $Lang ::tr{'ovpn dh new key'}:</td>
5581 <td nowrap='nowrap'><size='15' align='left'/></td>
5582 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'generate dh key'}' /></td>
5586 <tr><td colspan=4><hr /></td></tr><tr>
5590 if ( $srunning eq "yes" ) {
5591 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' disabled='disabled' /></div></form> \n " ;
5593 print "<div align='center'><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' /></div></form> \n " ;
5595 & Header
:: closebox
();
5599 & Header
:: closepage
();