This is a wrapper around Xray-core to improve the client development experience.
- This repository has few maintainers. If you do not report a bug or initiate a PR, your issue will be ignored.
- This repository does not guarantee API stability, you need to adapt it yourself.
- This repository is only compatible with the latest release of Xray-core.
Releases use CalVer in the form v<YY>.<M>.<D> (e.g. v26.3.27 = 2026-03-27).
Because Go modules require any module with major version >= 2 to encode the
major in its import path, every CalVer release is mirrored onto a Go-friendly
SemVer tag on the same commit:
| CalVer tag | Go-import tag |
|---|---|
v26.3.27 |
v1.260327.0 |
Go consumers should pin against the SemVer mirror:
go get github.com/xtls/libxray@v1.260327.0The mirror tag is created automatically by
.github/workflows/release-go-mirror.yml
on every CalVer push. Existing CalVer tags can be backfilled with
scripts/backfill-semver-tags.sh.
Compile script. It is recommended to always use this script to compile libXray. We will not answer questions caused by using other compilation methods.
depends on git and go.
# Android (min Android API level is 21)
python3 build/main.py android
# Apple (gomobile or go)
python3 build/main.py apple gomobile
python3 build/main.py apple go
# Linux
python3 build/main.py linux
# Windows
python3 build/main.py windows
use gomobile .
Need "iOS Simulator Runtime".
This is the best choice for general scenarios and will not conflict with other frameworks.
Supports iOS, iOSSimulator, macOS, macCatalyst.
But it is not possible to set the minimum macOS version, which will cause some warnings when compiling. And it does not support tvOS.
Need "iOS Simulator Runtime" and "tvOS Simulator Runtime".
Support more compilation options, output c header files.
This works well when you use ffi for integration. For example, integration with swift, kotlin, dart.
Support iOS, iOSSimulator, macOS, tvOS.
Note: The product LibXray.xcframework does not contain module.modulemap. When using swift, you need to create a bridge file.
depend on gcc and g++.
depend on MinGW.
you can use winget to install LLVM MinGW or WinLibs .
winget install MartinStorsjo.LLVM-MinGW.UCRT
winget install BrechtSanders.WinLibs.POSIX.UCRTUsed to solve the socket protect problem on Android.
Used to solve server address resolution issues on Android, Linux, and Windows. If not handled, the DNS traffic will be resent to the tun device, resulting in failure to initiate a connection.
Read geo files and count the categories and rules.
Read the Xray Json configuration and extract the geo file name used.
Download geosite.dat and geoip.dat and count them.
Only executed on iOS, GC is initiated once a second. This can alleviate memory pressure on iOS.
Write data to a file.
Speed test the Xray configuration.
The response body of the wrapper interface.
Get free ports.
libXray uses sendThrough to store outbound names.
Parse Clash.Meta configuration.
convert Xray Json to VMessAEAD/VLESS sharing protocol.
convert VMessAEAD/VLESS sharing protocol to Xray Json.
convert VMessQRCode to Xray Json.
convert VMessQRCode to Xray Json.
Some tools used to parse shared links.
Latency testing.
Refer to the following configuration:
{
"metrics" : {
"tag" : "metrics",
"listen": "[::1]:49227",
},
"policy" : {
"system" : {
"statsInboundDownlink" : true,
"statsInboundUplink" : true,
"statsOutboundDownlink" : true,
"statsOutboundUplink" : true
}
},
"stats" : {}
}Note:
-
When testing latency or validating configuration, make sure
metricsisnull. -
When enabling metrics, the Xray-core instance needs to be run in a child process.
Verify the Xray configuration.
Start and stop Xray instances.
export nodep.
export xray.
This repository is based on the MIT License.