aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/src/main/java/com/wireguard/android/backend
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-04-17 05:59:23 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-04-17 05:59:23 +0200
commit140fb395dcb23a9d2fef24789796f5d985569a06 (patch)
treecaf8d4f406dac00949d368a9272fe4ba71ef5c47 /app/src/main/java/com/wireguard/android/backend
parentRemove sloppy java with enterprise java horrors (diff)
downloadwireguard-android-140fb395dcb23a9d2fef24789796f5d985569a06.tar.xz
wireguard-android-140fb395dcb23a9d2fef24789796f5d985569a06.zip
GoBackend: default MTU is 1280
This sucks, but it works with mobile networks. Later we can do something sophisticated like we do with wg-quick.c, but not now. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/android/backend')
-rw-r--r--app/src/main/java/com/wireguard/android/backend/GoBackend.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/src/main/java/com/wireguard/android/backend/GoBackend.java b/app/src/main/java/com/wireguard/android/backend/GoBackend.java
index 7b397f05..28ce7a5e 100644
--- a/app/src/main/java/com/wireguard/android/backend/GoBackend.java
+++ b/app/src/main/java/com/wireguard/android/backend/GoBackend.java
@@ -72,7 +72,7 @@ public final class GoBackend implements Backend {
private static native void wgTurnOff(int handle);
- private static native int wgTurnOn(String ifName, int tunFd, String settings);
+ private static native int wgTurnOn(String ifName, int tunFd, int mtu, String settings);
@Override
public Config applyConfig(final Tunnel tunnel, final Config config) throws Exception {
@@ -244,12 +244,21 @@ public final class GoBackend implements Backend {
}
}
+ int mtu = -1;
+ try {
+ mtu = Integer.parseInt(config.getInterface().getMtu(), 10);
+ } catch (Exception e) {
+ }
+ if (mtu < 0)
+ mtu = 1280;
+ builder.setMtu(mtu);
+
builder.setBlocking(true);
ParcelFileDescriptor tun = builder.establish();
if (tun == null)
throw new Exception("Unable to create tun device");
- currentTunnelHandle = wgTurnOn(tunnel.getName(), tun.detachFd(), fmt.toString());
+ currentTunnelHandle = wgTurnOn(tunnel.getName(), tun.detachFd(), mtu, fmt.toString());
if (currentTunnelHandle < 0)
throw new Exception("Unable to turn tunnel on (wgTurnOn return " + currentTunnelHandle + ")");