Compare commits

..

11 Commits
6.35 ... 6.36

Author SHA1 Message Date
2dust
643547704e Up 6.36 2024-02-18 11:09:00 +08:00
2dust
4717b63775 Bug fix 4 mihomo 2024-02-18 11:02:50 +08:00
2dust
4af148f480 Bug fix 2024-02-15 10:34:43 +08:00
2dust
a9c59693ee Bug fix 2024-02-13 10:11:17 +08:00
2dust
9b3ac159c1 Merge pull request #4712 from hxdhttk/hxdhttk/statePortConf
Fix the state ports conflicts when multiple `v2rayN` instances start in a short period.
2024-02-13 09:57:59 +08:00
2dust
c03c98157f Merge pull request #4711 from hxdhttk/hxdhttk/mixedStdErr
Fix misleading "Cannot mix synchronous and asynchronous operation on process stream." logs.
2024-02-13 09:47:19 +08:00
Minghao Hu
74149b761f Resolve the StatePort when the other components call it. 2024-02-12 22:49:57 +09:00
Minghao Hu
44cfa2d8dc Add a start up error receiver. 2024-02-12 22:12:57 +09:00
Minghao Hu
b0fb00d597 Merge new commits. 2024-02-12 21:20:16 +09:00
2dust
af3c1dc039 Bug fix
https://github.com/2dust/v2rayN/issues/4707
2024-02-12 08:49:22 +08:00
Minghao Hu
ba246e99e8 Fix mixed sync/async ops on Process streams. 2023-12-24 16:21:21 +09:00
11 changed files with 46 additions and 37 deletions

View File

@@ -187,10 +187,7 @@ namespace v2rayN.Handler
config.mux4SboxItem = new()
{
protocol = Global.SingboxMuxs[0],
max_connections = 4,
min_streams = 4,
max_streams = 0,
padding = true
max_connections = 4
};
}

View File

@@ -170,7 +170,7 @@ namespace v2rayN.Handler
{
if (_config.tunModeItem.mtu <= 0)
{
_config.tunModeItem.mtu = Convert.ToInt32(Global.TunMtus[0]);
_config.tunModeItem.mtu = Utils.ToInt(Global.TunMtus[0]);
}
if (Utils.IsNullOrEmpty(_config.tunModeItem.stack))
{
@@ -294,8 +294,6 @@ namespace v2rayN.Handler
outbound.up_mbps = _config.hysteriaItem.up_mbps > 0 ? _config.hysteriaItem.up_mbps : null;
outbound.down_mbps = _config.hysteriaItem.down_mbps > 0 ? _config.hysteriaItem.down_mbps : null;
GenOutboundMux(node, outbound);
}
else if (node.configType == EConfigType.Tuic)
{
@@ -304,8 +302,6 @@ namespace v2rayN.Handler
outbound.uuid = node.id;
outbound.password = node.security;
outbound.congestion_control = node.headerType;
GenOutboundMux(node, outbound);
}
else if (node.configType == EConfigType.Wireguard)
{
@@ -316,7 +312,6 @@ namespace v2rayN.Handler
outbound.reserved = Utils.String2List(node.path).Select(int.Parse).ToArray();
outbound.local_address = [.. Utils.String2List(node.requestHost)];
outbound.mtu = Utils.ToInt(node.shortId.IsNullOrEmpty() ? Global.TunMtus.FirstOrDefault() : node.shortId);
GenOutboundMux(node, outbound);
}
GenOutboundTls(node, outbound);
@@ -339,11 +334,8 @@ namespace v2rayN.Handler
// var mux = new Multiplex4Sbox()
// {
// enabled = true,
// protocol = _config.mux4Sbox.protocol,
// max_connections = _config.mux4Sbox.max_connections,
// min_streams = _config.mux4Sbox.min_streams,
// max_streams = _config.mux4Sbox.max_streams,
// padding = _config.mux4Sbox.padding
// protocol = _config.mux4SboxItem.protocol,
// max_connections = _config.mux4SboxItem.max_connections,
// };
// outbound.multiplex = mux;
//}

View File

@@ -156,7 +156,7 @@ namespace v2rayN.Handler
#region Private
private string CoreFindexe(CoreInfo coreInfo)
private string CoreFindExe(CoreInfo coreInfo)
{
string fileName = string.Empty;
foreach (string name in coreInfo.coreExes)
@@ -266,7 +266,7 @@ namespace v2rayN.Handler
{
try
{
string fileName = CoreFindexe(coreInfo);
string fileName = CoreFindExe(coreInfo);
if (Utils.IsNullOrEmpty(fileName))
{
return null;
@@ -286,6 +286,8 @@ namespace v2rayN.Handler
StandardErrorEncoding = displayLog ? Encoding.UTF8 : null,
}
};
var startUpErrorMessage = new StringBuilder();
var startUpSuccessful = false;
if (displayLog)
{
proc.OutputDataReceived += (sender, e) =>
@@ -302,6 +304,11 @@ namespace v2rayN.Handler
{
string msg = e.Data + Environment.NewLine;
update(false, msg);
if (!startUpSuccessful)
{
startUpErrorMessage.Append(msg);
}
}
};
}
@@ -314,7 +321,12 @@ namespace v2rayN.Handler
if (proc.WaitForExit(1000))
{
throw new Exception(displayLog ? proc.StandardError.ReadToEnd() : "启动进程失败并退出 (Failed to start the process and exited)");
proc.CancelErrorRead();
throw new Exception(displayLog ? startUpErrorMessage.ToString() : "启动进程失败并退出 (Failed to start the process and exited)");
}
else
{
startUpSuccessful = true;
}
LazyConfig.Instance.AddProcess(proc.Handle);

View File

@@ -11,14 +11,25 @@ namespace v2rayN.Handler
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>();
@@ -68,7 +79,7 @@ namespace v2rayN.Handler
}
return localPort;
}
public void AddProcess(IntPtr processHandle)
{
_processJob.AddProcess(processHandle);
@@ -339,7 +350,7 @@ namespace v2rayN.Handler
{
coreType = ECoreType.mihomo,
coreExes = new List<string> { $"mihomo-windows-amd64{(Avx2.X64.IsSupported ? "" : "-compatible")}", "mihomo-windows-amd64-compatible", "mihomo-windows-amd64", "mihomo-windows-386", "mihomo", "clash" },
arguments = "-f config.yaml",
arguments = "-f config.json",
coreUrl = Global.MihomoCoreUrl,
coreReleaseApiUrl = Global.MihomoCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
match = "Mihomo",

View File

@@ -69,7 +69,7 @@ namespace v2rayN.Handler
}
}
await Task.Delay(1000);
await _channel.ConnectAsync();
if (_channel != null) await _channel.ConnectAsync();
}
catch
{

View File

@@ -54,7 +54,7 @@ namespace v2rayN.Handler
StartInfo = new ProcessStartInfo
{
FileName = "v2rayUpgrade.exe",
Arguments = fileName.AppendQuotes(),
Arguments = fileName.AppendQuotes(),
WorkingDirectory = Utils.StartupPath()
}
};
@@ -392,6 +392,7 @@ namespace v2rayN.Handler
case ECoreType.clash:
case ECoreType.clash_meta:
case ECoreType.mihomo:
version = Regex.Match(echo, $"v[0-9.]+").Groups[0].Value;
break;
@@ -453,6 +454,7 @@ namespace v2rayN.Handler
}
case ECoreType.clash:
case ECoreType.clash_meta:
case ECoreType.mihomo:
{
curVersion = getCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, type, curVersion);

