Facilité maj site, ajouté rep "static"
- ajouté répertoire static, defaut pour aller chercher les fichiers - ajouté sample_config.js, cf README
This commit is contained in:
parent
fa9f4f9f28
commit
445be5f7ff
8 changed files with 26 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
node_modules
|
node_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
config.js
|
||||||
|
|
|
@ -8,6 +8,13 @@ cd traque
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp -p sample_config.js config.js
|
||||||
|
```
|
||||||
|
Then edit manually `config.js`.
|
||||||
|
|
||||||
## Run server
|
## Run server
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
6
map.html
6
map.html
|
@ -28,9 +28,9 @@
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var protocol = "https";
|
var protocol = location.protocol;
|
||||||
var server = "localhost";
|
var server = location.hostname;
|
||||||
var port = "9000";
|
var port = location.port;
|
||||||
var socket = io.connect({rejectUnauthorized: false},
|
var socket = io.connect({rejectUnauthorized: false},
|
||||||
protocol+"://"+server+":"+port);
|
protocol+"://"+server+":"+port);
|
||||||
|
|
||||||
|
|
7
sample_config.js
Normal file
7
sample_config.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
// Configuration file for the server
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
"port": 9000,
|
||||||
|
"key": "certif/server.key",
|
||||||
|
"cert": "certif/server.crt"
|
||||||
|
}
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 590 B After Width: | Height: | Size: 590 B |
11
traque.js
11
traque.js
|
@ -23,18 +23,21 @@ var equipes = [];
|
||||||
var http = require('https');//require('http');
|
var http = require('https');//require('http');
|
||||||
var url = require('url');
|
var url = require('url');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
var config = require('./config.js');
|
||||||
|
|
||||||
console.log("Setup http server");
|
console.log("Setup http server");
|
||||||
|
|
||||||
const option = {
|
const option = {
|
||||||
key: fs.readFileSync('certif/server.key'),
|
key: fs.readFileSync(config.key),
|
||||||
cert: fs.readFileSync('certif/server.crt')
|
cert: fs.readFileSync(config.cert)
|
||||||
};
|
};
|
||||||
|
|
||||||
// The server
|
// The server
|
||||||
var server = http.createServer(option, function(req, res){
|
var server = http.createServer(option, function(req, res){
|
||||||
var q = url.parse(req.url, true);
|
var q = url.parse(req.url, true);
|
||||||
var filename = "." + q.pathname;
|
var filename = "static" + q.pathname;
|
||||||
|
if(q.pathname.includes(".."))
|
||||||
|
filename = "static/dotdot.html";
|
||||||
if(q.pathname == "/")
|
if(q.pathname == "/")
|
||||||
filename = "map.html";
|
filename = "map.html";
|
||||||
fs.readFile(filename, function(err, data) {
|
fs.readFile(filename, function(err, data) {
|
||||||
|
@ -104,5 +107,5 @@ io.sockets.on('connection', function(socket){
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("Launch server");
|
console.log("Launch server");
|
||||||
server.listen(9000);
|
server.listen(config.port, "::");
|
||||||
console.log("Running !");
|
console.log("Running !");
|
||||||
|
|
Loading…
Reference in a new issue