整理代码,调整参数名称,避免混淆。

pull/105/head
Apex Liu 2017-08-21 17:32:17 +08:00
parent 191d007678
commit eef2ce4460
10 changed files with 230 additions and 210 deletions

View File

@ -17,20 +17,30 @@
typedef struct TPP_CONNECT_INFO
{
char* sid;
// 与此连接信息相关的三个要素的ID
int user_id;
int host_id;
int account_id;
char* user_name; // 申请本次连接的用户名
char* real_remote_host_ip; // 真正的远程主机IP如果是直接连接模式则与remote_host_ip相同
char* remote_host_ip; // 要连接的远程主机的IP如果是端口映射模式则为路由主机的IP
int remote_host_port; // 要连接的远程主机的端口(如果是端口映射模式,则为路由主机的端口)
char* client_ip;
char* account_name; // 远程主机的账号
char* account_secret; // 远程主机账号的密码(或者私钥)
char* user_param;
int remote_host_port; // 要连接的远程主机的端口(如果是端口映射模式,则为路由主机的端口)
char* account_param;
int protocol_type;
int protocol_sub_type;
//int auth_id;
int auth_type;
int sys_type;
int ref_count; // 这个连接信息的引用计数如果创建的连接信息从来未被使用则超过60秒后自动销毁
ex_u64 ticket_start; // 此连接信息的创建时间(用于超时未使用就销毁的功能)
// int ref_count; // 这个连接信息的引用计数如果创建的连接信息从来未被使用则超过60秒后自动销毁
// ex_u64 ticket_start; // 此连接信息的创建时间(用于超时未使用就销毁的功能)
}TPP_CONNECT_INFO;
typedef TPP_CONNECT_INFO* (*TPP_GET_CONNNECT_INFO_FUNC)(const char* sid);

View File

@ -17,12 +17,11 @@ ExLogger g_ex_logger;
bool g_is_debug = false;
#define RUN_UNKNOWN 0
#define RUN_CORE 1
#define RUN_CORE 1
#define RUN_INSTALL_SRV 2
#define RUN_UNINST_SRV 3
static ex_u8 g_run_type = RUN_UNKNOWN;
#define EOM_CORE_SERVICE_NAME L"Teleport Core Service"
static bool _run_daemon(void);

View File

