aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-09-05 20:17:14 -0500
committerJason A. Donenfeld <Jason@zx2c4.com>2018-12-08 02:39:41 +0100
commitd1e85633fbe8d871355d2b9feb51e2c9983d8a21 (patch)
treed95ad1ae84d02fc3e18a211aa1e1ef8150d8fa35 /app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
parentAuto-format the source directories (diff)
downloadwireguard-android-d1e85633fbe8d871355d2b9feb51e2c9983d8a21.tar.xz
wireguard-android-d1e85633fbe8d871355d2b9feb51e2c9983d8a21.zip
Remodel the Model
- The configuration and crypto model is now entirely independent of Android classes other than Nullable and TextUtils. - Model classes are immutable and use builders that enforce the appropriate optional/required attributes. - The Android config proxies (for Parcelable and databinding) are moved to the Android side of the codebase, and are designed to be safe for two-way databinding. This allows proper observability in TunnelDetailFragment. - Various robustness fixes and documentation updates to helper classes. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java')
-rw-r--r--app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java b/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
index 0e66dab8..654cb48f 100644
--- a/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
+++ b/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
@@ -9,6 +9,7 @@ import android.content.Context;
import android.util.Log;
import com.wireguard.config.Config;
+import com.wireguard.config.ParseException;
import java.io.File;
import java.io.FileInputStream;
@@ -41,7 +42,7 @@ public final class FileConfigStore implements ConfigStore {
if (!file.createNewFile())
throw new IOException("Configuration file " + file.getName() + " already exists");
try (final FileOutputStream stream = new FileOutputStream(file, false)) {
- stream.write(config.toString().getBytes(StandardCharsets.UTF_8));
+ stream.write(config.toWgQuickString().getBytes(StandardCharsets.UTF_8));
}
return config;
}
@@ -67,9 +68,9 @@ public final class FileConfigStore implements ConfigStore {
}
@Override
- public Config load(final String name) throws IOException {
+ public Config load(final String name) throws IOException, ParseException {
try (final FileInputStream stream = new FileInputStream(fileFor(name))) {
- return Config.from(stream);
+ return Config.parse(stream);
}
}
@@ -94,7 +95,7 @@ public final class FileConfigStore implements ConfigStore {
if (!file.isFile())
throw new FileNotFoundException("Configuration file " + file.getName() + " not found");
try (final FileOutputStream stream = new FileOutputStream(file, false)) {
- stream.write(config.toString().getBytes(StandardCharsets.UTF_8));
+ stream.write(config.toWgQuickString().getBytes(StandardCharsets.UTF_8));
}
return config;
}