cross-tools
Version:
Cross-platform fundamental tools for developers
1 lines • 1.04 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),command_1=require("@oclif/command"),default_gateway_1=tslib_1.__importDefault(require("default-gateway")),myPrompts_1=require("../util/myPrompts"),ip_1=tslib_1.__importDefault(require("ip")),axios_1=tslib_1.__importDefault(require("axios")),asyncLoader_1=tslib_1.__importDefault(require("../util/asyncLoader")),choices=[{title:"Get my ip details",value:"get-my-ip-details",description:"Get details about your ip."}];class Network extends command_1.Command{async run(){const{operation:t}=await myPrompts_1.askFuzzy(choices,{});switch(t){case"get-my-ip-details":const t=await asyncLoader_1.default(this.getMyIpDetails,"Inspecting network");console.log(t)}}async getMyIpDetails(){const t={localIp:ip_1.default.address()};return await default_gateway_1.default.v4().then(e=>{t.gateway=e}).catch(t=>{}),await axios_1.default.get("https://freegeoip.app/json",{timeout:2e3}).then(e=>{t.publicIp=e.data}).catch(t=>{}),t}}exports.default=Network;