Giter Site home page Giter Site logo

lantern-mobile's Introduction

UNMAINTAINED Lantern Android

This project is no longer maintained.

Overview

Lantern Android is an App that uses the Android VpnService API to route all device traffic through a packet interception service and subsequently the Lantern circumvention tool.

Building Lantern Android

Before building make sure you've compiled the Lantern proxy for Android:

cd $GOPATH/src/github.com/getlantern/lantern
make android-lib

Building from Android Studio

Prerequisites

Download the most recent copy of the Lantern Android source code using git:

mkdir -p ~/AndroidstudioProjects
cd ~/AndroidstudioProjects
git clone https://github.com/getlantern/lantern-mobile.git

In the welcome screen choose the "Open an existing Android Studio" option and select the lantern folder you just checked out with git.

Building from the Command Line (beta, for development only)

Prerequisites

  • Java Development Kit 1.7
  • Git
  • Android NDK
  • Android SDK Tools (if not using Android Studio)
  • Go (1.6 tip is best as it eliminates text-relocations and provides the best performance)

Replace the paths based on wherever you've installed the Android SDK and NDK

export ANDROID_HOME=/opt/adt-bundle-mac-x86_64-20130917/sdk
export PATH=$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/23.0.2/:$PATH
export NDK_HOME=/opt/android-ndk-r10e
export PATH=$NDK_HOME:$PATH

Using the sdk-manager ($ANDROID_HOME/tools/android), install Android 6.0 API 23 and also the Android SDK Build Tools rev. 23.0.1.

Building tun2socks

Lantern Android uses tun2socks to route intercepted VPN traffic through a local SOCKS server.

make build-tun2socks

Building, installing and running

Build the Debug target:

make build-debug

Install it:

make install

Run the app on the device from the command line:

make run

By default, all three tasks will be run in order with:

make

Note - if you want to test with an emulator, run android and then choose Tools -> Manage AVDs. Create an AVD (e.g. Nexus_4) and then run the emulator from the command line like so:

emulator -avd Nexus_4

The following settings seem to work well enough performance wise:

Device: 3.4" WQVGA 240x432
Target: Android 5.1.1 - API Level 22
CPU/ABI: ARM (armeabi-v7a)
Keyboard: x Hardware keyboard present
Skin: Skin with dynamic hardware controls
Front Camera: None
Back Camera: None
Memory RAM: 2048
VM Heap: 128
Internal Storage: 200
SD Card: 4GiB (probably more than necessary)
Emulation Options: x Use Host GPU

Testing the app

Debugging

With Lantern Android running, to filter Logcat messages:

make logcat

Simulating tun2socks and lantern outside Android

This is very useful when you can to check each moving part separately.

Within Android, the VpnService creates a TUN device and configures the network to route all traffic to this virtual device, an app is listening on this device and has the ability to inspect, modify and reinject packets back to the device. Some special packets can ignore the tun device and pass to the Internet directly (protected packages).

We are going to use a Linux virtual machine to simulate the device <-> tun <-> tun2sock <-> lantern <-> Internet dance, on a normal Linux we don't have the VpnService API but we have the ability to create tun devices and route traffic at will.

The main idea is to create a tun device, run a vanilla tun2socks and route all outgoing traffic to this device, everything but DNS server requests and a special route that goes directly to the virtual machine's host, which will be running a Lantern-SOCKs server.

Let's create and configure this virtual machine:

cd /path/to/lantern-mobile
vagrant up

While you're waiting for the vm to build up go back to the local machine (the vm's host) and compile the socks-server:

cd ~/go/src/github.com/getlantern/lantern
source setenv.bash
go build github.com/getlantern/lantern-mobile/lantern/socks-server

Run the server you've just compiled:

./socks-server
# ...
# DEBUG lantern-android.interceptor: interceptor.go:90 SOCKS proxy now listening on port: 8788
# 2015/09/15 08:47:40 Go and play for 10 minutes.

Run a simple test with cURL and watch the sock-server output.

curl --socks5 127.0.0.1:8788 https://www.google.com/humans.txt
# Google is built by a large team of engineers, designers, researchers, robots, and others in many different sites across the globe. It is updated continuously, and built with more tools and technologies than we can shake a stick at. If you'd like to help us out, see google.com/careers.

The SOCKs server will run for 10 minutes and then it will exit, you can also stop it anytime with ^C.

You can also cross-compile the tests we're going to run within the vm:

cd ~/go/src/github.com/getlantern/lantern
make mobile-test-linux-amd64
# ...
# ok      github.com/getlantern/lantern-mobile/lantern    0.082s

Once the build has finished log in into the new box:

vagrant ssh

