Compare commits

..

15 Commits
6.18 ... 6.20

Author SHA1 Message Date
2dust
790209efbc up 6.20 2023-04-01 18:57:24 +08:00
2dust
f1679e444c Add skip subscription tips 2023-03-31 20:07:39 +08:00
2dust
9dc6ba182a Fix delete duplicate server 2023-03-30 14:09:14 +08:00
2dust
785a30e623 Update CoreConfigHandler.cs 2023-03-26 20:05:51 +08:00
2dust
f09efdad66 Add tip for custom log 2023-03-25 18:05:01 +08:00
2dust
4e73b3ae28 Adjust some style 2023-03-25 17:50:32 +08:00
2dust
6213f86f81 up 6.19 2023-03-21 17:20:24 +08:00
2dust
0a6955cd59 Add log start core 2023-03-21 14:22:13 +08:00
2dust
6ee8f03ec0 Gui's log can be turned off 2023-03-20 15:25:58 +08:00
2dust
b1a82d95c2 Hide title when title width is equal to 0 2023-03-20 15:23:29 +08:00
2dust
30bc9ded29 Add REALITY share link 2023-03-20 15:20:55 +08:00
2dust
5a32892e94 bug fixes 2023-03-20 14:03:50 +08:00
2dust
e33de896b6 Merge pull request #3507 from ShiinaRinne/dev
Update: 默认关闭硬件加速
2023-03-20 13:23:58 +08:00
ShiinaRinne
3ba92444a5 Update: 默认关闭硬件加速
开启硬件加速时可能会导致奇奇怪怪的问题,因此修改为默认关闭
https://github.com/2dust/v2rayN/issues/3379
https://github.com/2dust/v2rayN/issues/3279
2023-03-18 20:49:02 +08:00
2dust
4f120e8eb4 bug fixes 2023-03-17 17:20:40 +08:00
24 changed files with 137 additions and 62 deletions

View File

@@ -42,10 +42,11 @@ namespace v2rayN
Global.processJob = new Job();
Logging.Setup();
Init();
Logging.LoggingEnabled(_config.guiItem.enableLog);
Utils.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
Logging.ClearLogs();
Init();
Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage);

View File

