File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -289,6 +289,8 @@ function runApp() {
289
289
} )
290
290
}
291
291
292
+ let proxyUrl
293
+
292
294
app . on ( 'ready' , async ( _ , __ ) => {
293
295
if ( process . env . NODE_ENV === 'production' ) {
294
296
protocol . handle ( 'app' , async ( request ) => {
@@ -402,8 +404,10 @@ function runApp() {
402
404
}
403
405
404
406
if ( useProxy ) {
407
+ proxyUrl = `${ proxyProtocol } ://${ proxyHostname } :${ proxyPort } `
408
+
405
409
session . defaultSession . setProxy ( {
406
- proxyRules : ` ${ proxyProtocol } :// ${ proxyHostname } : ${ proxyPort } `
410
+ proxyRules : proxyUrl
407
411
} )
408
412
}
409
413
@@ -898,18 +902,20 @@ function runApp() {
898
902
} )
899
903
900
904
ipcMain . handle ( IpcChannels . GENERATE_PO_TOKEN , ( _ , visitorData ) => {
901
- return generatePoToken ( visitorData )
905
+ return generatePoToken ( visitorData , proxyUrl )
902
906
} )
903
907
904
908
ipcMain . on ( IpcChannels . ENABLE_PROXY , ( _ , url ) => {
905
909
session . defaultSession . setProxy ( {
906
910
proxyRules : url
907
911
} )
912
+ proxyUrl = url
908
913
session . defaultSession . closeAllConnections ( )
909
914
} )
910
915
911
916
ipcMain . on ( IpcChannels . DISABLE_PROXY , ( ) => {
912
917
session . defaultSession . setProxy ( { } )
918
+ proxyUrl = undefined
913
919
session . defaultSession . closeAllConnections ( )
914
920
} )
915
921
Original file line number Diff line number Diff line change @@ -10,9 +10,10 @@ import { join } from 'path'
10
10
* as the BotGuard stuff accesses the global `document` and `window` objects and also requires making some requests.
11
11
* So we definitely don't want it running in the same places as the rest of the FreeTube code with the user data.
12
12
* @param {string } visitorData
13
+ * @param {string|undefined } proxyUrl
13
14
* @returns {Promise<string> }
14
15
*/
15
- export async function generatePoToken ( visitorData ) {
16
+ export async function generatePoToken ( visitorData , proxyUrl ) {
16
17
const sessionUuid = crypto . randomUUID ( )
17
18
18
19
const theSession = session . fromPartition ( `potoken-${ sessionUuid } ` , { cache : false } )
@@ -28,6 +29,12 @@ export async function generatePoToken(visitorData) {
28
29
. join ( ' ' )
29
30
)
30
31
32
+ if ( proxyUrl ) {
33
+ await theSession . setProxy ( {
34
+ proxyRules : proxyUrl
35
+ } )
36
+ }
37
+
31
38
const webContentsView = new WebContentsView ( {
32
39
webPreferences : {
33
40
backgroundThrottling : false ,
You can’t perform that action at this time.
0 commit comments