@ -113,7 +113,7 @@ bool TsEnv::init(bool load_config)
if (!ps->GetStr(L"web-server-rpc", tmp))
{
web_server_rpc = "http://127.0.0.1:7190/rpc";
web_server_rpc = "http://localhost:7190/rpc";
}
else
{

View File

@ -1,108 +1,102 @@
#include "ts_http_client.h"
#include <mongoose.h>
#include <ex/ex_str.h>
// #include<map>
// using namespace std;
//map<unsigned int, unsigned int> session_map;
void ts_url_encode(const char *src, ex_astr& out)
{
static const char *dont_escape = "._-$,;~()/";
static const char *hex = "0123456789abcdef";
size_t s_len = strlen(src);
size_t dst_len = s_len * 3 + 1;
char* dst = new char[dst_len];
memset(dst, 0, dst_len);
size_t i = 0, j = 0;
for (i = j = 0; dst_len > 0 && i < s_len && j + 2 < dst_len - 1; i++, j++) {
if (isalnum(*(const unsigned char *)(src + i)) ||
strchr(dont_escape, *(const unsigned char *)(src + i)) != NULL) {
dst[j] = src[i];
}
else if (j + 3 < dst_len) {
dst[j] = '%';
dst[j + 1] = hex[(*(const unsigned char *)(src + i)) >> 4];
dst[j + 2] = hex[(*(const unsigned char *)(src + i)) & 0xf];
j += 2;
}
}
dst[j] = '\0';
out = dst;
delete []dst;
}
typedef struct HTTP_DATA {
bool exit_flag;
bool have_error;
ex_astr body;
}HTTP_DATA;
//int s_exit_flag = 0;
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data)
{
HTTP_DATA* hdata = (HTTP_DATA*)nc->user_data;
struct http_message *hm = (struct http_message *) ev_data;
switch (ev) {
case MG_EV_CONNECT:
if (*(int *)ev_data != 0) {
hdata->exit_flag = true;
hdata->have_error = true;
}
break;
case MG_EV_HTTP_REPLY:
nc->flags |= MG_F_CLOSE_IMMEDIATELY;
hdata->exit_flag = true;
hdata->body.assign(hm->body.p, hm->body.len);
break;
case MG_EV_CLOSE:
// if (s_exit_flag == 0) {
// printf("Server closed connection\n");
// s_exit_flag = 1;
// }
hdata->exit_flag = true;
break;
default:
break;
}
}
bool ts_http_get(const ex_astr& url, ex_astr& body)
{
struct mg_mgr mgr;
mg_mgr_init(&mgr, NULL);
mg_connection* nc = mg_connect_http(&mgr, ev_handler, url.c_str(), NULL, NULL);
if (NULL == nc)
return false;
HTTP_DATA* hdata = new HTTP_DATA;
hdata->exit_flag = false;
hdata->have_error = false;
nc->user_data = hdata;
// int count = 0;
while (!hdata->exit_flag)
{
mg_mgr_poll(&mgr, 100);
// count++;
// if (count > 2)
// break;
}
bool ret = !hdata->have_error;
if (ret)
body = hdata->body;
delete hdata;
mg_mgr_free(&mgr);
return ret;
}
#include "ts_http_client.h"
#include <mongoose.h>
#include <ex/ex_str.h>
void ts_url_encode(const char *src, ex_astr& out)
{
static const char *dont_escape = "._-$,;~()/";
static const char *hex = "0123456789abcdef";
size_t s_len = strlen(src);
size_t dst_len = s_len * 3 + 1;
char* dst = new char[dst_len];
memset(dst, 0, dst_len);
size_t i = 0, j = 0;
for (i = j = 0; dst_len > 0 && i < s_len && j + 2 < dst_len - 1; i++, j++) {
if (isalnum(*(const unsigned char *)(src + i)) ||
strchr(dont_escape, *(const unsigned char *)(src + i)) != NULL) {
dst[j] = src[i];
}
else if (j + 3 < dst_len) {
dst[j] = '%';
dst[j + 1] = hex[(*(const unsigned char *)(src + i)) >> 4];
dst[j + 2] = hex[(*(const unsigned char *)(src + i)) & 0xf];
j += 2;
}
}
dst[j] = '\0';
out = dst;
delete []dst;
}
typedef struct HTTP_DATA {
bool exit_flag;
bool have_error;
ex_astr body;
}HTTP_DATA;
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data)
{
HTTP_DATA* hdata = (HTTP_DATA*)nc->user_data;
struct http_message *hm = (struct http_message *) ev_data;
switch (ev) {
case MG_EV_CONNECT:
if (*(int *)ev_data != 0) {
hdata->exit_flag = true;
hdata->have_error = true;
}
break;
case MG_EV_HTTP_REPLY:
nc->flags |= MG_F_CLOSE_IMMEDIATELY;
hdata->exit_flag = true;
hdata->body.assign(hm->body.p, hm->body.len);
break;
case MG_EV_CLOSE:
// if (s_exit_flag == 0) {
// printf("Server closed connection\n");
// s_exit_flag = 1;
// }
hdata->exit_flag = true;
break;
default:
break;
}
}
bool ts_http_get(const ex_astr& url, ex_astr& body)
{
struct mg_mgr mgr;
mg_mgr_init(&mgr, NULL);
mg_connection* nc = mg_connect_http(&mgr, ev_handler, url.c_str(), NULL, NULL);
if (NULL == nc)
return false;
HTTP_DATA* hdata = new HTTP_DATA;
hdata->exit_flag = false;
hdata->have_error = false;
nc->user_data = hdata;
// int count = 0;
while (!hdata->exit_flag)
{
mg_mgr_poll(&mgr, 100);
// count++;
// if (count > 2)
// break;
}
bool ret = !hdata->have_error;
if (ret)
body = hdata->body;
delete hdata;
mg_mgr_free(&mgr);
return ret;
}

View File

