Documentation
¶
Overview ¶
libXray is an Xray wrapper focusing on improving the experience of Xray-core mobile development.
Index ¶
- func ConvertShareTextToXrayJson(textPath string, xrayPath string) string
- func ConvertXrayJsonToShareText(xrayPath string, textPath string) string
- func CustomUUID(text string) string
- func CutGeoData(datDir string, dstDir string, cutCodePath string) string
- func GetFreePorts(count int) string
- func LoadGeoData(datDir string, name string, geoType string) string
- func Ping(datDir string, configPath string, timeout int, url string, times int, ...) string
- func RunXray(datDir string, configPath string, maxMemory int64) string
- func StopXray() string
- func TcpPing(timeout int, server string, times int) string
- func TestXray(datDir string, configPath string) string
- func XrayVersion() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertShareTextToXrayJson ¶
Convert share text to XrayJson support XrayJson, v2rayN plain text, v2rayN base64 text, Clash yaml, Clash.Meta yaml
func ConvertXrayJsonToShareText ¶
Convert XrayJson to share links. VMess will generate VMessAEAD link.
func CutGeoData ¶
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 ¶
Wrapper of nodep.GetFreePorts count means how many ports you need. return ports divided by ":", like "1080:1081"
func LoadGeoData ¶
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 ¶
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 TcpPing ¶
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.
Types ¶
This section is empty.