import 'package:json_annotation/json_annotation.dart';

/// This allows the `User` class to access private members in
/// the generated file. The value for this is *.g.dart, where
/// the star denotes the source file name.
part 'configs.g.dart';

/// An annotation for the code generator to know that this class needs the
/// JSON serialization logic to be generated.
@JsonSerializable()
class Configs {
  Configs(
      this.port,
      this.socksPort,
      this.tproxyPort,
      this.redirPort,
      this.mixedPort,
      this.authentication,
      this.allowLan,
      this.bindAddress,
      this.mode,
      this.logLevel,
      this.ipv6);

  int port;
  @JsonKey(name: 'socks-port')
  int socksPort;
  @JsonKey(name: 'redir-port')
  int redirPort;
  @JsonKey(name: 'tproxy-port')
  int tproxyPort;
  @JsonKey(name: 'mixed-port')
  int mixedPort;
  List authentication;
  @JsonKey(name: 'allow-lan')
  bool allowLan;
  @JsonKey(name: 'bind-address')
  String bindAddress;
  String mode;
  @JsonKey(name: 'log-level')
  String logLevel;
  bool ipv6;

  /// A necessary factory constructor for creating a new Configs instance
  /// from a map. Pass the map to the generated `_$ConfigsFromJson()` constructor.
  /// The constructor is named after the source class, in this case, Configs.
  factory Configs.fromJson(Map<String, dynamic> json) =>
      _$ConfigsFromJson(json);

  /// `toJson` is the convention for a class to declare support for serialization
  /// to JSON. The implementation simply calls the private, generated
  /// helper method `_$ConfigsToJson`.
  Map<String, dynamic> toJson() => _$ConfigsToJson(this);
}
