Files
umbrix/lib/singbox/model/singbox_rule.dart
problematicconsumer 3541f8e3db Change mapping
2024-02-17 13:12:15 +03:30

36 lines
785 B
Dart

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? 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);
}
enum RuleOutbound { proxy, bypass, block }
@JsonEnum(valueField: 'key')
enum RuleNetwork {
tcpAndUdp(""),
tcp("tcp"),
udp("udp");
const RuleNetwork(this.key);
final String? key;
}