dscalzi / HeliosLauncher

☀ Custom launcher for modded minecraft written in Electron and Node.js
MIT License
838 stars 1.73k forks source link

enhancement/fix: Add support for domain based ip addresses #199

Closed drori200 closed 2 years ago

drori200 commented 2 years ago

Why?: When trying to get the status of domain based ip's with the current implementation you weren't able to do that since you could not resolve the host ip, with this PR i have replaced the old system with a simple request using node-fetch (since Request is deprecated and not maintained for the time being) using the https://api.mcsrvstat.us/ API.

dscalzi commented 2 years ago

whats wrong with the host ip resolution? is it a srv record?

drori200 commented 2 years ago

whats wrong with the host ip resolution? is it a srv record?

I do not know the cause, it could be a problem with the srv record (although i do not think it is) but what i know is when i had an ip address like the ones of for example "mc.hypixel.net" i could not get a response with it being online while with my implementation i could get both numerical ips and domain ips working

dscalzi commented 2 years ago

IIRC I wrote replacement code for this specific thing for the v2 branch. I wonder if we can just backport that into v1. I'd like to avoid dependence on 3rd party services if it can be avoided.

https://github.com/dscalzi/HeliosLauncher/blob/ts-refactor/src/common/mojang/net/Protocol.ts https://github.com/dscalzi/HeliosLauncher/blob/ts-refactor/src/common/mojang/net/ServerStatusAPI.ts

Test case available here. https://github.com/dscalzi/HeliosLauncher/blob/ts-refactor/test/mojang/net/ServerStatusAPITest.ts

dscalzi commented 2 years ago

Can you try achieving what you want with the change I just pushed to master? https://github.com/dscalzi/HeliosLauncher/commit/9c6d75f8121ecc65210fd2c773242e5ac0068ae5

drori200 commented 2 years ago

I will try to do so when i get back home in around 5 hours

drori200 commented 2 years ago

Alright so now even with numerical IPs the status shows offline

drori200 commented 2 years ago

I think the problem could be with the URL module but i don't know enough about it. Some way i can think of is to get the ip address using the DNS module but that still leaves us with the part of finding the port for the server

dscalzi commented 2 years ago

can you send me an IP that isnt working for you?

drori200 commented 2 years ago

can you send me an IP that isnt working for you?

Testing on both a numerical and a domain ip for (each for different server /modpack) 144.217.35.37:25587 and dbc.dbdivinity.com

dscalzi commented 2 years ago

Neither appears online. SRV records are not supported in the lookup (if these IPs have srv). Support would have to be added here https://github.com/dscalzi/helios-core