@@ -800,16 +800,15 @@ namespace v2rayN.Handler
return 0;
}
public static int DedupServerList(ref Config config, ref List<ProfileItem> lstProfile)
public static Tuple<int, int> DedupServerList(Config config, string subId)
{
List<ProfileItem> source = lstProfile;
bool keepOlder = config.guiItem.keepOlderDedupl;
var lstProfile = LazyConfig.Instance.ProfileItems(subId);
List<ProfileItem> lstKeep = new();
List<ProfileItem> lstRemove = new();
if (!keepOlder) source.Reverse(); // Remove the early items first
if (config.guiItem.keepOlderDedupl) lstProfile.Reverse();
foreach (ProfileItem item in source)
foreach (ProfileItem item in lstProfile)
{
if (!lstKeep.Exists(i => CompareProfileItem(i, item, false)))
{
@@ -822,7 +821,7 @@ namespace v2rayN.Handler
}
RemoveServer(config, lstRemove);
return lstKeep.Count;
return new Tuple<int, int>(lstProfile.Count, lstKeep.Count);
}
public static int AddServerCommon(ref Config config, ProfileItem profileItem, bool toFile = true)
@@ -956,7 +955,7 @@ namespace v2rayN.Handler
//exist sub items
if (isSub && !Utils.IsNullOrEmpty(subid))
{
var existItem = lstOriSub?.FirstOrDefault(t => CompareProfileItem(t, profileItem, true));
var existItem = lstOriSub?.FirstOrDefault(t => t.isSub == isSub && CompareProfileItem(t, profileItem, true));
if (existItem != null)
{
profileItem.indexId = existItem.indexId;

View File

@@ -1390,7 +1390,7 @@ namespace v2rayN.Handler
Utils.SaveLog(ex.Message, ex);
}
log(configCopy, ref v2rayConfig, false);
log(configCopy, ref v2rayConfig, true);
//routing(config, ref v2rayConfig);
//dns(configCopy, ref v2rayConfig);

View File

@@ -156,6 +156,7 @@ namespace v2rayN.Handler
if (Utils.IsNullOrEmpty(fileName))
{
string msg = string.Format(ResUI.NotFoundCore, Utils.GetBinPath("", coreInfo.coreType), string.Join(", ", coreInfo.coreExes.ToArray()), coreInfo.coreUrl);
Utils.SaveLog(msg);
ShowMsg(false, msg);
}
return fileName;
@@ -213,6 +214,7 @@ namespace v2rayN.Handler
}
catch (Exception ex)
{
Utils.SaveLog(Utils.ToJson(node));
Utils.SaveLog(ex.Message, ex);
string msg = ex.Message;
ShowMsg(true, msg);

View File

@@ -197,6 +197,18 @@ namespace v2rayN.Handler
{
dicQuery.Add("fp", Utils.UrlEncode(item.fingerprint));
}
if (!Utils.IsNullOrEmpty(item.publicKey))
{
dicQuery.Add("pbk", Utils.UrlEncode(item.publicKey));
}
if (!Utils.IsNullOrEmpty(item.shortId))
{
dicQuery.Add("sid", Utils.UrlEncode(item.shortId));
}
if (!Utils.IsNullOrEmpty(item.spiderX))
{
dicQuery.Add("spx", Utils.UrlEncode(item.spiderX));
}
dicQuery.Add("type", !Utils.IsNullOrEmpty(item.network) ? item.network : "tcp");
@@ -756,6 +768,10 @@ namespace v2rayN.Handler
item.sni = query["sni"] ?? "";
item.alpn = Utils.UrlDecode(query["alpn"] ?? "");
item.fingerprint = Utils.UrlDecode(query["fp"] ?? "");
item.publicKey = Utils.UrlDecode(query["pbk"] ?? "");
item.shortId = Utils.UrlDecode(query["sid"] ?? "");
item.spiderX = Utils.UrlDecode(query["spx"] ?? "");
item.network = query["type"] ?? "tcp";
switch (item.network)
{

View File

@@ -175,24 +175,20 @@ namespace v2rayN.Handler
foreach (var item in subItem)
{
if (item.enabled == false)
{
continue;
}
if (!Utils.IsNullOrEmpty(subId) && item.id != subId)
{
continue;
}
string id = item.id.TrimEx();
string url = item.url.TrimEx();
string userAgent = item.userAgent.TrimEx();
string hashCode = $"{item.remarks}->";
if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url))
if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url) || (!Utils.IsNullOrEmpty(subId) && item.id != subId))
{
//_updateFunc(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
continue;
}
if (item.enabled == false)
{
_updateFunc(false, $"{hashCode}{ResUI.MsgSkipSubscriptionUpdate}");
continue;
}
var downloadHandle = new DownloadHandle();
downloadHandle.Error += (sender2, args) =>

View File

@@ -103,8 +103,10 @@ namespace v2rayN.Mode
public bool enableSecurityProtocolTls13 { get; set; }
public int trayMenuServersLimit { get; set; } = 20;
public bool enableHWA { get; set; } = true;
public bool enableHWA { get; set; } = false;
public bool enableLog { get; set; } = true;
}
[Serializable]

View File

@@ -1446,6 +1446,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Updates are not enabled, skip this subscription 的本地化字符串。
/// </summary>
public static string MsgSkipSubscriptionUpdate {
get {
return ResourceManager.GetString("MsgSkipSubscriptionUpdate", resourceCulture);
}
}
/// <summary>
/// 查找类似 Start getting subscriptions 的本地化字符串。
/// </summary>
@@ -2995,6 +3004,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Please turn off when there is an abnormal disconnection 的本地化字符串。
/// </summary>
public static string TipDisplayLog {
get {
return ResourceManager.GetString("TipDisplayLog", resourceCulture);
}
}
/// <summary>
/// 查找类似 *Default value tcp 的本地化字符串。
/// </summary>

View File

@@ -1147,4 +1147,10 @@
<data name="SpeedtestingWait" xml:space="preserve">
<value>Waiting for testing</value>
</data>
<data name="TipDisplayLog" xml:space="preserve">
<value>Please turn off when there is an abnormal disconnection</value>
</data>
<data name="MsgSkipSubscriptionUpdate" xml:space="preserve">
<value>Updates are not enabled, skip this subscription</value>
</data>
</root>

