Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): support v6 #42

Merged
merged 44 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6b9383a
Add loginQuery
tsutsu3 Dec 7, 2024
01e5a6f
Add maxRetries parameter for request retries on 401 response
tsutsu3 Dec 7, 2024
5204ecc
Remove fail_ci_if_error option from Codecov action
tsutsu3 Dec 7, 2024
d0537d0
Update doc comments
tsutsu3 Dec 7, 2024
3b89474
Add realtimeStatus
tsutsu3 Dec 8, 2024
a822206
Add fetchOverTimeData
tsutsu3 Dec 8, 2024
61d2797
Add disable/enable server request
tsutsu3 Dec 8, 2024
a2d9fe0
Remove unused line
tsutsu3 Dec 8, 2024
3a3b9a2
chore: WIP - gomain apis
tsutsu3 Dec 10, 2024
744edb1
Fix mulple login
tsutsu3 Dec 10, 2024
16f4fd5
Refactor server model to use SessionManager and remove password field
tsutsu3 Dec 11, 2024
86650f5
Add SessionManagerMock for testing and update loginQuery tests
tsutsu3 Dec 11, 2024
60f8e87
Add domain methods tests
tsutsu3 Dec 12, 2024
922f7f6
Fix login error
tsutsu3 Dec 12, 2024
1206ef5
Remove unused file
tsutsu3 Dec 12, 2024
8cfc52d
Fix login error
tsutsu3 Dec 12, 2024
d6d9621
Change edit server screen title
tsutsu3 Dec 12, 2024
f84ef5f
Fix password disappearing issue on edit connection screen in API v6
tsutsu3 Dec 12, 2024
8515f6f
Removde unused file
tsutsu3 Dec 12, 2024
7247280
Refactor imports in ApiGatewayV6 to use 'show' for specific classes
tsutsu3 Dec 13, 2024
487684b
Add fetchlogs
tsutsu3 Dec 13, 2024
8d3321a
Add TODO comment for loading issue when switching servers
tsutsu3 Dec 13, 2024
35526c0
Remove unused file
tsutsu3 Dec 13, 2024
0ceeeaf
Add TODO comment for loading issue when switching servers
tsutsu3 Dec 13, 2024
d8c0ccc
Fix server model initialization and pass 'sm' parameter
tsutsu3 Dec 14, 2024
743c606
Add Pi-hole services
tsutsu3 Dec 14, 2024
8eb698f
Remove commented-out login method
tsutsu3 Dec 14, 2024
d1fb45b
Fix selected server status update condition
tsutsu3 Dec 14, 2024
e055e38
Add logging for fetched queries and logs, and implement toJson method…
tsutsu3 Dec 14, 2024
e5411b8
Refactor filter modal
tsutsu3 Dec 14, 2024
8e9e448
Fix cant check box
tsutsu3 Dec 14, 2024
470a07a
Fix check/uncheck all logic in status filters modal to use dynamic co…
tsutsu3 Dec 14, 2024
1a1144e
Refactor filter status management to use dynamic status lists
tsutsu3 Dec 14, 2024
f258f94
Remove unused import from filters_v6.dart
tsutsu3 Dec 14, 2024
123c4d5
Refactor LogStatus to use dynamic query status
tsutsu3 Dec 14, 2024
206ebdc
Refactor query status retrieval to accept a key parameter
tsutsu3 Dec 14, 2024
f39db4a
Refactor log status management to utilize dynamic query statuses
tsutsu3 Dec 14, 2024
5ae0ce2
Fix API query URL
tsutsu3 Dec 14, 2024
acb1160
Fix query URL in fetchLogs test to use correct parameter syntax
tsutsu3 Dec 14, 2024
6fbda3d
Add comments to clarify autoRefreshTime and logsPerQuery units
tsutsu3 Dec 15, 2024
ad02cba
Fix login
tsutsu3 Dec 15, 2024
6a8d96e
Fix fetchlogs
tsutsu3 Dec 15, 2024
c081107
Fix data was not being deleted from secure storage
tsutsu3 Dec 15, 2024
6c4fd89
Fix preventing data loading for default server in v6
tsutsu3 Dec 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ jobs:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ linter:

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
analyzer:
errors:
invalid_annotation_target: ignore
24 changes: 24 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,27 @@ services:
environment:
TZ: 'Asia/Tokyo'
FTLCONF_webserver_api_password: 'test123'