@ -9,42 +9,45 @@
bool g_exit_flag = false;
TPP_CONNECT_INFO* tpp_get_session(const char* sid)
TPP_CONNECT_INFO* tpp_get_connect_info(const char* sid)
{
TS_SESSION_INFO sinfo;
bool ret = g_session_mgr.take_session(sid, sinfo);
TS_CONNECT_INFO sinfo;
bool ret = g_session_mgr.get_connect_info(sid, sinfo);
if (!ret)
return NULL;
TPP_CONNECT_INFO* info = (TPP_CONNECT_INFO*)calloc(1, sizeof(TPP_CONNECT_INFO));
info->sid = (char*)calloc(1, sinfo.sid.length() + 1);
ex_strcpy(info->sid, sinfo.sid.length() + 1, sinfo.sid.c_str());
info->account_name = (char*)calloc(1, sinfo.account_name.length() + 1);
ex_strcpy(info->account_name, sinfo.account_name.length() + 1, sinfo.account_name.c_str());
info->real_remote_host_ip = (char*)calloc(1, sinfo.host_ip.length() + 1);
ex_strcpy(info->real_remote_host_ip, sinfo.host_ip.length() + 1, sinfo.host_ip.c_str());
info->remote_host_ip = (char*)calloc(1, sinfo.host_ip.length() + 1);
ex_strcpy(info->remote_host_ip, sinfo.host_ip.length() + 1, sinfo.host_ip.c_str());
info->user_name = (char*)calloc(1, sinfo.user_name.length() + 1);
ex_strcpy(info->user_name, sinfo.user_name.length() + 1, sinfo.user_name.c_str());
info->account_secret = (char*)calloc(1, sinfo.user_auth.length() + 1);
ex_strcpy(info->account_secret, sinfo.user_auth.length() + 1, sinfo.user_auth.c_str());
info->user_param = (char*)calloc(1, sinfo.user_param.length() + 1);
ex_strcpy(info->user_param, sinfo.user_param.length() + 1, sinfo.user_param.c_str());
info->real_remote_host_ip = (char*)calloc(1, sinfo.real_remote_host_ip.length() + 1);
ex_strcpy(info->real_remote_host_ip, sinfo.real_remote_host_ip.length() + 1, sinfo.real_remote_host_ip.c_str());
info->remote_host_ip = (char*)calloc(1, sinfo.remote_host_ip.length() + 1);
ex_strcpy(info->remote_host_ip, sinfo.remote_host_ip.length() + 1, sinfo.remote_host_ip.c_str());
info->client_ip = (char*)calloc(1, sinfo.client_ip.length() + 1);
ex_strcpy(info->client_ip, sinfo.client_ip.length() + 1, sinfo.client_ip.c_str());
info->account_name = (char*)calloc(1, sinfo.account_name.length() + 1);
ex_strcpy(info->account_name, sinfo.account_name.length() + 1, sinfo.account_name.c_str());
info->account_secret = (char*)calloc(1, sinfo.account_secret.length() + 1);
ex_strcpy(info->account_secret, sinfo.account_secret.length() + 1, sinfo.account_secret.c_str());
info->account_param = (char*)calloc(1, sinfo.account_param.length() + 1);
ex_strcpy(info->account_param, sinfo.account_param.length() + 1, sinfo.account_param.c_str());
//info->auth_id = sinfo.auth_id;
info->remote_host_port = sinfo.host_port;
info->protocol_type = sinfo.protocol;
info->auth_type= sinfo.auth_mode;
info->user_id = sinfo.user_id;
info->host_id = sinfo.host_id;
info->account_id = sinfo.account_id;
info->remote_host_port = sinfo.remote_host_port;
info->protocol_type = sinfo.protocol_type;
info->protocol_sub_type = sinfo.protocol_sub_type;
info->auth_type= sinfo.auth_type;
info->sys_type = sinfo.sys_type;
info->ref_count = sinfo.ref_count;
info->ticket_start = sinfo.ticket_start;
return info;
}
void tpp_free_session(TPP_CONNECT_INFO* info)
void tpp_free_connect_info(TPP_CONNECT_INFO* info)
{
if (NULL == info)
return;
@ -53,9 +56,10 @@ void tpp_free_session(TPP_CONNECT_INFO* info)
free(info->user_name);
free(info->real_remote_host_ip);
free(info->remote_host_ip);
free(info->client_ip);
free(info->account_name);
free(info->account_secret);
free(info->user_param);
free(info->account_param);
free(info);
}
@ -64,20 +68,19 @@ bool tpp_session_begin(const TPP_CONNECT_INFO* info, int* db_id)
if (NULL == info || NULL == db_id)
return false;
TS_SESSION_INFO sinfo;
TS_CONNECT_INFO sinfo;
sinfo.sid = info->sid;
sinfo.account_name = info->account_name;
sinfo.auth_id = info->auth_id;
sinfo.host_ip = info->host_ip;
sinfo.host_port = info->host_port;
sinfo.protocol = info->protocol;
sinfo.user_name = info->user_name;
sinfo.user_auth = info->user_auth;
sinfo.user_param = info->user_param;
sinfo.auth_mode = info->auth_mode;
sinfo.real_remote_host_ip = info->real_remote_host_ip;
sinfo.remote_host_ip = info->remote_host_ip;
sinfo.client_ip = info->client_ip;
sinfo.account_name = info->account_name;
sinfo.remote_host_port = info->remote_host_port;
sinfo.protocol_type = info->protocol_type;
sinfo.protocol_sub_type = info->protocol_sub_type;
sinfo.auth_type = info->auth_type;
sinfo.sys_type = info->sys_type;
sinfo.ref_count = info->ref_count;
sinfo.ticket_start = info->ticket_start;
return ts_web_rpc_session_begin(sinfo, *db_id);
}
@ -184,8 +187,8 @@ bool TppManager::load_tpp(const ex_wstr& libname)
init_args.etc_path = g_env.m_etc_path;
init_args.replay_path = g_env.m_replay_path;
init_args.cfg = &g_env.get_ini();
init_args.func_take_session = tpp_take_session;
init_args.func_free_session = tpp_free_session;
init_args.func_get_connect_info = tpp_get_connect_info;
init_args.func_free_connect_info = tpp_free_connect_info;
init_args.func_session_begin = tpp_session_begin;
init_args.func_session_end = tpp_session_end;

