Refactor config options
This commit is contained in:
@@ -101,12 +101,17 @@ enum MuxProtocol {
|
||||
yamux;
|
||||
}
|
||||
|
||||
@JsonEnum(valueField: 'key')
|
||||
enum WarpDetourMode {
|
||||
outbound,
|
||||
inbound;
|
||||
proxyOverWarp("proxy_over_warp"),
|
||||
warpOverProxy("warp_over_proxy");
|
||||
|
||||
const WarpDetourMode(this.key);
|
||||
|
||||
final String key;
|
||||
|
||||
String present(TranslationsEn t) => switch (this) {
|
||||
outbound => t.settings.config.warpDetourModes.outbound,
|
||||
inbound => t.settings.config.warpDetourModes.inbound,
|
||||
proxyOverWarp => t.settings.config.warpDetourModes.proxyOverWarp,
|
||||
warpOverProxy => t.settings.config.warpDetourModes.warpOverProxy,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,19 +41,11 @@ class SingboxConfigOption with _$SingboxConfigOption {
|
||||
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,
|
||||
required SingboxMuxOption mux,
|
||||
required SingboxTlsTricks tlsTricks,
|
||||
required SingboxWarpOption warp,
|
||||
}) = _SingboxConfigOption;
|
||||
|
||||
@@ -68,7 +60,7 @@ class SingboxConfigOption with _$SingboxConfigOption {
|
||||
|
||||
@freezed
|
||||
class SingboxWarpOption with _$SingboxWarpOption {
|
||||
@JsonSerializable(fieldRename: FieldRename.kebab, createFieldMap: true)
|
||||
@JsonSerializable(fieldRename: FieldRename.kebab)
|
||||
const factory SingboxWarpOption({
|
||||
required bool enable,
|
||||
required WarpDetourMode mode,
|
||||
@@ -85,3 +77,33 @@ class SingboxWarpOption with _$SingboxWarpOption {
|
||||
factory SingboxWarpOption.fromJson(Map<String, dynamic> json) =>
|
||||
_$SingboxWarpOptionFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SingboxMuxOption with _$SingboxMuxOption {
|
||||
@JsonSerializable(fieldRename: FieldRename.kebab)
|
||||
const factory SingboxMuxOption({
|
||||
required bool enable,
|
||||
required bool padding,
|
||||
required int maxStreams,
|
||||
required MuxProtocol protocol,
|
||||
}) = _SingboxMuxOption;
|
||||
|
||||
factory SingboxMuxOption.fromJson(Map<String, dynamic> json) =>
|
||||
_$SingboxMuxOptionFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SingboxTlsTricks with _$SingboxTlsTricks {
|
||||
@JsonSerializable(fieldRename: FieldRename.kebab)
|
||||
const factory SingboxTlsTricks({
|
||||
required bool enableFragment,
|
||||
@OptionalRangeJsonConverter() required OptionalRange fragmentSize,
|
||||
@OptionalRangeJsonConverter() required OptionalRange fragmentSleep,
|
||||
required bool mixedSniCase,
|
||||
required bool enablePadding,
|
||||
@OptionalRangeJsonConverter() required OptionalRange paddingSize,
|
||||
}) = _SingboxTlsTricks;
|
||||
|
||||
factory SingboxTlsTricks.fromJson(Map<String, dynamic> json) =>
|
||||
_$SingboxTlsTricksFromJson(json);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user