Skip to content

Commit 1dd2cb6

Browse files
authored
Merge pull request #659 from pavelpikta/fix/Matrix.138
fix(settings): enhance ProxyHosts handling and input validation
2 parents a011369 + 6e1b589 commit 1dd2cb6

File tree

4 files changed

+75
-55
lines changed

4 files changed

+75
-55
lines changed

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RUN yarn run build
2121

2222

2323
### BUILD TORRSERVER MULTIARCH START ###
24-
FROM --platform=$BUILDPLATFORM golang:1.24.0-alpine AS builder
24+
FROM --platform=$BUILDPLATFORM golang:1.26.0-alpine AS builder
2525

2626
COPY . /opt/src
2727
COPY --from=front /app/build /opt/src/web/build
@@ -35,11 +35,11 @@ ENV GOARCH=$TARGETARCH
3535

3636
# Build torrserver
3737
RUN apk add --update g++ \
38-
&& go run gen_web.go \
39-
&& cd server \
40-
&& go mod tidy \
41-
&& go clean -i -r -cache \
42-
&& go build -ldflags '-w -s' --o "torrserver" ./cmd
38+
&& go run gen_web.go \
39+
&& cd server \
40+
&& go mod tidy \
41+
&& go clean -i -r -cache \
42+
&& go build -ldflags '-w -s' --o "torrserver" ./cmd
4343
### BUILD TORRSERVER MULTIARCH END ###
4444

4545

web/src/components/Settings/SecondarySettingsComponent.jsx

Lines changed: 64 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import {useTranslation} from 'react-i18next'
1+
import { useTranslation } from 'react-i18next'
22
import TextField from '@material-ui/core/TextField'
33
import {
4-
Box,
5-
Button,
6-
CircularProgress,
7-
FormControlLabel,
8-
FormGroup,
9-
FormHelperText,
10-
InputAdornment,
11-
InputLabel,
12-
MenuItem,
13-
Select,
14-
Switch,
4+
Box,
5+
Button,
6+
CircularProgress,
7+
FormControlLabel,
8+
FormGroup,
9+
FormHelperText,
10+
InputAdornment,
11+
InputLabel,
12+
MenuItem,
13+
Select,
14+
Switch,
1515
} from '@material-ui/core'
16-
import {styled} from '@material-ui/core/styles'
17-
import {useEffect, useMemo, useState} from 'react'
16+
import { styled } from '@material-ui/core/styles'
17+
import { useEffect, useMemo, useState } from 'react'
1818

19-
import {SecondarySettingsContent, SettingSectionLabel} from './style'
19+
import { SecondarySettingsContent, SettingSectionLabel } from './style'
2020

2121
// Create a styled status message component
2222
const StatusMessage = styled('div')(({ theme, severity }) => ({
@@ -72,6 +72,15 @@ export default function SecondarySettingsComponent({ settings, inputForm }) {
7272
ProxyHosts,
7373
} = settings || {}
7474

75+
// Local state for ProxyHosts text input
76+
const [proxyHostsText, setProxyHostsText] = useState('')
77+
78+
// Sync proxyHostsText with ProxyHosts when settings change
79+
useEffect(() => {
80+
const textValue = Array.isArray(ProxyHosts) ? ProxyHosts.join(', ') : ProxyHosts || ''
81+
setProxyHostsText(textValue)
82+
}, [ProxyHosts])
83+
7584
// Use useMemo to compute basePath once
7685
const basePath = useMemo(() => {
7786
if (typeof window !== 'undefined') {
@@ -443,39 +452,47 @@ export default function SecondarySettingsComponent({ settings, inputForm }) {
443452
</StatusMessage>
444453
)}
445454
</Box>
446-
{/* ProxyP2P */}
447-
<SettingSectionLabel style={{ marginTop: '20px' }}>{t('Proxy')}</SettingSectionLabel>
448-
<FormGroup>
449-
<FormControlLabel
450-
control={<Switch checked={EnableProxy} onChange={inputForm} id='EnableProxy' color='secondary' />}
451-
label={t('SettingsDialog.EnableProxy')}
452-
labelPlacement='start'
453-
/>
454-
<FormHelperText margin='none'>{t('SettingsDialog.EnableProxyHint')}</FormHelperText>
455-
</FormGroup>
456-
{/* Proxy hosts */}
457-
<TextField
458-
onChange={(e) => {
459-
const hostsArray = e.target.value
460-
.split(',')
461-
.map((s) => s.trim());
462-
463-
inputForm({
464-
target: {
465-
id: 'ProxyHosts',
466-
value: hostsArray,
467-
},
468-
});
469-
}}
470-
margin='normal'
471-
id='ProxyHosts'
472-
label={t('SettingsDialog.ProxyHosts')}
473-
helperText={t('SettingsDialog.ProxyHostsHint')}
474-
value={Array.isArray(ProxyHosts) ? ProxyHosts.join(', ') : ''}
475-
type='text'
476-
variant='outlined'
477-
fullWidth
455+
{/* ProxyP2P */}
456+
<SettingSectionLabel style={{ marginTop: '20px' }}>{t('Proxy')}</SettingSectionLabel>
457+
<FormGroup>
458+
<FormControlLabel
459+
control={<Switch checked={EnableProxy} onChange={inputForm} id='EnableProxy' color='secondary' />}
460+
label={t('SettingsDialog.EnableProxy')}
461+
labelPlacement='start'
478462
/>
463+
<FormHelperText margin='none'>{t('SettingsDialog.EnableProxyHint')}</FormHelperText>
464+
</FormGroup>
465+
{/* Proxy hosts */}
466+
<TextField
467+
onChange={e => {
468+
setProxyHostsText(e.target.value)
469+
}}
470+
onBlur={e => {
471+
const inputValue = e.target.value.trim()
472+
const hostsArray =
473+
inputValue === ''
474+
? []
475+
: inputValue
476+
.split(',')
477+
.map(s => s.trim())
478+
.filter(s => s !== '')
479+
480+
inputForm({
481+
target: {
482+
id: 'ProxyHosts',
483+
value: hostsArray,
484+
},
485+
})
486+
}}
487+
margin='normal'
488+
id='ProxyHosts'
489+
label={t('SettingsDialog.ProxyHosts')}
490+
helperText={t('SettingsDialog.ProxyHostsHint')}
491+
value={proxyHostsText}
492+
type='text'
493+
variant='outlined'
494+
fullWidth
495+
/>
479496
</SecondarySettingsContent>
480497
)
481498
}

web/src/components/Settings/SettingsDialog.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ export default function SettingsDialog({ handleClose }) {
7878
else sets[id] = Boolean(checked)
7979
} else if (type === 'url' || type === 'text') {
8080
sets[id] = value
81+
} else if (!type && value !== undefined) {
82+
// Fallback for custom handlers that don't provide type (e.g., ProxyHosts array)
83+
sets[id] = value
8184
}
8285
setSettings(sets)
8386
}

web/src/components/Settings/defaultSettings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ export default {
2929
SslKey: '',
3030
ShowFSActiveTorr: true,
3131
StoreSettingsInJson: true,
32-
EnableProxy:false,
33-
ProxyHosts: ["*themoviedb.org", "*tmdb.org", "rutor.info"],
32+
EnableProxy: false,
33+
ProxyHosts: ['*themoviedb.org', '*tmdb.org', 'rutor.info'],
3434
}

0 commit comments

Comments
 (0)