Disallowed Underscores
Why was underscores on ip address disabled? Is this a technical limitation? I see that it was explicitly set to not allow underscores in this line:
/functions/validateHost.js#L21
function validateAddress(ip) {
const decoded = unidecode(ip);
return (
isIP(decoded) ||
isFQDN(decoded, {
allow_underscores: false,
allow_numeric_tld: true
})
);
}
Is the fix not as simple as
- allow_underscores: false,
+ allow_underscores: true,
I dug deeper and maybe this is a limitation of the mcstatus API? I tried plugging in an address with an underscore and it returned an error. If so, is it not possible to use this API instead (for bedrock servers with underscores). It may not give the same info but it does give server information such as Player Count and Server Status (Online/Offline). I haven't tested it's reliability yet but it does accept address with underscore.
api.mcsrvstat.us sample JSON body response (offline server)
{
"ip": "185.107.XXX.XXX",
"port": 99999,
"debug": {
"ping": false,
"query": false,
"srv": false,
"querymismatch": false,
"ipinsrv": false,
"cnameinsrv": false,
"animatedmotd": false,
"cachehit": false,
"cachetime": 1729746969,
"cacheexpire": 1729747029,
"apiversion": 3,
"dns": {
"a": [
{
"name": "xxx_xxx.aternos.me",
"type": "A",
"class": "IN",
"ttl": 5,
"rdlength": 0,
"rdata": "",
"address": "185.107.XXX.XXX"
},
{
"name": "xxx_xxx.aternos.me",
"type": "A",
"class": "IN",
"ttl": 5,
"rdlength": 0,
"rdata": "",
"address": "185.107.XXX.XXX"
},
{
"name": "xxx_xxx.aternos.me",
"type": "RRSIG",
"class": "IN",
"ttl": 5,
"rdlength": 0,
"rdata": "",
"typecovered": "A",
"algorithm": 13,
"labels": 3,
"origttl": 5,
"sigexp": "20241107000000",
"sigincep": "20241017000000",
"keytag": 56863,
"signname": "aternos.me",
"signature": "<redacted>"
}
]
},
"error": {
"query": "Failed to read from socket."
}
},
"hostname": "xxx_xxx.aternos.me",
"online": false
}
api.mcsrvstat.us sample JSON body response (online server)
{
"ip": "89.116.234.165",
"port": 19132,
"debug": {
"ping": false,
"query": true,
"srv": false,
"querymismatch": false,
"ipinsrv": false,
"cnameinsrv": false,
"animatedmotd": false,
"cachehit": false,
"cachetime": 1729747895,
"cacheexpire": 1729747955,
"apiversion": 3
},
"motd": {
"raw": [
"§r§fplay.§r§c§lLIFESTEAL§r§f§lMC§r§f.net | §r§cdiscord.gg/lsmc§r"
],
"clean": [
"play.LIFESTEALMC.net | discord.gg/lsmc"
],
"html": [
"<span style=\"color: #FFFFFF\">play.</span><span style=\"color: #FF5555\"><span style=\"font-weight: bold;\">LIFESTEAL</span></span><span style=\"color: #FFFFFF\"><span style=\"font-weight: bold;\">MC</span></span><span style=\"color: #FFFFFF\">.net | </span><span style=\"color: #FF5555\">discord.gg/lsmc</span>"
]
},
"players": {
"online": 7,
"max": 1000
},
"version": "1.21.30",
"online": true,
"protocol": {
"version": 729,
"name": "1.21.30"
},
"software": "Geyser",
"gamemode": "Survival",
"serverid": "8436967703580594055"
}
Yup you are correct it is a limitation of mcstatus. We currently use mcstatus because we are able to host our own version of their api locally due to the sheer load that the bot generates. If we were to use the mcsrvstat endpoint on their website we would most likely get banned real quick.
Seeing that their endpoint does work tho, Ill reach out to the dev and see if we can't collab and host an internal version of that API so we can get underscores to work.
Aight. Thanks for the response. Hoping for the best
Well this took a while, but essentially we built our own ping server so we don't need to use any third party APIs. We are currently testing to make sure that underscores work. Once these tests pass, Ill update the bot to allow underscores again :)
Underscores are now allowed again :)