From 8c25f3f44dd26f86ca72939b46d8fc80881bde53 Mon Sep 17 00:00:00 2001 From: Emma Casolin Date: Thu, 24 Feb 2022 16:55:38 +1100 Subject: [PATCH] `agent restart` command --- src/PolykeyAgent.ts | 19 ++ src/bin/agent/CommandAgent.ts | 2 + src/bin/agent/CommandRestart.ts | 86 +++++ src/client/GRPCClientClient.ts | 8 + src/client/service/agentRestart.ts | 47 +++ src/client/service/index.ts | 2 + src/proto/js/polykey/v1/agent/agent_pb.d.ts | 35 ++ src/proto/js/polykey/v1/agent/agent_pb.js | 302 ++++++++++++++++++ .../js/polykey/v1/client_service_grpc_pb.d.ts | 17 + .../js/polykey/v1/client_service_grpc_pb.js | 22 ++ .../schemas/polykey/v1/agent/agent.proto | 9 + .../schemas/polykey/v1/client_service.proto | 1 + 12 files changed, 550 insertions(+) create mode 100644 src/bin/agent/CommandRestart.ts create mode 100644 src/client/service/agentRestart.ts diff --git a/src/PolykeyAgent.ts b/src/PolykeyAgent.ts index 87c605c773..8037c1188a 100644 --- a/src/PolykeyAgent.ts +++ b/src/PolykeyAgent.ts @@ -712,6 +712,25 @@ class PolykeyAgent { this.logger.info(`Destroyed ${this.constructor.name}`); } + public async restart({ + password, + networkConfig = {}, + fresh = false, + }: { + password: string; + networkConfig?: NetworkConfig; + fresh?: boolean; + }) { + this.logger.info(`Restarting ${this.constructor.name}`); + await this.stop(); + await this.start({ + password, + networkConfig, + fresh, + }); + this.logger.info(`Restarted ${this.constructor.name}`); + } + public setWorkerManager(workerManager: PolykeyWorkerManagerInterface) { this.db.setWorkerManager(workerManager); this.keyManager.setWorkerManager(workerManager); diff --git a/src/bin/agent/CommandAgent.ts b/src/bin/agent/CommandAgent.ts index 8e83ac63e0..4bc96b55bb 100644 --- a/src/bin/agent/CommandAgent.ts +++ b/src/bin/agent/CommandAgent.ts @@ -1,5 +1,6 @@ import CommandLock from './CommandLock'; import CommandLockAll from './CommandLockAll'; +import CommandRestart from './CommandRestart'; import CommandStart from './CommandStart'; import CommandStatus from './CommandStatus'; import CommandStop from './CommandStop'; @@ -13,6 +14,7 @@ class CommandAgent extends CommandPolykey { this.description('Agent Operations'); this.addCommand(new CommandLock(...args)); this.addCommand(new CommandLockAll(...args)); + this.addCommand(new CommandRestart(...args)); this.addCommand(new CommandStart(...args)); this.addCommand(new CommandStatus(...args)); this.addCommand(new CommandStop(...args)); diff --git a/src/bin/agent/CommandRestart.ts b/src/bin/agent/CommandRestart.ts new file mode 100644 index 0000000000..3f63a44a6c --- /dev/null +++ b/src/bin/agent/CommandRestart.ts @@ -0,0 +1,86 @@ +import type PolykeyClient from '../../PolykeyClient'; +import CommandPolykey from '../CommandPolykey'; +import * as binUtils from '../utils'; +import * as binOptions from '../utils/options'; +import * as binProcessors from '../utils/processors'; +import * as binErrors from '../errors'; +import config from '../../config'; + +class CommandRestart extends CommandPolykey { + constructor(...args: ConstructorParameters) { + super(...args); + this.name('restart'); + this.description('Restart the Polykey Agent'); + this.addOption(binOptions.nodeId); + this.addOption(binOptions.clientHost); + this.addOption(binOptions.clientPort); + this.addOption(binOptions.ingressHost); + this.addOption(binOptions.ingressPort); + this.addOption(binOptions.fresh); + this.action(async (options) => { + const { default: PolykeyClient } = await import('../../PolykeyClient'); + const agentPB = await import('../../proto/js/polykey/v1/agent/agent_pb'); + const clientStatus = await binProcessors.processClientStatus( + options.nodePath, + options.nodeId, + options.clientHost, + options.clientPort, + this.fs, + this.logger.getChild(binProcessors.processClientOptions.name), + ); + const statusInfo = clientStatus.statusInfo; + if (statusInfo?.status === 'DEAD') { + this.logger.info('Agent is already dead'); + return; + } else if (statusInfo?.status === 'STOPPING') { + this.logger.info('Agent is already stopping'); + return; + } else if (statusInfo?.status === 'STARTING') { + throw new binErrors.ErrorCLIStatusStarting(); + } + const meta = await binProcessors.processAuthentication( + options.passwordFile, + this.fs, + ); + const password = await binProcessors.processPassword( + options.passwordFile, + this.fs, + ); + // Either the statusInfo is undefined or LIVE + // Either way, the connection parameters now exist + let pkClient: PolykeyClient; + this.exitHandlers.handlers.push(async () => { + if (pkClient != null) await pkClient.stop(); + }); + try { + pkClient = await PolykeyClient.createPolykeyClient({ + nodePath: options.nodePath, + nodeId: clientStatus.nodeId!, + host: clientStatus.clientHost!, + port: clientStatus.clientPort!, + logger: this.logger.getChild(PolykeyClient.name), + }); + const restartMessage = new agentPB.RestartMessage(); + restartMessage.setPassword(password); + restartMessage.setClientHost( + options.clientHost ?? config.defaults.networkConfig.clientHost, + ); + restartMessage.setClientPort( + options.clientPort ?? config.defaults.networkConfig.clientPort, + ); + restartMessage.setIngressHost(options.ingressHost); + restartMessage.setIngressPort(options.ingressPort); + restartMessage.setFresh(options.fresh); + await binUtils.retryAuthentication( + (auth) => pkClient.grpcClient.agentRestart(restartMessage, auth), + meta, + ); + this.logger.info('Restarting Agent'); + } finally { + if (pkClient! != null) await pkClient.stop(); + } + }); + } +} + +export default CommandRestart; diff --git a/src/client/GRPCClientClient.ts b/src/client/GRPCClientClient.ts index ae0de84f1d..b86b4aa8ef 100644 --- a/src/client/GRPCClientClient.ts +++ b/src/client/GRPCClientClient.ts @@ -119,6 +119,14 @@ class GRPCClientClient extends GRPCClient { )(...args); } + @ready(new clientErrors.ErrorClientClientDestroyed()) + public agentRestart(...args) { + return grpcUtils.promisifyUnaryCall( + this.client, + this.client.agentRestart, + )(...args); + } + @ready(new clientErrors.ErrorClientClientDestroyed()) public vaultsList( ...args diff --git a/src/client/service/agentRestart.ts b/src/client/service/agentRestart.ts new file mode 100644 index 0000000000..d822782ed8 --- /dev/null +++ b/src/client/service/agentRestart.ts @@ -0,0 +1,47 @@ +import type { Host, Port } from '../../network/types'; +import type * as grpc from '@grpc/grpc-js'; +import type { Authenticate } from '../types'; +import type PolykeyAgent from '../../PolykeyAgent'; +import type * as agentPB from '../../proto/js/polykey/v1/agent/agent_pb'; +import * as grpcUtils from '../../grpc/utils'; +import * as utilsPB from '../../proto/js/polykey/v1/utils/utils_pb'; + +function agentRestart({ + authenticate, + pkAgent, +}: { + authenticate: Authenticate; + pkAgent: PolykeyAgent; +}) { + return async ( + call: grpc.ServerUnaryCall, + callback: grpc.sendUnaryData, + ): Promise => { + const response = new utilsPB.EmptyMessage(); + try { + const metadata = await authenticate(call.metadata); + call.sendMetadata(metadata); + // Respond first to close the GRPC connection + callback(null, response); + } catch (err) { + callback(grpcUtils.fromError(err), null); + return; + } + const password = call.request.getPassword(); + const networkConfig = { + clientHost: call.request.getClientHost() as Host, + clientPort: call.request.getClientPort() as Port, + ingressHost: call.request.getIngressHost() as Host, + ingressPort: call.request.getIngressPort() as Port, + }; + const fresh = call.request.getFresh(); + await pkAgent.restart({ + password, + networkConfig, + fresh, + }); + return; + }; +} + +export default agentRestart; diff --git a/src/client/service/index.ts b/src/client/service/index.ts index 70864a2f39..fe7849d85d 100644 --- a/src/client/service/index.ts +++ b/src/client/service/index.ts @@ -19,6 +19,7 @@ import type { IClientServiceServer } from '../../proto/js/polykey/v1/client_serv import type { FileSystem } from '../../types'; import Logger from '@matrixai/logger'; import agentLockAll from './agentLockAll'; +import agentRestart from './agentRestart'; import agentStatus from './agentStatus'; import agentStop from './agentStop'; import agentUnlock from './agentUnlock'; @@ -122,6 +123,7 @@ function createService({ }; const service: IClientServiceServer = { agentLockAll: agentLockAll(container), + agentRestart: agentRestart(container), agentStatus: agentStatus(container), agentStop: agentStop(container), agentUnlock: agentUnlock(container), diff --git a/src/proto/js/polykey/v1/agent/agent_pb.d.ts b/src/proto/js/polykey/v1/agent/agent_pb.d.ts index 0f71b70128..832c8acbf6 100644 --- a/src/proto/js/polykey/v1/agent/agent_pb.d.ts +++ b/src/proto/js/polykey/v1/agent/agent_pb.d.ts @@ -67,3 +67,38 @@ export namespace InfoMessage { rootCertChainPem: string, } } + +export class RestartMessage extends jspb.Message { + getPassword(): string; + setPassword(value: string): RestartMessage; + getClientHost(): string; + setClientHost(value: string): RestartMessage; + getClientPort(): number; + setClientPort(value: number): RestartMessage; + getIngressHost(): string; + setIngressHost(value: string): RestartMessage; + getIngressPort(): number; + setIngressPort(value: number): RestartMessage; + getFresh(): boolean; + setFresh(value: boolean): RestartMessage; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): RestartMessage.AsObject; + static toObject(includeInstance: boolean, msg: RestartMessage): RestartMessage.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: RestartMessage, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): RestartMessage; + static deserializeBinaryFromReader(message: RestartMessage, reader: jspb.BinaryReader): RestartMessage; +} + +export namespace RestartMessage { + export type AsObject = { + password: string, + clientHost: string, + clientPort: number, + ingressHost: string, + ingressPort: number, + fresh: boolean, + } +} diff --git a/src/proto/js/polykey/v1/agent/agent_pb.js b/src/proto/js/polykey/v1/agent/agent_pb.js index 2421558f83..384d1e8ad4 100644 --- a/src/proto/js/polykey/v1/agent/agent_pb.js +++ b/src/proto/js/polykey/v1/agent/agent_pb.js @@ -15,6 +15,7 @@ var goog = jspb; var global = Function('return this')(); goog.exportSymbol('proto.polykey.v1.agent.InfoMessage', null, global); +goog.exportSymbol('proto.polykey.v1.agent.RestartMessage', null, global); /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -36,6 +37,27 @@ if (goog.DEBUG && !COMPILED) { */ proto.polykey.v1.agent.InfoMessage.displayName = 'proto.polykey.v1.agent.InfoMessage'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.polykey.v1.agent.RestartMessage = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.polykey.v1.agent.RestartMessage, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.polykey.v1.agent.RestartMessage.displayName = 'proto.polykey.v1.agent.RestartMessage'; +} @@ -586,4 +608,284 @@ proto.polykey.v1.agent.InfoMessage.prototype.setRootCertChainPem = function(valu }; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.polykey.v1.agent.RestartMessage.prototype.toObject = function(opt_includeInstance) { + return proto.polykey.v1.agent.RestartMessage.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.polykey.v1.agent.RestartMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.polykey.v1.agent.RestartMessage.toObject = function(includeInstance, msg) { + var f, obj = { + password: jspb.Message.getFieldWithDefault(msg, 1, ""), + clientHost: jspb.Message.getFieldWithDefault(msg, 2, ""), + clientPort: jspb.Message.getFieldWithDefault(msg, 3, 0), + ingressHost: jspb.Message.getFieldWithDefault(msg, 4, ""), + ingressPort: jspb.Message.getFieldWithDefault(msg, 5, 0), + fresh: jspb.Message.getBooleanFieldWithDefault(msg, 6, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.polykey.v1.agent.RestartMessage} + */ +proto.polykey.v1.agent.RestartMessage.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.polykey.v1.agent.RestartMessage; + return proto.polykey.v1.agent.RestartMessage.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.polykey.v1.agent.RestartMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.polykey.v1.agent.RestartMessage} + */ +proto.polykey.v1.agent.RestartMessage.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setPassword(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setClientHost(value); + break; + case 3: + var value = /** @type {number} */ (reader.readUint32()); + msg.setClientPort(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setIngressHost(value); + break; + case 5: + var value = /** @type {number} */ (reader.readUint32()); + msg.setIngressPort(value); + break; + case 6: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setFresh(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.polykey.v1.agent.RestartMessage.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.polykey.v1.agent.RestartMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.polykey.v1.agent.RestartMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.polykey.v1.agent.RestartMessage.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getPassword(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getClientHost(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getClientPort(); + if (f !== 0) { + writer.writeUint32( + 3, + f + ); + } + f = message.getIngressHost(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } + f = message.getIngressPort(); + if (f !== 0) { + writer.writeUint32( + 5, + f + ); + } + f = message.getFresh(); + if (f) { + writer.writeBool( + 6, + f + ); + } +}; + + +/** + * optional string password = 1; + * @return {string} + */ +proto.polykey.v1.agent.RestartMessage.prototype.getPassword = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.polykey.v1.agent.RestartMessage} returns this + */ +proto.polykey.v1.agent.RestartMessage.prototype.setPassword = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string client_host = 2; + * @return {string} + */ +proto.polykey.v1.agent.RestartMessage.prototype.getClientHost = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.polykey.v1.agent.RestartMessage} returns this + */ +proto.polykey.v1.agent.RestartMessage.prototype.setClientHost = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional uint32 client_port = 3; + * @return {number} + */ +proto.polykey.v1.agent.RestartMessage.prototype.getClientPort = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.polykey.v1.agent.RestartMessage} returns this + */ +proto.polykey.v1.agent.RestartMessage.prototype.setClientPort = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); +}; + + +/** + * optional string ingress_host = 4; + * @return {string} + */ +proto.polykey.v1.agent.RestartMessage.prototype.getIngressHost = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.polykey.v1.agent.RestartMessage} returns this + */ +proto.polykey.v1.agent.RestartMessage.prototype.setIngressHost = function(value) { + return jspb.Message.setProto3StringField(this, 4, value); +}; + + +/** + * optional uint32 ingress_port = 5; + * @return {number} + */ +proto.polykey.v1.agent.RestartMessage.prototype.getIngressPort = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.polykey.v1.agent.RestartMessage} returns this + */ +proto.polykey.v1.agent.RestartMessage.prototype.setIngressPort = function(value) { + return jspb.Message.setProto3IntField(this, 5, value); +}; + + +/** + * optional bool fresh = 6; + * @return {boolean} + */ +proto.polykey.v1.agent.RestartMessage.prototype.getFresh = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 6, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.polykey.v1.agent.RestartMessage} returns this + */ +proto.polykey.v1.agent.RestartMessage.prototype.setFresh = function(value) { + return jspb.Message.setProto3BooleanField(this, 6, value); +}; + + goog.object.extend(exports, proto.polykey.v1.agent); diff --git a/src/proto/js/polykey/v1/client_service_grpc_pb.d.ts b/src/proto/js/polykey/v1/client_service_grpc_pb.d.ts index d558b71408..c795a33358 100644 --- a/src/proto/js/polykey/v1/client_service_grpc_pb.d.ts +++ b/src/proto/js/polykey/v1/client_service_grpc_pb.d.ts @@ -20,6 +20,7 @@ import * as polykey_v1_utils_utils_pb from "../../polykey/v1/utils/utils_pb"; interface IClientServiceService extends grpc.ServiceDefinition { agentLockAll: IClientServiceService_IAgentLockAll; + agentRestart: IClientServiceService_IAgentRestart; agentStatus: IClientServiceService_IAgentStatus; agentStop: IClientServiceService_IAgentStop; agentUnlock: IClientServiceService_IAgentUnlock; @@ -94,6 +95,15 @@ interface IClientServiceService_IAgentLockAll extends grpc.MethodDefinition; responseDeserialize: grpc.deserialize; } +interface IClientServiceService_IAgentRestart extends grpc.MethodDefinition { + path: "/polykey.v1.ClientService/AgentRestart"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} interface IClientServiceService_IAgentStatus extends grpc.MethodDefinition { path: "/polykey.v1.ClientService/AgentStatus"; requestStream: false; @@ -666,6 +676,7 @@ export const ClientServiceService: IClientServiceService; export interface IClientServiceServer extends grpc.UntypedServiceImplementation { agentLockAll: grpc.handleUnaryCall; + agentRestart: grpc.handleUnaryCall; agentStatus: grpc.handleUnaryCall; agentStop: grpc.handleUnaryCall; agentUnlock: grpc.handleUnaryCall; @@ -735,6 +746,9 @@ export interface IClientServiceClient { agentLockAll(request: polykey_v1_utils_utils_pb.EmptyMessage, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; agentLockAll(request: polykey_v1_utils_utils_pb.EmptyMessage, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; agentLockAll(request: polykey_v1_utils_utils_pb.EmptyMessage, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; + agentRestart(request: polykey_v1_agent_agent_pb.RestartMessage, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; + agentRestart(request: polykey_v1_agent_agent_pb.RestartMessage, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; + agentRestart(request: polykey_v1_agent_agent_pb.RestartMessage, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; agentStatus(request: polykey_v1_utils_utils_pb.EmptyMessage, callback: (error: grpc.ServiceError | null, response: polykey_v1_agent_agent_pb.InfoMessage) => void): grpc.ClientUnaryCall; agentStatus(request: polykey_v1_utils_utils_pb.EmptyMessage, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: polykey_v1_agent_agent_pb.InfoMessage) => void): grpc.ClientUnaryCall; agentStatus(request: polykey_v1_utils_utils_pb.EmptyMessage, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: polykey_v1_agent_agent_pb.InfoMessage) => void): grpc.ClientUnaryCall; @@ -920,6 +934,9 @@ export class ClientServiceClient extends grpc.Client implements IClientServiceCl public agentLockAll(request: polykey_v1_utils_utils_pb.EmptyMessage, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; public agentLockAll(request: polykey_v1_utils_utils_pb.EmptyMessage, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; public agentLockAll(request: polykey_v1_utils_utils_pb.EmptyMessage, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; + public agentRestart(request: polykey_v1_agent_agent_pb.RestartMessage, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; + public agentRestart(request: polykey_v1_agent_agent_pb.RestartMessage, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; + public agentRestart(request: polykey_v1_agent_agent_pb.RestartMessage, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: polykey_v1_utils_utils_pb.EmptyMessage) => void): grpc.ClientUnaryCall; public agentStatus(request: polykey_v1_utils_utils_pb.EmptyMessage, callback: (error: grpc.ServiceError | null, response: polykey_v1_agent_agent_pb.InfoMessage) => void): grpc.ClientUnaryCall; public agentStatus(request: polykey_v1_utils_utils_pb.EmptyMessage, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: polykey_v1_agent_agent_pb.InfoMessage) => void): grpc.ClientUnaryCall; public agentStatus(request: polykey_v1_utils_utils_pb.EmptyMessage, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: polykey_v1_agent_agent_pb.InfoMessage) => void): grpc.ClientUnaryCall; diff --git a/src/proto/js/polykey/v1/client_service_grpc_pb.js b/src/proto/js/polykey/v1/client_service_grpc_pb.js index 59bfc3d728..bf33dee528 100644 --- a/src/proto/js/polykey/v1/client_service_grpc_pb.js +++ b/src/proto/js/polykey/v1/client_service_grpc_pb.js @@ -25,6 +25,17 @@ function deserialize_polykey_v1_agent_InfoMessage(buffer_arg) { return polykey_v1_agent_agent_pb.InfoMessage.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_polykey_v1_agent_RestartMessage(arg) { + if (!(arg instanceof polykey_v1_agent_agent_pb.RestartMessage)) { + throw new Error('Expected argument of type polykey.v1.agent.RestartMessage'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_polykey_v1_agent_RestartMessage(buffer_arg) { + return polykey_v1_agent_agent_pb.RestartMessage.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_polykey_v1_gestalts_Gestalt(arg) { if (!(arg instanceof polykey_v1_gestalts_gestalts_pb.Gestalt)) { throw new Error('Expected argument of type polykey.v1.gestalts.Gestalt'); @@ -512,6 +523,17 @@ agentLockAll: { responseSerialize: serialize_polykey_v1_utils_EmptyMessage, responseDeserialize: deserialize_polykey_v1_utils_EmptyMessage, }, + agentRestart: { + path: '/polykey.v1.ClientService/AgentRestart', + requestStream: false, + responseStream: false, + requestType: polykey_v1_agent_agent_pb.RestartMessage, + responseType: polykey_v1_utils_utils_pb.EmptyMessage, + requestSerialize: serialize_polykey_v1_agent_RestartMessage, + requestDeserialize: deserialize_polykey_v1_agent_RestartMessage, + responseSerialize: serialize_polykey_v1_utils_EmptyMessage, + responseDeserialize: deserialize_polykey_v1_utils_EmptyMessage, + }, agentStatus: { path: '/polykey.v1.ClientService/AgentStatus', requestStream: false, diff --git a/src/proto/schemas/polykey/v1/agent/agent.proto b/src/proto/schemas/polykey/v1/agent/agent.proto index 7e1a1e8d9d..27ac75c0c0 100644 --- a/src/proto/schemas/polykey/v1/agent/agent.proto +++ b/src/proto/schemas/polykey/v1/agent/agent.proto @@ -19,3 +19,12 @@ message InfoMessage { string root_cert_pem = 14; string root_cert_chain_pem = 15; } + +message RestartMessage { + string password = 1; + string client_host = 2; + uint32 client_port = 3; + string ingress_host = 4; + uint32 ingress_port = 5; + bool fresh = 6; +} diff --git a/src/proto/schemas/polykey/v1/client_service.proto b/src/proto/schemas/polykey/v1/client_service.proto index eb5aa9ced3..c97305aa60 100644 --- a/src/proto/schemas/polykey/v1/client_service.proto +++ b/src/proto/schemas/polykey/v1/client_service.proto @@ -17,6 +17,7 @@ package polykey.v1; service ClientService { // Agent rpc AgentLockAll (polykey.v1.utils.EmptyMessage) returns (polykey.v1.utils.EmptyMessage); + rpc AgentRestart (polykey.v1.agent.RestartMessage) returns (polykey.v1.utils.EmptyMessage); rpc AgentStatus(polykey.v1.utils.EmptyMessage) returns (polykey.v1.agent.InfoMessage); rpc AgentStop(polykey.v1.utils.EmptyMessage) returns (polykey.v1.utils.EmptyMessage); rpc AgentUnlock (polykey.v1.utils.EmptyMessage) returns (polykey.v1.utils.EmptyMessage);