{"id":25091589,"url":"https://github.com/futurragroup/openvpnxor","last_synced_at":"2025-04-15T23:38:50.734Z","repository":{"id":143635038,"uuid":"609872685","full_name":"FuturraGroup/OpenVPNXor","owner":"FuturraGroup","description":"Library for simple connection via OpenVPN protocol with Xor patch.","archived":false,"fork":false,"pushed_at":"2024-12-12T13:43:07.000Z","size":32437,"stargazers_count":12,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-12T14:29:17.985Z","etag":null,"topics":["ios","objective-c","openvpn","openvpn-client","swift","xor-cipher","xor-encryption","xor-patch"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FuturraGroup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-05T13:54:04.000Z","updated_at":"2024-12-12T13:43:06.000Z","dependencies_parsed_at":"2024-06-12T12:11:35.211Z","dependency_job_id":"5b8ac2af-10a4-4ac6-9753-c5842c56e876","html_url":"https://github.com/FuturraGroup/OpenVPNXor","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuturraGroup%2FOpenVPNXor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuturraGroup%2FOpenVPNXor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuturraGroup%2FOpenVPNXor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuturraGroup%2FOpenVPNXor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FuturraGroup","download_url":"https://codeload.github.com/FuturraGroup/OpenVPNXor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237654698,"owners_count":19345270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","objective-c","openvpn","openvpn-client","swift","xor-cipher","xor-encryption","xor-patch"],"created_at":"2025-02-07T13:35:25.123Z","updated_at":"2025-02-07T13:35:25.673Z","avatar_url":"https://github.com/FuturraGroup.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenVPNXor\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"280\" height=\"280\" src=\"https://user-images.githubusercontent.com/7910769/225934094-82104453-cc6e-4723-a763-8f664eea2cab.png\"\u003e\n\u003c/p\u003e\n\nLibrary for connecting via OpenVPN protocol for iOS and macOS platforms. The library supports [Xor patch](https://github.com/clayface/openvpn_xorpatch).\n\n## Overview\nOpenVPNXor is a library that allows to configure and establish VPN connection using OpenVPN protocol easily. It is based on the original [openvpn3](https://github.com/OpenVPN/openvpn3) library so it has every feature the library has.\n\nThe library is designed to use in conjunction with [`NetworkExtension`](https://developer.apple.com/documentation/networkextension) framework and doesn't use any private Apple API. Compatible with iOS and macOS and also Swift friendly.\n\n## Installation\n\nOpenVPNXor is available with CocoaPods.\n\n### CocoaPods\n\n[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate OpenVPNXor into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nplatform :ios, '11.0'\nuse_frameworks!\n\ndef sharedPods\n  pod 'OpenVPNXor'\nend\n\ntarget 'Example VPN' do\nsharedPods\nend\n\ntarget 'PacketTunnelOpenVPN' do\nsharedPods\nend\n```\n## Usage\n\nFirst, you need to add a [Packet Tunnel Provider extension](https://developer.apple.com/documentation/networkextension/packet_tunnel_provider) and create [App Group identifier](https://developer.apple.com/documentation/xcode/configuring-app-groups).\n\nNext, you need to call the `setup` method to initialize the library. You need to pass the bundle id of the Packet Tunnel extension and the App Group identifier to this method. App Group identifier to be same for App and packet tunnel provider.\n\n```swift\nimport OpenVPNXor\n\n    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -\u003e Bool {\n\n        OpenVPNManager.setup(openvpnPacketTunnelIdentifier: \"com.example.bundle.PacketTunnelOpenVPN\", appGroupIdentifier: \"group.com.example.bundle\")\n        \n        return true\n    }\n```\n\n`PacketTunnelProvider` class configuration.\n```swift\nimport NetworkExtension\nimport OpenVPNXor\nimport os.log\n\nextension OSLog {\n    private static var subsystem = Bundle.main.bundleIdentifier!\n    /// Logs the view cycles like viewDidLoad.\n    static let viewCycle = OSLog(subsystem: subsystem, category: \"PacketTunnel\")\n}\n\nclass PacketTunnelProvider: OpenVPNPacketTunnelProvider {\n\n    override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -\u003e Void) {\n        /// Add code here to start the process of connecting the tunnel.\n        os_log(\"startTunnel!\", log: OSLog.viewCycle, type: .info)\n        super.startTunnel(options: options, completionHandler: completionHandler)\n    }\n\n    override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -\u003e Void) {\n        /// Add code here to start the process of stopping the tunnel.\n        super.stopTunnel(with: reason, completionHandler: completionHandler)\n    }\n\n    override func handleAppMessage(_ messageData: Data, completionHandler: ((Data?) -\u003e Void)?) {\n        super.handleAppMessage(messageData, completionHandler: completionHandler)\n    }\n}\n```\nSaving configuration of the profile in the Network Extension preferences of the `.ovpn` file.\n```swift\nlet configurationFileContent = // .ovpn config file\nlet login = \"login\"\nlet pass = \"password\"\n            \nOpenVPNManager.shared.configureVPN(openVPNConfiguration: configurationFileContent, login: login, pass:pass) { success in\n    if success {\n        /// Profile saved successfully.\n    } else {\n        /// Error saving profile. See the description of the error in the delegate method - `VpnManagerConnectionFailed`\n    }\n}\n```\nStart VPN connection by calling the following code.\n```swift\nOpenVPNManager.shared.connectVPN { errorDescription in\n    /// If an error occurred while connecting, the `errorDescription` variable will contain a description of the error.\n}\n```\nDisconnect VPN\n```swift\nOpenVPNManager.shared.disconnectVPN()\n```\nUsing the `onVPNStatusChange` block, you can track changes in connection status.\n```swift\nOpenVPNManager.shared.onVPNStatusChange = { (status) in\n    switch status {\n    case .invalid:\n        /** @const VPNStatusDisconnected The VPN is disconnected. */\n        break\n    case .disconnected:\n        /** @const VPNStatusDisconnected The VPN is disconnected. */\n        break\n    case .connecting:\n        /** @const VPNStatusConnecting The VPN is connecting. */\n        break\n    case .connected:\n        /** @const VPNStatusConnected The VPN is connected. */\n        break\n    case .reasserting:\n        /** @const VPNStatusReasserting The VPN is reconnecting following loss of underlying network connectivity. */\n        break\n    case .disconnecting:\n        /** @const VPNStatusDisconnecting The VPN is disconnecting. */\n        break\n    }\n}\n```\nAlso at any time you can take the status with a variable `OpenVPNManager.shared.vpnStatus`\n### VPNManagerDelegate\nIf an error occurred while saving the profile or connecting, this method will return a description of the error.\n```swift\nfunc VpnManagerConnectionFailed(error : VPNCollectionErrorType , localizedDescription : String)\n```\nThe method will be called upon successful connection.\n```swift\nfunc VpnManagerConnected()\n```\nThe method to be called after disconnecting from the VPN server.\n```swift\nfunc VpnManagerDisconnected()\n```\nThe method will be called after successfully saving the configuration of the profile in the Network Extension preferences.\n```swift\nfunc VpnManagerProfileSaved()\n```\nNetwork Traffic Statistics\n```swift\nfunc VpnManagerPacketTransmitted(with bitrate: Bitrate) {\n    print(\"NetworkTrafficStatistics - \", NetworkTrafficStatistics.formBitrateString(with: bitrate))\n}\n```\nVPN session logs.\n```swift\nfunc VpnManagerLogs(log : String?)\n```\n## Contribute\n\nContributions for improvements are welcomed. Feel free to submit a pull request to help grow the library. If you have any questions, feature suggestions, or bug reports, please send them to [Issues](https://github.com/FuturraGroup/OpenVPNXor/issues).\n\n## License\n\n```\nMIT License\n\nCopyright (c) 2023 Futurra Group\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuturragroup%2Fopenvpnxor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuturragroup%2Fopenvpnxor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuturragroup%2Fopenvpnxor/lists"}