diff options
author | 2021-09-08 23:44:24 +0530 | |
---|---|---|
committer | 2021-09-08 23:52:06 +0530 | |
commit | 4960927289b88bcacbf7af2baa9c551deac64072 (patch) | |
tree | 4a338c63d2d42e06d37e6f01d14c5f2048c76ace /src/features/serviceProxy/index.js | |
parent | fix: U2F devices not recognised in snapcraft image (#1892) (diff) | |
download | ferdium-app-4960927289b88bcacbf7af2baa9c551deac64072.tar.gz ferdium-app-4960927289b88bcacbf7af2baa9c551deac64072.tar.zst ferdium-app-4960927289b88bcacbf7af2baa9c551deac64072.zip |
Revert "chore: proxy feature is always turned on: remove 'enabled' flag"
This reverts commit 2772cb2e3e75f16b3dc96a2441518ed0772e3ba1.
Diffstat (limited to 'src/features/serviceProxy/index.js')
-rw-r--r-- | src/features/serviceProxy/index.js | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/features/serviceProxy/index.js b/src/features/serviceProxy/index.js index 125b4729f..eb7116651 100644 --- a/src/features/serviceProxy/index.js +++ b/src/features/serviceProxy/index.js | |||
@@ -1,26 +1,37 @@ | |||
1 | import { autorun } from 'mobx'; | 1 | import { autorun, observable } from 'mobx'; |
2 | import { session } from '@electron/remote'; | 2 | import { session } from '@electron/remote'; |
3 | 3 | ||
4 | const debug = require('debug')('Ferdi:feature:serviceProxy'); | 4 | const debug = require('debug')('Ferdi:feature:serviceProxy'); |
5 | 5 | ||
6 | export const config = observable({ | ||
7 | isEnabled: true, | ||
8 | }); | ||
9 | |||
6 | export default function init(stores) { | 10 | export default function init(stores) { |
7 | debug('Initializing `serviceProxy` feature'); | 11 | debug('Initializing `serviceProxy` feature'); |
8 | 12 | ||
9 | autorun(() => { | 13 | autorun(() => { |
14 | config.isEnabled = true; | ||
15 | |||
10 | const services = stores.services.enabled; | 16 | const services = stores.services.enabled; |
11 | const proxySettings = stores.settings.proxy; | 17 | const proxySettings = stores.settings.proxy; |
12 | 18 | ||
13 | debug('Service Proxy autorun'); | 19 | debug('Service Proxy autorun'); |
14 | 20 | ||
15 | services.forEach((service) => { | 21 | services.forEach((service) => { |
16 | const serviceProxyConfig = proxySettings[service.id]; | 22 | const s = session.fromPartition(`persist:service-${service.id}`); |
17 | if (serviceProxyConfig && serviceProxyConfig.isEnabled && serviceProxyConfig.host) { | 23 | |
18 | const proxyHost = `${serviceProxyConfig.host}${serviceProxyConfig.port ? `:${serviceProxyConfig.port}` : ''}`; | 24 | if (config.isEnabled) { |
19 | debug(`Setting proxy config from service settings for "${service.name}" (${service.id}) to`, proxyHost); | 25 | const serviceProxyConfig = proxySettings[service.id]; |
20 | 26 | ||
21 | session.fromPartition(`persist:service-${service.id}`).setProxy({ proxyRules: proxyHost }, () => { | 27 | if (serviceProxyConfig && serviceProxyConfig.isEnabled && serviceProxyConfig.host) { |
22 | debug(`Using proxy "${proxyHost}" for "${service.name}" (${service.id})`); | 28 | const proxyHost = `${serviceProxyConfig.host}${serviceProxyConfig.port ? `:${serviceProxyConfig.port}` : ''}`; |
23 | }); | 29 | debug(`Setting proxy config from service settings for "${service.name}" (${service.id}) to`, proxyHost); |
30 | |||
31 | s.setProxy({ proxyRules: proxyHost }, () => { | ||
32 | debug(`Using proxy "${proxyHost}" for "${service.name}" (${service.id})`); | ||
33 | }); | ||
34 | } | ||
24 | } | 35 | } |
25 | }); | 36 | }); |
26 | }); | 37 | }); |