Add proxy routing and sing-box support
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2026 Fabian Freund.
|
||||
*
|
||||
* This file is part of WebLibre
|
||||
* (see https://weblibre.eu).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/proxy_profile.drift.dart';
|
||||
import 'package:weblibre/features/user/data/database/database.dart';
|
||||
import 'package:weblibre/features/user/data/database/definitions.drift.dart';
|
||||
|
||||
@DriftAccessor()
|
||||
class ProxyProfileDao extends DatabaseAccessor<UserDatabase>
|
||||
with $ProxyProfileDaoMixin {
|
||||
ProxyProfileDao(super.attachedDatabase);
|
||||
|
||||
Selectable<ProxyProfile> watch() {
|
||||
return db.proxyProfile.select()
|
||||
..orderBy([(t) => OrderingTerm.asc(t.createdAt)]);
|
||||
}
|
||||
|
||||
Future<List<ProxyProfile>> fetchAll() => watch().get();
|
||||
|
||||
Future<ProxyProfile?> findById(String id) {
|
||||
return (db.proxyProfile.select()
|
||||
..where((t) => t.id.equals(id))
|
||||
..limit(1))
|
||||
.getSingleOrNull();
|
||||
}
|
||||
|
||||
Future<void> upsert(ProxyProfile profile) {
|
||||
return db.proxyProfile.insertOne(
|
||||
profile,
|
||||
onConflict: DoUpdate(
|
||||
(_) => ProxyProfileCompanion(
|
||||
name: Value(profile.name),
|
||||
type: Value(profile.type),
|
||||
configJson: Value(profile.configJson),
|
||||
dnsOverrideJson: Value(profile.dnsOverrideJson),
|
||||
updatedAt: Value(profile.updatedAt),
|
||||
),
|
||||
target: [db.proxyProfile.id],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> deleteById(String id) {
|
||||
return (db.proxyProfile.delete()..where((t) => t.id.equals(id))).go();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// dart format width=80
|
||||
// ignore_for_file: type=lint
|
||||
import 'package:drift/drift.dart' as i0;
|
||||
import 'package:weblibre/features/user/data/database/database.dart' as i1;
|
||||
|
||||
mixin $ProxyProfileDaoMixin on i0.DatabaseAccessor<i1.UserDatabase> {
|
||||
ProxyProfileDaoManager get managers => ProxyProfileDaoManager(this);
|
||||
}
|
||||
|
||||
class ProxyProfileDaoManager {
|
||||
final $ProxyProfileDaoMixin _db;
|
||||
ProxyProfileDaoManager(this._db);
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import 'package:drift_dev/api/migrations_native.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/cache.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/onboarding.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/proxy_profile.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/search_tokens.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/setting.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/toolbar_button_config.dart';
|
||||
@@ -37,11 +38,12 @@ import 'package:weblibre/features/user/data/database/database.steps.dart';
|
||||
OnboardingDao,
|
||||
ToolbarButtonConfigDao,
|
||||
SearchTokensDao,
|
||||
ProxyProfileDao,
|
||||
],
|
||||
)
|
||||
class UserDatabase extends $UserDatabase {
|
||||
@override
|
||||
final int schemaVersion = 5;
|
||||
final int schemaVersion = 8;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration => MigrationStrategy(
|
||||
@@ -103,5 +105,21 @@ class UserDatabase extends $UserDatabase {
|
||||
await m.addColumn(schema.searchTokens, schema.searchTokens.reservedAt);
|
||||
await m.createIndex(schema.idxSearchTokensReservedAt);
|
||||
},
|
||||
from5To6: (m, schema) async {
|
||||
await m.createTable(schema.proxyProfile);
|
||||
await m.createIndex(schema.idxProxyProfileUpdatedAt);
|
||||
await m.createTable(schema.proxyRoutingSetting);
|
||||
},
|
||||
from6To7: (m, schema) async {
|
||||
await m.addColumn(
|
||||
schema.proxyProfile,
|
||||
schema.proxyProfile.dnsOverrideJson,
|
||||
);
|
||||
},
|
||||
from7To8: (m, schema) async {
|
||||
await m.database.customStatement(
|
||||
'DROP TABLE IF EXISTS proxy_routing_setting',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,13 +12,16 @@ import 'package:weblibre/features/user/data/database/daos/toolbar_button_config.
|
||||
as i6;
|
||||
import 'package:weblibre/features/user/data/database/daos/search_tokens.dart'
|
||||
as i7;
|
||||
import 'package:drift/internal/modular.dart' as i8;
|
||||
import 'package:sqlite3/common.dart' as i9;
|
||||
import 'package:weblibre/features/user/data/database/daos/proxy_profile.dart'
|
||||
as i8;
|
||||
import 'package:drift/internal/modular.dart' as i9;
|
||||
import 'package:sqlite3/common.dart' as i10;
|
||||
|
||||
abstract class $UserDatabase extends i0.GeneratedDatabase {
|
||||
$UserDatabase(i0.QueryExecutor e) : super(e);
|
||||
$UserDatabaseManager get managers => $UserDatabaseManager(this);
|
||||
late final i1.Setting setting = i1.Setting(this);
|
||||
late final i1.ProxyProfileTable proxyProfile = i1.ProxyProfileTable(this);
|
||||
late final i1.IconCache iconCache = i1.IconCache(this);
|
||||
late final i1.Onboarding onboarding = i1.Onboarding(this);
|
||||
late final i1.Riverpod riverpod = i1.Riverpod(this);
|
||||
@@ -35,7 +38,10 @@ abstract class $UserDatabase extends i0.GeneratedDatabase {
|
||||
late final i7.SearchTokensDao searchTokensDao = i7.SearchTokensDao(
|
||||
this as i3.UserDatabase,
|
||||
);
|
||||
i1.DefinitionsDrift get definitionsDrift => i8.ReadDatabaseContainer(
|
||||
late final i8.ProxyProfileDao proxyProfileDao = i8.ProxyProfileDao(
|
||||
this as i3.UserDatabase,
|
||||
);
|
||||
i1.DefinitionsDrift get definitionsDrift => i9.ReadDatabaseContainer(
|
||||
this,
|
||||
).accessor<i1.DefinitionsDrift>(i1.DefinitionsDrift.new);
|
||||
@override
|
||||
@@ -44,6 +50,8 @@ abstract class $UserDatabase extends i0.GeneratedDatabase {
|
||||
@override
|
||||
List<i0.DatabaseSchemaEntity> get allSchemaEntities => [
|
||||
setting,
|
||||
proxyProfile,
|
||||
i1.idxProxyProfileUpdatedAt,
|
||||
iconCache,
|
||||
onboarding,
|
||||
riverpod,
|
||||
@@ -60,6 +68,8 @@ class $UserDatabaseManager {
|
||||
$UserDatabaseManager(this._db);
|
||||
i1.$SettingTableManager get setting =>
|
||||
i1.$SettingTableManager(_db, _db.setting);
|
||||
i1.$ProxyProfileTableTableManager get proxyProfile =>
|
||||
i1.$ProxyProfileTableTableManager(_db, _db.proxyProfile);
|
||||
i1.$IconCacheTableManager get iconCache =>
|
||||
i1.$IconCacheTableManager(_db, _db.iconCache);
|
||||
i1.$OnboardingTableManager get onboarding =>
|
||||
@@ -72,7 +82,7 @@ class $UserDatabaseManager {
|
||||
i1.$SearchTokensTableManager(_db, _db.searchTokens);
|
||||
}
|
||||
|
||||
extension DefineFunctions on i9.CommonDatabase {
|
||||
extension DefineFunctions on i10.CommonDatabase {
|
||||
void defineFunctions({
|
||||
required String Function(int, String?) lexoRankNext,
|
||||
required String Function(int, String?) lexoRankPrevious,
|
||||
@@ -86,7 +96,7 @@ extension DefineFunctions on i9.CommonDatabase {
|
||||
}) {
|
||||
createFunction(
|
||||
functionName: 'lexo_rank_next',
|
||||
argumentCount: const i9.AllowedArgumentCount(2),
|
||||
argumentCount: const i10.AllowedArgumentCount(2),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as int;
|
||||
final arg1 = args[1] as String?;
|
||||
@@ -95,7 +105,7 @@ extension DefineFunctions on i9.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'lexo_rank_previous',
|
||||
argumentCount: const i9.AllowedArgumentCount(2),
|
||||
argumentCount: const i10.AllowedArgumentCount(2),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as int;
|
||||
final arg1 = args[1] as String?;
|
||||
@@ -104,7 +114,7 @@ extension DefineFunctions on i9.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'lexo_rank_reorder_after',
|
||||
argumentCount: const i9.AllowedArgumentCount(2),
|
||||
argumentCount: const i10.AllowedArgumentCount(2),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
final arg1 = args[1] as String?;
|
||||
@@ -113,7 +123,7 @@ extension DefineFunctions on i9.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'lexo_rank_reorder_before',
|
||||
argumentCount: const i9.AllowedArgumentCount(2),
|
||||
argumentCount: const i10.AllowedArgumentCount(2),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
final arg1 = args[1] as String?;
|
||||
@@ -122,14 +132,14 @@ extension DefineFunctions on i9.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'generate_content_hash',
|
||||
argumentCount: const i9.AllowedArgumentCount(0),
|
||||
argumentCount: const i10.AllowedArgumentCount(0),
|
||||
function: (args) {
|
||||
return generateContentHash();
|
||||
},
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'url_indexable',
|
||||
argumentCount: const i9.AllowedArgumentCount(1),
|
||||
argumentCount: const i10.AllowedArgumentCount(1),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
return urlIndexable(arg0);
|
||||
@@ -137,7 +147,7 @@ extension DefineFunctions on i9.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'url_canonical',
|
||||
argumentCount: const i9.AllowedArgumentCount(1),
|
||||
argumentCount: const i10.AllowedArgumentCount(1),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
return urlCanonical(arg0);
|
||||
@@ -145,7 +155,7 @@ extension DefineFunctions on i9.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'url_host',
|
||||
argumentCount: const i9.AllowedArgumentCount(1),
|
||||
argumentCount: const i10.AllowedArgumentCount(1),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
return urlHost(arg0);
|
||||
@@ -153,7 +163,7 @@ extension DefineFunctions on i9.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'url_path',
|
||||
argumentCount: const i9.AllowedArgumentCount(1),
|
||||
argumentCount: const i10.AllowedArgumentCount(1),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
return urlPath(arg0);
|
||||
|
||||
@@ -563,11 +563,536 @@ i1.GeneratedColumn<int> _column_19(String aliasedName) =>
|
||||
type: i1.DriftSqlType.int,
|
||||
$customConstraints: '',
|
||||
);
|
||||
|
||||
final class Schema6 extends i0.VersionedSchema {
|
||||
Schema6({required super.database}) : super(version: 6);
|
||||
@override
|
||||
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||
setting,
|
||||
proxyProfile,
|
||||
idxProxyProfileUpdatedAt,
|
||||
proxyRoutingSetting,
|
||||
iconCache,
|
||||
onboarding,
|
||||
riverpod,
|
||||
toolbarButtonConfigs,
|
||||
idxToolbarOrderKey,
|
||||
searchTokens,
|
||||
idxSearchTokensInsertedAt,
|
||||
idxSearchTokensReservedAt,
|
||||
];
|
||||
late final Shape0 setting = Shape0(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'setting',
|
||||
withoutRowId: false,
|
||||
isStrict: true,
|
||||
tableConstraints: [],
|
||||
columns: [_column_0, _column_1, _column_2],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape7 proxyProfile = Shape7(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'proxy_profile',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_20,
|
||||
_column_21,
|
||||
_column_22,
|
||||
_column_23,
|
||||
_column_24,
|
||||
_column_25,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxProxyProfileUpdatedAt = i1.Index(
|
||||
'idx_proxy_profile_updated_at',
|
||||
'CREATE INDEX idx_proxy_profile_updated_at ON proxy_profile (updated_at)',
|
||||
);
|
||||
late final Shape8 proxyRoutingSetting = Shape8(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'proxy_routing_setting',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_26, _column_27, _column_28, _column_29],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape1 iconCache = Shape1(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'icon_cache',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_3, _column_4, _column_5],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape2 onboarding = Shape2(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'onboarding',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_6, _column_7],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape3 riverpod = Shape3(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'riverpod',
|
||||
withoutRowId: true,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_0, _column_8, _column_9, _column_10],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape4 toolbarButtonConfigs = Shape4(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'toolbar_button_configs',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_11, _column_12, _column_13, _column_14],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxToolbarOrderKey = i1.Index(
|
||||
'idx_toolbar_order_key',
|
||||
'CREATE INDEX idx_toolbar_order_key ON toolbar_button_configs (order_key)',
|
||||
);
|
||||
late final Shape6 searchTokens = Shape6(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'search_tokens',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_15, _column_16, _column_17, _column_18, _column_19],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxSearchTokensInsertedAt = i1.Index(
|
||||
'idx_search_tokens_inserted_at',
|
||||
'CREATE INDEX idx_search_tokens_inserted_at ON search_tokens (inserted_at)',
|
||||
);
|
||||
final i1.Index idxSearchTokensReservedAt = i1.Index(
|
||||
'idx_search_tokens_reserved_at',
|
||||
'CREATE INDEX idx_search_tokens_reserved_at ON search_tokens (reserved_at)',
|
||||
);
|
||||
}
|
||||
|
||||
class Shape7 extends i0.VersionedTable {
|
||||
Shape7({required super.source, required super.alias}) : super.aliased();
|
||||
i1.GeneratedColumn<String> get id =>
|
||||
columnsByName['id']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get name =>
|
||||
columnsByName['name']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get type =>
|
||||
columnsByName['type']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get configJson =>
|
||||
columnsByName['config_json']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<int> get createdAt =>
|
||||
columnsByName['created_at']! as i1.GeneratedColumn<int>;
|
||||
i1.GeneratedColumn<int> get updatedAt =>
|
||||
columnsByName['updated_at']! as i1.GeneratedColumn<int>;
|
||||
}
|
||||
|
||||
i1.GeneratedColumn<String> _column_20(String aliasedName) =>
|
||||
i1.GeneratedColumn<String>(
|
||||
'id',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i1.DriftSqlType.string,
|
||||
$customConstraints: 'NOT NULL PRIMARY KEY',
|
||||
);
|
||||
i1.GeneratedColumn<String> _column_21(String aliasedName) =>
|
||||
i1.GeneratedColumn<String>(
|
||||
'name',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i1.DriftSqlType.string,
|
||||
$customConstraints: 'NOT NULL',
|
||||
);
|
||||
i1.GeneratedColumn<String> _column_22(String aliasedName) =>
|
||||
i1.GeneratedColumn<String>(
|
||||
'type',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i1.DriftSqlType.string,
|
||||
$customConstraints: 'NOT NULL',
|
||||
);
|
||||
i1.GeneratedColumn<String> _column_23(String aliasedName) =>
|
||||
i1.GeneratedColumn<String>(
|
||||
'config_json',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i1.DriftSqlType.string,
|
||||
$customConstraints: 'NOT NULL',
|
||||
);
|
||||
i1.GeneratedColumn<int> _column_24(String aliasedName) =>
|
||||
i1.GeneratedColumn<int>(
|
||||
'created_at',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i1.DriftSqlType.int,
|
||||
$customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||
defaultValue: const i1.CustomExpression('CURRENT_TIMESTAMP'),
|
||||
);
|
||||
i1.GeneratedColumn<int> _column_25(String aliasedName) =>
|
||||
i1.GeneratedColumn<int>(
|
||||
'updated_at',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i1.DriftSqlType.int,
|
||||
$customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||
defaultValue: const i1.CustomExpression('CURRENT_TIMESTAMP'),
|
||||
);
|
||||
|
||||
class Shape8 extends i0.VersionedTable {
|
||||
Shape8({required super.source, required super.alias}) : super.aliased();
|
||||
i1.GeneratedColumn<int> get id =>
|
||||
columnsByName['id']! as i1.GeneratedColumn<int>;
|
||||
i1.GeneratedColumn<String> get regularTabsMode =>
|
||||
columnsByName['regular_tabs_mode']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get regularTabsProxyConnectionId =>
|
||||
columnsByName['regular_tabs_proxy_connection_id']!
|
||||
as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get privateTabsProxyConnectionId =>
|
||||
columnsByName['private_tabs_proxy_connection_id']!
|
||||
as i1.GeneratedColumn<String>;
|
||||
}
|
||||
|
||||
i1.GeneratedColumn<int> _column_26(String aliasedName) =>
|
||||
i1.GeneratedColumn<int>(
|
||||
'id',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i1.DriftSqlType.int,
|
||||
$customConstraints: 'NOT NULL PRIMARY KEY CHECK (id = 1)',
|
||||
);
|
||||
i1.GeneratedColumn<String> _column_27(String aliasedName) =>
|
||||
i1.GeneratedColumn<String>(
|
||||
'regular_tabs_mode',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i1.DriftSqlType.string,
|
||||
$customConstraints: 'NOT NULL',
|
||||
);
|
||||
i1.GeneratedColumn<String> _column_28(String aliasedName) =>
|
||||
i1.GeneratedColumn<String>(
|
||||
'regular_tabs_proxy_connection_id',
|
||||
aliasedName,
|
||||
true,
|
||||
type: i1.DriftSqlType.string,
|
||||
$customConstraints: '',
|
||||
);
|
||||
i1.GeneratedColumn<String> _column_29(String aliasedName) =>
|
||||
i1.GeneratedColumn<String>(
|
||||
'private_tabs_proxy_connection_id',
|
||||
aliasedName,
|
||||
true,
|
||||
type: i1.DriftSqlType.string,
|
||||
$customConstraints: '',
|
||||
);
|
||||
|
||||
final class Schema7 extends i0.VersionedSchema {
|
||||
Schema7({required super.database}) : super(version: 7);
|
||||
@override
|
||||
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||
setting,
|
||||
proxyProfile,
|
||||
idxProxyProfileUpdatedAt,
|
||||
proxyRoutingSetting,
|
||||
iconCache,
|
||||
onboarding,
|
||||
riverpod,
|
||||
toolbarButtonConfigs,
|
||||
idxToolbarOrderKey,
|
||||
searchTokens,
|
||||
idxSearchTokensInsertedAt,
|
||||
idxSearchTokensReservedAt,
|
||||
];
|
||||
late final Shape0 setting = Shape0(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'setting',
|
||||
withoutRowId: false,
|
||||
isStrict: true,
|
||||
tableConstraints: [],
|
||||
columns: [_column_0, _column_1, _column_2],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape9 proxyProfile = Shape9(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'proxy_profile',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_20,
|
||||
_column_21,
|
||||
_column_22,
|
||||
_column_23,
|
||||
_column_30,
|
||||
_column_24,
|
||||
_column_25,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxProxyProfileUpdatedAt = i1.Index(
|
||||
'idx_proxy_profile_updated_at',
|
||||
'CREATE INDEX idx_proxy_profile_updated_at ON proxy_profile (updated_at)',
|
||||
);
|
||||
late final Shape8 proxyRoutingSetting = Shape8(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'proxy_routing_setting',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_26, _column_27, _column_28, _column_29],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape1 iconCache = Shape1(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'icon_cache',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_3, _column_4, _column_5],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape2 onboarding = Shape2(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'onboarding',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_6, _column_7],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape3 riverpod = Shape3(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'riverpod',
|
||||
withoutRowId: true,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_0, _column_8, _column_9, _column_10],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape4 toolbarButtonConfigs = Shape4(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'toolbar_button_configs',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_11, _column_12, _column_13, _column_14],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxToolbarOrderKey = i1.Index(
|
||||
'idx_toolbar_order_key',
|
||||
'CREATE INDEX idx_toolbar_order_key ON toolbar_button_configs (order_key)',
|
||||
);
|
||||
late final Shape6 searchTokens = Shape6(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'search_tokens',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_15, _column_16, _column_17, _column_18, _column_19],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxSearchTokensInsertedAt = i1.Index(
|
||||
'idx_search_tokens_inserted_at',
|
||||
'CREATE INDEX idx_search_tokens_inserted_at ON search_tokens (inserted_at)',
|
||||
);
|
||||
final i1.Index idxSearchTokensReservedAt = i1.Index(
|
||||
'idx_search_tokens_reserved_at',
|
||||
'CREATE INDEX idx_search_tokens_reserved_at ON search_tokens (reserved_at)',
|
||||
);
|
||||
}
|
||||
|
||||
class Shape9 extends i0.VersionedTable {
|
||||
Shape9({required super.source, required super.alias}) : super.aliased();
|
||||
i1.GeneratedColumn<String> get id =>
|
||||
columnsByName['id']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get name =>
|
||||
columnsByName['name']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get type =>
|
||||
columnsByName['type']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get configJson =>
|
||||
columnsByName['config_json']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get dnsOverrideJson =>
|
||||
columnsByName['dns_override_json']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<int> get createdAt =>
|
||||
columnsByName['created_at']! as i1.GeneratedColumn<int>;
|
||||
i1.GeneratedColumn<int> get updatedAt =>
|
||||
columnsByName['updated_at']! as i1.GeneratedColumn<int>;
|
||||
}
|
||||
|
||||
i1.GeneratedColumn<String> _column_30(String aliasedName) =>
|
||||
i1.GeneratedColumn<String>(
|
||||
'dns_override_json',
|
||||
aliasedName,
|
||||
true,
|
||||
type: i1.DriftSqlType.string,
|
||||
$customConstraints: '',
|
||||
);
|
||||
|
||||
final class Schema8 extends i0.VersionedSchema {
|
||||
Schema8({required super.database}) : super(version: 8);
|
||||
@override
|
||||
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||
setting,
|
||||
proxyProfile,
|
||||
idxProxyProfileUpdatedAt,
|
||||
iconCache,
|
||||
onboarding,
|
||||
riverpod,
|
||||
toolbarButtonConfigs,
|
||||
idxToolbarOrderKey,
|
||||
searchTokens,
|
||||
idxSearchTokensInsertedAt,
|
||||
idxSearchTokensReservedAt,
|
||||
];
|
||||
late final Shape0 setting = Shape0(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'setting',
|
||||
withoutRowId: false,
|
||||
isStrict: true,
|
||||
tableConstraints: [],
|
||||
columns: [_column_0, _column_1, _column_2],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape9 proxyProfile = Shape9(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'proxy_profile',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_20,
|
||||
_column_21,
|
||||
_column_22,
|
||||
_column_23,
|
||||
_column_30,
|
||||
_column_24,
|
||||
_column_25,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxProxyProfileUpdatedAt = i1.Index(
|
||||
'idx_proxy_profile_updated_at',
|
||||
'CREATE INDEX idx_proxy_profile_updated_at ON proxy_profile (updated_at)',
|
||||
);
|
||||
late final Shape1 iconCache = Shape1(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'icon_cache',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_3, _column_4, _column_5],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape2 onboarding = Shape2(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'onboarding',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_6, _column_7],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape3 riverpod = Shape3(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'riverpod',
|
||||
withoutRowId: true,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_0, _column_8, _column_9, _column_10],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape4 toolbarButtonConfigs = Shape4(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'toolbar_button_configs',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_11, _column_12, _column_13, _column_14],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxToolbarOrderKey = i1.Index(
|
||||
'idx_toolbar_order_key',
|
||||
'CREATE INDEX idx_toolbar_order_key ON toolbar_button_configs (order_key)',
|
||||
);
|
||||
late final Shape6 searchTokens = Shape6(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'search_tokens',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_15, _column_16, _column_17, _column_18, _column_19],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxSearchTokensInsertedAt = i1.Index(
|
||||
'idx_search_tokens_inserted_at',
|
||||
'CREATE INDEX idx_search_tokens_inserted_at ON search_tokens (inserted_at)',
|
||||
);
|
||||
final i1.Index idxSearchTokensReservedAt = i1.Index(
|
||||
'idx_search_tokens_reserved_at',
|
||||
'CREATE INDEX idx_search_tokens_reserved_at ON search_tokens (reserved_at)',
|
||||
);
|
||||
}
|
||||
|
||||
i0.MigrationStepWithVersion migrationSteps({
|
||||
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
||||
required Future<void> Function(i1.Migrator m, Schema3 schema) from2To3,
|
||||
required Future<void> Function(i1.Migrator m, Schema4 schema) from3To4,
|
||||
required Future<void> Function(i1.Migrator m, Schema5 schema) from4To5,
|
||||
required Future<void> Function(i1.Migrator m, Schema6 schema) from5To6,
|
||||
required Future<void> Function(i1.Migrator m, Schema7 schema) from6To7,
|
||||
required Future<void> Function(i1.Migrator m, Schema8 schema) from7To8,
|
||||
}) {
|
||||
return (currentVersion, database) async {
|
||||
switch (currentVersion) {
|
||||
@@ -591,6 +1116,21 @@ i0.MigrationStepWithVersion migrationSteps({
|
||||
final migrator = i1.Migrator(database, schema);
|
||||
await from4To5(migrator, schema);
|
||||
return 5;
|
||||
case 5:
|
||||
final schema = Schema6(database: database);
|
||||
final migrator = i1.Migrator(database, schema);
|
||||
await from5To6(migrator, schema);
|
||||
return 6;
|
||||
case 6:
|
||||
final schema = Schema7(database: database);
|
||||
final migrator = i1.Migrator(database, schema);
|
||||
await from6To7(migrator, schema);
|
||||
return 7;
|
||||
case 7:
|
||||
final schema = Schema8(database: database);
|
||||
final migrator = i1.Migrator(database, schema);
|
||||
await from7To8(migrator, schema);
|
||||
return 8;
|
||||
default:
|
||||
throw ArgumentError.value('Unknown migration from $currentVersion');
|
||||
}
|
||||
@@ -602,11 +1142,17 @@ i1.OnUpgrade stepByStep({
|
||||
required Future<void> Function(i1.Migrator m, Schema3 schema) from2To3,
|
||||
required Future<void> Function(i1.Migrator m, Schema4 schema) from3To4,
|
||||
required Future<void> Function(i1.Migrator m, Schema5 schema) from4To5,
|
||||
required Future<void> Function(i1.Migrator m, Schema6 schema) from5To6,
|
||||
required Future<void> Function(i1.Migrator m, Schema7 schema) from6To7,
|
||||
required Future<void> Function(i1.Migrator m, Schema8 schema) from7To8,
|
||||
}) => i0.VersionedSchema.stepByStepHelper(
|
||||
step: migrationSteps(
|
||||
from1To2: from1To2,
|
||||
from2To3: from2To3,
|
||||
from3To4: from3To4,
|
||||
from4To5: from4To5,
|
||||
from5To6: from5To6,
|
||||
from6To7: from6To7,
|
||||
from7To8: from7To8,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
import 'package:flutter_singbox_proxy/flutter_singbox_proxy.dart';
|
||||
|
||||
CREATE TABLE setting (
|
||||
"key" TEXT PRIMARY KEY NOT NULL,
|
||||
partition_key TEXT,
|
||||
"value" ANY
|
||||
) STRICT;
|
||||
|
||||
CREATE TABLE proxy_profile (
|
||||
id TEXT NOT NULL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
type ENUMNAME(SingboxProxyProfileType) NOT NULL,
|
||||
config_json TEXT NOT NULL,
|
||||
dns_override_json TEXT,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
) AS ProxyProfile;
|
||||
|
||||
CREATE INDEX idx_proxy_profile_updated_at ON proxy_profile(updated_at);
|
||||
|
||||
CREATE TABLE icon_cache (
|
||||
origin TEXT PRIMARY KEY NOT NULL,
|
||||
icon_data BLOB NOT NULL,
|
||||
@@ -104,4 +118,4 @@ evictCacheEntries:
|
||||
FROM icon_cache
|
||||
ORDER BY fetch_date DESC
|
||||
LIMIT -1 OFFSET :limit
|
||||
);
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2026 Fabian Freund.
|
||||
*
|
||||
* This file is part of WebLibre
|
||||
* (see https://weblibre.eu).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'proxy_dns_override.g.dart';
|
||||
|
||||
/// Mirrors sing-box's `dns.strategy` field.
|
||||
enum ProxyDnsDomainStrategy { auto, preferIpv4, preferIpv6, ipv4Only, ipv6Only }
|
||||
|
||||
extension ProxyDnsDomainStrategyExt on ProxyDnsDomainStrategy {
|
||||
String get singboxValue => switch (this) {
|
||||
ProxyDnsDomainStrategy.auto => '',
|
||||
ProxyDnsDomainStrategy.preferIpv4 => 'prefer_ipv4',
|
||||
ProxyDnsDomainStrategy.preferIpv6 => 'prefer_ipv6',
|
||||
ProxyDnsDomainStrategy.ipv4Only => 'ipv4_only',
|
||||
ProxyDnsDomainStrategy.ipv6Only => 'ipv6_only',
|
||||
};
|
||||
}
|
||||
|
||||
@JsonSerializable(includeIfNull: true)
|
||||
class ProxyDnsOverride with FastEquatable {
|
||||
/// Single DNS server resolved through this profile's own outbound.
|
||||
final String? remoteServerAddress;
|
||||
|
||||
final ProxyDnsDomainStrategy domainStrategy;
|
||||
|
||||
ProxyDnsOverride({
|
||||
this.remoteServerAddress,
|
||||
this.domainStrategy = ProxyDnsDomainStrategy.preferIpv4,
|
||||
});
|
||||
|
||||
factory ProxyDnsOverride.fromJson(Map<String, dynamic> json) =>
|
||||
_$ProxyDnsOverrideFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ProxyDnsOverrideToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [remoteServerAddress, domainStrategy];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'proxy_dns_override.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ProxyDnsOverride _$ProxyDnsOverrideFromJson(Map<String, dynamic> json) =>
|
||||
ProxyDnsOverride(
|
||||
remoteServerAddress: json['remoteServerAddress'] as String?,
|
||||
domainStrategy:
|
||||
$enumDecodeNullable(
|
||||
_$ProxyDnsDomainStrategyEnumMap,
|
||||
json['domainStrategy'],
|
||||
) ??
|
||||
ProxyDnsDomainStrategy.preferIpv4,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ProxyDnsOverrideToJson(
|
||||
ProxyDnsOverride instance,
|
||||
) => <String, dynamic>{
|
||||
'remoteServerAddress': instance.remoteServerAddress,
|
||||
'domainStrategy': _$ProxyDnsDomainStrategyEnumMap[instance.domainStrategy]!,
|
||||
};
|
||||
|
||||
const _$ProxyDnsDomainStrategyEnumMap = {
|
||||
ProxyDnsDomainStrategy.auto: 'auto',
|
||||
ProxyDnsDomainStrategy.preferIpv4: 'preferIpv4',
|
||||
ProxyDnsDomainStrategy.preferIpv6: 'preferIpv6',
|
||||
ProxyDnsDomainStrategy.ipv4Only: 'ipv4Only',
|
||||
ProxyDnsDomainStrategy.ipv6Only: 'ipv6Only',
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2026 Fabian Freund.
|
||||
*
|
||||
* This file is part of WebLibre
|
||||
* (see https://weblibre.eu).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:weblibre/features/proxy/data/proxy_connection.dart';
|
||||
|
||||
part 'proxy_routing_settings.g.dart';
|
||||
|
||||
enum ProxyRegularTabRoutingMode { container, all }
|
||||
|
||||
@CopyWith()
|
||||
@JsonSerializable(includeIfNull: true, constructor: 'withDefaults')
|
||||
class ProxyRoutingSettings with FastEquatable {
|
||||
final ProxyRegularTabRoutingMode regularTabsMode;
|
||||
|
||||
@JsonKey(
|
||||
fromJson: _proxyConnectionIdFromJson,
|
||||
toJson: _proxyConnectionIdToJson,
|
||||
)
|
||||
final ProxyConnectionId? regularTabsProxyConnectionId;
|
||||
|
||||
@JsonKey(
|
||||
fromJson: _proxyConnectionIdFromJson,
|
||||
toJson: _proxyConnectionIdToJson,
|
||||
)
|
||||
final ProxyConnectionId? privateTabsProxyConnectionId;
|
||||
|
||||
ProxyRoutingSettings({
|
||||
required this.regularTabsMode,
|
||||
required this.regularTabsProxyConnectionId,
|
||||
required this.privateTabsProxyConnectionId,
|
||||
});
|
||||
|
||||
ProxyRoutingSettings.withDefaults({
|
||||
ProxyRegularTabRoutingMode? regularTabsMode,
|
||||
this.regularTabsProxyConnectionId,
|
||||
this.privateTabsProxyConnectionId,
|
||||
}) : regularTabsMode =
|
||||
regularTabsMode ?? ProxyRegularTabRoutingMode.container;
|
||||
|
||||
factory ProxyRoutingSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$ProxyRoutingSettingsFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ProxyRoutingSettingsToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [
|
||||
regularTabsMode,
|
||||
regularTabsProxyConnectionId,
|
||||
privateTabsProxyConnectionId,
|
||||
];
|
||||
}
|
||||
|
||||
ProxyConnectionId? _proxyConnectionIdFromJson(String? json) =>
|
||||
ProxyConnectionId.decode(json);
|
||||
|
||||
String? _proxyConnectionIdToJson(ProxyConnectionId? object) => object?.encode();
|
||||
@@ -0,0 +1,136 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'proxy_routing_settings.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$ProxyRoutingSettingsCWProxy {
|
||||
ProxyRoutingSettings regularTabsMode(
|
||||
ProxyRegularTabRoutingMode regularTabsMode,
|
||||
);
|
||||
|
||||
ProxyRoutingSettings regularTabsProxyConnectionId(
|
||||
ProxyConnectionId? regularTabsProxyConnectionId,
|
||||
);
|
||||
|
||||
ProxyRoutingSettings privateTabsProxyConnectionId(
|
||||
ProxyConnectionId? privateTabsProxyConnectionId,
|
||||
);
|
||||
|
||||
/// Creates a new instance with the provided field values.
|
||||
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `ProxyRoutingSettings(...).copyWith.fieldName(value)`.
|
||||
///
|
||||
/// Example:
|
||||
/// ```dart
|
||||
/// ProxyRoutingSettings(...).copyWith(id: 12, name: "My name")
|
||||
/// ```
|
||||
ProxyRoutingSettings call({
|
||||
ProxyRegularTabRoutingMode regularTabsMode,
|
||||
ProxyConnectionId? regularTabsProxyConnectionId,
|
||||
ProxyConnectionId? privateTabsProxyConnectionId,
|
||||
});
|
||||
}
|
||||
|
||||
/// Callable proxy for `copyWith` functionality.
|
||||
/// Use as `instanceOfProxyRoutingSettings.copyWith(...)` or call `instanceOfProxyRoutingSettings.copyWith.fieldName(value)` for a single field.
|
||||
class _$ProxyRoutingSettingsCWProxyImpl
|
||||
implements _$ProxyRoutingSettingsCWProxy {
|
||||
const _$ProxyRoutingSettingsCWProxyImpl(this._value);
|
||||
|
||||
final ProxyRoutingSettings _value;
|
||||
|
||||
@override
|
||||
ProxyRoutingSettings regularTabsMode(
|
||||
ProxyRegularTabRoutingMode regularTabsMode,
|
||||
) => call(regularTabsMode: regularTabsMode);
|
||||
|
||||
@override
|
||||
ProxyRoutingSettings regularTabsProxyConnectionId(
|
||||
ProxyConnectionId? regularTabsProxyConnectionId,
|
||||
) => call(regularTabsProxyConnectionId: regularTabsProxyConnectionId);
|
||||
|
||||
@override
|
||||
ProxyRoutingSettings privateTabsProxyConnectionId(
|
||||
ProxyConnectionId? privateTabsProxyConnectionId,
|
||||
) => call(privateTabsProxyConnectionId: privateTabsProxyConnectionId);
|
||||
|
||||
@override
|
||||
/// Creates a new instance with the provided field values.
|
||||
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `ProxyRoutingSettings(...).copyWith.fieldName(value)`.
|
||||
///
|
||||
/// Example:
|
||||
/// ```dart
|
||||
/// ProxyRoutingSettings(...).copyWith(id: 12, name: "My name")
|
||||
/// ```
|
||||
ProxyRoutingSettings call({
|
||||
Object? regularTabsMode = const $CopyWithPlaceholder(),
|
||||
Object? regularTabsProxyConnectionId = const $CopyWithPlaceholder(),
|
||||
Object? privateTabsProxyConnectionId = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return ProxyRoutingSettings(
|
||||
regularTabsMode:
|
||||
regularTabsMode == const $CopyWithPlaceholder() ||
|
||||
regularTabsMode == null
|
||||
? _value.regularTabsMode
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: regularTabsMode as ProxyRegularTabRoutingMode,
|
||||
regularTabsProxyConnectionId:
|
||||
regularTabsProxyConnectionId == const $CopyWithPlaceholder()
|
||||
? _value.regularTabsProxyConnectionId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: regularTabsProxyConnectionId as ProxyConnectionId?,
|
||||
privateTabsProxyConnectionId:
|
||||
privateTabsProxyConnectionId == const $CopyWithPlaceholder()
|
||||
? _value.privateTabsProxyConnectionId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: privateTabsProxyConnectionId as ProxyConnectionId?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $ProxyRoutingSettingsCopyWith on ProxyRoutingSettings {
|
||||
/// Returns a callable class used to build a new instance with modified fields.
|
||||
/// Example: `instanceOfProxyRoutingSettings.copyWith(...)` or `instanceOfProxyRoutingSettings.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$ProxyRoutingSettingsCWProxy get copyWith =>
|
||||
_$ProxyRoutingSettingsCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ProxyRoutingSettings _$ProxyRoutingSettingsFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => ProxyRoutingSettings.withDefaults(
|
||||
regularTabsMode: $enumDecodeNullable(
|
||||
_$ProxyRegularTabRoutingModeEnumMap,
|
||||
json['regularTabsMode'],
|
||||
),
|
||||
regularTabsProxyConnectionId: _proxyConnectionIdFromJson(
|
||||
json['regularTabsProxyConnectionId'] as String?,
|
||||
),
|
||||
privateTabsProxyConnectionId: _proxyConnectionIdFromJson(
|
||||
json['privateTabsProxyConnectionId'] as String?,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ProxyRoutingSettingsToJson(
|
||||
ProxyRoutingSettings instance,
|
||||
) => <String, dynamic>{
|
||||
'regularTabsMode':
|
||||
_$ProxyRegularTabRoutingModeEnumMap[instance.regularTabsMode]!,
|
||||
'regularTabsProxyConnectionId': _proxyConnectionIdToJson(
|
||||
instance.regularTabsProxyConnectionId,
|
||||
),
|
||||
'privateTabsProxyConnectionId': _proxyConnectionIdToJson(
|
||||
instance.privateTabsProxyConnectionId,
|
||||
),
|
||||
};
|
||||
|
||||
const _$ProxyRegularTabRoutingModeEnumMap = {
|
||||
ProxyRegularTabRoutingMode.container: 'container',
|
||||
ProxyRegularTabRoutingMode.all: 'all',
|
||||
};
|
||||
@@ -25,13 +25,9 @@ part 'tor_settings.g.dart';
|
||||
|
||||
enum TorConnectionConfig { auto, direct, obfs4, snowflake }
|
||||
|
||||
enum TorRegularTabProxyMode { container, all }
|
||||
|
||||
@CopyWith()
|
||||
@JsonSerializable(includeIfNull: true, constructor: 'withDefaults')
|
||||
class TorSettings with FastEquatable {
|
||||
final TorRegularTabProxyMode proxyRegularTabsMode;
|
||||
final bool proxyPrivateTabsTor;
|
||||
final TorConnectionConfig config;
|
||||
final bool requireBridge;
|
||||
final bool fetchRemoteBridges;
|
||||
@@ -39,8 +35,6 @@ class TorSettings with FastEquatable {
|
||||
final String? exitNodeCountry;
|
||||
|
||||
TorSettings({
|
||||
required this.proxyRegularTabsMode,
|
||||
required this.proxyPrivateTabsTor,
|
||||
required this.config,
|
||||
required this.requireBridge,
|
||||
required this.fetchRemoteBridges,
|
||||
@@ -49,17 +43,12 @@ class TorSettings with FastEquatable {
|
||||
});
|
||||
|
||||
TorSettings.withDefaults({
|
||||
TorRegularTabProxyMode? proxyRegularTabsMode,
|
||||
bool? proxyPrivateTabsTor,
|
||||
TorConnectionConfig? config,
|
||||
bool? requireBridge,
|
||||
bool? fetchRemoteBridges,
|
||||
this.entryNodeCountry,
|
||||
this.exitNodeCountry,
|
||||
}) : proxyRegularTabsMode =
|
||||
proxyRegularTabsMode ?? TorRegularTabProxyMode.container,
|
||||
proxyPrivateTabsTor = proxyPrivateTabsTor ?? false,
|
||||
config = config ?? TorConnectionConfig.auto,
|
||||
}) : config = config ?? TorConnectionConfig.auto,
|
||||
requireBridge = requireBridge ?? false,
|
||||
fetchRemoteBridges = fetchRemoteBridges ?? true;
|
||||
|
||||
@@ -70,8 +59,6 @@ class TorSettings with FastEquatable {
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [
|
||||
proxyRegularTabsMode,
|
||||
proxyPrivateTabsTor,
|
||||
config,
|
||||
requireBridge,
|
||||
fetchRemoteBridges,
|
||||
|
||||
@@ -7,10 +7,6 @@ part of 'tor_settings.dart';
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$TorSettingsCWProxy {
|
||||
TorSettings proxyRegularTabsMode(TorRegularTabProxyMode proxyRegularTabsMode);
|
||||
|
||||
TorSettings proxyPrivateTabsTor(bool proxyPrivateTabsTor);
|
||||
|
||||
TorSettings config(TorConnectionConfig config);
|
||||
|
||||
TorSettings requireBridge(bool requireBridge);
|
||||
@@ -29,8 +25,6 @@ abstract class _$TorSettingsCWProxy {
|
||||
/// TorSettings(...).copyWith(id: 12, name: "My name")
|
||||
/// ```
|
||||
TorSettings call({
|
||||
TorRegularTabProxyMode proxyRegularTabsMode,
|
||||
bool proxyPrivateTabsTor,
|
||||
TorConnectionConfig config,
|
||||
bool requireBridge,
|
||||
bool fetchRemoteBridges,
|
||||
@@ -46,15 +40,6 @@ class _$TorSettingsCWProxyImpl implements _$TorSettingsCWProxy {
|
||||
|
||||
final TorSettings _value;
|
||||
|
||||
@override
|
||||
TorSettings proxyRegularTabsMode(
|
||||
TorRegularTabProxyMode proxyRegularTabsMode,
|
||||
) => call(proxyRegularTabsMode: proxyRegularTabsMode);
|
||||
|
||||
@override
|
||||
TorSettings proxyPrivateTabsTor(bool proxyPrivateTabsTor) =>
|
||||
call(proxyPrivateTabsTor: proxyPrivateTabsTor);
|
||||
|
||||
@override
|
||||
TorSettings config(TorConnectionConfig config) => call(config: config);
|
||||
|
||||
@@ -83,8 +68,6 @@ class _$TorSettingsCWProxyImpl implements _$TorSettingsCWProxy {
|
||||
/// TorSettings(...).copyWith(id: 12, name: "My name")
|
||||
/// ```
|
||||
TorSettings call({
|
||||
Object? proxyRegularTabsMode = const $CopyWithPlaceholder(),
|
||||
Object? proxyPrivateTabsTor = const $CopyWithPlaceholder(),
|
||||
Object? config = const $CopyWithPlaceholder(),
|
||||
Object? requireBridge = const $CopyWithPlaceholder(),
|
||||
Object? fetchRemoteBridges = const $CopyWithPlaceholder(),
|
||||
@@ -92,18 +75,6 @@ class _$TorSettingsCWProxyImpl implements _$TorSettingsCWProxy {
|
||||
Object? exitNodeCountry = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return TorSettings(
|
||||
proxyRegularTabsMode:
|
||||
proxyRegularTabsMode == const $CopyWithPlaceholder() ||
|
||||
proxyRegularTabsMode == null
|
||||
? _value.proxyRegularTabsMode
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: proxyRegularTabsMode as TorRegularTabProxyMode,
|
||||
proxyPrivateTabsTor:
|
||||
proxyPrivateTabsTor == const $CopyWithPlaceholder() ||
|
||||
proxyPrivateTabsTor == null
|
||||
? _value.proxyPrivateTabsTor
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: proxyPrivateTabsTor as bool,
|
||||
config: config == const $CopyWithPlaceholder() || config == null
|
||||
? _value.config
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
@@ -144,11 +115,6 @@ extension $TorSettingsCopyWith on TorSettings {
|
||||
|
||||
TorSettings _$TorSettingsFromJson(Map<String, dynamic> json) =>
|
||||
TorSettings.withDefaults(
|
||||
proxyRegularTabsMode: $enumDecodeNullable(
|
||||
_$TorRegularTabProxyModeEnumMap,
|
||||
json['proxyRegularTabsMode'],
|
||||
),
|
||||
proxyPrivateTabsTor: json['proxyPrivateTabsTor'] as bool?,
|
||||
config: $enumDecodeNullable(_$TorConnectionConfigEnumMap, json['config']),
|
||||
requireBridge: json['requireBridge'] as bool?,
|
||||
fetchRemoteBridges: json['fetchRemoteBridges'] as bool?,
|
||||
@@ -158,9 +124,6 @@ TorSettings _$TorSettingsFromJson(Map<String, dynamic> json) =>
|
||||
|
||||
Map<String, dynamic> _$TorSettingsToJson(TorSettings instance) =>
|
||||
<String, dynamic>{
|
||||
'proxyRegularTabsMode':
|
||||
_$TorRegularTabProxyModeEnumMap[instance.proxyRegularTabsMode]!,
|
||||
'proxyPrivateTabsTor': instance.proxyPrivateTabsTor,
|
||||
'config': _$TorConnectionConfigEnumMap[instance.config]!,
|
||||
'requireBridge': instance.requireBridge,
|
||||
'fetchRemoteBridges': instance.fetchRemoteBridges,
|
||||
@@ -168,11 +131,6 @@ Map<String, dynamic> _$TorSettingsToJson(TorSettings instance) =>
|
||||
'exitNodeCountry': instance.exitNodeCountry,
|
||||
};
|
||||
|
||||
const _$TorRegularTabProxyModeEnumMap = {
|
||||
TorRegularTabProxyMode.container: 'container',
|
||||
TorRegularTabProxyMode.all: 'all',
|
||||
};
|
||||
|
||||
const _$TorConnectionConfigEnumMap = {
|
||||
TorConnectionConfig.auto: 'auto',
|
||||
TorConnectionConfig.direct: 'direct',
|
||||
|
||||
Reference in New Issue
Block a user