new: option of ignoring pve cert (#317)

This commit is contained in:
lollipopkit
2024-03-23 12:16:46 +08:00
parent 6ed2e558cb
commit 96866565c4
17 changed files with 93 additions and 38 deletions

View File

@@ -8,18 +8,23 @@ final class ServerCustom {
final String? temperature;
@HiveField(1)
final String? pveAddr;
@HiveField(2)
final bool? pveIgnoreCert;
const ServerCustom({
this.temperature,
this.pveAddr,
this.pveIgnoreCert,
});
static ServerCustom fromJson(Map<String, dynamic> json) {
final temperature = json["temperature"] as String?;
final pveAddr = json["pveAddr"] as String?;
final pveIgnoreCert = json["pveIgnoreCert"] as bool?;
return ServerCustom(
temperature: temperature,
pveAddr: pveAddr,
pveIgnoreCert: pveIgnoreCert,
);
}
@@ -31,6 +36,9 @@ final class ServerCustom {
if (pveAddr != null) {
json["pveAddr"] = pveAddr;
}
if (pveIgnoreCert != null) {
json["pveIgnoreCert"] = pveIgnoreCert;
}
return json;
}
}

View File

@@ -19,17 +19,20 @@ class ServerCustomAdapter extends TypeAdapter<ServerCustom> {
return ServerCustom(
temperature: fields[0] as String?,
pveAddr: fields[1] as String?,
pveIgnoreCert: fields[2] as bool?,
);
}
@override
void write(BinaryWriter writer, ServerCustom obj) {
writer
..writeByte(2)
..writeByte(3)
..writeByte(0)
..write(obj.temperature)
..writeByte(1)
..write(obj.pveAddr);
..write(obj.pveAddr)
..writeByte(2)
..write(obj.pveIgnoreCert);
}
@override

View File

@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:computer/computer.dart';
import 'package:dio/dio.dart';
import 'package:dio/io.dart';
import 'package:flutter/material.dart';
import 'package:toolbox/core/extension/context/locale.dart';
import 'package:toolbox/data/model/app/error.dart';
@@ -33,7 +34,12 @@ final class PveProvider extends ChangeNotifier {
final err = ValueNotifier<String?>(null);
final connected = Completer<void>();
final session = Dio();
late final _ignoreCert = spi.custom?.pveIgnoreCert ?? false;
late final session = Dio()
..httpClientAdapter = IOHttpClientAdapter(
validateCertificate: _ignoreCert ? (_, __, ___) => true : null,
);
final data = ValueNotifier<PveRes?>(null);
bool get onlyOneNode => data.value?.nodes.length == 1;
String? release;

View File

@@ -2,9 +2,9 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 822;
static const int build = 824;
static const String engine = "3.19.3";
static const String buildAt = "2024-03-21 17:33:04";
static const int modifications = 4;
static const String buildAt = "2024-03-23 10:51:07";
static const int modifications = 6;
static const int script = 41;
}