Revert "Allow configuring the listen host (#9924)"
This reverts commit 3dfe3aa9a4
.
This commit is contained in:
parent
3dfe3aa9a4
commit
5b3a07ee9e
5 changed files with 9 additions and 15 deletions
|
@ -30,9 +30,6 @@ url: https://example.tld/
|
||||||
# The port that your Misskey server should listen on.
|
# The port that your Misskey server should listen on.
|
||||||
port: 3000
|
port: 3000
|
||||||
|
|
||||||
# The hostname or address to listen on (default: all)
|
|
||||||
#host: "127.0.0.1"
|
|
||||||
|
|
||||||
# ┌──────────────────────────┐
|
# ┌──────────────────────────┐
|
||||||
#───┘ PostgreSQL configuration └────────────────────────────────
|
#───┘ PostgreSQL configuration └────────────────────────────────
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ export async function masterMain() {
|
||||||
await spawnWorkers(config.clusterLimit);
|
await spawnWorkers(config.clusterLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bootLogger.succ(`Now listening on ${config.host ? `[${config.host}]:` : ''}${config.port} for ${config.url}`, null, true);
|
bootLogger.succ(`Now listening on port ${config.port} on ${config.url}`, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showEnvironment(): void {
|
function showEnvironment(): void {
|
||||||
|
|
|
@ -15,7 +15,6 @@ export type Source = {
|
||||||
feedback_url?: string;
|
feedback_url?: string;
|
||||||
url: string;
|
url: string;
|
||||||
port: number;
|
port: number;
|
||||||
host: string;
|
|
||||||
disableHsts?: boolean;
|
disableHsts?: boolean;
|
||||||
db: {
|
db: {
|
||||||
host: string;
|
host: string;
|
||||||
|
@ -126,7 +125,6 @@ export function loadConfig() {
|
||||||
config.url = url.origin;
|
config.url = url.origin;
|
||||||
|
|
||||||
config.port = config.port ?? parseInt(process.env.PORT ?? '', 10);
|
config.port = config.port ?? parseInt(process.env.PORT ?? '', 10);
|
||||||
config.host = config.host ?? process.env.HOST;
|
|
||||||
|
|
||||||
mixin.version = meta.version;
|
mixin.version = meta.version;
|
||||||
mixin.host = url.host;
|
mixin.host = url.host;
|
||||||
|
|
|
@ -176,10 +176,10 @@ export class ServerService {
|
||||||
fastify.server.on('error', err => {
|
fastify.server.on('error', err => {
|
||||||
switch ((err as any).code) {
|
switch ((err as any).code) {
|
||||||
case 'EACCES':
|
case 'EACCES':
|
||||||
this.logger.error(`You do not have permission to listen on port ${this.config.port}${this.config.host ? ` of host ${this.config.host}` : ''}`);
|
this.logger.error(`You do not have permission to listen on port ${this.config.port}.`);
|
||||||
break;
|
break;
|
||||||
case 'EADDRINUSE':
|
case 'EADDRINUSE':
|
||||||
this.logger.error(`Port ${this.config.port}${this.config.host ? ` on ${this.config.host}` : ''} is already in use by another process.`);
|
this.logger.error(`Port ${this.config.port} is already in use by another process.`);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.logger.error(err);
|
this.logger.error(err);
|
||||||
|
@ -194,6 +194,6 @@ export class ServerService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.listen({ port: this.config.port, host: this.config.host });
|
fastify.listen({ port: this.config.port, host: '0.0.0.0' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ const _dirname = dirname(_filename);
|
||||||
|
|
||||||
const config = loadConfig();
|
const config = loadConfig();
|
||||||
export const port = config.port;
|
export const port = config.port;
|
||||||
export const host = config.host || "localhost";
|
|
||||||
|
|
||||||
export const api = async (endpoint: string, params: any, me?: any) => {
|
export const api = async (endpoint: string, params: any, me?: any) => {
|
||||||
endpoint = endpoint.replace(/^\//, '');
|
endpoint = endpoint.replace(/^\//, '');
|
||||||
|
@ -29,7 +28,7 @@ export const api = async (endpoint: string, params: any, me?: any) => {
|
||||||
} : {};
|
} : {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await got<string>(`http://${host}:${port}/api/${endpoint}`, {
|
const res = await got<string>(`http://localhost:${port}/api/${endpoint}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -67,7 +66,7 @@ export const request = async (path: string, params: any, me?: any): Promise<{ bo
|
||||||
i: me.token,
|
i: me.token,
|
||||||
} : {};
|
} : {};
|
||||||
|
|
||||||
const res = await fetch(`http://${host}:${port}/${path}`, {
|
const res = await fetch(`http://localhost:${port}/${path}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -124,7 +123,7 @@ export const uploadFile = async (user: any, _path?: string): Promise<any> => {
|
||||||
formData.append('file', fs.createReadStream(absPath));
|
formData.append('file', fs.createReadStream(absPath));
|
||||||
formData.append('force', 'true');
|
formData.append('force', 'true');
|
||||||
|
|
||||||
const res = await got<string>(`http://${host}:${port}/api/drive/files/create`, {
|
const res = await got<string>(`http://localhost:${port}/api/drive/files/create`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
retry: {
|
retry: {
|
||||||
|
@ -161,7 +160,7 @@ export const uploadUrl = async (user: any, url: string) => {
|
||||||
|
|
||||||
export function connectStream(user: any, channel: string, listener: (message: Record<string, any>) => any, params?: any): Promise<WebSocket> {
|
export function connectStream(user: any, channel: string, listener: (message: Record<string, any>) => any, params?: any): Promise<WebSocket> {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
const ws = new WebSocket(`ws://${host}:${port}/streaming?i=${user.token}`);
|
const ws = new WebSocket(`ws://localhost:${port}/streaming?i=${user.token}`);
|
||||||
|
|
||||||
ws.on('open', () => {
|
ws.on('open', () => {
|
||||||
ws.on('message', data => {
|
ws.on('message', data => {
|
||||||
|
@ -223,7 +222,7 @@ export const waitFire = async (user: any, channel: string, trgr: () => any, cond
|
||||||
export const simpleGet = async (path: string, accept = '*/*'): Promise<{ status?: number, type?: string, location?: string }> => {
|
export const simpleGet = async (path: string, accept = '*/*'): Promise<{ status?: number, type?: string, location?: string }> => {
|
||||||
// node-fetchだと3xxを取れない
|
// node-fetchだと3xxを取れない
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
const req = http.request(`http://${host}:${port}${path}`, {
|
const req = http.request(`http://localhost:${port}${path}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: accept,
|
Accept: accept,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue