Feature: built-in server will listen to 0.0.0.0 other than 127.0.0.1

This commit is contained in:
Kuingsmile
2023-10-09 23:18:09 +08:00
parent 615cbc5f07
commit 54d289c8f1
7 changed files with 25 additions and 21 deletions

View File

@@ -40,10 +40,13 @@ class Server {
const result = this.checkIfConfigIsValid(config)
if (result) {
this.config = config
if (this.config.host === '127.0.0.1') {
this.config.host = '0.0.0.0'
}
} else {
config = {
port: 36677,
host: '127.0.0.1',
host: '0.0.0.0',
enable: true
}
this.config = config
@@ -141,7 +144,7 @@ class Server {
// port as string is a bug
private listen = (port: number | string) => {
logger.info(`[PicList Server] is listening at ${port}`)
logger.info(`[PicList Server] is listening at ${port} of ${this.config.host}`)
if (typeof port === 'string') {
port = parseInt(port, 10)
}
@@ -177,6 +180,9 @@ class Server {
restart () {
this.config = picgo.getConfig('settings.server')
if (this.config.host === '127.0.0.1') {
this.config.host = '0.0.0.0'
}
this.shutdown()
this.startup()
}