Merge remote-tracking branch 'ummeegge/OpenVPN_additional_configs' into next

This commit is contained in:
Michael Tremer
2014-12-08 19:12:48 +01:00
3 changed files with 105 additions and 30 deletions

View File

@@ -70,6 +70,9 @@ my $configgrp="${General::swroot}/fwhosts/customgroups";
my $customnet="${General::swroot}/fwhosts/customnetworks";
my $name;
my $col="";
my $local_serverconf = "${General::swroot}/ovpn/scripts/server.conf.local";
my $local_clientconf = "${General::swroot}/ovpn/scripts/client.conf.local";
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
$cgiparams{'ENABLED'} = 'off';
$cgiparams{'ENABLED_BLUE'} = 'off';
@@ -94,10 +97,33 @@ $cgiparams{'DCIPHER'} = '';
$cgiparams{'DAUTH'} = '';
$cgiparams{'TLSAUTH'} = '';
$routes_push_file = "${General::swroot}/ovpn/routes_push";
unless (-e $routes_push_file) { system("touch $routes_push_file"); }
unless (-e "${General::swroot}/ovpn/ccd.conf") { system("touch ${General::swroot}/ovpn/ccd.conf"); }
unless (-e "${General::swroot}/ovpn/ccdroute") { system("touch ${General::swroot}/ovpn/ccdroute"); }
unless (-e "${General::swroot}/ovpn/ccdroute2") { system("touch ${General::swroot}/ovpn/ccdroute2"); }
# Add CCD files if not already presant
unless (-e $routes_push_file) {
open(RPF, ">$routes_push_file");
close(RPF);
}
unless (-e "${General::swroot}/ovpn/ccd.conf") {
open(CCDC, ">${General::swroot}/ovpn/ccd.conf");
close (CCDC);
}
unless (-e "${General::swroot}/ovpn/ccdroute") {
open(CCDR, ">${General::swroot}/ovpn/ccdroute");
close (CCDR);
}
unless (-e "${General::swroot}/ovpn/ccdroute2") {
open(CCDRT, ">${General::swroot}/ovpn/ccdroute2");
close (CCDRT);
}
# Add additional configs if not already presant
unless (-e "$local_serverconf") {
open(LSC, ">$local_serverconf");
close (LSC);
}
unless (-e "$local_clientconf") {
open(LCC, ">$local_clientconf");
close (LCC);
}
&Header::getcgihash(\%cgiparams, {'wantfile' => 1, 'filevar' => 'FH'});
@@ -306,7 +332,22 @@ sub writeserverconf {
print CONF "verb $sovpnsettings{LOG_VERB}\n";
} else {
print CONF "verb 3\n";
}
}
# Print server.conf.local if entries exist to server.conf
if ( !-z $local_serverconf && $sovpnsettings{'ADDITIONAL_CONFIGS'} eq 'on') {
open (LSC, "$local_serverconf");
print CONF "\n#---------------------------\n";
print CONF "# Start of custom directives\n";
print CONF "# from server.conf.local\n";
print CONF "#---------------------------\n\n";
while (<LSC>) {
print CONF $_;
}
print CONF "\n#-----------------------------\n";
print CONF "# End of custom directives\n";
print CONF "#-----------------------------\n";
close (LSC);
}
print CONF "\n";
close(CONF);
@@ -685,6 +726,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'save-adv-options'}) {
$vpnsettings{'MAX_CLIENTS'} = $cgiparams{'MAX_CLIENTS'};
$vpnsettings{'REDIRECT_GW_DEF1'} = $cgiparams{'REDIRECT_GW_DEF1'};
$vpnsettings{'CLIENT2CLIENT'} = $cgiparams{'CLIENT2CLIENT'};
$vpnsettings{'ADDITIONAL_CONFIGS'} = $cgiparams{'ADDITIONAL_CONFIGS'};
$vpnsettings{'DHCP_DOMAIN'} = $cgiparams{'DHCP_DOMAIN'};
$vpnsettings{'DHCP_DNS'} = $cgiparams{'DHCP_DNS'};
$vpnsettings{'DHCP_WINS'} = $cgiparams{'DHCP_WINS'};
@@ -2224,6 +2266,21 @@ else
print CLIENTCONF "mtu-disc $vpnsettings{'PMTU_DISCOVERY'}\r\n";
}
}
# Print client.conf.local if entries exist to client.ovpn
if (!-z $local_clientconf && $vpnsettings{'ADDITIONAL_CONFIGS'} eq 'on') {
open (LCC, "$local_clientconf");
print CLIENTCONF "\n#---------------------------\n";
print CLIENTCONF "# Start of custom directives\n";
print CLIENTCONF "# from client.conf.local\n";
print CLIENTCONF "#---------------------------\n\n";
while (<LCC>) {
print CLIENTCONF $_;
}
print CLIENTCONF "\n#---------------------------\n";
print CLIENTCONF "# End of custom directives\n";
print CLIENTCONF "#---------------------------\n\n";
close (LCC);
}
close(CLIENTCONF);
$zip->addFile( "$tempdir/$clientovpn", $clientovpn) or die "Can't add file $clientovpn\n";
@@ -2456,6 +2513,9 @@ ADV_ERROR:
$checked{'REDIRECT_GW_DEF1'}{'off'} = '';
$checked{'REDIRECT_GW_DEF1'}{'on'} = '';
$checked{'REDIRECT_GW_DEF1'}{$cgiparams{'REDIRECT_GW_DEF1'}} = 'CHECKED';
$checked{'ADDITIONAL_CONFIGS'}{'off'} = '';
$checked{'ADDITIONAL_CONFIGS'}{'on'} = '';
$checked{'ADDITIONAL_CONFIGS'}{$cgiparams{'ADDITIONAL_CONFIGS'}} = 'CHECKED';
$checked{'MSSFIX'}{'off'} = '';
$checked{'MSSFIX'}{'on'} = '';
$checked{'MSSFIX'}{$cgiparams{'MSSFIX'}} = 'CHECKED';
@@ -2536,39 +2596,52 @@ print <<END;
</table>
<hr size='1'>
<table width='100%'>
<tr>
<tr>
<td class'base'><b>$Lang::tr{'misc-options'}</b></td>
</tr>
<tr>
</tr>
<tr>
<td width='20%'></td> <td width='15%'> </td><td width='15%'> </td><td width='15%'></td><td width='35%'></td>
</tr>
<tr>
</tr>
<tr>
<td class='base'>Client-To-Client</td>
<td><input type='checkbox' name='CLIENT2CLIENT' $checked{'CLIENT2CLIENT'}{'on'} /></td>
</tr>
<tr>
</tr>
<tr>
<td class='base'>Redirect-Gateway def1</td>
<td><input type='checkbox' name='REDIRECT_GW_DEF1' $checked{'REDIRECT_GW_DEF1'}{'on'} /></td>
</tr>
<tr>
<td class='base'>Max-Clients</td>
<td><input type='text' name='MAX_CLIENTS' value='$cgiparams{'MAX_CLIENTS'}' size='10' /></td>
</tr>
</tr>
<tr>
<td class='base'>Keepalive <br />
(ping/ping-restart)</td>
<td><input type='TEXT' name='KEEPALIVE_1' value='$cgiparams{'KEEPALIVE_1'}' size='10' /></td>
<td><input type='TEXT' name='KEEPALIVE_2' value='$cgiparams{'KEEPALIVE_2'}' size='10' /></td>
</tr>
<td class='base'>$Lang::tr{'ovpn add conf'}</td>
<td><input type='checkbox' name='ADDITIONAL_CONFIGS' $checked{'ADDITIONAL_CONFIGS'}{'on'} /></td>
<td>$Lang::tr{'openvpn default'}: off</td>
</tr>
<tr>
<td class='base'>fragment <br></td>
<td><input type='TEXT' name='FRAGMENT' value='$cgiparams{'FRAGMENT'}' size='10' /></td>
</tr>
<tr>
<td class='base'>mssfix</td>
<td><input type='checkbox' name='MSSFIX' $checked{'MSSFIX'}{'on'} /></td>
<td>$Lang::tr{'openvpn default'}: off</td>
</tr>
<td class='base'>mssfix</td>
<td><input type='checkbox' name='MSSFIX' $checked{'MSSFIX'}{'on'} /></td>
<td>$Lang::tr{'openvpn default'}: off</td>
</tr>
<tr>
<td class='base'>fragment <br></td>
<td><input type='TEXT' name='FRAGMENT' value='$cgiparams{'FRAGMENT'}' size='10' /></td>
</tr>
<tr>
<td class='base'>Max-Clients</td>
<td><input type='text' name='MAX_CLIENTS' value='$cgiparams{'MAX_CLIENTS'}' size='10' /></td>
</tr>
<tr>
<td class='base'>Keepalive <br />
(ping/ping-restart)</td>
<td><input type='TEXT' name='KEEPALIVE_1' value='$cgiparams{'KEEPALIVE_1'}' size='10' /></td>
<td><input type='TEXT' name='KEEPALIVE_2' value='$cgiparams{'KEEPALIVE_2'}' size='10' /></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'ovpn mtu-disc'}</td>

View File

@@ -1690,6 +1690,7 @@
'outgoing traffic in bytes per second' => 'Abgehender Verkehr',
'override mtu' => 'Überschreibe Standard MTU',
'ovpn' => 'OpenVPN',
'ovpn add conf' => 'Erweiterte Konfiguration',
'ovpn con stat' => 'OpenVPN Verbindungs-Statistik',
'ovpn config' => 'OVPN-Konfiguration',
'ovpn crypt options' => 'Kryptografieoptionen',

View File

@@ -1721,6 +1721,7 @@
'outgoing traffic in bytes per second' => 'Outgoing Traffic',
'override mtu' => 'Override default MTU',
'ovpn' => 'OpenVPN',
'ovpn add conf' => 'Additional configuration',
'ovpn con stat' => 'OpenVPN Connection Statistics',
'ovpn config' => 'OVPN-Config',
'ovpn crypt options' => 'Cryptographic options',