diff options
Diffstat (limited to 'src/features/serviceProxy/index.js')
-rw-r--r-- | src/features/serviceProxy/index.js | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/features/serviceProxy/index.js b/src/features/serviceProxy/index.js deleted file mode 100644 index b9320cda9..000000000 --- a/src/features/serviceProxy/index.js +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | import { autorun, observable } from 'mobx'; | ||
2 | import { session } from '@electron/remote'; | ||
3 | |||
4 | const debug = require('debug')('Ferdi:feature:serviceProxy'); | ||
5 | |||
6 | export const config = observable({ | ||
7 | isEnabled: true, | ||
8 | }); | ||
9 | |||
10 | export default function init(stores) { | ||
11 | debug('Initializing `serviceProxy` feature'); | ||
12 | |||
13 | autorun(() => { | ||
14 | config.isEnabled = true; | ||
15 | |||
16 | const services = stores.services.enabled; | ||
17 | const proxySettings = stores.settings.proxy; | ||
18 | |||
19 | debug('Service Proxy autorun'); | ||
20 | |||
21 | for (const service of services) { | ||
22 | const s = session.fromPartition(`persist:service-${service.id}`); | ||
23 | |||
24 | if (config.isEnabled) { | ||
25 | const serviceProxyConfig = proxySettings[service.id]; | ||
26 | |||
27 | if (serviceProxyConfig && serviceProxyConfig.isEnabled && serviceProxyConfig.host) { | ||
28 | const proxyHost = `${serviceProxyConfig.host}${serviceProxyConfig.port ? `:${serviceProxyConfig.port}` : ''}`; | ||
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 | } | ||
35 | } | ||
36 | } | ||
37 | }); | ||
38 | } | ||