mirror of
https://github.com/amnezia-vpn/amnezia-libxray.git
synced 2026-05-17 06:55:44 +03:00
Add xray init function for android
This commit is contained in:
2
go.mod
2
go.mod
@@ -4,6 +4,7 @@ go 1.22.3
|
||||
|
||||
require (
|
||||
github.com/amnezia-vpn/amnezia-xray-core v1.8.12
|
||||
golang.org/x/mobile v0.0.0-20240520174638-fa72addaaa1b
|
||||
google.golang.org/grpc v1.64.0
|
||||
google.golang.org/protobuf v1.34.1
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
@@ -41,7 +42,6 @@ require (
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
|
||||
golang.org/x/crypto v0.23.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
|
||||
golang.org/x/mobile v0.0.0-20240520174638-fa72addaaa1b // indirect
|
||||
golang.org/x/mod v0.17.0 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
|
||||
21
xray_wrapper_android.go
Normal file
21
xray_wrapper_android.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package libXray
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
xrayfs "github.com/amnezia-vpn/amnezia-xray-core/common/platform/filesystem"
|
||||
mobasset "golang.org/x/mobile/asset"
|
||||
)
|
||||
|
||||
// Prepare Xray for android
|
||||
func InitXray() {
|
||||
xrayfs.NewFileReader = func(path string) (io.ReadCloser, error) {
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
_, file := filepath.Split(path)
|
||||
return mobasset.Open(file)
|
||||
}
|
||||
return os.Open(path)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user