mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-29 22:36:20 +00:00
make Tun button shown when v2rayN starts without admin permission, and ask for permission for sing_box.exe when tun button is clicked
This commit is contained in:
parent
5ceb638edf
commit
96e96007eb
4 changed files with 14 additions and 8 deletions
|
@ -40,7 +40,7 @@ namespace v2rayN.Base
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public bool Start()
|
||||||
{
|
{
|
||||||
var socksPort = LazyConfig.Instance.GetLocalPort(Global.InboundSocks);
|
var socksPort = LazyConfig.Instance.GetLocalPort(Global.InboundSocks);
|
||||||
|
|
||||||
|
@ -58,10 +58,11 @@ namespace v2rayN.Base
|
||||||
CoreStop();
|
CoreStop();
|
||||||
if (Init() == false)
|
if (Init() == false)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
CoreStart();
|
return CoreStart();
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
|
@ -200,14 +201,14 @@ namespace v2rayN.Base
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CoreStart()
|
private bool CoreStart()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string fileName = CoreFindexe();
|
string fileName = CoreFindexe();
|
||||||
if (fileName == "")
|
if (fileName == "")
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
var showWindow = _config.tunModeItem.showWindow;
|
var showWindow = _config.tunModeItem.showWindow;
|
||||||
Process p = new Process
|
Process p = new Process
|
||||||
|
@ -239,10 +240,13 @@ namespace v2rayN.Base
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.processJob.AddProcess(p.Handle);
|
Global.processJob.AddProcess(p.Handle);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
_isRunning = false;
|
||||||
Utils.SaveLog(ex.Message, ex);
|
Utils.SaveLog(ex.Message, ex);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1481,7 +1481,7 @@ namespace v2rayN.ViewModels
|
||||||
{
|
{
|
||||||
if (EnableTun)
|
if (EnableTun)
|
||||||
{
|
{
|
||||||
TunHandler.Instance.Start();
|
EnableTun = TunHandler.Instance.Start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -359,7 +359,8 @@
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
x:Name="togEnableTun"
|
x:Name="togEnableTun"
|
||||||
Margin="4"
|
Margin="4"
|
||||||
HorizontalAlignment="Left" />
|
HorizontalAlignment="Left"
|
||||||
|
IsChecked="{Binding EnableTun}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel
|
<StackPanel
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace v2rayN.Views
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewModel = new MainWindowViewModel(MainSnackbar.MessageQueue!, UpdateViewHandler);
|
ViewModel = new MainWindowViewModel(MainSnackbar.MessageQueue!, UpdateViewHandler);
|
||||||
|
this.DataContext = ViewModel;
|
||||||
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
|
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
|
||||||
|
|
||||||
Global.Languages.ForEach(it =>
|
Global.Languages.ForEach(it =>
|
||||||
|
@ -181,7 +182,7 @@ namespace v2rayN.Views
|
||||||
var IsAdministrator = Utils.IsAdministrator();
|
var IsAdministrator = Utils.IsAdministrator();
|
||||||
this.Title = $"{Utils.GetVersion()} - {(IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";
|
this.Title = $"{Utils.GetVersion()} - {(IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";
|
||||||
|
|
||||||
spEnableTun.Visibility = IsAdministrator ? Visibility.Visible : Visibility.Collapsed;
|
//spEnableTun.Visibility = IsAdministrator ? Visibility.Visible : Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Event
|
#region Event
|
||||||
|
|
Loading…
Reference in a new issue