-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
61 lines (54 loc) · 1.66 KB
/
app.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
var express = require('express')
var app = express()
var url = require('url');
var exec = require("child_process").exec
var server_dir = "C:\\path\\to\\server\\directory\\";
var server_file = "server.bat";
var key = "123456";
var port = 82;
app.get("/", function(request, response){
response.send("FiveM Communication API - Made by Koen1997#2008<hr><a href='/restart'>Restart</a><br><a href='/stop'>Stop</a><br><a href='/start'>Start</a>");
});
app.get("/restart", function(request, response){
var url_parts = url.parse(request.url, true);
var query = url_parts.query;
if (query['key'] === key) {
exec("taskkill /IM fxserver.exe /f", (error, stdout, stderr) => {
exec("cd "+server_dir+" && start "+server_file, (error, stdout, stderr) => {
console.log(error);
})
})
response.send("done");
} else {
response.statusCode = 401;
response.send("401 Unauthorized");
}
});
app.get("/start", function(request, response){
var url_parts = url.parse(request.url, true);
var query = url_parts.query;
if (query['key'] === key) {
exec("cd "+server_dir+" && start "+server_file, (error, stdout, stderr) => {
console.log(error);
})
response.send("done");
} else {
response.statusCode = 401;
response.send("401 Unauthorized");
}
});
app.get("/stop", function(request, response){
var url_parts = url.parse(request.url, true);
var query = url_parts.query;
if (query['key'] === key) {
exec("taskkill /IM fxserver.exe /f", (error, stdout, stderr) => {
console.log(error);
})
response.send("done");
} else {
response.statusCode = 401;
response.send("401 Unauthorized");
}
});
app.listen(port);
console.log("Running on port "+ port);