diff --git a/client/tp_assist_macos/src/csrc/ts_http_rpc.cpp b/client/tp_assist_macos/src/csrc/ts_http_rpc.cpp index 65220e2..df8706f 100644 --- a/client/tp_assist_macos/src/csrc/ts_http_rpc.cpp +++ b/client/tp_assist_macos/src/csrc/ts_http_rpc.cpp @@ -609,7 +609,7 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf) // SSH //============================================== - if (pro_sub == TP_PROTOCOL_SUB_TYPE_SSH) + if (pro_sub == TP_PROTOCOL_TYPE_SSH_SHELL) { char szCmd[1024] = {0}; ex_strformat(szCmd, 1023, "ssh %s@%s -p %d", sid.c_str(), teleport_ip.c_str(), teleport_port); diff --git a/server/tp_core/core/ts_main.cpp b/server/tp_core/core/ts_main.cpp index 686dc6d..15af5d2 100644 --- a/server/tp_core/core/ts_main.cpp +++ b/server/tp_core/core/ts_main.cpp @@ -85,7 +85,6 @@ bool tpp_session_begin(const TPP_CONNECT_INFO* info, int* db_id) sinfo.conn_port = info->conn_port; sinfo.protocol_type = info->protocol_type; sinfo.protocol_sub_type = info->protocol_sub_type; - //sinfo.protocol_flag = info->protocol_flag; sinfo.auth_type = info->auth_type; return ts_web_rpc_session_begin(sinfo, *db_id); diff --git a/server/tp_core/core/ts_session.h b/server/tp_core/core/ts_session.h index efc9040..8d39af5 100644 --- a/server/tp_core/core/ts_session.h +++ b/server/tp_core/core/ts_session.h @@ -8,6 +8,9 @@ typedef struct TS_CONNECT_INFO { + // TODO: + //TPP_CONNECT_INFO conn; + ex_astr sid; // 与此连接信息相关的三个要素的ID @@ -36,7 +39,7 @@ typedef struct TS_CONNECT_INFO ex_u64 ticket_start;// 此连接信息的创建时间(用于超时未使用就销毁的功能) }TS_CONNECT_INFO; -typedef std::map ts_connections; +typedef std::map ts_connections; // sid -> TS_CONNECT_INFO class TsSessionManager : public ExThreadBase { @@ -44,8 +47,21 @@ public: TsSessionManager(); ~TsSessionManager(); + // generate a sid for connection info. bool request_session(ex_astr& sid, TS_CONNECT_INFO* info); + // +ref for connection-info. + bool session_connect(const ex_astr& sid, TPP_CONNECT_INFO** info); + + // free connection-info created by session_connect(). + bool free_connect_info(TPP_CONNECT_INFO* info); + + // -ref for connecton-info, and release it when ref is 0. + bool session_end(const ex_astr& sid); + + // TODO: + void timer(); + // 根据sid得到session信息 bool get_connect_info(const ex_astr& sid, TS_CONNECT_INFO& info); diff --git a/server/tp_core/protocol/ssh/ssh_proxy.cpp b/server/tp_core/protocol/ssh/ssh_proxy.cpp index 3bb731e..789080e 100644 --- a/server/tp_core/protocol/ssh/ssh_proxy.cpp +++ b/server/tp_core/protocol/ssh/ssh_proxy.cpp @@ -25,7 +25,7 @@ SshProxy::~SshProxy() m_sftp_sessions.clear(); } -bool SshProxy::init(void) +bool SshProxy::init() { m_host_ip = g_ssh_env.bind_ip; m_host_port = g_ssh_env.bind_port; @@ -69,9 +69,8 @@ bool SshProxy::init(void) return true; } -void SshProxy::timer(void) { +void SshProxy::timer() { // be called per one second. - // EXLOGV("[ssh] on-timer.\n"); m_timer_counter++; if(m_timer_counter < 5) return; @@ -86,14 +85,14 @@ void SshProxy::timer(void) { } } -void SshProxy::_thread_loop(void) +void SshProxy::_thread_loop() { EXLOGV("[ssh] TeleportServer-SSH ready on %s:%d\n", m_host_ip.c_str(), m_host_port); _run(); EXLOGV("[ssh] main-loop end.\n"); } -void SshProxy::_set_stop_flag(void) +void SshProxy::_set_stop_flag() { m_stop_flag = true; @@ -108,8 +107,8 @@ void SshProxy::_set_stop_flag(void) ssh_options_set(_session, SSH_OPTIONS_HOST, host_ip.c_str()); ssh_options_set(_session, SSH_OPTIONS_PORT, &m_host_port); - int _timeout_us = 100000; - ssh_options_set(_session, SSH_OPTIONS_TIMEOUT_USEC, &_timeout_us); + int _timeout_us = 10; + ssh_options_set(_session, SSH_OPTIONS_TIMEOUT, &_timeout_us); ssh_connect(_session); ssh_free(_session); } @@ -117,7 +116,7 @@ void SshProxy::_set_stop_flag(void) m_thread_mgr.stop_all(); } -void SshProxy::_run(void) +void SshProxy::_run() { for (;;) { @@ -172,7 +171,7 @@ void SshProxy::_run(void) m_thread_mgr.stop_all(); } -void SshProxy::_dump_sftp_sessions(void) +void SshProxy::_dump_sftp_sessions() { ts_sftp_sessions::iterator it = m_sftp_sessions.begin(); for (; it != m_sftp_sessions.end(); ++it) diff --git a/server/tp_core/protocol/ssh/ssh_proxy.h b/server/tp_core/protocol/ssh/ssh_proxy.h index 3452bb7..5d0cff0 100644 --- a/server/tp_core/protocol/ssh/ssh_proxy.h +++ b/server/tp_core/protocol/ssh/ssh_proxy.h @@ -25,8 +25,8 @@ public: SshProxy(); ~SshProxy(); - bool init(void); - void timer(void); + bool init(); + void timer(); void add_sftp_session_info( const ex_astr& sid, @@ -42,13 +42,13 @@ public: void session_finished(SshSession* sess); protected: - void _thread_loop(void); - void _set_stop_flag(void); + void _thread_loop(); + void _set_stop_flag(); - void _run(void); + void _run(); private: - void _dump_sftp_sessions(void); + void _dump_sftp_sessions(); private: ssh_bind m_bind;