Giter Club home page Giter Club logo

xray's Introduction

Xray

App Cover

This is a simple GUI client for XTLS/Xray-core
Also you can use it independent of Xray-core just for your socks proxy (Like SocksDroid)

Screenshots

MainActivityAssetsActivitySettingsActivity: Basic TabSettingsActivity: Advanced Tab

APK variants guide

  • arm32 => versionCode + 1
  • arm64 => versionCode + 2
  • x86 => versionCode + 3
  • amd64 => versionCode + 4

Download

Release CI
Get it on GitHub Get it on F-Droid

xray's People

Contributors

maskedeken avatar relan avatar saeeddev94 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

Watchers

 avatar  avatar  avatar  avatar  avatar

xray's Issues

About blacklist and whitelist

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?

how we can monitor used traffic

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.

Proposal

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

[FR] Add some important features

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.

The application crashes after loading hev-socks5-tunnel.so

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

Regarding xray configuration file issues

{
"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?

some x-ray configs not working

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;

Picsart_23-09-10_22-50-15-344

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?

add internal fargmant

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.

error after build app and its crashing

app crashing on hev-socks5-tunnel version.

Untitled

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.

vpn

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

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.