From 705fb90740e2583ae7c8cfd1dd88202bc00a1ca0 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sun, 14 Jan 2024 17:36:43 +0100 Subject: [PATCH] Remove agent string The agent string was inspired by the HTTP User-Agent header to serve as a way to identify what's connecting to the cluster. While there may have been vision of other software connecting to a controller than the Clusterio provided ones this seems highly unlikely to ever happen. Remove redundant agent string for now. --- docs/devs/protocol.md | 3 --- packages/controller/src/ControlConnection.ts | 4 +--- packages/controller/src/HostConnection.ts | 3 --- packages/controller/src/HostInfo.ts | 6 ------ packages/controller/src/WsServer.ts | 4 ++-- packages/ctl/ctl.ts | 1 - packages/host/host.ts | 1 - packages/lib/src/data/messages_core.ts | 8 ++------ packages/lib/src/data/messages_host.ts | 3 --- packages/web_ui/src/components/HostViewPage.tsx | 1 - packages/web_ui/src/components/HostsPage.tsx | 6 ------ packages/web_ui/src/util/websocket.ts | 1 - test/lib/command.js | 2 +- 13 files changed, 6 insertions(+), 37 deletions(-) diff --git a/docs/devs/protocol.md b/docs/devs/protocol.md index 230ad045..46d72949 100644 --- a/docs/devs/protocol.md +++ b/docs/devs/protocol.md @@ -107,7 +107,6 @@ Sent by the controller when the WebSocket connection has been opened. Host handshake for establishing a new connection session. - `token: string` - Authentication token. -- `agent: string` - Human readable string of the software connecting. - `version: string` - The protocol version of the host, e.g. "2.0.0". - `name: string` - Name of the host. - `id: integer` - ID of the host. @@ -119,7 +118,6 @@ Host handshake for establishing a new connection session. Control handshake for enstablishing a new connection session. - `token: string` - Authentication token. -- `agent: string` - Human readable string of the software connecting. - `version: string` - The protocol version of the control, e.g. "2.0.0". #### `resume` @@ -243,7 +241,6 @@ Host registering a new connection session. "type": "register_host", "data": { "token": "xyzabc123", - "agent": "Clusterio Host", "version": "2.0.0", "name": "Foo", "id": 123 diff --git a/packages/controller/src/ControlConnection.ts b/packages/controller/src/ControlConnection.ts index 6cf9deca..9284b97c 100644 --- a/packages/controller/src/ControlConnection.ts +++ b/packages/controller/src/ControlConnection.ts @@ -24,7 +24,6 @@ const queryLogTime = new lib.Summary( * @alias module:controller/src/ControlConnection */ export default class ControlConnection extends BaseConnection { - private _agent: string; private _version: string; logTransport: lib.LinkTransport | null = null; logSubscriptions = { @@ -38,7 +37,7 @@ export default class ControlConnection extends BaseConnection { declare connector: WsServerConnector; constructor( - registerData: { agent:string, version:string }, + registerData: { version: string }, connector: WsServerConnector, controller: Controller, public user: ControllerUser, // The user making this connection. @@ -46,7 +45,6 @@ export default class ControlConnection extends BaseConnection { ) { super(connector, controller); - this._agent = registerData.agent; this._version = registerData.version; this.connector.on("connect", () => { diff --git a/packages/controller/src/HostConnection.ts b/packages/controller/src/HostConnection.ts index 037dabc8..62f4546e 100644 --- a/packages/controller/src/HostConnection.ts +++ b/packages/controller/src/HostConnection.ts @@ -16,7 +16,6 @@ import HostInfo from "./HostInfo"; * @alias module:controller/src/HostConnection */ export default class HostConnection extends BaseConnection { - private _agent: string; private _id: number; private _name: string; private _version: string; @@ -29,7 +28,6 @@ export default class HostConnection extends BaseConnection { ) { super(connector, controller); - this._agent = registerData.agent; this._id = registerData.id; this._name = registerData.name; this._version = registerData.version; @@ -38,7 +36,6 @@ export default class HostConnection extends BaseConnection { const previousHostInfo = this._controller.hosts.get(this._id); const currentHostInfo = new HostInfo( - this._agent, this._id, this._name, this._version, diff --git a/packages/controller/src/HostInfo.ts b/packages/controller/src/HostInfo.ts index 7a817c53..6b523c9c 100644 --- a/packages/controller/src/HostInfo.ts +++ b/packages/controller/src/HostInfo.ts @@ -6,8 +6,6 @@ import { HostDetails } from "@clusterio/lib"; */ export default class HostInfo { constructor( - /** Agent this host last connected with */ - public agent: string, /** Id of this host */ public id: number, /** Version this host last connected with */ @@ -29,7 +27,6 @@ export default class HostInfo { ) { } static jsonSchema = Type.Object({ - "agent": Type.String(), "id": Type.Number(), "name": Type.String(), "version": Type.String(), @@ -43,7 +40,6 @@ export default class HostInfo { static fromJSON(json: Static) { return new this( - json.agent, json.id, json.name, json.version, @@ -58,7 +54,6 @@ export default class HostInfo { toJSON(): Static { return { - agent: this.agent, id: this.id, name: this.name, version: this.version, @@ -73,7 +68,6 @@ export default class HostInfo { toHostDetails() { return new HostDetails( - this.agent, this.version, this.name, this.id, diff --git a/packages/controller/src/WsServer.ts b/packages/controller/src/WsServer.ts index e4b86251..d2166cfa 100644 --- a/packages/controller/src/WsServer.ts +++ b/packages/controller/src/WsServer.ts @@ -261,9 +261,9 @@ ${err.stack}` } logger.info( - `WsServer | registered host ${data.name} (${data.id}) using agent ${data.agent} ${data.version}` + `WsServer | registered host ${data.name} (${data.id}) using version ${data.version}` ); - if (data.agent === "Clusterio Host" && data.version !== packageVersion) { + if (data.version !== packageVersion) { logger.warn( `Host ${data.name} (${data.id}) connected using version ${data.version} which does not match the ` + `version of the controller is currently running (${packageVersion}). It may not work as expected.` diff --git a/packages/ctl/ctl.ts b/packages/ctl/ctl.ts index 46863461..b5edb31c 100755 --- a/packages/ctl/ctl.ts +++ b/packages/ctl/ctl.ts @@ -38,7 +38,6 @@ class ControlConnector extends lib.WebSocketClientConnector { new lib.MessageRegisterControl( new lib.RegisterControlData( this._token, - "clusterioctl", version, ) ) diff --git a/packages/host/host.ts b/packages/host/host.ts index 56a8c346..bce5e8a2 100755 --- a/packages/host/host.ts +++ b/packages/host/host.ts @@ -51,7 +51,6 @@ export class HostConnector extends lib.WebSocketClientConnector { new lib.MessageRegisterHost( new lib.RegisterHostData( this.hostConfig.get("host.controller_token"), - "Clusterio Host", version, this.hostConfig.get("host.name"), this.hostConfig.get("host.id"), diff --git a/packages/lib/src/data/messages_core.ts b/packages/lib/src/data/messages_core.ts index a5c2d54b..ba531930 100644 --- a/packages/lib/src/data/messages_core.ts +++ b/packages/lib/src/data/messages_core.ts @@ -211,7 +211,6 @@ export class MessageHello extends Message { export class RegisterHostData { constructor( public token: string, - public agent: string, public version: string, public name: string, public id: number, @@ -221,7 +220,6 @@ export class RegisterHostData { static jsonSchema = Type.Object({ "token": Type.String(), - "agent": Type.String(), "version": Type.String(), "name": Type.String(), "id": Type.Integer(), @@ -230,7 +228,7 @@ export class RegisterHostData { }); static fromJSON(json: Static) { - return new this(json.token, json.agent, json.version, json.name, json.id, json.publicAddress, json.plugins); + return new this(json.token, json.version, json.name, json.id, json.publicAddress, json.plugins); } } @@ -254,18 +252,16 @@ export class MessageRegisterHost extends Message { export class RegisterControlData { constructor( public token: string, - public agent: string, public version: string, ) { } static jsonSchema = Type.Object({ "token": Type.String(), - "agent": Type.String(), "version": Type.String(), }); static fromJSON(json: Static) { - return new this(json.token, json.agent, json.version); + return new this(json.token, json.version); } } diff --git a/packages/lib/src/data/messages_host.ts b/packages/lib/src/data/messages_host.ts index 674ff34e..1ee3b4b6 100644 --- a/packages/lib/src/data/messages_host.ts +++ b/packages/lib/src/data/messages_host.ts @@ -4,7 +4,6 @@ import { CollectorResultSerialized } from "../prometheus"; export class HostDetails { constructor( - public agent: string, public version: string, public name: string, public id: number, @@ -17,7 +16,6 @@ export class HostDetails { ) { } static jsonSchema = Type.Object({ - "agent": Type.String(), "version": Type.String(), "name": Type.String(), "id": Type.Integer(), @@ -30,7 +28,6 @@ export class HostDetails { static fromJSON(json: Static) { return new this( - json.agent, json.version, json.name, json.id, diff --git a/packages/web_ui/src/components/HostViewPage.tsx b/packages/web_ui/src/components/HostViewPage.tsx index f9c9f74e..6906bf5d 100644 --- a/packages/web_ui/src/components/HostViewPage.tsx +++ b/packages/web_ui/src/components/HostViewPage.tsx @@ -83,7 +83,6 @@ export default function HostViewPage() { - {host["agent"]} {host["version"]} { host.tokenValidAfter diff --git a/packages/web_ui/src/components/HostsPage.tsx b/packages/web_ui/src/components/HostsPage.tsx index 6a6586fa..510f6e2b 100644 --- a/packages/web_ui/src/components/HostsPage.tsx +++ b/packages/web_ui/src/components/HostsPage.tsx @@ -251,12 +251,6 @@ export default function HostsPage() { render: (_, host) => , hidden: !showNumbers, }, - { - title: "Agent", - dataIndex: "agent", - sorter: (a, b) => strcmp(a.agent, b.agent), - responsive: ["lg"], - }, { title: "Version", dataIndex: "version", diff --git a/packages/web_ui/src/util/websocket.ts b/packages/web_ui/src/util/websocket.ts index 6596725b..f987ce15 100644 --- a/packages/web_ui/src/util/websocket.ts +++ b/packages/web_ui/src/util/websocket.ts @@ -30,7 +30,6 @@ export class ControlConnector extends lib.WebSocketClientConnector { new lib.MessageRegisterControl( new lib.RegisterControlData( this.token, - "Clusterio Web UI", packageJson.version, ) ) diff --git a/test/lib/command.js b/test/lib/command.js index 82decfea..86e299c6 100644 --- a/test/lib/command.js +++ b/test/lib/command.js @@ -16,7 +16,7 @@ describe("lib/command", function() { let testControl = new mock.MockControl(controlConnector); let testController = new lib.Link(controllerConnector); testController.handle( - lib.HostListRequest, () => [new lib.HostDetails("test", "0.1", "Test Host", 11, false)] + lib.HostListRequest, () => [new lib.HostDetails("0.1", "Test Host", 11, false)] ); testController.handle( lib.InstanceDetailsListRequest, () => [new lib.InstanceDetails("Test Instance", 57, 4, undefined, "stopped")]