MCPcopy Create free account
hub / github.com/UnsignedInt8/LightSword / parseUsers

Function parseUsers

server/bin/cli.ts:59–68  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

57if (fileOptions) Object.getOwnPropertyNames(fileOptions).forEach(n => args[n] = args[n] === undefined ? fileOptions[n] : args[n]);
58
59function parseUsers(path: string): { port: number, password: string, cipherAlgorithm: string, expireDate?: string, disableSelfProtection?: boolean }[] {
60 if (!path) return [];
61 if (!fs.existsSync(path)) return [];
62
63 var content: string = fs.readFileSync(path).toString();
64 return content.split('\n').where((l: string) => l.length > 0 && !l.trim().startsWith('#')).select((l: string) => {
65 var info = l.trim().split(' ');
66 return { port: Number(info[0]), password: info[1], cipherAlgorithm: info[2], expireDate: info[3], speed: Number(info[4]), disableSelfProtection: args.disableSelfProtection };
67 }).toArray();
68}
69
70var users = parseUsers(args.users);
71

Callers 1

cli.tsFile · 0.85

Calls 4

toStringMethod · 0.80
toArrayMethod · 0.80
selectMethod · 0.80
whereMethod · 0.80

Tested by

no test coverage detected