-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathosolo.js
85 lines (61 loc) · 1.82 KB
/
osolo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var app = require('http').createServer(handler);
var io = require('socket.io')(app);
var fs = require('fs');
var path = require("path");
var rcon = require('srcds-rcon');
console.log('Osolo v.0.0.5')
console.log('Copyright (C) 2017 Viktor Lazarev(russiantux)')
console.log('This program comes with ABSOLUTELY NO WARRANTY!!')
console.log('This is free software, and you are welcome to redistribute it under certain conditions')
console.log('For detailed use of this program, please consult the LICENSE.MD file')
app.listen(8080);
function handler (request, response) {
var filePath = '.' + request.url;
if (filePath == './')
filePath = './index.html';
var extname = path.extname(filePath);
var contentType = 'text/html';
switch (extname) {
case '.js':
contentType = 'text/javascript';
break;
case '.css':
contentType = 'text/css';
break;
case '.ttf':
contentType = 'font/ttf';
break;
}
fs.exists(filePath, function(exists) {
if (exists) {
fs.readFile(filePath, function(error, content) {
if (error) {
response.writeHead(500);
response.end();
}
else {
response.writeHead(200, { 'Content-Type': contentType });
response.end(content, 'utf-8');
}
});
}
else {
response.writeHead(404);
response.end();
}
});
};
console.log('Osolo is online, running at port 8080')
io.on('connection', function (socket) {
socket.on('runserver', function (RunServer) {
console.log('Recived call to run server.');
var exec = require('child_process').exec;
var child = exec('java -Xmx1024M -Xms1024M -jar minecraft_server.1.10.jar',
function (error, stdout, stderr){
console.log('Server started');
if(error !== null){
console.log("Error when starting the server => "+error);
}
});
});
});