selfprivacy.org.app/lib/logic/models/hive/server_domain.dart

60 lines
1.3 KiB
Dart
Raw Normal View History

2021-01-06 17:35:57 +00:00
import 'package:hive/hive.dart';
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/schema.graphql.dart';
2021-01-06 17:35:57 +00:00
part 'server_domain.g.dart';
2021-01-06 17:35:57 +00:00
@HiveType(typeId: 3)
class ServerDomain {
ServerDomain({
2021-03-26 13:38:39 +00:00
required this.domainName,
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
// @HiveField(1)
2021-01-06 17:35:57 +00:00
@HiveField(2, defaultValue: DnsProviderType.cloudflare)
final DnsProviderType provider;
2021-01-06 17:35:57 +00:00
}
@HiveType(typeId: 100)
enum DnsProviderType {
@HiveField(0)
2022-05-24 18:55:39 +00:00
unknown,
@HiveField(1)
2022-05-24 18:55:39 +00:00
cloudflare,
@HiveField(2)
2023-05-17 16:58:15 +00:00
desec,
@HiveField(3)
digitalOcean;
factory DnsProviderType.fromGraphQL(final Enum$DnsProvider provider) {
switch (provider) {
case Enum$DnsProvider.CLOUDFLARE:
return cloudflare;
case Enum$DnsProvider.DESEC:
return desec;
case Enum$DnsProvider.DIGITALOCEAN:
return digitalOcean;
default:
return unknown;
}
}
String toInfectName() => switch (this) {
digitalOcean => 'DIGITALOCEAN',
cloudflare => 'CLOUDFLARE',
desec => 'DESEC',
unknown => 'UNKNOWN',
};
String get displayName => switch (this) {
digitalOcean => 'Digital Ocean DNS',
cloudflare => 'Cloudflare',
desec => 'deSEC',
unknown => 'Unknown',
};
}