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 cleanExif = true;
|
||||
|
||||
|
||||
static String? httpProxy;
|
||||
static String get defaultHomeserver => _defaultHomeserver;
|
||||
static double fontSizeFactor = 1;
|
||||
static const Color chatColor = primaryColor;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
abstract class SettingKeys {
|
||||
static const String httpProxy = 'xyz.extera.next.httpProxy';
|
||||
static const String cleanExif = 'xyz.extera.next.cleanExif';
|
||||
static const String displayNavigationRail = 'chat.fluffy.displayNavigationRail';
|
||||
static const String hideAvatarsInInvites = 'xyz.extera.next.hideAvatarsInInvites';
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ abstract class ClientManager {
|
|||
return Client(
|
||||
clientName,
|
||||
httpClient:
|
||||
PlatformInfos.isAndroid ? CustomHttpClient.createHTTPClient() : null,
|
||||
CustomHttpClient.createHTTPClient(),
|
||||
verificationMethods: {
|
||||
KeyVerificationMethod.numbers,
|
||||
if (kIsWeb || PlatformInfos.isMobile || PlatformInfos.isLinux)
|
||||
|
|
|
|||
|
|
@ -1,29 +1,43 @@
|
|||
import 'dart:convert';
|
||||
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/io_client.dart';
|
||||
|
||||
import 'package:extera_next/config/isrg_x1.dart';
|
||||
|
||||
class CustomHttpClient {
|
||||
static HttpClient customHttpClient(String? cert) {
|
||||
static HttpClient? customHttpClient(String? cert) {
|
||||
if (PlatformInfos.isWeb) return null;
|
||||
|
||||
final context = SecurityContext.defaultContext;
|
||||
|
||||
try {
|
||||
if (cert != null) {
|
||||
final bytes = utf8.encode(cert);
|
||||
context.setTrustedCertificatesBytes(bytes);
|
||||
}
|
||||
} on TlsException catch (e) {
|
||||
if (e.osError != null &&
|
||||
e.osError!.message.contains('CERT_ALREADY_IN_HASH_TABLE')) {
|
||||
} else {
|
||||
rethrow;
|
||||
if (PlatformInfos.isAndroid) {
|
||||
try {
|
||||
if (cert != null) {
|
||||
final bytes = utf8.encode(cert);
|
||||
context.setTrustedCertificatesBytes(bytes);
|
||||
}
|
||||
} on TlsException catch (e) {
|
||||
if (e.osError != null &&
|
||||
e.osError!.message.contains('CERT_ALREADY_IN_HASH_TABLE')) {
|
||||
} 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));
|
||||
|
|
|
|||
Loading…
Reference in New Issue