Servers should always be IP Filtered, in light of the number of fake servers around.
Enabling the Filter servers too (rejects dynIP-servers) option in Options->security->IP Filter causes eMule not to add IP Filtered servers and
dynIP-servers to the server list Previous post {edit} Regardless of its state, servers in the server list are not IP Filtered,(I was under the erroneous belief that they were always filtered!!)
I think the following code changes make sense given the facts outlined above. Code changes are indicated in bold red unless change From and To are shown.
Code changes
Firstly servers should always be IP Filtered so:
IMHO IDS_FILTERSERVERBYIPFILTER should be changed from
Filter servers too (rejects dynIP-servers)
to something like
Reject all dynIP-servers
and the code change to reflect this in ServerList.cpp AddServer() thus:
From:
bool CServerList::AddServer(const CServer* pServer) said:
if (thePrefs.FilterServerByIP()){
if (pServer->HasDynIP())
return false;
if (theApp.ipfilter->IsFiltered(pServer->GetIP())){
if (thePrefs.GetLogFilteredIPs())
AddDebugLogLine(false, _T("Ignored server (IP=%s) - IP filter (%s)"), ipstr(pServer->GetIP()), theApp.ipfilter->GetLastHit());
return false;
}
}
To:
bool CServerList::AddServer(const CServer* pServer) said:
if (thePrefs.FilterServerByIP() && pServer->HasDynIP())
return false;
if (theApp.ipfilter->IsFiltered(pServer->GetIP())){
if (thePrefs.GetLogFilteredIPs())
AddDebugLogLine(false, _T("Ignored server (IP=%s) - IP filter (%s)"), ipstr(pServer->GetIP()), theApp.ipfilter->GetLastHit());
return false;
}
Then to make sure we never connect to an IP Filtered server, and delete any filtered servers as we try them*
*Additional code to always filter servers!!
In ServerSocket.cpp (Old solution fixed by SiRoB! The fix fixes this issue! found by XMan)*
void CServerSocket::ConnectToServer() said:
if (cur_server){
ASSERT(0);
delete cur_server;
cur_server = NULL;
}
//Wizard's fix. Remove the server now!
if(theApp.ipfilter->IsFiltered(server->GetIP()))
{
theApp.emuledlg->serverwnd->serverlistctrl.RemoveServer(server);
SetConnectionState(CS_ERROR); //SiRoB's Fix
return;
}
cur_server = new CServer(server);
OR XMan's Solution!*
In Socket.cpp so we can call IsFiltered()
Socket.cpp said:
In Socket.cpp
void CServerConnect::ConnectToServer(CServer* server, on bool multiconnect), said:
void CServerConnect::ConnectToServer(CServer* server, bool multiconnect)
{
if (!multiconnect) {
StopConnectionTry();
Disconnect();
}
//Xman filter outgoing server connections
//it makes no sence to allow to connect to any ipfiltered server, because you'll only get lowID
if(theApp.ipfilter->IsFiltered(server->GetIP()))
{
AddLogLine(true,_T("you can't connect to filtered server: %s, %s"),ipstr(server->GetIP()), server->GetDescription() );
if(thePrefs.FilterServerByIP())
{
theApp.emuledlg->serverwnd->serverlistctrl.RemoveServer(server);
}
return;
}
//Xman end
connecting = true;
singleconnecting = !multiconnect;
If you don't add IP Filtered servers, doesn't it also make sense to remove existing IP Filtered servers
and any servers that become IP Filtered,(after you update your IPFilter.dat)?
Remove IP Filtered servers as well as dead servers:
In ServerListCtrl.cpp so we can call IsFiltered()
ServerListCtrl.cpp said:
Remove IP Filtered servers. in ServerListCtrl.cpp RemoveAllDeadServers()
ServerListCtrl.cpp said:
void CServerListCtrl::RemoveAllDeadServers()
{
ShowWindow(SW_HIDE);
for(POSITION pos = server_list->list.GetHeadPosition(); pos != NULL; server_list->list.GetNext(pos))
{
const CServer* cur_server = server_list->list.GetAt(pos);
if(cur_server->GetFailedCount() >= thePrefs.GetDeadServerRetries() || theApp.ipfilter->IsFiltered(cur_server->GetIP()) )
{
RemoveServer(cur_server);
pos = server_list->list.GetHeadPosition();
}
}
ShowWindow(SW_SHOW);
}
ServerListCtrl.cpp and ServerList.cpp said:
if( (cur_server->GetFailedCount() >= thePrefs.GetDeadServerRetries() && (!cur_server->IsStaticMember() || !thePrefs.DontRemoveStaticServers)) || theApp.ipfilter->IsFiltered(cur_server->GetIP()))//don't remove static servers option
{
RemoveServer(cur_server);
pos = server_list->list.GetHeadPosition();
}
In ServerList.cpp void CServerList::ServerStats()
if (ping_server->GetFailedCount() >= thePrefs.GetDeadServerRetries()) {
if(!ping_server->IsStaticMember() || !thePrefs.DontRemoveStaticServers)
{
theApp.emuledlg->serverwnd->serverlistctrl.RemoveServer(ping_server);
return;
}
}
In addition to this, I believe it makes sense to show IP Filtered servers in the same way you show dead servers, as you cannot connect to them! Of course removing them on connect to a good server or *on connection attempt to a bad server. That way you get to see which servers your new IPFilter.dat has "taken out" before they are removed! Users can then see what is happening with regard to fake servers.
Show IP Filtered Server greyed out as per dead servers in ServerListCtrl.cpp OnNMCustomdraw()
ServerListCtrl.cpp said:
void CServerListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *plResult)
{
LPNMLVCUSTOMDRAW pnmlvcd = (LPNMLVCUSTOMDRAW)pNMHDR;
if (pnmlvcd->nmcd.dwDrawStage == CDDS_PREPAINT)
{
*plResult = CDRF_NOTIFYITEMDRAW;
return;
}
if (pnmlvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
{
const CServer* pServer = (const CServer*)pnmlvcd->nmcd.lItemlParam;
const CServer* pConnectedServer = theApp.serverconnect->GetCurrentServer();
// the server which we are connected to always has a valid numerical IP member assigned,
// therefore we do not need to call CServer::IsEqual (which is little expensive)
//if (pConnectedServer && pConnectedServer->IsEqual(pServer))
if (pConnectedServer && pConnectedServer->GetIP() == pServer->GetIP() && pConnectedServer->GetPort() == pServer->GetPort())
pnmlvcd->clrText = RGB(32,32,255);
else if (pServer->GetFailedCount() >= thePrefs.GetDeadServerRetries() || theApp.ipfilter->IsFiltered(pServer->GetIP()))// IP Filtered indication
pnmlvcd->clrText = RGB(192,192,192);
else if (pServer->GetFailedCount() >= 2)
pnmlvcd->clrText = RGB(128,128,128);
}
*plResult = CDRF_DODEFAULT;
}
And finally a very minor semi-related visual fix. The Load button in options->security->IP Filter should be greyed out on init and isn't in 47a
In PPgSecurity.cpp
PPgSecurity.cpp said:
void CPPgSecurity::LoadSettings(void)
{
CString strBuffer;
GetDlgItem(IDC_LOADURL)->EnableWindow(false);
Edit:to include Wizard's optimize!
Edit:*To fix my stupid oversight! Thanks Aenarion[ITA]
Edit:*Wizard's fix - Not only don't connect to an IP Filtered server but remove it from our list straight away!
Edit:*XMan & SiRoB's's fixes - For This Issue.
Edit:* Fix for "Don't remove static servers"
Done! Thank you for reading...
This post has been edited by BlueSonicBoy: 07 August 2006 - 03:13 AM