Sync wireguard rules uses internal jumps if they are available
This commit is contained in:
@@ -27,11 +27,16 @@ class SyncWireguardRules
|
||||
$output = $result->getOutput();
|
||||
$commands = collect();
|
||||
|
||||
$server->organisation->servers()->where('id', '!=', $server->id)->each(function ($organisationServer) use (&$commands, $output) {
|
||||
$server->organisation->servers()->where('id', '!=', $server->id)->each(function ($organisationServer) use (&$commands, $output, $server) {
|
||||
if (Str::contains($output, $organisationServer->internal_public_key)) {
|
||||
$commands->push("wg set wg0 peer {$organisationServer->internal_public_key} remove");
|
||||
}
|
||||
|
||||
if ($organisationServer->external_network_id === $server->external_network_id) {
|
||||
$commands->push("wg set wg0 peer {$organisationServer->internal_public_key} allowed-ips {$organisationServer->internal_ip}/32");
|
||||
} else {
|
||||
$commands->push("wg set wg0 peer {$organisationServer->internal_public_key} allowed-ips {$organisationServer->ipv4}/32,{$organisationServer->ipv6}/128");
|
||||
}
|
||||
});
|
||||
|
||||
$result = $ssh->execute($commands->toArray());
|
||||
|
||||
@@ -15,6 +15,7 @@ class Provider extends Model
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $hidden = ['token'];
|
||||
|
||||
protected function casts(): array
|
||||
|
||||
@@ -43,7 +43,7 @@ class DatabaseSeeder extends Seeder
|
||||
'name' => 'keystone',
|
||||
'external_id' => 'net-12345',
|
||||
'provider_id' => $provider->id,
|
||||
'ip_range' => fake()->ipv4() . '/24',
|
||||
'ip_range' => fake()->ipv4().'/24',
|
||||
]);
|
||||
|
||||
$servers = Server::factory(40)
|
||||
|
||||
@@ -35,7 +35,7 @@ const props = defineProps({
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid gap-4 rounded-xl p-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
<Card v-for="application in applications.data" :key="`application{$applications.id}`" class="relative w-full">
|
||||
<Card v-for="application in applications" :key="`application{$applications.id}`" class="relative w-full">
|
||||
<CardHeader>
|
||||
<CardTitle>{{ application.name }}</CardTitle>
|
||||
</CardHeader>
|
||||
|
||||
Reference in New Issue
Block a user