add reverse-dns

This commit is contained in:
Kherel 2021-05-17 14:38:38 +02:00
parent 8ccb4f18f6
commit d4f315214b
2 changed files with 22 additions and 1 deletions

View file

@ -192,4 +192,20 @@ class HetznerApi extends ApiMap {
return HetznerServerInfo.fromJson(response.data!['server']);
}
Future<void> createReverseDns({
required String ip4,
required String cloudFlareDomain,
}) 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": cloudFlareDomain,
},
);
close(client);
}
}

View file

@ -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,
cloudFlareDomain: cloudFlareDomain.domainName,
);
}
Future<bool> isHttpServerWorking() async {