And run the script that is going to setup

chmod +x /vagrant/vagrant-tun-up.sh
/vagrant/vagrant-tun-up.sh

The script will ask you for a HOST_IP, this is the IP of the host machine which in my case is 10.0.0.101:

HOST_IP=10.0.0.101 /vagrant/vagrant-tun-up.sh
# NOTICE(tun2socks): initializing BadVPN tun2socks 1.999.130
# NOTICE(tun2socks): entering event loop

Go back to your host and restart the socks-server.

./socks-server
# ^C
./socks-server
# ...

Open another terminal without stopping the tun2socks process and we'll be ready to test everything.

vagrant ssh
curl https://www.google.com/humans.txt
# Google is built by a large team of engineers, designers, researchers, robots, and others in many different sites across the globe. It is updated continuously, and built with more tools and technologies than we can shake a stick at. If you'd like to help us out, see google.com/careers.

Make sure the request is catched by tun2socks and by the socks-server by watching each program's output.

Finally, run the transparent test, which will basically do the same as a normal cURL through tun2socks and the socks-server:

/vagrant/lantern/lantern_mobile_test -test.v -test.run TestTransparentRequestPassingThroughTun0
# ...
# --- PASS: TestTransparentRequestPassingThroughTun0 (1.36s)
# PASS

lantern-mobile's People

Contributors

oxtoacart 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lantern-mobile's Issues

Update start/stop button when app is sent to the background

After we start the app/turn full-device VPN mode on, if we send the app to the background and open it again, the start/stop button needs to reflect this. We also need a way of querying the VpnService to see if Lantern is already running.

Custom share screen

I finally figured out how to limit/filter the apps we present in the share intent:

image

We can also use custom messages for each

Crash Android 5.1.1

application will close without any message or error after i open application and then click on start button
here is logcat
as it's a custom rom so I'm not sure if this problem is just because of my rom but i can confirm other vpn apps like openvpn, shadowsocks and psyphon, etc works well

Doesn't run in background

I'm using Sony Xperia Z3 compact with Android 5.1.1. When I turn on Lantern, it works, but as soon as I swipe it away from my open apps list, Lantern closes and doesn't proxy my traffic anymore.

Is this normal behavior? I find that a few apps seem to misbehave in this way with my phone, perhaps Sony's particular build of Android handles app closing differently? Or is this a bug with Lantern?

Packet interception and forwarding

As traffic arrives on the VPN connection, we open corresponding input and output streams on the actual interface for sending and receiving packets. The packets are handed off to a tunnel we open with Lantern via the shared library using the processPacket interface method; any incoming packets from Lantern are returned to the end user via readPacket:

https://github.com/getlantern/lantern-mobile/blob/initial-release/app/src/main/java/org/getlantern/lantern/model/Lantern.java

startRun in https://github.com/getlantern/lantern-mobile/blob/initial-release/app/src/main/java/org/getlantern/lantern/service/LanternVpn.java

Lantern turns Off even when the UI shows as ON

Steps:

  1. Switch ON Lantern
  2. Use back button to go to home screen
  3. Immediately go back to Lantern and it shows ON but the message shows that Lantern is switched OFF. But if I wait in the home screen for a few seconds then Lantern is really switching OFF. Not a big issue but a possible scenario where the user could get confused.

Lantern is switching off irrespective of its state ON/OFF whenever I use the back button within the Lantern app to come out of it.

Fork tun2socks and add to build process

This is a tool from BadVPN that's used in several apps to implement a VpnService which intercepts all TCP connections and routes them via a local SOCKS proxy. We're using a pre-built version but should create our own fork with custom JNI methods. This will be easier to maintain/customize.

Unable to watch videos in Netflix

This is related to this app alone. I am able to watch youtube without any problem.

Also this happens only when I block by changing DNS and try to run it with Lantern. If I don't block and let lantern run, I am able to watch videos. In this case, Lantern switches off automatically after some 15-20 mins.

Use config package from Lantern proper

We're using a custom config implementation because of previous difficulties writing the config to disk on Android. This is becoming harder to maintain, and it would be vastly preferable to consolidate both approaches.

I want to develop the iOS version

Hi, I'm very eager to help develop the mobile version.
I want to develop the iOS app, could you please tell me how to combine Lantern?
Cause I'm poor in Network knowledge, but I'm ready to learn.

Cleaner mechanism for stopping Lantern

Rather than abruptly exit the Lantern backend when the stop button is pressed, which incidentally triggers a runtime exception in the Android app (though we could catch this possibly, assuming nothing else was affected), we should add a native method that initiates a graceful shutdown that closes all goroutines and performs any necessary clean-up

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.