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 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>

<queries>
<!-- If your app opens https URLs -->
<intent>
Expand Down Expand Up @@ -37,7 +37,8 @@
android:label="@string/app_name"
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
9 changes: 9 additions & 0 deletions android/app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</base-config>
</network-security-config>
3 changes: 1 addition & 2 deletions lib/boorus/anime-pictures/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import 'package:boorusama/core/configs/configs.dart';
import 'package:boorusama/core/downloads/downloads.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/core/tags/tags.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'anime_pictures.dart';

final animePicturesClientProvider =
Provider.family<AnimePicturesClient, BooruConfig>(
(ref, config) {
final dio = newDio(ref.watch(dioArgsProvider(config)));
final dio = ref.watch(dioProvider(config));

return AnimePicturesClient(
dio: dio,
Expand Down
3 changes: 1 addition & 2 deletions lib/boorus/danbooru/danbooru_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import 'package:boorusama/core/autocompletes/autocompletes.dart';
import 'package:boorusama/core/configs/configs.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/core/tags/tags.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'package:boorusama/functional.dart';

final danbooruClientProvider =
Provider.family<DanbooruClient, BooruConfig>((ref, booruConfig) {
final dio = newDio(ref.watch(dioArgsProvider(booruConfig)));
final dio = ref.watch(dioProvider(booruConfig));

return DanbooruClient(
dio: dio,
Expand Down
3 changes: 1 addition & 2 deletions lib/boorus/danbooru/users/users_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:boorusama/boorus/providers.dart';
import 'package:boorusama/clients/danbooru/danbooru_client.dart';
import 'package:boorusama/core/configs/configs.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'package:boorusama/functional.dart';

final danbooruUserRepoProvider =
Expand All @@ -37,7 +36,7 @@ final danbooruCurrentUserProvider =

// If the cached id is null, we need to fetch it from the api
if (id == null) {
final dio = newDio(ref.watch(dioArgsProvider(config)));
final dio = ref.watch(dioProvider(config));

final data = await DanbooruClient(
dio: dio,
Expand Down
3 changes: 1 addition & 2 deletions lib/boorus/e621/e621.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import 'package:boorusama/core/configs/configs.dart';
import 'package:boorusama/core/configs/create/create.dart';
import 'package:boorusama/core/downloads/downloads.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'artists/artists.dart';
import 'comments/comments.dart';
import 'favorites/favorites.dart';
Expand All @@ -24,7 +23,7 @@ import 'tags/tags.dart';

final e621ClientProvider =
Provider.family<E621Client, BooruConfig>((ref, booruConfig) {
final dio = newDio(ref.watch(dioArgsProvider(booruConfig)));
final dio = ref.watch(dioProvider(booruConfig));

return E621Client(
baseUrl: booruConfig.url,
Expand Down
3 changes: 1 addition & 2 deletions lib/boorus/gelbooru/gelbooru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'package:boorusama/core/notes/notes.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/core/scaffolds/scaffolds.dart';
import 'package:boorusama/core/tags/tags.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'artists/gelbooru_artist_page.dart';
import 'comments/gelbooru_comment_page.dart';
import 'configs/create_gelbooru_config_page.dart';
Expand All @@ -38,7 +37,7 @@ String getGelbooruProfileUrl(String url) => url.endsWith('/')

final gelbooruClientProvider =
Provider.family<GelbooruClient, BooruConfig>((ref, booruConfig) {
final dio = newDio(ref.watch(dioArgsProvider(booruConfig)));
final dio = ref.watch(dioProvider(booruConfig));

return GelbooruClient.custom(
baseUrl: booruConfig.url,
Expand Down
1 change: 0 additions & 1 deletion lib/boorus/gelbooru_v1/gelbooru_v1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import 'package:boorusama/core/downloads/downloads.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/core/scaffolds/scaffolds.dart';
import 'package:boorusama/foundation/html.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'package:boorusama/widgets/info_container.dart';

part 'providers.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/boorus/gelbooru_v1/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final gelbooruV1AutocompleteRepoProvider =

final gelbooruV1ClientProvider =
Provider.family<GelbooruV1Client, BooruConfig>((ref, booruConfig) {
final dio = newDio(ref.watch(dioArgsProvider(booruConfig)));
final dio = ref.watch(dioProvider(booruConfig));

return GelbooruV1Client(
baseUrl: booruConfig.url,
Expand Down
3 changes: 1 addition & 2 deletions lib/boorus/gelbooru_v2/gelbooru_v2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'package:boorusama/core/notes/notes.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/core/scaffolds/scaffolds.dart';
import 'package:boorusama/core/tags/tags.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'create_gelbooru_v2_config_page.dart';
import 'home/gelbooru_v2_home_page.dart';
import 'posts/gelbooru_v2_post_details_page.dart';
Expand All @@ -31,7 +30,7 @@ const kGelbooruV2CustomDownloadFileNameFormat =

final gelbooruV2ClientProvider =
Provider.family<GelbooruV2Client, BooruConfig>((ref, booruConfig) {
final dio = newDio(ref.watch(dioArgsProvider(booruConfig)));
final dio = ref.watch(dioProvider(booruConfig));

return GelbooruV2Client.custom(
baseUrl: booruConfig.url,
Expand Down
3 changes: 1 addition & 2 deletions lib/boorus/hydrus/hydrus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'package:boorusama/core/home/home.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/core/scaffolds/scaffolds.dart';
import 'package:boorusama/foundation/i18n.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'package:boorusama/router.dart';
import 'package:boorusama/widgets/widgets.dart';
import 'favorites/favorites.dart';
Expand Down Expand Up @@ -65,7 +64,7 @@ class HydrusPost extends SimplePost {

final hydrusClientProvider =
Provider.family<HydrusClient, BooruConfig>((ref, config) {
final dio = newDio(ref.watch(dioArgsProvider(config)));
final dio = ref.watch(dioProvider(config));

return HydrusClient(
dio: dio,
Expand Down
3 changes: 1 addition & 2 deletions lib/boorus/moebooru/moebooru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import 'package:boorusama/core/downloads/downloads.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/core/scaffolds/scaffolds.dart';
import 'package:boorusama/core/tags/tags.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'package:boorusama/functional.dart';
import 'configs/create_moebooru_config_page.dart';
import 'feats/posts/posts.dart';
Expand All @@ -29,7 +28,7 @@ import 'pages/widgets/moebooru_related_post_section.dart';

final moebooruClientProvider =
Provider.family<MoebooruClient, BooruConfig>((ref, booruConfig) {
final dio = newDio(ref.watch(dioArgsProvider(booruConfig)));
final dio = ref.watch(dioProvider(booruConfig));

return MoebooruClient.custom(
baseUrl: booruConfig.url,
Expand Down
3 changes: 1 addition & 2 deletions lib/boorus/philomena/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import 'package:boorusama/clients/philomena/types/image_dto.dart';
import 'package:boorusama/core/autocompletes/autocompletes.dart';
import 'package:boorusama/core/configs/configs.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'package:boorusama/functional.dart';

final philomenaClientProvider = Provider.family<PhilomenaClient, BooruConfig>(
(ref, config) {
final dio = newDio(ref.watch(dioArgsProvider(config)));
final dio = ref.watch(dioProvider(config));

return PhilomenaClient(
dio: dio,
Expand Down
9 changes: 5 additions & 4 deletions lib/boorus/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import 'dart:io';

// Package imports:
import 'package:dio/dio.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:hive/hive.dart';

Expand Down Expand Up @@ -234,20 +235,20 @@ class DioArgs {
final BooruFactory booruFactory;
}

final dioArgsProvider = Provider.family<DioArgs, BooruConfig>((ref, config) {
final dioProvider = Provider.family<Dio, BooruConfig>((ref, config) {
final cacheDir = ref.watch(httpCacheDirProvider);
final userAgentGenerator = ref.watch(userAgentGeneratorProvider(config));
final loggerService = ref.watch(loggerProvider);
final booruFactory = ref.watch(booruFactoryProvider);

return DioArgs(
return newDio(DioArgs(
cacheDir: cacheDir,
baseUrl: config.url,
userAgentGenerator: userAgentGenerator,
booruConfig: config,
loggerService: loggerService,
booruFactory: booruFactory,
);
));
});

final httpCacheDirProvider = Provider<Directory>(
Expand Down Expand Up @@ -492,7 +493,7 @@ final blacklistTagsProvider =

final booruSiteValidatorProvider =
FutureProvider.autoDispose.family<bool, BooruConfig>((ref, config) {
final dio = newDio(ref.watch(dioArgsProvider(config)));
final dio = ref.watch(dioProvider(config));
final login =
config.login.toOption().fold(() => null, (v) => v.isEmpty ? null : v);
final apiKey =
Expand Down
1 change: 0 additions & 1 deletion lib/boorus/sankaku/sankaku.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/core/scaffolds/artist_page_scaffold.dart';
import 'package:boorusama/core/tags/tags.dart';
import 'package:boorusama/foundation/caching/caching.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'package:boorusama/router.dart';
import 'sankaku_post.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/boorus/sankaku/sankaku_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ part of 'sankaku.dart';

final sankakuClientProvider = Provider.family<SankakuClient, BooruConfig>(
(ref, config) {
final dio = newDio(ref.watch(dioArgsProvider(config)));
final dio = ref.watch(dioProvider(config));
final booruFactory = ref.watch(booruFactoryProvider);
final booru = booruFactory.create(type: config.booruType);

Expand Down
3 changes: 1 addition & 2 deletions lib/boorus/shimmie2/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import 'package:boorusama/clients/shimmie2/shimmie2_client.dart';
import 'package:boorusama/core/autocompletes/autocompletes.dart';
import 'package:boorusama/core/configs/configs.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'package:boorusama/foundation/path.dart';

final shimmie2ClientProvider = Provider.family<Shimmie2Client, BooruConfig>(
(ref, config) {
final dio = newDio(ref.watch(dioArgsProvider(config)));
final dio = ref.watch(dioProvider(config));

return Shimmie2Client(
dio: dio,
Expand Down
3 changes: 1 addition & 2 deletions lib/boorus/szurubooru/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import 'package:boorusama/core/configs/configs.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/core/tags/tags.dart';
import 'package:boorusama/dart.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'package:boorusama/foundation/path.dart';
import 'package:boorusama/functional.dart';
import 'post_votes/post_votes.dart';
import 'szurubooru_post.dart';

final szurubooruClientProvider = Provider.family<SzurubooruClient, BooruConfig>(
(ref, config) {
final dio = newDio(ref.watch(dioArgsProvider(config)));
final dio = ref.watch(dioProvider(config));

return SzurubooruClient(
dio: dio,
Expand Down
3 changes: 1 addition & 2 deletions lib/boorus/zerochan/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import 'package:boorusama/core/autocompletes/autocompletes.dart';
import 'package:boorusama/core/configs/configs.dart';
import 'package:boorusama/core/posts/posts.dart';
import 'package:boorusama/core/tags/tags.dart';
import 'package:boorusama/foundation/networking/networking.dart';
import 'package:boorusama/foundation/path.dart' as path;
import 'zerochan_post.dart';

final zerochanClientProvider =
Provider.family<ZerochanClient, BooruConfig>((ref, config) {
final dio = newDio(ref.watch(dioArgsProvider(config)));
final dio = ref.watch(dioProvider(config));
final logger = ref.watch(loggerProvider);

return ZerochanClient(
Expand Down
8 changes: 5 additions & 3 deletions lib/core/comments/youtube_preview_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import 'package:flutter/material.dart';

// Package imports:
import 'package:dio/dio.dart';
import 'package:extended_image/extended_image.dart';
import 'package:html/parser.dart';
import 'package:material_symbols_icons/symbols.dart';

// Project imports:
import 'package:boorusama/core/images/dio_extended_image.dart';
import 'package:boorusama/core/images/images.dart';
import 'package:boorusama/foundation/theme.dart';
import 'package:boorusama/foundation/url_launcher.dart';
Expand All @@ -24,8 +24,9 @@ class YoutubePreviewBox extends StatelessWidget {
@override
Widget build(BuildContext context) {
try {
final dio = Dio();
return FutureBuilder<PreviewUrlData>(
future: Dio()
future: dio
.getUri(uri)
.then((value) => value.data)
.then((value) => parseHtmlAsync(value, uri.toString())),
Expand Down Expand Up @@ -60,8 +61,9 @@ class YoutubePreviewBox extends StatelessWidget {
ClipRRect(
borderRadius:
const BorderRadius.all(Radius.circular(8)),
child: ExtendedImage.network(
child: DioExtendedImage.network(
data.previewImage!,
dio: dio,
fit: BoxFit.contain,
cacheMaxAge: kDefaultImageCacheDuration,
),
Expand Down
4 changes: 3 additions & 1 deletion lib/core/configs/booru_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class BooruFactory {
return null;
}

Booru? getBooruFromId(int id) => boorus.firstWhereOrNull((e) => e.id == id);

Booru? create({
required BooruType type,
}) {
Expand All @@ -49,6 +51,6 @@ class BooruFactory {
BooruType.unknown => 0,
};

return boorus.firstWhereOrNull((e) => e.id == id);
return getBooruFromId(id);
}
}
2 changes: 1 addition & 1 deletion lib/core/downloads/download_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final downloadServiceProvider = Provider.family<DownloadService, BooruConfig>(
return BackgroundDownloader();
},
dependencies: [
dioArgsProvider,
dioProvider,
downloadNotificationProvider,
currentBooruConfigProvider,
settingsProvider,
Expand Down
Loading