mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-05 04:40:37 +00:00
Created dhcp settings screen
This commit is contained in:
parent
867822d01e
commit
50685d1ea8
7 changed files with 974 additions and 3 deletions
133
lib/models/dhcp.dart
Normal file
133
lib/models/dhcp.dart
Normal file
|
@ -0,0 +1,133 @@
|
|||
import 'dart:convert';
|
||||
|
||||
class DhcpModel {
|
||||
int loadStatus = 0;
|
||||
DhcpData? data;
|
||||
|
||||
DhcpModel({
|
||||
required this.loadStatus,
|
||||
this.data,
|
||||
});
|
||||
}
|
||||
|
||||
class DhcpData {
|
||||
List<NetworkInterface> networkInterfaces;
|
||||
DhcpStatus dhcpStatus;
|
||||
|
||||
DhcpData({
|
||||
required this.networkInterfaces,
|
||||
required this.dhcpStatus,
|
||||
});
|
||||
}
|
||||
|
||||
NetworkInterface networkInterfaceFromJson(String str) => NetworkInterface.fromJson(json.decode(str));
|
||||
|
||||
String networkInterfaceToJson(NetworkInterface data) => json.encode(data.toJson());
|
||||
|
||||
class NetworkInterface {
|
||||
String name;
|
||||
String hardwareAddress;
|
||||
List<String> flags;
|
||||
String gatewayIp;
|
||||
List<String> ipv4Addresses;
|
||||
List<String> ipv6Addresses;
|
||||
|
||||
NetworkInterface({
|
||||
required this.name,
|
||||
required this.hardwareAddress,
|
||||
required this.flags,
|
||||
required this.gatewayIp,
|
||||
required this.ipv4Addresses,
|
||||
required this.ipv6Addresses,
|
||||
});
|
||||
|
||||
factory NetworkInterface.fromJson(Map<String, dynamic> json) => NetworkInterface(
|
||||
name: json["name"],
|
||||
hardwareAddress: json["hardware_address"],
|
||||
flags: json["flags"] != null ? json["flags"].split("|") : [],
|
||||
gatewayIp: json["gateway_ip"],
|
||||
ipv4Addresses: json["ipv4_addresses"] != null ? List<String>.from(json["ipv4_addresses"].map((x) => x)) : [],
|
||||
ipv6Addresses: json["ipv6_addresses"] != null ? List<String>.from(json["ipv6_addresses"].map((x) => x)) : [],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"name": name,
|
||||
"hardware_address": hardwareAddress,
|
||||
"flags": flags,
|
||||
"gateway_ip": gatewayIp,
|
||||
"ipv4_addresses": List<dynamic>.from(ipv4Addresses.map((x) => x)),
|
||||
"ipv6_addresses": List<dynamic>.from(ipv6Addresses.map((x) => x)),
|
||||
};
|
||||
}
|
||||
|
||||
DhcpStatus dhcpStatusFromJson(String str) => DhcpStatus.fromJson(json.decode(str));
|
||||
|
||||
String dhcpStatusToJson(DhcpStatus data) => json.encode(data.toJson());
|
||||
|
||||
class DhcpStatus {
|
||||
String interfaceName;
|
||||
IpVersion v4;
|
||||
IpVersion v6;
|
||||
List<dynamic> leases;
|
||||
List<dynamic> staticLeases;
|
||||
bool enabled;
|
||||
|
||||
DhcpStatus({
|
||||
required this.interfaceName,
|
||||
required this.v4,
|
||||
required this.v6,
|
||||
required this.leases,
|
||||
required this.staticLeases,
|
||||
required this.enabled,
|
||||
});
|
||||
|
||||
factory DhcpStatus.fromJson(Map<String, dynamic> json) => DhcpStatus(
|
||||
interfaceName: json["interface_name"],
|
||||
v4: IpVersion.fromJson(json["v4"]),
|
||||
v6: IpVersion.fromJson(json["v6"]),
|
||||
leases: List<dynamic>.from(json["leases"].map((x) => x)),
|
||||
staticLeases: List<dynamic>.from(json["static_leases"].map((x) => x)),
|
||||
enabled: json["enabled"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"interface_name": interfaceName,
|
||||
"v4": v4.toJson(),
|
||||
"v6": v6.toJson(),
|
||||
"leases": List<dynamic>.from(leases.map((x) => x)),
|
||||
"static_leases": List<dynamic>.from(staticLeases.map((x) => x)),
|
||||
"enabled": enabled,
|
||||
};
|
||||
}
|
||||
|
||||
class IpVersion {
|
||||
String ?gatewayIp;
|
||||
String? subnetMask;
|
||||
String rangeStart;
|
||||
String? rangeEnd;
|
||||
int leaseDuration;
|
||||
|
||||
IpVersion({
|
||||
this.gatewayIp,
|
||||
this.subnetMask,
|
||||
required this.rangeStart,
|
||||
this.rangeEnd,
|
||||
required this.leaseDuration,
|
||||
});
|
||||
|
||||
factory IpVersion.fromJson(Map<String, dynamic> json) => IpVersion(
|
||||
gatewayIp: json["gateway_ip"],
|
||||
subnetMask: json["subnet_mask"],
|
||||
rangeStart: json["range_start"],
|
||||
rangeEnd: json["range_end"],
|
||||
leaseDuration: json["lease_duration"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"gateway_ip": gatewayIp,
|
||||
"subnet_mask": subnetMask,
|
||||
"range_start": rangeStart,
|
||||
"range_end": rangeEnd,
|
||||
"lease_duration": leaseDuration,
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue