ad showmyip
This commit is contained in:
22
bundles/showmyip.ts
Normal file
22
bundles/showmyip.ts
Normal 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);
|
||||
Reference in New Issue
Block a user