proxie.dart 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. class Proxie {
  2. Proxie({
  3. required this.proxies,
  4. });
  5. late Map<String, ProxieProxiesItem> proxies;
  6. Proxie.fromJson(Map<String, dynamic> json) {
  7. proxies = (json['proxies'] as Map<String, dynamic>).map((key, value) => MapEntry(key, ProxieProxiesItem.fromJson(value)));
  8. }
  9. // Map<String, dynamic> toJson() {
  10. // final _data = <String, dynamic>{};
  11. // _data['proxies'] = proxies.toJson();
  12. // return _data;
  13. // }
  14. // @override
  15. // String toString() {
  16. // return toJson().toString();
  17. // }
  18. }
  19. class ProxieProxiesItem {
  20. ProxieProxiesItem({
  21. this.all,
  22. required this.history,
  23. required this.name,
  24. this.now,
  25. required this.type,
  26. required this.udp,
  27. });
  28. late List<String>? all;
  29. late List<ProxieProxiesItemHistory> history;
  30. late String name;
  31. late String? now;
  32. late String type;
  33. late bool udp;
  34. get delay {
  35. return history.isEmpty ? 0 : history.last.delay;
  36. }
  37. ProxieProxiesItem.fromJson(Map<String, dynamic> json) {
  38. all = json['all'] == null ? null : List.castFrom<dynamic, String>(json['all']);
  39. history = List.from(json['history']).map((e) => ProxieProxiesItemHistory.fromJson(e)).toList();
  40. name = json['name'];
  41. now = json['now'];
  42. type = json['type'];
  43. udp = json['udp'];
  44. }
  45. Map<String, dynamic> toJson() {
  46. final data = <String, dynamic>{};
  47. data['all'] = all;
  48. data['history'] = history.map((e) => e.toJson()).toList();
  49. data['name'] = name;
  50. data['now'] = now;
  51. data['type'] = type;
  52. data['udp'] = udp;
  53. return data;
  54. }
  55. @override
  56. String toString() {
  57. return toJson().toString();
  58. }
  59. }
  60. class ProxieProxiesItemHistory {
  61. ProxieProxiesItemHistory({
  62. required this.time,
  63. required this.delay,
  64. });
  65. late String time;
  66. late int delay;
  67. ProxieProxiesItemHistory.fromJson(Map<String, dynamic> json) {
  68. time = json['time'];
  69. delay = json['delay'];
  70. }
  71. Map<String, dynamic> toJson() {
  72. final data = <String, dynamic>{};
  73. data['time'] = time;
  74. data['delay'] = delay;
  75. return data;
  76. }
  77. @override
  78. String toString() {
  79. return toJson().toString();
  80. }
  81. }
  82. class ProxieProvider {
  83. ProxieProvider({
  84. required this.providers,
  85. });
  86. late Map<String, ProxieProviderItem> providers;
  87. ProxieProvider.fromJson(Map<String, dynamic> json) {
  88. providers = (json['providers'] as Map<String, dynamic>).map((key, value) => MapEntry(key, ProxieProviderItem.fromJson(value)));
  89. }
  90. // Map<String, dynamic> toJson() {
  91. // final _data = <String, dynamic>{};
  92. // _data['providers'] = providers.toJson();
  93. // return _data;
  94. // }
  95. // @override
  96. // String toString() {
  97. // return toJson().toString();
  98. // }
  99. }
  100. class ProxieProviderItem {
  101. ProxieProviderItem({
  102. required this.name,
  103. required this.proxies,
  104. required this.type,
  105. required this.vehicleType,
  106. this.updatedAt,
  107. });
  108. late String name;
  109. late List<ProxieProxiesItem> proxies;
  110. late String type;
  111. late String vehicleType;
  112. late String? updatedAt;
  113. ProxieProviderItem.fromJson(Map<String, dynamic> json) {
  114. name = json['name'];
  115. proxies = List.from(json['proxies']).map((e) => ProxieProxiesItem.fromJson(e)).toList();
  116. type = json['type'];
  117. vehicleType = json['vehicleType'];
  118. updatedAt = json['updatedAt'];
  119. }
  120. Map<String, dynamic> toJson() {
  121. final data = <String, dynamic>{};
  122. data['name'] = name;
  123. data['proxies'] = proxies.map((e) => e.toJson()).toList();
  124. data['type'] = type;
  125. data['vehicleType'] = vehicleType;
  126. data['updatedAt'] = updatedAt;
  127. return data;
  128. }
  129. @override
  130. String toString() {
  131. return toJson().toString();
  132. }
  133. }
  134. class ProxieProxieType {
  135. static const String selector = 'Selector';
  136. static const String urltest = 'URLTest';
  137. static const String fallback = 'Fallback';
  138. static const String loadbalance = 'LoadBalance';
  139. static const String direct = 'Direct';
  140. static const String reject = 'Reject';
  141. }