-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,348 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
sudo: required | ||
language: go | ||
go: | ||
- "1.12" | ||
go_import_path: github.com/2dust/AndroidLibV2rayLite | ||
git: | ||
depth: 5 | ||
addons: | ||
apt: | ||
update: true | ||
before_script: | ||
- sudo ntpdate -u time.google.com | ||
- date | ||
- make all | ||
- make downloadGoMobile | ||
script: | ||
- make BuildMobile | ||
after_success: | ||
deploy: | ||
provider: releases | ||
api_key: ${GH_TOKEN} | ||
file: | ||
- libv2ray.aar | ||
skip_cleanup: true | ||
on: | ||
tags: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package CoreI | ||
|
||
import ( | ||
v2core "v2ray.com/core" | ||
) | ||
|
||
type Status struct { | ||
IsRunning bool | ||
PackageName string | ||
|
||
Vpoint v2core.Server | ||
} | ||
|
||
func CheckVersion() int { | ||
return 20 | ||
} | ||
|
||
func (v *Status) GetDataDir() string { | ||
return v.PackageName | ||
} | ||
|
||
func (v *Status) GetApp(name string) string { | ||
return v.PackageName + name | ||
} | ||
|
||
func (v *Status) GetTun2socksArgs(localDNS bool, enableIPv6 bool) (ret []string) { | ||
ret = []string{"--netif-ipaddr", | ||
"26.26.26.2", | ||
"--netif-netmask", | ||
"255.255.255.252", | ||
"--socks-server-addr", | ||
"127.0.0.1:10808", | ||
"--tunmtu", | ||
"1500", | ||
"--loglevel", | ||
"notice", | ||
"--enable-udprelay", | ||
"--sock-path", | ||
v.GetDataDir() + "sock_path", | ||
} | ||
|
||
if enableIPv6 { | ||
ret = append(ret, "--netif-ip6addr", "da26:2626::2") | ||
} | ||
|
||
if localDNS { | ||
ret = append(ret, "--dnsgw", "127.0.0.1:10807") | ||
} | ||
|
||
return | ||
} | ||
|
||
func (v *Status) GetVPNSetupArg(localDNS bool, enableIPv6 bool) (ret string) { | ||
ret = "m,1500 a,26.26.26.1,30 r,0.0.0.0,0" | ||
|
||
if enableIPv6 { | ||
ret += " a,da26:2626::1,126 r,::,0" | ||
} | ||
if localDNS { | ||
ret += " d,26.26.26.2" | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
pb: | ||
go get -u github.com/golang/protobuf/protoc-gen-go | ||
@echo "pb Start" | ||
asset: | ||
bash gen_assets.sh download | ||
mkdir assets | ||
cp -v data/*.dat assets/ | ||
# cd assets;curl https://raw.githubusercontent.com/2dust/AndroidLibV2rayLite/master/data/geosite.dat > geosite.dat | ||
# cd assets;curl https://raw.githubusercontent.com/2dust/AndroidLibV2rayLite/master/data/geoip.dat > geoip.dat | ||
|
||
shippedBinary: | ||
cd shippedBinarys; $(MAKE) shippedBinary | ||
|
||
fetchDep: | ||
-go get github.com/2dust/AndroidLibV2rayLite | ||
go get github.com/2dust/AndroidLibV2rayLite | ||
|
||
ANDROID_HOME=$(HOME)/android-sdk-linux | ||
export ANDROID_HOME | ||
PATH:=$(PATH):$(GOPATH)/bin | ||
export PATH | ||
downloadGoMobile: | ||
go get golang.org/x/mobile/cmd/... | ||
sudo apt-get install -qq libstdc++6:i386 lib32z1 expect | ||
cd ~ ;curl -L https://raw.githubusercontent.com/2dust/AndroidLibV2rayLite/master/ubuntu-cli-install-android-sdk.sh | sudo bash - > /dev/null | ||
ls ~ | ||
ls ~/android-sdk-linux/ | ||
gomobile init ;gomobile bind -v -tags json github.com/2dust/AndroidLibV2rayLite | ||
|
||
BuildMobile: | ||
@echo Stub | ||
|
||
all: asset pb shippedBinary fetchDep | ||
@echo DONE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package Escort | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"time" | ||
|
||
"log" | ||
|
||
"github.com/2dust/AndroidLibV2rayLite/CoreI" | ||
) | ||
|
||
func (v *Escorting) EscortRun(proc string, pt []string, additionalEnv string, sendFd func() int) { | ||
log.Println(proc, pt) | ||
count := 0 | ||
for count <= 42 { | ||
cmd := exec.Command(proc, pt...) | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
|
||
if len(additionalEnv) > 0 { | ||
//additionalEnv := "FOO=bar" | ||
newEnv := append(os.Environ(), additionalEnv) | ||
cmd.Env = newEnv | ||
} | ||
|
||
if err := cmd.Start(); err != nil { | ||
log.Println("EscortRun cmd.Start err", err) | ||
goto CMDERROR | ||
} | ||
|
||
if v.escortProcess == nil { | ||
log.Println("EscortRun v.escortProcess nil") | ||
break | ||
} | ||
|
||
*v.escortProcess = append(*v.escortProcess, cmd.Process) | ||
log.Println("EscortRun Waiting....") | ||
|
||
if count > 0 { | ||
go func() { | ||
time.Sleep(time.Second) | ||
sendFd() | ||
}() | ||
} | ||
|
||
if err := cmd.Wait(); err != nil { | ||
log.Println("EscortRun cmd.Wait err:", err) | ||
} | ||
|
||
CMDERROR: | ||
if v.Status.IsRunning { | ||
log.Println("EscortRun Unexpected Exit, Restart now.") | ||
count++ | ||
} else { | ||
log.Println("EscortRun Exit") | ||
break | ||
} | ||
} | ||
} | ||
|
||
func (v *Escorting) EscortingUp() { | ||
if v.escortProcess != nil { | ||
return | ||
} | ||
v.escortProcess = new([](*os.Process)) | ||
} | ||
|
||
func (v *Escorting) EscortingDown() { | ||
if v.escortProcess == nil { | ||
return | ||
} | ||
|
||
log.Println("EscortingDown() Killing all escorted process ") | ||
for _, pr := range *v.escortProcess { | ||
pr.Kill() | ||
if _, err := pr.Wait(); err != nil { | ||
log.Println("EscortingDown pr.Wait err:", err) | ||
} | ||
} | ||
v.escortProcess = nil | ||
} | ||
|
||
type Escorting struct { | ||
escortProcess *[](*os.Process) | ||
Status *CoreI.Status | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# AndroidLibV2rayLite |
Oops, something went wrong.