SpeedifyPacketTunnel

@objc
public class SpeedifyPacketTunnel : NSObject
extension SpeedifyPacketTunnel: MXMetricManagerSubscriber
  • Singleton of the SpeedifyPacketTunnel

    Declaration

    Swift

    @objc
    public static var sharedInstance: SpeedifyPacketTunnel
  • Declaration

    Swift

    public var safeBrowsingBlockDelegate: PacketTunnelSafeBrowsingBlockDelegate?
  • Declaration

    Swift

    public var currentState: Int
  • runDaemon

    Declaration

    Swift

    @available(*, deprecated, message: "Use runDaemon(in port: Int, provider: NEPacketTunnelProvider,  options: [String : NSObject]?, connectWithHandler: Bool, completionHandler: @escaping (Error?﹚-> Void﹚")
    public func runDaemon(in port: Int, provider: NEPacketTunnelProvider, connectWithHandler: Bool, completionHandler: @escaping (Error?) -> Void)

    Parameters

    port

    Port used for websocket communication with the SpeedifySDK service

    provider

    The principal class for a packet tunnel provider app extension. This should always be self of the users implementation of the PacketTunnelProvider

    connectWithHandler

    Tells the tunnel to connect right away or wait for Speedify. Default should be false

    completionHandler

    A block that must be executed when the tunnel is fully established, or when the tunnel cannot be started due to an error. If the tunnel was successfully established, then the error parameter must be set to nil. If an error occurred, the error parameter passed to this block must be set to a non-nil NSError object.

  • runDaemon

    Declaration

    Swift

    @available(*, deprecated, message: "Use runDaemon(in port: Int, provider: NEPacketTunnelProvider, connectWithHandler: Bool, completionHandler: @escaping (Error?﹚-> Void﹚")
    public func runDaemon(in port: Int, provider: NEPacketTunnelProvider, currentDefaults: UserDefaults, connectWithHandler: Bool, completionHandler: @escaping (Error?) -> Void)

    Parameters

    port

    Port used for websocket communication with the SpeedifySDK service

    provider

    The principal class for a packet tunnel provider app extension. This should always be self of the users implementation of the PacketTunnelProvider

    currentDefaults

    User preferences that Speedify can read. NOTE: If you would like to connect to a speed server from the settings app on a device you MUST pass in a security group default and the same default must be used in the containing application

    connectWithHandler

    Tells the tunnel to connect right away or wait for Speedify. Default should be false

    completionHandler

    A block that must be executed when the tunnel is fully established, or when the tunnel cannot be started due to an error. If the tunnel was successfully established, then the error parameter must be set to nil. If an error occurred, the error parameter passed to this block must be set to a non-nil NSError object.

  • runDaemon

    Declaration

    Swift

    public func runDaemon(in port: Int, provider: NEPacketTunnelProvider, options: [String : NSObject]?, connectWithHandler: Bool, completionHandler: @escaping (Error?) -> Void)

    Parameters

    port

    Port used for websocket communication with the SpeedifySDK service

    provider

    The principal class for a packet tunnel provider app extension. This should always be self of the users implementation of the PacketTunnelProvider

    options

    User options passed in when starting a tunnel. These options should be passed from a users implemenation of PacketTunnelPrivider.swift so the SDK can ingest these options from the container

    connectWithHandler

    Tells the tunnel to connect right away or wait for Speedify. Default should be false

    completionHandler

    A block that must be executed when the tunnel is fully established, or when the tunnel cannot be started due to an error. If the tunnel was successfully established, then the error parameter must be set to nil. If an error occurred, the error parameter passed to this block must be set to a non-nil NSError object.

  • Add this inside of the willWake() delegate of the Parent Provider https://developer.apple.com/documentation/networkextension/neprovider/1406543-wake

    Declaration

    Swift

    public func willWake()
  • Add this inside of t.he sleep(completionHandler: @escaping () -> Void) delegate of the Parent Provider https://developer.apple.com/documentation/networkextension/neprovider/1406731-sleep

    Declaration

    Swift

    public func willSleep()
  • tunnelWillStop

    Declaration

    Swift

    public func tunnelWillStop(with reason: NEProviderStopReason, completionHandler: ((Bool) -> Void)?)

    Parameters

    completionHandler

    An optional block passed in from PacketTunnel provider that will be called to signal the tunnel has stopped. The Bool indicates whether the daemon confirmed it stopped cleanly on macOS (on iOS it is always true, since iOS doesn’t call exitDaemon). Callers on macOS use this to decide whether it is safe to force-exit the extension process. https://developer.apple.com/documentation/networkextension/nepackettunnelprovider/1406192-stoptunnel

  • handleCallBackResponse

    Declaration

    Swift

    public func handleCallBackResponse(_ message: String) -> Data

    Parameters

    message

    A string to send to the daemon process.

    Return Value

    Data returned from the daemon process.

  • Declaration

    Swift

    public func sendExtMessage(command: String?, returnMessages: Bool) -> Data
  • Declaration

    Swift

    public func setupMetricKit()
  • Declaration

    Swift

    public func didReceive(_ payloads: [MXMetricPayload])
  • Posted in the extension process once Clear Settings has emptied settingsDirectory(). The extension target owns the stderr redirect and listens for this so it can reopen its log; this framework can’t reach Logger to do it here.

    Declaration

    Swift

    public static let daemonSettingsWiped: Notification.Name
  • Where the daemon keeps sql.db: the private data path, one level ABOVE the settings directory — SpeedifyDb::Init moves the database here.

    Declaration

    Swift

    public static func privateDataDirectory() -> String
  • Where the daemon keeps its persistent data — settings, VERSION, logs. Must stay in step with discoverPersistentDataPath() on the C++ side.

    Declaration

    Swift

    public static func settingsDirectory() -> String
  • The daemon’s persisted state — not logs or VERSION, which are diagnostics and get rewritten. Anything left here is picked straight back up when the daemon restarts.

    macOS layout only, and the settings half is what makes it so: on iOS the daemon’s persistent path is Speedify, not the Speedify used here, so those six paths would miss. The four sql.db paths, however, resolve to a real iOS location and WOULD delete the live statistics database. Fix the settings path before adding an iOS caller, and do not assume this list is inert there.

    Declaration

    Swift

    public static func daemonStatePaths() -> [String]
  • Deletes daemonStatePaths(). Returns the paths that were still there afterwards so callers can report a partial wipe rather than claim success.

    Declaration

    Swift

    public static func wipeDaemonState() -> [String]
  • Tests must use this overload, never wipeDaemonState() — the latter resolves real container paths and on a dev machine that is your own installed Speedify’s settings and usage history.

    Declaration

    Swift

    public static func wipeDaemonState(paths: [String]) -> [String]