Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Commit

Permalink
Fix merge mess
Browse files Browse the repository at this point in the history
  • Loading branch information
getkey committed Feb 7, 2017
1 parent 92e54f0 commit b1da1d1
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 239 deletions.
1 change: 0 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ rules:
- always
no-trailing-spaces: "error"
no-console: 0
eqeqeq: "error"
parserOptions:
sourceType: "module"
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"readme": "readme.md",
"license": "MPL-2.0",
"scripts": {
"test": "./node_modules/ava/cli.js ./tests/payloads.js ./tests/subpayloads.js ./tests/ip_picker.js",
"stylelint": "./node_modules/stylelint/dist/cli.js ./static/*.css"
"test": "ava ./tests/payloads.js ./tests/subpayloads.js",
"stylelint": "stylelint ./static/*.css"
},
"ava": {
"require": [
Expand Down
29 changes: 3 additions & 26 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ JumpSuit works in a decentralised way: anyone can create a game server. After re

## How to build

```
```sh
$ npm install
$ node build/bundler.js
```
Expand Down Expand Up @@ -68,18 +68,7 @@ In any case, if it doesn't exists, it will be created.

You can modify settings without having to restart the server.

Here is what the default file looks like:

```JSON
{
"dev": false,
"master": "wss://jumpsuit.space",
"monitor": false,
"port": 7483,
"secure" false,
"server_name": "JumpSuit server"
}
```
In this file you can set the following parameters:

Parameter | Explanation | Default | Variable type
--------- | ----------- | ------- | -------------
Expand All @@ -96,19 +85,7 @@ The master server's configuration works the same way as the game server's, all p
$ node master_server.js path/to/your/config.json
```

Here is what the default file looks like:

```JSON
{
"dev": true,
"monitor": false,
"nat": {
"ipv4_provider": "https://ipv4.icanhazip.com/",
"ipv6_provider": "https://ipv6.icanhazip.com/"
},
"port": 80
}
```
In this file you can set the following parameters:

Parameter | Explanation | Default | Variable type
--------- | ----------- | ------- | -------------
Expand Down
4 changes: 2 additions & 2 deletions server/lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class Lobby {
entitiesDelta.removedShots.splice(iRm, 1);
}
});
if (entitiesDelta.addedShots.length !== 0) this.broadcast(message.addEntity.serialize([], [], entitiesDelta.addedShots, []));
//if (entitiesDelta.removedShots.length !== 0) this.broadcast(message.removeEntity.serialize([], [], entitiesDelta.removedShots, [])); // Why is this disabled?
if (entitiesDelta.addedShots.length != 0) this.broadcast(message.addEntity.serialize([], [], entitiesDelta.addedShots, []));
//if (entitiesDelta.removedShots.length != 0) this.broadcast(message.removeEntity.serialize([], [], entitiesDelta.removedShots, [])); // Why is this disabled?


this.players.forEach(function(player) {
Expand Down
77 changes: 10 additions & 67 deletions server/master_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import * as config from './config_loader.js';
config.init(process.argv[2] || './master_config.json', {
dev: true,
monitor: false,
nat: {
ipv4_provider: 'https://ipv4.icanhazip.com/',
ipv6_provider: 'https://ipv6.icanhazip.com/'
},
port: 80
},
(newConfig, previousConfig) => {
Expand All @@ -30,7 +26,6 @@ require('colors');
const http = require('http'),
fs = require('fs');

ipPicker.init().then(() => {

if(config.config.monitor) monitor.setMonitorMode();

Expand Down Expand Up @@ -75,71 +70,19 @@ let server = http.createServer((req, res) => {
console.log(err);
}
}
effectiveIp(clientIp) {
return ipPicker.pick(this.ip, clientIp);
}
}
let gameServers = [];


if(config.config.monitor) monitor.setMonitorMode();

let files = {};
function loadFile(name, path) {
let mimeList = {html: 'text/html', css: 'text/css', svg: 'image/svg+xml', png: 'image/png', js: 'application/javascript', ogg: 'audio/ogg', opus: 'audio/ogg'},
extension = path.slice(path.lastIndexOf('.') - path.length + 1);
files[name] = {
content: fs.readFileSync(path),
mtime: fs.statSync(path).mtime,
path: path,
mime: extension in mimeList ? mimeList[extension] : 'application/octet-stream'
};
if (config.config.dev && (extension === 'html' || extension === 'css' || extension === 'js')) files[name].content = files[name].content.toString('utf8').replace(/https:\/\/jumpsuit\.space/g, '');
}
loadFile('/ipaddr.min.js', './node_modules/ipaddr.js/ipaddr.min.js');
loadFile('/vinage.js', './node_modules/vinage/vinage.js');

files.construct = function(path, oName) {
fs.readdirSync(path).forEach(function(pPath) {
let cPath = path + '/' + pPath,
stat = fs.statSync(cPath);
if(stat.isDirectory()) {//WE NEED TO GO DEEPER
files.construct(cPath, oName + pPath + '/');
} else loadFile(oName + pPath, cPath);
});
};
files.construct('./static', '/'); // load everything under `./static` in RAM for fast access

server = http.createServer(function (req, res) {
if (req.url === '/index.html') {
res.writeHead(301, {'Location': '/'});
if (req.headers['if-modified-since'] !== undefined && new Date(req.headers['if-modified-since']).toUTCString() === files[req.url].mtime.toUTCString()) {
res.writeHead(304);
res.end();
return;
} //beautifying URL, shows foo.bar when requested foo.bar/index.html

if (req.url === '/') req.url = '/index.html';
if (files[req.url] !== undefined) {
res.setHeader('Cache-Control', 'public, no-cache, must-revalidate, proxy-revalidate');
if (config.config.dev) {
try {
if (fs.statSync(files[req.url].path).mtime.getTime() !== files[req.url].mtime.getTime()) loadFile(req.url, files[req.url].path);
} catch(err) {
console.log(err);
}
}
if (req.headers['if-modified-since'] !== undefined && new Date(req.headers['if-modified-since']).toUTCString() === files[req.url].mtime.toUTCString()) {
res.writeHead(304);
res.end();
} else {
res.writeHead(200, {'Content-Type': files[req.url].mime, 'Last-Modified': files[req.url].mtime.toUTCString()});
res.end(files[req.url].content);
}
} else {
res.writeHead(404);
res.end('Error 404:\nPage not found\n');
res.writeHead(200, {'Content-Type': files[req.url].mime, 'Last-Modified': files[req.url].mtime.toUTCString()});
res.end(files[req.url].content);
}
});
server.listen(config.config.port);
} else {
res.writeHead(404);
res.end('Error 404:\nPage not found\n');
}
});
server.listen(config.config.port);


const Master = require('enslavism').Master;
Expand Down
3 changes: 0 additions & 3 deletions server/mods/capture/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import Player from '../../../shared/player.js';
import { config } from '../../config_loader.js';
import * as monitor from '../../monitor.js';

import { config } from '../../config_loader.js';
import * as monitor from '../..//monitor.js';

export default class SrvPlayer extends Player {
constructor(dc) {
super();
Expand Down
3 changes: 0 additions & 3 deletions tests/config.js

This file was deleted.

88 changes: 0 additions & 88 deletions tests/ip_picker.js

This file was deleted.

46 changes: 0 additions & 46 deletions tests/os.js

This file was deleted.

2 changes: 1 addition & 1 deletion tests/websocket-fuzzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ ws.on('open', function open() {
}
console.log(array);

ws.send(array.buffer);
ws.send(array.buffer, { binary: true, mask: true });
}, 0);
});

0 comments on commit b1da1d1

Please sign in to comment.