View File

@ -13,12 +13,12 @@ TsSessionManager::TsSessionManager() :
TsSessionManager::~TsSessionManager()
{
ts_sessiones::iterator it = m_sessions.begin();
for (; it != m_sessions.end(); ++it)
ts_connections::iterator it_conn = m_connections.begin();
for (; it_conn != m_connections.end(); ++it_conn)
{
delete it->second;
delete it_conn->second;
}
m_sessions.clear();
m_connections.clear();
}
void TsSessionManager::_thread_loop(void)
@ -28,7 +28,7 @@ void TsSessionManager::_thread_loop(void)
ex_sleep_ms(1000);
if (m_stop_flag)
return;
_check_sessions();
_check_connect_info();
}
}
@ -38,25 +38,25 @@ void TsSessionManager::_set_stop_flag(void)
}
void TsSessionManager::_check_sessions(void)
void TsSessionManager::_check_connect_info(void)
{
// 超过10秒未进行连接的session-id会被移除
// 超过30秒未进行连接的connect-info会被移除
ExThreadSmartLock locker(m_lock);
ex_u64 _now = ex_get_tick_count();
ts_sessiones::iterator it = m_sessions.begin();
for (; it != m_sessions.end(); )
ts_connections::iterator it = m_connections.begin();
for (; it != m_connections.end(); )
{
#ifdef EX_DEBUG
if (_now - it->second->ticket_start >= 60*1000*60)
if (it->second->ref_count == 0 && _now - it->second->ticket_start >= 60*1000*60)
#else
if (_now - it->second->ticket_start >= 10000)
if (it->second->ref_count == 0 && _now - it->second->ticket_start >= 30000)
#endif
{
EXLOGV("[core] remove session: %s\n", it->first.c_str());
EXLOGV("[core] remove connection info: %s\n", it->first.c_str());
delete it->second;
m_sessions.erase(it++);
m_connections.erase(it++);
}
else
{
@ -98,19 +98,19 @@ ex_rv TsSessionManager::request_session(
EXLOGD("[core] request session: user-name: [%s], protocol: [%d], auth-mode: [%d]\n", info->user_name.c_str(), info->protocol, info->auth_mode);
if (_add_session(sid, info))
if (_add_connect_info(sid, info))
return EXRV_OK;
delete info;
return EXRV_FAILED;
}
bool TsSessionManager::get_session(const ex_astr& sid, TS_SESSION_INFO& info)
bool TsSessionManager::get_connect_info(const ex_astr& sid, TS_CONNECT_INFO& info)
{
ExThreadSmartLock locker(m_lock);
ts_sessiones::iterator it = m_sessions.find(sid);
if (it == m_sessions.end())
ts_connections::iterator it = m_connections.find(sid);
if (it == m_connections.end())
return false;
info.sid = it->second->sid;
@ -139,18 +139,18 @@ bool TsSessionManager::get_session(const ex_astr& sid, TS_SESSION_INFO& info)
return true;
}
bool TsSessionManager::_add_session(ex_astr& sid, TS_SESSION_INFO* info)
bool TsSessionManager::_add_connect_info(ex_astr& sid, TS_CONNECT_INFO* info)
{
ExThreadSmartLock locker(m_lock);
ex_astr _sid;
int retried = 0;
ts_sessiones::iterator it;
ts_connections::iterator it;
for (;;)
{
_gen_session_id(_sid, info, 6);
it = m_sessions.find(_sid);
if (it == m_sessions.end())
it = m_connections.find(_sid);
if (it == m_connections.end())
break;
retried++;
@ -159,20 +159,20 @@ bool TsSessionManager::_add_session(ex_astr& sid, TS_SESSION_INFO* info)
}
info->sid = _sid;
m_sessions.insert(std::make_pair(_sid, info));
m_connections.insert(std::make_pair(_sid, info));
sid = _sid;
if (info->protocol == 1)
if (info->protocol_type == TP_PROTOCOL_TYPE_RDP)
{
char szTmp[8] = { 0 };
snprintf(szTmp, 8, "%02X", (unsigned char)(info->user_name.length() + info->user_auth.length()));
snprintf(szTmp, 8, "%02X", (unsigned char)(info->account_name.length() + info->account_secret.length()));
sid += szTmp;
}
return true;
}
void TsSessionManager::_gen_session_id(ex_astr& sid, const TS_SESSION_INFO* info, int len)
void TsSessionManager::_gen_session_id(ex_astr& sid, const TS_CONNECT_INFO* info, int len)
{
mbedtls_sha1_context sha;
ex_u8 sha_digist[20] = { 0 };
@ -184,8 +184,9 @@ void TsSessionManager::_gen_session_id(ex_astr& sid, const TS_SESSION_INFO* info
mbedtls_sha1_starts(&sha);
mbedtls_sha1_update(&sha, (const unsigned char*)&_tick, sizeof(ex_u64));
mbedtls_sha1_update(&sha, (const unsigned char*)&_tid, sizeof(ex_u64));
mbedtls_sha1_update(&sha, (const unsigned char*)info->host_ip.c_str(), info->host_ip.length());
mbedtls_sha1_update(&sha, (const unsigned char*)info->user_name.c_str(), info->user_name.length());
mbedtls_sha1_update(&sha, (const unsigned char*)info->remote_host_ip.c_str(), info->remote_host_ip.length());
mbedtls_sha1_update(&sha, (const unsigned char*)info->client_ip.c_str(), info->client_ip.length());
mbedtls_sha1_update(&sha, (const unsigned char*)info->account_name.c_str(), info->account_name.length());
mbedtls_sha1_finish(&sha, sha_digist);
mbedtls_sha1_free(&sha);

View File

@ -6,26 +6,36 @@
#include <ex.h>
typedef struct TS_SESSION_INFO
typedef struct TS_CONNECT_INFO
{
ex_astr sid;
ex_astr account_name; // ÉêÇë±¾´ÎÁ¬½ÓµÄÓû§Ãû
//int auth_id;
ex_astr host_ip;
int host_port;
int protocol;
ex_astr user_name;
ex_astr user_auth;
ex_astr user_param;
int auth_mode;
// 与此连接信息相关的三个要素的ID
int user_id;
int host_id;
int account_id;
ex_astr user_name;// 申请本次连接的用户名
ex_astr real_remote_host_ip;// 真正的远程主机IP如果是直接连接模式则与remote_host_ip相同
ex_astr remote_host_ip;// 要连接的远程主机的IP如果是端口映射模式则为路由主机的IP
int remote_host_port;// 要连接的远程主机的端口(如果是端口映射模式,则为路由主机的端口)
ex_astr client_ip;
ex_astr account_name; // 远程主机的账号
ex_astr account_secret;// 远程主机账号的密码(或者私钥)
ex_astr account_param;
int protocol_type;
int protocol_sub_type;
int auth_type;
int sys_type;
int ref_count;// 这个连接信息的引用计数如果创建的连接信息从来未被使用则超过30秒后自动销毁
ex_u64 ticket_start;// 此连接信息的创建时间(用于超时未使用就销毁的功能)
}TS_CONNECT_INFO;
int ref_count;
ex_u64 ticket_start;
}TS_SESSION_INFO;
typedef std::map<ex_astr, TS_SESSION_INFO*> ts_sessiones;
typedef std::map<ex_astr, TS_CONNECT_INFO*> ts_connections;
class TsSessionManager : public ExThreadBase
{
@ -49,7 +59,7 @@ public:
);
// 根据sid得到session信息
bool get_session(const ex_astr& sid, TS_SESSION_INFO& info);
bool get_connect_info(const ex_astr& sid, TS_CONNECT_INFO& info);
protected:
// 线程循环
@ -58,13 +68,13 @@ protected:
void _set_stop_flag(void);
private:
bool _add_session(ex_astr& sid, TS_SESSION_INFO* info);
void _gen_session_id(ex_astr& sid, const TS_SESSION_INFO* info, int len);
void _check_sessions(void);
void _gen_session_id(ex_astr& sid, const TS_CONNECT_INFO* info, int len);
bool _add_connect_info(ex_astr& sid, TS_CONNECT_INFO* info);
void _check_connect_info(void);
private:
ExThreadLock m_lock;
ts_sessiones m_sessions;
ts_connections m_connections;
};
extern TsSessionManager g_session_mgr;

View File

@ -92,20 +92,23 @@ int ts_web_rpc_get_conn_info(int conn_id, Json::Value& jret)
return TPE_OK;
}
bool ts_web_rpc_session_begin(TS_SESSION_INFO& info, int& record_id)
bool ts_web_rpc_session_begin(TS_CONNECT_INFO& info, int& record_id)
{
Json::FastWriter json_writer;
Json::Value jreq;
jreq["method"] = "session_begin";
jreq["param"]["sid"] = info.sid.c_str();
jreq["param"]["account_name"] = info.account_name.c_str();
jreq["param"]["host_ip"] = info.host_ip.c_str();
jreq["param"]["sys_type"] = info.sys_type;
jreq["param"]["host_port"] = info.host_port;
jreq["param"]["auth_mode"] = info.auth_mode,
jreq["param"]["user_name"] = info.user_name.c_str();
jreq["param"]["protocol"] = info.protocol;
jreq["param"]["account_name"] = info.account_name.c_str();
jreq["param"]["real_remote_host_ip"] = info.real_remote_host_ip.c_str();
jreq["param"]["remote_host_ip"] = info.remote_host_ip.c_str();
jreq["param"]["client_ip"] = info.client_ip.c_str();
jreq["param"]["sys_type"] = info.sys_type;
jreq["param"]["remote_host_port"] = info.remote_host_port;
jreq["param"]["auth_type"] = info.auth_type;
jreq["param"]["protocol_type"] = info.protocol_type;
jreq["param"]["protocol_sub_type"] = info.protocol_sub_type;
ex_astr json_param;
json_param = json_writer.write(jreq);

View File

@ -12,7 +12,7 @@ bool ts_web_rpc_register_core();
int ts_web_rpc_get_conn_info(int conn_id, Json::Value& jret);
// 记录会话的开始
bool ts_web_rpc_session_begin(TS_SESSION_INFO& info, int& record_id);
bool ts_web_rpc_session_begin(TS_CONNECT_INFO& info, int& record_id);
//session 结束
bool ts_web_rpc_session_end(const char* sid, int id, int ret_code);

View File

@ -228,7 +228,7 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
EXLOGV("[ssh] authenticating, session-id: %s\n", _this->m_sid.c_str());
int protocol = 0;
TPP_CONNECT_INFO* sess_info = g_ssh_env.get_session(_this->m_sid.c_str());
TPP_CONNECT_INFO* sess_info = g_ssh_env.get_connect_info(_this->m_sid.c_str());
if (NULL == sess_info) {
// EXLOGW("[ssh] try to get login-info from ssh-sftp-session.\n");
@ -261,7 +261,7 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
}
if (protocol != TP_PROTOCOL_TYPE_SSH) {
g_ssh_env.free_session(sess_info);
g_ssh_env.free_connect_info(sess_info);
EXLOGE("[ssh] session '%s' is not for SSH.\n", _this->m_sid.c_str());
_this->m_have_error = true;
_this->m_retcode = TP_SESS_STAT_ERR_AUTH_DENIED;
@ -270,13 +270,13 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
if (!_this->_on_session_begin(sess_info))
{
g_ssh_env.free_session(sess_info);
g_ssh_env.free_connect_info(sess_info);
_this->m_have_error = true;
_this->m_retcode = TP_SESS_STAT_ERR_AUTH_DENIED;
return SSH_AUTH_DENIED;
}
g_ssh_env.free_session(sess_info);
g_ssh_env.free_connect_info(sess_info);
sess_info = NULL;
// 现在尝试根据session-id获取得到的信息连接并登录真正的SSH服务器