Giter VIP home page Giter VIP logo

androidpluggabletransports's Introduction

Android Pluggable Transports

This project is for implementing and providing access to transports compliant with the Pluggable Transports 2.x specification to any Android app that wishes to utilize them. It is built from knowledge and code initially developed through the work on Orbot (Tor for Android) use of Pluggable Transports, VPN features, and inter-application APIs (NetCipher). This project also will utilize the Operator Foundation's Shapeshifter-Transports library in order to provide access to common pluggable transports implemented in Go.

Here is a basic example of how to use the Dispatcher, to retrieve a Transport instance, which then can be used to make a connection to a specific "bridge" endpoint:

    Transport transport = Dispatcher.get().getTransport(this, type, options);
    if (transport != null)
    {
        Connection conn = transport.connect(bridgeAddress);
        //now use the connection, either as a proxy, or to read and write bytes directly
        if (conn.getLocalAddress() != null && conn.getLocalPort() != -1)
            setSocksProxy (conn.getLocalAddress(), conn.getLocalPort());
    }

Each transport will like need specific configuration values in order to connect to the remote bridge or other resources. These values can shared through the bridge address argument, as well as the open-ended key/value options.

Properties options = new Properties();
    String bridgeAddress = "https://meek.actualdomain.com";
    options.put(MeekTransport.OPTION_FRONT,"www.somefrontabledomain.com");
    options.put(MeekTransport.OPTION_KEY,"18800CFE9F483596DDA6264C4D7DF7331E1E39CE");
    init("meek", bridgeAddress, options);

In some cases, the Connection instance returned can be used to setup a general purpose SOCKS proxy. In other cases, you will have to use the read() and write() methods of the Connection instance to transmit data over the transport.

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos.write("GET https://somewebsite.org/TheProject.html HTTP/1.0".getBytes());
    conn.write(baos.toByteArray());

    byte[] buffer = new byte[1024*64];
    int read = conn.read(buffer,0,buffer.length);
    String response = new String(buffer);

The core library is the 'APTDispatchLibrary', but you also need to include a specific library for the transports you wish to bundle and utilize in your app. For instance 'APTDispatchLibrary-MeekObfs4-Full' would include the obfs4proxy library for x86 and arm devices in both 32 and 64-bit. Alternatively, you can just include ''APTDispatchLibrary-MeekObfs4-ARM' for a smaller 'armeabi' only build, reducing the size from 9MB to 2MB.

This project also demonstrates how to implement and register new Transport types, through the 'APTDispatchLibrary-SampleTransport' project. A Pluggable Transport can be implemented entirely in Java, or utilize any other language supported by the Android SDK or NDK. Transport register by making this simple call

{
    Dispatcher.get().register("sample",getClass());
}

This then allows any app using the library to get an instance of the transport like so:

    SampleTransport transport = (SampleTransport)Dispatcher.get().getTransport(this, "sample", options);

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
   		maven { url "https://raw.githubusercontent.com/guardianproject/gpmaven/master" }
	}
}


 
}

Step 2. Add the dependency

dependencies {
        compile 'com.github.guardianproject:AndroidPluggableTransportsDispatcher:-SNAPSHOT'
}

Notices

Obfs4proxy is Copyright (c) 2014, Yawning Angel All rights reserved. https://github.com/Yawning/obfs4/

Thanks

  • Yawning Angel for obfs4proxy.
  • David Fifield for goptlib.
  • Adam Langley for his Elligator implementation.
  • Philipp Winter for the ScrambleSuit protocol which provided much of the design.

androidpluggabletransports's People

Contributors

eighthave avatar jiangyi avatar n8fr8 avatar uniqx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

androidpluggabletransports's Issues

obfs4proxy.go crash on opening socket

When I connect to the obfs4proxy/meek_list instance local socks port to configure it (https://github.com/guardianproject/AndroidPluggableTransports/blob/master/APTDispatchLibrary-MeekObfs4-Full/src/main/java/info/pluggabletransports/dispatch/transports/MeekTransport.java#L113), the crash below happens

05-08 22:33:22.234 20763-0/info.pluggabletransports.sample E/Go: panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x7678ff5034]
goroutine 20 [running]:
gitlab.com/pluggable-transports/goptbundle/obfs4proxy.(*termMonitor).onHandlerStart(...)
/home/hans/go/src/gitlab.com/pluggable-transports/goptbundle/obfs4proxy/termmon.go:51
gitlab.com/pluggable-transports/goptbundle/obfs4proxy.clientHandler(0x767912a4a0, 0x442013e0a0, 0x767912b800, 0x4420140010, 0x0)
/home/hans/go/src/gitlab.com/pluggable-transports/goptbundle/obfs4proxy/obfs4proxy.go:140 +0x54
created by gitlab.com/pluggable-transports/goptbundle/obfs4proxy.clientAcceptLoop
05-08 22:33:22.235 20763-0/info.pluggabletransports.sample E/Go: /home/hans/go/src/gitlab.com/pluggable-transports/goptbundle/obfs4proxy/obfs4proxy.go:134 +0x10c
05-08 22:33:22.235 20763-20839/info.pluggabletransports.sample A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 20839 (AsyncTask #1), pid 20763 (ansports.sample)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.