Implemented an option to reset keys (and IP). (#40)

* Implemented an option to reset keys (and IP).
* Implemented an option to set own keys (and IP).
* Incremented app version.
This commit is contained in:
Revertron 2022-12-14 12:37:45 +01:00 committed by GitHub
parent a07412d02d
commit 05de180066
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 113 additions and 7 deletions

View file

@ -1,7 +1,6 @@
package eu.neilalexander.yggdrasil
import android.content.Context
import android.provider.Settings
import mobile.Mobile
import org.json.JSONArray
import org.json.JSONObject
@ -29,6 +28,21 @@ object ConfigurationProxy {
fix()
}
fun resetKeys() {
val newJson = JSONObject(String(Mobile.generateConfigJSON()))
updateJSON { json ->
json.put("PrivateKey", newJson.getString("PrivateKey"))
json.put("PublicKey", newJson.getString("PublicKey"))
}
}
fun setKeys(privateKey: String, publicKey: String) {
updateJSON { json ->
json.put("PrivateKey", privateKey)
json.put("PublicKey", publicKey)
}
}
fun updateJSON(fn: (JSONObject) -> Unit) {
json = JSONObject(file.readText(Charsets.UTF_8))
fn(json)