mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 07:04:53 +09:00
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:
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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -64,8 +64,9 @@ export class HostDetails {
|
||||
public name: string,
|
||||
public id: number,
|
||||
public connected: boolean,
|
||||
public publicAddress?: string,
|
||||
public tokenValidAfter?: number,
|
||||
public remoteAddress = "",
|
||||
public publicAddress: string = "",
|
||||
public tokenValidAfter: number = 0,
|
||||
/** Millisecond Unix timestamp this entry was last updated at */
|
||||
public updatedAt = 0,
|
||||
public isDeleted = false,
|
||||
@@ -76,6 +77,7 @@ export class HostDetails {
|
||||
"name": Type.String(),
|
||||
"id": Type.Integer(),
|
||||
"connected": Type.Boolean(),
|
||||
"remoteAddress": Type.Optional(Type.String()),
|
||||
"publicAddress": Type.Optional(Type.String()),
|
||||
"tokenValidAfter": Type.Optional(Type.Number()),
|
||||
"updatedAt": Type.Optional(Type.Number()),
|
||||
@@ -88,6 +90,7 @@ export class HostDetails {
|
||||
json.name,
|
||||
json.id,
|
||||
json.connected,
|
||||
json.remoteAddress,
|
||||
json.publicAddress,
|
||||
json.tokenValidAfter,
|
||||
json.updatedAt,
|
||||
|
||||
@@ -83,6 +83,7 @@ export default function HostViewPage() {
|
||||
<Descriptions.Item label="OS Kernel">{system?.kernel}</Descriptions.Item>
|
||||
<Descriptions.Item label="Machine">{system?.machine}</Descriptions.Item>
|
||||
<Descriptions.Item label="Hostname" span={2}>{system?.hostname}</Descriptions.Item>
|
||||
<Descriptions.Item label="Connected From" span={2}>{host.remoteAddress}</Descriptions.Item>
|
||||
<Descriptions.Item label="CPU Model" span={2}>{system?.cpuModel}</Descriptions.Item>
|
||||
<Descriptions.Item label="CPU Usage"><MetricCpuRatio system={system} /></Descriptions.Item>
|
||||
<Descriptions.Item label="Cores"><MetricCpuUsed system={system} /></Descriptions.Item>
|
||||
|
||||
Reference in new issue
Block a user