mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-16 10:28:33 -07:00
Add host bind option for frontend (#5014)
* Added IP address bind to HTTP frontend listener * Changed ip to host in configuration and code Co-authored-by: romanius <me@romanius.me> Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
This commit is contained in:
parent
9ee35f6933
commit
481cdefafc
@ -27,6 +27,7 @@ class Frontend extends Extension {
|
||||
this.server.on('upgrade', this.onUpgrade);
|
||||
this.developmentServer = settings.get().frontend.development_server;
|
||||
this.development = !!this.developmentServer;
|
||||
this.host = settings.get().frontend.host || '0.0.0.0';
|
||||
this.port = settings.get().frontend.port || 8080;
|
||||
this.retainedMessages = new Map();
|
||||
|
||||
@ -51,8 +52,8 @@ class Frontend extends Extension {
|
||||
logger.info(`Running frontend in development mode (${this.developmentServer})`);
|
||||
}
|
||||
|
||||
this.server.listen(this.port);
|
||||
logger.info(`Started frontend on port ${this.port}`);
|
||||
this.server.listen(this.port, this.host);
|
||||
logger.info(`Started frontend on port ${this.host}:${this.port}`);
|
||||
}
|
||||
|
||||
async stop() {
|
||||
|
@ -86,7 +86,7 @@ describe('Frontend', () => {
|
||||
data.writeDefaultState();
|
||||
settings._reRead();
|
||||
settings.set(['experimental'], {new_api: true});
|
||||
settings.set(['frontend'], {port: 8081});
|
||||
settings.set(['frontend'], {port: 8081, host: "127.0.0.1"});
|
||||
settings.set(['homeassistant'], true);
|
||||
zigbeeHerdsman.devices.bulb.linkquality = 10;
|
||||
});
|
||||
@ -99,7 +99,7 @@ describe('Frontend', () => {
|
||||
controller = new Controller();
|
||||
await controller.start();
|
||||
expect(mockNodeStatic.variables.path).toBe("my/dummy/path");
|
||||
expect(mockHTTP.implementation.listen).toHaveBeenCalledWith(8081);
|
||||
expect(mockHTTP.implementation.listen).toHaveBeenCalledWith(8081, "127.0.0.1");
|
||||
|
||||
const mockWSClient = {
|
||||
implementation: {
|
||||
@ -197,7 +197,7 @@ describe('Frontend', () => {
|
||||
controller = new Controller();
|
||||
await controller.start();
|
||||
expect(mockHTTPProxy.variables.initParameter).toStrictEqual({ws: true});
|
||||
expect(mockHTTP.implementation.listen).toHaveBeenCalledWith(8080);
|
||||
expect(mockHTTP.implementation.listen).toHaveBeenCalledWith(8080, "0.0.0.0");
|
||||
|
||||
mockHTTP.variables.onRequest(1, 2);
|
||||
expect(mockHTTPProxy.implementation.web).toHaveBeenCalledTimes(1);
|
||||
|
Loading…
Reference in New Issue
Block a user