Implement hello back in IPC protocol (#7334)

* Update VS Code config for Windows daemon debugging

* Update CL

* Implement hello back in IPC protocol

* Update CL
This commit is contained in:
Nick Bolton 2024-01-23 22:20:53 +00:00 committed by GitHub
parent fb908d6e17
commit 9e2fc6150e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 43 additions and 13 deletions

View File

@ -11,9 +11,6 @@ Enhancements:
- #7277 Change all errors that cause crash are FATAL
- #7282 Improve error handling for thread jobs
- #7284 Change session ID info log message to DEBUG2
Tasks:
- #7283 Update all workflows and fix broken macOS workflows
- #7313 Fix CodeQL workflow: Failed to perl 404 Not Found
- #7317 Bump sonar-scanner-cli to 5.0.1.3006
@ -31,6 +28,7 @@ Tasks:
- #7331 Script to install deps (Windows only for now)
- #7332 Static link OpenSSL libs in CMake preset for Windows
- #7333 Update VS Code config for Windows daemon debugging
- #7334 Implement hello back in IPC protocol
# 1.14.6
@ -62,9 +60,6 @@ Enhancements:
- #7193 Support for maintenance licenses in China
- #7197 Special contributor mentions on the about screen
- #7203 License registration for Business edition
CI changes:
- #7210 Update macos workflow to use macos-latest
- #7213 Update azure pipelines to use macos-latest
@ -86,9 +81,6 @@ Enhancements:
- #7188 Synergy Basic\Pro accepts business licenses
- #7166 Replace language notifications with warnings in logs
- #7181 Fedora 36 support to CI system
CI changes:
- #7177 Create workflow for flatpak build support
- #7148 Fix unstable build for Windows core
- #7156 Change binary storage server
@ -135,9 +127,6 @@ Enhancements:
- #7068 Restart when settings changed
- #7072 Run synergy as a pre-login agent
- #7074 Restart when server settings changed
CI changes:
- #1043 Upload to S3 feature on all OS
- #7098 Apple M1 runner
- #7103 Fix core builds

View File

@ -19,6 +19,7 @@
#include "ipc/Ipc.h"
const char* kIpcMsgHello = "IHEL%1i";
const char* kIpcMsgHelloBack = "IHEL";
const char* kIpcMsgLogLine = "ILOG%s";
const char* kIpcMsgCommand = "ICMD%s%1i";
const char* kIpcMsgShutdown = "ISDN";

View File

@ -23,6 +23,7 @@
enum EIpcMessage {
kIpcHello,
kIpcHelloBack,
kIpcLogLine,
kIpcCommand,
kIpcShutdown,
@ -32,13 +33,17 @@ enum EIpcMessage {
enum EIpcClientType {
kIpcClientUnknown,
kIpcClientGui,
kIpcClientNode,
kIpcClientNode
};
// handshake: node/gui -> daemon
// $1 = type, the client identifies it's self as gui or node (synergyc/s).
extern const char* kIpcMsgHello;
// handshake: daemon -> node/gui
// the daemon responds to the handshake.
extern const char* kIpcMsgHelloBack;
// log line: daemon -> gui
// $1 = aggregate log lines collected from synergys/c or the daemon itself.
extern const char* kIpcMsgLogLine;

View File

@ -159,6 +159,10 @@ IpcClientProxy::send(const IpcMessage& message)
ProtocolUtil::writef(&m_stream, kIpcMsgShutdown);
break;
case kIpcHelloBack:
ProtocolUtil::writef(&m_stream, kIpcMsgHelloBack);
break;
default:
LOG((CLOG_ERR "ipc message not supported: %d", message.type()));
break;

View File

@ -38,6 +38,15 @@ IpcHelloMessage::~IpcHelloMessage()
{
}
IpcHelloBackMessage::IpcHelloBackMessage() :
IpcMessage(kIpcHelloBack)
{
}
IpcHelloBackMessage::~IpcHelloBackMessage()
{
}
IpcShutdownMessage::IpcShutdownMessage() :
IpcMessage(kIpcShutdown)
{

View File

@ -49,6 +49,12 @@ private:
EIpcClientType m_clientType;
};
class IpcHelloBackMessage : public IpcMessage {
public:
IpcHelloBackMessage();
virtual ~IpcHelloBackMessage();
};
class IpcShutdownMessage : public IpcMessage {
public:
IpcShutdownMessage();

View File

@ -21,6 +21,7 @@
#include "synergy/DaemonApp.h"
#include "ipc/Ipc.h"
#include "synergy/App.h"
#include "synergy/ArgParser.h"
#include "synergy/ServerArgs.h"
@ -37,6 +38,7 @@
#include "base/EventQueue.h"
#include "base/log_outputters.h"
#include "base/Log.h"
#include "synergy/protocol_types.h"
#if SYSAPI_WIN32
@ -145,6 +147,7 @@ DaemonApp::run(int argc, char** argv)
try
{
#if SYSAPI_WIN32
// TODO: maybe we should only add this if not using /f?
// sends debug messages to visual studio console window.
log.insert(new MSWindowsDebugOutputter());
#endif
@ -164,11 +167,13 @@ DaemonApp::run(int argc, char** argv)
}
#if SYSAPI_WIN32
else if (arg == "/install") {
LOG((CLOG_PRINT "installing windows daemon"));
uninstall = true;
arch.installDaemon();
return kExitSuccess;
}
else if (arg == "/uninstall") {
LOG((CLOG_PRINT "uninstalling windows daemon"));
arch.uninstallDaemon();
return kExitSuccess;
}
@ -182,14 +187,18 @@ DaemonApp::run(int argc, char** argv)
}
if (foreground) {
LOG((CLOG_PRINT "starting daemon in foreground"));
// run process in foreground instead of daemonizing.
// useful for debugging.
mainLoop(false, foreground);
}
else {
#if SYSAPI_WIN32
LOG((CLOG_PRINT "daemonizing windows service"));
arch.daemonize("Synergy", winMainLoopStatic);
#elif SYSAPI_UNIX
LOG((CLOG_PRINT "daemonizing unix service"));
arch.daemonize("Synergy", unixMainLoopStatic);
#endif
}
@ -399,6 +408,13 @@ DaemonApp::handleIpcMessage(const Event& e, void*)
LOG((CLOG_DEBUG "ipc hello, type=%s", type.c_str()));
// TODO: implement hello back handling in s1 gui and node (server/client).
if (hm->clientType() == kIpcClientGui) {
LOG((CLOG_DEBUG "sending ipc hello back"));
IpcHelloBackMessage hbm;
m_ipcServer->send(hbm, hm->clientType());
}
#if SYSAPI_WIN32
String watchdogStatus = m_watchdog->isProcessActive() ? "active" : "idle";
LOG((CLOG_INFO "service status: %s", watchdogStatus.c_str()));