Commit 7f208845 by César Galvis

feat: generate client.conf file for wireguard

parent 11270155
...@@ -19,7 +19,8 @@ Start-Sleep -Seconds 10 ...@@ -19,7 +19,8 @@ Start-Sleep -Seconds 10
$wgPath = "C:\Program Files\WireGuard" $wgPath = "C:\Program Files\WireGuard"
$configPath = "$wgPath\Configurations" $configPath = "$wgPath\Configurations"
$serverConfigFile = "$configPath\server.conf" $serverConfigFile = "$configPath\server.conf"
$outputPath = "C:\vagrant\files\wireguard" $outputPath = "C:\vagrant\files\WireGuard"
$clientConfigFile = "$outputPath\client.conf"
# Create configuration and output folders if it doesn't exist # Create configuration and output folders if it doesn't exist
New-Item -ItemType Directory -Force -Path $configPath New-Item -ItemType Directory -Force -Path $configPath
...@@ -56,6 +57,19 @@ PublicKey = $clientPublicKey ...@@ -56,6 +57,19 @@ PublicKey = $clientPublicKey
AllowedIPs = 10.10.0.2/32 AllowedIPs = 10.10.0.2/32
"@ | Out-File $serverConfigFile -Encoding ascii "@ | Out-File $serverConfigFile -Encoding ascii
# Create the WireGuard client configuration
@"
[Interface]
PrivateKey = $clientPrivateKey
Address = 10.10.0.2/24
[Peer]
PublicKey = $serverPublicKey
Endpoint = windows-vpn.local:51820
AllowedIPs = 192.168.11.0/24
PersistentKeepalive = 25
"@ | Out-File $clientConfigFile -Encoding ascii
# Install the tunnel as a Windows service # Install the tunnel as a Windows service
& "$wgPath\wireguard.exe" /installtunnelservice $serverConfigFile & "$wgPath\wireguard.exe" /installtunnelservice $serverConfigFile
...@@ -66,6 +80,7 @@ New-NetFirewallRule -DisplayName "WireGuard VPN" -Direction Inbound -Action Allo ...@@ -66,6 +80,7 @@ New-NetFirewallRule -DisplayName "WireGuard VPN" -Direction Inbound -Action Allo
# Output server info # Output server info
Write-Host "WireGuard server has been configured and started." Write-Host "WireGuard server has been configured and started."
Write-Host "Keys saved to: $outputPath\generated-keys.json" Write-Host "Keys saved to: $outputPath\generated-keys.json"
Write-Host "Client config saved to: $outputPath\client.conf"
# Add shortcuts # Add shortcuts
## Get the desktop path for the current user ## Get the desktop path for the current user
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment