Installation
composer require mrclln/wire-sileo
Publish the config file (if available):
php artisan vendor:publish --provider="Mrclln\WireSileo\WireSileoServiceProvider"
Basic Usage
The package appears to be a wrapper for interacting with WireGuard via the sileo CLI tool (likely for iOS management). Start by inspecting the WireSileo facade or service container binding:
use Mrclln\WireSileo\Facades\WireSileo;
// Example: Check WireGuard status (hypothetical method)
$status = WireSileo::status();
First Use Case
// Enable/disable a tunnel (example)
WireSileo::enableTunnel('my-tunnel');
WireSileo::disableTunnel('my-tunnel');
$config = WireSileo::getConfig('tunnel-name');
WireSileo::setConfig('tunnel-name', $newConfig);
Where to Look First
app/WireSileo.php or Mrclln\WireSileo\Facades\WireSileo.WireSileoServiceProvider for bindings and boot logic.src/ directory for methods like execute(), runCommand(), or parseOutput().Command Execution
The package likely wraps sileo CLI commands. Follow this pattern:
// Hypothetical: Run a raw sileo command
$output = WireSileo::run('tunnel list');
$tunnels = WireSileo::parseTunnels($output);
Configuration Management
getConfig()/setConfig() to sync Laravel config with WireGuard.
$config = WireSileo::getConfig('vpn-tunnel');
config(['wireguard.tunnels.vpn-tunnel' => $config]);
PrivateKey).Event-Driven Integration
WireGuardTunnelUpdated) when configs change.
WireSileo::setConfig('tunnel', $data)->then(function () {
event(new TunnelUpdated($data));
});
Http client to notify external services.Artisan Commands Create custom Artisan commands to interact with WireGuard:
php artisan wireguard:status
php artisan wireguard:enable my-tunnel
config/wireguard.php:
'tunnels' => [
'vpn-tunnel' => [
'PrivateKey' => env('WIREGUARD_PRIVATE_KEY'),
'Peers' => [...],
],
],
.env for sensitive data:
WIREGUARD_SILEO_PATH=/usr/local/bin/sileo
WIREGUARD_TUNNELS=vpn-tunnel,backup-tunnel
Log facade for debugging:
Log::debug('WireGuard command output:', ['output' => $output]);
CLI Dependency
sileo being installed and in $PATH.
Fix: Validate the binary exists in WireSileoServiceProvider:
if (!file_exists('/usr/local/bin/sileo')) {
throw new \RuntimeException('sileo CLI not found. Install it first.');
}
Artisan::call() to check the binary path dynamically.Output Parsing
sileo CLI output may be unstructured (e.g., JSON vs. plaintext).
Fix: Implement a parser in WireSileo:
protected function parseOutput(string $output): array
{
return json_decode($output, true) ?: $this->fallbackParse($output);
}
Permissions
sudo or specific user permissions.
Fix: Use Laravel’s Process facade with sudo:
use Symfony\Component\Process\Process;
$process = new Process(['sudo', 'sileo', 'tunnel', 'enable', 'tunnel-name']);
Error Handling
sileo commands exit non-zero.
Fix: Throw exceptions or log errors:
$process = Process::fromShellCommandline('sileo tunnel enable my-tunnel');
$process->run();
if (!$process->isSuccessful()) {
throw new \RuntimeException($process->getErrorOutput());
}
Verbose Mode
Add a --verbose flag to commands:
public function run(string $command, bool $verbose = false): string
{
$args = $verbose ? ['--verbose'] : [];
return Process::fromShellCommandline("sileo {$command} " . implode(' ', $args))
->getOutput();
}
Logging Commands
Log all executed commands to storage/logs/wireguard.log:
Log::channel('wireguard')->info('Executing: sileo ' . $command);
Testing
Process mock in tests:
$mock = Mockery::mock(Process::class);
$mock->shouldReceive('run')->andReturn(new ProcessResult(0, 'Success', ''));
$this->app->instance(Process::class, $mock);
Custom Commands
Extend the package by adding methods to WireSileo:
public function generateKey(): string
{
return Process::fromShellCommandline('sileo key generate')->getOutput();
}
Event System Dispatch events for tunnel lifecycle:
// In WireSileo.php
event(new TunnelEnabled($tunnelName));
API Wrapper
If sileo has a REST API, create a WireSileoApi class to abstract HTTP calls:
public function getTunnels(): array
{
return Http::post('http://localhost:8080/api/tunnels')->json();
}
Queue Jobs Offload long-running commands (e.g., config sync) to queues:
SyncWireGuardConfig::dispatch($tunnelName)->onQueue('wireguard');
How can I help you explore Laravel packages today?