mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 05:52:51 +00:00
Added support for general protection legacy mode
This commit is contained in:
parent
20b2f89602
commit
9e400f7efa
5 changed files with 209 additions and 54 deletions
|
@ -280,7 +280,7 @@ Future getServerStatus(Server server) async {
|
|||
final Map<String, dynamic> mappedData = {
|
||||
'stats': jsonDecode(result[0]['body']),
|
||||
'clients': jsonDecode(result[6]['body'])['clients'],
|
||||
'generalEnabled': jsonDecode(result[1]['body']),
|
||||
'status': jsonDecode(result[1]['body']),
|
||||
'filtering': jsonDecode(result[2]['body']),
|
||||
'safeSearchEnabled': jsonDecode(result[3]['body']),
|
||||
'safeBrowsingEnabled': jsonDecode(result[4]['body']),
|
||||
|
@ -503,6 +503,39 @@ Future updateGeneralProtection({
|
|||
}
|
||||
}
|
||||
|
||||
Future updateGeneralProtectionLegacy(Server server, bool enable) async {
|
||||
final result = await apiRequest(
|
||||
urlPath: '/dns_config',
|
||||
method: 'post',
|
||||
server: server,
|
||||
body: {
|
||||
'protection_enabled': enable
|
||||
},
|
||||
type: 'general_protection'
|
||||
);
|
||||
|
||||
if (result['hasResponse'] == true) {
|
||||
if (result['statusCode'] == 200) {
|
||||
return {'result': 'success'};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
'result': 'error',
|
||||
'log': AppLog(
|
||||
type: 'general_protection',
|
||||
dateTime: DateTime.now(),
|
||||
message: 'error_code_not_expected',
|
||||
statusCode: result['statusCode'].toString(),
|
||||
resBody: result['body']
|
||||
)
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Future getClients(Server server) async {
|
||||
final result = await Future.wait([
|
||||
apiRequest(server: server, method: 'get', urlPath: '/clients', type: 'get_clients'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue