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

Method NewProject

AdaptixClient/Source/MainAdaptix.cpp:116–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114void MainAdaptix::Exit() { QCoreApplication::quit(); }
115
116void MainAdaptix::NewProject() const
117{
118 QThread* ChannelThread = nullptr;
119 WebSocketWorker* ChannelWsWorker = nullptr;
120 AuthProfile* authProfile = nullptr;
121
122 while (true) {
123 authProfile = this->Login();
124 if (!authProfile)
125 return;
126
127 ChannelThread = new QThread;
128 ChannelWsWorker = new WebSocketWorker(authProfile);
129 ChannelWsWorker->moveToThread( ChannelThread );
130
131 QEventLoop loop;
132 QTimer timeoutTimer;
133 timeoutTimer.setSingleShot(true);
134
135 connect( ChannelWsWorker, &WebSocketWorker::connected, &loop, &QEventLoop::quit);
136 connect( ChannelWsWorker, &WebSocketWorker::ws_error, &loop, &QEventLoop::quit);
137 connect( &timeoutTimer, &QTimer::timeout, &loop, &QEventLoop::quit);
138 connect( ChannelThread, &QThread::started, ChannelWsWorker, &WebSocketWorker::run);
139
140 ChannelThread->start();
141
142 timeoutTimer.start(5000);
143 loop.exec();
144
145 if (!timeoutTimer.isActive()) {
146 MessageError("Server is unreachable");
147 if (ChannelThread->isRunning()) {
148 ChannelThread->quit();
149 ChannelThread->wait();
150 }
151
152 delete ChannelWsWorker;
153 delete ChannelThread;
154 delete authProfile;
155 continue;
156 }
157
158 timeoutTimer.stop();
159
160 if (!ChannelWsWorker->ok) {
161 MessageError(ChannelWsWorker->message);
162 if (ChannelThread->isRunning()) {
163 ChannelThread->quit();
164 ChannelThread->wait();
165 }
166 delete ChannelWsWorker;
167 delete ChannelThread;
168 delete authProfile;
169 continue;
170 }
171
172 break;
173 }

Callers 1

onNewProjectMethod · 0.80

Calls 8

LoginMethod · 0.95
MessageErrorFunction · 0.85
execMethod · 0.80
AddNewProjectMethod · 0.80
startMethod · 0.45
isActiveMethod · 0.45
isRunningMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected