-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Dart sockets don't respect iOS's VPN #41376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @zichangg |
I think this should be added. |
We do have HOST_OS_IOS defined when TARGET_OS_IPHONE is defined, see runtime/platform/globals.h |
We do distinguish between iOS and Mac, it's just that the implementations are so similar we put them in the same files (unlike how we have separated files for Android and Linux) that have a small number of ifdefs. |
@zichangg The CoreNetworking framework exists for iOS and macosx. If you change iOS and macosx to use it, it will be easier on you since you'll be able to test it locally instead of having to test on the simulator / device all the time. |
CFSocket should be available on both iOS and macOS. An alternative to this is #39104, but this is likely easier to implement and should not require any breakages in the API surface. |
Right. That should be easier for testing. If we move to |
Looked at some docs and code examples.
What @dnfield proposed might be a good choice. Since the only problem is activation of modem and VPN. Is it possible to turn them on programmatically for this case? |
@zichangg @dnfield That's a bummer. I think we are stuck with the higher level API's if CFSocket doesn't work. #39104 sounds good and necessary but the one problem is that it doesn't solve the issue for every client of Dart. This is going to be a problem for everyone that uses Dart on iOS, it would be nice to solve this problem as the default implementation on iOS. |
The idea with 39104 is to keep the API compatible with dart:io, so that you can just switch your import from |
We do have some discussions for splitting dart:io into multiple smaller packages. I haven't started but this is the plan for this quarter. |
what is the current state of this issue? i face app vpn from mobile iron at every enterprise customer. it is a show stopper in many cases if the app vpn is used to secure a connection. |
Hi @tobiaszuercher, As a work around you can create a custom http client and use http overriders to return your custom client when a HttpClient is requested. Inside the custom client you can get the device proxy so that it is dynamic. Please see the examples below of our Proxy aware http client that utilises the device_proxy package from pub dev
A custom HttpOverrides that returns your new proxy aware client
Some docs regarding httpoverrides Regards, |
@thaoula thank you a lot for your code! i still don't have access to an app-vpn, but i'll try as soon as the environment is there! |
With per-apn vpn the suggested solution doesn't work, since it might not be "just" a proxy. I've tested with VMware Airwatch, using flutter and the host cannot be reached. |
Any news on this issue? Will there be a built-in solution in the near future? |
Hello @gaaclarke |
@JordiGiros no |
Did anyone try this with F5 BIG IP VPN? I dont have access to a working environment just yet. |
late Client client;
if (Platform.isIOS) {
final config = URLSessionConfiguration.ephemeralSessionConfiguration()
# Do whatever configuration you want.
..allowsCellularAccess = false
..allowsConstrainedNetworkAccess = false
..allowsExpensiveNetworkAccess = false;
client = CupertinoClient.fromSessionConfiguration(config);
} else {
client = IOClient(); // Uses an HTTP client based on dart:io
}
final response = await client.get(Uri.https(
'www.googleapis.com',
'/books/v1/volumes',
{'q': 'HTTP', 'maxResults': '40', 'printType': 'books'})); I would really appreciate it if you can try Comments or bugs in the |
Are there any news? |
@komaxx have you tried https://pub.dev/packages/cupertino_http ? |
@a-siva Good point, I'll give it a try! |
@komaxx it is currently marked as "experimental" as this package is fairly new and we are soliciting feedback from users, our plan is to address all the initial feedback we receive and move it out of the "experimental" state. |
Bump. |
@GoncaloPT have you tried https://pub.dev/packages/cupertino_http for your VPN problem. |
Hello @a-siva. Would it support websocket connections? |
An interesting note about using VPN with BSD sockets: https://developer.apple.com/forums/thread/76448 |
I filed a bug to track adding websocket support in |
Originally filed for Flutter: flutter/flutter#41500
The issue reports that using Dart to access resources over VPN doesn't work.
I looked through Dart's source code and it appears to be using posix sockets. Apple's documentation recommends against that:
In iOS, POSIX networking is discouraged because it does not activate the cellular radio or on-demand VPN. Thus, as a general rule, you should separate the networking code from any common data processing functionality and rewrite the networking code using higher-level APIs.
source: https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/UsingSocketsandSocketStreams.html
We should implement a socket implementation based on CFSocket.
The text was updated successfully, but these errors were encountered: