mirror of https://github.com/tp4a/teleport
助手使用原生RDP客户端,并解决使用原生RDP客户端两次连接的问题。但是目前无法连接,会认证失败。下一步需要重构数据包解析的模块。
parent
507ef71766
commit
9034daf0f3
|
@ -44,9 +44,9 @@ End Sub
|
|||
手工测试了,ubuntu服务器可以,不知道是否能够支持所有的Linux。SecureCRT对此表示忽略。
|
||||
*/
|
||||
|
||||
// #define RDP_CLIENT_SYSTEM_BUILTIN
|
||||
#define RDP_CLIENT_SYSTEM_BUILTIN
|
||||
// #define RDP_CLIENT_SYSTEM_ACTIVE_CONTROL
|
||||
#define RDP_CLIENT_FREERDP
|
||||
//#define RDP_CLIENT_FREERDP
|
||||
|
||||
|
||||
#ifdef RDP_CLIENT_SYSTEM_BUILTIN
|
||||
|
|
|
@ -49,7 +49,7 @@ void TsSessionManager::_remove_expired_connect_info(void)
|
|||
for (; it != m_connections.end(); )
|
||||
{
|
||||
//EXLOGD("[core] check expired connect info: [%s] %d, %d %d %d\n", it->first.c_str(), it->second->ref_count, int(_now), int(it->second->ticket_start), int(_now - it->second->ticket_start));
|
||||
if (it->second->ref_count == 0 && _now - it->second->ticket_start > 15000)
|
||||
if (it->second->ref_count == 0 && _now - 15000 > it->second->ticket_start)
|
||||
{
|
||||
EXLOGD("[core] remove connection info, because timeout: %s\n", it->first.c_str());
|
||||
delete it->second;
|
||||
|
@ -94,23 +94,34 @@ bool TsSessionManager::get_connect_info(const ex_astr& sid, TS_CONNECT_INFO& inf
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TsSessionManager::free_connect_info(const ex_astr& sid) {
|
||||
bool TsSessionManager::free_connect_info(const ex_astr& sid) {
|
||||
ExThreadSmartLock locker(m_lock);
|
||||
|
||||
ts_connections::iterator it = m_connections.find(sid);
|
||||
if (it == m_connections.end())
|
||||
return false;
|
||||
|
||||
it->second->ref_count--;
|
||||
if (it->second->ref_count <= 0) {
|
||||
EXLOGD("[core] remove connection info, because all connections closed: %s\n", it->first.c_str());
|
||||
delete it->second;
|
||||
m_connections.erase(it);
|
||||
EXLOGD("[core] there are %d connection info exists.\n", m_connections.size());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
it->second->ref_count--;
|
||||
|
||||
// 对于RDP来说,此时不要移除连接信息,系统自带RDP客户端在第一次连接时进行协议协商,然后马上会断开,之后立即重新连接一次(第二次连接之前可能会提示证书信息,如果用户长时间不操作,可能会导致超时)。
|
||||
// 因此,我们将其引用计数减低,并更新一下最后访问时间,让定时器来移除它。
|
||||
if (it->second->protocol_type != TP_PROTOCOL_TYPE_RDP) {
|
||||
if (it->second->ref_count <= 0) {
|
||||
EXLOGD("[core] remove connection info, because all connections closed: %s\n", it->first.c_str());
|
||||
delete it->second;
|
||||
m_connections.erase(it);
|
||||
EXLOGD("[core] there are %d connection info exists.\n", m_connections.size());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (it->second->ref_count == 1)
|
||||
it->second->ref_count = 0;
|
||||
it->second->ticket_start = ex_get_tick_count() + 45000; // 我们将时间向后移动45秒,这样如果没有发生RDP的第二次连接,这个连接信息就会在一分钟后被清除。
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TsSessionManager::request_session(ex_astr& sid, TS_CONNECT_INFO* info)
|
||||
{
|
||||
|
@ -141,6 +152,7 @@ bool TsSessionManager::request_session(ex_astr& sid, TS_CONNECT_INFO* info)
|
|||
sid = _sid;
|
||||
if (info->protocol_type == TP_PROTOCOL_TYPE_RDP)
|
||||
{
|
||||
info->ref_count = 1; // 因为RDP连接之前可能会有很长时间用于确认是否连接、是否信任证书,所以很容易超时,我们认为将引用计数+1,防止因超时被清除。
|
||||
char szTmp[8] = { 0 };
|
||||
snprintf(szTmp, 8, "%02X", (unsigned char)(info->acc_username.length() + info->acc_secret.length()));
|
||||
sid += szTmp;
|
||||
|
|
Loading…
Reference in New Issue