助手使用原生RDP客户端,并解决使用原生RDP客户端两次连接的问题。但是目前无法连接,会认证失败。下一步需要重构数据包解析的模块。

pull/105/head
Apex Liu 2017-11-27 03:12:41 +08:00
parent 507ef71766
commit 9034daf0f3
2 changed files with 27 additions and 15 deletions

View File

@ -44,9 +44,9 @@ End Sub
ubuntuLinuxSecureCRT
*/
// #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

View File

@ -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;