Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

v0.7.0 connect failed #209

Open
plkgq opened this issue Jun 22, 2021 · 5 comments
Open

v0.7.0 connect failed #209

plkgq opened this issue Jun 22, 2021 · 5 comments

Comments

@plkgq
Copy link

plkgq commented Jun 22, 2021

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
Copy link
Author

plkgq commented Jun 22, 2021

WX20210622-173350@2x

@ss-abramchuk
Copy link
Owner

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.

@plkgq
Copy link
Author

plkgq commented Jun 24, 2021

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

@ss-abramchuk
Copy link
Owner

ss-abramchuk commented Jun 24, 2021

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)
}

@plkgq
Copy link
Author

plkgq commented Jun 25, 2021

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 :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants