Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
service_ipc.h File Reference
#include <Windows.h>
#include <string>
#include <queue>
#include <mutex>
#include <condition_variable>
#include <thread>

Go to the source code of this file.

Classes

class  PanoptesContainerClient

Functions

VOID RunServiceServer (LPVOID lpParam)

Function Documentation

◆ RunServiceServer()

VOID RunServiceServer ( LPVOID lpParam)

Definition at line 598 of file grpc.cpp.

599{
600 serviceContext = reinterpret_cast<PanoptesContext*>(lpParam);
601 PanoptesImpl service;
602 grpc::ServerBuilder builder;
603 int selected_port = 0;
604 std::string server_url = "localhost:0";
605
606 //Setting the server address to localhost:0 will allow the OS to assign an available port
607 builder.AddListeningPort(server_url, grpc::InsecureServerCredentials(), &selected_port);
608 builder.RegisterService(&service);
609
610 std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
611 if (server == nullptr) {
612 auto threadError = &serviceContext->threadError;
613 bool threadState = threadError->load();
614 threadError->store(true);
615 return;
616 }
617
618 g_serverPort = selected_port;
619 bool updatedReg = CreateRegistryEntryWithPort(selected_port);
620 if (!updatedReg) {
621 auto threadError = &serviceContext->threadError;
622 bool threadState = threadError->load();
623 threadError->store(true);
624 }
625
626 {
627 std::lock_guard<std::mutex> lock(g_serverLock);
628 if (g_serverStopping) {
629 server->Shutdown();
630 }
631 g_server = server.get();
632 }
633
634 // Returns once StopServiceServer has shut the server down
635 server->Wait();
636
637 std::lock_guard<std::mutex> lock(g_serverLock);
638 g_server = nullptr;
639}
The PanoptesImpl class is a class that implements the PanoptesExtensibility::Service interface from t...
PanoptesContext * serviceContext
Definition grpc.cpp:33
bool CreateRegistryEntryWithPort(DWORD dwPort)
Definition grpc.cpp:152