Fix iptables internet forwarding bug. Update UI errors.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import type { BUN_SQLITE_WGUI_HOSTS } from "@/db/types/db";
|
||||
import fetchApi from "@/src/components/twui/utils/fetch/fetchApi";
|
||||
import type useFormInit from "@/src/hooks/use-form-init";
|
||||
import type { ApiReqParams } from "@/src/types";
|
||||
import type { APIResponseObject } from "@moduletrace/bunext/types";
|
||||
import type { Dispatch, SetStateAction } from "react";
|
||||
|
||||
type Params = {
|
||||
iface: string;
|
||||
local: boolean;
|
||||
setLoading: Dispatch<SetStateAction<boolean>>;
|
||||
setForm: Dispatch<SetStateAction<BUN_SQLITE_WGUI_HOSTS>>;
|
||||
};
|
||||
|
||||
export default async function clientFetchIP({
|
||||
iface,
|
||||
local,
|
||||
setLoading,
|
||||
setForm,
|
||||
}: Params) {
|
||||
if (!iface) return;
|
||||
|
||||
const endpoint = local
|
||||
? `/api/admin/interface-local-ip?interface=${iface}`
|
||||
: `/api/admin/public-ip?interface=${iface}`;
|
||||
|
||||
setLoading(true);
|
||||
|
||||
fetchApi<ApiReqParams, APIResponseObject>(endpoint, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.success && res.stringRes) {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
public_ip_address: res.stringRes!,
|
||||
}));
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
setLoading(false);
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user