안드로이드, iOS, 맥OS, 윈도우, 리눅스에서 네이티브 플랫폼 API를 사용하여 VPN 연결을 감지하는 플러터 패키지입니다. 실시간으로 VPN 상태 변경 사항을 스트리밍하며 현재 연결 상태를 확인하기 위한 일회성 체크도 지원합니다. 보안 도구, 네트워크 인식 애플리케이션 또는 프라이버시 중심 서비스와 같은 VPN 사용을 모니터링하거나 반응해야 하는 앱을 위해 설계되었습니다. 최소한의 설정으로 다양한 플랫폼 간 신뢰할 수 있는 감지를 보장합니다.
사용 사례
활성 VPN 연결 모니터링
네트워크 보안 검사 구현
개인 정보 보호 중심 앱 개발
실시간으로 연결 변경 감지
네트워크 정책 준수 보장
주요 기능
실시간 상태 스트리밍
일회성 연결 확인
다중 플랫폼 지원 (Android, iOS, macOS, Windows, Linux)
네이티브 플랫폼 통합
상태 모니터링을 위한 간단한 API
적합한 대상
보안 및 개인정보 보호 애플리케이션
네트워크 인식 모바일 앱
실시간 연결성 인사이트가 필요한 앱
다중 플랫폼을 대상으로 하는 개발자
VPN 사용을 감지해야 하는 도구
고려 사항
플랫폼별 권한이 필요합니다
모든 사용자 지정 또는 제3자 VPN을 감지하지 못할 수 있습니다
플랫폼 간에 동작이 약간 다를 수 있습니다
활성 VPN 상태 감지에 한정되며, 세부 구성은 포함되지 않음
원시 구현의 신뢰성에 달려 있음
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
VPN Connection Detector
The most accurate VPN detection package for Flutter — with native iOS & Android implementations that detect both system-configured VPNs and third-party VPN apps like NordVPN, ExpressVPN, ProtonVPN, and more.
Why This Package?
Most VPN detection solutions only check for system-configured VPNs, missing the majority of users who use third-party VPN apps. This package uses platform-native APIs to detect VPNs with ~95% accuracy:
// Check if VPN is currently activebool isVpnConnected = awaitVpnConnectionDetector.isVpnActive();
if (isVpnConnected) {
print('VPN is connected');
} else {
print('VPN is not connected');
}
Real-time VPN Status Stream
final vpnDetector = VpnConnectionDetector();
// Listen to VPN status changes
vpnDetector.vpnConnectionStream.listen((state) {
switch (state) {
caseVpnConnectionState.connected:
print('VPN connected');
break;
caseVpnConnectionState.disconnected:
print('VPN disconnected');
break;
}
});
// Don't forget to dispose when done
vpnDetector.dispose();
Get Detailed VPN Information
final info = awaitVpnConnectionDetector.getVpnInfo();
if (info != null && info.isConnected) {
print('VPN Connected');
print('Interface: ${info.interfaceName}'); // e.g., 'utun3', 'tun0'print('Protocol: ${info.vpnProtocol}'); // e.g., 'WireGuard', 'IKEv2'
}
Access Current Cached State
final vpnDetector = VpnConnectionDetector();
// Get the last known state (may be null if not yet determined)final currentState = vpnDetector.currentState;
print('Current state: ${currentState?.name ?? "unknown"}');
API Reference
VpnConnectionDetector
Method/Property
Type
Description
isVpnActive()
static Future<bool>
One-time check if VPN is active
getVpnInfo()
static Future<VpnInfo?>
Get detailed VPN information
vpnConnectionStream
Stream<VpnConnectionState>
Real-time status stream
currentState
VpnConnectionState?
Last known VPN state
dispose()
void
Clean up resources
VpnConnectionState
enumVpnConnectionState {
connected, // VPN is currently connected
disconnected, // VPN is currently disconnected
}
Version 2.0 introduces native platform support with a cleaner API:
// v1.x (still works)final isActive = awaitVpnConnectionDetector.isVpnActive();
final detector = VpnConnectionDetector();
detector.vpnConnectionStream.listen((state) { ... });
// v2.0 (new features)final info = awaitVpnConnectionDetector.getVpnInfo();
print('Protocol: ${info?.vpnProtocol}');
Breaking changes:
Minimum iOS version: 12.0
Minimum Android SDK: 21
Removed web platform support (not possible to detect VPN in browsers)
How It Works
iOS
VPN detection: Uses CFNetworkCopySystemProxySettings to inspect the __SCOPED__ dictionary, which only contains active VPN network interfaces — this reliably detects both system-configured VPNs and third-party apps like NordVPN, ExpressVPN, ProtonVPN, Surfshark, etc.
Real-time monitoring: Uses NWPathMonitor to detect network changes and re-evaluate VPN status
App Store safe: Does not use NEVPNManager or any APIs that require the Network Extension entitlement
Android
Uses ConnectivityManager with NetworkCapabilities.TRANSPORT_VPN for accurate VPN detection on API 23+. This detects all VPN connections regardless of the VPN app used.
Desktop (Fallback)
Inspects network interface names for common VPN patterns (tun, tap, ppp, wireguard, etc.).
Contributing
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.