mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-25 23:00:13 +00:00
Don't perform lookup for obvious IPs and account for async
This old version of Node forces us to use callbacks, so I had to rearrange some code to ensure the client only launches after the resolution is complete
This commit is contained in:
parent
8d6e546628
commit
7ce21cdddc
@ -156,6 +156,20 @@ function setGameInfo(serverUUID) {
|
|||||||
window.asseturl = gameversion.url; // gameclient.js needs to access this
|
window.asseturl = gameversion.url; // gameclient.js needs to access this
|
||||||
|
|
||||||
remotefs.writeFileSync(__dirname+"\\assetInfo.php", asseturl);
|
remotefs.writeFileSync(__dirname+"\\assetInfo.php", asseturl);
|
||||||
|
if (result.hasOwnProperty('endpoint')) {
|
||||||
|
var httpendpoint = result.endpoint.replace("https://", "http://")
|
||||||
|
remotefs.writeFileSync(__dirname+"\\rankurl.txt", httpendpoint+"getranks");
|
||||||
|
// Write these out too
|
||||||
|
remotefs.writeFileSync(__dirname+"\\sponsor.php", httpendpoint+"upsell/sponsor.png");
|
||||||
|
remotefs.writeFileSync(__dirname+"\\images.php", httpendpoint+"upsell/");
|
||||||
|
} else {
|
||||||
|
// Remove/default the endpoint related stuff, this server won't be using it
|
||||||
|
if (remotefs.existsSync(__dirname+"\\rankurl.txt")) {
|
||||||
|
remotefs.unlinkSync(__dirname+"\\rankurl.txt");
|
||||||
|
remotefs.writeFileSync(__dirname+"\\sponsor.php", "assets/img/welcome.png");
|
||||||
|
remotefs.writeFileSync(__dirname+"\\images.php", "assets/img/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Server address parsing
|
// Server address parsing
|
||||||
var address;
|
var address;
|
||||||
@ -169,34 +183,27 @@ function setGameInfo(serverUUID) {
|
|||||||
port = 23000 // default
|
port = 23000 // default
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNS resolution. there is no synchronous version unfortunately
|
// DNS resolution. there is no synchronous version for some stupid reason
|
||||||
// if the resolution fails, keep the original entry (includes plain IP cases)
|
if(!address.match(/^[0-9.]+$/)) dns.resolve4(address, function(err, res) {
|
||||||
var ip = address;
|
|
||||||
dns.resolve4(address, function(err, res) {
|
|
||||||
if(!err) {
|
if(!err) {
|
||||||
ip = res[0];
|
console.log("Resolved " + address + " to " + res[0]);
|
||||||
console.log("Resolved " + address + " to " + ip);
|
address = res[0];
|
||||||
}
|
|
||||||
|
|
||||||
var fullAddress = ip + ":" + port;
|
|
||||||
console.log("Will connect to " + fullAddress);
|
|
||||||
remotefs.writeFileSync(__dirname+"\\loginInfo.php", fullAddress);
|
|
||||||
|
|
||||||
if (result.hasOwnProperty('endpoint')) {
|
|
||||||
var httpendpoint = result.endpoint.replace("https://", "http://")
|
|
||||||
remotefs.writeFileSync(__dirname+"\\rankurl.txt", httpendpoint+"getranks");
|
|
||||||
// Write these out too
|
|
||||||
remotefs.writeFileSync(__dirname+"\\sponsor.php", httpendpoint+"upsell/sponsor.png");
|
|
||||||
remotefs.writeFileSync(__dirname+"\\images.php", httpendpoint+"upsell/");
|
|
||||||
} else {
|
} else {
|
||||||
// Remove/default the endpoint related stuff, this server won't be using it
|
console.log("Err: " + err.code);
|
||||||
if (remotefs.existsSync(__dirname+"\\rankurl.txt")) {
|
|
||||||
remotefs.unlinkSync(__dirname+"\\rankurl.txt");
|
|
||||||
remotefs.writeFileSync(__dirname+"\\sponsor.php", "assets/img/welcome.png");
|
|
||||||
remotefs.writeFileSync(__dirname+"\\images.php", "assets/img/");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
prepConnection(address, port);
|
||||||
});
|
});
|
||||||
|
else {
|
||||||
|
console.log(address + " is an IP; skipping DNS lookup");
|
||||||
|
prepConnection(address, port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepConnection(address, port) {
|
||||||
|
var full = address + ":" + port;
|
||||||
|
console.log("Will connect to " + full);
|
||||||
|
remotefs.writeFileSync(__dirname+"\\loginInfo.php", full);
|
||||||
|
launchGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the UUID of the server with the selected background color.
|
// Returns the UUID of the server with the selected background color.
|
||||||
@ -216,7 +223,6 @@ function connectToServer() {
|
|||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('body,html').css('pointer-events','');
|
$('body,html').css('pointer-events','');
|
||||||
setGameInfo(getSelectedServer());
|
setGameInfo(getSelectedServer());
|
||||||
launchGame();
|
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user