MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / onFilter

Method onFilter

Plugins/FtpServer/BackendFtpServer.cpp:116–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116bool CBackendFtpServer::onFilter(QSslSocket *socket)
117{
118 bool bFilte = false;
119 if(!socket) return true;
120 QString szIP = socket->peerAddress().toString();
121
122 QStringList white = m_Para->GetWhitelist();
123 QStringList black = m_Para->GetBlacklist();
124 bool bInWhite = false;
125 if(!white.isEmpty()) {
126 foreach(auto i, white) {
127 QHostAddress addr(szIP);
128 auto sub = QHostAddress::parseSubnet(i);
129 if(addr.isInSubnet(sub.first, sub.second)) {
130 bInWhite = true;
131 break;
132 }
133 }
134 }
135
136 if(!bInWhite && !black.isEmpty()) {
137 foreach(auto i, black) {
138 QHostAddress addr(szIP);
139 auto sub = QHostAddress::parseSubnet(i);
140 if(addr.isInSubnet(sub.first, sub.second)) {
141 qInfo(log) << "Filet" << szIP << "in blacklist";
142 return true;
143 }
144 }
145 }
146
147 if(bFilte) return true;
148
149 if(m_Para->GetConnectCount() >= 0 && m_Para->GetConnectCount() <= m_Sockets.size()) {
150 qDebug(log) << "Exceeded the allowed number of connections:" << m_Para->GetConnectCount();
151 return true;
152 }
153
154 bool check = false;
155 check = connect(socket, SIGNAL(disconnected()),
156 this, SLOT(slotDisconnected()));
157 Q_ASSERT(check);
158
159 quint16 port = socket->peerPort();
160 m_Sockets.append(socket);
161 m_nTotal++;
162 emit sigConnectCount(m_nTotal, m_Sockets.size(), m_nDisconnect);
163 emit sigConnected(szIP, port);
164 qDebug(log) << "Current connect count:" << m_Sockets.size()
165 << "; new connect from:" << szIP + ":" + QString::number(port);
166 return false;
167}
168
169void CBackendFtpServer::slotDisconnected()
170{

Callers

nothing calls this directly

Calls 4

GetWhitelistMethod · 0.80
GetBlacklistMethod · 0.80
GetConnectCountMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected