From d4f315214ba96839abfd5728ae9af94146a76ec4 Mon Sep 17 00:00:00 2001 From: Kherel Date: Mon, 17 May 2021 14:38:38 +0200 Subject: [PATCH] add reverse-dns --- lib/logic/api_maps/hetzner.dart | 16 ++++++++++++++++ .../cubit/app_config/app_config_repository.dart | 7 ++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/logic/api_maps/hetzner.dart b/lib/logic/api_maps/hetzner.dart index a2ba9962..cf3de138 100644 --- a/lib/logic/api_maps/hetzner.dart +++ b/lib/logic/api_maps/hetzner.dart @@ -192,4 +192,20 @@ class HetznerApi extends ApiMap { return HetznerServerInfo.fromJson(response.data!['server']); } + + Future createReverseDns({ + required String ip4, + required String cloudFlareDomain, + }) async { + var hetznerServer = getIt().hetznerServer; + var client = await getClient(); + await client.post( + '/servers/${hetznerServer!.id}/actions/change_dns_ptr', + data: { + "ip": ip4, + "dns_ptr": cloudFlareDomain, + }, + ); + close(client); + } } diff --git a/lib/logic/cubit/app_config/app_config_repository.dart b/lib/logic/cubit/app_config/app_config_repository.dart index da9bee28..fe41ac41 100644 --- a/lib/logic/cubit/app_config/app_config_repository.dart +++ b/lib/logic/cubit/app_config/app_config_repository.dart @@ -149,7 +149,7 @@ class AppConfigRepository { } Future 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, + cloudFlareDomain: cloudFlareDomain.domainName, + ); } Future isHttpServerWorking() async {