OpenVPNAdapter icon indicating copy to clipboard operation
OpenVPNAdapter copied to clipboard

v0.7.0 connect failed

Open plkgq opened this issue 3 years ago • 5 comments

Hello, Mr. Author, first of all thank you very much for the open plugin you provided, However, some problems occurred in the project upgrade recently (from 0.5.1 to 0.7.0) WX20210622-164520@2x

The following is the problem I have on my iOS device In the oc version, NEPacketTunnelFlow has already followed the OpenVPNAdapterPacketFlow protocol, but errors still occur. I guess there should be some problems in the type conversion, but I don’t know how to solve it.

In the swift version, there are some different problems WX20210622-164806@2x

In addition, I found that you use APPLICATION_EXTENSION_API_ONLY in your pod project, which makes it compatible with other projects. I need to manually remove it after each install. If APPLICATION_EXTENSION_API_ONLY is not necessary, I suggest removing it. This It will be better compatible with pod projects WX20210622-165809@2x

Looking forward to your reply

plkgq avatar Jun 22 '21 09:06 plkgq

WX20210622-173350@2x

plkgq avatar Jun 22 '21 09:06 plkgq

Hi @plkgq,

Looking at the exception it seems to me that you are trying to store NEPacketTunnelFlow object into some special storage like UserDefaults or tunnel settings. And as the exception message said it is not possible because this object doesn't adopt NSSecureCoding protocol.

As for cocoapods, thanx for suggestion, although I think it would be better to define additional subspec so at the end we would have one for extension, and one for client app. I'll fix it when I have enough spare time.

ss-abramchuk avatar Jun 23 '21 16:06 ss-abramchuk

Thank you very much for your reply I double-checked my code and found no special storage WX20210624-164824@2x I just executed [self.vpnAdapter connectUsingPacketFlow:self.packetFlow]; WX20210624-175848@2x WX20210624-175901@2x

plkgq avatar Jun 24 '21 09:06 plkgq

Ahhh... I see what's wrong. In 0.7.0 version delegate's API has changed, in openVPNAdapter(_:configureTunnelWithNetworkSettings:completionHandler:) you use packetFlow as completion handler argument. But now completion handler accepts NSError that returned by setTunnelNetworkSettings. Here how it could be done in Swift:

func openVPNAdapter(
    _ openVPNAdapter: OpenVPNAdapter, 
    configureTunnelWithNetworkSettings networkSettings: NEPacketTunnelNetworkSettings?, 
    completionHandler: @escaping (Error?) -> Void
) {
    networkSettings?.dnsSettings?.matchDomains = [""]
    setTunnelNetworkSettings(networkSettings, completionHandler: completionHandler)
}

ss-abramchuk avatar Jun 24 '21 17:06 ss-abramchuk

Thank you again for your reply. I seem to know how to fix it. WX20210625-155817@2x

Before that, I returned the wrong object. When I changed it to this, it worked,

but there was another problem. I found that I disconnected the network and reconnected. Later, it does not work, but I see in the log that the connection has been established, but the network is unavailable. It seems that some configuration has not been updated. I want to know how to fix it.

thank :)

plkgq avatar Jun 25 '21 08:06 plkgq