Add OpenVPN clients endpoint

This commit is contained in:
litoral05
2026-05-05 11:52:21 +01:00
parent 4355f78986
commit 072d82e185
2 changed files with 43 additions and 0 deletions
@@ -0,0 +1,20 @@
package com.litoralregas.openvpn.openvpn;
import com.litoralregas.openvpn.ssh.SshCommandResult;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/openvpn")
public class OpenVpnController {
private final OpenVpnService service;
public OpenVpnController(OpenVpnService service) {
this.service = service;
}
@GetMapping("/clients")
public SshCommandResult getClients() {
return service.listClients();
}
}
@@ -0,0 +1,23 @@
package com.litoralregas.openvpn.openvpn;
import com.litoralregas.openvpn.ssh.SshCommandResult;
import com.litoralregas.openvpn.ssh.SshService;
import org.springframework.stereotype.Service;
@Service
public class OpenVpnService {
private static final String TOOLS_PATH = "/var/litoral_regas_openvpn/tools";
private final SshService sshService;
public OpenVpnService(SshService sshService) {
this.sshService = sshService;
}
public SshCommandResult listClients() {
return sshService.executeOnConfiguredVps(
TOOLS_PATH + "/list-clients.sh"
);
}
}