saeeddev94 / xray Goto Github PK
View Code? Open in Web Editor NEWXray GUI Client For Android
License: MIT License
Xray GUI Client For Android
License: MIT License
i found that if config of xray includes (ws) or (grpc) or even (tcp) network, it not works.
for example, if you put this config in app, it not works.
{ "dns": { "hosts": { "domain:googleapis.cn": "googleapis.com" }, "servers": [ "1.1.1.1" ] }, "inbounds": [ { "listen": "127.0.0.1", "port": 10808, "protocol": "socks", "settings": { "auth": "noauth", "udp": true, "userLevel": 8 }, "sniffing": { "destOverride": [ "http", "tls" ], "enabled": true }, "tag": "socks" }, { "listen": "127.0.0.1", "port": 10809, "protocol": "http", "settings": { "userLevel": 8 }, "tag": "http" } ], "log": { "loglevel": "warning" }, "outbounds": [ { "mux": { "concurrency": 8, "enabled": false }, "protocol": "vless", "settings": { "vnext": [ { "address": "turkey.legendaryam.xyz", "port": 2053, "users": [ { "encryption": "none", "flow": "", "id": "aa7e9f71-c222-47f3-86e4-9ac30435ffed", "level": 8, "security": "auto" } ] } ] }, "streamSettings": { "grpcSettings": { "multiMode": false, "serviceName": "xyz" }, "network": "grpc", "realitySettings": { "allowInsecure": false, "fingerprint": "chrome", "publicKey": "WqqDJ7TsdoGf7RAzbtKd485RmUqSw-hebRWMFvKqlQ0", "serverName": "creativecommons.org", "shortId": "", "show": false, "spiderX": "" }, "security": "reality" }, "tag": "proxy" }, { "protocol": "freedom", "settings": {}, "tag": "direct" }, { "protocol": "blackhole", "settings": { "response": { "type": "http" } }, "tag": "block" } ], "routing": { "domainStrategy": "IPIfNonMatch", "rules": [ { "ip": [ "1.1.1.1" ], "outboundTag": "proxy", "port": "53", "type": "field" } ] } }
also some times in some configs, app sends fake speed like below;
the tested configs;
{ "dns": { "hosts": { "domain:googleapis.cn": "googleapis.com" }, "servers": [ "1.1.1.1" ] }, "inbounds": [ { "listen": "127.0.0.1", "port": 10808, "protocol": "socks", "settings": { "auth": "noauth", "udp": true, "userLevel": 8 }, "sniffing": { "destOverride": [ "http", "tls" ], "enabled": true }, "tag": "socks" }, { "listen": "127.0.0.1", "port": 10809, "protocol": "http", "settings": { "userLevel": 8 }, "tag": "http" } ], "log": { "loglevel": "warning" }, "outbounds": [ { "mux": { "concurrency": 8, "enabled": false }, "protocol": "vless", "settings": { "vnext": [ { "address": "6544.outline-vpn.cloud", "port": 2096, "users": [ { "encryption": "none", "flow": "", "id": "e3c633c7-37de-4a73-9064-240b645777bc", "level": 8, "security": "auto" } ] } ] }, "streamSettings": { "network": "ws", "security": "tls", "tlsSettings": { "allowInsecure": false, "fingerprint": "", "publicKey": "", "serverName": "sgp.vps.wengmail.link", "shortId": "", "show": false, "spiderX": "" }, "wsSettings": { "headers": { "Host": "sgp.vps.wengmail.link" }, "path": "/?ed=2048" } }, "tag": "proxy" }, { "protocol": "freedom", "settings": {}, "tag": "direct" }, { "protocol": "blackhole", "settings": { "response": { "type": "http" } }, "tag": "block" } ], "routing": { "domainStrategy": "IPIfNonMatch", "rules": [ { "ip": [ "1.1.1.1" ], "outboundTag": "proxy", "port": "53", "type": "field" } ] } }
is there any problem in the x-ray configs or apps?
Hello, the application crashes when I call System.loadLibrary("hev-socks5-tunnel")
. What is the reason?
adb error report
01-09 16:07:22.431 14701 14762 F com.phone: runtime.cc:677] at void java.lang.Thread.run() (Thread.java:920)
01-09 16:07:22.431 14701 14762 F com.phone: runtime.cc:677]
01-09 16:07:22.431 14701 14762 F com.phone: runtime.cc:677] in call to RegisterNatives
01-09 16:07:22.431 14701 14762 F com.phone: runtime.cc:677] from java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.Class)
01-09 16:07:22.431 14701 14762 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 14762 (create_react_co), pid 14701 (com.phone)
01-09 16:07:22.711 14773 14773 F DEBUG : Cmdline: com.phone
01-09 16:07:22.711 14773 14773 F DEBUG : pid: 14701, tid: 14762, name: create_react_co >>> com.phone <<<
01-09 16:07:22.711 14773 14773 F DEBUG : Abort message: 'JNI DETECTED ERROR IN APPLICATION: JNI RegisterNatives called with pending exception java.lang.ClassNotFoundException: Didn't find class "hev.htproxy.TProxyService" on path: DexPathList[[zip file "/data/app/~~pxR0Ca3fwbolY8veI4o4Og==/com.phone-L2ydzuScfNRlMDuz2zlAfg==/base.apk"],nativeLibraryDirectories=[/data/app/~~pxR0Ca3fwbolY8veI4o4Og==/com.phone-L2ydzuScfNRlMDuz2zlAfg==/lib/arm64, /data/app/~~pxR0Ca3fwbolY8veI4o4Og==/com.phone-L2ydzuScfNRlMDuz2zlAfg==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
01-09 16:07:22.711 14773 14773 F DEBUG : at void com.phone.TProxyService.<clinit>() (Tun2socks.kt:23)
01-09 16:07:22.711 14773 14773 F DEBUG : at void com.phone.VPN.<init>(com.facebook.react.bridge.ReactApplicationContext) (Tun2socks.kt:110)
01-09 16:07:22.711 14773 14773 F DEBUG : at java.util.List com.phone.VPNPackage.createNativeModules(com.facebook.react.bridge.ReactApplicationContext) (Tun2socks.kt:133)
01-09 16:07:22.711 14773 14773 F DEBUG : #10 pc 000000000001db84 /data/app/~~pxR0Ca3fwbolY8veI4o4Og==/com.phone-L2ydzuScfNRlMDuz2zlAfg==/lib/arm64/libhev-socks5-tunnel.so (JNI_OnLoad+144) (BuildId: 348c998273a889308eb4fea70c2d0e66e5461151)
01-09 16:07:22.711 14773 14773 F DEBUG : #34 pc 0000000000001e86 [anon:dalvik-classes4.dex extracted in memory from /data/app/~~pxR0Ca3fwbolY8veI4o4Og==/com.phone-L2ydzuScfNRlMDuz2zlAfg==/base.apk!classes4.dex]
01-09 16:07:22.711 14773 14773 F DEBUG : #41 pc 0000000000002444 [anon:dalvik-classes4.dex extracted in memory from /data/app/~~pxR0Ca3fwbolY8veI4o4Og==/com.phone-L2ydzuScfNRlMDuz2zlAfg==/base.apk!classes4.dex]
01-09 16:07:22.711 14773 14773 F DEBUG : #47 pc 00000000000023be [anon:dalvik-classes4.dex extracted in memory from /data/app/~~pxR0Ca3fwbolY8veI4o4Og==/com.phone-L2ydzuScfNRlMDuz2zlAfg==/base.apk!classes4.dex]
my code
package com.phone
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.uimanager.ViewManager
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.Promise
import android.content.Intent
import android.net.VpnService
import android.os.Binder
import android.os.IBinder
import android.os.ParcelFileDescriptor
import java.util.ArrayList
class TProxyService : VpnService() {
companion object {
init {
System.loadLibrary("hev-socks5-tunnel")
}
}
private external fun TProxyStartService(configPath: String, fd: Int)
private external fun TProxyStopService()
inner class ServiceBinder : Binder() {
fun getService(): TProxyService = this@TProxyService
}
private val binder: ServiceBinder = ServiceBinder()
private var isRunning: Boolean = false
private var tunDevice: ParcelFileDescriptor? = null
override fun onBind(intent: Intent?): IBinder = binder
override fun onDestroy() {
stopVPN()
super.onDestroy()
}
fun getIsRunning(): Boolean = isRunning
fun startVPN() {
isRunning = true
// 创建 Tun 设备
val tun = Builder()
// 基本 Tun 配置
tun.setMetered(false)
tun.setMtu(Settings.tunMtu)
tun.setSession(Settings.tunName)
tun.addAddress(Settings.tunAddress, Settings.tunPrefix)
tun.addDnsServer(Settings.primaryDns)
tun.addDnsServer(Settings.secondaryDns)
// 通过 Tun 设备转发所有流量(除私有 IP 地址)
resources.getStringArray(R.array.publicIpAddresses).forEach {
val address = it.split('/')
tun.addRoute(address[0], address[1].toInt())
}
// 排除特定应用
tun.addDisallowedApplication(applicationContext.packageName)
Settings.excludedApps.split("\n").forEach { packageName ->
if (packageName.trim().isNotEmpty()) tun.addDisallowedApplication(packageName)
}
// 构建 Tun 设备
tunDevice = tun.establish()
// 创建并更新 tun2socks 配置
val tun2socksConfig = arrayOf(
"tunnel:",
" name: ${Settings.tunName}",
" mtu: ${Settings.tunMtu}",
" ipv4:",
" gateway: ${Settings.tunGateway}",
" address: ${Settings.tunAddress}",
" prefix: ${Settings.tunPrefix}",
"socks5:",
" address: ${Settings.socksAddress}",
" port: ${Settings.socksPort}",
if (Settings.socksUdp) " udp: udp" else " udp: tcp",
""
)
Settings.tun2socksConfig(applicationContext).writeText(tun2socksConfig.joinToString("\n"))
// 启动 tun2socks
TProxyStartService(Settings.tun2socksConfig(applicationContext).absolutePath, tunDevice!!.fd)
}
fun stopVPN() {
isRunning = false
if (tunDevice != null) {
TProxyStopService()
tunDevice!!.close()
tunDevice = null
}
stopSelf()
}
}
class VPN(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
private var tProxyService = TProxyService();
override fun getName(): String {
return "VPN"
}
@ReactMethod
fun start(promise: Promise) {
tProxyService.startVPN()
promise.resolve("Server Started")
}
@ReactMethod
fun stop(promise: Promise) {
tProxyService.stopVPN()
promise.resolve("Server Stopped")
}
}
class VPNPackage : ReactPackage {
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
return listOf(VPN(reactContext))
}
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
return emptyList()
}
}
My project structure
android/app/src/main/java/com/phone/Tun2socks.kt
android/app/src/main/jniLibs/arm64-v8a/libhev-socks5-tunnel.so
thanks for your great work.
how we can monitor used traffic? i already opened an issues about it HERE.
please add more feature like xray api statsquery to this project so we can learn and use it.
As title. Now there are just numbers, so I can't figure out which one is x86_64 or armv8 to download.
For better transmission performance, I recommended setting the default MTU value to 8500.
tun.addDisallowedApplication(applicationContext.packageName) Sorry, I don't quite understand why this method requires adding my program itself to the blacklist. After I delete this sentence, the proxy cannot be completed. How to add blacklist or whitelist yourself?Can I proxy normally in my webview?
May I ask in which directory this file is placed?
What is the content of the configuration file? I looked at Configuration File. There should be no need to configure Tun in Android development? How did you configure it?
Can we work together to make a better VPN , with the V2RAY ,xtls , udpgw, ssh , sll, tls , psiphon am familiar with most of them but not good at the core implementation I am good at UI design and other code we can write it in kotlin compose or jetpack. my email is [email protected] if you agree
thanks for your job. please add install commands document in the project README.md
time="2023-11-24T09:04:58Z" level=warning msg="[UDP] dial 8.8.8.8:53: client handshake: UDP ASSOCIATE: command not supported"
time="2023-11-24T09:06:33Z" level=warning msg="[UDP] dial 1.1.1.1:53: client handshake: UDP ASSOCIATE: command not supported"
Excuse me, how did you solve the issue of my error report? How did you link UDP to the proxy server or how should the server configuration file be configured? Is there a problem with the server connection? Because I use Android Studio's simulated mobile proxy to use it normally, I cannot connect to the VPN proxy server in real phones
app crashing on hev-socks5-tunnel version.
FATAL EXCEPTION: main Process: com.xtls.xray, PID: 6501 java.lang.UnsatisfiedLinkError: dlopen failed: library "libhev-socks5-tunnel.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at com.xtls.xray.TProxyService.<clinit>(TProxyService.kt:20) at java.lang.Class.newInstance(Native Method) at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:129) at androidx.core.app.CoreComponentFactory.instantiateService(CoreComponentFactory.java:74) at android.app.ActivityThread.handleCreateService(ActivityThread.java:4330) at android.app.ActivityThread.access$1800(ActivityThread.java:263) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2053) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:236) at android.app.ActivityThread.main(ActivityThread.java:8057) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
where is libhev-socks5-tunnel.so files ??? it not creating in jniLibs folder. i never changed anything. just downloaded this project as raw into my android studio and getting this error.
but only this arch: https://monitor.f-droid.org/builds/log/io.github.saeeddev94.xray/283#site-footer as the others were repro
/LE: fyi https://gitlab.com/fdroid/fdroiddata/-/commit/361dbe524be4ec95ed333c5f20386e9e219191d6
tun.addDisallowedApplication(applicationContext.packageName)
Because of this line of code, the webview I added cannot pass the proxy,How to modify the code so that webview can pass the proxy
what's different between libXray - AndroidLibXrayLite and this branches ? you used 3 different engine during time. i want to know why . does the current libXray engine has better performance?
Please add internal fragment because it is a vital and important feature in China and Iran.
You can also set the amount of packet division.
try lots of times
it don't work, please leave a config json file without ip or id value
1.Manual typing to set the socks proxy (the current part that exists for adding manfig requires a lot of trouble for this.)
2.Add a section to select specific apps to bypass or proxy.
3.Add a subscription and installment to determine the duration of its automatic update.
4.Adding configs in normal format (not custom) from the clipboard to the program.
{
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 10808,
"protocol": "socks",
"settings": {
"udp": true
},
"sniffing": {
"destOverride": ["http", "tls"],
"enabled": true
},
"tag": "socks"
},
{
"listen": "127.0.0.1",
"port": 10809,
"protocol": "http",
"settings": {
"udp": true
},
"tag": "http"
}
],
"outbounds": [
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "",
"port": 443,
"users": [
{
"id": "59d634c2-4015-43c4-bb00-bcd9622fd202",
"encryption": "none"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"tlsSettings": {
"allowInsecure": false,
"serverName": ""
},
"wsSettings": {
"path": "/59d634c2-4015-43c4-bb00-bcd9622fd202",
"headers": {
"Host": ""
}
}
}
}
]
}
Hi bro, this is my client configuration. This doesn't work. What's wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.