mirror of
https://github.com/yggdrasil-network/yggdrasil-android.git
synced 2025-04-28 14:15:08 +03:00
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:
parent
a07412d02d
commit
05de180066
8 changed files with 113 additions and 7 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue