Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enhance VPN Detection Logic and Real-Time Stream Integration
Summary:
This PR significantly improves the VPN detection logic by adding a robust and dynamic
VpnConnectionDetector
class. The changes provide a real-time stream to monitor VPN connection states and include enhanced flexibility for detecting various VPN types across platforms.Key Changes:
New
VpnConnectionDetector
Class:tun
,tap
,vpn
, etc.) to determine if a VPN is active.Real-Time VPN Connection State Stream:
vpnConnectionStream
to listen for updates on whether a VPN connection is active or disconnected.Custom VPN Pattern Support:
addVpnPattern()
method enables developers to add custom VPN interface patterns dynamically to account for unique VPN implementations.Static Method for One-Time VPN Checks:
isVpnActive()
as a static method for cases where a one-time VPN status check is needed, without subscribing to the stream.Optimized Resource Management:
dispose()
method that cleans up stream controllers, connectivity subscriptions, and timers.Extensive Documentation:
Example Usage:
Benefits:
NetworkInterface
API.Next Steps:
Looking forward to feedback and suggestions!