2023-12-01 12:56:24 +03:30
|
|
|
import 'dart:convert';
|
|
|
|
|
|
2024-02-17 11:58:34 +03:30
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2024-02-15 19:39:35 +03:30
|
|
|
import 'package:hiddify/core/model/optional_range.dart';
|
2024-02-16 18:45:56 +03:30
|
|
|
import 'package:hiddify/core/utils/json_converters.dart';
|
2023-12-01 12:56:24 +03:30
|
|
|
import 'package:hiddify/features/log/model/log_level.dart';
|
|
|
|
|
import 'package:hiddify/singbox/model/singbox_config_enum.dart';
|
|
|
|
|
import 'package:hiddify/singbox/model/singbox_rule.dart';
|
|
|
|
|
|
2024-02-17 11:58:34 +03:30
|
|
|
part 'singbox_config_option.freezed.dart';
|
|
|
|
|
part 'singbox_config_option.g.dart';
|
2023-12-01 12:56:24 +03:30
|
|
|
|
2024-02-17 11:58:34 +03:30
|
|
|
@freezed
|
|
|
|
|
class SingboxConfigOption with _$SingboxConfigOption {
|
|
|
|
|
const SingboxConfigOption._();
|
2023-12-01 12:56:24 +03:30
|
|
|
|
2024-02-17 11:58:34 +03:30
|
|
|
@JsonSerializable(fieldRename: FieldRename.kebab)
|
|
|
|
|
const factory SingboxConfigOption({
|
|
|
|
|
required bool executeConfigAsIs,
|
|
|
|
|
required LogLevel logLevel,
|
|
|
|
|
required bool resolveDestination,
|
|
|
|
|
required IPv6Mode ipv6Mode,
|
|
|
|
|
required String remoteDnsAddress,
|
|
|
|
|
required DomainStrategy remoteDnsDomainStrategy,
|
|
|
|
|
required String directDnsAddress,
|
|
|
|
|
required DomainStrategy directDnsDomainStrategy,
|
|
|
|
|
required int mixedPort,
|
|
|
|
|
required int localDnsPort,
|
|
|
|
|
required TunImplementation tunImplementation,
|
|
|
|
|
required int mtu,
|
|
|
|
|
required bool strictRoute,
|
|
|
|
|
required String connectionTestUrl,
|
|
|
|
|
@IntervalInSecondsConverter() required Duration urlTestInterval,
|
|
|
|
|
required bool enableClashApi,
|
|
|
|
|
required int clashApiPort,
|
|
|
|
|
required bool enableTun,
|
|
|
|
|
required bool enableTunService,
|
|
|
|
|
required bool setSystemProxy,
|
|
|
|
|
required bool bypassLan,
|
|
|
|
|
required bool allowConnectionFromLan,
|
|
|
|
|
required bool enableFakeDns,
|
|
|
|
|
required bool enableDnsRouting,
|
|
|
|
|
required bool independentDnsCache,
|
|
|
|
|
required bool enableTlsFragment,
|
|
|
|
|
@OptionalRangeJsonConverter() required OptionalRange tlsFragmentSize,
|
|
|
|
|
@OptionalRangeJsonConverter() required OptionalRange tlsFragmentSleep,
|
|
|
|
|
required bool enableTlsMixedSniCase,
|
|
|
|
|
required bool enableTlsPadding,
|
|
|
|
|
@OptionalRangeJsonConverter() required OptionalRange tlsPaddingSize,
|
|
|
|
|
required bool enableMux,
|
|
|
|
|
required bool muxPadding,
|
|
|
|
|
required int muxMaxStreams,
|
|
|
|
|
required MuxProtocol muxProtocol,
|
|
|
|
|
required String geoipPath,
|
|
|
|
|
required String geositePath,
|
|
|
|
|
required List<SingboxRule> rules,
|
2024-02-20 22:16:47 +03:30
|
|
|
required SingboxWarpOption warp,
|
2024-02-17 11:58:34 +03:30
|
|
|
}) = _SingboxConfigOption;
|
2023-12-01 12:56:24 +03:30
|
|
|
|
|
|
|
|
String format() {
|
|
|
|
|
const encoder = JsonEncoder.withIndent(' ');
|
2024-02-17 11:58:34 +03:30
|
|
|
return encoder.convert(toJson());
|
2023-12-01 12:56:24 +03:30
|
|
|
}
|
2024-02-17 11:58:34 +03:30
|
|
|
|
|
|
|
|
factory SingboxConfigOption.fromJson(Map<String, dynamic> json) =>
|
|
|
|
|
_$SingboxConfigOptionFromJson(json);
|
2023-12-01 12:56:24 +03:30
|
|
|
}
|
2024-02-20 22:16:47 +03:30
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
class SingboxWarpOption with _$SingboxWarpOption {
|
|
|
|
|
const factory SingboxWarpOption({
|
|
|
|
|
required bool enable,
|
|
|
|
|
required WarpDetourMode mode,
|
|
|
|
|
required String wireguardConfig,
|
|
|
|
|
required String licenseKey,
|
|
|
|
|
required String accountId,
|
|
|
|
|
required String accessToken,
|
|
|
|
|
required String cleanIp,
|
|
|
|
|
required int cleanPort,
|
|
|
|
|
@OptionalRangeJsonConverter() required OptionalRange warpNoise,
|
2024-02-21 20:03:20 +01:00
|
|
|
@OptionalRangeJsonConverter() required OptionalRange warpNoiseDelay,
|
2024-02-20 22:16:47 +03:30
|
|
|
}) = _SingboxWarpOption;
|
|
|
|
|
|
|
|
|
|
factory SingboxWarpOption.fromJson(Map<String, dynamic> json) =>
|
|
|
|
|
_$SingboxWarpOptionFromJson(json);
|
|
|
|
|
}
|