extremecoders-re / go-dispatch-proxy

SOCKS5/Transparent load balancing proxy developed in Go, combines multiple internet connections
MIT License
278 stars 45 forks source link

Not work on Android that are Linux too. #8

Closed SirSAC closed 2 years ago

SirSAC commented 3 years ago

Hi, im Alex and i have your open source project that i work on it for more options, more stable and complex but in sametime simple and light, the problem is syscall.BindToDevice not work on Android but wikipedia saids is Linux too, thats normal or needs different code for this system? PS: I love your work man, i very appreciate and thanks for open source and MIT license, when i will have some money i will donate to you.

extremecoders-re commented 3 years ago

Is there any specific error message when running on Android?

SirSAC commented 3 years ago

no, just the syscall.BindToDevice return non nil value (err), i have root on my phone with Magisk and i have busybox and extras, i have Android 9 close to stock rom, my phone support aarch64 (ARM v8-A).

SirSAC commented 3 years ago

so, you have any idea how we can try to make compatible with Android?

extremecoders-re commented 3 years ago

Didn't get a chance to work on this yet. How are you compiling for Android? I think GOOS must be set to android rather than linux.

SirSAC commented 3 years ago

yes, i did it as GOOS=android and GOARCH=arm64 because my phone have 64-bit processor (ARM-v8) and is rooted with Magisk but not work on the syscall.BindToDevice as work on computer Linux, on net.DialTCP not work at all on Android, i try with different methods and commands to can be working on Android but at this moment i not have positive results, if i have one i will tell you that. By the way, i found an issue about on how Linux works on firewall thing that make this program to be stuck on only one network and it can be fixed by running this command sudo sysctl --write net.ipv4.conf.all.rp_filter="0", add it below of setcap command. Cya later, have a nice day and good luck with Android things, im waiting you about Android issue if you have any results or doubts.

extremecoders-re commented 3 years ago

Tested go-dispatch-proxy on an Android emulator and it's working fine. It's for x86 though not ARM. Traffic is dispatched across two interfaces.

Command used to compile (Requires Android NDK)

x86

$ CGO_ENABLED=1 CC=~/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android28-clang GOOS=android GOARCH=386 go build

ARM64

$ CGO_ENABLED=1 CC=~/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang GOOS=android GOARCH=arm64 go build

The ARM64 version hasn't been tested. Binaries attached.

go-dispatch-proxy-android-x86.zip go-dispatch-proxy-android-arm64.zip

SirSAC commented 3 years ago

I will test it now and i will tell you if is working or not.

SirSAC commented 3 years ago

Nope, on arm64 or on arm in general not work, the error message is: [WARN] 23.239.16.110:443 -> 10.24.161.221:0 {dial tcp4 10.24.161.221:0->23.239.16.110:443: connect: software caused connection abort} [WARN] 23.239.16.110:443 -> 192.168.1.3:0 {dial tcp4 192.168.1.3:0->23.239.16.110:443: connect: software caused connection abort} and this is repeated for any address.

extremecoders-re commented 3 years ago

Are you running it with root privileges?

SirSAC commented 3 years ago

Yes, with su -c ./go-dispatch-proxy

SirSAC commented 3 years ago

I think is the problem is ARM not code, but im not sure.

SirSAC commented 3 years ago

I have setcap too by termux and not work too with this.

extremecoders-re commented 3 years ago

Can you test if it works on an Android emulator? Here there were no such errors when I tested it on Android Studio emulator.

SirSAC commented 3 years ago

btw, golang have builtin android compiler, so, is not necessary to an external compiler.

SirSAC commented 3 years ago

I tested on my phone that is android 9 (Pie) AOSP and is rooted with Magisk.

SirSAC commented 3 years ago

Can you test if it works on an Android emulator? Here there were no such errors when I tested it on Android Studio emulator.

My PC is low end and i not think so, my CPU is E8200 and 4 GB of RAM of DDR2.

SirSAC commented 3 years ago

You said you not tested for ARM64 but tested the x86 on emulator.

SirSAC commented 3 years ago

Can give me the link of website of iso or img for x86 Android?

extremecoders-re commented 3 years ago

golang have builtin android compiler, so, is not necessary to an external compile

About this. AFAIK Setting GOOS=android does require external compiler. It's mentioned in https://golang.org/misc/android/README

you not tested for ARM64 but tested the x86 on emulator

Yep, Just tested the x86 version

Can give me the link of website of iso or img for x86 Android?

SirSAC commented 3 years ago

Thanks, i compiled the other programs for Android on ARM64 and i not have any problems with builtin compiler.

SirSAC commented 3 years ago

Do not forget to mention this command for some Linux systems that have an conflict with this program. Command that can fix this is sudo sysctl --write net.ipv4.conf.all.rp_filter=0

SirSAC commented 3 years ago

Ubuntu or Debian based systems have this conflict in general.

SirSAC commented 3 years ago

Hello again, did you find an workaround for Android on ARM processors? On the Android with x86 processors i not see any problems.

SirSAC commented 2 years ago

Hello again, i fixed the problem on Android, the real problem was ARM not the system, so ARM thinks different and need to have IP address instead of site or web address. Thanks anticipated for trying to help me.