Fix port cehcking

This commit is contained in:
Aya Morisawa 2018-07-13 23:25:32 +09:00
parent bd805f1d88
commit aec7d53414
3 changed files with 18188 additions and 16351 deletions

34527
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -66,6 +66,7 @@
"@types/ms": "0.7.30",
"@types/node": "10.5.2",
"@types/parse5": "5.0.0",
"@types/portscanner": "2.1.0",
"@types/pug": "2.0.4",
"@types/qrcode": "1.2.0",
"@types/ratelimiter": "2.1.28",
@ -160,6 +161,7 @@
"on-build-webpack": "0.1.0",
"os-utils": "0.0.14",
"parse5": "5.0.0",
"portscanner": "2.2.0",
"progress-bar-webpack-plugin": "1.11.0",
"prominence": "0.2.0",
"promise-sequential": "1.1.1",
@ -185,7 +187,6 @@
"summaly": "2.0.6",
"swagger-jsdoc": "1.9.7",
"syuilo-password-strength": "0.0.1",
"tcp-port-used": "0.1.2",
"textarea-caret": "3.1.0",
"tmp": "0.0.33",
"ts-loader": "4.4.1",

View file

@ -8,7 +8,7 @@ import * as os from 'os';
import * as cluster from 'cluster';
import * as debug from 'debug';
import chalk from 'chalk';
// import portUsed = require('tcp-port-used');
import * as portscanner from 'portscanner';
import isRoot = require('is-root');
import Xev from 'xev';
@ -125,12 +125,9 @@ async function init(): Promise<Config> {
throw 'You need root privileges to listen on port below 1024 on Linux';
}
// Check if a port is being used
/* https://github.com/stdarg/tcp-port-used/issues/3
if (await portUsed.check(config.port)) {
throw `Port ${config.port} is already used`;
if (await portscanner.checkPortStatus(config.port, '127.0.0.1') === 'open') {
throw `Port ${config.port} is already in use`;
}
*/
// Try to connect to MongoDB
const mongoDBLogger = new Logger('MongoDB');