View File

@@ -1147,4 +1147,10 @@
<data name="SpeedtestingWait" xml:space="preserve">
<value>等待测试中...</value>
</data>
<data name="TipDisplayLog" xml:space="preserve">
<value>当有异常断流时请关闭</value>
</data>
<data name="MsgSkipSubscriptionUpdate" xml:space="preserve">
<value>未启用更新,跳过此订阅</value>
</data>
</root>

View File

@@ -17,6 +17,13 @@ namespace v2rayN.Tool
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, fileTarget));
LogManager.Configuration = config;
}
public static void LoggingEnabled(bool enable)
{
if (!enable)
{
LogManager.SuspendLogging();
}
}
public static void ClearLogs()
{

View File

@@ -282,6 +282,8 @@ namespace v2rayN
.Replace(Environment.NewLine, "")
.Replace("\n", "")
.Replace("\r", "")
.Replace('_', '/')
.Replace('-', '+')
.Replace(" ", "");
if (plainText.Length % 4 > 0)
@@ -312,7 +314,7 @@ namespace v2rayN
}
catch (Exception ex)
{
SaveLog(ex.Message, ex);
//SaveLog(ex.Message, ex);
return 0;
}
}
@@ -324,7 +326,7 @@ namespace v2rayN
}
catch (Exception ex)
{
SaveLog(ex.Message, ex);
//SaveLog(ex.Message, ex);
return false;
}
}
@@ -337,7 +339,7 @@ namespace v2rayN
}
catch (Exception ex)
{
SaveLog(ex.Message, ex);
//SaveLog(ex.Message, ex);
return string.Empty;
}
}
@@ -778,7 +780,7 @@ namespace v2rayN
task.Settings.RunOnlyIfIdle = false;
task.Settings.IdleSettings.StopOnIdleEnd = false;
task.Settings.ExecutionTimeLimit = TimeSpan.Zero;
task.Triggers.Add(new LogonTrigger { UserId = logonUser, Delay = TimeSpan.FromMinutes(1) });
task.Triggers.Add(new LogonTrigger { UserId = logonUser, Delay = TimeSpan.FromSeconds(10) });
task.Principal.RunLevel = TaskRunLevel.Highest;
task.Actions.Add(new ExecAction(deamonFileName));
@@ -907,13 +909,13 @@ namespace v2rayN
/// <returns></returns>
public static string? GetClipboardData()
{
string strData = string.Empty;
string? strData = string.Empty;
try
{
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.UnicodeText))
{
strData = data.GetData(DataFormats.UnicodeText).ToString();
strData = data.GetData(DataFormats.UnicodeText)?.ToString();
}
return strData;
}
@@ -1150,17 +1152,23 @@ namespace v2rayN
public static void SaveLog(string strContent)
{
var logger = LogManager.GetLogger("Log1");
logger.Info(strContent);
if (LogManager.IsLoggingEnabled())
{
var logger = LogManager.GetLogger("Log1");
logger.Info(strContent);
}
}
public static void SaveLog(string strTitle, Exception ex)
{
var logger = LogManager.GetLogger("Log2");
logger.Debug($"{strTitle},{ex.Message}");
logger.Debug(ex.StackTrace);
if (ex?.InnerException != null)
if (LogManager.IsLoggingEnabled())
{
logger.Error(ex.InnerException);
var logger = LogManager.GetLogger("Log2");
logger.Debug($"{strTitle},{ex.Message}");
logger.Debug(ex.StackTrace);
if (ex?.InnerException != null)
{
logger.Error(ex.InnerException);
}
}
}

View File

@@ -971,11 +971,10 @@ namespace v2rayN.ViewModels
private void RemoveDuplicateServer()
{
int oldCount = _lstProfile.Count;
int newCount = ConfigHandler.DedupServerList(ref _config, ref _lstProfile);
var tuple = ConfigHandler.DedupServerList(_config, _subId);
RefreshServers();
Reload();
_noticeHandler?.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, oldCount, newCount));
_noticeHandler?.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2));
}
private void CopyServer()
{

View File

@@ -137,12 +137,19 @@
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbDisplayLog}" />
<ToggleButton
x:Name="togDisplayLog"
<StackPanel
Grid.Row="4"
Grid.Column="1"
Margin="4"
HorizontalAlignment="Left" />
Orientation="Horizontal">
<ToggleButton x:Name="togDisplayLog" HorizontalAlignment="Left" />
<TextBlock
Margin="8,0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TipDisplayLog}" />
</StackPanel>
<TextBlock
Grid.Row="5"
@@ -176,7 +183,7 @@
<Grid
Grid.Row="1"
Margin="16"
Margin="8"
HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />

