xtls / libxray Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
https://github.com/yiguous/libxray/blob/0ad0717b70b088ff628b917dade43dfbe0a60a9a/build.sh#L11
例如
gomobile bind -o ./XrayKit.xcframework -target=ios,iossimulator,macos -iosversion=12.0 -ldflags="-s -w" -v ./
Today I started implementing a demo on Mac with this lib.
I can't build it though.
/Users/houmie/Library/Developer/Xcode/DerivedData/xraydemo-akmagyiewjmaxhgqegcdimbvucrm/Build/Products/Debug/tunnel-mac.appex: code object is not signed at all
In subcomponent: /Users/houmie/Library/Developer/Xcode/DerivedData/xraydemo-akmagyiewjmaxhgqegcdimbvucrm/Build/Products/Debug/tunnel-mac.appex/Contents/Frameworks/Libxray.framework
Command CodeSign failed with a nonzero exit code
I have already set it to Embed Without Signing.
But it doesn't work.
Any advice please?
After compiling this for apple:
bash build.sh apple
and adding LibXray.xcframework
to my project, I can no longer build it.
I get this error:
/Users/houmie/Projects/libXray/LibXray.xcframework/ios-arm64/LibXray.framework bitcode_strip /Users/houmie/Projects/libXray/LibXray.xcframework/ios-arm64/LibXray.framework/Versions/A/LibXray: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip exited with 1
The only way to circumvent it is to
STRIP_BITCODE_FROM_COPIED_FILES=NO
Embed & Sign
to Embed Without Signing
.Is this intended like this?
Hello,
What is the best way to get the usage (traffic)?
import UIKit
import NetworkExtension
import LibXray
class ViewController: UIViewController {
var tunnelProviderManager: NETunnelProviderManager?
var isTimerUsageRunning = false
var timerUsage = Timer()
override func viewDidLoad() {
super.viewDidLoad()
if self.isTimerUsageRunning == false {
self.isTimerUsageRunning = true
self.timerUsage = Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { [self] _ in
LibXrayQueryStats("127.0.0.1:8080", TGConstant.homeDirectory.absoluteString + "test.json")
})
}
}
I try to get the stats written to test.json every second. Is this the correct approach?
As my understanding go.sum
is like npm package-lock.json
which guarantees the dependencies versions be exactly same as author machine
Why it listed in .gitignore
file?
When i run go mod download
to install dependencies go command updates libs so I have to commit the changes (go.mod
) which I don't want to do it!
I saw other go repos that contains this file
Please include it if there is no specific reason for that, Thanks
This library is great. But to run it on Android, it should be optimized.
For example, when we want to use commands like share.go, the strings must be written in the file each time, and then specify the path of the file to this command for output.
This causes more pressure. Because to use any command, we have to write it in the file and give the file path to the program.
For example, consider this command:
val decode = "
vless://dqwdqw...\n
vless://dqwdqw...\n
vless://dqwdqw...\n
vless://dqwdqw..."
val array = decode.split("\n").toTypedArray()
for (strings in array) {
// first write each strings to a file
writeFile(path, strings)
// then give path of file to lib
LibXray.convertShareTextToXrayJson(path, outputPath)
// then read outputPath and ping them
LibXray.Ping(datDir, outputPath, timeout, url, proxy)
}
each step should written in disk and then read it from there.
But if it is as follows, all the steps are in string and it makes it more efficient and reduces the pressure on the disk;
val decode = "
vless://dqwdqw...\n
vless://dqwdqw...\n
vless://dqwdqw...\n
vless://dqwdqw..."
val array = decode.split("\n").toTypedArray()
for (strings in array) {
// the final output in string
val share = LibXray.convertShareTextToXrayJson(path, strings)
// read output in string format
LibXray.Ping(datDir, share, timeout, url, proxy)
}
please look at this sub, it has about +100 configs and by this way all of them should be write in disk every time. it will cool if this lib give us all of outputs in the string format.
my knowledge is not enough in go, but i just checked AndroidLibXrayLite and And I saw this line. i dont know how strings.NewReader works in go. But if anyone can please help to improve this library.
接续问题 #14
请问我后来在 xray_wrapper.go 新增增加转发 xray log 至 native 的功能,但是在 系统监控程式.app 看到的 log 是 "private" 并无转发到 native 中,所以提出以下 xray_wrapper.go 新增的内容,能请问各位前辈,我的程式码是否有没注意到的问题吗?
目前遇到两个问题
/// XrayLogger
type XrayLogger interface {
OnAccessLog(message string)
}
type myLogger struct{}
func (m *myLogger) OnAccessLog(message string) {
fmt.Println("Access Log:", message)
}
var globalLogger XrayLogger
// XraySetupLogger 接收一个 XrayLogger 接口实现
func XraySetupLogger(logger XrayLogger) {
globalLogger = logger
if logger != nil {
logger.OnAccessLog("Access log message")
}
}
/// Give me Log
type consoleLogWriter struct {
logger *log.Logger
}
func (w *consoleLogWriter) Close() error {
return nil
}
func (w *consoleLogWriter) Write(s string) error {
w.logger.Println(s)
globalLogger.OnAccessLog(s)
var stringA = fmt.Sprintf("(String(reflecting: %v), privacy: .public)", s)
globalLogger.OnAccessLog(stringA)
return nil
}
type defaultLogWriter struct{}
func (defaultLogWriter) Write(b []byte) (int, error) {
log.Println("(String(reflecting: %v), privacy: .public)", string(b))
var stringA = fmt.Sprintf("(String(reflecting: %v), privacy: .public)", string(b))
globalLogger.OnAccessLog(stringA)
return len(b), nil
}
func CreateDefaultLogWriter() v2commlog.WriterCreator {
return func() v2commlog.Writer {
return &consoleLogWriter{
logger: log.New(defaultLogWriter{}, "", 0),
}
}
}
func init() {
v2applog.RegisterHandlerCreator(v2applog.LogType_Console, func(lt v2applog.LogType, options v2applog.HandlerCreatorOptions) (v2commlog.Handler, error) {
return v2commlog.NewLogger(CreateDefaultLogWriter()), nil
})
}
以下是Swift的實現接口部分
extension XRayCoreManager: LibXrayXrayLoggerProtocol {
func onAccessLog(_ message: String?) {
os_log("[DEBUGV] onAccessLog: %{public}@", log: OSLog.default, type: .info, message ?? "456")
}
}
使用空结构体指针作为接收对象,提供面向对象的 API。
感谢作者开源,已可以使用libxray打包出来的 xcframework 可以正常运作
唯独只有无法检视log的运作,因为想仿造当时 Mango 专案在运作时可以观看log
但碍于已联系不到作者,只能自行摸索开发现阶段的 go 程式码
尝试好几天都还没有办法把 log 显示出来,所以上来请教
Hello friend,
It was working fine until today. Maybe it's because of the new iOS 17?
I have XCode Version 15.0 (15A240d), Mac M1 Ventura 13.6 (22G120) and iOS 17.0, go version go1.21.1 darwin/arm64
When trying to build it on Mac:
➜ libXray git:(main) bash build.sh apple
go: downloading github.com/xtls/xray-core v1.8.4
go: downloading google.golang.org/protobuf v1.31.0
go: downloading go4.org/netipx v0.0.0-20230824141953-6213f710f925
go: downloading github.com/sagernet/sing v0.2.9
go: downloading google.golang.org/grpc v1.57.0
go: downloading github.com/quic-go/quic-go v0.38.1
go: downloading golang.org/x/net v0.15.0
go: downloading github.com/miekg/dns v1.1.55
go: downloading golang.org/x/crypto v0.13.0
go: downloading github.com/refraction-networking/utls v1.4.3
go: downloading gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744
go: downloading github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6
go: downloading golang.org/x/exp v0.0.0-20230725093048-515e97ebf090
go: downloading github.com/onsi/ginkgo/v2 v2.12.0
go: downloading github.com/onsi/gomega v1.27.10
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d
go: downloading github.com/sagernet/sing-shadowsocks v0.2.4
go: downloading github.com/gaukas/godicttls v0.0.4
go: downloading github.com/klauspost/compress v1.16.7
go: downloading golang.org/x/text v0.13.0
go: downloading github.com/quic-go/qtls-go1-20 v0.3.3
go: downloading github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f
go: added golang.org/x/mobile v0.0.0-20230906132913-2077a3224571
will build libxray for apple
gomobile: xcodebuild -create-xcframework -framework /var/folders/9m/lwx24q8929g7kpcg7vb5vssh0000gn/T/gomobile-work-122789388/ios/iphoneos/LibXray.framework -framework /var/folders/9m/lwx24q8929g7kpcg7vb5vssh0000gn/T/gomobile-work-122789388/iossimulator/iphonesimulator/LibXray.framework -framework /var/folders/9m/lwx24q8929g7kpcg7vb5vssh0000gn/T/gomobile-work-122789388/iossimulator/iphonesimulator/LibXray.framework -framework /var/folders/9m/lwx24q8929g7kpcg7vb5vssh0000gn/T/gomobile-work-122789388/macos/macosx/LibXray.framework -framework /var/folders/9m/lwx24q8929g7kpcg7vb5vssh0000gn/T/gomobile-work-122789388/macos/macosx/LibXray.framework -output LibXray.xcframework failed: exit status 70
error: cannot compute path of binary 'Path(str: "/private/var/folders/9m/lwx24q8929g7kpcg7vb5vssh0000gn/T/gomobile-work-122789388/ios/iphoneos/LibXray.framework/Versions/A/LibXray")' relative to that of '/var/folders/9m/lwx24q8929g7kpcg7vb5vssh0000gn/T/gomobile-work-122789388/ios/iphoneos/LibXray.framework'
Any advice, please?
Thanks
thanks for this great work.
does this library always using the least version of Xray (XTLS Core) when we building it?
你好,
感谢你的精彩项目。
我已经为iOS编译了这个项目,并添加到我的项目中。我是否需要在我的PacketTunnelProvider中使用这个框架?例如,我是否可以在startTunnel()等函数中直接运行LibxrayRunXray()?
请问有关于如何在iOS中使用这个框架的文档吗?
谢谢你,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.