piholeV52:
container_name: piholeV52
image: pihole/pihole:latest
ports:
- "56:53/tcp"
- "56:53/udp"
- "8082:80/tcp"
- "1446:443/tcp"
environment:
TZ: 'Asia/Tokyo'
WEBPASSWORD: 'test456'

piholeV62:
container_name: piholeV62
image: pihole/pihole:development
ports:
- "57:53/tcp"
- "57:53/udp"
- "8083:80/tcp"
- "1447:443/tcp"
environment:
TZ: 'Asia/Tokyo'
FTLCONF_webserver_api_password: 'test456'
17 changes: 0 additions & 17 deletions lib/constants/log_status.dart

This file was deleted.

252 changes: 252 additions & 0 deletions lib/constants/query_types.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
import 'package:flutter/material.dart';
import 'package:pi_hole_client/models/query_status.dart';

final List<QueryStatus> queryStatusesV5 = [
QueryStatus(

Check warning on line 5 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L4-L5

Added lines #L4 - L5 were not covered by tests
index: 1,
key: "1",
text: "Blocked (gravity)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(

Check warning on line 12 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L12

Added line #L12 was not covered by tests
index: 2,
key: "2",
text: "OK (forwarded)",
color: Colors.green,
icon: Icons.verified_user_rounded,
),
QueryStatus(

Check warning on line 19 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L19

Added line #L19 was not covered by tests
index: 3,
key: "3",
text: "OK (cache)",
color: Colors.green,
icon: Icons.verified_user_rounded,
),
QueryStatus(

Check warning on line 26 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L26

Added line #L26 was not covered by tests
index: 4,
key: "4",
text: "Blocked (regex blacklist)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(

Check warning on line 33 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L33

Added line #L33 was not covered by tests
index: 5,
key: "5",
text: "Blocked (exact blacklist)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(

Check warning on line 40 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L40

Added line #L40 was not covered by tests
index: 6,
key: "6",
text: "Blocked (external, IP)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(

Check warning on line 47 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L47

Added line #L47 was not covered by tests
index: 7,
key: "7",
text: "Blocked (external, NULL)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(

Check warning on line 54 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L54

Added line #L54 was not covered by tests
index: 8,
key: "8",
text: "Blocked (external, NXRA)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(

Check warning on line 61 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L61

Added line #L61 was not covered by tests
index: 9,
key: "9",
text: "Blocked (gravity, CNAME)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(

Check warning on line 68 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L68

Added line #L68 was not covered by tests
index: 10,
key: "10",
text: "Blocked (regex blacklist, CNAME)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(

Check warning on line 75 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L75

Added line #L75 was not covered by tests
index: 11,
key: "11",
text: "Blocked (exact blacklist, CNAME)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(

Check warning on line 82 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L82

Added line #L82 was not covered by tests
index: 12,
key: "12",
text: "Retried",
color: Colors.blue,
icon: Icons.refresh_rounded,
),
QueryStatus(

Check warning on line 89 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L89

Added line #L89 was not covered by tests
index: 13,
key: "13",
text: "Retried (ignored)",
color: Colors.blue,
icon: Icons.refresh_rounded,
),
QueryStatus(

Check warning on line 96 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L96

Added line #L96 was not covered by tests
index: 14,
key: "14",
text: "OK (already forwarded)",
color: Colors.green,
icon: Icons.verified_user_rounded,
),
QueryStatus(

Check warning on line 103 in lib/constants/query_types.dart

View check run for this annotation

Codecov / codecov/patch

lib/constants/query_types.dart#L103

Added line #L103 was not covered by tests
index: 15,
key: "15",
text: "Database is busy",
color: Colors.orange,
icon: Icons.storage_rounded,
isShown: false,
),
];

