libXray

package module
v1.8.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2023 License: MIT Imports: 15 Imported by: 0

README

libXray

This is an Xray wrapper focusing on improving the experience of Xray-core mobile development.

Note

  1. This repository has very limited maintainers. If you're not reporting a bug, or making a PR, your question will most likely be ignored.

  2. This lib does not guarantee the stability of the api, you need to adapt it by yourself.

  3. If your issue is about some Platform development, like iOS or Android, it will be just closed.

Features

nodep

clash.go

转换 Clash yaml,Clash.Meta yaml 为 Xray Json。

file.go

文件写入。

measure.go

基于 http/socks5 proxy 进行延迟测试。

基于 geoip.dat 进行 geolocation。

TCPPing。

memory.go

强制 GC。

port.go

获取空闲端口。

share.go

转换 v2rayN 订阅为 Xray Json。

转换 VMessAEAD/VLESS 分享为 Xray Json。

subscription.go

转换 Xray Json 为订阅文本。

vmess.go

转换 VMessQRCode 为 Xray Json。

xray_json.go

Xray 配置的子集,为出口节点添加了 Name 字段,便于 App 内进行解析。

支持 flatten outbounds 。

lib package

build.sh

编译脚本。一键生成 xcframework 和 aar。

geo_cut.go

剪切 geosite.data 和 geoip.data 。

geo.go

读取 geo site dat,生成类别名称文件并统计规则数量,包含 Attribute。

读取 geo ip dat,生成类别名称文件并统计规则数量。

nodep_wrapper.go

获取空闲端口。

转换分享文本为 Xray Json。

转换 Xray Json 为分享文本。

ping.go

测速。

uuid.go

转换自定义文本为 uuid。

validation.go

测试 Xray 配置文件。

xray.go

启动和停止 Xray 。

Credits

Project X

VMessPing

FreePort

SeeIP

Documentation

Overview

libXray is an Xray wrapper focusing on improving the experience of Xray-core mobile development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertShareTextToXrayJson

func ConvertShareTextToXrayJson(textPath string, xrayPath string) string

Convert share text to XrayJson support XrayJson, v2rayN plain text, v2rayN base64 text, Clash yaml, Clash.Meta yaml

func ConvertXrayJsonToShareText

func ConvertXrayJsonToShareText(xrayPath string, textPath string) string

Convert XrayJson to share links. VMess will generate VMessAEAD link.

func CustomUUID

func CustomUUID(text string) string

convert text to uuid

func CutGeoData

func CutGeoData(datDir string, dstDir string, cutCodePath string) string

Read geo data and cut the codes we need. datDir means the dir which geo dat are in. dstDir means the dir which new geo dat are in. cutCodePath means geoCutCode json file path

This function is used to reduce memory when init instance. You can cut the country codes which rules and nameservers contain.

func GetFreePorts

func GetFreePorts(count int) string

Wrapper of nodep.GetFreePorts count means how many ports you need. return ports divided by ":", like "1080:1081"

func LoadGeoData

func LoadGeoData(datDir string, name string, geoType string) string

Read geo data and write all codes to text file. datDir means the dir which geo dat are in. name means the geo dat file name, like "geosite", "geoip" geoType must be the value of geoType

func Ping

func Ping(datDir string, configPath string, timeout int, url string, times int, proxy string) string

Ping Xray config and find the delay and country code of its outbound. datDir means the dir which geosite.dat and geoip.dat are in. configPath means the config.json file path. timeout means how long the http request will be cancelled if no response, in units of seconds. url means the website we use to test speed. "https://www.google.com" is a good choice for most cases. times means how many times we should test the url. proxy means the local http/socks5 proxy, like "socks5://[::1]:1080".

func RunXray

func RunXray(datDir string, configPath string, maxMemory int64) string

Run Xray instance. datDir means the dir which geosite.dat and geoip.dat are in. configPath means the config.json file path. maxMemory means the soft memory limit of golang, see SetMemoryLimit to find more information.

func StopXray

func StopXray() string

Stop Xray instance.

func TcpPing

func TcpPing(timeout int, server string, times int) string

Find the delay of some outbound. timeout means how long the tcp connection will be cancelled if no response, in units of seconds. server means the destination we use to test speed, like "8.8.8.8:853". times means how many times we should test the server.

func TestXray

func TestXray(datDir string, configPath string) string

Test Xray Config. datDir means the dir which geosite.dat and geoip.dat are in. configPath means the config.json file path.

func XrayVersion

func XrayVersion() string

Xray's version

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL