Apply WireGuard peers to VPS safely

This commit is contained in:
litoral05
2026-05-07 15:10:09 +01:00
parent f93a4c8402
commit 8b849e6560
11 changed files with 309 additions and 0 deletions
@@ -44,4 +44,25 @@ public class WireGuardVpsService {
return ips;
}
public WireGuardPeerApplyResult applyPeer(String publicKey, String allowedIps) {
String command = """
sudo /usr/local/sbin/lr-wg-add-peer '%s' '%s'
""".formatted(publicKey, allowedIps);
SshCommandResult result = sshService.executeOnConfiguredVps(command);
if (result.exitCode() != 0) {
throw new SshCommandException(
"Failed to apply WireGuard peer: " + result.stderr()
);
}
return new WireGuardPeerApplyResult(
publicKey,
allowedIps,
true
);
}
}