aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-05-14 00:46:21 +0300
committerRblSb <msrblsb@gmail.com>2020-05-14 00:46:21 +0300
commit2ac659cb17ada55286bed44913cb8479ed1f9288 (patch)
tree2500d7647f4213bece5666efc6d467431fd383db /src
parent0e3f5b5d2ca586841b1640e721f8d6789635d801 (diff)
Fix public ip request for old nodejs
Diffstat (limited to 'src')
-rw-r--r--src/server/Utils.hx9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/server/Utils.hx b/src/server/Utils.hx
index 218184d..4764751 100644
--- a/src/server/Utils.hx
+++ b/src/server/Utils.hx
@@ -1,14 +1,17 @@
package server;
-import js.node.Http;
+import js.node.Https;
import js.node.Os;
class Utils {
public static function getGlobalIp(callback:(ip:String)->Void):Void {
- Http.get("http://myexternalip.com/raw", r -> {
+ // untyped to skip second null argument for node < v10
+ Https.get(untyped "https://myexternalip.com/raw", r -> {
r.setEncoding("utf8");
- r.on("data", callback);
+ final data = new StringBuf();
+ r.on("data", chunk -> data.add(chunk));
+ r.on("end", _ -> callback(data.toString()));
}).on("error", e -> {
trace("Warning: connection error, server is local.");
callback("127.0.0.1");
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage