68 lines
2.7 KiB
Python
68 lines
2.7 KiB
Python
"""VPN status tools: OpenVPN, IPsec, WireGuard (plugin)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
from mcp.server.fastmcp import FastMCP
|
|
|
|
from pfsense_mcp.client import get_client
|
|
|
|
|
|
def register(mcp: FastMCP) -> None:
|
|
@mcp.tool()
|
|
def pfsense_get_openvpn_status() -> str:
|
|
"""Get OpenVPN server/client status with connected clients."""
|
|
client = get_client()
|
|
result = client.get("status/openvpn/servers")
|
|
return json.dumps(result, indent=2, default=str)
|
|
|
|
@mcp.tool()
|
|
def pfsense_list_openvpn_servers(limit: int = 50, offset: int = 0) -> str:
|
|
"""List OpenVPN server configurations."""
|
|
client = get_client()
|
|
result = client.get("vpn/openvpn/servers", params={"limit": limit, "offset": offset})
|
|
return json.dumps(result, indent=2, default=str)
|
|
|
|
@mcp.tool()
|
|
def pfsense_list_openvpn_clients(limit: int = 50, offset: int = 0) -> str:
|
|
"""List OpenVPN client configurations."""
|
|
client = get_client()
|
|
result = client.get("vpn/openvpn/clients", params={"limit": limit, "offset": offset})
|
|
return json.dumps(result, indent=2, default=str)
|
|
|
|
@mcp.tool()
|
|
def pfsense_get_ipsec_status() -> str:
|
|
"""Get IPsec tunnel status (phase 1/2 SAs)."""
|
|
client = get_client()
|
|
result = client.get("status/ipsec/sas")
|
|
return json.dumps(result, indent=2, default=str)
|
|
|
|
@mcp.tool()
|
|
def pfsense_list_ipsec_phase1(limit: int = 50, offset: int = 0) -> str:
|
|
"""List configured IPsec phase 1 entries."""
|
|
client = get_client()
|
|
result = client.get("vpn/ipsec/phase1s", params={"limit": limit, "offset": offset})
|
|
return json.dumps(result, indent=2, default=str)
|
|
|
|
@mcp.tool()
|
|
def pfsense_get_wireguard_status() -> str:
|
|
"""Get WireGuard status (requires the WireGuard package to be installed)."""
|
|
client = get_client()
|
|
result = client.get("vpn/wireguard/settings")
|
|
return json.dumps(result, indent=2, default=str)
|
|
|
|
@mcp.tool()
|
|
def pfsense_list_wireguard_tunnels(limit: int = 50, offset: int = 0) -> str:
|
|
"""List WireGuard tunnels (requires the WireGuard package)."""
|
|
client = get_client()
|
|
result = client.get("vpn/wireguard/tunnels", params={"limit": limit, "offset": offset})
|
|
return json.dumps(result, indent=2, default=str)
|
|
|
|
@mcp.tool()
|
|
def pfsense_list_wireguard_peers(limit: int = 100, offset: int = 0) -> str:
|
|
"""List WireGuard peers (requires the WireGuard package)."""
|
|
client = get_client()
|
|
result = client.get("vpn/wireguard/peers", params={"limit": limit, "offset": offset})
|
|
return json.dumps(result, indent=2, default=str)
|