@samitouri / QOSami-HFS / commits / cc436e5a

admin/home: warn in case of too-high proxies value

Massimo Melina committed Mar 23, 2025 at 12:26 UTC cc436e5adaa20fdc2db038c9e3546390cea18a70
2 files changed +5 -5
admin/src/HomePage.ts
+4 -3
@@ -30,7 +30,7 @@ export default function HomePage() {
30 const { data: status, reload: reloadStatus, element: statusEl } = useApiEx<typeof adminApis.get_status>('get_status')
31 const { data: vfs } = useApiEx<{ root?: VfsNode }>('get_vfs')
32 const { data: account } = useApiEx<Account>(username && 'get_account')
33 - const cfg = useApiEx('get_config', { only: ['https_port', 'cert', 'private_key', 'proxies'] })
33 + const cfg = useApiEx('get_config', { only: ['https_port', 'cert', 'private_key', 'proxies', 'ignore_proxies'] })
34 const { list: plugins } = useApiList('get_plugins')
35 const [checkPlugins, setCheckPlugins] = useState(false)
36 const { list: pluginUpdates} = useApiList(checkPlugins && 'get_plugin_updates')
@@ -235,6 +235,7 @@ function cfgLink(text=`Options page`) {
235 }
236
237 export function proxyWarning(cfg: any, status: any) {
238 - return cfg && !cfg.proxies && status?.proxyDetected
239 - ? "A proxy was detected but none is configured" : ''
238 + return status && cfg && !cfg.ignore_proxies && (!cfg.proxies && status.proxyDetected ? "A proxy was detected but none is configured"
239 + : cfg.proxies && !status.proxyDetected && (Date.now() - +new Date(status.started) > DAY) ? `Proxies is set to ${cfg.proxies} but none was detected recently. Consider setting it zero`
240 + : '')
241 }
src/middlewares.ts
+1 -2
@@ -91,8 +91,7 @@ export const someSecurity: Koa.Middleware = (ctx, next) => {
91 export function getProxyDetected() {
92 if (proxyDetected?.state.whenProxyDetected < Date.now() - DAY)
93 proxyDetected = undefined
94 - return !ignoreProxies.get() && proxyDetected
95 - && { from: proxyDetected.ip, for: proxyDetected.get('X-Forwarded-For') }
94 + return proxyDetected && { from: proxyDetected.ip, for: proxyDetected.get('X-Forwarded-For') }
95 }
96
97 export const prepareState: Koa.Middleware = async (ctx, next) => {