-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize TTL and Number of mutating requests to API
- Loading branch information
Showing
7 changed files
with
79 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package io.heapy.ddns.dns_clients | ||
|
||
interface DnsClient { | ||
suspend fun createOrUpdateRecord(ip: String) | ||
suspend fun createOrUpdateRecord(ip: String): String? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.heapy.ddns.ip_provider | ||
|
||
interface IpProvider { | ||
suspend fun getIp(): String | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/io/heapy/ddns/ip_provider/ServerIpProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.heapy.ddns.ip_provider | ||
|
||
import io.ktor.client.* | ||
import io.ktor.client.call.* | ||
import io.ktor.client.request.* | ||
import kotlinx.serialization.Serializable | ||
|
||
class ServerIpProvider( | ||
private val httpClient: HttpClient, | ||
private val serverUrl: String, | ||
) : IpProvider { | ||
@Serializable | ||
data class Response( | ||
val ip: String, | ||
) | ||
|
||
override suspend fun getIp(): String { | ||
return httpClient.post(serverUrl) | ||
.body<Response>() | ||
.ip | ||
} | ||
} |