initial commit of file from CVS for smeserver-wireguard on Sat Sep 7 16:45:37 AEST 2024
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# wireguard specific configuration
|
||||
{
|
||||
$wg = $wireguard{status} || 'disabled';
|
||||
$wg0 = ${'wg-quick@wg0'}{status} || 'disabled';
|
||||
if ($wg0 eq 'enabled') {
|
||||
$OUT .= "enable wg-quick\@wg0.service\n";
|
||||
} else {
|
||||
$OUT .= "disable wg-quick\@wg0.service\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
{${'wg-quick@wg0'}{private};}
|
@@ -0,0 +1,8 @@
|
||||
{
|
||||
use esmith::templates;
|
||||
esmith::templates::processTemplate({
|
||||
TEMPLATE_PATH => "/etc/wireguard/server_private.key"
|
||||
});
|
||||
${'wg-quick@wg0'}{public};
|
||||
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
[Interface]
|
||||
Address = { ${'wg-quick@wg0'}{ip} . '/' . ${'wg-quick@wg0'}{mask}}
|
||||
ListenPort = {${'wg-quick@wg0'}{UDPPort} || '51820' }
|
||||
PrivateKey = {${'wg-quick@wg0'}{private}}
|
||||
|
||||
# this is not needed as we define vpn network as lan in network db
|
||||
# furthermore masquerading postrouting will also mess up with any openvpn-s2s vpn
|
||||
#PostUp = iptables -I FORWARD -i %i -j ACCEPT; iptables -I FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o {$outernet = ($SystemMode eq "serveronly") ? $InternalInterface{Name} : $ExternalInterface{Name}; return $InternalInterface{Name} } -j MASQUERADE
|
||||
#PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o {$outernet = ($SystemMode eq "serveronly") ? $InternalInterface{Name} : $ExternalInterface{Name}; return $InternalInterface{Name} } -j MASQUERADE
|
||||
|
@@ -0,0 +1,36 @@
|
||||
{
|
||||
use esmith::AccountsDB;
|
||||
|
||||
my $wg = esmith::ConfigDB->open_ro('/home/e-smith/db/wireguard');
|
||||
my $accounts = esmith::AccountsDB->open_ro;
|
||||
|
||||
# for each user
|
||||
my @users = ( $accounts->users );
|
||||
push(@users, $accounts->get('admin'));
|
||||
for my $user ( @users ) {
|
||||
my $username = $user->key;
|
||||
my $count = 0;
|
||||
for my $cnx ( $wg->get_all_by_prop(user => $username) ) {
|
||||
$count++;
|
||||
my $public = $cnx->prop('public');
|
||||
my $ip = $cnx->key;
|
||||
my $info = $cnx->prop('info');
|
||||
my $status = $cnx->prop('status') || "enabled";
|
||||
if ( $status eq "disabled" ) {
|
||||
$OUT .= "\n# $username : $info DISABLED (PublicKey = $public ; AllowedIPs = $ip)\n";
|
||||
next;
|
||||
}
|
||||
|
||||
$OUT .= "
|
||||
[Peer]
|
||||
# $username : $info
|
||||
PublicKey = $public
|
||||
AllowedIPs = $ip\n";
|
||||
|
||||
|
||||
}
|
||||
$OUT .= "# no entry for user $username\n" if $count <1;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user