Kropatz / boorusphere

Simple, content-focused booru viewer for Android
BSD 3-Clause "New" or "Revised" License
11 stars 0 forks source link

Feature: Proxy #1

Open bropines opened 2 weeks ago

bropines commented 2 weeks ago

Type

Functionality

Issue

since the original author didn't want to, I want to ask you to add socks or http proxy support. I live in a very cool country where booru services are almost constantly being banned

Feature

Proxy

Additional context

No response

Acknowledgements

Kropatz commented 1 week ago

Sure, can add that in the future. Have never used one, but from doing some quick googling I'm a little bit surprised that android doesn't support a system wide proxy. Only on WiFi and apps can ignore it?

If you want to hardcode a proxy for the time being, something like this might work (haven't tested it though, copied the instructions from here)

diff --git a/lib/data/dio/app_dio.dart b/lib/data/dio/app_dio.dart
index 8e52faf..6bc7f1b 100644
--- a/lib/data/dio/app_dio.dart
+++ b/lib/data/dio/app_dio.dart
@@ -1,3 +1,5 @@
+import 'dart:io';
+
 import 'package:boorusphere/data/dio/headers_interceptor.dart';
 import 'package:boorusphere/domain/repository/env_repo.dart';
 import 'package:cookie_jar/cookie_jar.dart';
@@ -12,7 +14,14 @@ class AppDio with DioMixin implements Dio {
     required EnvRepo envRepo,
   }) {
     options = BaseOptions();
-    httpClientAdapter = IOHttpClientAdapter();
+    httpClientAdapter = IOHttpClientAdapter(createHttpClient: () {
+      final client = HttpClient();
+      client.findProxy = (uri) {
+        return 'PROXY localhost:8888';
+      };
+      client.addProxyCredentials("localhost", 8888, '', HttpClientBasicCredentials('username', 'password'));
+      return client;
+    });
     final retryDelays = List.generate(5, (index) {
       return Duration(milliseconds: 400 + (100 * (index + 1)));
     });
bropines commented 1 week ago

even though it seems to me that hardcoding a proxy would not be the best idea. these are all methods, how can I add a proxy? In my understanding It would be normal like this

Screenshot_2024-11-10-17-09-39-155_com hippo ehviewer