Class IosVpnService
- Assembly
- VpnHood.Core.Client.VpnServices.Host.Ios.dll
Represents the VPN service on iOS and tvOS: the Network Extension's packet tunnel provider, which runs the VPN service's host and answers the app over the provider's app messages.
[Register("IosVpnService")]
public class IosVpnService : NEPacketTunnelProvider, IEquatable<NSObject>, INSObjectProtocol, INativeObject, IDisposable, IVpnServiceHandler
- Inheritance
-
NSObjectNEProviderNETunnelProviderNEPacketTunnelProviderIosVpnService
- Implements
-
IEquatable<NSObject>INSObjectProtocolINativeObject
- Inherited Members
-
NEPacketTunnelProvider.CancelTunnel(NSError)NEPacketTunnelProvider.CreateUdpSession(NWEndpoint, NWHostEndpoint)NEPacketTunnelProvider.StartTunnelAsync(NSDictionary<NSString, NSObject>)NEPacketTunnelProvider.StopTunnelAsync(NEProviderStopReason)NEPacketTunnelProvider.ClassHandleNEPacketTunnelProvider.PacketFlowNEPacketTunnelProvider.VirtualInterfaceNETunnelProvider.HandleAppMessageAsync(NSData)NETunnelProvider.SetTunnelNetworkSettingsAsync(NETunnelNetworkSettings)NETunnelProvider.AppRulesNETunnelProvider.ProtocolConfigurationNETunnelProvider.ReassertingNETunnelProvider.RoutingMethodNEProvider.CreateUdpSessionToEndpoint(NWEndpoint, NWHostEndpoint)NEProvider.SleepAsync()NEProvider.Wake()NEProvider.DefaultPathNSObject.PlatformAssemblyNSObject.Dispose()NSObject.ConformsToProtocol(NativeHandle)NSObject.DangerousRelease()NSObject.DangerousRetain()NSObject.DangerousAutorelease()NSObject.BeginInvokeOnMainThread(Selector, NSObject)NSObject.InvokeOnMainThread(Selector, NSObject)NSObject.SetValueForKeyPath(NativeHandle, NSString)NSObject.GetHashCode()NSObject.Equals(NSObject)NSObject.ToString()NSObject.AwakeFromNib()NSObject.CancelPreviousPerformRequest(NSObject)NSObject.CancelPreviousPerformRequest(NSObject, Selector, NSObject)NSObject.Copy()NSObject.DidChange(NSKeyValueChange, NSIndexSet, NSString)NSObject.DidChange(NSString, NSKeyValueSetMutationKind, NSSet)NSObject.DoesNotRecognizeSelector(Selector)NSObject.GetDictionaryOfValuesFromKeys(NSString[])NSObject.GetKeyPathsForValuesAffecting(NSString)NSObject.GetMethodForSelector(Selector)NSObject.MutableCopy()NSObject.PerformSelector(Selector)NSObject.PerformSelector(Selector, NSObject)NSObject.PerformSelector(Selector, NSObject, NSObject)NSObject.PrepareForInterfaceBuilder()NSObject.RemoveObserver(NSObject, NSString)NSObject.SetNilValueForKey(NSString)NSObject.SetValueForKey(NSObject, NSString)NSObject.SetValueForKeyPath(NSObject, NSString)NSObject.SetValueForUndefinedKey(NSObject, NSString)NSObject.SetValuesForKeysWithDictionary(NSDictionary)NSObject.ValueForKey(NSString)NSObject.ValueForKeyPath(NSString)NSObject.ValueForUndefinedKey(NSString)NSObject.WillChange(NSKeyValueChange, NSIndexSet, NSString)NSObject.WillChange(NSString, NSKeyValueSetMutationKind, NSSet)NSObject.AccessibilityAttributedUserInputLabelsNSObject.AccessibilityRespondsToUserInteractionNSObject.AccessibilityTextualContextNSObject.AccessibilityUserInputLabelsNSObject.DebugDescriptionNSObject.DescriptionNSObject.RetainCountNSObject.ChangeIndexesKeyNSObject.ChangeKindKeyNSObject.ChangeNewKeyNSObject.ChangeNotificationIsPriorKeyNSObject.ChangeOldKey
Remarks
An extension subclasses it in its own assembly and registers the subclass under the name its Info.plist gives in
NSExtensionPrincipalClass, as the heads' PacketTunnelProvider does: under CoreCLR's registrar, an
Info.plist that names IosVpnService itself crashes the extension at its launch, as nothing of the extension's
own loads this assembly.
Constructors
IosVpnService(NativeHandle)
Initializes a new instance of the IosVpnService class, as the .NET iOS runtime makes it for the extension's Objective-C object.
protected IosVpnService(NativeHandle handle)
Parameters
handleNativeHandleThe Objective-C object's handle.
Remarks
It first sends .NET's console output to nothing, as an extension has no reader of its standard output and a write would block once the pipe fills, then adds Apple's unified log (os_log) as the log's sink, under the extension's bundle identifier.
Properties
CanReconnect
Gets a value indicating whether the service may connect again by itself, with no start from the app or the system: false where only the system's start may bring an adapter up.
public bool CanReconnect { get; }
Property Value
Remarks
The extension's tunnel outlives an adapter: a new one applies its settings to it anew.
Methods
CreateAdapter(VpnAdapterSettings, string?)
Makes the VPN adapter for a connection.
public IVpnAdapter CreateAdapter(VpnAdapterSettings adapterSettings, string? debugData)
Parameters
adapterSettingsVpnAdapterSettingsThe adapter's settings.
debugDatastringThe developer's debug switches (DebugData1), or null.
Returns
- IVpnAdapter
The adapter, which the client disposes with itself where AutoDisposeVpnAdapter says so, the default.
Remarks
It is IosTun's, on this provider, and completes the tunnel's start for iOS once its settings apply. Where debug logging is on, it also starts the memory diagnostics.
Exceptions
- InvalidOperationException
Windows has given the VPN plug-in no channel yet.
- ArgumentOutOfRangeException
The settings' queue capacity is less than 1.
CreateClientFactory()
Names the factory that builds the VpnHoodClient for each connection. Return VpnHoodClientFactory for the default composition, or a derived factory to replace a single piece (filters, proxy connector, tracker). The host calls this per connection and keeps ownership of the created client (state wiring and dispose) — the factory must not hold a reference to it.
public VpnHoodClientFactory CreateClientFactory()
Returns
- VpnHoodClientFactory
The factory.
Remarks
It is the default one.
HandleAppMessage(NSData?, Action<NSData>?)
Method that is called to handle messages from the containing app.
public override void HandleAppMessage(NSData? messageData, Action<NSData>? completionHandler)
Parameters
messageDataNSDataTo be added.
completionHandlerAction<NSData>To be added.
This parameter can be null.
Remarks
To be added.
ShowNotification(ConnectionInfo, CancellationToken)
Shows or updates the service's notification, where the platform has one.
public void ShowNotification(ConnectionInfo connectionInfo, CancellationToken cancellationToken)
Parameters
connectionInfoConnectionInfoThe connection's info.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Remarks
iOS has no foreground notification for it: it does nothing.
StartTunnel(NSDictionary<NSString, NSObject>?, Action<NSError>)
Starts the tunnel.
public override void StartTunnel(NSDictionary<NSString, NSObject>? options, Action<NSError> startTunnelCompletionHandler)
Parameters
optionsNSDictionary<NSString, NSObject>To be added.
This parameter can be null.
startTunnelCompletionHandlerAction<NSError>The handler that tells iOS the start's outcome: null, or the error it failed with.
Remarks
To be added.
Exceptions
- InvalidOperationException
The VPN service's folder, from an older app's configuration, has no parent folder.
StopNotification()
Removes the service's notification, where the platform has one.
public void StopNotification()
Remarks
iOS has no foreground notification for it: it does nothing.
StopSelf()
Ends the service itself, once its connection has ended with no other to follow.
public void StopSelf()
Remarks
It cancels the tunnel from the provider's side.
StopTunnel(NEProviderStopReason, Action)
Stops the Tunnel.
public override void StopTunnel(NEProviderStopReason reason, Action completionHandler)
Parameters
reasonNEProviderStopReasonTo be added.
completionHandlerActionTo be added.
Remarks
To be added.