|
|
il y a 11 ans | |
|---|---|---|
| .. | ||
| go_psi | il y a 11 ans | |
| java_golang | il y a 11 ans | |
| java_psi | il y a 11 ans | |
| libpsi | il y a 11 ans | |
| psi | il y a 11 ans | |
| Dockerfile | il y a 11 ans | |
| README.md | il y a 11 ans | |
| make.bash | il y a 11 ans | |
Psiphon Library for Android enables you to easily embed Psiphon in your Android app. The Psiphon Library for Android is implemented in Go and follows the standard conventions for using a Go library in an Android app.
Follow Go Android documentation:
/AndroidLibrary
README.md - this file
libgojni.so - build binary output
/psi
psi.go - main library source
/go_psi
go_psi.go - gobind output
/java_psi/go/psi
Psi.java - gobind output
/java_golang/go
Go.java - fork of Go/Java integration file
Seq.java - fork of Go/Java integration file
/libpsi
main.go - stub main package for library
Requires Go 1.4 or later.
Install Go from source. The Android instructions are here: https://code.google.com/p/go/source/browse/README?repo=mobile.
$GOPATH/bin/gobind -lang=go github.com/Psiphon-Labs/psiphon-tunnel-core/AndroidLibrary/psi > go_psi/go_psi.go
$GOPATH/bin/gobind -lang=java github.com/Psiphon-Labs/psiphon-tunnel-core/AndroidLibrary/psi > java_psi/go/psi/Psi.java
In /libpsi CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 go build -ldflags="-shared" and copy output file to gojni.so
Create the build image:
# While in the same directory as the Dockerfile...
$ sudo docker build -t psibuild .
# That will take a long time to complete.
# After it's done, you'll have an image called "psibuild". Check with...
$ sudo docker images
To do the build:
$ sudo docker run -v $GOPATH/src:/src psibuild /bin/bash -c 'cd /src/github.com/Psiphon-Labs/psiphon-tunnel-core/AndroidLibrary && ./make.bash'
When that command completes, the compiled library will be located at libs/armeabi-v7a/libgojni.so.
java_golang/go/*.java to your $src/gojava_psi/go/psi/Psi.java to your $src/go/psilibgojni.so to your Android appNOTE: may change to Psiphon-specific library name and init.
See sample usage in Psiphon.java. Uses gobind conventions for data passing.
Go.init(getApplicationContext()); in Application.onCreate()Psi.Listener.Stub to receive messages in Message(String line)Psi.Start(configFile, Psi.Listener) to start Psiphon. Catch Exception to receive errors.Psi.Stop() to stop Psiphon.NOTE: may add more explicit interface for state change events.