forked from schlagmichdoch/PairDrop
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
51 lines (42 loc) · 1.26 KB
/
server.js
File metadata and controls
51 lines (42 loc) · 1.26 KB
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
import http from "http";
import ErikrafTdropWsServer from "./server/ws-server.js";
const port = parseInt(process.env.PORT, 10) || 3000;
const host = process.env.HOST || "0.0.0.0";
const rtcConfig = {
sdpSemantics: "unified-plan",
iceServers: []
};
const server = http.createServer((req, res) => {
if (req.url === "/config") {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({
lanOnly: true,
rtcConfig
}));
return;
}
if (req.url === "/health") {
res.writeHead(200, { "Content-Type": "text/plain" });
res.end("ok");
return;
}
res.writeHead(200, { "Content-Type": "text/plain" });
res.end("ErikrafT Drop LAN signaling server");
});
new ErikrafTdropWsServer(server, {
rtcConfig,
wsFallback: false,
debugMode: process.env.DEBUG_MODE === "true",
rateLimit: false,
allowLocalOnly: true
});
server.listen(port, host, () => {
console.log(`ErikrafT Drop LAN signaling server running at http://${host}:${port}/`);
console.log("LAN-only mode enabled (local network connections only).");
});
server.on('error', (err) => {
if (err.code === 'EADDRINUSE') {
console.error(err);
process.exit(1);
}
});