mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-02 13:18:50 +00:00
Bug fix
This commit is contained in:
parent
a49455f330
commit
80ed8346be
5 changed files with 40 additions and 23 deletions
|
@ -776,18 +776,21 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
singboxConfig.experimental = new Experimental4Sbox()
|
singboxConfig.experimental = new Experimental4Sbox()
|
||||||
{
|
{
|
||||||
|
//cache_file = new CacheFile4Sbox()
|
||||||
|
//{
|
||||||
|
// enabled = true
|
||||||
|
//},
|
||||||
//v2ray_api = new V2ray_Api4Sbox()
|
//v2ray_api = new V2ray_Api4Sbox()
|
||||||
//{
|
//{
|
||||||
// listen = $"{Global.Loopback}:{Global.statePort}",
|
// listen = $"{Global.Loopback}:{Global.StatePort}",
|
||||||
// stats = new Stats4Sbox()
|
// stats = new Stats4Sbox()
|
||||||
// {
|
// {
|
||||||
// enabled = true,
|
// enabled = true,
|
||||||
// }
|
// }
|
||||||
//}
|
//},
|
||||||
clash_api = new Clash_Api4Sbox()
|
clash_api = new Clash_Api4Sbox()
|
||||||
{
|
{
|
||||||
external_controller = $"{Global.Loopback}:{Global.StatePort}",
|
external_controller = $"{Global.Loopback}:{Global.StatePort}",
|
||||||
store_selected = true
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,14 +143,12 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
return defaultPort;
|
return defaultPort;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
TcpListener l = new(IPAddress.Loopback, 0);
|
||||||
TcpListener l = new(IPAddress.Loopback, 0);
|
l.Start();
|
||||||
l.Start();
|
int port = ((IPEndPoint)l.LocalEndpoint).Port;
|
||||||
int port = ((IPEndPoint)l.LocalEndpoint).Port;
|
l.Stop();
|
||||||
l.Stop();
|
return port;
|
||||||
return port;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,8 +8,8 @@ namespace v2rayN.Handler
|
||||||
internal class StatisticsV2ray
|
internal class StatisticsV2ray
|
||||||
{
|
{
|
||||||
private Mode.Config _config;
|
private Mode.Config _config;
|
||||||
private GrpcChannel _channel;
|
private GrpcChannel? _channel;
|
||||||
private StatsService.StatsServiceClient _client;
|
private StatsService.StatsServiceClient? _client;
|
||||||
private bool _exitFlag;
|
private bool _exitFlag;
|
||||||
private Action<ServerSpeedItem> _updateFunc;
|
private Action<ServerSpeedItem> _updateFunc;
|
||||||
|
|
||||||
|
@ -26,10 +26,17 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
private void GrpcInit()
|
private void GrpcInit()
|
||||||
{
|
{
|
||||||
if (_channel == null)
|
if (_channel is null)
|
||||||
{
|
{
|
||||||
_channel = GrpcChannel.ForAddress($"{Global.HttpProtocol}{Global.Loopback}:{Global.StatePort}");
|
try
|
||||||
_client = new StatsService.StatsServiceClient(_channel);
|
{
|
||||||
|
_channel = GrpcChannel.ForAddress($"{Global.HttpProtocol}{Global.Loopback}:{Global.StatePort}");
|
||||||
|
_client = new StatsService.StatsServiceClient(_channel);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Utils.SaveLog(ex.Message, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +51,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_channel.State == ConnectivityState.Ready)
|
if (_channel?.State == ConnectivityState.Ready)
|
||||||
{
|
{
|
||||||
QueryStatsResponse? res = null;
|
QueryStatsResponse? res = null;
|
||||||
try
|
try
|
||||||
|
|
|
@ -180,8 +180,9 @@
|
||||||
|
|
||||||
public class Experimental4Sbox
|
public class Experimental4Sbox
|
||||||
{
|
{
|
||||||
public V2ray_Api4Sbox v2ray_api { get; set; }
|
public CacheFile4Sbox? cache_file { get; set; }
|
||||||
public Clash_Api4Sbox clash_api { get; set; }
|
public V2ray_Api4Sbox? v2ray_api { get; set; }
|
||||||
|
public Clash_Api4Sbox? clash_api { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class V2ray_Api4Sbox
|
public class V2ray_Api4Sbox
|
||||||
|
@ -192,8 +193,8 @@
|
||||||
|
|
||||||
public class Clash_Api4Sbox
|
public class Clash_Api4Sbox
|
||||||
{
|
{
|
||||||
public string external_controller { get; set; }
|
public string? external_controller { get; set; }
|
||||||
public bool store_selected { get; set; }
|
public bool? store_selected { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Stats4Sbox
|
public class Stats4Sbox
|
||||||
|
@ -210,4 +211,12 @@
|
||||||
public string inet4_range { get; set; }
|
public string inet4_range { get; set; }
|
||||||
public string inet6_range { get; set; }
|
public string inet6_range { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class CacheFile4Sbox
|
||||||
|
{
|
||||||
|
public bool enabled { get; set; }
|
||||||
|
public string? path { get; set; }
|
||||||
|
public string? cache_id { get; set; }
|
||||||
|
public bool? store_fakeip { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -880,13 +880,13 @@ namespace v2rayN
|
||||||
if (blFull)
|
if (blFull)
|
||||||
{
|
{
|
||||||
return string.Format("v2rayN - V{0} - {1}",
|
return string.Format("v2rayN - V{0} - {1}",
|
||||||
FileVersionInfo.GetVersionInfo(location).FileVersion.ToString(),
|
FileVersionInfo.GetVersionInfo(location).FileVersion?.ToString(),
|
||||||
File.GetLastWriteTime(location).ToString("yyyy/MM/dd"));
|
File.GetLastWriteTime(location).ToString("yyyy/MM/dd"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return string.Format("v2rayN/{0}",
|
return string.Format("v2rayN/{0}",
|
||||||
FileVersionInfo.GetVersionInfo(location).FileVersion.ToString());
|
FileVersionInfo.GetVersionInfo(location).FileVersion?.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
Loading…
Reference in a new issue