Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic
C ccybersecurityhttp3httpproxylinuxlinux-proxymacosmacos-appmacos-proxyproxifierproxifier-alternativeproxyclienttcpthick-clientudpwindivertwindows
optimized search /filter - search is speedup with less memory usage
Sourav Kalal5cdcd5efe0c7
diff --git a/Windows/gui/ViewModels/MainWindowViewModel.cs b/Windows/gui/ViewModels/MainWindowViewModel.csindex c477bd3..bba0c32 100644--- a/Windows/gui/ViewModels/MainWindowViewModel.cs+++ b/Windows/gui/ViewModels/MainWindowViewModel.cs@@ -175,8 +175,11 @@ public class MainWindowViewModel : ViewModelBaseget => _connectionsLog;set{- SetProperty(ref _connectionsLog, value);- FilterConnectionsLog();+ if (SetProperty(ref _connectionsLog, value))+ {+ if (string.IsNullOrWhiteSpace(_connectionsSearchText))+ FilteredConnectionsLog = _connectionsLog;+ }}}@@ -185,29 +188,44 @@ public class MainWindowViewModel : ViewModelBaseget => _activityLog;set{- SetProperty(ref _activityLog, value);- FilterActivityLog();+ if (SetProperty(ref _activityLog, value))+ {+ if (string.IsNullOrWhiteSpace(_activitySearchText))+ FilteredActivityLog = _activityLog;+ }}}+++ public bool IsProxyRulesDialogOpen+ {+ get => _isProxyRulesDialogOpen;+ set => SetProperty(ref _isProxyRulesDialogOpen, value);+ }++ public bool IsProxySettingsDialogOpen+ {+ get => _isProxySettingsDialogOpen;+ set => SetProperty(ref _isProxySettingsDialogOpen, value);+ }++ public bool IsAddRuleViewOpen+ {+ get => _isAddRuleViewOpen;+ set => SetProperty(ref _isAddRuleViewOpen, value);+ }+public string ConnectionsSearchText{get => _connectionsSearchText;- set- {- SetProperty(ref _connectionsSearchText, value);- FilterConnectionsLog();- }+ set => SetProperty(ref _connectionsSearchText, value);}public string ActivitySearchText{get => _activitySearchText;- set- {- SetProperty(ref _activitySearchText, value);- FilterActivityLog();- }+ set => SetProperty(ref _activitySearchText, value);}public string FilteredConnectionsLog@@ -222,24 +240,6 @@ public class MainWindowViewModel : ViewModelBaseset => SetProperty(ref _filteredActivityLog, value);}- public bool IsProxyRulesDialogOpen- {- get => _isProxyRulesDialogOpen;- set => SetProperty(ref _isProxyRulesDialogOpen, value);- }-- public bool IsProxySettingsDialogOpen- {- get => _isProxySettingsDialogOpen;- set => SetProperty(ref _isProxySettingsDialogOpen, value);- }-- public bool IsAddRuleViewOpen- {- get => _isAddRuleViewOpen;- set => SetProperty(ref _isAddRuleViewOpen, value);- }-public string NewProcessName{get => _newProcessName;@@ -305,6 +305,8 @@ public class MainWindowViewModel : ViewModelBasepublic ICommand CloseDialogCommand { get; }public ICommand ClearConnectionsLogCommand { get; }public ICommand ClearActivityLogCommand { get; }+ public ICommand SearchConnectionsCommand { get; }+ public ICommand SearchActivityCommand { get; }public ICommand AddRuleCommand { get; }public ICommand SaveNewRuleCommand { get; }public ICommand CancelAddRuleCommand { get; }@@ -453,11 +455,25 @@ public class MainWindowViewModel : ViewModelBaseClearConnectionsLogCommand = new RelayCommand(() =>{ConnectionsLog = "";+ ConnectionsSearchText = "";+ FilteredConnectionsLog = "";});ClearActivityLogCommand = new RelayCommand(() =>{ActivityLog = "ProxyBridge initialized successfully\n";+ ActivitySearchText = "";+ FilteredActivityLog = "ProxyBridge initialized successfully\n";+ });++ SearchConnectionsCommand = new RelayCommand(() =>+ {+ FilteredConnectionsLog = FilterLog(_connectionsLog, _connectionsSearchText);+ });++ SearchActivityCommand = new RelayCommand(() =>+ {+ FilteredActivityLog = FilterLog(_activityLog, _activitySearchText);});AddRuleCommand = new RelayCommand(() =>@@ -527,33 +543,7 @@ public class MainWindowViewModel : ViewModelBaseActivityLog += $"[{DateTime.Now:HH:mm:ss}] {_loc.LogLanguageChanged}: {languageCode}\n";}- private void FilterConnectionsLog()- {- if (string.IsNullOrWhiteSpace(_connectionsSearchText))- {- FilteredConnectionsLog = _connectionsLog;- }- else- {- var lines = _connectionsLog.Split('\n', StringSplitOptions.RemoveEmptyEntries);- var filtered = lines.Where(line => line.Contains(_connectionsSearchText, StringComparison.OrdinalIgnoreCase));- FilteredConnectionsLog = string.Join('\n', filtered) + (filtered.Any() ? "\n" : "");- }- }- private void FilterActivityLog()- {- if (string.IsNullOrWhiteSpace(_activitySearchText))- {- FilteredActivityLog = _activityLog;- }- else- {- var lines = _activityLog.Split('\n', StringSplitOptions.RemoveEmptyEntries);- var filtered = lines.Where(line => line.Contains(_activitySearchText, StringComparison.OrdinalIgnoreCase));- FilteredActivityLog = string.Join('\n', filtered) + (filtered.Any() ? "\n" : "");- }- }private void CloseDialogs(){@@ -597,6 +587,26 @@ public class MainWindowViewModel : ViewModelBasecatch { }}+ private string FilterLog(string log, string searchText)+ {+ if (string.IsNullOrWhiteSpace(searchText))+ return log;++ var sb = new StringBuilder(log.Length / 2);+ var lines = log.Split('\n');++ foreach (var line in lines)+ {+ if (line.Contains(searchText, StringComparison.OrdinalIgnoreCase))+ {+ sb.Append(line);+ sb.Append('\n');+ }+ }++ return sb.ToString();+ }+private void LoadConfiguration(){trydiff --git a/Windows/gui/Views/MainWindow.axaml b/Windows/gui/Views/MainWindow.axamlindex dc9b46b..e29cbdd 100644--- a/Windows/gui/Views/MainWindow.axaml+++ b/Windows/gui/Views/MainWindow.axaml@@ -250,17 +250,20 @@<DockPanel><!-- Search and Clear Bar --><Border DockPanel.Dock="Top" Background="#FF1E1E1E" Padding="8" BorderBrush="#FF3F3F46" BorderThickness="0,0,0,1">- <Grid ColumnDefinitions="*,Auto,Auto">+ <Grid ColumnDefinitions="*,Auto"><TextBox Grid.Column="0"Text="{Binding ConnectionsSearchText}"- Watermark="{Binding Loc.SearchConnectionsPlaceholder}"- Margin="0,0,8,0"/>+ Watermark="Search connections (press Enter)..."+ Margin="0,0,8,0">+ <TextBox.KeyBindings>+ <KeyBinding Gesture="Enter" Command="{Binding SearchConnectionsCommand}"/>+ </TextBox.KeyBindings>+ </TextBox><Button Grid.Column="1"Content="{Binding Loc.ButtonClear}"Classes="secondary"Command="{Binding ClearConnectionsLogCommand}"- Padding="12,6"- Margin="0,0,8,0"/>+ Padding="12,6"/></Grid></Border>@@ -283,17 +286,20 @@<DockPanel><!-- Search and Clear Bar --><Border DockPanel.Dock="Top" Background="#FF1E1E1E" Padding="8" BorderBrush="#FF3F3F46" BorderThickness="0,0,0,1">- <Grid ColumnDefinitions="*,Auto,Auto">+ <Grid ColumnDefinitions="*,Auto"><TextBox Grid.Column="0"Text="{Binding ActivitySearchText}"- Watermark="{Binding Loc.SearchActivityPlaceholder}"- Margin="0,0,8,0"/>+ Watermark="Search activity (press Enter)..."+ Margin="0,0,8,0">+ <TextBox.KeyBindings>+ <KeyBinding Gesture="Enter" Command="{Binding SearchActivityCommand}"/>+ </TextBox.KeyBindings>+ </TextBox><Button Grid.Column="1"Content="{Binding Loc.ButtonClear}"Classes="secondary"Command="{Binding ClearActivityLogCommand}"- Padding="12,6"- Margin="0,0,8,0"/>+ Padding="12,6"/></Grid></Border>