mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-22 05:30:05 +00:00
Add automatic DNS resolution for server addresses
This commit is contained in:
parent
6e881cbfaf
commit
8d6e546628
@ -1,5 +1,6 @@
|
|||||||
var remote = require("remote");
|
var remote = require("remote");
|
||||||
var remotefs = remote.require('fs-extra');
|
var remotefs = remote.require('fs-extra');
|
||||||
|
var dns = remote.require('dns');
|
||||||
|
|
||||||
var userdir = remote.require('app').getPath('userData');
|
var userdir = remote.require('app').getPath('userData');
|
||||||
var versionarray
|
var versionarray
|
||||||
@ -167,22 +168,35 @@ function setGameInfo(serverUUID) {
|
|||||||
address = result.ip
|
address = result.ip
|
||||||
port = 23000 // default
|
port = 23000 // default
|
||||||
}
|
}
|
||||||
remotefs.writeFileSync(__dirname+"\\loginInfo.php", address + ":" + port);
|
|
||||||
|
|
||||||
if (result.hasOwnProperty('endpoint')) {
|
// DNS resolution. there is no synchronous version unfortunately
|
||||||
var httpendpoint = result.endpoint.replace("https://", "http://")
|
// if the resolution fails, keep the original entry (includes plain IP cases)
|
||||||
remotefs.writeFileSync(__dirname+"\\rankurl.txt", httpendpoint+"getranks");
|
var ip = address;
|
||||||
// Write these out too
|
dns.resolve4(address, function(err, res) {
|
||||||
remotefs.writeFileSync(__dirname+"\\sponsor.php", httpendpoint+"upsell/sponsor.png");
|
if(!err) {
|
||||||
remotefs.writeFileSync(__dirname+"\\images.php", httpendpoint+"upsell/");
|
ip = res[0];
|
||||||
} else {
|
console.log("Resolved " + address + " to " + ip);
|
||||||
// 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/");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
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 {
|
||||||
|
// 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/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the UUID of the server with the selected background color.
|
// Returns the UUID of the server with the selected background color.
|
||||||
|
Loading…
Reference in New Issue
Block a user