mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 00:51:20 +00:00
chore: Merge pull request 'feat(provider): Implement proper load functions for DNS and Server providers' (#237) from server-providers-fix into master
Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy.org.app/pulls/237 Reviewed-by: Inex Code <inex.code@selfprivacy.org>
This commit is contained in:
commit
6453257aa3
|
@ -57,6 +57,7 @@ class ServerInstallationRepository {
|
|||
ProvidersController.initServerProvider(
|
||||
ServerProviderSettings(
|
||||
provider: serverProvider ?? serverDetails!.provider,
|
||||
isAuthorized: providerApiToken != null,
|
||||
location: location,
|
||||
),
|
||||
);
|
||||
|
@ -67,6 +68,7 @@ class ServerInstallationRepository {
|
|||
serverDomain.provider != DnsProviderType.unknown)) {
|
||||
ProvidersController.initDnsProvider(
|
||||
DnsProviderSettings(
|
||||
isAuthorized: dnsApiToken != null,
|
||||
provider: dnsProvider ?? serverDomain!.provider,
|
||||
),
|
||||
);
|
||||
|
|
|
@ -16,11 +16,23 @@ class DnsProviderFactory {
|
|||
) {
|
||||
switch (settings.provider) {
|
||||
case DnsProviderType.cloudflare:
|
||||
return CloudflareDnsProvider();
|
||||
return settings.isAuthorized
|
||||
? CloudflareDnsProvider.load(
|
||||
settings.isAuthorized,
|
||||
)
|
||||
: CloudflareDnsProvider();
|
||||
case DnsProviderType.digitalOcean:
|
||||
return DigitalOceanDnsProvider();
|
||||
return settings.isAuthorized
|
||||
? DigitalOceanDnsProvider.load(
|
||||
settings.isAuthorized,
|
||||
)
|
||||
: DigitalOceanDnsProvider();
|
||||
case DnsProviderType.desec:
|
||||
return DesecDnsProvider();
|
||||
return settings.isAuthorized
|
||||
? DesecDnsProvider.load(
|
||||
settings.isAuthorized,
|
||||
)
|
||||
: DesecDnsProvider();
|
||||
case DnsProviderType.unknown:
|
||||
throw UnknownProviderException('Unknown server provider');
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@ import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
|||
class ServerProviderSettings {
|
||||
ServerProviderSettings({
|
||||
required this.provider,
|
||||
this.isAuthorized = false,
|
||||
this.location,
|
||||
});
|
||||
|
||||
final bool isAuthorized;
|
||||
final ServerProviderType provider;
|
||||
final String? location;
|
||||
}
|
||||
|
@ -14,7 +16,9 @@ class ServerProviderSettings {
|
|||
class DnsProviderSettings {
|
||||
DnsProviderSettings({
|
||||
required this.provider,
|
||||
this.isAuthorized = false,
|
||||
});
|
||||
|
||||
final bool isAuthorized;
|
||||
final DnsProviderType provider;
|
||||
}
|
||||
|
|
|
@ -37,11 +37,11 @@ class ApiAdapter {
|
|||
class DigitalOceanServerProvider extends ServerProvider {
|
||||
DigitalOceanServerProvider() : _adapter = ApiAdapter();
|
||||
DigitalOceanServerProvider.load(
|
||||
final ServerType serverType,
|
||||
final String? location,
|
||||
final bool isAuthotized,
|
||||
) : _adapter = ApiAdapter(
|
||||
isWithToken: isAuthotized,
|
||||
region: serverType.location.identifier,
|
||||
region: location,
|
||||
);
|
||||
|
||||
ApiAdapter _adapter;
|
||||
|
|
|
@ -37,11 +37,11 @@ class ApiAdapter {
|
|||
class HetznerServerProvider extends ServerProvider {
|
||||
HetznerServerProvider() : _adapter = ApiAdapter();
|
||||
HetznerServerProvider.load(
|
||||
final ServerType serverType,
|
||||
final String? location,
|
||||
final bool isAuthotized,
|
||||
) : _adapter = ApiAdapter(
|
||||
isWithToken: isAuthotized,
|
||||
region: serverType.location.identifier,
|
||||
region: location,
|
||||
);
|
||||
|
||||
ApiAdapter _adapter;
|
||||
|
|
|
@ -15,9 +15,19 @@ class ServerProviderFactory {
|
|||
) {
|
||||
switch (settings.provider) {
|
||||
case ServerProviderType.hetzner:
|
||||
return HetznerServerProvider();
|
||||
return settings.isAuthorized
|
||||
? HetznerServerProvider.load(
|
||||
settings.location,
|
||||
settings.isAuthorized,
|
||||
)
|
||||
: HetznerServerProvider();
|
||||
case ServerProviderType.digitalOcean:
|
||||
return DigitalOceanServerProvider();
|
||||
return settings.isAuthorized
|
||||
? DigitalOceanServerProvider.load(
|
||||
settings.location,
|
||||
settings.isAuthorized,
|
||||
)
|
||||
: DigitalOceanServerProvider();
|
||||
case ServerProviderType.unknown:
|
||||
throw UnknownProviderException('Unknown server provider');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue