Migrate to singbox
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
export 'clash_config.dart';
|
||||
export 'clash_enums.dart';
|
||||
export 'clash_facade.dart';
|
||||
export 'clash_failures.dart';
|
||||
export 'clash_log.dart';
|
||||
export 'clash_proxy.dart';
|
||||
export 'clash_traffic.dart';
|
||||
|
||||
@@ -24,12 +24,6 @@ class ClashConfig with _$ClashConfig {
|
||||
bool? ipv6,
|
||||
}) = _ClashConfig;
|
||||
|
||||
static const initial = ClashConfig(
|
||||
httpPort: 12346,
|
||||
socksPort: 12347,
|
||||
mixedPort: 12348,
|
||||
);
|
||||
|
||||
ClashConfig patch(ClashConfigPatch patch) {
|
||||
return copyWith(
|
||||
httpPort: (patch.httpPort ?? optionOf(httpPort)).toNullable(),
|
||||
|
||||
@@ -38,6 +38,7 @@ enum ProxyType {
|
||||
hysteria("Hysteria"),
|
||||
wireGuard("WireGuard"),
|
||||
tuic("Tuic"),
|
||||
ssh("SSH"),
|
||||
relay("Relay"),
|
||||
selector("Selector"),
|
||||
fallback("Fallback"),
|
||||
|
||||
@@ -1,32 +1,24 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:hiddify/domain/clash/clash.dart';
|
||||
import 'package:hiddify/domain/constants.dart';
|
||||
import 'package:hiddify/domain/core_service_failure.dart';
|
||||
|
||||
abstract class ClashFacade {
|
||||
TaskEither<ClashFailure, ClashConfig> getConfigs();
|
||||
TaskEither<CoreServiceFailure, ClashConfig> getConfigs();
|
||||
|
||||
TaskEither<ClashFailure, bool> validateConfig(String configFileName);
|
||||
TaskEither<CoreServiceFailure, Unit> patchOverrides(ClashConfig overrides);
|
||||
|
||||
/// change active configuration file by [configFileName]
|
||||
TaskEither<ClashFailure, Unit> changeConfigs(String configFileName);
|
||||
TaskEither<CoreServiceFailure, List<ClashProxy>> getProxies();
|
||||
|
||||
TaskEither<ClashFailure, Unit> patchOverrides(ClashConfig overrides);
|
||||
|
||||
TaskEither<ClashFailure, List<ClashProxy>> getProxies();
|
||||
|
||||
TaskEither<ClashFailure, Unit> changeProxy(
|
||||
TaskEither<CoreServiceFailure, Unit> changeProxy(
|
||||
String selectorName,
|
||||
String proxyName,
|
||||
);
|
||||
|
||||
TaskEither<ClashFailure, int> testDelay(
|
||||
TaskEither<CoreServiceFailure, int> testDelay(
|
||||
String proxyName, {
|
||||
String testUrl = Constants.delayTestUrl,
|
||||
String testUrl = Defaults.delayTestUrl,
|
||||
});
|
||||
|
||||
TaskEither<ClashFailure, ClashTraffic> getTraffic();
|
||||
|
||||
Stream<Either<ClashFailure, ClashLog>> watchLogs();
|
||||
Stream<Either<CoreServiceFailure, ClashTraffic>> watchTraffic();
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:hiddify/core/locale/locale.dart';
|
||||
import 'package:hiddify/domain/failures.dart';
|
||||
|
||||
part 'clash_failures.freezed.dart';
|
||||
|
||||
// TODO: rewrite
|
||||
@freezed
|
||||
sealed class ClashFailure with _$ClashFailure, Failure {
|
||||
const ClashFailure._();
|
||||
|
||||
const factory ClashFailure.unexpected(
|
||||
Object error,
|
||||
StackTrace stackTrace,
|
||||
) = ClashUnexpectedFailure;
|
||||
|
||||
const factory ClashFailure.core([String? error]) = ClashCoreFailure;
|
||||
|
||||
@override
|
||||
String present(TranslationsEn t) {
|
||||
return switch (this) {
|
||||
ClashUnexpectedFailure() => t.failure.clash.unexpected,
|
||||
ClashCoreFailure(:final error) =>
|
||||
t.failure.clash.core(reason: error ?? ""),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ part 'clash_proxy.g.dart';
|
||||
|
||||
// TODO: test and improve
|
||||
@Freezed(fromJson: true)
|
||||
class ClashProxy with _$ClashProxy {
|
||||
sealed class ClashProxy with _$ClashProxy {
|
||||
const ClashProxy._();
|
||||
|
||||
const factory ClashProxy.group({
|
||||
@@ -15,6 +15,7 @@ class ClashProxy with _$ClashProxy {
|
||||
@JsonKey(fromJson: _typeFromJson) required ProxyType type,
|
||||
required List<String> all,
|
||||
required String now,
|
||||
@Default(false) bool udp,
|
||||
List<ClashHistory>? history,
|
||||
@JsonKey(includeFromJson: false, includeToJson: false) int? delay,
|
||||
}) = ClashProxyGroup;
|
||||
@@ -22,6 +23,7 @@ class ClashProxy with _$ClashProxy {
|
||||
const factory ClashProxy.item({
|
||||
required String name,
|
||||
@JsonKey(fromJson: _typeFromJson) required ProxyType type,
|
||||
@Default(false) bool udp,
|
||||
List<ClashHistory>? history,
|
||||
@JsonKey(includeFromJson: false, includeToJson: false) int? delay,
|
||||
}) = ClashProxyItem;
|
||||
|
||||
Reference in New Issue
Block a user