Skip to content

Commit

Permalink
Reload tabs based on custom proxy actions (see commit details)
Browse files Browse the repository at this point in the history
- add
- remove
- toggle
- toggle DNS
- exclude/remove-exclusion
  • Loading branch information
ruihildt committed Nov 25, 2024
1 parent 8ff513d commit 18d4a85
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/composables/useSocksProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { updateCurrentTabProxyBadge } from '@/helpers/proxyBadge';
import useActiveTab from '@/composables/useActiveTab';
import useConnection from '@/composables/useConnection';
import useStore from '@/composables/useStore';
import { reloadMatchingTabs } from '@/helpers/tabs';

const baseConfig: Partial<ProxyInfo> = {
port: 1080,
Expand Down Expand Up @@ -46,16 +47,19 @@ const toggleCurrentHostProxy = () => {
hostProxiesDetails.value[activeTabHost.value].socksEnabled = !currentHostProxyEnabled.value;
updateCurrentTabProxyBadge();
reloadOptions();
reloadMatchingTabs(activeTabHost.value);
};

const toggleCustomProxy = (host: string) => {
hostProxiesDetails.value[host].socksEnabled = !hostProxiesDetails.value[host].socksEnabled;
updateCurrentTabProxyBadge();
reloadOptions();
reloadMatchingTabs(host);
};
const toggleCustomProxyDNS = (host: string) => {
hostProxiesDetails.value[host].proxyDNS = !hostProxiesDetails.value[host].proxyDNS;
updateCurrentTabProxyBadge();
reloadMatchingTabs(host);
};

const toggleGlobalProxyDNS = () => {
Expand All @@ -69,6 +73,7 @@ const toggleCurrentHostProxyDNS = () => {
hostProxiesDetails.value[activeTabHost.value].proxyDNS = updatedCurrentHostProxyDNS;
hostProxies.value[activeTabHost.value].proxyDNS = updatedCurrentHostProxyDNS;
updateCurrentTabProxyBadge();
reloadMatchingTabs(activeTabHost.value);
};

const setGlobalProxy = ({
Expand Down Expand Up @@ -133,6 +138,7 @@ const setCurrentHostProxy = (
hostProxiesDetails.value = { ...hostProxiesDetails.value, [host]: newHostProxyDetails };

reloadOptions();
reloadMatchingTabs(host);
};

const removeCustomProxy = (host: string) => {
Expand All @@ -141,6 +147,7 @@ const removeCustomProxy = (host: string) => {
updateConnection();
updateCurrentTabProxyBadge();
reloadOptions();
reloadMatchingTabs(host);
};

const removeGlobalProxy = () => {
Expand All @@ -154,12 +161,14 @@ const allowProxy = (host: string) => {
excludedHosts.value = excludedHosts.value.filter((excluded) => excluded !== host);
updateCurrentTabProxyBadge();
reloadOptions();
reloadMatchingTabs(host);
};

const neverProxyHost = (host: string) => {
excludedHosts.value = [...excludedHosts.value, host];
updateCurrentTabProxyBadge();
reloadOptions();
reloadMatchingTabs(host);
};

const useSocksProxy = () => {
Expand Down

0 comments on commit 18d4a85

Please sign in to comment.