Skip to content

Commit

Permalink
Give core execute permission at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Oct 25, 2024
1 parent a2e8755 commit 0efb0b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion v2rayN/ServiceLib/Handler/CoreHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,34 @@ public class CoreHandler
private Process? _processPre;
private Action<bool, string>? _updateFunc;

public void Init(Config config, Action<bool, string> updateFunc)
public async Task Init(Config config, Action<bool, string> updateFunc)
{
_config = config;
_updateFunc = updateFunc;

Environment.SetEnvironmentVariable("V2RAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("XRAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);

if (Utils.IsLinux())
{
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo();
foreach (var it in coreInfo)
{
if (it.CoreType == ECoreType.v2rayN)
{
continue;
}

foreach (var vName in it.CoreExes)
{
var exe = Utils.GetExeName(Utils.GetBinPath(vName, it.CoreType.ToString()));
if (File.Exists(exe))
{
await Utils.SetLinuxChmod(exe);
}
}
}
}
}

public async Task LoadCore(ProfileItem? node)
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private async Task Init()

await ConfigHandler.InitBuiltinRouting(_config);
await ConfigHandler.InitBuiltinDNS(_config);
CoreHandler.Instance.Init(_config, UpdateHandler);
await CoreHandler.Instance.Init(_config, UpdateHandler);
TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler);

if (_config.GuiItem.EnableStatistics)
Expand Down

0 comments on commit 0efb0b5

Please sign in to comment.