diff --git a/v2rayN/v2rayN/Handler/TunHandler.cs b/v2rayN/v2rayN/Handler/TunHandler.cs
index 2f0746fa..4702f187 100644
--- a/v2rayN/v2rayN/Handler/TunHandler.cs
+++ b/v2rayN/v2rayN/Handler/TunHandler.cs
@@ -40,7 +40,7 @@ namespace v2rayN.Base
});
}
- public void Start()
+ public bool Start()
{
var socksPort = LazyConfig.Instance.GetLocalPort(Global.InboundSocks);
@@ -58,10 +58,11 @@ namespace v2rayN.Base
CoreStop();
if (Init() == false)
{
- return;
+ return false;
}
- CoreStart();
+ return CoreStart();
}
+ return false;
}
public void Stop()
@@ -200,14 +201,14 @@ namespace v2rayN.Base
return fileName;
}
- private void CoreStart()
+ private bool CoreStart()
{
try
{
string fileName = CoreFindexe();
if (fileName == "")
{
- return;
+ return false;
}
var showWindow = _config.tunModeItem.showWindow;
Process p = new Process
@@ -239,10 +240,13 @@ namespace v2rayN.Base
}
Global.processJob.AddProcess(p.Handle);
+ return true;
}
catch (Exception ex)
{
+ _isRunning = false;
Utils.SaveLog(ex.Message, ex);
+ return false;
}
}
diff --git a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs
index 38400250..346fbbb9 100644
--- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs
+++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs
@@ -1481,7 +1481,7 @@ namespace v2rayN.ViewModels
{
if (EnableTun)
{
- TunHandler.Instance.Start();
+ EnableTun = TunHandler.Instance.Start();
}
else
{
diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml b/v2rayN/v2rayN/Views/MainWindow.xaml
index dc525929..d1f992d0 100644
--- a/v2rayN/v2rayN/Views/MainWindow.xaml
+++ b/v2rayN/v2rayN/Views/MainWindow.xaml
@@ -359,7 +359,8 @@
+ HorizontalAlignment="Left"
+ IsChecked="{Binding EnableTun}"/>
ViewModel, typeof(MainWindowViewModel));
Global.Languages.ForEach(it =>
@@ -181,7 +182,7 @@ namespace v2rayN.Views
var IsAdministrator = Utils.IsAdministrator();
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