Untitled
unknown
plain_text
12 days ago
1.4 kB
1
Indexable
Never
#include <algorithm> // for std::remove_if void append_reset(string ip) { while (true) { auto it = std::find_if(connection_data.begin(), connection_data.end(), [ip](const Connection& connection) { return connection.ip == ip; }); if (it != connection_data.end()) { if (it->attempts > 5) { // Kalıcı engelleme işlemi it = connection_data.erase(it); connection_data.push_back({ip, -1}); // -1, kalıcı engeli temsil edebilir saveConnectionData(); return; // Fonksiyonu burada sonlandır, çünkü kalıcı engelleme uygulandı. } else if (it->attempts > 3) { this_thread::sleep_for(4s); it->attempts -= 3; } else { if (it->attempts <= 0) continue; this_thread::sleep_for(1800ms); it->attempts -= 1; } saveConnectionData(); } else { // Eğer bağlantı bulunamazsa, yeni bir Connection nesnesi ekleyin Connection new_data; new_data.ip = ip; new_data.attempts = 1; connection_data.push_back(new_data); saveConnectionData(); } this_thread::sleep_for(5ms); } }
Leave a Comment