Add address host connected from to the host info

Provide an easy way to see where a host is connecting from in the web UI
and clusterioctl list.
This commit is contained in:
Hornwitser committed 2024-01-16 21:27:02 +01:00
1 parent de47989527
commit b5ed0800cf
5 files changed
+16 -4

No files matched your search

@@ -23,6 +23,7 @@ export default class HostConnection extends BaseConnection {
registerData: lib.RegisterHostData,
connector: WsServerConnector,
controller: Controller,
remoteAddress: string,
) {
super(connector, controller);
@@ -35,6 +36,7 @@ export default class HostConnection extends BaseConnection {
registerData.version,
this.plugins,
true,
remoteAddress,
previousHostInfo?.publicAddress,
previousHostInfo?.tokenValidAfter,
0,
+7 -1
View File
@@ -16,9 +16,11 @@ export default class HostInfo {
public plugins: Map<string, string>,
/** True if this host is currently connected to controller */
public connected: boolean = false,
/** IP this host last connected from */
public remoteAddress: string = "",
/** Value of host.public_address configured for this host */
public publicAddress: string = "",
/** Unix timestamp in seconds host token must be issued afterto be valid */
/** Unix timestamp in seconds host token must be issued after to be valid */
public tokenValidAfter: number = 0,
/** Millisecond Unix timestamp this entry was last updated at */
public updatedAt: number = 0,
@@ -32,6 +34,7 @@ export default class HostInfo {
"version": Type.String(),
"plugins": Type.Record(Type.String(), Type.String()),
"connected": Type.Boolean(),
"remote_address": Type.String(),
"public_address": Type.String(),
"token_valid_after": Type.Number(),
"updated_at": Type.Number(),
@@ -45,6 +48,7 @@ export default class HostInfo {
json.version,
new Map(Object.entries(json.plugins)),
json.connected,
json.remote_address,
json.public_address,
json.token_valid_after,
json.updated_at,
@@ -59,6 +63,7 @@ export default class HostInfo {
version: this.version,
plugins: Object.fromEntries(this.plugins),
connected: this.connected,
remote_address: this.remoteAddress,
public_address: this.publicAddress,
token_valid_after: this.tokenValidAfter,
updated_at: this.updatedAt,
@@ -72,6 +77,7 @@ export default class HostInfo {
this.name,
this.id,
this.connected,
this.remoteAddress,
this.publicAddress,
this.tokenValidAfter,
this.updatedAt,
+1 -1
View File
@@ -284,7 +284,7 @@ ${err.stack}`
);
}
connection = new HostConnection(data, connector, this.controller);
connection = new HostConnection(data, connector, this.controller, this.remoteAddr(req));
connector.on("close", () => {
if (this.hostConnections.get(data.id) === connection) {
this.hostConnections.delete(data.id);