Support core status check and force restart Optimize proxies page and access page Update flutter and pub dependencies
26 lines
758 B
Dart
26 lines
758 B
Dart
import 'dart:io';
|
|
|
|
import 'package:fl_clash/common/common.dart';
|
|
import 'package:fl_clash/state.dart';
|
|
|
|
class FlClashHttpOverrides extends HttpOverrides {
|
|
static String handleFindProxy(Uri url) {
|
|
if ([localhost].contains(url.host)) {
|
|
return 'DIRECT';
|
|
}
|
|
final port = globalState.config.patchClashConfig.mixedPort;
|
|
final isStart = globalState.appState.runTime != null;
|
|
commonPrint.log('find $url proxy:$isStart');
|
|
if (!isStart) return 'DIRECT';
|
|
return 'PROXY localhost:$port';
|
|
}
|
|
|
|
@override
|
|
HttpClient createHttpClient(SecurityContext? context) {
|
|
final client = super.createHttpClient(context);
|
|
client.badCertificateCallback = (_, _, _) => true;
|
|
client.findProxy = handleFindProxy;
|
|
return client;
|
|
}
|
|
}
|