Complete API documentation for VPN Hub enterprise-grade secure VPN manager.
The main interface for VPN operations.
from src.core.vpn_manager import VPNManager
# Initialize VPN Manager
vpn_manager = VPNManager()Connect to a VPN provider.
Parameters:
provider(str): Provider name ('nordvpn', 'expressvpn', 'surfshark', 'cyberghost', 'protonvpn')server(str, optional): Specific server to connect to
Returns:
bool: True if connection successful, False otherwise
Example:
# Connect to NordVPN (auto-select server)
success = await vpn_manager.connect('nordvpn')
# Connect to specific server
success = await vpn_manager.connect('nordvpn', 'us3045.nordvpn.com')Disconnect from current VPN connection.
Returns:
bool: True if disconnection successful, False otherwise
Example:
success = await vpn_manager.disconnect()Get current VPN connection status.
Returns:
Dict[str, Any]: Connection status information
Example:
status = vpn_manager.get_status()
print(f"Connected: {status['connected']}")
print(f"Provider: {status['provider']}")
print(f"Server: {status['server']}")
print(f"IP Address: {status['ip_address']}")Get list of available VPN providers.
Returns:
List[str]: List of provider names
Example:
providers = vpn_manager.list_providers()
# ['nordvpn', 'expressvpn', 'surfshark', 'cyberghost', 'protonvpn']All VPN providers implement the BaseVPNProvider interface.
from src.providers.base import BaseVPNProviderAuthenticate with the VPN provider.
Connect to the VPN service.
Disconnect from the VPN service.
Get list of available servers.
Get current connection information.
from src.providers.nordvpn import NordVPNProvider
provider = NordVPNProvider()Get recommended servers for optimal performance.
Parameters:
country(str, optional): Country code (e.g., 'US', 'UK', 'DE')
Example:
servers = await provider.get_recommended_servers('US')
for server in servers:
print(f"{server['name']} - Load: {server['load']}%")Enable NordVPN's CyberSec feature.
Example:
success = await provider.enable_cybersec()from src.providers.expressvpn import ExpressVPNProvider
provider = ExpressVPNProvider()Activate ExpressVPN license with activation code.
Parameters:
activation_code(str): License activation code
Example:
success = await provider.activate_license("ABCD-1234-EFGH-5678")Get ExpressVPN Smart Location recommendations.
Example:
locations = await provider.get_smart_locations()from src.providers.surfshark import SurfsharkProvider
provider = SurfsharkProvider()Enable Surfshark's kill switch feature.
Enable Surfshark's ad-blocking feature.
Configure split tunneling for specific applications.
Parameters:
apps(List[str]): List of application names to bypass VPN
Example:
apps_to_bypass = ['spotify.exe', 'steam.exe']
success = await provider.enable_bypasser(apps_to_bypass)from src.providers.cyberghost import CyberGhostProvider
provider = CyberGhostProvider()Get servers optimized for streaming services.
Parameters:
service(str): Streaming service ('netflix', 'hulu', 'bbc_iplayer', etc.)
Example:
netflix_servers = await provider.get_streaming_servers('netflix')Enable CyberGhost's malware blocking feature.
from src.providers.protonvpn import ProtonVPNProvider
provider = ProtonVPNProvider()Enable ProtonVPN's Secure Core feature.
Enable ProtonVPN's NetShield ad-blocking.
Connect through Tor network (Tor over VPN).
Example:
# Enable maximum security
await provider.enable_secure_core()
await provider.enable_netshield()
await provider.connect_tor()from src.security.input_sanitizer import InputSanitizer
sanitizer = InputSanitizer()Sanitize username input.
Parameters:
username(str): Raw username input
Returns:
str: Sanitized username
Raises:
ValidationError: If input is invalid
Example:
try:
clean_username = sanitizer.sanitize_username("user@domain.com")
except ValidationError as e:
print(f"Invalid username: {e}")Sanitize password input.
Sanitize server name input.
Sanitize IP address input.
from src.security.secure_command_executor import SecureCommandExecutor
executor = SecureCommandExecutor()Execute command securely with input validation.
Parameters:
command(List[str]): Command and argumentsenv_vars(Dict[str, str], optional): Environment variables
Returns:
CompletedProcess: Command execution result
Example:
result = executor.execute_command(
['nordvpn', 'connect'],
env_vars={'NORDVPN_USERNAME': username, 'NORDVPN_PASSWORD': password}
)from src.security.code_signing import CodeSigning
signer = CodeSigning()Generate digital signature for a file.
Verify digital signature of a file.
Verify integrity of all VPN Hub files.
Example:
integrity_report = signer.verify_integrity()
if integrity_report['integrity_score'] < 100:
print("File integrity compromised!")from src.config.config_manager import ConfigManager
config_manager = ConfigManager()Load current configuration.
Save configuration to file.
Get specific configuration setting.
Example:
# Get kill switch setting
kill_switch_enabled = config_manager.get_setting('network.kill_switch.enabled', False)
# Update setting
config = config_manager.load_config()
config['network']['kill_switch']['enabled'] = True
config_manager.save_config(config)Reset configuration to default values.
from src.security.credential_manager import CredentialManager
cred_manager = CredentialManager()Store credentials securely in system keyring.
Retrieve stored credentials.
Delete stored credentials.
Example:
# Store credentials
cred_manager.store_credentials('nordvpn', 'user@example.com', 'secure_password')
# Retrieve credentials
username, password = cred_manager.get_credentials('nordvpn')
# Delete credentials
cred_manager.delete_credentials('nordvpn')from src.security.security_monitor import SecurityMonitor
monitor = SecurityMonitor()Get recent security events.
Parameters:
hours(int): Number of hours to look back
Returns:
List[Dict[str, Any]]: List of security events
Example:
events = monitor.get_security_events(24)
for event in events:
print(f"{event['timestamp']}: {event['type']} - {event['description']}")Get current threat level assessment.
Returns:
str: Threat level ('LOW', 'MEDIUM', 'HIGH', 'CRITICAL')
Check if any anomalies are currently detected.
from src.monitoring.network_monitor import NetworkMonitor
net_monitor = NetworkMonitor()Check for IP address leaks.
Returns:
Dict[str, Any]: Leak detection results
Example:
leak_check = net_monitor.check_ip_leak()
if leak_check['leak_detected']:
print(f"IP Leak detected: {leak_check['leaked_ip']}")Check for DNS leaks.
Measure VPN connection speed.
Returns:
Dict[str, float]: Speed test results (download, upload, ping)
from src.utils.logger import get_logger
logger = get_logger(__name__)logger.debug(message)logger.info(message)logger.warning(message)logger.error(message)logger.critical(message)
Log security-specific events.
Example:
logger.log_security_event(
'AUTHENTICATION_FAILURE',
'Failed login attempt for user: suspicious_user',
'WARNING'
)from src.utils.encryption import encrypt_data, decrypt_data, generate_keyEncrypt data using AES-256-GCM.
Decrypt data using AES-256-GCM.
Generate a new encryption key.
Example:
# Generate key
key = generate_key()
# Encrypt sensitive data
encrypted = encrypt_data(b"sensitive_data", key)
# Decrypt data
decrypted = decrypt_data(encrypted, key)from src.exceptions import (
VPNHubException,
AuthenticationError,
ConnectionError,
ValidationError,
SecurityError,
ConfigurationError
)VPNHubException
├── AuthenticationError
├── ConnectionError
├── ValidationError
├── SecurityError
└── ConfigurationError
try:
await provider.authenticate(username, password)
except AuthenticationError as e:
logger.error(f"Authentication failed: {e}")
except ConnectionError as e:
logger.error(f"Connection failed: {e}")
except VPNHubException as e:
logger.error(f"General VPN Hub error: {e}"){
"success": bool,
"data": Any,
"error": str | None,
"timestamp": str,
"request_id": str
}{
"connected": bool,
"provider": str | None,
"server": str | None,
"ip_address": str | None,
"location": {
"country": str,
"city": str,
"coordinates": {
"lat": float,
"lng": float
}
},
"connection_time": str | None,
"protocol": str | None,
"encryption": str | None
}{
"id": str,
"timestamp": str,
"type": str,
"severity": str,
"description": str,
"source": str,
"details": Dict[str, Any]
}| Code | Description | Action |
|---|---|---|
| 1001 | Authentication Failed | Check credentials |
| 1002 | Connection Timeout | Retry connection |
| 1003 | Invalid Server | Select different server |
| 2001 | Security Violation | Review security logs |
| 2002 | Certificate Error | Update certificates |
| 3001 | Configuration Error | Check config file |
| 3002 | Permission Denied | Run with admin privileges |
| 4001 | Network Error | Check internet connection |
| 4002 | DNS Resolution Failed | Check DNS settings |
import asyncio
from src.core.vpn_manager import VPNManager
from src.security.credential_manager import CredentialManager
async def connect_vpn():
# Initialize managers
vpn_manager = VPNManager()
cred_manager = CredentialManager()
try:
# Store credentials securely
cred_manager.store_credentials(
'nordvpn',
'user@example.com',
'secure_password'
)
# Get stored credentials
username, password = cred_manager.get_credentials('nordvpn')
# Connect to VPN
success = await vpn_manager.connect('nordvpn')
if success:
status = vpn_manager.get_status()
print(f"Connected to {status['server']} in {status['location']['country']}")
else:
print("Connection failed")
except Exception as e:
print(f"Error: {e}")
# Run the example
asyncio.run(connect_vpn())from src.security.security_monitor import SecurityMonitor
from src.monitoring.network_monitor import NetworkMonitor
def security_check():
security_monitor = SecurityMonitor()
network_monitor = NetworkMonitor()
# Check threat level
threat_level = security_monitor.get_threat_level()
print(f"Current threat level: {threat_level}")
# Check for anomalies
if security_monitor.is_anomaly_detected():
print("⚠️ Security anomaly detected!")
# Check for leaks
ip_leak = network_monitor.check_ip_leak()
dns_leak = network_monitor.check_dns_leak()
if ip_leak['leak_detected']:
print(f"🚨 IP leak detected: {ip_leak['leaked_ip']}")
if dns_leak['leak_detected']:
print(f"🚨 DNS leak detected: {dns_leak['leaked_dns']}")
print("✅ Security check complete")
security_check()API Version: 2.0
Last Updated: November 1, 2025
For Support: api-support@vpnhub.local