Files
umbrix/lib/singbox/model/singbox_config_enum.dart

120 lines
2.6 KiB
Dart
Raw Normal View History

2024-02-15 12:24:42 +03:30
import 'dart:io';
2024-02-15 19:39:35 +03:30
import 'package:dart_mappable/dart_mappable.dart';
2023-12-01 12:56:24 +03:30
import 'package:hiddify/core/localization/translations.dart';
import 'package:hiddify/utils/platform_utils.dart';
2024-02-15 19:39:35 +03:30
part 'singbox_config_enum.mapper.dart';
@MappableEnum()
2023-12-01 12:56:24 +03:30
enum ServiceMode {
2024-02-15 19:39:35 +03:30
@MappableValue("proxy")
proxy,
2023-12-14 15:46:15 +03:30
2024-02-15 19:39:35 +03:30
@MappableValue("system-proxy")
systemProxy,
2023-12-14 15:46:15 +03:30
2024-02-15 19:39:35 +03:30
@MappableValue("vpn")
tun,
@MappableValue("vpn-service")
tunService;
2023-12-01 12:56:24 +03:30
static ServiceMode get defaultMode =>
PlatformUtils.isDesktop ? systemProxy : tun;
2024-02-15 12:24:42 +03:30
/// supported service mode based on platform, use this instead of [values] in UI
2023-12-01 12:56:24 +03:30
static List<ServiceMode> get choices {
2024-02-15 12:24:42 +03:30
if (Platform.isWindows || Platform.isLinux) {
2023-12-01 12:56:24 +03:30
return values;
2024-02-15 12:24:42 +03:30
} else if (Platform.isMacOS) {
return [proxy, systemProxy, tun];
2023-12-01 12:56:24 +03:30
}
2024-02-15 12:24:42 +03:30
// mobile
2023-12-01 12:56:24 +03:30
return [proxy, tun];
}
String present(TranslationsEn t) => switch (this) {
proxy => t.settings.config.serviceModes.proxy,
systemProxy => t.settings.config.serviceModes.systemProxy,
2023-12-29 15:35:01 +03:30
tun =>
"${t.settings.config.serviceModes.tun}${PlatformUtils.isDesktop ? " (${t.settings.experimental})" : ""}",
2024-02-14 15:51:58 +01:00
tunService =>
"${t.settings.config.serviceModes.tunService}${PlatformUtils.isDesktop ? " (${t.settings.experimental})" : ""}",
2023-12-01 12:56:24 +03:30
};
}
2024-02-15 19:39:35 +03:30
@MappableEnum()
2023-12-01 12:56:24 +03:30
enum IPv6Mode {
2024-02-15 19:39:35 +03:30
@MappableValue("ipv4_only")
disable,
2023-12-01 12:56:24 +03:30
2024-02-15 19:39:35 +03:30
@MappableValue("prefer_ipv4")
enable,
2023-12-01 12:56:24 +03:30
2024-02-15 19:39:35 +03:30
@MappableValue("prefer_ipv6")
prefer,
@MappableValue("ipv6_only")
only;
2023-12-01 12:56:24 +03:30
String present(TranslationsEn t) => switch (this) {
disable => t.settings.config.ipv6Modes.disable,
enable => t.settings.config.ipv6Modes.enable,
prefer => t.settings.config.ipv6Modes.prefer,
only => t.settings.config.ipv6Modes.only,
};
}
2024-02-15 19:39:35 +03:30
@MappableEnum()
2023-12-01 12:56:24 +03:30
enum DomainStrategy {
2024-02-15 19:39:35 +03:30
@MappableValue("")
2023-12-01 12:56:24 +03:30
auto(""),
2024-02-15 19:39:35 +03:30
@MappableValue("prefer_ipv6")
2023-12-01 12:56:24 +03:30
preferIpv6("prefer_ipv6"),
2024-02-15 19:39:35 +03:30
@MappableValue("prefer_ipv4")
2023-12-01 12:56:24 +03:30
preferIpv4("prefer_ipv4"),
2024-02-15 19:39:35 +03:30
@MappableValue("ipv4_only")
2023-12-01 12:56:24 +03:30
ipv4Only("ipv4_only"),
2024-02-15 19:39:35 +03:30
@MappableValue("ipv6_only")
2023-12-01 12:56:24 +03:30
ipv6Only("ipv6_only");
const DomainStrategy(this.key);
final String key;
String get displayName => switch (this) {
auto => "auto",
_ => key,
};
}
2024-02-15 19:39:35 +03:30
@MappableEnum()
2023-12-01 12:56:24 +03:30
enum TunImplementation {
mixed,
system,
gVisor;
}
2024-01-19 22:26:23 +03:30
2024-02-15 19:39:35 +03:30
@MappableEnum()
2024-01-19 22:26:23 +03:30
enum MuxProtocol {
h2mux,
smux,
yamux;
}
2024-02-03 12:36:27 +03:30
2024-02-15 19:39:35 +03:30
@MappableEnum()
2024-02-03 12:36:27 +03:30
enum WarpDetourMode {
outbound,
inbound;
String present(TranslationsEn t) => switch (this) {
outbound => t.settings.config.warpDetourModes.outbound,
inbound => t.settings.config.warpDetourModes.inbound,
};
}