forked from husudosu/mpv-remote-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.js
51 lines (45 loc) · 1.42 KB
/
settings.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
const { networkInterfaces } = require("os");
const IP_ADDR = Object.values(networkInterfaces())
.flat()
.find((i) => (i.family == "IPv4" || i.family == 4) && !i.internal);
const CORSOPTIONS = {
origin: "*",
methods: ["GET", "POST", "DELETE", "UPDATE", "PUT", "PATCH"],
};
let settings = {
serverIP: IP_ADDR ? IP_ADDR.address : "127.0.0.1", // Used for displaying the remote access URL
realServerIP: undefined, // Used for app.listen(). Default is all interfaces
serverPort: null,
serverPortRangeEnd: null,
filebrowserPaths: [],
socketName: null,
uselocaldb: false,
unsafefilebrowsing: false,
verbose: false,
};
/*
Loads settings
*/
function loadSettings(argv) {
settings.socketName = argv._[0];
settings.realServerIP = argv.address;
// If we have an explicit address, display that instead
if (argv.address) settings.serverIP = argv.address;
settings.serverPort = argv.webport;
settings.serverPortRangeEnd = argv.webportrangeend;
settings.uselocaldb = argv.uselocaldb;
settings.unsafefilebrowsing = argv.unsafefilebrowsing;
settings.verbose = argv.verbose;
settings.osdMessages = argv["osd-messages"];
if (argv.filebrowserpaths) {
settings.filebrowserPaths = argv.filebrowserpaths.map((el, index) => {
return {
index,
path: el.replace(/^"|'+|"|'+$/g, ""),
};
});
}
}
exports.loadSettings = loadSettings;
exports.settings = settings;
exports.CORSOPTIONS = CORSOPTIONS;