Merge pull request 'reverse-dns' (#27) from reverse-dns into master

Reviewed-on: kherel/selfprivacy.org.app#27
master
kherel 2 years ago
commit e849b551fc
  1. 16
      lib/logic/api_maps/hetzner.dart
  2. 2
      lib/logic/cubit/app_config/app_config_cubit.dart
  3. 7
      lib/logic/cubit/app_config/app_config_repository.dart

@ -192,4 +192,20 @@ class HetznerApi extends ApiMap {
return HetznerServerInfo.fromJson(response.data!['server']);
}
Future<void> createReverseDns({
required String ip4,
required String domainName,
}) async {
var hetznerServer = getIt<ApiConfigModel>().hetznerServer;
var client = await getClient();
await client.post(
'/servers/${hetznerServer!.id}/actions/change_dns_ptr',
data: {
"ip": ip4,
"dns_ptr": domainName,
},
);
close(client);
}
}

@ -316,7 +316,7 @@ class AppConfigCubit extends Cubit<AppConfigState> {
void createServerAndSetDnsRecords() async {
AppConfigState _stateCopy = state;
var onSuccess = (serverDetails) async {
var onSuccess = (HetznerServerDetails serverDetails) async {
await repository.createDnsRecords(
serverDetails.ip4,
state.cloudFlareDomain!,

@ -149,7 +149,7 @@ class AppConfigRepository {
}
Future<void> createDnsRecords(
String? ip4,
String ip4,
CloudFlareDomain cloudFlareDomain,
) async {
var cloudflareApi = CloudflareApi();
@ -163,6 +163,11 @@ class AppConfigRepository {
ip4: ip4,
cloudFlareDomain: cloudFlareDomain,
);
await HetznerApi().createReverseDns(
ip4: ip4,
domainName: cloudFlareDomain.domainName,
);
}
Future<bool> isHttpServerWorking() async {

Loading…
Cancel
Save