2021-01-06 17:35:57 +00:00
|
|
|
import 'package:hive/hive.dart';
|
2023-01-17 14:33:25 +00:00
|
|
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/schema.graphql.dart';
|
2021-01-06 17:35:57 +00:00
|
|
|
|
2022-05-13 13:57:56 +00:00
|
|
|
part 'server_domain.g.dart';
|
|
|
|
|
2021-01-06 17:35:57 +00:00
|
|
|
@HiveType(typeId: 3)
|
2022-05-13 13:57:56 +00:00
|
|
|
class ServerDomain {
|
|
|
|
ServerDomain({
|
2021-03-26 13:38:39 +00:00
|
|
|
required this.domainName,
|
2022-05-13 13:57:56 +00:00
|
|
|
required this.provider,
|
2021-03-26 13:38:39 +00:00
|
|
|
});
|
2021-01-06 17:35:57 +00:00
|
|
|
|
|
|
|
@HiveField(0)
|
2021-03-26 13:38:39 +00:00
|
|
|
final String domainName;
|
2021-01-06 17:35:57 +00:00
|
|
|
|
2023-08-01 02:40:25 +00:00
|
|
|
// @HiveField(1)
|
2021-01-06 17:35:57 +00:00
|
|
|
|
2023-01-30 15:44:52 +00:00
|
|
|
@HiveField(2, defaultValue: DnsProviderType.cloudflare)
|
|
|
|
final DnsProviderType provider;
|
2021-01-06 17:35:57 +00:00
|
|
|
}
|
2022-05-14 02:54:40 +00:00
|
|
|
|
|
|
|
@HiveType(typeId: 100)
|
2023-01-30 15:44:52 +00:00
|
|
|
enum DnsProviderType {
|
2022-05-14 02:54:40 +00:00
|
|
|
@HiveField(0)
|
2022-05-24 18:55:39 +00:00
|
|
|
unknown,
|
2022-05-14 02:54:40 +00:00
|
|
|
@HiveField(1)
|
2022-05-24 18:55:39 +00:00
|
|
|
cloudflare,
|
2022-12-17 10:26:19 +00:00
|
|
|
@HiveField(2)
|
2023-05-17 16:58:15 +00:00
|
|
|
desec,
|
|
|
|
@HiveField(3)
|
2023-01-17 14:33:25 +00:00
|
|
|
digitalOcean;
|
|
|
|
|
2023-01-30 15:44:52 +00:00
|
|
|
factory DnsProviderType.fromGraphQL(final Enum$DnsProvider provider) {
|
2023-01-17 14:33:25 +00:00
|
|
|
switch (provider) {
|
|
|
|
case Enum$DnsProvider.CLOUDFLARE:
|
|
|
|
return cloudflare;
|
2023-05-12 19:32:19 +00:00
|
|
|
case Enum$DnsProvider.DESEC:
|
|
|
|
return desec;
|
2023-01-17 14:33:25 +00:00
|
|
|
case Enum$DnsProvider.DIGITALOCEAN:
|
|
|
|
return digitalOcean;
|
|
|
|
default:
|
|
|
|
return unknown;
|
|
|
|
}
|
|
|
|
}
|
2023-06-26 17:15:53 +00:00
|
|
|
|
|
|
|
String toInfectName() => switch (this) {
|
|
|
|
digitalOcean => 'DIGITALOCEAN',
|
|
|
|
cloudflare => 'CLOUDFLARE',
|
|
|
|
desec => 'DESEC',
|
|
|
|
unknown => 'UNKNOWN',
|
|
|
|
};
|
2023-07-28 23:42:41 +00:00
|
|
|
|
|
|
|
String get displayName => switch (this) {
|
|
|
|
digitalOcean => 'Digital Ocean DNS',
|
|
|
|
cloudflare => 'Cloudflare',
|
|
|
|
desec => 'deSEC',
|
|
|
|
unknown => 'Unknown',
|
|
|
|
};
|
2024-08-22 07:21:36 +00:00
|
|
|
|
|
|
|
String get supportArticle => switch (this) {
|
|
|
|
digitalOcean => 'how_digital_ocean',
|
|
|
|
cloudflare => 'how_cloudflare',
|
|
|
|
desec => 'how_desec',
|
|
|
|
unknown => '',
|
|
|
|
};
|
2022-05-14 02:54:40 +00:00
|
|
|
}
|
2024-06-30 14:50:21 +00:00
|
|
|
|
|
|
|
extension DnsProviderTypeIsSpecified on DnsProviderType? {
|
|
|
|
bool get isSpecified => this != null && this != DnsProviderType.unknown;
|
|
|
|
}
|