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 @@ -287,6 +287,8 @@ function runApp() {
287
287
} )
288
288
}
289
289
290
+ let proxyUrl
291
+
290
292
app . on ( 'ready' , async ( _ , __ ) => {
291
293
if ( process . env . NODE_ENV === 'production' ) {
292
294
protocol . handle ( 'app' , async ( request ) => {
@@ -400,8 +402,10 @@ function runApp() {
400
402
}
401
403
402
404
if ( useProxy ) {
405
+ proxyUrl = `${ proxyProtocol } ://${ proxyHostname } :${ proxyPort } `
406
+
403
407
session . defaultSession . setProxy ( {
404
- proxyRules : ` ${ proxyProtocol } :// ${ proxyHostname } : ${ proxyPort } `
408
+ proxyRules : proxyUrl
405
409
} )
406
410
}
407
411
@@ -884,18 +888,20 @@ function runApp() {
884
888
} )
885
889
886
890
ipcMain . handle ( IpcChannels . GENERATE_PO_TOKEN , ( _ , visitorData ) => {
887
- return generatePoToken ( visitorData )
891
+ return generatePoToken ( visitorData , proxyUrl )
888
892
} )
889
893
890
894
ipcMain . on ( IpcChannels . ENABLE_PROXY , ( _ , url ) => {
891
895
session . defaultSession . setProxy ( {
892
896
proxyRules : url
893
897
} )
898
+ proxyUrl = url
894
899
session . defaultSession . closeAllConnections ( )
895
900
} )
896
901
897
902
ipcMain . on ( IpcChannels . DISABLE_PROXY , ( ) => {
898
903
session . defaultSession . setProxy ( { } )
904
+ proxyUrl = undefined
899
905
session . defaultSession . closeAllConnections ( )
900
906
} )
901
907
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