generated from template/slidev-template
update
This commit is contained in:
8
agent/ddns/get-ip.ts
Normal file
8
agent/ddns/get-ip.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
const baseURLv4 = 'https://4.ipw.cn/';
|
||||
const baseURLv6 = 'https://6.ipw.cn/';
|
||||
export const getPublicIp = async (type: 'v4' | 'v6'): Promise<string> => {
|
||||
const url = type === 'v4' ? baseURLv4 : baseURLv6;
|
||||
const response = await fetch(url);
|
||||
const ip = (await response.text()).trim();
|
||||
return ip;
|
||||
}
|
||||
Reference in New Issue
Block a user