Feature : in memoryy configg #92
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So this pr solves or enhances the issue #91 where they are concerned about like their config being stolen. I felt the same cause some attackers most of the time tries to get my config from the files directory where we write the temp config which is vulnerable in my view. So its a really great approach to solve the problem by just using in memory config and simplifies how we start xray , cause personally I hate it to write a config.json every time , its super boring !!!
Whatever now lets see how the pr solves the problem
so lets talk about the core functions that I have added firstly .
StartXrayFromJSON(configJSON string) (*core.Instance, error)
-> It creates a xray instance from the json config given to it. so in the main xray-core we have a function like this inside core packagewhat it does it takes the format (our case json and the config content in bytes) so when we deal normally with config.json file written in some location it uses the same function to process and get the instance by using the content bytes. so in our
StartXrayFromJSON(configJSON string) (*core.Instance, error)
function we are writing a wrapper to that function simply thats it , no config.json file path related stuff required. we get the json -> get bytes and then send to theStartInstance()
then here comes the main function that the issue mentioned needed to included so its the functionRunXrayFromJSON(datDir string, configJSON string) (err error)
it takes the datdir path and the configJson file content then inits the env and simply starts the instance without involving any file writing so it works in memory. these all are changes in xray.go and in xray_wrapper.go I added wrapperss around these and some useful stuff likeRunXrayFromJSONRequest
-> struct for the request with jsonNewXrayRunFromJSONRequest(datDir, configJSON string) (string, error)
-> for creating a request from json and the actualRunXrayFromJSON(base64Text string)
string which handles the connection. so thats how I implemented or fixed the issue/feature/ feel free to do any counter questions, thanks ::::))))