Fix: make gluetun port_forwarded opt-in (#5345)

This commit is contained in:
shamoon 2025-06-01 09:10:18 -07:00 committed by GitHub
parent 524cb7695c
commit 7850fe4651
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 6 deletions

View File

@ -10,8 +10,9 @@ Learn more about [Gluetun](https://github.com/qdm12/gluetun).
Requires [HTTP control server options](https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/control-server.md) to be enabled. By default this runs on port `8000`.
Allowed fields: `["public_ip", "region", "country", "port_forwarded"]`.
Default fields: `["public_ip", "region", "country"]`.
To setup authentication, follow [the official Gluetun documentation](https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/control-server.md#authentication). Note that to use the api key method, you must add the route `GET /v1/publicip/ip` to the `routes` array in your Gluetun config.toml.
To setup authentication, follow [the official Gluetun documentation](https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/control-server.md#authentication). Note that to use the api key method, you must add the route `GET /v1/publicip/ip` to the `routes` array in your Gluetun config.toml. Similarly, if you want to include the `port_forwarded` field, you must add the route `GET /v1/openvpn/portforwarded` to your Gluetun config.toml.
```yaml
widget:

View File

@ -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>
);
}