Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.1 kB
1
Indexable
Never
bool check_perma(ENetPeer* peer) {

    std::ifstream ifs("db/ban.json");
    json data = json::parse(ifs);

    bool vidFound = data["vid"][0] == pInfo(peer)->vid, macFound = data["mac"][0] == pInfo(peer)->mac, wkFound = data["wk"][0] == pInfo(peer)->mac, ipFound = data["ip"][0] == pInfo(peer)->ip, ridFound = data["rid"][0] == pInfo(peer)->rid, aidFound = data["aid"][0] == pInfo(peer)->aid, gidFound = data["gid"][0] == pInfo(peer)->gid;

    return vidFound && macFound && wkFound && ipFound && ridFound && aidFound && gidFound;
    
}

void add_perma(ENetPeer* peer) {

json data;

std::vector<std::string> rid = {""}, wk = {""}, gid = {""}, vid = {""}, mac = {""}, ip = {""}, wk = {""};

rid.push_back(pInfo(peer)->rid), wk.push_back(pInfo(peer)->wk), gid.push_back(pInfo(peer)->gid), ip.push_back(pInfo(peer)->ip), vid.push_back(pInfo(peer)->vid), mac.push_back(pInfo(peer)->mac);

data["rid"] = rid, data["gid"] = gid, data["vid"] = vid, data["mac"] = mac, data["ip"] = ip, data["wk"] = wk;

std::ofstream ofs("db/ban.json");
ofs << setw(4) << data << endl;

}

if (check_perma(peer)) break;