Skip to content
Permalink
Browse files

fix(Service Proxies): Fix proxy setting rehydration

  • Loading branch information...
adlk committed Oct 2, 2019
1 parent 8405b09 commit e2126a60ad287e76a24c44242b80699e49e8fb0e
Showing with 36 additions and 23 deletions.
  1. +1 −16 src/index.js
  2. +34 −7 src/models/Service.js
  3. +1 −0 src/stores/ServicesStore.js
@@ -331,22 +331,7 @@ app.on('login', (event, webContents, request, authInfo, callback) => {
debug('browser login event', authInfo);
event.preventDefault();

if (authInfo.isProxy && authInfo.scheme === 'basic') {
debug('Sending service echo ping');
webContents.send('get-service-id');

ipcMain.once('service-id', (e, id) => {
debug('Received service id', id);

const ps = proxySettings.get(id);
if (ps) {
debug('Sending proxy auth callback for service', id);
callback(ps.user, ps.password);
} else {
debug('No proxy auth config found for', id);
}
});
} else if (authInfo.scheme === 'basic') {
if (!authInfo.isProxy && authInfo.scheme === 'basic') {
debug('basic auth handler', authInfo);
basicAuthHandler(mainWindow, authInfo);
}
@@ -188,19 +188,24 @@ export default class Service {
return userAgent;
}

initializeWebViewEvents({ handleIPCMessage, openWindow }) {
initializeWebViewEvents({ handleIPCMessage, openWindow, stores }) {
const webContents = this.webview.getWebContents();

this.webview.addEventListener('ipc-message', e => handleIPCMessage({
serviceId: this.id,
channel: e.channel,
args: e.args,
}));

this.webview.addEventListener('new-window', (event, url, frameName, options) => openWindow({
event,
url,
frameName,
options,
}));
this.webview.addEventListener('new-window', (event, url, frameName, options) => {
console.log('open window', event, url, frameName, options);
openWindow({
event,
url,
frameName,
options,
});
});

this.webview.addEventListener('did-start-loading', (event) => {
debug('Did start load', this.name, event);
@@ -234,6 +239,28 @@ export default class Service {
debug('Service crashed', this.name);
this.hasCrashed = true;
});

webContents.on('login', (event, request, authInfo, callback) => {
// const authCallback = callback;
debug('browser login event', authInfo);
event.preventDefault();

if (authInfo.isProxy && authInfo.scheme === 'basic') {
debug('Sending service echo ping');
webContents.send('get-service-id');

debug('Received service id', this.id);

const ps = stores.settings.proxy[this.id];

if (ps) {
debug('Sending proxy auth callback for service', this.id);
callback(ps.user, ps.password);
} else {
debug('No proxy auth config found for', this.id);
}
}
});
}

initializeWebViewListener() {
@@ -345,6 +345,7 @@ export default class ServicesStore extends Store {
service.initializeWebViewEvents({
handleIPCMessage: this.actions.service.handleIPCMessage,
openWindow: this.actions.service.openWindow,
stores: this.stores,
});
service.initializeWebViewListener();
}

0 comments on commit e2126a6

Please sign in to comment.
You can’t perform that action at this time.