Skip to content
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

Proxy support for Android and IOS #1727

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

marcmcl
Copy link

@marcmcl marcmcl commented Nov 9, 2020

Screenshots

Screenshots Add any relevant before/after screenshots here

How did you test the change?

  • iOS Simulator
  • iOS Device
  • Android Simulator
  • Android Device
  • curl to a dev App Engine server
  • other, please describe
    Tested by manually specifying proxy host and port, as well as with a proxy.pac URL.

Checklist:

@brunobowden
Copy link
Collaborator

@marcmcl - have a look at the check failures on GitHub:

  1. pubspec.lock changes are missing. This is breaking most of the CI builds.
  2. Podfile.lock changes are missing. Even though you're not fixing up iOS, you need to include this.

@brunobowden
Copy link
Collaborator

brunobowden commented Nov 9, 2020

@marcmcl - two further comments:

  1. Your name shouldn't be in the title. It should be targeted such as "Proxy Support for Android"
  2. PR description should mention associated issue: "Partial fix for Network Proxy Settings aren't used by Flutter #1155"
  3. What other libraries did you look at for http proxies? There seem to be a few on pub.dev. My concern is that by creating a new library, you become responsible for maintaining it long in to the future. I'd first carefully check if there's other good libraries we can use. If we have to build our own, then it might be better to do it under the WHO repo so it has more shared responsibility.
  4. The GitHub example is formatted incorrectly and needs this type of quote:
code example

@marcmcl marcmcl changed the title Marcmcl proxysupport Proxy support for Android Nov 10, 2020
@marcmcl marcmcl marked this pull request as draft November 10, 2020 11:04
@stale
Copy link

stale bot commented Nov 17, 2020

This item has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the resolved:stale No recent activity on the issue or PR label Nov 17, 2020
@marcmcl marcmcl changed the title Proxy support for Android Proxy support for Android and IOS Nov 28, 2020
@stale stale bot removed the resolved:stale No recent activity on the issue or PR label Nov 28, 2020
@marcmcl
Copy link
Author

marcmcl commented Nov 28, 2020

@brunobowden I added the missing files and have also included my plugin files as well. Managed to get hostname and port working for proxy on IOS too. Still no support for proxy authentication on both IOS and Android implementations. IOS implementation also doesn't autoconfig proxies specified via PAC yet.

Copy link
Collaborator

@brunobowden brunobowden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @marcmcl, thanks for contributing this. It'll take me more time to look at this. Here's some initial cursory observations.

@brunobowden
Copy link
Collaborator

@marcmcl - there's also a conflict in client/ios/Podfile.lock. Not sure what to do in GitHub desktop but from the command line you'll need to:

git fetch upstream
git rebase -i upstream/master

@marcmcl marcmcl force-pushed the marcmcl-proxysupport branch from 05dcc57 to eaabc6f Compare November 30, 2020 20:35
@marcmcl
Copy link
Author

marcmcl commented Dec 2, 2020

@brunobowden going to retest tomorrow then I will mark the PR as ready for review.

Copy link
Collaborator

@brunobowden brunobowden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcmcl - thanks for pressing on with this. Sorry to ask you to rename lots of file as that's a painful process. Feel free to discuss / push back on the name. We should be thoughtful about that so we don't need to change it later on.

There's also two further client fetches using webHelper.downloadFile in caching.dart. Though should also use the proxy but I'm not quite sure how to do it:
https://github.com/WorldHealthOrganization/app/blob/master/client/lib/api/content/caching.dart#L44


var client = new HttpClient();
String proxy = await GetProxy.getProxy;
if(proxy!="")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space after if

@@ -4,7 +4,8 @@ import 'package:who_app/main.dart';
import 'package:who_app/api/user_preferences.dart';
import 'package:http/http.dart' as http;
import 'dart:io' as io;

import 'package:get_proxy/get_proxy.dart';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of get_proxy, should it be http_proxy? You're not getting a proxy but using it for requests. It should match the http.post API as much as possible. The used class can then be httpProxy which more closely matches.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads up that get_proxy was literally just getting the proxy information. But I'll move the http.post alternative into this package and rename it as you suggest @brunobowden .

@@ -24,7 +25,7 @@ class WhoService {
final postBody = jsonEncode(req.toProto3Json());

final url = '$serviceUrl/putDeviceToken';
final response = await http.post(url, headers: headers, body: postBody);
final response = await httpPost(url, headers, postBody);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General thought is that the http.post APIs will have a lot of thought that's gone in to them. So my suggestion was to use the same API for httpPost. It also benefits users as they can use the same syntax and it benefits reviewers as there's fewer changes switching from one to the other. So you'd expect the new line to be:

Suggested change
final response = await httpPost(url, headers, postBody);
final response = await await httpProxy.post(url, headers: headers, body: postBody);

@stale
Copy link

stale bot commented Dec 9, 2020

This item has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added resolved:stale No recent activity on the issue or PR and removed resolved:stale No recent activity on the issue or PR labels Dec 9, 2020
@stale
Copy link

stale bot commented Dec 21, 2020

This item has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the resolved:stale No recent activity on the issue or PR label Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolved:stale No recent activity on the issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants