Change warp options
This commit is contained in:
@@ -51,17 +51,10 @@ class SingboxConfigOption with _$SingboxConfigOption {
|
||||
required bool muxPadding,
|
||||
required int muxMaxStreams,
|
||||
required MuxProtocol muxProtocol,
|
||||
required bool enableWarp,
|
||||
required WarpDetourMode warpDetourMode,
|
||||
required String warpLicenseKey,
|
||||
required String warpAccountId,
|
||||
required String warpAccessToken,
|
||||
required String warpCleanIp,
|
||||
required int warpPort,
|
||||
@OptionalRangeJsonConverter() required OptionalRange warpNoise,
|
||||
required String geoipPath,
|
||||
required String geositePath,
|
||||
required List<SingboxRule> rules,
|
||||
required SingboxWarpOption warp,
|
||||
}) = _SingboxConfigOption;
|
||||
|
||||
String format() {
|
||||
@@ -72,3 +65,21 @@ class SingboxConfigOption with _$SingboxConfigOption {
|
||||
factory SingboxConfigOption.fromJson(Map<String, dynamic> json) =>
|
||||
_$SingboxConfigOptionFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SingboxWarpOption with _$SingboxWarpOption {
|
||||
const factory SingboxWarpOption({
|
||||
required bool enable,
|
||||
required WarpDetourMode mode,
|
||||
required String wireguardConfig,
|
||||
required String licenseKey,
|
||||
required String accountId,
|
||||
required String accessToken,
|
||||
required String cleanIp,
|
||||
required int cleanPort,
|
||||
@OptionalRangeJsonConverter() required OptionalRange warpNoise,
|
||||
}) = _SingboxWarpOption;
|
||||
|
||||
factory SingboxWarpOption.fromJson(Map<String, dynamic> json) =>
|
||||
_$SingboxWarpOptionFromJson(json);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
part 'warp_account.freezed.dart';
|
||||
part 'warp_account.g.dart';
|
||||
typedef WarpResponse = ({
|
||||
String log,
|
||||
String accountId,
|
||||
String accessToken,
|
||||
String wireguardConfig,
|
||||
});
|
||||
|
||||
@freezed
|
||||
class WarpAccount with _$WarpAccount {
|
||||
const factory WarpAccount({
|
||||
required String licenseKey,
|
||||
required String accountId,
|
||||
required String accessToken,
|
||||
}) = _WarpAccount;
|
||||
|
||||
factory WarpAccount.fromJson(Map<String, dynamic> json) =>
|
||||
_$WarpAccountFromJson(json);
|
||||
WarpResponse warpFromJson(dynamic json) {
|
||||
if (json
|
||||
case {
|
||||
"account-id": final String newAccountId,
|
||||
"access-token": final String newAccessToken,
|
||||
"log": final String log,
|
||||
"config": final Map<String, dynamic> wireguardConfig,
|
||||
}) {
|
||||
return (
|
||||
log: log,
|
||||
accountId: newAccountId,
|
||||
accessToken: newAccessToken,
|
||||
wireguardConfig: jsonEncode(wireguardConfig),
|
||||
);
|
||||
}
|
||||
throw Exception("invalid response");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user