Add OpenVPN clients endpoint
This commit is contained in:
@@ -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"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user