mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-02-02 14:16:58 +00:00
refactor: Generalize DKIM usage into DnsRecords
- Replace raw DKIM String object with a general DnsRecord structure - Implement network utils for common operations with networking concepts and structures - Implement initializing page pop up to re-try server deployment in case of a random networking error
This commit is contained in:
parent
68811efc1e
commit
86b80156fd
|
@ -348,4 +348,12 @@ enum UserType {
|
|||
type Users {
|
||||
allUsers: [User!]!
|
||||
getUser(username: String!): User
|
||||
}
|
||||
|
||||
fragment dnsRecordFields on DnsRecord {
|
||||
content
|
||||
name
|
||||
priority
|
||||
recordType
|
||||
ttl
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
import 'package:gql/ast.dart';
|
||||
import 'package:graphql/client.dart' as graphql;
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:selfprivacy/utils/scalars.dart';
|
||||
part 'schema.graphql.g.dart';
|
||||
|
@ -736,6 +738,220 @@ enum Enum$UserType {
|
|||
$unknown
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Fragment$dnsRecordFields {
|
||||
Fragment$dnsRecordFields(
|
||||
{required this.content,
|
||||
required this.name,
|
||||
this.priority,
|
||||
required this.recordType,
|
||||
required this.ttl,
|
||||
required this.$__typename});
|
||||
|
||||
@override
|
||||
factory Fragment$dnsRecordFields.fromJson(Map<String, dynamic> json) =>
|
||||
_$Fragment$dnsRecordFieldsFromJson(json);
|
||||
|
||||
final String content;
|
||||
|
||||
final String name;
|
||||
|
||||
final int? priority;
|
||||
|
||||
final String recordType;
|
||||
|
||||
final int ttl;
|
||||
|
||||
@JsonKey(name: '__typename')
|
||||
final String $__typename;
|
||||
|
||||
Map<String, dynamic> toJson() => _$Fragment$dnsRecordFieldsToJson(this);
|
||||
int get hashCode {
|
||||
final l$content = content;
|
||||
final l$name = name;
|
||||
final l$priority = priority;
|
||||
final l$recordType = recordType;
|
||||
final l$ttl = ttl;
|
||||
final l$$__typename = $__typename;
|
||||
return Object.hashAll(
|
||||
[l$content, l$name, l$priority, l$recordType, l$ttl, l$$__typename]);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
if (!(other is Fragment$dnsRecordFields) ||
|
||||
runtimeType != other.runtimeType) return false;
|
||||
final l$content = content;
|
||||
final lOther$content = other.content;
|
||||
if (l$content != lOther$content) return false;
|
||||
final l$name = name;
|
||||
final lOther$name = other.name;
|
||||
if (l$name != lOther$name) return false;
|
||||
final l$priority = priority;
|
||||
final lOther$priority = other.priority;
|
||||
if (l$priority != lOther$priority) return false;
|
||||
final l$recordType = recordType;
|
||||
final lOther$recordType = other.recordType;
|
||||
if (l$recordType != lOther$recordType) return false;
|
||||
final l$ttl = ttl;
|
||||
final lOther$ttl = other.ttl;
|
||||
if (l$ttl != lOther$ttl) return false;
|
||||
final l$$__typename = $__typename;
|
||||
final lOther$$__typename = other.$__typename;
|
||||
if (l$$__typename != lOther$$__typename) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
extension UtilityExtension$Fragment$dnsRecordFields
|
||||
on Fragment$dnsRecordFields {
|
||||
CopyWith$Fragment$dnsRecordFields<Fragment$dnsRecordFields> get copyWith =>
|
||||
CopyWith$Fragment$dnsRecordFields(this, (i) => i);
|
||||
}
|
||||
|
||||
abstract class CopyWith$Fragment$dnsRecordFields<TRes> {
|
||||
factory CopyWith$Fragment$dnsRecordFields(Fragment$dnsRecordFields instance,
|
||||
TRes Function(Fragment$dnsRecordFields) then) =
|
||||
_CopyWithImpl$Fragment$dnsRecordFields;
|
||||
|
||||
factory CopyWith$Fragment$dnsRecordFields.stub(TRes res) =
|
||||
_CopyWithStubImpl$Fragment$dnsRecordFields;
|
||||
|
||||
TRes call(
|
||||
{String? content,
|
||||
String? name,
|
||||
int? priority,
|
||||
String? recordType,
|
||||
int? ttl,
|
||||
String? $__typename});
|
||||
}
|
||||
|
||||
class _CopyWithImpl$Fragment$dnsRecordFields<TRes>
|
||||
implements CopyWith$Fragment$dnsRecordFields<TRes> {
|
||||
_CopyWithImpl$Fragment$dnsRecordFields(this._instance, this._then);
|
||||
|
||||
final Fragment$dnsRecordFields _instance;
|
||||
|
||||
final TRes Function(Fragment$dnsRecordFields) _then;
|
||||
|
||||
static const _undefined = {};
|
||||
|
||||
TRes call(
|
||||
{Object? content = _undefined,
|
||||
Object? name = _undefined,
|
||||
Object? priority = _undefined,
|
||||
Object? recordType = _undefined,
|
||||
Object? ttl = _undefined,
|
||||
Object? $__typename = _undefined}) =>
|
||||
_then(Fragment$dnsRecordFields(
|
||||
content: content == _undefined || content == null
|
||||
? _instance.content
|
||||
: (content as String),
|
||||
name: name == _undefined || name == null
|
||||
? _instance.name
|
||||
: (name as String),
|
||||
priority:
|
||||
priority == _undefined ? _instance.priority : (priority as int?),
|
||||
recordType: recordType == _undefined || recordType == null
|
||||
? _instance.recordType
|
||||
: (recordType as String),
|
||||
ttl: ttl == _undefined || ttl == null ? _instance.ttl : (ttl as int),
|
||||
$__typename: $__typename == _undefined || $__typename == null
|
||||
? _instance.$__typename
|
||||
: ($__typename as String)));
|
||||
}
|
||||
|
||||
class _CopyWithStubImpl$Fragment$dnsRecordFields<TRes>
|
||||
implements CopyWith$Fragment$dnsRecordFields<TRes> {
|
||||
_CopyWithStubImpl$Fragment$dnsRecordFields(this._res);
|
||||
|
||||
TRes _res;
|
||||
|
||||
call(
|
||||
{String? content,
|
||||
String? name,
|
||||
int? priority,
|
||||
String? recordType,
|
||||
int? ttl,
|
||||
String? $__typename}) =>
|
||||
_res;
|
||||
}
|
||||
|
||||
const fragmentDefinitiondnsRecordFields = FragmentDefinitionNode(
|
||||
name: NameNode(value: 'dnsRecordFields'),
|
||||
typeCondition: TypeConditionNode(
|
||||
on: NamedTypeNode(
|
||||
name: NameNode(value: 'DnsRecord'), isNonNull: false)),
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'content'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'name'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'priority'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'recordType'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'ttl'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: '__typename'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null)
|
||||
]));
|
||||
const documentNodeFragmentdnsRecordFields = DocumentNode(definitions: [
|
||||
fragmentDefinitiondnsRecordFields,
|
||||
]);
|
||||
|
||||
extension ClientExtension$Fragment$dnsRecordFields on graphql.GraphQLClient {
|
||||
void writeFragment$dnsRecordFields(
|
||||
{required Fragment$dnsRecordFields data,
|
||||
required Map<String, dynamic> idFields,
|
||||
bool broadcast = true}) =>
|
||||
this.writeFragment(
|
||||
graphql.FragmentRequest(
|
||||
idFields: idFields,
|
||||
fragment: const graphql.Fragment(
|
||||
fragmentName: 'dnsRecordFields',
|
||||
document: documentNodeFragmentdnsRecordFields)),
|
||||
data: data.toJson(),
|
||||
broadcast: broadcast);
|
||||
Fragment$dnsRecordFields? readFragment$dnsRecordFields(
|
||||
{required Map<String, dynamic> idFields, bool optimistic = true}) {
|
||||
final result = this.readFragment(
|
||||
graphql.FragmentRequest(
|
||||
idFields: idFields,
|
||||
fragment: const graphql.Fragment(
|
||||
fragmentName: 'dnsRecordFields',
|
||||
document: documentNodeFragmentdnsRecordFields)),
|
||||
optimistic: optimistic);
|
||||
return result == null ? null : Fragment$dnsRecordFields.fromJson(result);
|
||||
}
|
||||
}
|
||||
|
||||
const possibleTypesMap = {
|
||||
'MutationReturnInterface': {
|
||||
'ApiKeyMutationReturn',
|
||||
|
|
|
@ -123,3 +123,25 @@ Map<String, dynamic> _$Input$UserMutationInputToJson(
|
|||
'username': instance.username,
|
||||
'password': instance.password,
|
||||
};
|
||||
|
||||
Fragment$dnsRecordFields _$Fragment$dnsRecordFieldsFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Fragment$dnsRecordFields(
|
||||
content: json['content'] as String,
|
||||
name: json['name'] as String,
|
||||
priority: json['priority'] as int?,
|
||||
recordType: json['recordType'] as String,
|
||||
ttl: json['ttl'] as int,
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Fragment$dnsRecordFieldsToJson(
|
||||
Fragment$dnsRecordFields instance) =>
|
||||
<String, dynamic>{
|
||||
'content': instance.content,
|
||||
'name': instance.name,
|
||||
'priority': instance.priority,
|
||||
'recordType': instance.recordType,
|
||||
'ttl': instance.ttl,
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
|
|
@ -35,11 +35,7 @@ query DomainInfo {
|
|||
hostname
|
||||
provider
|
||||
requiredDnsRecords {
|
||||
content
|
||||
name
|
||||
priority
|
||||
recordType
|
||||
ttl
|
||||
...dnsRecordFields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1444,36 +1444,9 @@ const documentNodeQueryDomainInfo = DocumentNode(definitions: [
|
|||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'content'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'name'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'priority'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'recordType'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'ttl'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FragmentSpreadNode(
|
||||
name: NameNode(value: 'dnsRecordFields'),
|
||||
directives: []),
|
||||
FieldNode(
|
||||
name: NameNode(value: '__typename'),
|
||||
alias: null,
|
||||
|
@ -1502,6 +1475,7 @@ const documentNodeQueryDomainInfo = DocumentNode(definitions: [
|
|||
directives: [],
|
||||
selectionSet: null)
|
||||
])),
|
||||
fragmentDefinitiondnsRecordFields,
|
||||
]);
|
||||
Query$DomainInfo _parserFn$Query$DomainInfo(Map<String, dynamic> data) =>
|
||||
Query$DomainInfo.fromJson(data);
|
||||
|
@ -1699,8 +1673,7 @@ class Query$DomainInfo$system$domainInfo {
|
|||
@JsonKey(unknownEnumValue: Enum$DnsProvider.$unknown)
|
||||
final Enum$DnsProvider provider;
|
||||
|
||||
final List<Query$DomainInfo$system$domainInfo$requiredDnsRecords>
|
||||
requiredDnsRecords;
|
||||
final List<Fragment$dnsRecordFields> requiredDnsRecords;
|
||||
|
||||
@JsonKey(name: '__typename')
|
||||
final String $__typename;
|
||||
|
@ -1775,14 +1748,12 @@ abstract class CopyWith$Query$DomainInfo$system$domainInfo<TRes> {
|
|||
{String? domain,
|
||||
String? hostname,
|
||||
Enum$DnsProvider? provider,
|
||||
List<Query$DomainInfo$system$domainInfo$requiredDnsRecords>?
|
||||
requiredDnsRecords,
|
||||
List<Fragment$dnsRecordFields>? requiredDnsRecords,
|
||||
String? $__typename});
|
||||
TRes requiredDnsRecords(
|
||||
Iterable<Query$DomainInfo$system$domainInfo$requiredDnsRecords> Function(
|
||||
Iterable<Fragment$dnsRecordFields> Function(
|
||||
Iterable<
|
||||
CopyWith$Query$DomainInfo$system$domainInfo$requiredDnsRecords<
|
||||
Query$DomainInfo$system$domainInfo$requiredDnsRecords>>)
|
||||
CopyWith$Fragment$dnsRecordFields<Fragment$dnsRecordFields>>)
|
||||
_fn);
|
||||
}
|
||||
|
||||
|
@ -1815,21 +1786,20 @@ class _CopyWithImpl$Query$DomainInfo$system$domainInfo<TRes>
|
|||
requiredDnsRecords:
|
||||
requiredDnsRecords == _undefined || requiredDnsRecords == null
|
||||
? _instance.requiredDnsRecords
|
||||
: (requiredDnsRecords as List<
|
||||
Query$DomainInfo$system$domainInfo$requiredDnsRecords>),
|
||||
: (requiredDnsRecords as List<Fragment$dnsRecordFields>),
|
||||
$__typename: $__typename == _undefined || $__typename == null
|
||||
? _instance.$__typename
|
||||
: ($__typename as String)));
|
||||
TRes requiredDnsRecords(
|
||||
Iterable<Query$DomainInfo$system$domainInfo$requiredDnsRecords> Function(
|
||||
Iterable<Fragment$dnsRecordFields> Function(
|
||||
Iterable<
|
||||
CopyWith$Query$DomainInfo$system$domainInfo$requiredDnsRecords<
|
||||
Query$DomainInfo$system$domainInfo$requiredDnsRecords>>)
|
||||
CopyWith$Fragment$dnsRecordFields<
|
||||
Fragment$dnsRecordFields>>)
|
||||
_fn) =>
|
||||
call(
|
||||
requiredDnsRecords: _fn(_instance.requiredDnsRecords.map((e) =>
|
||||
CopyWith$Query$DomainInfo$system$domainInfo$requiredDnsRecords(
|
||||
e, (i) => i))).toList());
|
||||
requiredDnsRecords: _fn(_instance.requiredDnsRecords
|
||||
.map((e) => CopyWith$Fragment$dnsRecordFields(e, (i) => i)))
|
||||
.toList());
|
||||
}
|
||||
|
||||
class _CopyWithStubImpl$Query$DomainInfo$system$domainInfo<TRes>
|
||||
|
@ -1842,168 +1812,12 @@ class _CopyWithStubImpl$Query$DomainInfo$system$domainInfo<TRes>
|
|||
{String? domain,
|
||||
String? hostname,
|
||||
Enum$DnsProvider? provider,
|
||||
List<Query$DomainInfo$system$domainInfo$requiredDnsRecords>?
|
||||
requiredDnsRecords,
|
||||
List<Fragment$dnsRecordFields>? requiredDnsRecords,
|
||||
String? $__typename}) =>
|
||||
_res;
|
||||
requiredDnsRecords(_fn) => _res;
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Query$DomainInfo$system$domainInfo$requiredDnsRecords {
|
||||
Query$DomainInfo$system$domainInfo$requiredDnsRecords(
|
||||
{required this.content,
|
||||
required this.name,
|
||||
this.priority,
|
||||
required this.recordType,
|
||||
required this.ttl,
|
||||
required this.$__typename});
|
||||
|
||||
@override
|
||||
factory Query$DomainInfo$system$domainInfo$requiredDnsRecords.fromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$Query$DomainInfo$system$domainInfo$requiredDnsRecordsFromJson(json);
|
||||
|
||||
final String content;
|
||||
|
||||
final String name;
|
||||
|
||||
final int? priority;
|
||||
|
||||
final String recordType;
|
||||
|
||||
final int ttl;
|
||||
|
||||
@JsonKey(name: '__typename')
|
||||
final String $__typename;
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
_$Query$DomainInfo$system$domainInfo$requiredDnsRecordsToJson(this);
|
||||
int get hashCode {
|
||||
final l$content = content;
|
||||
final l$name = name;
|
||||
final l$priority = priority;
|
||||
final l$recordType = recordType;
|
||||
final l$ttl = ttl;
|
||||
final l$$__typename = $__typename;
|
||||
return Object.hashAll(
|
||||
[l$content, l$name, l$priority, l$recordType, l$ttl, l$$__typename]);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
if (!(other is Query$DomainInfo$system$domainInfo$requiredDnsRecords) ||
|
||||
runtimeType != other.runtimeType) return false;
|
||||
final l$content = content;
|
||||
final lOther$content = other.content;
|
||||
if (l$content != lOther$content) return false;
|
||||
final l$name = name;
|
||||
final lOther$name = other.name;
|
||||
if (l$name != lOther$name) return false;
|
||||
final l$priority = priority;
|
||||
final lOther$priority = other.priority;
|
||||
if (l$priority != lOther$priority) return false;
|
||||
final l$recordType = recordType;
|
||||
final lOther$recordType = other.recordType;
|
||||
if (l$recordType != lOther$recordType) return false;
|
||||
final l$ttl = ttl;
|
||||
final lOther$ttl = other.ttl;
|
||||
if (l$ttl != lOther$ttl) return false;
|
||||
final l$$__typename = $__typename;
|
||||
final lOther$$__typename = other.$__typename;
|
||||
if (l$$__typename != lOther$$__typename) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
extension UtilityExtension$Query$DomainInfo$system$domainInfo$requiredDnsRecords
|
||||
on Query$DomainInfo$system$domainInfo$requiredDnsRecords {
|
||||
CopyWith$Query$DomainInfo$system$domainInfo$requiredDnsRecords<
|
||||
Query$DomainInfo$system$domainInfo$requiredDnsRecords>
|
||||
get copyWith =>
|
||||
CopyWith$Query$DomainInfo$system$domainInfo$requiredDnsRecords(
|
||||
this, (i) => i);
|
||||
}
|
||||
|
||||
abstract class CopyWith$Query$DomainInfo$system$domainInfo$requiredDnsRecords<
|
||||
TRes> {
|
||||
factory CopyWith$Query$DomainInfo$system$domainInfo$requiredDnsRecords(
|
||||
Query$DomainInfo$system$domainInfo$requiredDnsRecords instance,
|
||||
TRes Function(Query$DomainInfo$system$domainInfo$requiredDnsRecords)
|
||||
then) =
|
||||
_CopyWithImpl$Query$DomainInfo$system$domainInfo$requiredDnsRecords;
|
||||
|
||||
factory CopyWith$Query$DomainInfo$system$domainInfo$requiredDnsRecords.stub(
|
||||
TRes res) =
|
||||
_CopyWithStubImpl$Query$DomainInfo$system$domainInfo$requiredDnsRecords;
|
||||
|
||||
TRes call(
|
||||
{String? content,
|
||||
String? name,
|
||||
int? priority,
|
||||
String? recordType,
|
||||
int? ttl,
|
||||
String? $__typename});
|
||||
}
|
||||
|
||||
class _CopyWithImpl$Query$DomainInfo$system$domainInfo$requiredDnsRecords<TRes>
|
||||
implements
|
||||
CopyWith$Query$DomainInfo$system$domainInfo$requiredDnsRecords<TRes> {
|
||||
_CopyWithImpl$Query$DomainInfo$system$domainInfo$requiredDnsRecords(
|
||||
this._instance, this._then);
|
||||
|
||||
final Query$DomainInfo$system$domainInfo$requiredDnsRecords _instance;
|
||||
|
||||
final TRes Function(Query$DomainInfo$system$domainInfo$requiredDnsRecords)
|
||||
_then;
|
||||
|
||||
static const _undefined = {};
|
||||
|
||||
TRes call(
|
||||
{Object? content = _undefined,
|
||||
Object? name = _undefined,
|
||||
Object? priority = _undefined,
|
||||
Object? recordType = _undefined,
|
||||
Object? ttl = _undefined,
|
||||
Object? $__typename = _undefined}) =>
|
||||
_then(Query$DomainInfo$system$domainInfo$requiredDnsRecords(
|
||||
content: content == _undefined || content == null
|
||||
? _instance.content
|
||||
: (content as String),
|
||||
name: name == _undefined || name == null
|
||||
? _instance.name
|
||||
: (name as String),
|
||||
priority:
|
||||
priority == _undefined ? _instance.priority : (priority as int?),
|
||||
recordType: recordType == _undefined || recordType == null
|
||||
? _instance.recordType
|
||||
: (recordType as String),
|
||||
ttl: ttl == _undefined || ttl == null ? _instance.ttl : (ttl as int),
|
||||
$__typename: $__typename == _undefined || $__typename == null
|
||||
? _instance.$__typename
|
||||
: ($__typename as String)));
|
||||
}
|
||||
|
||||
class _CopyWithStubImpl$Query$DomainInfo$system$domainInfo$requiredDnsRecords<
|
||||
TRes>
|
||||
implements
|
||||
CopyWith$Query$DomainInfo$system$domainInfo$requiredDnsRecords<TRes> {
|
||||
_CopyWithStubImpl$Query$DomainInfo$system$domainInfo$requiredDnsRecords(
|
||||
this._res);
|
||||
|
||||
TRes _res;
|
||||
|
||||
call(
|
||||
{String? content,
|
||||
String? name,
|
||||
int? priority,
|
||||
String? recordType,
|
||||
int? ttl,
|
||||
String? $__typename}) =>
|
||||
_res;
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Variables$Mutation$ChangeTimezone {
|
||||
Variables$Mutation$ChangeTimezone({required this.timezone});
|
||||
|
|
|
@ -190,8 +190,7 @@ Query$DomainInfo$system$domainInfo _$Query$DomainInfo$system$domainInfoFromJson(
|
|||
unknownValue: Enum$DnsProvider.$unknown),
|
||||
requiredDnsRecords: (json['requiredDnsRecords'] as List<dynamic>)
|
||||
.map((e) =>
|
||||
Query$DomainInfo$system$domainInfo$requiredDnsRecords.fromJson(
|
||||
e as Map<String, dynamic>))
|
||||
Fragment$dnsRecordFields.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
@ -212,30 +211,6 @@ const _$Enum$DnsProviderEnumMap = {
|
|||
Enum$DnsProvider.$unknown: r'$unknown',
|
||||
};
|
||||
|
||||
Query$DomainInfo$system$domainInfo$requiredDnsRecords
|
||||
_$Query$DomainInfo$system$domainInfo$requiredDnsRecordsFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Query$DomainInfo$system$domainInfo$requiredDnsRecords(
|
||||
content: json['content'] as String,
|
||||
name: json['name'] as String,
|
||||
priority: json['priority'] as int?,
|
||||
recordType: json['recordType'] as String,
|
||||
ttl: json['ttl'] as int,
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic>
|
||||
_$Query$DomainInfo$system$domainInfo$requiredDnsRecordsToJson(
|
||||
Query$DomainInfo$system$domainInfo$requiredDnsRecords instance) =>
|
||||
<String, dynamic>{
|
||||
'content': instance.content,
|
||||
'name': instance.name,
|
||||
'priority': instance.priority,
|
||||
'recordType': instance.recordType,
|
||||
'ttl': instance.ttl,
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Variables$Mutation$ChangeTimezone _$Variables$Mutation$ChangeTimezoneFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Variables$Mutation$ChangeTimezone(
|
||||
|
|
|
@ -10,11 +10,7 @@ query AllServices {
|
|||
description
|
||||
displayName
|
||||
dnsRecords {
|
||||
content
|
||||
name
|
||||
priority
|
||||
recordType
|
||||
ttl
|
||||
...dnsRecordFields
|
||||
}
|
||||
id
|
||||
isEnabled
|
||||
|
|
|
@ -312,36 +312,9 @@ const documentNodeQueryAllServices = DocumentNode(definitions: [
|
|||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'content'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'name'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'priority'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'recordType'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'ttl'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FragmentSpreadNode(
|
||||
name: NameNode(value: 'dnsRecordFields'),
|
||||
directives: []),
|
||||
FieldNode(
|
||||
name: NameNode(value: '__typename'),
|
||||
alias: null,
|
||||
|
@ -456,6 +429,7 @@ const documentNodeQueryAllServices = DocumentNode(definitions: [
|
|||
directives: [],
|
||||
selectionSet: null)
|
||||
])),
|
||||
fragmentDefinitiondnsRecordFields,
|
||||
]);
|
||||
Query$AllServices _parserFn$Query$AllServices(Map<String, dynamic> data) =>
|
||||
Query$AllServices.fromJson(data);
|
||||
|
@ -679,7 +653,7 @@ class Query$AllServices$services$allServices {
|
|||
|
||||
final String displayName;
|
||||
|
||||
final List<Query$AllServices$services$allServices$dnsRecords>? dnsRecords;
|
||||
final List<Fragment$dnsRecordFields>? dnsRecords;
|
||||
|
||||
final String id;
|
||||
|
||||
|
@ -807,7 +781,7 @@ abstract class CopyWith$Query$AllServices$services$allServices<TRes> {
|
|||
TRes call(
|
||||
{String? description,
|
||||
String? displayName,
|
||||
List<Query$AllServices$services$allServices$dnsRecords>? dnsRecords,
|
||||
List<Fragment$dnsRecordFields>? dnsRecords,
|
||||
String? id,
|
||||
bool? isEnabled,
|
||||
bool? isMovable,
|
||||
|
@ -818,10 +792,9 @@ abstract class CopyWith$Query$AllServices$services$allServices<TRes> {
|
|||
String? url,
|
||||
String? $__typename});
|
||||
TRes dnsRecords(
|
||||
Iterable<Query$AllServices$services$allServices$dnsRecords>? Function(
|
||||
Iterable<Fragment$dnsRecordFields>? Function(
|
||||
Iterable<
|
||||
CopyWith$Query$AllServices$services$allServices$dnsRecords<
|
||||
Query$AllServices$services$allServices$dnsRecords>>?)
|
||||
CopyWith$Fragment$dnsRecordFields<Fragment$dnsRecordFields>>?)
|
||||
_fn);
|
||||
CopyWith$Query$AllServices$services$allServices$storageUsage<TRes>
|
||||
get storageUsage;
|
||||
|
@ -860,8 +833,7 @@ class _CopyWithImpl$Query$AllServices$services$allServices<TRes>
|
|||
: (displayName as String),
|
||||
dnsRecords: dnsRecords == _undefined
|
||||
? _instance.dnsRecords
|
||||
: (dnsRecords
|
||||
as List<Query$AllServices$services$allServices$dnsRecords>?),
|
||||
: (dnsRecords as List<Fragment$dnsRecordFields>?),
|
||||
id: id == _undefined || id == null ? _instance.id : (id as String),
|
||||
isEnabled: isEnabled == _undefined || isEnabled == null
|
||||
? _instance.isEnabled
|
||||
|
@ -887,15 +859,15 @@ class _CopyWithImpl$Query$AllServices$services$allServices<TRes>
|
|||
? _instance.$__typename
|
||||
: ($__typename as String)));
|
||||
TRes dnsRecords(
|
||||
Iterable<Query$AllServices$services$allServices$dnsRecords>? Function(
|
||||
Iterable<Fragment$dnsRecordFields>? Function(
|
||||
Iterable<
|
||||
CopyWith$Query$AllServices$services$allServices$dnsRecords<
|
||||
Query$AllServices$services$allServices$dnsRecords>>?)
|
||||
CopyWith$Fragment$dnsRecordFields<
|
||||
Fragment$dnsRecordFields>>?)
|
||||
_fn) =>
|
||||
call(
|
||||
dnsRecords: _fn(_instance.dnsRecords?.map((e) =>
|
||||
CopyWith$Query$AllServices$services$allServices$dnsRecords(
|
||||
e, (i) => i)))?.toList());
|
||||
dnsRecords: _fn(_instance.dnsRecords
|
||||
?.map((e) => CopyWith$Fragment$dnsRecordFields(e, (i) => i)))
|
||||
?.toList());
|
||||
CopyWith$Query$AllServices$services$allServices$storageUsage<TRes>
|
||||
get storageUsage {
|
||||
final local$storageUsage = _instance.storageUsage;
|
||||
|
@ -913,7 +885,7 @@ class _CopyWithStubImpl$Query$AllServices$services$allServices<TRes>
|
|||
call(
|
||||
{String? description,
|
||||
String? displayName,
|
||||
List<Query$AllServices$services$allServices$dnsRecords>? dnsRecords,
|
||||
List<Fragment$dnsRecordFields>? dnsRecords,
|
||||
String? id,
|
||||
bool? isEnabled,
|
||||
bool? isMovable,
|
||||
|
@ -931,159 +903,6 @@ class _CopyWithStubImpl$Query$AllServices$services$allServices<TRes>
|
|||
_res);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Query$AllServices$services$allServices$dnsRecords {
|
||||
Query$AllServices$services$allServices$dnsRecords(
|
||||
{required this.content,
|
||||
required this.name,
|
||||
this.priority,
|
||||
required this.recordType,
|
||||
required this.ttl,
|
||||
required this.$__typename});
|
||||
|
||||
@override
|
||||
factory Query$AllServices$services$allServices$dnsRecords.fromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$Query$AllServices$services$allServices$dnsRecordsFromJson(json);
|
||||
|
||||
final String content;
|
||||
|
||||
final String name;
|
||||
|
||||
final int? priority;
|
||||
|
||||
final String recordType;
|
||||
|
||||
final int ttl;
|
||||
|
||||
@JsonKey(name: '__typename')
|
||||
final String $__typename;
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
_$Query$AllServices$services$allServices$dnsRecordsToJson(this);
|
||||
int get hashCode {
|
||||
final l$content = content;
|
||||
final l$name = name;
|
||||
final l$priority = priority;
|
||||
final l$recordType = recordType;
|
||||
final l$ttl = ttl;
|
||||
final l$$__typename = $__typename;
|
||||
return Object.hashAll(
|
||||
[l$content, l$name, l$priority, l$recordType, l$ttl, l$$__typename]);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
if (!(other is Query$AllServices$services$allServices$dnsRecords) ||
|
||||
runtimeType != other.runtimeType) return false;
|
||||
final l$content = content;
|
||||
final lOther$content = other.content;
|
||||
if (l$content != lOther$content) return false;
|
||||
final l$name = name;
|
||||
final lOther$name = other.name;
|
||||
if (l$name != lOther$name) return false;
|
||||
final l$priority = priority;
|
||||
final lOther$priority = other.priority;
|
||||
if (l$priority != lOther$priority) return false;
|
||||
final l$recordType = recordType;
|
||||
final lOther$recordType = other.recordType;
|
||||
if (l$recordType != lOther$recordType) return false;
|
||||
final l$ttl = ttl;
|
||||
final lOther$ttl = other.ttl;
|
||||
if (l$ttl != lOther$ttl) return false;
|
||||
final l$$__typename = $__typename;
|
||||
final lOther$$__typename = other.$__typename;
|
||||
if (l$$__typename != lOther$$__typename) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
extension UtilityExtension$Query$AllServices$services$allServices$dnsRecords
|
||||
on Query$AllServices$services$allServices$dnsRecords {
|
||||
CopyWith$Query$AllServices$services$allServices$dnsRecords<
|
||||
Query$AllServices$services$allServices$dnsRecords>
|
||||
get copyWith =>
|
||||
CopyWith$Query$AllServices$services$allServices$dnsRecords(
|
||||
this, (i) => i);
|
||||
}
|
||||
|
||||
abstract class CopyWith$Query$AllServices$services$allServices$dnsRecords<
|
||||
TRes> {
|
||||
factory CopyWith$Query$AllServices$services$allServices$dnsRecords(
|
||||
Query$AllServices$services$allServices$dnsRecords instance,
|
||||
TRes Function(Query$AllServices$services$allServices$dnsRecords)
|
||||
then) =
|
||||
_CopyWithImpl$Query$AllServices$services$allServices$dnsRecords;
|
||||
|
||||
factory CopyWith$Query$AllServices$services$allServices$dnsRecords.stub(
|
||||
TRes res) =
|
||||
_CopyWithStubImpl$Query$AllServices$services$allServices$dnsRecords;
|
||||
|
||||
TRes call(
|
||||
{String? content,
|
||||
String? name,
|
||||
int? priority,
|
||||
String? recordType,
|
||||
int? ttl,
|
||||
String? $__typename});
|
||||
}
|
||||
|
||||
class _CopyWithImpl$Query$AllServices$services$allServices$dnsRecords<TRes>
|
||||
implements
|
||||
CopyWith$Query$AllServices$services$allServices$dnsRecords<TRes> {
|
||||
_CopyWithImpl$Query$AllServices$services$allServices$dnsRecords(
|
||||
this._instance, this._then);
|
||||
|
||||
final Query$AllServices$services$allServices$dnsRecords _instance;
|
||||
|
||||
final TRes Function(Query$AllServices$services$allServices$dnsRecords) _then;
|
||||
|
||||
static const _undefined = {};
|
||||
|
||||
TRes call(
|
||||
{Object? content = _undefined,
|
||||
Object? name = _undefined,
|
||||
Object? priority = _undefined,
|
||||
Object? recordType = _undefined,
|
||||
Object? ttl = _undefined,
|
||||
Object? $__typename = _undefined}) =>
|
||||
_then(Query$AllServices$services$allServices$dnsRecords(
|
||||
content: content == _undefined || content == null
|
||||
? _instance.content
|
||||
: (content as String),
|
||||
name: name == _undefined || name == null
|
||||
? _instance.name
|
||||
: (name as String),
|
||||
priority:
|
||||
priority == _undefined ? _instance.priority : (priority as int?),
|
||||
recordType: recordType == _undefined || recordType == null
|
||||
? _instance.recordType
|
||||
: (recordType as String),
|
||||
ttl: ttl == _undefined || ttl == null ? _instance.ttl : (ttl as int),
|
||||
$__typename: $__typename == _undefined || $__typename == null
|
||||
? _instance.$__typename
|
||||
: ($__typename as String)));
|
||||
}
|
||||
|
||||
class _CopyWithStubImpl$Query$AllServices$services$allServices$dnsRecords<TRes>
|
||||
implements
|
||||
CopyWith$Query$AllServices$services$allServices$dnsRecords<TRes> {
|
||||
_CopyWithStubImpl$Query$AllServices$services$allServices$dnsRecords(
|
||||
this._res);
|
||||
|
||||
TRes _res;
|
||||
|
||||
call(
|
||||
{String? content,
|
||||
String? name,
|
||||
int? priority,
|
||||
String? recordType,
|
||||
int? ttl,
|
||||
String? $__typename}) =>
|
||||
_res;
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Query$AllServices$services$allServices$storageUsage {
|
||||
Query$AllServices$services$allServices$storageUsage(
|
||||
|
|
|
@ -62,8 +62,7 @@ Query$AllServices$services$allServices
|
|||
displayName: json['displayName'] as String,
|
||||
dnsRecords: (json['dnsRecords'] as List<dynamic>?)
|
||||
?.map((e) =>
|
||||
Query$AllServices$services$allServices$dnsRecords.fromJson(
|
||||
e as Map<String, dynamic>))
|
||||
Fragment$dnsRecordFields.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
id: json['id'] as String,
|
||||
isEnabled: json['isEnabled'] as bool,
|
||||
|
@ -107,29 +106,6 @@ const _$Enum$ServiceStatusEnumEnumMap = {
|
|||
Enum$ServiceStatusEnum.$unknown: r'$unknown',
|
||||
};
|
||||
|
||||
Query$AllServices$services$allServices$dnsRecords
|
||||
_$Query$AllServices$services$allServices$dnsRecordsFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Query$AllServices$services$allServices$dnsRecords(
|
||||
content: json['content'] as String,
|
||||
name: json['name'] as String,
|
||||
priority: json['priority'] as int?,
|
||||
recordType: json['recordType'] as String,
|
||||
ttl: json['ttl'] as int,
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Query$AllServices$services$allServices$dnsRecordsToJson(
|
||||
Query$AllServices$services$allServices$dnsRecords instance) =>
|
||||
<String, dynamic>{
|
||||
'content': instance.content,
|
||||
'name': instance.name,
|
||||
'priority': instance.priority,
|
||||
'recordType': instance.recordType,
|
||||
'ttl': instance.ttl,
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Query$AllServices$services$allServices$storageUsage
|
||||
_$Query$AllServices$services$allServices$storageUsageFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
|
|
|
@ -13,6 +13,7 @@ import 'package:selfprivacy/logic/models/hive/user.dart';
|
|||
import 'package:selfprivacy/logic/models/json/api_token.dart';
|
||||
import 'package:selfprivacy/logic/models/json/backup.dart';
|
||||
import 'package:selfprivacy/logic/models/json/device_token.dart';
|
||||
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
||||
import 'package:selfprivacy/logic/models/json/recovery_token_status.dart';
|
||||
import 'package:selfprivacy/logic/models/json/server_disk_volume.dart';
|
||||
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
||||
|
@ -256,11 +257,8 @@ class ServerApi extends ApiMap
|
|||
return key;
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
'Server now aware of all required DNS records. More general approach has to be implemented',
|
||||
)
|
||||
Future<String?> getDkim() async {
|
||||
String? dkim;
|
||||
Future<List<DnsRecord>> getDnsRecords() async {
|
||||
List<DnsRecord> records = [];
|
||||
QueryResult<Query$DomainInfo> response;
|
||||
|
||||
try {
|
||||
|
@ -269,21 +267,17 @@ class ServerApi extends ApiMap
|
|||
if (response.hasException) {
|
||||
print(response.exception.toString());
|
||||
}
|
||||
dkim = response.parsedData!.system.domainInfo.requiredDnsRecords
|
||||
.firstWhere(
|
||||
(
|
||||
final Query$DomainInfo$system$domainInfo$requiredDnsRecords
|
||||
dnsRecord,
|
||||
) =>
|
||||
dnsRecord.name == 'selector._domainkey' &&
|
||||
dnsRecord.recordType == 'TXT',
|
||||
records = response.parsedData!.system.domainInfo.requiredDnsRecords
|
||||
.map<DnsRecord>(
|
||||
(final Fragment$dnsRecordFields fragment) =>
|
||||
DnsRecord.fromGraphQL(fragment),
|
||||
)
|
||||
.content;
|
||||
.toList();
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
|
||||
return dkim;
|
||||
return records;
|
||||
}
|
||||
|
||||
Future<GenericResult<List<ApiToken>>> getApiTokens() async {
|
||||
|
|
|
@ -242,25 +242,18 @@ class CloudflareApi extends DnsProviderApi {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<void> setDkim(
|
||||
final String dkimRecordString,
|
||||
Future<void> setDnsRecord(
|
||||
final DnsRecord record,
|
||||
final ServerDomain domain,
|
||||
) async {
|
||||
final String domainZoneId = domain.zoneId;
|
||||
final String url = '$rootAddress/zones/$domainZoneId/dns_records';
|
||||
|
||||
final DnsRecord dkimRecord = DnsRecord(
|
||||
type: 'TXT',
|
||||
name: 'selector._domainkey',
|
||||
content: dkimRecordString,
|
||||
ttl: 18000,
|
||||
);
|
||||
|
||||
final Dio client = await getClient();
|
||||
try {
|
||||
await client.post(
|
||||
url,
|
||||
data: dkimRecord.toJson(),
|
||||
data: record.toJson(),
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
|
|
|
@ -19,8 +19,8 @@ abstract class DnsProviderApi extends ApiMap {
|
|||
required final ServerDomain domain,
|
||||
final String? ip4,
|
||||
});
|
||||
Future<void> setDkim(
|
||||
final String dkimRecordString,
|
||||
Future<void> setDnsRecord(
|
||||
final DnsRecord record,
|
||||
final ServerDomain domain,
|
||||
);
|
||||
Future<String?> getZoneId(final String domain);
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
|||
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
||||
|
||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server.dart';
|
||||
import 'package:selfprivacy/utils/network_utils.dart';
|
||||
|
||||
part 'dns_records_state.dart';
|
||||
|
||||
|
@ -30,7 +31,7 @@ class DnsRecordsCubit
|
|||
emit(
|
||||
DnsRecordsState(
|
||||
dnsState: DnsRecordsStatus.refreshing,
|
||||
dnsRecords: _getDesiredDnsRecords(
|
||||
dnsRecords: getDesiredDnsRecords(
|
||||
serverInstallationCubit.state.serverDomain?.domainName,
|
||||
'',
|
||||
'',
|
||||
|
@ -46,9 +47,10 @@ class DnsRecordsCubit
|
|||
final List<DnsRecord> records = await dnsProviderApiFactory!
|
||||
.getDnsProvider()
|
||||
.getDnsRecords(domain: domain);
|
||||
final String? dkimPublicKey = await api.getDkim();
|
||||
final String? dkimPublicKey =
|
||||
extractDkimRecord(await api.getDnsRecords())?.content;
|
||||
final List<DesiredDnsRecord> desiredRecords =
|
||||
_getDesiredDnsRecords(domain.domainName, ipAddress, dkimPublicKey);
|
||||
getDesiredDnsRecords(domain.domainName, ipAddress, dkimPublicKey);
|
||||
final List<DesiredDnsRecord> foundRecords = [];
|
||||
for (final DesiredDnsRecord record in desiredRecords) {
|
||||
if (record.description == 'record.dkim') {
|
||||
|
@ -121,7 +123,6 @@ class DnsRecordsCubit
|
|||
emit(state.copyWith(dnsState: DnsRecordsStatus.refreshing));
|
||||
final ServerDomain? domain = serverInstallationCubit.state.serverDomain;
|
||||
final String? ipAddress = serverInstallationCubit.state.serverDetails?.ip4;
|
||||
final String? dkimPublicKey = await api.getDkim();
|
||||
final DnsProviderApi dnsProviderApi =
|
||||
dnsProviderApiFactory!.getDnsProvider();
|
||||
await dnsProviderApi.removeSimilarRecords(domain: domain!);
|
||||
|
@ -129,88 +130,13 @@ class DnsRecordsCubit
|
|||
domain: domain,
|
||||
ip4: ipAddress,
|
||||
);
|
||||
await dnsProviderApi.setDkim(dkimPublicKey ?? '', domain);
|
||||
|
||||
final List<DnsRecord> records = await api.getDnsRecords();
|
||||
final DnsRecord? dkimRecord = extractDkimRecord(records);
|
||||
if (dkimRecord != null) {
|
||||
await dnsProviderApi.setDnsRecord(dkimRecord, domain);
|
||||
}
|
||||
|
||||
await load();
|
||||
}
|
||||
|
||||
List<DesiredDnsRecord> _getDesiredDnsRecords(
|
||||
final String? domainName,
|
||||
final String? ipAddress,
|
||||
final String? dkimPublicKey,
|
||||
) {
|
||||
if (domainName == null || ipAddress == null) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
DesiredDnsRecord(
|
||||
name: domainName,
|
||||
content: ipAddress,
|
||||
description: 'record.root',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'api.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.api',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'cloud.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.cloud',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'git.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.git',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'meet.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.meet',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'social.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.social',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'password.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.password',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'vpn.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.vpn',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: domainName,
|
||||
content: domainName,
|
||||
description: 'record.mx',
|
||||
type: 'MX',
|
||||
category: DnsRecordsCategory.email,
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: '_dmarc.$domainName',
|
||||
content: 'v=DMARC1; p=none',
|
||||
description: 'record.dmarc',
|
||||
type: 'TXT',
|
||||
category: DnsRecordsCategory.email,
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: domainName,
|
||||
content: 'v=spf1 a mx ip4:$ipAddress -all',
|
||||
description: 'record.spf',
|
||||
type: 'TXT',
|
||||
category: DnsRecordsCategory.email,
|
||||
),
|
||||
if (dkimPublicKey != null)
|
||||
DesiredDnsRecord(
|
||||
name: 'selector._domainkey.$domainName',
|
||||
content: dkimPublicKey,
|
||||
description: 'record.dkim',
|
||||
type: 'TXT',
|
||||
category: DnsRecordsCategory.email,
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,6 @@ enum DnsRecordsStatus {
|
|||
error,
|
||||
}
|
||||
|
||||
enum DnsRecordsCategory {
|
||||
services,
|
||||
email,
|
||||
other,
|
||||
}
|
||||
|
||||
class DnsRecordsState extends ServerInstallationDependendState {
|
||||
const DnsRecordsState({
|
||||
this.dnsState = DnsRecordsStatus.uninitialized,
|
||||
|
@ -37,38 +31,3 @@ class DnsRecordsState extends ServerInstallationDependendState {
|
|||
dnsRecords: dnsRecords ?? this.dnsRecords,
|
||||
);
|
||||
}
|
||||
|
||||
class DesiredDnsRecord {
|
||||
const DesiredDnsRecord({
|
||||
required this.name,
|
||||
required this.content,
|
||||
this.type = 'A',
|
||||
this.description = '',
|
||||
this.category = DnsRecordsCategory.services,
|
||||
this.isSatisfied = false,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final String type;
|
||||
final String content;
|
||||
final String description;
|
||||
final DnsRecordsCategory category;
|
||||
final bool isSatisfied;
|
||||
|
||||
DesiredDnsRecord copyWith({
|
||||
final String? name,
|
||||
final String? type,
|
||||
final String? content,
|
||||
final String? description,
|
||||
final DnsRecordsCategory? category,
|
||||
final bool? isSatisfied,
|
||||
}) =>
|
||||
DesiredDnsRecord(
|
||||
name: name ?? this.name,
|
||||
type: type ?? this.type,
|
||||
content: content ?? this.content,
|
||||
description: description ?? this.description,
|
||||
category: category ?? this.category,
|
||||
isSatisfied: isSatisfied ?? this.isSatisfied,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -21,10 +21,12 @@ import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
|||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||
import 'package:selfprivacy/logic/models/json/device_token.dart';
|
||||
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
||||
import 'package:selfprivacy/logic/models/message.dart';
|
||||
import 'package:selfprivacy/logic/models/server_basic_info.dart';
|
||||
import 'package:selfprivacy/ui/components/action_button/action_button.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
|
||||
import 'package:selfprivacy/utils/network_utils.dart';
|
||||
|
||||
class IpNotFoundException implements Exception {
|
||||
IpNotFoundException(this.message);
|
||||
|
@ -286,7 +288,7 @@ class ServerInstallationRepository {
|
|||
],
|
||||
),
|
||||
);
|
||||
} else if (e.response!.data['error']['code'] == 'resource_unavailable') {
|
||||
} else {
|
||||
final NavigationService nav = getIt.get<NavigationService>();
|
||||
nav.showPopUpDialog(
|
||||
BrandAlert(
|
||||
|
@ -390,15 +392,15 @@ class ServerInstallationRepository {
|
|||
dnsProviderApiFactory!.getDnsProvider();
|
||||
final ServerApi api = ServerApi();
|
||||
|
||||
String dkimRecordString = '';
|
||||
late DnsRecord record;
|
||||
try {
|
||||
dkimRecordString = (await api.getDkim())!;
|
||||
record = extractDkimRecord(await api.getDnsRecords())!;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
}
|
||||
|
||||
await dnsProviderApi.setDkim(dkimRecordString, cloudFlareDomain);
|
||||
await dnsProviderApi.setDnsRecord(record, cloudFlareDomain);
|
||||
}
|
||||
|
||||
Future<bool> isHttpServerWorking() async {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/services.graphql.dart';
|
||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/schema.graphql.dart';
|
||||
|
||||
part 'dns_records.g.dart';
|
||||
|
||||
|
@ -15,7 +15,7 @@ class DnsRecord {
|
|||
});
|
||||
|
||||
DnsRecord.fromGraphQL(
|
||||
final Query$AllServices$services$allServices$dnsRecords record,
|
||||
final Fragment$dnsRecordFields record,
|
||||
) : this(
|
||||
type: record.recordType,
|
||||
name: record.name,
|
||||
|
|
|
@ -23,7 +23,10 @@ class Service {
|
|||
// Decode the base64 encoded svg icon to text.
|
||||
svgIcon: utf8.decode(base64.decode(service.svgIcon)),
|
||||
dnsRecords: service.dnsRecords
|
||||
?.map((final record) => DnsRecord.fromGraphQL(record))
|
||||
?.map(
|
||||
(final Fragment$dnsRecordFields record) =>
|
||||
DnsRecord.fromGraphQL(record),
|
||||
)
|
||||
.toList() ??
|
||||
[],
|
||||
url: service.url,
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
|||
import 'package:selfprivacy/ui/components/brand_cards/filled_card.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
||||
import 'package:selfprivacy/utils/network_utils.dart';
|
||||
|
||||
class DnsDetailsPage extends StatefulWidget {
|
||||
const DnsDetailsPage({super.key});
|
||||
|
|
135
lib/utils/network_utils.dart
Normal file
135
lib/utils/network_utils.dart
Normal file
|
@ -0,0 +1,135 @@
|
|||
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
||||
|
||||
enum DnsRecordsCategory {
|
||||
services,
|
||||
email,
|
||||
other,
|
||||
}
|
||||
|
||||
class DesiredDnsRecord {
|
||||
const DesiredDnsRecord({
|
||||
required this.name,
|
||||
required this.content,
|
||||
this.type = 'A',
|
||||
this.description = '',
|
||||
this.category = DnsRecordsCategory.services,
|
||||
this.isSatisfied = false,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final String type;
|
||||
final String content;
|
||||
final String description;
|
||||
final DnsRecordsCategory category;
|
||||
final bool isSatisfied;
|
||||
|
||||
DesiredDnsRecord copyWith({
|
||||
final String? name,
|
||||
final String? type,
|
||||
final String? content,
|
||||
final String? description,
|
||||
final DnsRecordsCategory? category,
|
||||
final bool? isSatisfied,
|
||||
}) =>
|
||||
DesiredDnsRecord(
|
||||
name: name ?? this.name,
|
||||
type: type ?? this.type,
|
||||
content: content ?? this.content,
|
||||
description: description ?? this.description,
|
||||
category: category ?? this.category,
|
||||
isSatisfied: isSatisfied ?? this.isSatisfied,
|
||||
);
|
||||
}
|
||||
|
||||
List<DesiredDnsRecord> getDesiredDnsRecords(
|
||||
final String? domainName,
|
||||
final String? ipAddress,
|
||||
final String? dkimPublicKey,
|
||||
) {
|
||||
if (domainName == null || ipAddress == null) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
DesiredDnsRecord(
|
||||
name: domainName,
|
||||
content: ipAddress,
|
||||
description: 'record.root',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'api.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.api',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'cloud.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.cloud',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'git.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.git',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'meet.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.meet',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'social.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.social',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'password.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.password',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: 'vpn.$domainName',
|
||||
content: ipAddress,
|
||||
description: 'record.vpn',
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: domainName,
|
||||
content: domainName,
|
||||
description: 'record.mx',
|
||||
type: 'MX',
|
||||
category: DnsRecordsCategory.email,
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: '_dmarc.$domainName',
|
||||
content: 'v=DMARC1; p=none',
|
||||
description: 'record.dmarc',
|
||||
type: 'TXT',
|
||||
category: DnsRecordsCategory.email,
|
||||
),
|
||||
DesiredDnsRecord(
|
||||
name: domainName,
|
||||
content: 'v=spf1 a mx ip4:$ipAddress -all',
|
||||
description: 'record.spf',
|
||||
type: 'TXT',
|
||||
category: DnsRecordsCategory.email,
|
||||
),
|
||||
if (dkimPublicKey != null)
|
||||
DesiredDnsRecord(
|
||||
name: 'selector._domainkey.$domainName',
|
||||
content: dkimPublicKey,
|
||||
description: 'record.dkim',
|
||||
type: 'TXT',
|
||||
category: DnsRecordsCategory.email,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
DnsRecord? extractDkimRecord(final List<DnsRecord> records) {
|
||||
DnsRecord? dkimRecord;
|
||||
|
||||
for (final DnsRecord record in records) {
|
||||
if (record.type == 'TXT' && record.name == 'selector._domainkey') {
|
||||
dkimRecord = record;
|
||||
}
|
||||
}
|
||||
|
||||
return dkimRecord;
|
||||
}
|
Loading…
Reference in a new issue