Skip to content

Commit

Permalink
Merge pull request #4621 from yscjr/master
Browse files Browse the repository at this point in the history
修改修改非管理员模式下tun模式启动逻辑;缩短自动隐藏时间
  • Loading branch information
2dust authored Jan 14, 2024
2 parents 726d9d4 + 6d73857 commit 75435b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
11 changes: 0 additions & 11 deletions v2rayN/v2rayN/Sample/tun_singbox_rules
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[
{
"protocol": [ "dns" ],
"outbound": "dns_out"
},
{
"network": "udp",
"port": [
Expand All @@ -20,12 +16,5 @@
"ff00::/8"
],
"outbound": "block"
},
{
"source_ip_cidr": [
"224.0.0.0/3",
"ff00::/8"
],
"outbound": "block"
}
]
12 changes: 9 additions & 3 deletions v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1390,8 +1390,7 @@ private void RebootAsAdmin()
{
Process.Start(startInfo);
MyAppExit(false);
}
catch { }
} catch { }
}

private void ImportOldGuiConfig()
Expand Down Expand Up @@ -1621,6 +1620,13 @@ private void DoEnableTun(bool c)
if (_config.tunModeItem.enableTun != EnableTun)
{
_config.tunModeItem.enableTun = EnableTun;
// 非管理员运行时tun模式开启逻辑修改
if (EnableTun && !Utils.IsAdministrator())
{
RebootAsAdmin();
_config.tunModeItem.enableTun = EnableTun = false;
return;
}
Reload();
}
}
Expand Down Expand Up @@ -1839,7 +1845,7 @@ private void AutoHideStartup()
if (_config.uiItem.autoHideStartup)
{
Observable.Range(1, 1)
.Delay(TimeSpan.FromSeconds(2))
.Delay(TimeSpan.FromSeconds(0.5))
.Subscribe(x =>
{
Application.Current.Dispatcher.Invoke(() =>
Expand Down
2 changes: 0 additions & 2 deletions v2rayN/v2rayN/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ public MainWindow()
var IsAdministrator = Utils.IsAdministrator();
this.Title = $"{Utils.GetVersion()} - {(IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";

spEnableTun.Visibility = IsAdministrator ? Visibility.Visible : Visibility.Collapsed;

//if (_config.uiItem.autoHideStartup)
//{
// WindowState = WindowState.Minimized;
Expand Down

0 comments on commit 75435b8

Please sign in to comment.