mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-06 21:57:48 +01:00
Fix: make gluetun port_forwarded opt-in (#5345)
This commit is contained in:
@@ -6,14 +6,22 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
export default function Component({ service }) {
|
||||
const { widget } = service;
|
||||
|
||||
const { data: gluetunData, error: gluetunError } = useWidgetAPI(widget, "ip");
|
||||
const { data: portForwardedData, error: portForwardedError } = useWidgetAPI(widget, "port_forwarded");
|
||||
if (!widget.fields) {
|
||||
widget.fields = ["public_ip", "region", "country"];
|
||||
}
|
||||
|
||||
if (gluetunError || portForwardedError) {
|
||||
const { data: gluetunData, error: gluetunError } = useWidgetAPI(widget, "ip");
|
||||
const includePF = !!widget.fields["port_forwarded"];
|
||||
const { data: portForwardedData, error: portForwardedError } = useWidgetAPI(
|
||||
widget,
|
||||
includePF ? "port_forwarded" : "",
|
||||
);
|
||||
|
||||
if (gluetunError || (includePF && portForwardedError)) {
|
||||
return <Container service={service} error={gluetunError || portForwardedError} />;
|
||||
}
|
||||
|
||||
if (!gluetunData || !portForwardedData) {
|
||||
if (!gluetunData || (includePF && !portForwardedData)) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="gluetun.public_ip" />
|
||||
@@ -29,7 +37,7 @@ export default function Component({ service }) {
|
||||
<Block label="gluetun.public_ip" value={gluetunData.public_ip} />
|
||||
<Block label="gluetun.region" value={gluetunData.region} />
|
||||
<Block label="gluetun.country" value={gluetunData.country} />
|
||||
<Block label="gluetun.port_forwarded" value={portForwardedData.port} />
|
||||
<Block label="gluetun.port_forwarded" value={portForwardedData?.port} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user