MCPcopy Create free account
hub / github.com/Adaptix-Framework/AdaptixC2 / Start

Method Start

AdaptixClient/Source/MainAdaptix.cpp:40–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40void MainAdaptix::Start() const
41{
42 QThread* ChannelThread = nullptr;
43 WebSocketWorker* ChannelWsWorker = nullptr;
44 AuthProfile* authProfile = nullptr;
45
46 while (true) {
47 authProfile = this->Login();
48 if (!authProfile) {
49 this->Exit();
50 return;
51 }
52
53 ChannelThread = new QThread;
54 ChannelWsWorker = new WebSocketWorker(authProfile);
55 ChannelWsWorker->moveToThread( ChannelThread );
56
57 QEventLoop loop;
58 QTimer timeoutTimer;
59 timeoutTimer.setSingleShot(true);
60
61 connect( ChannelWsWorker, &WebSocketWorker::connected, &loop, &QEventLoop::quit);
62 connect( ChannelWsWorker, &WebSocketWorker::ws_error, &loop, &QEventLoop::quit);
63 connect( &timeoutTimer, &QTimer::timeout, &loop, &QEventLoop::quit);
64 connect( ChannelThread, &QThread::started, ChannelWsWorker, &WebSocketWorker::run);
65
66 ChannelThread->start();
67
68 timeoutTimer.start(5000);
69 loop.exec();
70
71 if (!timeoutTimer.isActive()) {
72 MessageError("Server is unreachable");
73 if (ChannelThread->isRunning()) {
74 ChannelThread->quit();
75 ChannelThread->wait();
76 }
77 delete ChannelWsWorker;
78 delete ChannelThread;
79 delete authProfile;
80 continue;
81 }
82
83 timeoutTimer.stop();
84
85 if (!ChannelWsWorker->ok) {
86 MessageError(ChannelWsWorker->message);
87 if (ChannelThread->isRunning()) {
88 ChannelThread->quit();
89 ChannelThread->wait();
90 }
91 delete ChannelWsWorker;
92 delete ChannelThread;
93 delete authProfile;
94 continue;
95 }
96
97 break;

Callers 1

mainFunction · 0.45

Calls 12

LoginMethod · 0.95
ExitMethod · 0.95
MessageErrorFunction · 0.85
execMethod · 0.80
showMaximizedMethod · 0.80
AddNewProjectMethod · 0.80
startMethod · 0.45
isActiveMethod · 0.45
isRunningMethod · 0.45
stopMethod · 0.45
setMinimumSizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected