GithubHelp home page GithubHelp logo

libxray's People

Contributors

maskedeken avatar open2dev avatar pingpromax avatar rprx avatar yiguous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libxray's Issues

Mac - Command CodeSign failed with a nonzero exit code

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.

Screenshot 2023-07-09 at 12 21 17

But it doesn't work.

Any advice please?

XcodeDefault.xctoolchain/usr/bin/bitcode_strip exited with 1

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

  1. Add this in User Settings: STRIP_BITCODE_FROM_COPIED_FILES=NO
  2. In Frameworks and Libraries change Embed & Sign to Embed Without Signing.

Is this intended like this?

LibXrayQueryStats() for usage traffic

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?

why go.sum listed in .gitignore file?

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

use string based, instead of file

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.

请教转发 xray log 至 native 的功能问题提问?

接续问题 #14
请问我后来在 xray_wrapper.go 新增增加转发 xray log 至 native 的功能,但是在 系统监控程式.app 看到的 log 是 "private" 并无转发到 native 中,所以提出以下 xray_wrapper.go 新增的内容,能请问各位前辈,我的程式码是否有没注意到的问题吗?

目前遇到两个问题

  1. log 内容是 "< private >"。
  2. OnAccessLog 没有转发到 native;设计上是希望向 delegate 传到 native。

private log image

/// 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")

    }
}

Latest version is no longer compiling

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

about building xray version

thanks for this great work.
does this library always using the least version of Xray (XTLS Core) when we building it?

在iOS项目中使用Libxray.xcframework的咨询

你好,

感谢你的精彩项目。

我已经为iOS编译了这个项目,并添加到我的项目中。我是否需要在我的PacketTunnelProvider中使用这个框架?例如,我是否可以在startTunnel()等函数中直接运行LibxrayRunXray()?

请问有关于如何在iOS中使用这个框架的文档吗?

谢谢你,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.