Skip to content

Commit

Permalink
Resolve the StatePort when the other components call it.
Browse files Browse the repository at this point in the history
  • Loading branch information
hxdhttk committed Feb 12, 2024
1 parent af3c1dc commit 74149b7
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions v2rayN/v2rayN/Handler/LazyConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,24 @@ public sealed class LazyConfig

public static LazyConfig Instance => _instance.Value;

private int _statePort;
public int StatePort { get => _statePort; }
private Job _processJob = new();
private int? _statePort;
public int StatePort
{
get
{
if (_statePort is null)
{
_statePort = Utils.GetFreePort();
}

return _statePort.Value;
}
}

private Job _processJob = new();

public LazyConfig()
{
_statePort = Utils.GetFreePort();

SqliteHelper.Instance.CreateTable<SubItem>();
SqliteHelper.Instance.CreateTable<ProfileItem>();
SqliteHelper.Instance.CreateTable<ServerStatItem>();
Expand Down Expand Up @@ -68,7 +78,7 @@ public int GetLocalPort(string protocol)
}
return localPort;
}

public void AddProcess(IntPtr processHandle)
{
_processJob.AddProcess(processHandle);
Expand Down

0 comments on commit 74149b7

Please sign in to comment.