import 'package:json_annotation/json_annotation.dart'; part 'config.g.dart'; @JsonSerializable(includeIfNull: false) class SingBoxConfig { Log? log; Dns? dns; Route? route; List? inbounds; List? outbounds; Experimental? experimental; SingBoxConfig({ this.log, this.dns, this.route, this.inbounds, this.outbounds, this.experimental, }); factory SingBoxConfig.fromJson(Map json) => _$SingBoxConfigFromJson(json); Map toJson() => _$SingBoxConfigToJson(this); } @JsonSerializable(includeIfNull: false) class Log { bool disabled; String? level; String? output; bool timestamp; Log({ required this.disabled, this.level, this.output, required this.timestamp, }); factory Log.fromJson(Map json) => _$LogFromJson(json); Map toJson() => _$LogToJson(this); } @JsonSerializable(includeIfNull: false) class Dns { List servers; List rules; Dns({ required this.servers, required this.rules, }); factory Dns.fromJson(Map json) => _$DnsFromJson(json); Map toJson() => _$DnsToJson(this); } @JsonSerializable(includeIfNull: false) class DnsServer { String tag; String address; @JsonKey(name: 'address_resolver') String? addressResolver; String? strategy; String? detour; DnsServer({ required this.tag, required this.address, this.addressResolver, this.strategy, this.detour, }); factory DnsServer.fromJson(Map json) => _$DnsServerFromJson(json); Map toJson() => _$DnsServerToJson(this); } @JsonSerializable(includeIfNull: false) class RouteRule { String? protocol; List? geosite; List? geoip; List? domain; @JsonKey(name: 'ip_cidr') List? ipCidr; List? port; @JsonKey(name: 'port_range') List? portRange; String? outbound; @JsonKey(name: 'process_name') List? processName; RouteRule({ this.protocol, this.geosite, this.geoip, this.domain, this.ipCidr, this.port, this.portRange, this.outbound, this.processName, }); factory RouteRule.fromJson(Map json) => _$RouteRuleFromJson(json); Map toJson() => _$RouteRuleToJson(this); } @JsonSerializable(includeIfNull: false) class DnsRule { List? geosite; List? geoip; List? domain; String? server; @JsonKey(name: 'disable_cache') bool? disableCache; List? outbound; DnsRule({ this.geosite, this.geoip, this.domain, this.server, this.disableCache, this.outbound, }); factory DnsRule.fromJson(Map json) => _$DnsRuleFromJson(json); Map toJson() => _$DnsRuleToJson(this); } @JsonSerializable(includeIfNull: false) class Route { Geoip? geoip; Geosite? geosite; List? rules; @JsonKey(name: 'auto_detect_interface') bool autoDetectInterface; @JsonKey(name: 'final') String? finalTag; Route({ this.geoip, this.geosite, this.rules, required this.autoDetectInterface, this.finalTag, }); factory Route.fromJson(Map json) => _$RouteFromJson(json); Map toJson() => _$RouteToJson(this); } @JsonSerializable(includeIfNull: false) class Geoip { String path; Geoip({ required this.path, }); factory Geoip.fromJson(Map json) => _$GeoipFromJson(json); Map toJson() => _$GeoipToJson(this); } @JsonSerializable(includeIfNull: false) class Geosite { String path; Geosite({ required this.path, }); factory Geosite.fromJson(Map json) => _$GeositeFromJson(json); Map toJson() => _$GeositeToJson(this); } @JsonSerializable(includeIfNull: false) class Inbound { String type; String? tag; String? listen; @JsonKey(name: 'listen_port') int? listenPort; List? users; @JsonKey(name: 'interface_name') String? interfaceName; @JsonKey(name: 'inet4_address') String? inet4Address; @JsonKey(name: 'inet6_address') String? inet6Address; int? mtu; @JsonKey(name: 'auto_route') bool? autoRoute; @JsonKey(name: 'strict_route') bool? strictRoute; String? stack; bool? sniff; Inbound({ required this.type, this.tag, this.listen, this.listenPort, this.users, this.interfaceName, this.inet4Address, this.inet6Address, this.mtu, this.autoRoute, this.strictRoute, this.stack, this.sniff, }); factory Inbound.fromJson(Map json) => _$InboundFromJson(json); Map toJson() => _$InboundToJson(this); } @JsonSerializable(includeIfNull: false) class Outbound { String type; String? tag; String? server; @JsonKey(name: 'server_port') int? serverPort; String? version; String? username; String? method; String? password; String? plugin; @JsonKey(name: 'plugin_opts') String? pluginOpts; String? uuid; String? flow; String? security; @JsonKey(name: 'alter_id') int? alterId; String? network; Tls? tls; Transport? transport; int? upMbps; int? downMbps; String? obfs; String? auth; @JsonKey(name: 'auth_str') String? authStr; @JsonKey(name: 'recv_window_conn') int? recvWindowConn; @JsonKey(name: 'recv_window') int? recvWindow; @JsonKey(name: 'disable_mtu_discovery') int? disableMtuDiscovery; Outbound({ required this.type, this.tag, this.server, this.serverPort, this.version, this.username, this.method, this.password, this.plugin, this.pluginOpts, this.uuid, this.flow, this.security, this.alterId, this.network, this.tls, this.transport, this.upMbps, this.downMbps, this.obfs, this.auth, this.authStr, this.recvWindowConn, this.recvWindow, this.disableMtuDiscovery, }); factory Outbound.fromJson(Map json) => _$OutboundFromJson(json); Map toJson() => _$OutboundToJson(this); } @JsonSerializable(includeIfNull: false) class Tls { bool enabled; @JsonKey(name: 'server_name') String serverName; bool insecure; List? alpn; UTls? utls; Reality? reality; Tls({ required this.enabled, required this.serverName, required this.insecure, this.alpn, this.utls, this.reality, }); factory Tls.fromJson(Map json) => _$TlsFromJson(json); Map toJson() => _$TlsToJson(this); } @JsonSerializable(includeIfNull: false) class UTls { bool enabled; String? fingerprint; UTls({ required this.enabled, this.fingerprint, }); factory UTls.fromJson(Map json) => _$UTlsFromJson(json); Map toJson() => _$UTlsToJson(this); } @JsonSerializable(includeIfNull: false) class Reality { bool enabled; @JsonKey(name: 'public_key') String publicKey; @JsonKey(name: "short_id") String? shortId; Reality({ required this.enabled, required this.publicKey, this.shortId, }); factory Reality.fromJson(Map json) => _$RealityFromJson(json); Map toJson() => _$RealityToJson(this); } @JsonSerializable(includeIfNull: false) class Transport { String type; String? host; String? path; @JsonKey(name: 'service_name') String? serviceName; Transport({ required this.type, this.host, this.path, this.serviceName, }); factory Transport.fromJson(Map json) => _$TransportFromJson(json); Map toJson() => _$TransportToJson(this); } @JsonSerializable(includeIfNull: false) class User { String? username; String? password; User({ this.username, this.password, }); factory User.fromJson(Map json) => _$UserFromJson(json); Map toJson() => _$UserToJson(this); } @JsonSerializable(includeIfNull: false) class Experimental { @JsonKey(name: 'clash_api') ClashApi? clashApi; Experimental({ this.clashApi, }); factory Experimental.fromJson(Map json) => _$ExperimentalFromJson(json); Map toJson() => _$ExperimentalToJson(this); } @JsonSerializable(includeIfNull: false) class ClashApi { @JsonKey(name: 'external_controller') String externalController; @JsonKey(name: 'store_selected') bool storeSelected; @JsonKey(name: 'cache_file') String? cacheFile; ClashApi({ required this.externalController, required this.storeSelected, this.cacheFile, }); factory ClashApi.fromJson(Map json) => _$ClashApiFromJson(json); Map toJson() => _$ClashApiToJson(this); }