From b5d8380fcd6c48210399c70aa7f5edd2ecd6036e Mon Sep 17 00:00:00 2001 From: ilim Date: Sun, 28 Jul 2019 02:29:22 +0900 Subject: [PATCH 1/3] Use another region on ngrok --- app.js | 2 +- ngrok.js | 2 +- slack.js | 4 ++-- utils.js | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index ac6e452..dcbc0a7 100644 --- a/app.js +++ b/app.js @@ -45,7 +45,7 @@ disk input = 'ffmpeg -i /dev/video0'; } daemon( - `${input} -vcodec libx264 -pix_fmt yuv420p -preset veryfast -tune zerolatency,stillimage,film -vb 2500k -vf "drawtext=text='%{localtime}':fontcolor=white@0.8:x=0:y=h-lh*1.2:fontsize=24" -f flv rtmp://localhost:${1935}/live/bushitsuchan -loglevel warning`, + `${input} -vcodec libx264 -pix_fmt yuv420p -preset veryfast -tune zerolatency,stillimage,film -vb 2500k -vf "drawtext=text='%{localtime}':fontcolor=blue@1:x=0:y=h-lh*1.2:fontsize=24" -f flv rtmp://localhost:${1935}/live/bushitsuchan -loglevel warning`, ); daemon( `ffmpeg -i rtmp://localhost:1935/live/bushitsuchan -hls_flags delete_segments -g 40 -f hls ${mountPath}/output.m3u8 -loglevel warning`, diff --git a/ngrok.js b/ngrok.js index 8d02642..a9a4df1 100644 --- a/ngrok.js +++ b/ngrok.js @@ -2,6 +2,6 @@ const ngrok = require('ngrok'); module.exports.run = async (token, port = 3000) => { await ngrok.authtoken(token); - const url = await ngrok.connect(port); + const url = await ngrok.connect({ addr: port, region: 'ap' }); return url; }; diff --git a/slack.js b/slack.js index d48f45b..8b9259a 100644 --- a/slack.js +++ b/slack.js @@ -55,7 +55,7 @@ module.exports = (awsUrl, contactChannel, rtmpAddress, slackBotAccessToken, slac if (!former || !store.get(key)) { respond({ text: - '失敗 おそらくすでに無期限延長されているか,写真がされたあとプログラムが再実行されたことに起因すると思慮されます。', + '失敗 おそらくすでに無期限延長されているか,写真がされたあと部室ちゃんが再実行されたことに起因すると思慮されます。', response_type: 'ephemeral', replace_original: false, }); @@ -80,7 +80,7 @@ module.exports = (awsUrl, contactChannel, rtmpAddress, slackBotAccessToken, slac if (!chunks) { respond({ text: - '失敗 おそらく写真がされたあとプログラムが再実行されたことに起因すると思慮されます。', + '失敗 おそらく写真がされたあと部室ちゃんが再実行されたことに起因すると思慮されます。', response_type: 'ephemeral', replace_original: false, }); diff --git a/utils.js b/utils.js index 511e37a..0832c85 100644 --- a/utils.js +++ b/utils.js @@ -17,6 +17,9 @@ module.exports.daemon = async (command, ms = 1000 * 10, maxCount = 100) => { // eslint-disable-next-line no-await-in-loop await module.exports.exec(command); } catch (e) { + if (i === 0) { + console.error(e); + } logger.error(e); // eslint-disable-next-line no-await-in-loop await wait(ms); From d42920bf6915b68118102ca870d9fee3e03aee1f Mon Sep 17 00:00:00 2001 From: ilim Date: Sun, 28 Jul 2019 02:33:41 +0900 Subject: [PATCH 2/3] Fix bug --- slack.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slack.js b/slack.js index 8b9259a..c92bec6 100644 --- a/slack.js +++ b/slack.js @@ -88,7 +88,7 @@ module.exports = (awsUrl, contactChannel, rtmpAddress, slackBotAccessToken, slac } fs.mkdirSync(`${__dirname}/photos`, { recursive: true }); - fs.writeFileSync(`${__dirname}/photos/${base64Encode(key)}.jpg`, chunks.data); + fs.writeFileSync(`${__dirname}/photos/${base64Encode(key)}.jpg`, Buffer.from(chunks)); template = template.replace(/\${expired-time}/g, '写真はずっと表示されます'); } @@ -168,7 +168,7 @@ module.exports = (awsUrl, contactChannel, rtmpAddress, slackBotAccessToken, slac return; } res.contentType('image/jpg'); - res.send(Buffer.from(chunks.data)); + res.send(Buffer.from(chunks)); }); router.get('/thumb.jpg', (req, res) => { From d057b2443d722ed46a2a90c7edb817167b1872e6 Mon Sep 17 00:00:00 2001 From: ilim Date: Sun, 28 Jul 2019 02:41:20 +0900 Subject: [PATCH 3/3] Update packages --- package-lock.json | 154 +++++++++++++++++++++++++++++++++++++--------- package.json | 6 +- 2 files changed, 128 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5be108e..c47a8f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,10 +25,16 @@ } }, "@slack/interactive-messages": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@slack/interactive-messages/-/interactive-messages-1.1.1.tgz", - "integrity": "sha512-FIyj/sBmCjQ4B4Tt1z6MNdFmgvyT5CK2U2VrWGcdqdynxQk8tlN/AA/C0SSc5wIr/WNYck1c90ZawQJTlw3YsQ==", - "requires": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@slack/interactive-messages/-/interactive-messages-1.2.0.tgz", + "integrity": "sha512-Q0Dm29ctDM6ljkURcHxVe5AXYNqyEBTGLllUQX+zrr7UXbB/V62LhFw82eDOQN+kDhsOeBlpRscL1EMJvKDkxw==", + "requires": { + "@types/debug": "^4.1.4", + "@types/express": "^4.17.0", + "@types/lodash.isfunction": "^3.0.6", + "@types/lodash.isregexp": "^4.0.6", + "@types/lodash.isstring": "^4.0.6", + "@types/node": ">=4.2.0", "axios": "^0.18.0", "debug": "^3.1.0", "lodash.isfunction": "^3.0.9", @@ -59,24 +65,23 @@ } }, "@slack/types": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@slack/types/-/types-1.0.0.tgz", - "integrity": "sha512-IktC4uD/CHfLQcSitKSmjmRu4a6+Nf/KzfS6dTgUlDzENhh26l8aESKAuIpvYD5VOOE6NxDDIAdPJOXBvUGxlg==" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@slack/types/-/types-1.1.0.tgz", + "integrity": "sha512-uak4Jbi8nlX8xmElkPt1ixxVQXMKdBRbzBayn5bRzZ9Yx3bQGlyJdFs6GjEKI+fvFP0ZTiGWKOzlJTH3Tm/9fg==" }, "@slack/web-api": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@slack/web-api/-/web-api-5.0.1.tgz", - "integrity": "sha512-L2Nc8P+NjXH1yqnsNhqxsrbpW3Qv+//9X5PQqcM3bctDmvmwTuhuM1X208RVD2avhnC89aghY5PssyaayWj5sA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@slack/web-api/-/web-api-5.1.0.tgz", + "integrity": "sha512-bnzS1I8iOfNB4xSX0zQ/uRBnWTy7iPnAd0y+H/D8YRbEiXqAWaxlVQB8pio54hegSVcRRWRKFb2fyViSraMXqw==", "requires": { "@slack/logger": "^1.0.0", - "@slack/types": "^1.0.0", - "@types/form-data": "^2.2.1", + "@slack/types": "^1.1.0", "@types/is-stream": "^1.1.0", "@types/node": ">=8.9.0", "@types/p-queue": "^2.3.2", "axios": "^0.18.0", "eventemitter3": "^3.1.0", - "form-data": "^2.3.3", + "form-data": "^2.5.0", "is-stream": "^1.1.0", "p-queue": "^2.4.2", "p-retry": "^4.0.0" @@ -90,15 +95,58 @@ "follow-redirects": "1.5.10", "is-buffer": "^2.0.2" } + }, + "form-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.0.tgz", + "integrity": "sha512-WXieX3G/8side6VIqx44ablyULoGruSde5PNTxoUyo5CeyAMX6nVWUd0rgist/EuX655cjhUhTo1Fo3tRYqbcA==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } } } }, - "@types/form-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.5.0.tgz", - "integrity": "sha512-23/wYiuckYYtFpL+4RPWiWmRQH2BjFuqCUi2+N3amB1a1Drv+i/byTrGvlLwRVLFNAZbwpbQ7JvTK+VCAPMbcg==", + "@types/body-parser": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz", + "integrity": "sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w==", + "requires": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "@types/connect": { + "version": "3.4.32", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.32.tgz", + "integrity": "sha512-4r8qa0quOvh7lGD0pre62CAb1oni1OO6ecJLGCezTmhQ8Fz50Arx9RUszryR8KlgK6avuSXvviL6yWyViQABOg==", + "requires": { + "@types/node": "*" + } + }, + "@types/debug": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.4.tgz", + "integrity": "sha512-D9MyoQFI7iP5VdpEyPZyjjqIJ8Y8EDNQFIFVLOmeg1rI1xiHOChyUPMPRUVfqFCerxfE+yS3vMyj37F6IdtOoQ==" + }, + "@types/express": { + "version": "4.17.0", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.0.tgz", + "integrity": "sha512-CjaMu57cjgjuZbh9DpkloeGxV45CnMGlVd+XpG7Gm9QgVrd7KFq+X4HY0vM+2v0bczS48Wg7bvnMY5TN+Xmcfw==", + "requires": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "*", + "@types/serve-static": "*" + } + }, + "@types/express-serve-static-core": { + "version": "4.16.7", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.16.7.tgz", + "integrity": "sha512-847KvL8Q1y3TtFLRTXcVakErLJQgdpFSaq+k043xefz9raEf0C7HalpSY7OW5PyjCnY8P7bPW5t/Co9qqp+USg==", "requires": { - "form-data": "*" + "@types/node": "*", + "@types/range-parser": "*" } }, "@types/is-stream": { @@ -109,6 +157,40 @@ "@types/node": "*" } }, + "@types/lodash": { + "version": "4.14.136", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.136.tgz", + "integrity": "sha512-0GJhzBdvsW2RUccNHOBkabI8HZVdOXmXbXhuKlDEd5Vv12P7oAVGfomGp3Ne21o5D/qu1WmthlNKFaoZJJeErA==" + }, + "@types/lodash.isfunction": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/lodash.isfunction/-/lodash.isfunction-3.0.6.tgz", + "integrity": "sha512-olhgKmBgzHnA5pxsOI6YHunzTBMSyBw1XjxIKFio8W+XhYiELGTt05FStE0suV0GWtlIMdn7V8M/UbYbSVdGYw==", + "requires": { + "@types/lodash": "*" + } + }, + "@types/lodash.isregexp": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@types/lodash.isregexp/-/lodash.isregexp-4.0.6.tgz", + "integrity": "sha512-+MxWeayd6d0xdLuLA6T3kY7uNdfHH82m4gsxgpcQkpHcqEmXJiTWDrfUhDdlmErAn6tlj5zhjKsV0mQEkfJcfA==", + "requires": { + "@types/lodash": "*" + } + }, + "@types/lodash.isstring": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@types/lodash.isstring/-/lodash.isstring-4.0.6.tgz", + "integrity": "sha512-uUGvF9G1G7jQ5H42Y38GA9rZmUoY8wI/OMSwnW0BZA+Ra0uxzpuQf4CixXl3yG3TvF6LjuduMyt1WvKl+je8QA==", + "requires": { + "@types/lodash": "*" + } + }, + "@types/mime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.1.tgz", + "integrity": "sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw==" + }, "@types/node": { "version": "8.10.51", "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.51.tgz", @@ -119,11 +201,25 @@ "resolved": "https://registry.npmjs.org/@types/p-queue/-/p-queue-2.3.2.tgz", "integrity": "sha512-eKAv5Ql6k78dh3ULCsSBxX6bFNuGjTmof5Q/T6PiECDq0Yf8IIn46jCyp3RJvCi8owaEmm3DZH1PEImjBMd/vQ==" }, + "@types/range-parser": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.3.tgz", + "integrity": "sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==" + }, "@types/retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==" }, + "@types/serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-/BZ4QRLpH/bNYgZgwhKEh+5AsboDBcUdlBYgzoLX0fpj3Y2gp6EApyOlM3bK53wQS/OE1SrdSYBAbux2D1528Q==", + "requires": { + "@types/express-serve-static-core": "*", + "@types/mime": "*" + } + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -455,9 +551,9 @@ } }, "content-security-policy-builder": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/content-security-policy-builder/-/content-security-policy-builder-2.0.0.tgz", - "integrity": "sha512-j+Nhmj1yfZAikJLImCvPJFE29x/UuBi+/MWqggGGc515JKaZrjuei2RhULJmy0MsstW3E3htl002bwmBNMKr7w==" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-security-policy-builder/-/content-security-policy-builder-2.1.0.tgz", + "integrity": "sha512-/MtLWhJVvJNkA9dVLAp6fg9LxD2gfI6R2Fi1hPmfjYXSahJJzcfvoeDOxSyp4NvxMuwWv3WMssE9o31DoULHrQ==" }, "content-type": { "version": "1.0.4", @@ -1243,9 +1339,9 @@ "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=" }, "helmet": { - "version": "3.19.0", - "resolved": "https://registry.npmjs.org/helmet/-/helmet-3.19.0.tgz", - "integrity": "sha512-l58Q3unSpYatlurvFzkCbTRQ8oWUmdXbOs7h+pnwQbFJRhRJDjER6UMyqHxp9iFtWPcVA05VLcUGSi0EXIv7GA==", + "version": "3.20.0", + "resolved": "https://registry.npmjs.org/helmet/-/helmet-3.20.0.tgz", + "integrity": "sha512-Ob+TqmQFZ5f7WgP8kBbAzNPsbf6p1lOj5r+327/ymw/IILWih3wcx9u/u/S8Mwv5wbBkO7Li6x5s23t3COhUKw==", "requires": { "depd": "2.0.0", "dns-prefetch-control": "0.2.0", @@ -1254,7 +1350,7 @@ "feature-policy": "0.3.0", "frameguard": "3.1.0", "helmet-crossdomain": "0.4.0", - "helmet-csp": "2.7.1", + "helmet-csp": "2.8.0", "hide-powered-by": "1.1.0", "hpkp": "2.0.0", "hsts": "2.2.0", @@ -1277,12 +1373,12 @@ "integrity": "sha512-AB4DTykRw3HCOxovD1nPR16hllrVImeFp5VBV9/twj66lJ2nU75DP8FPL0/Jp4jj79JhTfG+pFI2MD02kWJ+fA==" }, "helmet-csp": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/helmet-csp/-/helmet-csp-2.7.1.tgz", - "integrity": "sha512-sCHwywg4daQ2mY0YYwXSZRsgcCeerUwxMwNixGA7aMLkVmPTYBl7gJoZDHOZyXkqPrtuDT3s2B1A+RLI7WxSdQ==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/helmet-csp/-/helmet-csp-2.8.0.tgz", + "integrity": "sha512-MlCPeM0Sm3pS9RACRihx70VeTHmkQwa7sum9EK1tfw1VZyvFU0dBWym9nHh3CRkTRNlyNm/WFCMvuh9zXkOjNw==", "requires": { "camelize": "1.0.0", - "content-security-policy-builder": "2.0.0", + "content-security-policy-builder": "2.1.0", "dasherize": "2.0.0", "platform": "1.3.5" } diff --git a/package.json b/package.json index cd7fd6e..bfe7100 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ }, "homepage": "https://github.com/TUS-OSK/bushitsuchan-PC#readme", "dependencies": { - "@slack/interactive-messages": "^1.1.1", - "@slack/web-api": "^5.0.1", + "@slack/interactive-messages": "^1.2.0", + "@slack/web-api": "^5.1.0", "axios": "^0.19.0", "body-parser": "^1.19.0", "child_process": "^1.0.2", @@ -28,7 +28,7 @@ "cors": "^2.8.5", "express": "^4.17.1", "fs": "0.0.1-security", - "helmet": "^3.19.0", + "helmet": "^3.20.0", "morgan": "^1.9.1", "ngrok": "^3.2.3", "node-media-server": "^2.1.2",