From a20fff7174524ffb80251ed80f927f0b2d61f63b Mon Sep 17 00:00:00 2001 From: sbosse Date: Mon, 21 Jul 2025 22:48:16 +0200 Subject: [PATCH] Mon 21 Jul 22:43:21 CEST 2025 --- js/dos/ext/satelize.js | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 js/dos/ext/satelize.js diff --git a/js/dos/ext/satelize.js b/js/dos/ext/satelize.js new file mode 100644 index 0000000..7863c6b --- /dev/null +++ b/js/dos/ext/satelize.js @@ -0,0 +1,67 @@ +/* +* satelize - v0.1.3 +* +* (c) 2013 Julien VALERY https://github.com/darul75/satelize, 2018-2020 modfied by bLAB Dr. Stefan Bosse +* +* Usage: satelize(ip:string|undefined,function (err,info)) +* +* License: MIT +*/ + + +var http=Require("http"), + serviceHost="ip-api.com", + servicePort=80, + servicePath="/json", + serviceJSONP=""; + +function Satelize(options){ + this.init() +} + +Satelize.prototype.init=function(options){ + return this +} + +Satelize.prototype.satelize=function(a,b){ + var c=(a.ip?"/"+a.ip:"")+(a.JSONP?serviceJSONP:""), + d=a.timeout||1e3, + h=a.url||a.host||serviceHost, + p=a.port||servicePort, + e, + f; + if (!http) return b('ENOTSUPPORTED',null); + if (!http.xhr && http.request) { + // server + e={hostname:h,path:servicePath+c,method:"GET",port:p}; + f=http.request(e,function(a){ + a.setEncoding("utf8"); + var c=""; + a.on("data",function(a){c+=a}), + a.on("end",function(){ + try { + return b(null,JSON.parse(c)); + } catch (err) { + b(err.toString()+', '+e.hostname+':'+e.port); + } + }) + }); + return f.on("error",function(a){return b(a)}), + f.setTimeout(d,function(){return b(new Error("timeout"))}), + f.end(),this; + } else { + // Browser + e={uri:a.url?a.url:(a.proto?a.proto:'http')+'://'+h+':'+p+servicePath+c, + method:"GET", + headers:{}}; + console.log(e); + http.request(e,function(err,xhr,body){ + if (err) return b(err); + else try { b(null,JSON.parse(body)); } catch (err) { b(err.toString()+', '+e.uri) } + }) + return this; + } +} + +var sat = new Satelize +module.exports=sat;