ad showmyip

This commit is contained in:
2026-02-09 23:25:57 +08:00
parent 1d24822def
commit 503d57300d
3 changed files with 36 additions and 0 deletions

22
bundles/showmyip.ts Normal file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env runts -- --allow-all
import {log} from "../libraries/deno-commons-mod.ts";
interface Ip {
status: number;
message: string;
ip: string;
userAgent: string;
}
async function main() {
const ipResponse = await fetch("https://hatter.ink/ip/ip.jsonp");
if (ipResponse.status !== 200) {
log.error(`Failed to fetch ip response: ${ipResponse.status}`);
} else {
const ip = await ipResponse.json() as Ip;
log.info(`IP address: ${ip.ip}`);
}
}
main().catch(console.error);