Code Monkey home page Code Monkey logo

Comments (13)

ss-abramchuk avatar ss-abramchuk commented on September 13, 2024

Hi @Richard1202,
You can download Simple macOS OpenVPN Client source code and use it as the example. Despite it is written for macOS the iOS code will be almost the same.

from openvpnadapter.

Richard1202 avatar Richard1202 commented on September 13, 2024

Thank you for your reply.

OpenVPNAdapter framework is different in sample you sent, I have to use it for iPhone Project.

When can I download source code of them and compile it?

from openvpnadapter.

roshit-omanakuttan avatar roshit-omanakuttan commented on September 13, 2024

Hi @ss-abramchuk,

Thank you for creating a wonderful framework and sharing the above Mac Client.
The Mac Client works like a charm with the OVPNs you shared as well as my Server OVPN.

I also created an iOS Client similar to the Mac Client you shared.
Unfortunately, the iOS Client doesn't seem to be working.

The connection request doesn't seem to reach the server at all.
It would very helpful if you could please help me in this regard.
My codebase is here: https://drive.google.com/open?id=1RGF_KOJOc7BKI2NoJRwPEfXDUCdTSkah

Highly appreciate your time and effort.

Thanks and Regards,
Roshit

from openvpnadapter.

googleliyang avatar googleliyang commented on September 13, 2024

Hi @ss-abramchuk
I have downloaded Simple macOS OpenVPN Client source, run code, but can not connect the vpn.
I have a issue, when PacketTunnelProvider exec, i have print some log in startTunnel func, but never
exec

any help best regards.

from openvpnadapter.

googleliyang avatar googleliyang commented on September 13, 2024

@roshit-omanakuttan

I have solved this issue, I need config your info.plist

add

	<key>NSExtension</key>
<dict>  
    <key>NSExtensionPointIdentifier</key>  
    <string>com.apple.networkextension.packet-tunnel</string>  
    <key>NSExtensionPrincipalClass</key>  
    <string>$(PRODUCT_MODULE_NAME).PacketTunnelProvider</string>  
</dict>

Then, you will see your provider be called

from openvpnadapter.

roshit-omanakuttan avatar roshit-omanakuttan commented on September 13, 2024

Hi @googleliyang

Thank you for the response.
The mentioned NSExtension key was always part of the plist file of the Tunnel Provider.

Should I also add to the plist of main project as well?
I tried adding it to the plist of the project, but the app screen turned Black and non responsive.

from openvpnadapter.

googleliyang avatar googleliyang commented on September 13, 2024

@roshit-omanakuttan
If you create packetTunnel plist will auto generate, info.plist just config at packetTunnel not in you main project. you can call provider code as below


class ViewController: NSViewController {
    
    var manager: NETunnelProviderManager?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
    }
    
    override var representedObject: Any? {
        didSet {
            // Update the view, if already loaded.
        }
    }
    
    @IBAction func establishVPNConnection(_ sender: Any) {
        let callback = { (error: Error?) -> Void in
            self.manager?.loadFromPreferences(completionHandler: { (error) in
                guard error == nil else {
                    print("\(error!.localizedDescription)")
                    return
                }
                
                let options: [String : NSObject] = [
                    "username": "freeopenvpn" as NSString,
                    "password": "819646439" as NSString
                ]
                
                do {
                   // this will call providerTunnerProvider startTunnel method
                    try self.manager?.connection.startVPNTunnel(options: options)
                } catch {
                    print("\(error.localizedDescription)")
                }
            })
        }
        
        configureVPN(callback: callback)
    }
    
}

extension ViewController {
    
    func configureVPN(callback: @escaping (Error?) -> Void) {
        NETunnelProviderManager.loadAllFromPreferences { (managers, error) in
            guard error == nil else {
                print("\(error!.localizedDescription)")
                callback(error)
                return
            }
            
            self.manager = managers?.first ?? NETunnelProviderManager()
            self.manager?.loadFromPreferences(completionHandler: { (error) in
                guard error == nil else {
                    print("\(error!.localizedDescription)")
                    callback(error)
                    return
                }
                
                let configurationFile = Bundle.main.url(forResource: "freeopenvpn_DE_udp", withExtension: "ovpn")
                let configurationContent = try! Data(contentsOf: configurationFile!)
                
                let tunnelProtocol = NETunnelProviderProtocol()
                tunnelProtocol.serverAddress = "freeopenvpn.org"
                tunnelProtocol.providerBundleIdentifier = "me.ss-abramchuk.openvpn-macos-client.tunnel-provider"
                tunnelProtocol.providerConfiguration = ["configuration": configurationContent]
                
                tunnelProtocol.disconnectOnSleep = false
                
                self.manager?.protocolConfiguration = tunnelProtocol
                self.manager?.localizedDescription = "OpenVPN macOS Client"
                
                self.manager?.isEnabled = true
                
                self.manager?.saveToPreferences(completionHandler: { (error) in
                    guard error == nil else {
                        print("\(error!.localizedDescription)")
                        callback(error)
                        return
                    }
                    
                    callback(nil)
                })
            })
        }
    }
    
}

Notice: the log of packetTunnelProvider not show xocde console, you should cat in device log .

from openvpnadapter.

googleliyang avatar googleliyang commented on September 13, 2024

@roshit-omanakuttan
This is a simple demo
https://github.com/googleliyang/openvpn_adapter_ios

from openvpnadapter.

roshit-omanakuttan avatar roshit-omanakuttan commented on September 13, 2024

@googleliyang
Thank you so much for sharing the Codebase.
I ran the app on my device, but unfortunately I am getting the below logs:

exec connect
connecting
off

from openvpnadapter.

vishal-revdiwala avatar vishal-revdiwala commented on September 13, 2024

Hi @googleliyang
I am developing OpenVPN in iOS. I followed instruction. But I am unable to achieve it. Can you please share sample project for iOS.

Regards

from openvpnadapter.

vishal-revdiwala avatar vishal-revdiwala commented on September 13, 2024

@roshit-omanakuttan
This is a simple demo
https://github.com/googleliyang/openvpn_adapter_ios

Above URL doesn't exist now. Can you please share updated URL?

from openvpnadapter.

jonathanGuez01 avatar jonathanGuez01 commented on September 13, 2024

Hi @ss-abramchuk
Can you please re-share your Simple macOS OpenVPN Client source code download link,
the project not there and we cant download it.
Thanks a lot!

from openvpnadapter.

ss-abramchuk avatar ss-abramchuk commented on September 13, 2024

Hi @jonathanGuez01,

Here is new link to the project.

from openvpnadapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.