mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-30 12:20:35 +00:00
Streaming: Fix BIND IPv6 handling (#31624)
This commit is contained in:
parent
3c412578c9
commit
f6fb9b75db
|
@ -1351,15 +1351,23 @@ const startServer = async () => {
|
||||||
* @param {function(string): void} [onSuccess]
|
* @param {function(string): void} [onSuccess]
|
||||||
*/
|
*/
|
||||||
const attachServerWithConfig = (server, onSuccess) => {
|
const attachServerWithConfig = (server, onSuccess) => {
|
||||||
if (process.env.SOCKET || process.env.PORT && isNaN(+process.env.PORT)) {
|
if (process.env.SOCKET) {
|
||||||
server.listen(process.env.SOCKET || process.env.PORT, () => {
|
server.listen(process.env.SOCKET, () => {
|
||||||
if (onSuccess) {
|
if (onSuccess) {
|
||||||
fs.chmodSync(server.address(), 0o666);
|
fs.chmodSync(server.address(), 0o666);
|
||||||
onSuccess(server.address());
|
onSuccess(server.address());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
server.listen(+(process.env.PORT || 4000), process.env.BIND || '127.0.0.1', () => {
|
const port = +(process.env.PORT || 4000);
|
||||||
|
let bind = process.env.BIND ?? '127.0.0.1';
|
||||||
|
// Web uses the URI syntax for BIND, which means IPv6 addresses may
|
||||||
|
// be wrapped in square brackets:
|
||||||
|
if (bind.startsWith('[') && bind.endsWith(']')) {
|
||||||
|
bind = bind.slice(1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
server.listen(port, bind, () => {
|
||||||
if (onSuccess) {
|
if (onSuccess) {
|
||||||
onSuccess(`${server.address().address}:${server.address().port}`);
|
onSuccess(`${server.address().address}:${server.address().port}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue