diff options
author | cyBerta <cyberta@riseup.net> | 2019-10-06 00:21:49 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2019-10-06 00:21:49 +0200 |
commit | 9341f1e405bba7de0ea57a0588ac54ce653ff32f (patch) | |
tree | 84478edecaceccc25d94f1bac50b8b7b8447d70d /app/src | |
parent | 454e755d71b7c7a3f62bc1f6ab76b860fa4dfb3d (diff) |
write shapeshifter errors into Log fragment
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/pluggableTransports/Shapeshifter.java | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/Shapeshifter.java b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/Shapeshifter.java index 175e236a..f7b18083 100644 --- a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/Shapeshifter.java +++ b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/Shapeshifter.java @@ -17,8 +17,10 @@ package se.leap.bitmaskclient.pluggableTransports; +import android.os.AsyncTask; import android.util.Log; +import de.blinkt.openvpn.core.VpnStatus; import shapeshifter.ShapeShifter; public class Shapeshifter { @@ -28,25 +30,25 @@ public class Shapeshifter { private static final String TAG = Shapeshifter.class.getSimpleName(); ShapeShifter shapeShifter; + ShapeshifterErrorListner shapeshifterErrorListner; public Shapeshifter(Obfs4Options options) { shapeShifter = new ShapeShifter(); - shapeShifter.setIatMode(Long.valueOf(options.iatMode)); shapeShifter.setSocksAddr(DISPATCHER_IP+":"+DISPATCHER_PORT); shapeShifter.setTarget(options.remoteIP+":"+options.remotePort); shapeShifter.setCert(options.cert); - Log.d(TAG, "shapeshifter initialized with: iat - " + shapeShifter.getIatMode() + - "; socksAddr - " + shapeShifter.getSocksAddr() + - "; target addr - " + shapeShifter.getTarget() + - "; cert - " + shapeShifter.getCert()); + Log.d(TAG, "shapeshifter initialized with: \n" + shapeShifter.toString()); } public boolean start() { try { + shapeshifterErrorListner = new ShapeshifterErrorListner(); + shapeshifterErrorListner.execute(shapeShifter); shapeShifter.open(); Log.d(TAG, "shapeshifter opened"); return true; } catch (Exception e) { + VpnStatus.logError("SHAPESHIFTER ERROR " + e.getLocalizedMessage()); e.printStackTrace(); } return false; @@ -59,7 +61,34 @@ public class Shapeshifter { return true; } catch (Exception e) { e.printStackTrace(); + VpnStatus.logError("SHAPESHIFTER ERROR " + e.getLocalizedMessage()); } return false; } + + static class ShapeshifterErrorListner extends AsyncTask<ShapeShifter, Void, Void> { + @Override + protected Void doInBackground(ShapeShifter... shapeShifters) { + ShapeShifter shapeshifter = shapeShifters[0]; + try { + shapeshifter.getLastError(); + } catch (Exception e) { + e.printStackTrace(); + VpnStatus.logError("SHAPESHIFTER ERROR " + e.getLocalizedMessage()); + try { + shapeshifter.close(); + } catch (Exception ex) { + ex.printStackTrace(); + VpnStatus.logError("SHAPESHIFTER ERROR " + e.getLocalizedMessage()); + } + } + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + super.onPostExecute(aVoid); + } + } + } |