Update hosts form
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import getInterfaceLocalIP from "@/src/functions/backend/setup/get-interface-local-ip";
|
||||
import type { ApiReqParams } from "@/src/types";
|
||||
import type {
|
||||
APIResponseObject,
|
||||
BunextAPIRouteHandler,
|
||||
} from "@moduletrace/bunext/types";
|
||||
|
||||
export const handler: BunextAPIRouteHandler<APIResponseObject> = async (
|
||||
params,
|
||||
) => {
|
||||
if (params.req.method !== "GET") {
|
||||
return { success: false };
|
||||
}
|
||||
const url = new URL(params.req.url || "");
|
||||
const iface = url.searchParams.get("interface") || undefined;
|
||||
try {
|
||||
const local_ip = await getInterfaceLocalIP(iface || null);
|
||||
return { success: true, stringRes: local_ip };
|
||||
} catch (error: any) {
|
||||
return { success: false, msg: error.message };
|
||||
}
|
||||
};
|
||||
@@ -11,8 +11,10 @@ export const handler: BunextAPIRouteHandler<APIResponseObject> = async (
|
||||
if (params.req.method !== "GET") {
|
||||
return { success: false };
|
||||
}
|
||||
const url = new URL(params.req.url || "");
|
||||
const iface = url.searchParams.get("interface") || undefined;
|
||||
try {
|
||||
const public_ip = await grabHostPublicIPAddress();
|
||||
const public_ip = await grabHostPublicIPAddress(iface);
|
||||
return { success: true, stringRes: public_ip };
|
||||
} catch (error: any) {
|
||||
return { success: false, msg: error.message };
|
||||
|
||||
Reference in New Issue
Block a user