XTLS / libXray

MIT License
64 stars 57 forks source link

Breaking changes in 3.0.0 #29

Closed houmie closed 1 month ago

houmie commented 1 month ago

Hello brother,

Thanks for the great work on this project.

I understand there are breaking changes with version 3.0.0. But it is not clear to me.

Before I could do this on iOS:

LibXrayRunXray(TGConstant.assetDirectory.path, configurationFilePath, 1024 * 1024 * 10)

Now it only accepts a base64 text, I don't understand that. How do I pass in assetDirectory Path and configuration file path to LibXrayRunXray?

Do I need to convert them both to base64? Could you give an example in Go or Swift, so I understand it better?

Thank you so much

houmie commented 1 month ago

I figured it out with the help of ChatGPT.

This breaking change is very scary. I understand you did it after the discussion with the Android developer. :-) I think it requires a bit more documentation, so more people are aware of it.

Thanks

yiguous commented 1 month ago

https://github.com/XTLS/libXray/blob/893c20a93663a4126905ec839fbcdf719d4bd069/xray_wrapper.go#L113

Please read this file.

You should wrap all parameters into a json object, and encode it using base64, then pass the base64-text to LibXrayRunXray. The return value is same with parameters.

sohaib2050 commented 1 month ago

hello I am trying to implement Xray or v2ray in iOS swift. I am studying this for long time this project is in go. I install gomobile to compile it and will make framework for iOS this could help me? is that right path ? or is there any other way to implement also tell me. thank you

houmie commented 1 month ago

You should wrap all parameters into a json object, and encode it using base64, then pass the base64-text to LibXrayRunXray. The return value is same with parameters.

thank you @yiguous

I used lowercase in JSON and it still worked. Strange...

let dictionary: [String: Any] = [
        "datDir": datDir,
        "configPath": configPath,
        "maxMemory": maxMemory
    ]

But it's better to use Uppercase, right?

let dictionary: [String: Any] = [
        "DatDir": datDir,
        "ConfigPath": configPath,
        "MaxMemory": maxMemory
    ]
yiguous commented 1 month ago

No. The right key is lowercase.

datDir is the key in json. DatDir is the propery of runXrayRequest. It's just like CodingKeys in Swift.