Upgrade to socket.io v4
This commit is contained in:
parent
1b7e7c74f5
commit
7214b7c474
16
NEWS.md
16
NEWS.md
|
@ -1,3 +1,19 @@
|
||||||
|
2021-08-14
|
||||||
|
==========
|
||||||
|
|
||||||
|
CyTube has been upgraded to socket.io v4 (from v2).
|
||||||
|
|
||||||
|
**Breaking change:** Newer versions of socket.io require CORS to validate the
|
||||||
|
origin initiating the socket connection. CyTube allows the origins specified in
|
||||||
|
the `io.domain` and `https.domain` configuration keys by default, which should
|
||||||
|
work for many use cases, however, if you host your website on a different domain
|
||||||
|
than the socket connection, you will need to configure the allowed origins (see
|
||||||
|
config.template.yaml under `io.cors`).
|
||||||
|
|
||||||
|
CyTube enables the `allowEIO3` configuration in socket.io by default, which
|
||||||
|
means that existing clients and bots using socket.io-client v2 should continue
|
||||||
|
to work.
|
||||||
|
|
||||||
2021-08-12
|
2021-08-12
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,10 @@ io:
|
||||||
default-port: 1337
|
default-port: 1337
|
||||||
# limit the number of concurrent socket connections per IP address
|
# limit the number of concurrent socket connections per IP address
|
||||||
ip-connection-limit: 10
|
ip-connection-limit: 10
|
||||||
|
cors:
|
||||||
|
# Additional origins to allow socket connections from (io.domain and
|
||||||
|
# https.domain are included implicitly).
|
||||||
|
allowed-origins: []
|
||||||
|
|
||||||
# YouTube v3 API key
|
# YouTube v3 API key
|
||||||
# 1. Go to https://console.developers.google.com/, create a new "project" (or choose an existing one)
|
# 1. Go to https://console.developers.google.com/, create a new "project" (or choose an existing one)
|
||||||
|
|
292
package-lock.json
generated
292
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"version": "3.78.2",
|
"version": "3.81.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1377,6 +1377,26 @@
|
||||||
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz",
|
||||||
"integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw=="
|
"integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw=="
|
||||||
},
|
},
|
||||||
|
"@types/component-emitter": {
|
||||||
|
"version": "1.2.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/component-emitter/-/component-emitter-1.2.10.tgz",
|
||||||
|
"integrity": "sha512-bsjleuRKWmGqajMerkzox19aGbscQX5rmmvvXl3wlIp5gMG1HgkiwPxsN5p070fBDKTNSPgojVbuY1+HWMbFhg=="
|
||||||
|
},
|
||||||
|
"@types/cookie": {
|
||||||
|
"version": "0.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz",
|
||||||
|
"integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q=="
|
||||||
|
},
|
||||||
|
"@types/cors": {
|
||||||
|
"version": "2.8.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz",
|
||||||
|
"integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw=="
|
||||||
|
},
|
||||||
|
"@types/node": {
|
||||||
|
"version": "16.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.6.0.tgz",
|
||||||
|
"integrity": "sha512-OyiZPohMMjZEYqcVo/UJ04GyAxXOJEZO/FpzyXxcH4r/ArrVoXHf4MbUrkLp0Tz7/p1mMKpo5zJ6ZHl8XBNthQ=="
|
||||||
|
},
|
||||||
"@ungap/promise-all-settled": {
|
"@ungap/promise-all-settled": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz",
|
||||||
|
@ -1408,11 +1428,6 @@
|
||||||
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"after": {
|
|
||||||
"version": "0.8.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz",
|
|
||||||
"integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8="
|
|
||||||
},
|
|
||||||
"agent-base": {
|
"agent-base": {
|
||||||
"version": "6.0.2",
|
"version": "6.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
||||||
|
@ -1567,11 +1582,6 @@
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"arraybuffer.slice": {
|
|
||||||
"version": "0.0.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz",
|
|
||||||
"integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog=="
|
|
||||||
},
|
|
||||||
"asap": {
|
"asap": {
|
||||||
"version": "2.0.6",
|
"version": "2.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
|
||||||
|
@ -1670,11 +1680,6 @@
|
||||||
"@babel/types": "^7.9.6"
|
"@babel/types": "^7.9.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"backo2": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
|
|
||||||
"integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc="
|
|
||||||
},
|
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||||
|
@ -1791,11 +1796,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/bintrees/-/bintrees-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/bintrees/-/bintrees-1.0.1.tgz",
|
||||||
"integrity": "sha1-DmVcm5wkNeqraL9AJyJtK1WjRSQ="
|
"integrity": "sha1-DmVcm5wkNeqraL9AJyJtK1WjRSQ="
|
||||||
},
|
},
|
||||||
"blob": {
|
|
||||||
"version": "0.0.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz",
|
|
||||||
"integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig=="
|
|
||||||
},
|
|
||||||
"bluebird": {
|
"bluebird": {
|
||||||
"version": "3.7.2",
|
"version": "3.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
|
||||||
|
@ -2329,21 +2329,11 @@
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
|
||||||
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw=="
|
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw=="
|
||||||
},
|
},
|
||||||
"component-bind": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E="
|
|
||||||
},
|
|
||||||
"component-emitter": {
|
"component-emitter": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz",
|
||||||
"integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg=="
|
"integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg=="
|
||||||
},
|
},
|
||||||
"component-inherit": {
|
|
||||||
"version": "0.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz",
|
|
||||||
"integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM="
|
|
||||||
},
|
|
||||||
"compressible": {
|
"compressible": {
|
||||||
"version": "2.0.18",
|
"version": "2.0.18",
|
||||||
"resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz",
|
"resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz",
|
||||||
|
@ -2496,6 +2486,15 @@
|
||||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||||
},
|
},
|
||||||
|
"cors": {
|
||||||
|
"version": "2.8.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
|
||||||
|
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
|
||||||
|
"requires": {
|
||||||
|
"object-assign": "^4",
|
||||||
|
"vary": "^1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"create-error": {
|
"create-error": {
|
||||||
"version": "0.3.1",
|
"version": "0.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/create-error/-/create-error-0.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/create-error/-/create-error-0.3.1.tgz",
|
||||||
|
@ -2767,15 +2766,16 @@
|
||||||
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
|
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
|
||||||
},
|
},
|
||||||
"engine.io": {
|
"engine.io": {
|
||||||
"version": "3.5.0",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-5.1.1.tgz",
|
||||||
"integrity": "sha512-21HlvPUKaitDGE4GXNtQ7PLP0Sz4aWLddMPw2VTyFz1FVZqu/kZsJUO8WNpKuE/OCL7nkfRaOui2ZCJloGznGA==",
|
"integrity": "sha512-aMWot7H5aC8L4/T8qMYbLdvKlZOdJTH54FxfdFunTGvhMx1BHkJOntWArsVfgAZVwAO9LC2sryPWRcEeUzCe5w==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"accepts": "~1.3.4",
|
"accepts": "~1.3.4",
|
||||||
"base64id": "2.0.0",
|
"base64id": "2.0.0",
|
||||||
"cookie": "~0.4.1",
|
"cookie": "~0.4.1",
|
||||||
"debug": "~4.1.0",
|
"cors": "~2.8.5",
|
||||||
"engine.io-parser": "~2.2.0",
|
"debug": "~4.3.1",
|
||||||
|
"engine.io-parser": "~4.0.0",
|
||||||
"ws": "~7.4.2"
|
"ws": "~7.4.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -2783,60 +2783,15 @@
|
||||||
"version": "0.4.1",
|
"version": "0.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz",
|
||||||
"integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA=="
|
"integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA=="
|
||||||
},
|
|
||||||
"debug": {
|
|
||||||
"version": "4.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
|
||||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
|
||||||
"requires": {
|
|
||||||
"ms": "^2.1.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"engine.io-client": {
|
|
||||||
"version": "3.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.5.1.tgz",
|
|
||||||
"integrity": "sha512-oVu9kBkGbcggulyVF0kz6BV3ganqUeqXvD79WOFKa+11oK692w1NyFkuEj4xrkFRpZhn92QOqTk4RQq5LiBXbQ==",
|
|
||||||
"requires": {
|
|
||||||
"component-emitter": "~1.3.0",
|
|
||||||
"component-inherit": "0.0.3",
|
|
||||||
"debug": "~3.1.0",
|
|
||||||
"engine.io-parser": "~2.2.0",
|
|
||||||
"has-cors": "1.1.0",
|
|
||||||
"indexof": "0.0.1",
|
|
||||||
"parseqs": "0.0.6",
|
|
||||||
"parseuri": "0.0.6",
|
|
||||||
"ws": "~7.4.2",
|
|
||||||
"xmlhttprequest-ssl": "~1.5.4",
|
|
||||||
"yeast": "0.1.2"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"debug": {
|
|
||||||
"version": "3.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
|
||||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
|
||||||
"requires": {
|
|
||||||
"ms": "2.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ms": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
|
||||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"engine.io-parser": {
|
"engine.io-parser": {
|
||||||
"version": "2.2.1",
|
"version": "4.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-4.0.2.tgz",
|
||||||
"integrity": "sha512-x+dN/fBH8Ro8TFwJ+rkB2AmuVw9Yu2mockR/p3W8f8YtExwFgDvBDi0GWyb4ZLkpahtDGZgtr3zLovanJghPqg==",
|
"integrity": "sha512-sHfEQv6nmtJrq6TKuIz5kyEKH/qSdK56H/A+7DnAuUPWosnIZAS2NHNcPLmyjtY3cGS/MqJdZbUjW97JU72iYg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"after": "0.8.2",
|
"base64-arraybuffer": "0.1.4"
|
||||||
"arraybuffer.slice": "~0.0.7",
|
|
||||||
"base64-arraybuffer": "0.1.4",
|
|
||||||
"blob": "0.0.5",
|
|
||||||
"has-binary2": "~1.0.2"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"enquirer": {
|
"enquirer": {
|
||||||
|
@ -3631,26 +3586,6 @@
|
||||||
"function-bind": "^1.1.1"
|
"function-bind": "^1.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"has-binary2": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==",
|
|
||||||
"requires": {
|
|
||||||
"isarray": "2.0.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"isarray": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
|
|
||||||
"integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"has-cors": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz",
|
|
||||||
"integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk="
|
|
||||||
},
|
|
||||||
"has-flag": {
|
"has-flag": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||||
|
@ -3795,11 +3730,6 @@
|
||||||
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
|
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"indexof": {
|
|
||||||
"version": "0.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
|
|
||||||
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10="
|
|
||||||
},
|
|
||||||
"inflight": {
|
"inflight": {
|
||||||
"version": "1.0.6",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||||
|
@ -4860,16 +4790,6 @@
|
||||||
"parse5": "^6.0.1"
|
"parse5": "^6.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"parseqs": {
|
|
||||||
"version": "0.0.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.6.tgz",
|
|
||||||
"integrity": "sha512-jeAGzMDbfSHHA091hr0r31eYfTig+29g3GKKE/PPbEQ65X0lmMwlEoqmhzu0iztID5uJpZsFlUPDP8ThPL7M8w=="
|
|
||||||
},
|
|
||||||
"parseuri": {
|
|
||||||
"version": "0.0.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.6.tgz",
|
|
||||||
"integrity": "sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow=="
|
|
||||||
},
|
|
||||||
"parseurl": {
|
"parseurl": {
|
||||||
"version": "1.3.3",
|
"version": "1.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||||
|
@ -5852,109 +5772,34 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"socket.io": {
|
"socket.io": {
|
||||||
"version": "2.4.1",
|
"version": "4.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.1.3.tgz",
|
||||||
"integrity": "sha512-Si18v0mMXGAqLqCVpTxBa8MGqriHGQh8ccEOhmsmNS3thNCGBwO8WGrwMibANsWtQQ5NStdZwHqZR3naJVFc3w==",
|
"integrity": "sha512-tLkaY13RcO4nIRh1K2hT5iuotfTaIQw7cVIe0FUykN3SuQi0cm7ALxuyT5/CtDswOMWUzMGTibxYNx/gU7In+Q==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "~4.1.0",
|
"@types/cookie": "^0.4.0",
|
||||||
"engine.io": "~3.5.0",
|
"@types/cors": "^2.8.10",
|
||||||
"has-binary2": "~1.0.2",
|
"@types/node": ">=10.0.0",
|
||||||
"socket.io-adapter": "~1.1.0",
|
"accepts": "~1.3.4",
|
||||||
"socket.io-client": "2.4.0",
|
"base64id": "~2.0.0",
|
||||||
"socket.io-parser": "~3.4.0"
|
"debug": "~4.3.1",
|
||||||
},
|
"engine.io": "~5.1.1",
|
||||||
"dependencies": {
|
"socket.io-adapter": "~2.3.1",
|
||||||
"debug": {
|
"socket.io-parser": "~4.0.4"
|
||||||
"version": "4.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
|
||||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
|
||||||
"requires": {
|
|
||||||
"ms": "^2.1.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"socket.io-adapter": {
|
"socket.io-adapter": {
|
||||||
"version": "1.1.2",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.3.1.tgz",
|
||||||
"integrity": "sha512-WzZRUj1kUjrTIrUKpZLEzFZ1OLj5FwLlAFQs9kuZJzJi5DKdU7FsWc36SNmA8iDOtwBQyT8FkrriRM8vXLYz8g=="
|
"integrity": "sha512-8cVkRxI8Nt2wadkY6u60Y4rpW3ejA1rxgcK2JuyIhmF+RMNpTy1QRtkHIDUOf3B4HlQwakMsWbKftMv/71VMmw=="
|
||||||
},
|
|
||||||
"socket.io-client": {
|
|
||||||
"version": "2.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.4.0.tgz",
|
|
||||||
"integrity": "sha512-M6xhnKQHuuZd4Ba9vltCLT9oa+YvTsP8j9NcEiLElfIg8KeYPyhWOes6x4t+LTAC8enQbE/995AdTem2uNyKKQ==",
|
|
||||||
"requires": {
|
|
||||||
"backo2": "1.0.2",
|
|
||||||
"component-bind": "1.0.0",
|
|
||||||
"component-emitter": "~1.3.0",
|
|
||||||
"debug": "~3.1.0",
|
|
||||||
"engine.io-client": "~3.5.0",
|
|
||||||
"has-binary2": "~1.0.2",
|
|
||||||
"indexof": "0.0.1",
|
|
||||||
"parseqs": "0.0.6",
|
|
||||||
"parseuri": "0.0.6",
|
|
||||||
"socket.io-parser": "~3.3.0",
|
|
||||||
"to-array": "0.1.4"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"debug": {
|
|
||||||
"version": "3.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
|
||||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
|
||||||
"requires": {
|
|
||||||
"ms": "2.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isarray": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
|
|
||||||
"integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4="
|
|
||||||
},
|
|
||||||
"ms": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
|
||||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
|
||||||
},
|
|
||||||
"socket.io-parser": {
|
|
||||||
"version": "3.3.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.2.tgz",
|
|
||||||
"integrity": "sha512-FJvDBuOALxdCI9qwRrO/Rfp9yfndRtc1jSgVgV8FDraihmSP/MLGD5PEuJrNfjALvcQ+vMDM/33AWOYP/JSjDg==",
|
|
||||||
"requires": {
|
|
||||||
"component-emitter": "~1.3.0",
|
|
||||||
"debug": "~3.1.0",
|
|
||||||
"isarray": "2.0.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"socket.io-parser": {
|
"socket.io-parser": {
|
||||||
"version": "3.4.1",
|
"version": "4.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.4.tgz",
|
||||||
"integrity": "sha512-11hMgzL+WCLWf1uFtHSNvliI++tcRUWdoeYuwIl+Axvwy9z2gQM+7nJyN3STj1tLj5JyIUH8/gpDGxzAlDdi0A==",
|
"integrity": "sha512-t+b0SS+IxG7Rxzda2EVvyBZbvFPBCjJoyHuE0P//7OAsN23GItzDRdWa6ALxZI/8R5ygK7jAR6t028/z+7295g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"component-emitter": "1.2.1",
|
"@types/component-emitter": "^1.2.10",
|
||||||
"debug": "~4.1.0",
|
"component-emitter": "~1.3.0",
|
||||||
"isarray": "2.0.1"
|
"debug": "~4.3.1"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"component-emitter": {
|
|
||||||
"version": "1.2.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
|
|
||||||
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY="
|
|
||||||
},
|
|
||||||
"debug": {
|
|
||||||
"version": "4.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
|
||||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
|
||||||
"requires": {
|
|
||||||
"ms": "^2.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isarray": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
|
|
||||||
"integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4="
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"source-map": {
|
"source-map": {
|
||||||
|
@ -6187,11 +6032,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/tildify/-/tildify-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/tildify/-/tildify-2.0.0.tgz",
|
||||||
"integrity": "sha512-Cc+OraorugtXNfs50hU9KS369rFXCfgGLpfCfvlc+Ud5u6VWmUQsOAa9HbTvheQdYnrdJqqv1e5oIqXppMYnSw=="
|
"integrity": "sha512-Cc+OraorugtXNfs50hU9KS369rFXCfgGLpfCfvlc+Ud5u6VWmUQsOAa9HbTvheQdYnrdJqqv1e5oIqXppMYnSw=="
|
||||||
},
|
},
|
||||||
"to-array": {
|
|
||||||
"version": "0.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz",
|
|
||||||
"integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA="
|
|
||||||
},
|
|
||||||
"to-fast-properties": {
|
"to-fast-properties": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
|
||||||
|
@ -6581,11 +6421,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
|
||||||
"integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A=="
|
"integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A=="
|
||||||
},
|
},
|
||||||
"xmlhttprequest-ssl": {
|
|
||||||
"version": "1.5.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz",
|
|
||||||
"integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4="
|
|
||||||
},
|
|
||||||
"y18n": {
|
"y18n": {
|
||||||
"version": "5.0.5",
|
"version": "5.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz",
|
||||||
|
@ -6673,11 +6508,6 @@
|
||||||
"is-plain-obj": "^2.1.0"
|
"is-plain-obj": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"yeast": {
|
|
||||||
"version": "0.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",
|
|
||||||
"integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk="
|
|
||||||
},
|
|
||||||
"yocto-queue": {
|
"yocto-queue": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "3.80.0",
|
"version": "3.81.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
"redis": "^3.1.1",
|
"redis": "^3.1.1",
|
||||||
"sanitize-html": "^2.3.3",
|
"sanitize-html": "^2.3.3",
|
||||||
"serve-static": "^1.14.1",
|
"serve-static": "^1.14.1",
|
||||||
"socket.io": "^2.0.3",
|
"socket.io": "^4.1.3",
|
||||||
"source-map-support": "^0.5.19",
|
"source-map-support": "^0.5.19",
|
||||||
"toml": "^3.0.0",
|
"toml": "^3.0.0",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
|
|
|
@ -60,7 +60,10 @@ var defaults = {
|
||||||
io: {
|
io: {
|
||||||
domain: "http://localhost",
|
domain: "http://localhost",
|
||||||
"default-port": 1337,
|
"default-port": 1337,
|
||||||
"ip-connection-limit": 10
|
"ip-connection-limit": 10,
|
||||||
|
cors: {
|
||||||
|
"allowed-origins": []
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"youtube-v3-key": "",
|
"youtube-v3-key": "",
|
||||||
"channel-blacklist": [],
|
"channel-blacklist": [],
|
||||||
|
|
|
@ -14,7 +14,6 @@ const getAliases = Promise.promisify(db.getAliases);
|
||||||
import { CachingGlobalBanlist } from './globalban';
|
import { CachingGlobalBanlist } from './globalban';
|
||||||
import proxyaddr from 'proxy-addr';
|
import proxyaddr from 'proxy-addr';
|
||||||
import { Counter, Gauge } from 'prom-client';
|
import { Counter, Gauge } from 'prom-client';
|
||||||
import Socket from 'socket.io/lib/socket';
|
|
||||||
import { TokenBucket } from '../util/token-bucket';
|
import { TokenBucket } from '../util/token-bucket';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
|
|
||||||
|
@ -108,28 +107,6 @@ class IOServer {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
TODO: see https://github.com/calzoneman/sync/issues/724
|
|
||||||
ipConnectionLimitMiddleware(socket, next) {
|
|
||||||
const ip = socket.context.ipAddress;
|
|
||||||
const count = this.ipCount.get(ip) || 0;
|
|
||||||
if (count >= Config.get('io.ip-connection-limit')) {
|
|
||||||
// TODO: better error message would be nice
|
|
||||||
next(new Error('Too many connections from your IP address'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ipCount.set(ip, count + 1);
|
|
||||||
console.log(ip, this.ipCount.get(ip));
|
|
||||||
socket.once('disconnect', () => {
|
|
||||||
console.log('Disconnect event has fired for', socket.id);
|
|
||||||
this.ipCount.set(ip, this.ipCount.get(ip) - 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
checkIPLimit(socket) {
|
checkIPLimit(socket) {
|
||||||
const ip = socket.context.ipAddress;
|
const ip = socket.context.ipAddress;
|
||||||
const count = this.ipCount.get(ip) || 0;
|
const count = this.ipCount.get(ip) || 0;
|
||||||
|
@ -219,9 +196,12 @@ class IOServer {
|
||||||
|
|
||||||
handleConnection(socket) {
|
handleConnection(socket) {
|
||||||
if (!this.checkIPLimit(socket)) {
|
if (!this.checkIPLimit(socket)) {
|
||||||
return;
|
//return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
patchTypecheckedFunctions(socket);
|
||||||
|
patchSocketMetrics(socket);
|
||||||
|
|
||||||
this.setRateLimiter(socket);
|
this.setRateLimiter(socket);
|
||||||
|
|
||||||
emitMetrics(socket);
|
emitMetrics(socket);
|
||||||
|
@ -268,14 +248,10 @@ class IOServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
initSocketIO() {
|
initSocketIO() {
|
||||||
patchSocketMetrics();
|
|
||||||
patchTypecheckedFunctions();
|
|
||||||
|
|
||||||
const io = this.io = sio.instance = sio();
|
const io = this.io = sio.instance = sio();
|
||||||
io.use(this.ipProxyMiddleware.bind(this));
|
io.use(this.ipProxyMiddleware.bind(this));
|
||||||
io.use(this.ipBanMiddleware.bind(this));
|
io.use(this.ipBanMiddleware.bind(this));
|
||||||
io.use(this.ipThrottleMiddleware.bind(this));
|
io.use(this.ipThrottleMiddleware.bind(this));
|
||||||
//io.use(this.ipConnectionLimitMiddleware.bind(this));
|
|
||||||
io.use(this.cookieParsingMiddleware.bind(this));
|
io.use(this.cookieParsingMiddleware.bind(this));
|
||||||
io.use(this.ipSessionCookieMiddleware.bind(this));
|
io.use(this.ipSessionCookieMiddleware.bind(this));
|
||||||
io.use(this.authUserMiddleware.bind(this));
|
io.use(this.authUserMiddleware.bind(this));
|
||||||
|
@ -290,7 +266,7 @@ class IOServer {
|
||||||
const engineOpts = {
|
const engineOpts = {
|
||||||
/*
|
/*
|
||||||
* Set ping timeout to 2 minutes to avoid spurious reconnects
|
* Set ping timeout to 2 minutes to avoid spurious reconnects
|
||||||
* during transient network issues. The default of 5 minutes
|
* during transient network issues. The default of 20 seconds
|
||||||
* is too aggressive.
|
* is too aggressive.
|
||||||
*
|
*
|
||||||
* https://github.com/calzoneman/sync/issues/780
|
* https://github.com/calzoneman/sync/issues/780
|
||||||
|
@ -309,11 +285,17 @@ class IOServer {
|
||||||
perMessageDeflate: false,
|
perMessageDeflate: false,
|
||||||
httpCompression: false,
|
httpCompression: false,
|
||||||
|
|
||||||
|
maxHttpBufferSize: 1 << 20,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default is 10MB.
|
* Enable legacy support for socket.io v2 clients (e.g., bots)
|
||||||
* Even 1MiB seems like a generous limit...
|
|
||||||
*/
|
*/
|
||||||
maxHttpBufferSize: 1 << 20
|
allowEIO3: true,
|
||||||
|
|
||||||
|
cors: {
|
||||||
|
origin: getCorsAllowCallback(),
|
||||||
|
credentials: true // enable cookies for auth
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
servers.forEach(server => {
|
servers.forEach(server => {
|
||||||
|
@ -330,26 +312,25 @@ const outgoingPacketCount = new Counter({
|
||||||
name: 'cytube_socketio_outgoing_packets_total',
|
name: 'cytube_socketio_outgoing_packets_total',
|
||||||
help: 'Number of outgoing socket.io packets to clients'
|
help: 'Number of outgoing socket.io packets to clients'
|
||||||
});
|
});
|
||||||
function patchSocketMetrics() {
|
function patchSocketMetrics(sock) {
|
||||||
const onevent = Socket.prototype.onevent;
|
|
||||||
const packet = Socket.prototype.packet;
|
|
||||||
const emit = require('events').EventEmitter.prototype.emit;
|
const emit = require('events').EventEmitter.prototype.emit;
|
||||||
|
|
||||||
Socket.prototype.onevent = function patchedOnevent() {
|
sock.onAny(() => {
|
||||||
onevent.apply(this, arguments);
|
|
||||||
incomingEventCount.inc(1);
|
incomingEventCount.inc(1);
|
||||||
emit.call(this, 'cytube:count-event');
|
emit.call(sock, 'cytube:count-event');
|
||||||
};
|
});
|
||||||
|
|
||||||
Socket.prototype.packet = function patchedPacket() {
|
let packet = sock.packet;
|
||||||
|
sock.packet = function patchedPacket() {
|
||||||
packet.apply(this, arguments);
|
packet.apply(this, arguments);
|
||||||
outgoingPacketCount.inc(1);
|
outgoingPacketCount.inc(1);
|
||||||
};
|
}.bind(sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: remove this crap */
|
/* TODO: remove this crap */
|
||||||
function patchTypecheckedFunctions() {
|
/* Addendum 2021-08-14: socket.io v4 supports middleware, maybe move type validation to that */
|
||||||
Socket.prototype.typecheckedOn = function typecheckedOn(msg, template, cb) {
|
function patchTypecheckedFunctions(sock) {
|
||||||
|
sock.typecheckedOn = function typecheckedOn(msg, template, cb) {
|
||||||
this.on(msg, (data, ack) => {
|
this.on(msg, (data, ack) => {
|
||||||
typecheck(data, template, (err, data) => {
|
typecheck(data, template, (err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -361,9 +342,9 @@ function patchTypecheckedFunctions() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}.bind(sock);
|
||||||
|
|
||||||
Socket.prototype.typecheckedOnce = function typecheckedOnce(msg, template, cb) {
|
sock.typecheckedOnce = function typecheckedOnce(msg, template, cb) {
|
||||||
this.once(msg, data => {
|
this.once(msg, data => {
|
||||||
typecheck(data, template, (err, data) => {
|
typecheck(data, template, (err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -375,7 +356,7 @@ function patchTypecheckedFunctions() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}.bind(sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
let globalIPBanlist = null;
|
let globalIPBanlist = null;
|
||||||
|
@ -409,16 +390,17 @@ const promSocketReconnect = new Counter({
|
||||||
function emitMetrics(sock) {
|
function emitMetrics(sock) {
|
||||||
try {
|
try {
|
||||||
let closed = false;
|
let closed = false;
|
||||||
let transportName = sock.client.conn.transport.name;
|
let transportName = sock.conn.transport.name;
|
||||||
promSocketCount.inc({ transport: transportName });
|
promSocketCount.inc({ transport: transportName });
|
||||||
promSocketAccept.inc(1);
|
promSocketAccept.inc(1);
|
||||||
|
|
||||||
sock.client.conn.on('upgrade', newTransport => {
|
sock.conn.on('upgrade', () => {
|
||||||
try {
|
try {
|
||||||
|
let newTransport = sock.conn.transport.name;
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if (!closed && newTransport.name !== transportName) {
|
if (!closed && newTransport !== transportName) {
|
||||||
promSocketCount.dec({ transport: transportName });
|
promSocketCount.dec({ transport: transportName });
|
||||||
transportName = newTransport.name;
|
transportName = newTransport;
|
||||||
promSocketCount.inc({ transport: transportName });
|
promSocketCount.inc({ transport: transportName });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -526,3 +508,30 @@ setInterval(function () {
|
||||||
LOGGER.info('Cleaned up %d stale IP throttle token buckets', cleaned);
|
LOGGER.info('Cleaned up %d stale IP throttle token buckets', cleaned);
|
||||||
}
|
}
|
||||||
}, 5 * 60 * 1000);
|
}, 5 * 60 * 1000);
|
||||||
|
|
||||||
|
function getCorsAllowCallback() {
|
||||||
|
let origins = Array.prototype.slice.call(Config.get('io.cors.allowed-origins'));
|
||||||
|
|
||||||
|
origins = origins.concat([
|
||||||
|
Config.get('io.domain'),
|
||||||
|
Config.get('https.domain')
|
||||||
|
]);
|
||||||
|
|
||||||
|
return function corsOriginAllowed(origin, callback) {
|
||||||
|
if (!origin) {
|
||||||
|
// Non-browser clients might not care about Origin, allow these.
|
||||||
|
callback(null, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Different ports are technically cross-origin; a distinction that does not matter to CyTube.
|
||||||
|
origin = origin.replace(/:\d+$/, '');
|
||||||
|
|
||||||
|
if (origins.includes(origin)) {
|
||||||
|
callback(null, true);
|
||||||
|
} else {
|
||||||
|
LOGGER.warn('Rejecting origin "%s"; allowed origins are %j', origin, origins);
|
||||||
|
callback(new Error('Invalid origin'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -1249,7 +1249,8 @@ function ioServerConnect(socketConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var opts = {
|
var opts = {
|
||||||
secure: chosenServer.secure
|
secure: chosenServer.secure,
|
||||||
|
withCredentials: true // enable cookies for auth
|
||||||
};
|
};
|
||||||
|
|
||||||
window.socket = io(chosenServer.url, opts);
|
window.socket = io(chosenServer.url, opts);
|
||||||
|
|
Loading…
Reference in a new issue