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

Add HTTP/2, QUIC, VPN and Self-Signed CA support #464

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

GGG-KILLER
Copy link

@GGG-KILLER GGG-KILLER commented Nov 22, 2024

This PR basically makes it so that all requests go through package:cronet_http (on Android) or package:cupertino_http (on MacOS/iOS) using package:native_dio_adapter.

From the package:native_dio_adapter page:

Using the native platform implementation, rather than the socket-based dart:io HttpClient implementation, has several advantages:

  • It automatically supports platform features such VPNs and HTTP proxies.
  • It supports many more configuration options such as only allowing access through WiFi and blocking cookies.
  • It supports more HTTP features such as HTTP/3 and custom redirect handling.

This enables us in the future to add support for blocking image loading outside of WiFi or metered connections, however I did not want to do more than needed in this PR.

This PR also changes the security settings for the app to allow user-added/user-installed CAs so that people can access their own self-hosted boorus that use self-signed certificates.

Fixes #463.

@CLAassistant
Copy link

CLAassistant commented Nov 22, 2024

CLA assistant check
All committers have signed the CLA.

@GGG-KILLER GGG-KILLER force-pushed the all-http-through-cronet-cupertino branch from 0a86d8a to 38dc6ac Compare November 22, 2024 00:06
Comment on lines +57 to +58
if (Platform.isAndroid || Platform.isIOS || Platform.isMacOS) {
dio.httpClientAdapter = newNativeAdapter();
Copy link
Author

Choose a reason for hiding this comment

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

There shouldn't be any issues to just using the native methods since it's technically what the browsers use, so we'd just be doing requests in the same way a browser does, however it'd be nice to have some more testing on this front.

Copy link
Author

@GGG-KILLER GGG-KILLER Nov 22, 2024

Choose a reason for hiding this comment

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

I've tested gelbooru, gelbooru_v2, shimmie2, anime-pictures and danbooru.
They're all working on Android. It'd be nice to be able to get some tests on iOS/MacOS.

Comment on lines +40 to +41
final booru = booruFactory.getBooruFromUrl(baseUrl) ??
booruFactory.getBooruFromId(booruConfig.booruId);
Copy link
Author

Choose a reason for hiding this comment

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

This is needed because otherwise no booru is selected when coming from the "add new booru" page and an unknown URL is used, even though the user has told which booru it is.

Copy link
Owner

Choose a reason for hiding this comment

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

It works fine on my end. Are you sure this is an issue?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this is an issue when using boorus that don't have known URLs, in my case I have https://booru.shiro.lan/, that I tried to add as Danbooru, and when it tries to test it, booru is null because it tries to get the booru type from the URL, not from what was selected in the dropdown.

Copy link
Owner

Choose a reason for hiding this comment

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

Please merge the latest changes from dev and see if the issue is still there.

@GGG-KILLER GGG-KILLER changed the title Add HTTP/2, QUICK, VPN and Self-Signed CA support Add HTTP/2, QUIC, VPN and Self-Signed CA support Nov 22, 2024
enableBrotli: true,
enableHttp2: true,
enableQuic: true,
),
Copy link
Owner

Choose a reason for hiding this comment

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

need to add our custom User-Agent

Copy link
Owner

@khoadng khoadng Nov 22, 2024

Choose a reason for hiding this comment

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

Seems like error states are not handled correctly here, you can try adding https://www.zerochan.net/ WITHOUT a custom user-agent and see it yourself.
An error placeholder should be displayed whenever there are issues loading the image

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

Successfully merging this pull request may close these issues.

3 participants