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

36 lines
803 B
Dart
Raw Normal View History

2024-02-17 11:58:34 +03:30
import 'package:freezed_annotation/freezed_annotation.dart';
part 'singbox_rule.freezed.dart';
part 'singbox_rule.g.dart';
@freezed
class SingboxRule with _$SingboxRule {
const SingboxRule._();
@JsonSerializable(fieldRename: FieldRename.kebab)
const factory SingboxRule({
String? ruleSetUrl,
2024-02-17 11:58:34 +03:30
String? domains,
String? ip,
String? port,
String? protocol,
@Default(RuleNetwork.tcpAndUdp) RuleNetwork network,
@Default(RuleOutbound.proxy) RuleOutbound outbound,
}) = _SingboxRule;
factory SingboxRule.fromJson(Map<String, dynamic> json) => _$SingboxRuleFromJson(json);
2023-12-01 12:56:24 +03:30
}
enum RuleOutbound { proxy, bypass, block }
2024-02-17 11:58:34 +03:30
@JsonEnum(valueField: 'key')
2023-12-01 12:56:24 +03:30
enum RuleNetwork {
2024-02-17 11:58:34 +03:30
tcpAndUdp(""),
tcp("tcp"),
udp("udp");
2023-12-01 12:56:24 +03:30
2024-02-17 11:58:34 +03:30
const RuleNetwork(this.key);
2023-12-01 12:56:24 +03:30
2024-02-17 11:58:34 +03:30
final String? key;
2023-12-01 12:56:24 +03:30
}