diff --git a/config.json b/config.json index 1280405..90a82af 100644 --- a/config.json +++ b/config.json @@ -9,6 +9,7 @@ "delayOfTries": 2000, "output": "output.m3u8" }, + "maxBuffer": 5120, "passwords": [ { "name": "Admin", diff --git a/package-lock.json b/package-lock.json index 9ac3905..ccdd86b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,11 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@sindresorhus/is": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.6.0.tgz", + "integrity": "sha1-OD9Faya8lseInwMyB59DWLFsWNw=" + }, "abbrev": { "version": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha1-+PLIh60Qv2f2NPAFtph/7TF5qsg=" @@ -173,13 +178,6 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, - "async": { - "version": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", - "integrity": "sha1-hDGQ/WtzV6C54clW7d3V7IRitU0=", - "requires": { - "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz" - } - }, "async-each": { "version": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", @@ -340,6 +338,20 @@ "version": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" }, + "cacheable-request": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-2.1.3.tgz", + "integrity": "sha1-uTVgfdKrKBKJi++yJPZqqGxTPbs=", + "requires": { + "clone-response": "1.0.2", + "get-stream": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "http-cache-semantics": "3.8.1", + "keyv": "3.0.0", + "lowercase-keys": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", + "normalize-url": "2.0.0", + "responselike": "1.0.2" + } + }, "caller-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", @@ -427,6 +439,14 @@ "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", "dev": true }, + "clone-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", + "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "requires": { + "mimic-response": "1.0.0" + } + }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -525,8 +545,7 @@ }, "core-util-is": { "version": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "cors": { "version": "https://registry.npmjs.org/cors/-/cors-2.8.4.tgz", @@ -573,6 +592,19 @@ "ms": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz" } }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" + }, + "decompress-response": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", + "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", + "requires": { + "mimic-response": "1.0.0" + } + }, "deep-extend": { "version": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", @@ -610,6 +642,23 @@ "version": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "dns-packet": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-1.2.2.tgz", + "integrity": "sha512-kN+DjfGF7dJGUL7nWRktL9Z18t1rWP3aQlyZdY8XlpvU3Nc6GeFTQApftcjtWKxAZfiggZSGrCEoszNgvnpwDg==", + "requires": { + "ip": "1.1.5", + "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" + } + }, + "dns-socket": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/dns-socket/-/dns-socket-1.6.2.tgz", + "integrity": "sha512-Ztbaf5fToBfm/4+sVEJi7mT2mJOLYYpI+TpgOhxwp5l28UwunTpHMccVhTe9L0F6pQ2cUF0ja9ukuTCtzYq2Ig==", + "requires": { + "dns-packet": "1.2.2" + } + }, "doctrine": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.2.tgz", @@ -634,8 +683,7 @@ }, "duplexer3": { "version": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", - "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", - "dev": true + "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=" }, "eachr": { "version": "https://registry.npmjs.org/eachr/-/eachr-2.0.4.tgz", @@ -1186,14 +1234,6 @@ } } }, - "fluent-ffmpeg": { - "version": "https://registry.npmjs.org/fluent-ffmpeg/-/fluent-ffmpeg-2.1.2.tgz", - "integrity": "sha1-yVLeIkD4EuvaCqgAbXd27irPfXQ=", - "requires": { - "async": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", - "which": "https://registry.npmjs.org/which/-/which-1.3.0.tgz" - } - }, "for-in": { "version": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", @@ -1220,6 +1260,15 @@ "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", "dev": true }, + "from2": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", + "integrity": "sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8=", + "requires": { + "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz" + } + }, "fs.realpath": { "version": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" @@ -2249,8 +2298,7 @@ }, "get-stream": { "version": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", - "dev": true + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "glob": { "version": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -2367,6 +2415,19 @@ "version": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" }, + "has-symbol-support-x": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz", + "integrity": "sha512-JkaetveU7hFbqnAC1EV1sF4rlojU2D4Usc5CmS69l6NfmPDnpnFUegzFg33eDkkpNCxZ0mQp65HwUDrNFS/8MA==" + }, + "has-to-string-tag-x": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz", + "integrity": "sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw==", + "requires": { + "has-symbol-support-x": "1.4.1" + } + }, "hls-server": { "version": "https://registry.npmjs.org/hls-server/-/hls-server-1.2.2.tgz", "integrity": "sha1-C++O1gINrKFG6Iko7tFFiyue630=", @@ -2385,6 +2446,11 @@ "version": "https://registry.npmjs.org/http-attach/-/http-attach-1.0.0.tgz", "integrity": "sha1-ZeqA8AaWMB3s5dbMiC2BGzEy0AY=" }, + "http-cache-semantics": { + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz", + "integrity": "sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w==" + }, "http-errors": { "version": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", @@ -2493,6 +2559,25 @@ "through": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" } }, + "into-stream": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", + "integrity": "sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY=", + "requires": { + "from2": "2.3.0", + "p-is-promise": "1.1.0" + } + }, + "ip": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + }, + "ip-regex": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz", + "integrity": "sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=" + }, "ipaddr.js": { "version": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.5.2.tgz", "integrity": "sha1-1LUFvemUaYfM8PxY2QEP+WB+P6A=" @@ -2561,6 +2646,14 @@ "is-extglob": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz" } }, + "is-ip": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-ip/-/is-ip-2.0.0.tgz", + "integrity": "sha1-aO6gfooKCpTC0IDdZ0xzGrKkYas=", + "requires": { + "ip-regex": "2.1.0" + } + }, "is-npm": { "version": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", "integrity": "sha1-8vtjpl5JBbQGyGBydloaTceTufQ=", @@ -2579,6 +2672,11 @@ "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, + "is-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", + "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=" + }, "is-path-cwd": { "version": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=" @@ -2597,6 +2695,11 @@ "path-is-inside": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz" } }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=" + }, "is-posix-bracket": { "version": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", @@ -2629,8 +2732,7 @@ }, "is-retry-allowed": { "version": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", - "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=", - "dev": true + "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=" }, "is-stream": { "version": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -2639,12 +2741,12 @@ }, "isarray": { "version": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "isexe": { "version": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true }, "isobject": { "version": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", @@ -2654,6 +2756,15 @@ "isarray": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" } }, + "isurl": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isurl/-/isurl-1.0.0.tgz", + "integrity": "sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w==", + "requires": { + "has-to-string-tag-x": "1.4.1", + "is-object": "1.0.1" + } + }, "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", @@ -2670,6 +2781,11 @@ "esprima": "4.0.0" } }, + "json-buffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", + "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=" + }, "json-schema-traverse": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", @@ -2682,6 +2798,14 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, + "keyv": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.0.0.tgz", + "integrity": "sha512-eguHnq22OE3uVoSYG0LVWNP+4ppamWr9+zWBe1bsNcovIMy6huUJFPgy4mGwCd/rnl3vOLGW1MTlu4c57CT1xA==", + "requires": { + "json-buffer": "3.0.0" + } + }, "kind-of": { "version": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", @@ -2740,7 +2864,8 @@ }, "lodash": { "version": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true }, "lodash._baseassign": { "version": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", @@ -2833,8 +2958,7 @@ }, "lowercase-keys": { "version": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", - "integrity": "sha1-TjNms55/VFfjXxMkvfb4jQv8cwY=", - "dev": true + "integrity": "sha1-TjNms55/VFfjXxMkvfb4jQv8cwY=" }, "lru-cache": { "version": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", @@ -2960,6 +3084,11 @@ "integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=", "dev": true }, + "mimic-response": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.0.tgz", + "integrity": "sha1-3z02Uqc/3ta5sLJBRub9BSNTRY4=" + }, "minimatch": { "version": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", @@ -3002,6 +3131,11 @@ "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", "dev": true }, + "my-ip": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/my-ip/-/my-ip-1.1.1.tgz", + "integrity": "sha1-7l+aMD2taHdsGrp71iRpAU4QpJg=" + }, "nan": { "version": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz", "integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=", @@ -3063,6 +3197,23 @@ "remove-trailing-separator": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz" } }, + "normalize-url": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-2.0.0.tgz", + "integrity": "sha1-4E2KNp86TK3IUKKFT4+w+KgSAyg=", + "requires": { + "prepend-http": "2.0.0", + "query-string": "5.0.1", + "sort-keys": "2.0.0" + }, + "dependencies": { + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=" + } + } + }, "npm-run-path": { "version": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", @@ -3136,10 +3287,19 @@ "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, + "p-cancelable": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.3.0.tgz", + "integrity": "sha512-RVbZPLso8+jFeq1MfNvgXtCRED2raz/dKpacfTNxsx6pLEpEomM7gah6VeHSYV3+vo0OAi4MkArtQcWWXuQoyw==" + }, "p-finally": { "version": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" + }, + "p-is-promise": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", + "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=" }, "p-limit": { "version": "1.1.0", @@ -3160,6 +3320,14 @@ "version": "https://registry.npmjs.org/p-map/-/p-map-1.2.0.tgz", "integrity": "sha1-5OlPMR6rvIYzoeeZCBZfyiYkG2s=" }, + "p-timeout": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-2.0.1.tgz", + "integrity": "sha512-88em58dDVB/KzPEx1X0N3LwFfYZPyDc4B6eF38M1rk9VTZMbxXXgjugz8mmwpS9Ox4BDZ+t6t3QP5+/gazweIA==", + "requires": { + "p-finally": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz" + } + }, "package-json": { "version": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", @@ -3306,8 +3474,7 @@ }, "process-nextick-args": { "version": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" }, "progress": { "version": "2.0.0", @@ -3336,10 +3503,75 @@ "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, + "public-ip": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/public-ip/-/public-ip-2.4.0.tgz", + "integrity": "sha512-74cIy+T2cDmt+Z71AfVipH2q6qqZITPyNGszKV86OGDYIRvti1m8zg4GOaiTPCLgEIWnToKYXbhEnMiZWHPEUA==", + "requires": { + "dns-socket": "1.6.2", + "got": "8.0.1", + "is-ip": "2.0.0", + "pify": "3.0.0" + }, + "dependencies": { + "got": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/got/-/got-8.0.1.tgz", + "integrity": "sha1-bX+Ls+uZ5a+RLv4moQRHZEHgjn8=", + "requires": { + "@sindresorhus/is": "0.6.0", + "cacheable-request": "2.1.3", + "decompress-response": "3.3.0", + "duplexer3": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", + "get-stream": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "into-stream": "3.1.0", + "is-retry-allowed": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", + "isurl": "1.0.0", + "lowercase-keys": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", + "mimic-response": "1.0.0", + "p-cancelable": "0.3.0", + "p-timeout": "2.0.1", + "pify": "3.0.0", + "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "timed-out": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", + "url-parse-lax": "3.0.0", + "url-to-options": "1.0.1" + } + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" + }, + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=" + }, + "url-parse-lax": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", + "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", + "requires": { + "prepend-http": "2.0.0" + } + } + } + }, "qs": { "version": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=" }, + "query-string": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.0.1.tgz", + "integrity": "sha512-aM+MkQClojlNiKkO09tiN2Fv8jM/L7GWIjG2liWeKljlOdOPNWr+bW3KQ+w5V/uKprpezC7fAsAMsJtJ+2rLKA==", + "requires": { + "decode-uri-component": "0.2.0", + "object-assign": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "strict-uri-encode": "1.1.0" + } + }, "randomatic": { "version": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", @@ -3437,7 +3669,6 @@ "readable-stream": { "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", "integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw=", - "dev": true, "requires": { "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", @@ -3524,6 +3755,14 @@ "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", "dev": true }, + "responselike": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", + "integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=", + "requires": { + "lowercase-keys": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz" + } + }, "restore-cursor": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", @@ -3718,6 +3957,14 @@ } } }, + "sort-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz", + "integrity": "sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg=", + "requires": { + "is-plain-obj": "1.1.0" + } + }, "spdx-correct": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", @@ -3763,6 +4010,11 @@ "duplexer": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz" } }, + "strict-uri-encode": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", + "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=" + }, "string-width": { "version": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", @@ -3775,7 +4027,6 @@ "string_decoder": { "version": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", "integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=", - "dev": true, "requires": { "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" } @@ -3854,8 +4105,7 @@ }, "timed-out": { "version": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", - "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=", - "dev": true + "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=" }, "tmp": { "version": "0.0.33", @@ -4002,10 +4252,14 @@ "prepend-http": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz" } }, + "url-to-options": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/url-to-options/-/url-to-options-1.0.1.tgz", + "integrity": "sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k=" + }, "util-deprecate": { "version": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "utils-merge": { "version": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -4047,6 +4301,7 @@ "which": { "version": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "dev": true, "requires": { "isexe": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz" } diff --git a/package.json b/package.json index 6b0402d..365b5ed 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,8 @@ "express": "^4.16.2", "hls-server": "^1.2.2", "i18n": "^0.8.3", + "my-ip": "^1.1.1", + "public-ip": "^2.4.0", "rtmp-server": "^0.2.0", "socket.io": "^2.0.3" }, diff --git a/src/chatServer.js b/src/chatServer.js index 2100ef8..a990c06 100644 --- a/src/chatServer.js +++ b/src/chatServer.js @@ -1,19 +1,22 @@ const chalk = require('chalk'); -const { deleteVideos } = require('./utils'); +const { deleteVideos, stringify, log } = require('./utils'); let numUsers = 0; const usersCount = {}; +const sum = x => Object.values(x).reduce((acc, v) => acc + v, 0); const userAdd = (user, x = 1) => { + if (user === 'Admin') return sum(usersCount); + if (!usersCount[user]) { usersCount[user] = 1; - return usersCount; + return sum(usersCount); } usersCount[user] += x; - return usersCount; + return sum(usersCount); }; // io -> Promise -> socket @@ -43,8 +46,8 @@ function chatServer(io) { // we store the username in the socket session for this client socket.username = username; - userAdd(username); - numUsers += 1; + + numUsers = userAdd(username); addedUser = true; if (usersCount.Admin) delete usersCount.Admin; @@ -58,10 +61,10 @@ function chatServer(io) { usersCount, }); + log('-----------------------'); console.log(chalk.bold('In ') + chalk.green(` > ${socket.username}`)); - console.log(JSON.stringify(usersCount, null, ' ')); + console.log(stringify(usersCount)); console.log(chalk.bold('Total: ') + chalk.yellow(numUsers)); - console.log(''); }); // When the client emits 'typing', we broadcast it to others @@ -76,8 +79,7 @@ function chatServer(io) { // When the user disconnects. socket.on('disconnect', () => { if (addedUser) { - numUsers -= 1; - userAdd(socket.username, -1); + numUsers = userAdd(socket.username, -1); // echo globally that this client has left socket.broadcast.emit('user left', { @@ -86,10 +88,10 @@ function chatServer(io) { usersCount, }); + log('-----------------------'); console.log(chalk.bold('Out') + chalk.red(` < ${socket.username}`)); - console.log(JSON.stringify(usersCount, null, ' ')); + console.log(stringify(usersCount)); console.log(chalk.bold('Total: ') + chalk.yellow(numUsers)); - console.log(''); } }); }); diff --git a/src/rtmpServer.js b/src/rtmpServer.js index 3d4b859..a1387e5 100644 --- a/src/rtmpServer.js +++ b/src/rtmpServer.js @@ -9,7 +9,8 @@ function server(socket) { rtmpServer.listen(1935); rtmpServer.on('error', (err) => { - throw err; + log('RTMP server error:', 'yellow'); + log(err, 'yellow'); }); rtmpServer.on('client', (client) => { diff --git a/src/rtmpToHLS.js b/src/rtmpToHLS.js index 94f2365..812110a 100644 --- a/src/rtmpToHLS.js +++ b/src/rtmpToHLS.js @@ -1,6 +1,5 @@ const path = require('path'); -const { exec } = require('child_process'); -const { log } = require('./utils'); +const { log, execute } = require('./utils'); const { hls: { input, maxrate, bufsize, output, numberOfTries, delayOfTries, @@ -29,7 +28,7 @@ const rtmpToHLS = (tries = 0) => { ' -hls_wrap 10' + ' -start_number 1 '}${path.join(videosPath, output)}`; - exec(command, (err, stdout, stderr) => { + execute(command, (err, stdout, stderr) => { if (err) { if (tries >= numberOfTries) { log('FFmpeg error:', 'red'); diff --git a/src/utils.js b/src/utils.js index 8b351a7..7f86f60 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,7 +1,12 @@ const del = require('del'); const path = require('path'); -const { passwords, videosPath } = require('../config.json'); +const { passwords, videosPath, maxBuffer } = require('../config.json'); const chalk = require('chalk'); +const { exec } = require('child_process'); + +const execute = (command, callback) => { + exec(command, { maxBuffer: 1024 * maxBuffer }, callback); +}; const log = (data, color = 'blue') => { console.log(chalk[color](data)); @@ -25,8 +30,16 @@ const isAuth = (username, pass) => { return passwords.some(({ password }) => password === pass); }; +const stringify = (obj) => { + const stg = JSON.stringify(obj, null, ' '); + + return stg.replace(/[{}]+/g, ''); +}; + module.exports = { - isAuth, deleteVideos, + execute, + isAuth, log, + stringify, }; diff --git a/src/webServer.js b/src/webServer.js index d45701d..1ed86f3 100644 --- a/src/webServer.js +++ b/src/webServer.js @@ -4,8 +4,10 @@ const cookieParser = require('cookie-parser'); const cors = require('cors'); const i18n = require('i18n'); const path = require('path'); +const ip = require('my-ip'); +const publicIp = require('public-ip'); -const { isAuth } = require('./utils'); +const { isAuth, log } = require('./utils'); const port = process.env.PORT || 3000; @@ -18,7 +20,18 @@ const protect = (req, res, next) => { }; function webServer(app, server) { - server.listen(port, 'localhost', () => console.log(`\nhttp://localhost:${port}\n`)); + server.listen(port, '0.0.0.0', () => { + log(''); + log('Web server is running on:', 'white'); + log(`http://localhost:${port}`); + log(`http://${ip()}:${port}`); + + publicIp.v4().then((v4) => { + log('Your external IP is:', 'white'); + log(`http://${v4}`); + log(''); + }); + }); // Cookie secret. const secret = 'Mmm98N)8bewd88';