Skip to content

Commit 4655d0e

Browse files
Vaipexabsidue
andauthored
Add proxy login support (FreeTubeApp#7996)
* add proxy support * Update src/main/index.js Co-authored-by: absidue <[email protected]> --------- Co-authored-by: absidue <[email protected]>
1 parent 8ff066f commit 4655d0e

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

src/main/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,15 @@ function runApp() {
703703
}
704704
})
705705

706+
app.on('login', async (event, webContents, request, authInfo, callback) => {
707+
if (authInfo.isProxy) {
708+
event.preventDefault()
709+
const proxyUsername = (await baseHandlers.settings._findOne('proxyUsername'))?.value
710+
const proxyPassword = (await baseHandlers.settings._findOne('proxyPassword'))?.value
711+
callback(proxyUsername, proxyPassword)
712+
}
713+
})
714+
706715
function trayClick(window, close = false) {
707716
if (!close) {
708717
if (window.id in trayMaximizedWindows) {

src/renderer/components/ProxySettings/ProxySettings.vue

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@
5353
@keydown.enter.native="testProxy"
5454
/>
5555
</FtFlexBox>
56+
<FtFlexBox>
57+
<FtInput
58+
:placeholder="$t('Settings.Proxy Settings.Proxy Username')"
59+
:show-action-button="false"
60+
show-label
61+
:value="proxyUsername"
62+
@input="handleUpdateProxyUsername"
63+
@keydown.enter.native="testProxy"
64+
/>
65+
<FtInput
66+
:placeholder="$t('Settings.Proxy Settings.Proxy Password')"
67+
:show-action-button="false"
68+
show-label
69+
:value="proxyPassword"
70+
@input="handleUpdateProxyPassword"
71+
@keydown.enter.native="testProxy"
72+
/>
73+
</FtFlexBox>
5674
<p
5775
class="center"
5876
>
@@ -151,6 +169,16 @@ const proxyPort = computed(() => {
151169
return store.getters.getProxyPort
152170
})
153171
172+
/** @type {import('vue').ComputedRef<string>} */
173+
const proxyUsername = computed(() => {
174+
return store.getters.getProxyUsername
175+
})
176+
177+
/** @type {import('vue').ComputedRef<string>} */
178+
const proxyPassword = computed(() => {
179+
return store.getters.getProxyPassword
180+
})
181+
154182
const proxyUrl = computed(() => {
155183
return `${proxyProtocol.value}://${proxyHostname.value}:${proxyPort.value}`
156184
})
@@ -230,6 +258,28 @@ function handleUpdateProxyPort(value) {
230258
store.dispatch('updateProxyPort', value)
231259
}
232260
261+
/**
262+
* @param {string} value
263+
*/
264+
function handleUpdateProxyUsername(value) {
265+
if (useProxy.value) {
266+
debouncedEnableProxy()
267+
}
268+
269+
store.dispatch('updateProxyUsername', value)
270+
}
271+
272+
/**
273+
* @param {string} value
274+
*/
275+
function handleUpdateProxyPassword(value) {
276+
if (useProxy.value) {
277+
debouncedEnableProxy()
278+
}
279+
280+
store.dispatch('updateProxyPassword', value)
281+
}
282+
233283
function enableProxy() {
234284
if (process.env.IS_ELECTRON) {
235285
window.ftElectron.enableProxy(proxyUrl.value)

src/renderer/store/modules/settings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ const state = {
230230
playNextVideo: false,
231231
proxyHostname: '127.0.0.1',
232232
proxyPort: '9050',
233+
proxyUsername: '',
234+
proxyPassword: '',
233235
proxyProtocol: 'socks5',
234236
proxyVideos: !process.env.SUPPORTS_LOCAL_API,
235237
region: 'US',

static/locales/en-US.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,8 @@ Settings:
634634
Proxy Protocol: Proxy Protocol
635635
Proxy Host: Proxy Host
636636
Proxy Port Number: Proxy Port Number
637+
Proxy Username: Proxy Username
638+
Proxy Password: Proxy Password
637639
Clicking on Test Proxy will send a request to: Clicking on Test Proxy will send a request to
638640
Test Proxy: Test Proxy
639641
Your Info: Your Info

0 commit comments

Comments
 (0)