initial
This commit is contained in:
72
lib/domain/clash/clash_config.dart
Normal file
72
lib/domain/clash/clash_config.dart
Normal file
@@ -0,0 +1,72 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:hiddify/domain/clash/clash_enums.dart';
|
||||
|
||||
part 'clash_config.freezed.dart';
|
||||
part 'clash_config.g.dart';
|
||||
|
||||
@freezed
|
||||
class ClashConfig with _$ClashConfig {
|
||||
const ClashConfig._();
|
||||
|
||||
@JsonSerializable(includeIfNull: false, fieldRename: FieldRename.kebab)
|
||||
const factory ClashConfig({
|
||||
@JsonKey(name: 'port') int? httpPort,
|
||||
int? socksPort,
|
||||
int? redirPort,
|
||||
int? tproxyPort,
|
||||
int? mixedPort,
|
||||
List<String>? authentication,
|
||||
bool? allowLan,
|
||||
String? bindAddress,
|
||||
TunnelMode? mode,
|
||||
LogLevel? logLevel,
|
||||
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(),
|
||||
socksPort: (patch.socksPort ?? optionOf(socksPort)).toNullable(),
|
||||
redirPort: (patch.redirPort ?? optionOf(redirPort)).toNullable(),
|
||||
tproxyPort: (patch.tproxyPort ?? optionOf(tproxyPort)).toNullable(),
|
||||
mixedPort: (patch.mixedPort ?? optionOf(mixedPort)).toNullable(),
|
||||
authentication:
|
||||
(patch.authentication ?? optionOf(authentication)).toNullable(),
|
||||
allowLan: (patch.allowLan ?? optionOf(allowLan)).toNullable(),
|
||||
bindAddress: (patch.bindAddress ?? optionOf(bindAddress)).toNullable(),
|
||||
mode: (patch.mode ?? optionOf(mode)).toNullable(),
|
||||
logLevel: (patch.logLevel ?? optionOf(logLevel)).toNullable(),
|
||||
ipv6: (patch.ipv6 ?? optionOf(ipv6)).toNullable(),
|
||||
);
|
||||
}
|
||||
|
||||
factory ClashConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$ClashConfigFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ClashConfigPatch with _$ClashConfigPatch {
|
||||
const ClashConfigPatch._();
|
||||
|
||||
@JsonSerializable(includeIfNull: false)
|
||||
const factory ClashConfigPatch({
|
||||
Option<int>? httpPort,
|
||||
Option<int>? socksPort,
|
||||
Option<int>? redirPort,
|
||||
Option<int>? tproxyPort,
|
||||
Option<int>? mixedPort,
|
||||
Option<List<String>>? authentication,
|
||||
Option<bool>? allowLan,
|
||||
Option<String>? bindAddress,
|
||||
Option<TunnelMode>? mode,
|
||||
Option<LogLevel>? logLevel,
|
||||
Option<bool>? ipv6,
|
||||
}) = _ClashConfigPatch;
|
||||
}
|
||||
Reference in New Issue
Block a user