windows_sstp_vpn
A lightning-fast, native Windows MS-SSTP routing engine for Flutter.
This package bridges your Dart code directly into the Windows OS rasdial and PowerShell system APIs, allowing you to establish genuine VPN tunnels programmatically without requiring any C++ boilerplate or third-party OpenVPN TAP driver installations.
Features
- Zero Dependencies: Relies entirely on native Windows OS PowerShell commands and
rasdial. - TCP Pre-Check: Includes a fast concurrent socket scanner method to verify port 443 before attempting to dial, avoiding the agonizing 60-second Windows CLI timeout hangs on dead servers.
- SSTP Protocol: Harnesses the natively integrated Windows Secure Socket Tunneling Protocol (SSTP) for maximum out-of-the-box compatibility on modern Windows machines.
- No Elevated Prompt popups: Uses silent background processing to seamlessly map the profile into the user's OS without intrusive popups.
Getting Started
In your pubspec.yaml file, add:
dependencies:
windows_sstp_vpn: ^1.0.0
Usage
Below is a complete example of how to configure, pre-check, and dial a VPN connection securely.
import 'package:windows_sstp_vpn/windows_sstp_vpn.dart';
// 1. Create a server configuration
final config = VpnServerConfig(
hostName: "public-vpn-90.opengw.net", // MUST be a hostname to avoid Windows SSL Errors, do not use raw IPs
username: "vpn",
password: "vpn",
profileName: "MyCustomVPN" // The name that will appear in Windows Network Settings
);
// 2. Optional: Fast check to ensure the server port isn't blocked (avoids rasdial 60s freeze)
print("Checking server health...");
bool isPortOpen = await WindowsSstpEngine.pingSstpPort(config.hostName);
if (isPortOpen) {
// 3. Connect to the Windows VPN natively
print("Dialing VPN natively...");
bool connected = await WindowsSstpEngine.connect(config);
if (connected) {
print("Tunnel established! Traffic is now encrypted.");
} else {
print("Failed to establish tunnel.");
}
} else {
print("Server is offline or blocking traffic. Try another server.");
}
// 4. Disconnect and clean up the profile seamlessly from the OS
await WindowsSstpEngine.disconnect(profileName: "MyCustomVPN");
Setup & Native Requirements
- Operating System: Windows 10 / 11
- Target Platform: Windows Desktop (
flutter create -d windows) - Hostname rule: When connecting to SSTP, always provide the fully qualified DNS hostname. Using raw IP addresses (like
1.2.3.4) will cause Windows SSL Validation to reject the connection withError 800.