Speedify

public class Speedify : NSObject, SpeedifyDelegate, TunnelHelperDelegate

This is the entry point of the Speedify SDK. Initialize SpeedifySDK by using the sharedInstance property.

  • Subscribe to this delegate if you wish to be alerted when the SpeedifySDK returns the current:

    Declaration

    Swift

    open var delegate: SpeedifySDKDelegate?
  • Current AdapterData. If set to nil, no data available.

    Declaration

    Swift

    private(set) public var adapterData: [AdapterData]? { get }
  • Current ServerInformation. If set to nil, no server is connected.

    Declaration

    Swift

    private(set) public var serverInformation: ServerInformation? { get }
  • Setting to true will tell the sdk not to send any messages to the extension until it is fully connected

    Declaration

    Swift

    @objc
    public var waitUntilConnected: Bool { get set }
  • Start the PacketTunnel app extension.

    This must be called to ensure message accuracy and the ability to keep the tunnel open. This checks the app extension state for

    • Invalid
    • Disconnecting
    • Disconnected

    Upon reaching these states the function ensures the tunnel will be open. The timer fires every second to check the Tunnel State.

    Declaration

    Swift

    @objc
    public func startTunnel()
    • @method hasVPNPermissionWithCompletionHandler:
    • @discussion This function asynchronously reads all of the NETunnelProvider configurations created by the calling app that have previously been saved to disk and returns true if a configuration is found.

    Declaration

    Swift

    @objc
    public func reportVpnPermissionResult(completionHandler: @escaping (_ hasPermission: Bool, _ error: Error?) -> Void)
    • @method initializeVPNPermissionWithCompletionHandler:

    Declaration

    Swift

    @objc
    public func initializeVPNPermission(profile: String?, onDemandRules: [NEOnDemandRule]?, startTunnel: Bool, waitUntilConnected: Bool, completionHandler: @escaping (_ didSave: Bool, _ error: Error?) -> Void)
    • @method resetVpnProfileWithCompletionHandler:

    Declaration

    Swift

    @objc
    public func resetVpnProfile(completionHandler: @escaping (_ didSucceed: Bool, _ error: Error?) -> Void)
  • This will stop the test speed function if running.

    Declaration

    Swift

    @objc
    public func stopTestSpeed()
  • Connect to a server by an automatic selection method. If already connected, this will disconnect before reconnecting.

    • closest: Closest public or private server to user
    • closestPrivate: Closest private server to user
    • last: Selects the last connected server
    • p2p: Server that supports P2P/BitTorrent

    Declaration

    Swift

    public func connectAuto(connectOption: AutoConnectMethod, completionHandler: @escaping (_ serverInformation: ServerInformation?, _ error: ErrorType?) -> Void)

    Parameters

    connectOption

    Return Value

    completionHandler: ServerInformation

  • Connect to a server with a specific city. If already connected, this will disconnect before reconnecting.

    Declaration

    Swift

    public func connectByCity(country: String, city: String, completionHandler: @escaping (_ message: ServerInformation?, _ error: ErrorType?) -> Void)

    Parameters

    country

    2-character ISO country code, ie: ‘us’

    city

    City code, ie: ‘atlanta’

    Return Value

    completionHandler: ServerInformation

  • Connect to a server with a specific country. If already connected, this will disconnect before reconnecting.

    Declaration

    Swift

    public func connectByCountry(country: String, completionHandler: @escaping (_ message: ServerInformation?, _ error: ErrorType?) -> Void)

    Parameters

    country

    2-character ISO country code, ie: ‘us’.

    Return Value

    completionHandler: ServerInformation

  • Connect to a server with a specific server number i.e 5. If already connected, this will disconnect before reconnecting.

    Declaration

    Swift

    public func connectByServer(country: String, city: String, num: Int, completionHandler: @escaping (_ message: ServerInformation?, _ error: ErrorType?) -> Void)

    Parameters

    country

    2-character ISO country code, ie: ‘us’.

    city

    City code, ie: ‘atlanta’

    num

    Specific server number i.e 5

    Return Value

    completionHandler: ServerInformation

  • Disconnect from the server.

    Declaration

    Swift

    public func disconnect()
  • Authenticate a new user.

    Declaration

    Swift

    public func login(username: String, password: String, completionHandler: @escaping (_ message: State?, _ error: ErrorType?) -> Void)

    Parameters

    username

    Username of the user you wish to authenticate

    password

    Password of the user you wish to authenticate

    Return Value

    completionHandler: State and optional ValidationError

  • Logs out of any current account and logs in to an automatically generated account for this device. If setting a custom directory, call ‘changeDirectoryURL(url: String)’ before calling this. This may take several seconds as the OS is queryied for the device id Login or auto-account creation errors will be signalled in ‘ErrorType’ return in the ‘login(username: String, password: String, completionHandler:@escaping (_ message: State?, _ error: ErrorType)->Void’ closure. Automatic accounts have false email address in the form of .@autoaccount.speedify.com.

    Declaration

    Swift

    public func loginAutoAccount()

    Parameters

    serviceAccount

    A unique string to store UUID information. ex: “MyAppUUID”

  • Comcast Loopback Function @since 10.6

    Declaration

    Swift

    public func loginLocalOnly()
  • Logs out of any current account and logs in to an automatically generated account for this device. If setting a custom directory, call ‘changeDirectoryURL(url: String)’ before calling this. This may take several seconds as the OS is queryied for the device id Login or auto-account creation errors will be signalled in ‘ErrorType’ return in the ‘login(username: String, password: String, completionHandler:@escaping (_ message: State?, _ error: ErrorType)->Void’ closure. Automatic accounts have false email address in the form of .@autoaccount.speedify.com.

    Declaration

    Swift

    public func loginAuto(_ serviceName: String)

    Parameters

    serviceName

    Appends the auto account with the service name provided

    serviceAccount

    A unique string to store UUID information. ex: “MyAppUUID”

  • Logs out of any current account and logs in to an automatically generated account for this device. If setting a custom directory, call ‘changeDirectoryURL(url: String)’ before calling this. This may take several seconds as the OS is queryied for the device id Login or auto-account creation errors will be signalled in ‘ErrorType’ return in the ‘login(username: String, password: String, completionHandler:@escaping (_ message: State?, _ error: ErrorType)->Void’ closure. Automatic accounts have false email address in the form of .@autoaccount.speedify.com.

    Declaration

    Swift

    public func loginAutoAccount(completionHandler: @escaping (_ message: State?, _ error: ErrorType?) -> Void)

    Parameters

    serviceAccount

    A unique string to store UUID information. ex: “MyAppUUID”

    Return Value

    completionHandler: State and optional ValidationError

    • Authenticate a new user using oauth access token. You are responsible for fetching updated access tokens if you use this method.
    • If setting a custom directory, call changeDirectoryURL(url: String) before calling this.
    • Login errors will be signalled in completionHandler error.
    • An expired access token will give an error of ErrorType.token_expired, while invalid tokens will give ErrorType.credential. *

    Declaration

    Swift

    public func loginOAuth(oauthAccessToken: String, serviceAccount: String, completionHandler: @escaping (_ error: ErrorType?) -> Void)
  • Logout the current user.

    Declaration

    Swift

    public func logout(completionHandler: @escaping (_ message: State?) -> Void)

    Return Value

    completionHandler: State

  • Change the basic mode of operation, between optimizing for speed or maximizing reliability.

    Declaration

    Swift

    public func setMode(mode: BondingMode)

    Parameters

    mode

    Return Value

    This will show updated information inside of the delegate function func settingsDidUpdate(settings: Settings)

  • Get a list of available servers from the directory list.

    Declaration

    Swift

    public func getDirectory(completionHandler: @escaping (_ message: Dictionary<String, Any>) -> Void)

    Return Value

    completionHandler: A dictionary containing a server list

    • Change directory server used for user authentication and server management.
    • If using your own directory server, this should be called before login or loginAutoAccount.

    Declaration

    Swift

    @available(*, deprecated, message: "Use setDirectoryWithDomain(domain: String, completionHandler:@escaping (_ domain: String,_ esniEnabled: Bool﹚->Void﹚")
    public func setDirectoryDomain(domain: String, completionHandler: @escaping (_ domain: String) -> Void)
    • Change directory server used for user authentication and server management.
    • If using your own directory server, this should be called before login or loginAutoAccount.

    Declaration

    Swift

    public func setDirectoryWithDomain(domain: String, completionHandler: @escaping (_ directory: DirectorySettings) -> Void)
    • Set an oauth gateway to use for directory server requests.
    • If using your own directory gateway, this should be called before login or loginAutoAccount.
    • Triggers SpeedifyDirectoryDomainDelegate, and (if logged in) {@link ISpeedifyHandler#OnDirectory OnDirectory} on domain change.
    • @since 10.5

    Declaration

    Swift

    public func setDirectoryGatewayURI(gatewayUri: String)
    • Sets if credentials will not be stored. *
    • This includes passwords, OAuth tokens, and Safe Browsing init config.
    • Triggers SpeedifySDKDelegate privacySettingsDidUpdate
    • If true, automatic login and connect at boot will not work.
    • @since 10.5

    Declaration

    Swift

    public func setDoNotStoreCredentials(doNotStore: Bool)
  • Reset the directory oauth gateway to defaults. Triggers SpeedifyDirectoryDomainDelegate. @since 10.5

    Declaration

    Swift

    public func resetDirectoryURI()
  • Reset the directory server to defaults.

    Declaration

    Swift

    public func resetDirectoryDomain(completionHandler: @escaping (_ domain: String) -> Void)
    • Sets if ESNI is used when talking to the directory domain
    • If using your own directory server, this should be called before login or loginAutoAccount.
    • Triggers SpeedifyDirectoryDomainDelegate.
    • @since 10.4

    Declaration

    Swift

    public func setESNIEnabled(enable: Bool)
  • Get the current State.

    Declaration

    Swift

    public func getState(completionHandler: @escaping (_ message: State?) -> Void)

    Return Value

    completionHandler: State

  • Objective-C’s implementation to read state

    Declaration

    Swift

    @objc
    public func currentSpeedifyState() -> Int
  • Get the libspeedify version.

    Declaration

    Swift

    public func getVersion(completionHandler: @escaping (_ message: Version) -> Void)

    Return Value

    completionHandler: Version

  • Subscribe or Unsubscribe from receiving the tunnel ConnectionStats and SessionStats.

    Important

    Important note: This must be enabled to receive ConnectionStats updates.

    Example of some SessionStats.

    • Number of Failovers
    • Total Connected Minutes
    • Fastest Connected Mbps

    Example of some ConnectionStats.

    • Time Connected
    • total bytes per second
    • guid

    Declaration

    Swift

    public func enableConnectionStatUpdates(enabled: Bool)

    Return Value

    completionHandler: SessionStats

    • Set vendor user data
    • Current value available from SpeedifyVendorUserDataDelegate.
    • Discussion: You may send a JSON string to be saved inside of vendorUserData but be sure it is valid JSON or it will be ignored.
    • vendorSettings user data string
    • @since 9.8

    Declaration

    Swift

    public func setVendorUserData(vendorUserData: String)
  • Gets the vendor user data Triggers SpeedifyVendorUserDataDelegate. @since 9.8

    Declaration

    Swift

    public func refreshVendorUserData()
  • Get configuration of the local proxy Triggers SpeedifyLocalProxySettingsDelegate. @since 9.2

    Declaration

    Swift

    public func refreshLocalProxy()
  • Declaration

    Swift

    public func getConnections(completionHandler: @escaping (_ message: [AdapterData]?) -> Void)

    Return Value

    completionHandler: AdapterData

  • Set local vendor settings @param settingsJson a json object

    • Current value available from SpeedifyVendorLocalSettingsDelegate. @param merge if true, settingsJson is merged in to existing local vendor settings. if false, settingsJson replaces existing local vendor settings @since 9.2

    Declaration

    Swift

    public func setVendorLocalSettings(settings: Settings, merged: Bool)
  • Gets the local vendor settings @since 9.2

    Declaration

    Swift

    public func refreshVendorLocalSettings()
  • Refreshes streaming stats. @since 9.6

    Declaration

    Swift

    public func refreshStreamingStats()
  • Get configuration of the firewall @since 9.2

    Declaration

    Swift

    public func refreshFirewall()
  • Set the mode used by the firewall. @param mode how matches are treated @since 9.2

    Declaration

    Swift

    public func setFirewallMode(mode: FirewallMode)
  • Set domains to firewall. @param domains domain names to deny/allow @since 9.2

    Declaration

    Swift

    public func setFirewallDomains(domains: [String])
  • Set IPv6 address to firewall. @param ipv6 ipv6 addresses to deny/allow @since 9.3

    Declaration

    Swift

    public func setFirewallIPv6(ipv6: [String])
  • Set domain watchlist settings for the local proxy @param domainWatchlist domain watchlist items Triggers delegate localProxySettingsDidUpdate @since 9.3

    Declaration

    Swift

    public func setLocalProxyDomainWatchlistEnable(title: String, enabled: Bool)
  • Set IPv4 address to firewall. @param ipv4 ipv4 addresses to deny/allow @since 9.2

    Declaration

    Swift

    public func setFirewallIPv4(ipv4: [String])
  • Set ports to firewall. @param ports ports to be firewalled @since 9.2

    Declaration

    Swift

    public func setFirewallPorts(ports: [FirewallPort])
  • Gets the remote vendor settings @since 9.2

    Declaration

    Swift

    public func refreshRemoteVendorSettings()
  • Change the ConnectionPriority of each connection on the device.

    • Call the function getConnections(completionHandler:@escaping (_ message: Dictionary<String, Any>)->Void) before calling this function to ensure adapters are present.

    Possible ConnectionPriority options include

    • ALWAYS = 0
    • SECONDARY = 1
    • BACKUP = 2
    • NEVER = 100

    Declaration

    Swift

    public func setConnectionPriorities(connection: String, priority: ConnectionPriority)

    Parameters

    connection

    Should be ‘en0’ or ‘cellular’. The getConnections function will retrieve the list for you.

    priority

    Return Value

    This will show updated information inside of the delegate function func connectionDataDidUpdate(connectionData: [AdapterData])

  • Change which directory servers to connect with.

    • If using your own directory server, this should always be called before login() or loginAutoAccount().

    Declaration

    Swift

    @available(*, deprecated, message: "Please use the setDirectoryDomain(domain﹚ function instead")
    public func changeDirectoryURL(url: String)

    Parameters

    newURL

    Pass in a host name or ‘Empty’ field to change it back to the original server list

    Return Value

    completionHandler: A dictionary containing the Connections and Session stats.

  • Change the encryption settings per adapter.

    Declaration

    Swift

    public func setConnectionEncryption(adapterID: String, encrypt: Bool)

    Parameters

    adapterID

    Name of the adapter. ex: “en0”

    encrypt

    A boolean value to determine if encryption should be on or off

    Return Value

    This will show updated information inside of the delegate function func connectionDataDidUpdate(connectionData: [AdapterData])

  • Change the encryption settings on the tunnel.

    Declaration

    Swift

    public func setTunnelEncrypted(encrypted: Bool)

    Parameters

    encrypt

    A boolean value to determine if encryption should be on or off.

    Return Value

    This will show updated information inside of the delegate function func connectionDataDidUpdate(connectionData: [AdapterData]).

  • Allow or disallow use of ChaCha for connection encryptions. Current value available from Settings.

    Declaration

    Swift

    public func setChaChaEncrypted(encrypted: Bool)

    Parameters

    encrypt

    A boolean value to determine if ChaCha encryption should be on or off.

    Return Value

    This will show updated information inside of the delegate function func connectionDataDidUpdate(connectionData: [AdapterData]).

  • Set reporting encryption key.

    Declaration

    Swift

    public func setReportingEncryptionKey(key128bit: String)

    Parameters

    key128bit

    key A 16 byte ascii or 32byte hex string used to encrypt sensitive reports, or null to use default.

  • Set the overflow threshold.

    Declaration

    Swift

    public func setOverflowThreshold(mbpsOverflow: Double)

    Parameters

    mbpsOverflow

    The overflow threshold, in megabits per second.

    Return Value

    This will show updated information inside of the delegate function func settingsDidUpdate(settings: Settings).

  • Adds additional bytes to the adapter’s daily data usage limit for today. This value is not added to the base daily data usage limit.

    Declaration

    Swift

    public func addAdapterDailyDataLimitBoost(adapterID: String, additionalBytes: Int64)

    Parameters

    adapterID

    Name of the adapter. ex: “en0”

    additionalBytes

    Additional bytes that may be used today.

    Return Value

    This will show updated information inside of the delegate function func settingsDidUpdate(settings: Settings).

  • Set the data usage, in bytes, allowed on this adapter in a single day. Setting allowedBytes to 0 will disable this limit. Cellular adapters default to 200MB/month.

    Declaration

    Swift

    public func setAdapterDailyDataLimit(adapterID: String, allowedBytes: Int64)

    Parameters

    adapterID

    Name of the adapter. ex: “en0”

    allowedBytes

    Allowed bytes that may be used today.

    Return Value

    This will show updated information inside of the delegate function func settingsDidUpdate(settings: Settings).

  • Set the data usage, in bytes, allowed on this adapter in a single month. 0 for unlimited

    Declaration

    Swift

    public func setAdapterMonthlyDataLimit(adapterID: String, allowedBytes: Int64, resetDay: Int64)

    Parameters

    adapterID

    Name of the adapter. ex: “en0”

    allowedBytes

    Allowed bytes that may be used today.

    resetDay

    Day of the month that monthly usage is tracked from. 0 for last 30 days. Unused if allowedBytes is 0

    Return Value

    This will show updated information inside of the delegate function func settingsDidUpdate(settings: Settings).

  • Sets the adapter to unlimited daily data usage. Current value available on AdapterData

    Declaration

    Swift

    public func disableAdapterDailyDataLimit(adapterID: String)

    Parameters

    adapterID

    Name of the adapter. ex: “en0”

  • Sets the adapter to unlimited monthly data usage. Current value available on AdapterData

    Declaration

    Swift

    public func disableAdapterMonthlyDataLimit(adapterID: String)

    Parameters

    adapterID

    Name of the adapter. ex: “en0”

  • Acknowledge and clear message about a new adapter.

    Declaration

    Swift

    public func handleNewAdapter(adapterID: String)

    Parameters

    adapterID

    Name of the adapter. ex: “en0”

  • Set the speed rate limit on a connection.

    Declaration

    Swift

    public func setConnectionRateLimit(adapterID: String, bps: Int64)

    Parameters

    adapterId

    Name of the adapter to be limited. ex “en0”

    bps

    limit in bits per second

  • Will return the last 5 minutes worth of ConnectionStats *Important - This will not return anything on initial connect.

    Declaration

    Swift

    public func refreshHistoricalConnectionStats(completionHandler: @escaping (_ message: [ConnectionStatsGroup]?) -> Void)
  • Declaration

    Swift

    public func refreshSettings()
  • Set IP address ranges to exclude from going over the VPN tunnel This change takes effect on the next VPN connect. Current value available from delegate settingsDidUpdate.

    Declaration

    Swift

    public func setExcludedIPRanges(excludedRanges: [IPRange])

    Parameters

    excludedRanges
  • Sets the TransportMode selection used for each connection. Current value available from delegate settingsDidUpdate.

    Declaration

    Swift

    public func setConnectionTransportMode(transportMode: TransportMode)

    Parameters

    transportMode

    TransportMode

  • Sets whether to allow jumbo packets over the VPN tunnel. Current value available from delegate settingsDidUpdate.

    Declaration

    Swift

    public func setJumboPackets(useJumbo: Bool)
  • Sets whether to allow header compression on packets over the VPN tunnel. Current value available from delegate settingsDidUpdate.

    Declaration

    Swift

    public func setHeaderCompression(enable: Bool)
  • Refresh account data. Current value available from delegate accountingDataDidUpdate.

    Declaration

    Swift

    @objc
    public func refreshAccounting()
  • Sets how to handle an adapter that has hit its daily or monthly data limit. Current value available on AdapterData objects returned from AdapterUsageData.

    Declaration

    Swift

    public func setAdapterOverlimitRatelimit(adapterID: String, bps: Int64)

    Parameters

    adapterID

    name of the adapter. ex: “en0”.

  • Copies logs created by the daemon into the shared App Group Container

    • App Group Capabilities are mandatory when creating logs Please add the following key to the Container and PacketTunnel info.plist NSExtensionFileProviderDocumentGroup YOUR APP GROUP NAME

    Declaration

    Swift

    @objc
    public func generateLogs(completionHandler: @escaping (_ success: Bool) -> Void)

    Return Value

    completionHandler: Bool to indicate when the files are ready and copied over.

    • Set IP addresses of the DNS servers to use
    • Current value available from PrivacySettings.

    Declaration

    Swift

    public func setDNSServers(_ dnsAddrs: [String])
  • Toggles VPN On Demand.

    When On Demand is on, the operating system will automatically reconnect the VPN whenever internet is available. This setting persists across reboots (so if you set it on, the device will automatically reconnect the VPN after reboot).

    Declaration

    Swift

    @objc
    public func setOnDemand(ondemand: Bool)

    Parameters

    ondemand

    Boolean that toggles the VPN onDemand feature.

  • Check if the onDemand setting is currently enabled.

    Declaration

    Swift

    public func isOnDemandEnabled() -> Bool

    Return Value

    Boolean to determine if onDemand is enabled or disabled.

  • Erase all log files and log zips.

    Note that the current active log file is not erased. @since 10.5

    Declaration

    Swift

    public func eraseAllLogFiles()
  • Refresh privacy settings. Triggers privacySettingsDidUpdate

    Declaration

    Swift

    public func refreshPrivacySettings()
  • Get the last session disconnect event Triggers ‘SpeedifyLastDisconnectDelegate. Discussion: If the reason happens when closing the tunnel (SUPERCEDED, CONFIGURATIONDISABLED etc.) then the reason will not be updated in the database until the next extension launch. @since 10.4

    Declaration

    Swift

    public func refreshLastDisconnectEvent()
    • Check if there is already an account using this email address.
    • @since 7.4

    Declaration

    Swift

    public func accountCheck(email: String, completionHandler: @escaping (_ error: ErrorType, _ errorMessage: String, _ accountExists: Bool) -> Void)
    • Resets the tracked data usage on an adapter.
    • @since 7.8.3

    Declaration

    Swift

    public func resetAdapterUsage(adapterID: String)
    • Create a new account using this email address.
    • @since 7.4

    Declaration

    Swift

    public func accountCreate(email: String, password: String, completionHandler: @escaping (_ error: ErrorType, _ errorMessage: String) -> Void)
  • Request new session stats @since 9.5

    Declaration

    Swift

    public func requestSessionStats()
    • Change the password on the account.
    • @since 7.4

    Declaration

    Swift

    public func accountPasswordChange(email: String, originalPassword: String, newPassword: String, completionHandler: @escaping (_ error: ErrorType, _ errorMessage: String) -> Void)
    • Initialize Safe Browsing library
    • If initialized available from safebrowsingDelegate.
    • @since 10.6

    Declaration

    Swift

    public func initSafeBrowsing(safeBrowsingConfig: String)
    • Sets if Safe Browsing is enabled
    • Current value available safebrowsingDelegate.
    • @since 10.6

    Declaration

    Swift

    public func setSafeBrowsingEnabled(enabled: Bool)
  • Gets Safe Browsing stats Triggers safebrowsingDelegate statsDidUpdate. @since 10.6

    Declaration

    Swift

    public func refreshSafeBrowsingStats()
  • Gets Safe Browsing settings Triggers safebrowsingDelegate @since 10.6

    Declaration

    Swift

    public func refreshSafeBrowsing()
    • Set ports to be forwarded to this client when connected to a dedicated server.
    • Current value available from ‘SpeedifySettingsDelegate’
    • @since 8.2

    Declaration

    Swift

    public func setForwardPorts(ports: [ForwardedPort])
  • Set ports to proxy. Triggers LocalProxySettingsDelegate. @param ports ports to be proxied @since 9.9

    Declaration

    Swift

    public func setLocalProxyPorts(ports: [LocalProxyPort])
  • This will cancel an auto connect request.

    Declaration

    Swift

    public func cancelAutoConnect()
  • Tells the delegate the current ‘State’.

    Declaration

    Swift

    public func stateDidUpdate(state: State)
  • Tells the delegate the current ‘AdapterData’.

    Declaration

    Swift

    public func adapterDataDidUpdate(adapterData: [AdapterData])
  • Reports any setting error from settings being locked.

    Declaration

    Swift

    public func settingLockedError()
  • Tells the delegate the current ‘ConnectionStats’.

    Declaration

    Swift

    public func connectionStatsDidUpdate(connectionStats: [ConnectionStats])
  • Tells the delegate the current ‘Settings’.

    Declaration

    Swift

    public func settingsDidUpdate(settings: Settings)