Added support for both https AND http, config is now untracked by git

This commit is contained in:
Daniel Vestøl committed 2018-06-08 09:33:19 +02:00
1 parent a9532dd0d3
commit 94bbf62c26
3 files changed
+37 -21

No files matched your search

+17 -11
View File
@@ -70,17 +70,19 @@ NodeJS does not support EOL ubuntu releases. Make sure you are on the most recen
Master and all slaves: Master and all slaves:
sudo curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - \ sudo curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt install -y nodejs python-dev git wget curl tar build-essential \ sudo apt install -y nodejs python-dev git wget curl tar build-essential
sudo npm install pm2 -g \ sudo npm install pm2 -g
git clone https://github.com/Danielv123/factorioClusterio.git \ git clone https://github.com/Danielv123/factorioClusterio.git
cd factorioClusterio \ cd factorioClusterio
npm install \ curl -o factorio.tar.gz -L https://www.factorio.com/get-download/latest/headless/linux64
curl -o factorio.tar.gz -L https://www.factorio.com/get-download/latest/headless/linux64 \
tar -xf factorio.tar.gz tar -xf factorio.tar.gz
npm install
downloads and installs nodejs, pm2, git and clusterio. To specify a version, change "latest" in the link to a version number like 0.14.21. downloads and installs nodejs, pm2, git and clusterio. To specify a version, change "latest" in the link to a version number like 0.14.21.
*Copy config.json.dist to config.json* - Otherwise it will crash, as you'd expect.
**Master** **Master**
pm2 start master.js --name master pm2 start master.js --name master
@@ -141,17 +143,21 @@ reboot when you are done, then proceed to the next steps. *reboots matter*
1. download and run https://puu.sh/toFHl/01eebbb333.bat 1. download and run https://puu.sh/toFHl/01eebbb333.bat
2. You do not *need* to follow the given instructions, but you should 2. Copy config.json.dist to config.json
3. type `node master.js` 3. You do not *need* to follow the given instructions, but you should
4. type `node master.js`
**Server Host** **Server Host**
1. download and run https://puu.sh/toFHl/01eebbb333.bat 1. download and run https://puu.sh/toFHl/01eebbb333.bat
2. Follow the instructions given 2. Copy config.json.dist to config.json
3. Type `node client.js start [instancename]` to create a new instance. 3. Follow the instructions given
4. Type `node client.js start [instancename]` to create a new instance.
To connect to a master server running on a remote machine, open config.json with your favourite text editor (notepad++). You can also set it up to use the official server browser. To connect to a master server running on a remote machine, open config.json with your favourite text editor (notepad++). You can also set it up to use the official server browser.
+13 -4
View File
@@ -7,18 +7,27 @@
"__comment2": "IP the master web server runs at, can be ignored on the master system", "__comment2": "IP the master web server runs at, can be ignored on the master system",
"masterIP": "localhost", "masterIP": "localhost",
"__commentMasterPort": "HTTP port for the master to listen to, set to 0 or an empty string to not listen for HTTP requests",
"masterPort": 8080, "masterPort": 8080,
"__commentsslPort": "HTTPS port for the master to listen to. Set to 0 or an empty string to not use HTTPS.",
"sslPort": 443,
"sslCert": "database/certificates/cert.crt",
"sslPrivKey": "database/certificates/cert.key",
"__commentMasterAuthToken": "Authentication token to connect to the master server. Find it in secret-api-token.txt on the master.",
"masterAuthToken": "", "masterAuthToken": "",
"__commentAuthSecret": "This is a long random string generated by keyboard mashing. Please mash you own string for security.", "__commentAuthSecret": "This is a long random string used for generating authentication tokens. Do not share. Regenerates when secret-api-token.txt is deleted.",
"masterAuthSecret": "anfeåpvunuennuusnvzunsrevunåzeufnewnufasiojfåqwoiuajknwkjfdabewfkjadfnewåfundjkcvnewmfqewrmn123", "masterAuthSecret": "",
"__comment3": "Your factorio.com username for factorio MP services, also username will be admin", "__comment3": "Your factorio.com username for factorio MP services, also username will be admin on new instances",
"username": "", "username": "",
"__comment4": "Token from your factorio.com profile page. Required for MP and mod manager services.", "__comment4": "Token from your factorio.com profile page. Required for MP and mod manager services.",
"token": "", "token": "",
"factorio_version": "0.16.41",
"__comment7": "Used for communication with the mod portal, not needed if you manage mods by hand", "__comment7": "Used for communication with the mod portal, not needed if you manage mods by hand",
"factorio_version": "0.16.41",
"__comment5": "General user settings", "__comment5": "General user settings",
"verify_user_identity": false, "verify_user_identity": false,
+7 -6
View File
@@ -911,15 +911,16 @@ app.get("/api/getFactorioLocale", function(req,res){
httpRequestDurationMilliseconds.labels(req.route.path).observe(Date.now()-reqStartTime); httpRequestDurationMilliseconds.labels(req.route.path).observe(Date.now()-reqStartTime);
}); });
}); });
if(config.masterPort == 443){ if(config.sslPort){
var privateKey = fs.readFileSync( 'privatekey.pem' ); var certificate = fs.readFileSync( 'database/certificates/cert.crt' );
var certificate = fs.readFileSync( 'certificate.pem' ); var privateKey = fs.readFileSync( 'database/certificates/cert.key' );
server = https.createServer({ httpsServer = https.createServer({
key: privateKey, key: privateKey,
cert: certificate cert: certificate
}, app).listen(443); }, app).listen(config.sslPort);
} else { }
if(config.masterPort){
server = require("http").Server(app); server = require("http").Server(app);
server.listen(config.masterPort || 8080, function () { server.listen(config.masterPort || 8080, function () {
console.log("Listening on port %s...", server.address().port); console.log("Listening on port %s...", server.address().port);