add AppConfig.httpProxy
This commit is contained in:
parent
6e4ab00b57
commit
d84735e03b
|
|
@ -15,6 +15,8 @@ abstract class AppConfig {
|
||||||
static bool enableGradient = true;
|
static bool enableGradient = true;
|
||||||
static bool cleanExif = true;
|
static bool cleanExif = true;
|
||||||
|
|
||||||
|
|
||||||
|
static String? httpProxy;
|
||||||
static String get defaultHomeserver => _defaultHomeserver;
|
static String get defaultHomeserver => _defaultHomeserver;
|
||||||
static double fontSizeFactor = 1;
|
static double fontSizeFactor = 1;
|
||||||
static const Color chatColor = primaryColor;
|
static const Color chatColor = primaryColor;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
abstract class SettingKeys {
|
abstract class SettingKeys {
|
||||||
|
static const String httpProxy = 'xyz.extera.next.httpProxy';
|
||||||
static const String cleanExif = 'xyz.extera.next.cleanExif';
|
static const String cleanExif = 'xyz.extera.next.cleanExif';
|
||||||
static const String displayNavigationRail = 'chat.fluffy.displayNavigationRail';
|
static const String displayNavigationRail = 'chat.fluffy.displayNavigationRail';
|
||||||
static const String hideAvatarsInInvites = 'xyz.extera.next.hideAvatarsInInvites';
|
static const String hideAvatarsInInvites = 'xyz.extera.next.hideAvatarsInInvites';
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ abstract class ClientManager {
|
||||||
return Client(
|
return Client(
|
||||||
clientName,
|
clientName,
|
||||||
httpClient:
|
httpClient:
|
||||||
PlatformInfos.isAndroid ? CustomHttpClient.createHTTPClient() : null,
|
CustomHttpClient.createHTTPClient(),
|
||||||
verificationMethods: {
|
verificationMethods: {
|
||||||
KeyVerificationMethod.numbers,
|
KeyVerificationMethod.numbers,
|
||||||
if (kIsWeb || PlatformInfos.isMobile || PlatformInfos.isLinux)
|
if (kIsWeb || PlatformInfos.isMobile || PlatformInfos.isLinux)
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,43 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:extera_next/config/app_config.dart';
|
||||||
|
import 'package:extera_next/utils/platform_infos.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:http/io_client.dart';
|
import 'package:http/io_client.dart';
|
||||||
|
|
||||||
import 'package:extera_next/config/isrg_x1.dart';
|
import 'package:extera_next/config/isrg_x1.dart';
|
||||||
|
|
||||||
class CustomHttpClient {
|
class CustomHttpClient {
|
||||||
static HttpClient customHttpClient(String? cert) {
|
static HttpClient? customHttpClient(String? cert) {
|
||||||
|
if (PlatformInfos.isWeb) return null;
|
||||||
|
|
||||||
final context = SecurityContext.defaultContext;
|
final context = SecurityContext.defaultContext;
|
||||||
|
|
||||||
try {
|
if (PlatformInfos.isAndroid) {
|
||||||
if (cert != null) {
|
try {
|
||||||
final bytes = utf8.encode(cert);
|
if (cert != null) {
|
||||||
context.setTrustedCertificatesBytes(bytes);
|
final bytes = utf8.encode(cert);
|
||||||
}
|
context.setTrustedCertificatesBytes(bytes);
|
||||||
} on TlsException catch (e) {
|
}
|
||||||
if (e.osError != null &&
|
} on TlsException catch (e) {
|
||||||
e.osError!.message.contains('CERT_ALREADY_IN_HASH_TABLE')) {
|
if (e.osError != null &&
|
||||||
} else {
|
e.osError!.message.contains('CERT_ALREADY_IN_HASH_TABLE')) {
|
||||||
rethrow;
|
} else {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return HttpClient(context: context);
|
final client = HttpClient(context: context);
|
||||||
|
|
||||||
|
if (AppConfig.httpProxy != null) {
|
||||||
|
client.findProxy = (uri) {
|
||||||
|
return "PROXY ${AppConfig.httpProxy};";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
static http.Client createHTTPClient() => IOClient(customHttpClient(ISRG_X1));
|
static http.Client createHTTPClient() => IOClient(customHttpClient(ISRG_X1));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue