mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 09:31:13 +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(
|
ProvidersController.initServerProvider(
|
||||||
ServerProviderSettings(
|
ServerProviderSettings(
|
||||||
provider: serverProvider ?? serverDetails!.provider,
|
provider: serverProvider ?? serverDetails!.provider,
|
||||||
|
isAuthorized: providerApiToken != null,
|
||||||
location: location,
|
location: location,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -67,6 +68,7 @@ class ServerInstallationRepository {
|
||||||
serverDomain.provider != DnsProviderType.unknown)) {
|
serverDomain.provider != DnsProviderType.unknown)) {
|
||||||
ProvidersController.initDnsProvider(
|
ProvidersController.initDnsProvider(
|
||||||
DnsProviderSettings(
|
DnsProviderSettings(
|
||||||
|
isAuthorized: dnsApiToken != null,
|
||||||
provider: dnsProvider ?? serverDomain!.provider,
|
provider: dnsProvider ?? serverDomain!.provider,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,11 +16,23 @@ class DnsProviderFactory {
|
||||||
) {
|
) {
|
||||||
switch (settings.provider) {
|
switch (settings.provider) {
|
||||||
case DnsProviderType.cloudflare:
|
case DnsProviderType.cloudflare:
|
||||||
return CloudflareDnsProvider();
|
return settings.isAuthorized
|
||||||
|
? CloudflareDnsProvider.load(
|
||||||
|
settings.isAuthorized,
|
||||||
|
)
|
||||||
|
: CloudflareDnsProvider();
|
||||||
case DnsProviderType.digitalOcean:
|
case DnsProviderType.digitalOcean:
|
||||||
return DigitalOceanDnsProvider();
|
return settings.isAuthorized
|
||||||
|
? DigitalOceanDnsProvider.load(
|
||||||
|
settings.isAuthorized,
|
||||||
|
)
|
||||||
|
: DigitalOceanDnsProvider();
|
||||||
case DnsProviderType.desec:
|
case DnsProviderType.desec:
|
||||||
return DesecDnsProvider();
|
return settings.isAuthorized
|
||||||
|
? DesecDnsProvider.load(
|
||||||
|
settings.isAuthorized,
|
||||||
|
)
|
||||||
|
: DesecDnsProvider();
|
||||||
case DnsProviderType.unknown:
|
case DnsProviderType.unknown:
|
||||||
throw UnknownProviderException('Unknown server provider');
|
throw UnknownProviderException('Unknown server provider');
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,11 @@ import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
class ServerProviderSettings {
|
class ServerProviderSettings {
|
||||||
ServerProviderSettings({
|
ServerProviderSettings({
|
||||||
required this.provider,
|
required this.provider,
|
||||||
|
this.isAuthorized = false,
|
||||||
this.location,
|
this.location,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final bool isAuthorized;
|
||||||
final ServerProviderType provider;
|
final ServerProviderType provider;
|
||||||
final String? location;
|
final String? location;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +16,9 @@ class ServerProviderSettings {
|
||||||
class DnsProviderSettings {
|
class DnsProviderSettings {
|
||||||
DnsProviderSettings({
|
DnsProviderSettings({
|
||||||
required this.provider,
|
required this.provider,
|
||||||
|
this.isAuthorized = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final bool isAuthorized;
|
||||||
final DnsProviderType provider;
|
final DnsProviderType provider;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,11 @@ class ApiAdapter {
|
||||||
class DigitalOceanServerProvider extends ServerProvider {
|
class DigitalOceanServerProvider extends ServerProvider {
|
||||||
DigitalOceanServerProvider() : _adapter = ApiAdapter();
|
DigitalOceanServerProvider() : _adapter = ApiAdapter();
|
||||||
DigitalOceanServerProvider.load(
|
DigitalOceanServerProvider.load(
|
||||||
final ServerType serverType,
|
final String? location,
|
||||||
final bool isAuthotized,
|
final bool isAuthotized,
|
||||||
) : _adapter = ApiAdapter(
|
) : _adapter = ApiAdapter(
|
||||||
isWithToken: isAuthotized,
|
isWithToken: isAuthotized,
|
||||||
region: serverType.location.identifier,
|
region: location,
|
||||||
);
|
);
|
||||||
|
|
||||||
ApiAdapter _adapter;
|
ApiAdapter _adapter;
|
||||||
|
|
|
@ -37,11 +37,11 @@ class ApiAdapter {
|
||||||
class HetznerServerProvider extends ServerProvider {
|
class HetznerServerProvider extends ServerProvider {
|
||||||
HetznerServerProvider() : _adapter = ApiAdapter();
|
HetznerServerProvider() : _adapter = ApiAdapter();
|
||||||
HetznerServerProvider.load(
|
HetznerServerProvider.load(
|
||||||
final ServerType serverType,
|
final String? location,
|
||||||
final bool isAuthotized,
|
final bool isAuthotized,
|
||||||
) : _adapter = ApiAdapter(
|
) : _adapter = ApiAdapter(
|
||||||
isWithToken: isAuthotized,
|
isWithToken: isAuthotized,
|
||||||
region: serverType.location.identifier,
|
region: location,
|
||||||
);
|
);
|
||||||
|
|
||||||
ApiAdapter _adapter;
|
ApiAdapter _adapter;
|
||||||
|
|
|
@ -15,9 +15,19 @@ class ServerProviderFactory {
|
||||||
) {
|
) {
|
||||||
switch (settings.provider) {
|
switch (settings.provider) {
|
||||||
case ServerProviderType.hetzner:
|
case ServerProviderType.hetzner:
|
||||||
return HetznerServerProvider();
|
return settings.isAuthorized
|
||||||
|
? HetznerServerProvider.load(
|
||||||
|
settings.location,
|
||||||
|
settings.isAuthorized,
|
||||||
|
)
|
||||||
|
: HetznerServerProvider();
|
||||||
case ServerProviderType.digitalOcean:
|
case ServerProviderType.digitalOcean:
|
||||||
return DigitalOceanServerProvider();
|
return settings.isAuthorized
|
||||||
|
? DigitalOceanServerProvider.load(
|
||||||
|
settings.location,
|
||||||
|
settings.isAuthorized,
|
||||||
|
)
|
||||||
|
: DigitalOceanServerProvider();
|
||||||
case ServerProviderType.unknown:
|
case ServerProviderType.unknown:
|
||||||
throw UnknownProviderException('Unknown server provider');
|
throw UnknownProviderException('Unknown server provider');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue