Skip to content

Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic

#97 - Added Direct connection Hide option

AnoF-Cybered4504451e8f
diff --git a/Windows/gui/Resources/Resources.Designer.cs b/Windows/gui/Resources/Resources.Designer.cs
index c6de3e7..9756baa 100644
--- a/Windows/gui/Resources/Resources.Designer.cs
+++ b/Windows/gui/Resources/Resources.Designer.cs
@@ -104,6 +104,12 @@ namespace ProxyBridge.GUI.Resources {
}
}
+ internal static string MenuHideDirectConnections {
+ get {
+ return ResourceManager.GetString("MenuHideDirectConnections", resourceCulture);
+ }
+ }
+
internal static string MenuSettings {
get {
return ResourceManager.GetString("MenuSettings", resourceCulture);
diff --git a/Windows/gui/Resources/Resources.resx b/Windows/gui/Resources/Resources.resx
index c3f2519..379e931 100644
--- a/Windows/gui/Resources/Resources.resx
+++ b/Windows/gui/Resources/Resources.resx
@@ -32,6 +32,9 @@
<data name="MenuEnableTrafficLogging" xml:space="preserve">
<value>Enable Traffic Logging</value>
</data>
+ <data name="MenuHideDirectConnections" xml:space="preserve">
+ <value>Hide Direct Connections</value>
+ </data>
<data name="MenuSettings" xml:space="preserve">
<value>Settings</value>
</data>
diff --git a/Windows/gui/Resources/Resources.zh.resx b/Windows/gui/Resources/Resources.zh.resx
index 16e9c96..8babddd 100644
--- a/Windows/gui/Resources/Resources.zh.resx
+++ b/Windows/gui/Resources/Resources.zh.resx
@@ -32,6 +32,9 @@
<data name="MenuEnableTrafficLogging" xml:space="preserve">
<value>启用流量日志</value>
</data>
+ <data name="MenuHideDirectConnections" xml:space="preserve">
+ <value>隐藏直连连接</value>
+ </data>
<data name="MenuSettings" xml:space="preserve">
<value>设置</value>
</data>
diff --git a/Windows/gui/Services/Loc.cs b/Windows/gui/Services/Loc.cs
index 42ddffd..1d7a099 100644
--- a/Windows/gui/Services/Loc.cs
+++ b/Windows/gui/Services/Loc.cs
@@ -43,6 +43,7 @@ public class Loc : INotifyPropertyChanged
public string MenuDnsViaProxy => Resources.Resources.MenuDnsViaProxy;
public string MenuLocalhostViaProxy => Resources.Resources.MenuLocalhostViaProxy;
public string MenuEnableTrafficLogging => Resources.Resources.MenuEnableTrafficLogging;
+ public string MenuHideDirectConnections => Resources.Resources.MenuHideDirectConnections;
public string MenuSettings => Resources.Resources.MenuSettings;
public string MenuCloseToTray => Resources.Resources.MenuCloseToTray;
public string MenuRunAtStartup => Resources.Resources.MenuRunAtStartup;
diff --git a/Windows/gui/Services/ProfileManager.cs b/Windows/gui/Services/ProfileManager.cs
index 66508b7..6868d49 100644
--- a/Windows/gui/Services/ProfileManager.cs
+++ b/Windows/gui/Services/ProfileManager.cs
@@ -35,6 +35,7 @@ public class ProxyProfile
public bool DnsViaProxy { get; set; } = true;
public bool LocalhostViaProxy { get; set; } = false;
public bool IsTrafficLoggingEnabled { get; set; } = true;
+ public bool HideDirectConnections { get; set; } = false;
public string Language { get; set; } = "en";
public bool CloseToTray { get; set; } = true;
public List<ProxyConfigEntry> ProxyConfigs { get; set; } = new();
diff --git a/Windows/gui/ViewModels/MainWindowViewModel.cs b/Windows/gui/ViewModels/MainWindowViewModel.cs
index 783cfd9..8fad1a9 100644
--- a/Windows/gui/ViewModels/MainWindowViewModel.cs
+++ b/Windows/gui/ViewModels/MainWindowViewModel.cs
@@ -74,6 +74,9 @@ public class MainWindowViewModel : ViewModelBase
if (!_isTrafficLoggingEnabled)
return;
+ if (_hideDirectConnections && proxyInfo.StartsWith("Direct"))
+ return;
+
if (_connectionLogTimer?.IsEnabled == false)
_connectionLogTimer.Start();
@@ -309,6 +312,17 @@ public class MainWindowViewModel : ViewModelBase
}
}
+ private bool _hideDirectConnections = false;
+ public bool HideDirectConnections
+ {
+ get => _hideDirectConnections;
+ set
+ {
+ if (SetProperty(ref _hideDirectConnections, value))
+ SaveCurrentProfileAsync();
+ }
+ }
+
private bool _isTrafficLoggingEnabled = true;
public bool IsTrafficLoggingEnabled
{
@@ -385,6 +399,7 @@ public class MainWindowViewModel : ViewModelBase
public ICommand ToggleDnsViaProxyCommand { get; }
public ICommand ToggleLocalhostViaProxyCommand { get; }
public ICommand ToggleTrafficLoggingCommand { get; }
+ public ICommand ToggleHideDirectConnectionsCommand { get; }
public ICommand ToggleCloseToTrayCommand { get; }
public ICommand ToggleStartWithWindowsCommand { get; }
public ICommand CloseDialogCommand { get; }
@@ -501,6 +516,7 @@ public class MainWindowViewModel : ViewModelBase
ToggleDnsViaProxyCommand = new RelayCommand(() => { DnsViaProxy = !DnsViaProxy; });
ToggleLocalhostViaProxyCommand = new RelayCommand(() => { LocalhostViaProxy = !LocalhostViaProxy; });
ToggleTrafficLoggingCommand = new RelayCommand(() => { IsTrafficLoggingEnabled = !IsTrafficLoggingEnabled; });
+ ToggleHideDirectConnectionsCommand = new RelayCommand(() => { HideDirectConnections = !HideDirectConnections; });
ToggleCloseToTrayCommand = new RelayCommand(() =>
{
@@ -890,6 +906,9 @@ public class MainWindowViewModel : ViewModelBase
_isTrafficLoggingEnabled = profile.IsTrafficLoggingEnabled;
OnPropertyChanged(nameof(IsTrafficLoggingEnabled));
+ _hideDirectConnections = profile.HideDirectConnections;
+ OnPropertyChanged(nameof(HideDirectConnections));
+
if (!string.IsNullOrWhiteSpace(profile.Language))
{
_currentLanguage = profile.Language;
@@ -979,6 +998,9 @@ public class MainWindowViewModel : ViewModelBase
ProxyBridgeService.SetTrafficLoggingEnabled(profile.IsTrafficLoggingEnabled);
}
+ _hideDirectConnections = profile.HideDirectConnections;
+ OnPropertyChanged(nameof(HideDirectConnections));
+
if (!string.IsNullOrWhiteSpace(profile.Language))
{
_currentLanguage = profile.Language;
@@ -1069,6 +1091,7 @@ public class MainWindowViewModel : ViewModelBase
DnsViaProxy = _dnsViaProxy,
LocalhostViaProxy = _localhostViaProxy,
IsTrafficLoggingEnabled = _isTrafficLoggingEnabled,
+ HideDirectConnections = _hideDirectConnections,
Language = _currentLanguage,
CloseToTray = _closeToTray,
ProxyConfigs = ProxyConfigs.Select(pc => new ProxyConfigEntry
diff --git a/Windows/gui/Views/MainWindow.axaml b/Windows/gui/Views/MainWindow.axaml
index fc8db25..002bd26 100644
--- a/Windows/gui/Views/MainWindow.axaml
+++ b/Windows/gui/Views/MainWindow.axaml
@@ -213,6 +213,14 @@
Margin="0"/>
</MenuItem.Icon>
</MenuItem>
+ <MenuItem Header="{Binding Loc.MenuHideDirectConnections}"
+ Command="{Binding ToggleHideDirectConnectionsCommand}">
+ <MenuItem.Icon>
+ <CheckBox IsChecked="{Binding HideDirectConnections}"
+ IsHitTestVisible="False"
+ Margin="0"/>
+ </MenuItem.Icon>
+ </MenuItem>
<MenuItem Header="{Binding Loc.MenuDnsViaProxy}"
Command="{Binding ToggleDnsViaProxyCommand}">
<MenuItem.Icon>