2024-05-27 13:25:30 +03:00
|
|
|
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
|
2024-06-10 21:25:16 +03:00
|
|
|
func InitXray(assetsPath string) {
|
2024-05-27 13:25:30 +03:00
|
|
|
xrayfs.NewFileReader = func(path string) (io.ReadCloser, error) {
|
|
|
|
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
2024-06-10 21:25:16 +03:00
|
|
|
asset, err := filepath.Rel(assetsPath, path)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return mobasset.Open(asset)
|
2024-05-27 13:25:30 +03:00
|
|
|
}
|
|
|
|
|
return os.Open(path)
|
|
|
|
|
}
|
|
|
|
|
}
|