final List<QueryStatus> queryStatusesV6 = [
QueryStatus(
index: 1,
key: "UNKNOWN",
text: "UNKNOWN",
color: Colors.grey,
icon: Icons.question_mark_rounded,
isShown: false,
),
QueryStatus(
index: 2,
key: "GRAVITY",
text: "Blocked (gravity)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(
index: 3,
key: "FORWARDED",
text: "Forwarded",
color: Colors.green,
icon: Icons.verified_user_rounded,
),
QueryStatus(
index: 4,
key: "CACHE",
text: "Served from cache",
color: Colors.green,
icon: Icons.verified_user_rounded,
),
QueryStatus(
index: 5,
key: "REGEX",
text: "Blocked (regex)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(
index: 6,
key: "DENYLIST",
text: "Blocked (exact)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(
index: 7,
key: "EXTERNAL_BLOCKED_IP",
text: "Blocked (external, IP)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(
index: 8,
key: "EXTERNAL_BLOCKED_NULL",
text: "Blocked (external, NULL)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(
index: 9,
key: "EXTERNAL_BLOCKED_NXRA",
text: "Blocked (external, NXRA)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(
index: 10,
key: "GRAVITY_CNAME",
text: "Blocked (gravity, CNAME)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(
index: 11,
key: "REGEX_CNAME",
text: "Blocked (regex denied, CNAME)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(
index: 12,
key: "DENYLIST_CNAME",
text: "Blocked (exact denied, CNAME)",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
),
QueryStatus(
index: 13,
key: "RETRIED",
text: "Retried",
color: Colors.blue,
icon: Icons.refresh_rounded,
),
QueryStatus(
index: 14,
key: "RETRIED_DNSSEC",
text: "Retried (ignored)",
color: Colors.blue,
icon: Icons.refresh_rounded,
),
QueryStatus(
index: 15,
key: "IN_PROGRESS",
text: "Already forwarded, awaiting reply",
color: Colors.green,
icon: Icons.verified_user_rounded,
),
QueryStatus(
index: 16,
key: "DBBUSY",
text: "DBBUSY",
color: Colors.orange,
icon: Icons.storage_rounded,
isShown: false,
),
QueryStatus(
index: 17,
key: "SPECIAL_DOMAIN",
text: "SPECIAL_DOMAIN",
color: Colors.red,
icon: Icons.gpp_bad_rounded,
isShown: false,
),
QueryStatus(
index: 18,
key: "CACHE_STALE",
text: "Served by cache optimizer",
color: Colors.blue,
icon: Icons.cached_rounded,
isShown: false,
),
QueryStatus(
index: 19,
key: "EXTERNAL_BLOCKED_EDE15",
text: "EXTERNAL_BLOCKED_EDE15",
color: Colors.orange,
icon: Icons.question_mark_rounded,
isShown: false,
),
];
5 changes: 2 additions & 3 deletions lib/gateways/api_gateway_factory.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:pi_hole_client/gateways/api_gateway_interface.dart';
import 'package:pi_hole_client/gateways/v5/api_gateway_v5.dart';
// import 'package:pi_hole_client/gateways/v5/api_gateway_v6.dart';
import 'package:pi_hole_client/gateways/v6/api_gateway_v6.dart';
import 'package:pi_hole_client/models/server.dart';

class ApiGatewayFactory {
Expand All @@ -9,8 +9,7 @@ class ApiGatewayFactory {
if (version == 'v5') {
return ApiGatewayV5(server);
} else if (version == 'v6') {
// return ApiGatewayV6(server);
throw Exception('Not implemented yet');
return ApiGatewayV6(server);
} else {
throw Exception('Unsupported server version: $version');
}
Expand Down
4 changes: 2 additions & 2 deletions lib/gateways/v5/api_gateway_v5.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ class ApiGatewayV5 implements ApiGateway {
} else {
final enableOrDisableParsed = jsonDecode(enableOrDisable.body);
if (enableOrDisableParsed.runtimeType != List) {
final phpSessId = enableOrDisable.headers['set-cookie']!
final sid = enableOrDisable.headers['set-cookie']!
.split(';')[0]
.split('=')[1];
return LoginQueryResponse(
result: APiResponseType.success,
status: statusParsed['status'],
phpSessId: phpSessId);
sid: sid);
} else {
return LoginQueryResponse(
result: APiResponseType.authError,
Expand Down
Loading
Loading