SVCS - Русская документация
Загрузка...
Поиск...
Не найдено
SSHServer.hxx
См. документацию.
1
15
16#pragma once
17
18#include "SSHConfig.hxx"
19#include "SSHSession.hxx"
23
24#include <cstring>
25#include <memory>
26#include <string>
27#include <atomic>
28#include <thread>
29#include <vector>
30#include <mutex>
31
32namespace svcs::server::ssh {
33
34/**
35 * @english
36 * @class SSHServer
37 * @brief Main SSH server class
38 * @details Manages SSH connections and executes repository operations
39 *
40 * @russian
41 * @class SSHServer
42 * @brief Основной класс SSH сервера
43 * @details Управляет SSH соединениями и выполняет операции с репозиториями
44 */
45class SSHServer {
46public:
60 SSHServer(const SSHConfig& config,
61 std::shared_ptr<svcs::core::RepositoryManager> repo_manager,
62 std::shared_ptr<svcs::services::ISubject> event_bus);
63
71 ~SSHServer();
72
73 SSHServer(const SSHServer&) = delete;
74 SSHServer& operator=(const SSHServer&) = delete;
75
85 bool start();
86
94 void stop();
95
105 bool isRunning() const { return running_; }
106
115
116 size_t getActiveConnections() const;
117
129 void addUserKey(const std::string& username,
130 const std::string& public_key);
131
143 void setUserPassword(const std::string& username,
144 const std::string& password);
145
146private:
147 void run();
148 void handleClient(svcs::platform::SocketHandle client_fd);
149 bool initializeSSH();
150 void cleanup();
151 void logEvent(const std::string& message, bool is_error = false) const;
152 bool handleSVCSCommand(const std::string& command, ssh_channel channel);
153
154 SSHConfig config_;
155 std::shared_ptr<svcs::core::RepositoryManager> repo_manager_;
156 std::shared_ptr<svcs::services::ISubject> event_bus_;
157
158 std::atomic<bool> running_{false};
159 std::thread server_thread_;
160
161 svcs::platform::SocketHandle server_socket_ = INVALID_SOCKET_HANDLE;
162 ssh_bind ssh_bind_ = nullptr;
163
164 mutable std::mutex connections_mutex_;
165 std::vector<std::thread> client_threads_;
166 std::atomic<size_t> active_connections_{0};
167};
168
169}
Определяет интерфейс для компонента Subject (Издатель) шаблона Observer.
Cross-platform network utilities.
Declaration of the RepositoryManager class, managing all repository-level file operations.
Конфигурация SSH сервера
Обработчик SSH сессии
void setUserPassword(const std::string &username, const std::string &password)
Устанавливает пароль для пользователя
Определения SSHServer.cxx:278
void stop()
Останавливает сервер
Определения SSHServer.cxx:240
~SSHServer()
Деструктор
Определения SSHServer.cxx:203
SSHServer(const SSHConfig &config, std::shared_ptr< svcs::core::RepositoryManager > repo_manager, std::shared_ptr< svcs::services::ISubject > event_bus)
Конструктор
void addUserKey(const std::string &username, const std::string &public_key)
Добавляет публичный ключ для пользователя
Определения SSHServer.cxx:268
bool isRunning() const
Проверяет работу
Определения SSHServer.hxx:69
size_t getActiveConnections() const
Получает активные соединения
Определения SSHServer.cxx:264
bool start()
Запускает сервер
Определения SSHServer.cxx:207
Конфигурация SSH сервера
Определения SSHConfig.hxx:21