mirror of
https://github.com/desktop/desktop
synced 2024-09-12 21:01:16 +00:00
Refactor remote resolveProxy calls to be called from main process
This commit is contained in:
parent
ef31b21498
commit
c550ddb60e
|
@ -70,4 +70,5 @@ export type RequestResponseChannels = {
|
|||
items: ReadonlyArray<ISerializableMenuItem>
|
||||
) => Promise<ReadonlyArray<number> | null>
|
||||
'open-external': (path: string) => Promise<boolean>
|
||||
'resolve-proxy': (url: string) => Promise<string>
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { remote } from 'electron'
|
||||
import { resolveProxy } from '../ui/main-process-proxy'
|
||||
import { parsePACString } from './parse-pac-string'
|
||||
|
||||
export async function resolveGitProxy(
|
||||
|
@ -10,12 +10,10 @@ export async function resolveGitProxy(
|
|||
// error (if the URL we're given is null or undefined despite
|
||||
// our best type efforts for example).
|
||||
// Better safe than sorry.
|
||||
const pacString = await remote.session.defaultSession
|
||||
.resolveProxy(url)
|
||||
.catch(err => {
|
||||
log.error(`Failed resolving proxy for '${url}'`, err)
|
||||
return 'DIRECT'
|
||||
})
|
||||
const pacString = await resolveProxy(url).catch(err => {
|
||||
log.error(`Failed resolving proxy for '${url}'`, err)
|
||||
return 'DIRECT'
|
||||
})
|
||||
|
||||
const proxies = parsePACString(pacString)
|
||||
|
||||
|
|
|
@ -531,6 +531,13 @@ app.on('ready', () => {
|
|||
UNSAFE_openDirectory(path)
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Handle action to resolve proxy
|
||||
*/
|
||||
ipcMain.handle('resolve-proxy', async (_, url: string) => {
|
||||
return session.defaultSession.resolveProxy(url)
|
||||
})
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
|
|
|
@ -272,3 +272,6 @@ export function sendErrorReport(
|
|||
) {
|
||||
_sendErrorReport(getIpcFriendlyError(error), extra, nonFatal)
|
||||
}
|
||||
|
||||
/** Tells the main process to resolve the proxy for a given url */
|
||||
export const resolveProxy = invokeProxy('resolve-proxy')
|
||||
|
|
Loading…
Reference in a new issue