View File

@@ -203,9 +203,6 @@ namespace v2rayN.Mode
{
public string protocol { get; set; }
public int max_connections { get; set; }
public int min_streams { get; set; }
public int max_streams { get; set; }
public bool padding { get; set; }
}
[Serializable]

View File

@@ -139,9 +139,6 @@
public bool enabled { get; set; }
public string protocol { get; set; }
public int max_connections { get; set; }
public int min_streams { get; set; }
public int max_streams { get; set; }
public bool padding { get; set; }
}
public class Utls4Sbox

View File

@@ -40,6 +40,7 @@
<Button
x:Name="btnSave"
Width="100"
Click="btnSave_Click"
Content="{x:Static resx:ResUI.TbConfirm}"
Cursor="Hand"
Style="{StaticResource DefButton}" />

View File

@@ -512,8 +512,8 @@ namespace v2rayN.Views
private void StorageUI()
{
_config.uiItem.mainWidth = this.Width;
_config.uiItem.mainHeight = this.Height;
_config.uiItem.mainWidth = Utils.ToInt(this.Width);
_config.uiItem.mainHeight = Utils.ToInt(this.Height);
List<ColumnItem> lvColumnItem = new();
for (int k = 0; k < lstProfiles.Columns.Count; k++)
@@ -522,7 +522,7 @@ namespace v2rayN.Views
lvColumnItem.Add(new()
{
Name = item2.ExName,
Width = item2.Visibility == Visibility.Visible ? Convert.ToInt32(item2.ActualWidth) : -1,
Width = item2.Visibility == Visibility.Visible ? Utils.ToInt(item2.ActualWidth) : -1,
Index = item2.DisplayIndex
});
}

View File

@@ -10,7 +10,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
<Copyright>Copyright © 2017-2024 (GPLv3)</Copyright>
<FileVersion>6.35</FileVersion>
<FileVersion>6.36</FileVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
</PropertyGroup>