initial commit of file from CVS for smeserver-openvpn-bridge on Sat Sep 7 19:57:25 AEST 2024
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
{
|
||||
my $openvpn = $DB->get('openvpn-bridge') || $DB->new_record('openvpn-bridge', {type => 'service'});
|
||||
my $management = $openvpn->prop('management') || '';
|
||||
# If the management interface is already defined, return nothing
|
||||
return "" if ($management ne '');
|
||||
|
||||
# Else, we generate a random password
|
||||
|
||||
$pass=`/usr/bin/openssl rand -base64 20 | tr -c -d '[:alnum:]'`;
|
||||
$openvpn->set_prop('management',"localhost:11194:$pass");
|
||||
}
|
||||
|
@@ -0,0 +1,36 @@
|
||||
{
|
||||
my $openvpn = $DB->get('openvpn-bridge') || $DB->new_record('openvpn-bridge', {type => 'service'});
|
||||
my $start = $openvpn->prop('startPool') || '';
|
||||
my $end = $openvpn->prop('endPool') || '';
|
||||
|
||||
# If start and end are define, we return an empty string
|
||||
return "" if ($start ne '' and $end ne '');
|
||||
|
||||
# Else, we compute valid address
|
||||
|
||||
$start = '0.0.0.10';
|
||||
$end = '0.0.0.30';
|
||||
|
||||
$start = esmith::util::IPquadToAddr($start);
|
||||
$end = esmith::util::IPquadToAddr($end);
|
||||
my $netmask = esmith::util::IPquadToAddr($LocalNetmask);
|
||||
my $localnet = esmith::util::IPquadToAddr($LocalIP) & $netmask;
|
||||
|
||||
# AND-out the host bits from the start and end ips.
|
||||
# And, OR our local network with our start and end host values.
|
||||
$start = $localnet | ($start & ~$netmask);
|
||||
$end = $localnet | ($end & ~$netmask);
|
||||
|
||||
# Make sure that $start is less than $end (might not be if netmask has changed)
|
||||
if ($start > $end)
|
||||
{
|
||||
my $temp = $start;
|
||||
$start = $end;
|
||||
$end = $temp;
|
||||
}
|
||||
|
||||
$openvpn->merge_props(startPool => esmith::util::IPaddrToQuad($start),
|
||||
endPool => esmith::util::IPaddrToQuad($end));
|
||||
|
||||
|
||||
}
|
16
root/etc/e-smith/db/configuration/migrate/50openvpn-cipher
Normal file
16
root/etc/e-smith/db/configuration/migrate/50openvpn-cipher
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
#migrate cipher to Cipher that is used in all other openvpn contribs
|
||||
my $opv = $DB->get('openvpn-bridge') || $DB->new_record('openvpn-bridge', {type => 'service'});
|
||||
|
||||
my %old2new = (
|
||||
'cipher' => "Cipher",
|
||||
);
|
||||
|
||||
for my $keyt ( keys %old2new )
|
||||
{
|
||||
next unless ( $opv->prop($keyt) );
|
||||
my $value = $DB->get_prop_and_delete('openvpn-bridge', $keyt);
|
||||
next if ( $opv->prop($old2new{$keyt}) );
|
||||
$DB->set_prop('openvpn-bridge', $old2new{$keyt}, $value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user