2022-10-08 23:57:10 +02:00
|
|
|
import 'dart:convert';
|
|
|
|
|
2023-05-25 15:06:21 +02:00
|
|
|
import 'package:adguard_home_manager/constants/enums.dart';
|
|
|
|
|
2022-10-08 23:57:10 +02:00
|
|
|
class ServerInfo {
|
2023-05-25 15:06:21 +02:00
|
|
|
LoadStatus loadStatus = LoadStatus.loading;
|
2022-10-08 23:57:10 +02:00
|
|
|
ServerInfoData? data;
|
|
|
|
|
|
|
|
ServerInfo({
|
|
|
|
required this.loadStatus,
|
|
|
|
this.data
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ServerInfoData serverInfoDataFromJson(String str) => ServerInfoData.fromJson(json.decode(str));
|
|
|
|
|
|
|
|
String serverInfoDataToJson(ServerInfoData data) => json.encode(data.toJson());
|
|
|
|
|
|
|
|
class ServerInfoData {
|
|
|
|
final List<String> dnsAddresses;
|
|
|
|
final int dnsPort;
|
|
|
|
final int httpPort;
|
|
|
|
final bool protectionEnabled;
|
|
|
|
final bool dhcpAvailable;
|
|
|
|
final bool running;
|
|
|
|
final String version;
|
|
|
|
final String language;
|
|
|
|
|
|
|
|
ServerInfoData({
|
|
|
|
required this.dnsAddresses,
|
|
|
|
required this.dnsPort,
|
|
|
|
required this.httpPort,
|
|
|
|
required this.protectionEnabled,
|
|
|
|
required this.dhcpAvailable,
|
|
|
|
required this.running,
|
|
|
|
required this.version,
|
|
|
|
required this.language,
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
factory ServerInfoData.fromJson(Map<String, dynamic> json) => ServerInfoData(
|
|
|
|
dnsAddresses: List<String>.from(json["dns_addresses"].map((x) => x)),
|
|
|
|
dnsPort: json["dns_port"],
|
|
|
|
httpPort: json["http_port"],
|
|
|
|
protectionEnabled: json["protection_enabled"],
|
2023-06-13 12:53:10 +02:00
|
|
|
dhcpAvailable: json["dhcp_available"] ?? false,
|
2022-10-08 23:57:10 +02:00
|
|
|
running: json["running"],
|
|
|
|
version: json["version"],
|
|
|
|
language: json["language"],
|
|
|
|
);
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
"dns_addresses": List<dynamic>.from(dnsAddresses.map((x) => x)),
|
|
|
|
"dns_port": dnsPort,
|
|
|
|
"http_port": httpPort,
|
|
|
|
"protection_enabled": protectionEnabled,
|
|
|
|
"dhcp_available": dhcpAvailable,
|
|
|
|
"running": running,
|
|
|
|
"version": version,
|
|
|
|
"language": language,
|
|
|
|
};
|
|
|
|
}
|