View File

@@ -10,8 +10,8 @@
xmlns:resx="clr-namespace:v2rayN.Resx"
xmlns:vms="clr-namespace:v2rayN.ViewModels"
Title="{x:Static resx:ResUI.menuServers}"
Width="800"
Height="830"
Width="820"
Height="820"
x:TypeArguments="vms:AddServerViewModel"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
@@ -742,7 +742,7 @@
<Grid
Grid.Row="9"
Margin="16"
Margin="8"
HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />

View File

@@ -150,7 +150,7 @@
<Grid
Grid.Row="2"
Margin="16"
Margin="8"
HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150" />

View File

@@ -15,8 +15,8 @@
Title="v2rayN"
Width="900"
Height="700"
MinWidth="800"
MinHeight="600"
MinWidth="900"
MinHeight="700"
x:TypeArguments="vms:MainWindowViewModel"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
@@ -837,9 +837,10 @@
Height="Auto"
Background="{DynamicResource MaterialDesignLightBackground}"
BorderBrush="{DynamicResource MaterialDesignDarkBackground}"
BorderThickness="1">
BorderThickness="0"
CornerRadius="4">
<TextBlock
Margin="2"
Margin="8"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{DynamicResource MaterialDesignDarkBackground}"

View File

@@ -197,7 +197,7 @@ namespace v2rayN.Views
{
WindowState = WindowState.Minimized;
}
if (!_config.guiItem.enableHWA)
{
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
@@ -445,8 +445,15 @@ namespace v2rayN.Views
var item2 = (MyDGTextColumn)lstProfiles.Columns[k];
if (item2.ExName == item.Name)
{
item2.Width = item.Width;
item2.DisplayIndex = i + 1;
if (item.Width <= 0)
{
item2.Visibility = Visibility.Hidden;
}
else
{
item2.Width = item.Width;
item2.DisplayIndex = i + 1;
}
}
}
}
@@ -471,7 +478,7 @@ namespace v2rayN.Views
lvColumnItem.Add(new()
{
Name = item2.ExName,
Width = Convert.ToInt32(item2.ActualWidth),
Width = item2.Visibility == Visibility.Visible ? Convert.ToInt32(item2.ActualWidth) : 0,
Index = item2.DisplayIndex
});
}

View File

@@ -23,7 +23,7 @@
TextOptions.TextRenderingMode="Auto"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<DockPanel Margin="16">
<DockPanel Margin="8">
<Grid HorizontalAlignment="Center" DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
@@ -753,14 +753,14 @@
Width="300"
Margin="{StaticResource SettingItemMargin}"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="18"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsEnableHWA}"/>
Text="{x:Static resx:ResUI.TbSettingsEnableHWA}" />
<ToggleButton
x:Name="togEnableHWA"
Grid.Row="18"

View File

@@ -134,7 +134,7 @@
</Grid>
<Grid
Margin="16"
Margin="8"
HorizontalAlignment="Center"
DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>

View File

@@ -73,7 +73,7 @@
</ToolBarTray>
<Grid
Margin="16"
Margin="8"
HorizontalAlignment="Center"
DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>

View File

@@ -114,7 +114,7 @@
</ToolBarTray>
<Grid
Margin="16"
Margin="8"
HorizontalAlignment="Center"
DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>

View File

@@ -162,7 +162,7 @@
</Grid>
<Grid
Grid.Row="1"
Margin="16"
Margin="8"
HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />

View File

@@ -10,11 +10,11 @@
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
<Copyright>Copyright © 2017-2023 (GPLv3)</Copyright>
<FileVersion>6.18</FileVersion>
<FileVersion>6.20</FileVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Downloader" Version="3.0.3" />
<PackageReference Include="Downloader" Version="3.0.4" />
<PackageReference Include="MaterialDesignThemes" Version="4.7.1" />
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />