bool TreeSocket::ComparePass(const Link& link, const std::string &theirs) { this->auth_fingerprint = !link.Fingerprint.empty(); this->auth_challenge = !ourchallenge.empty() && !theirchallenge.empty(); const char* fp = NULL; if (GetHook()) fp = BufferedSocketFingerprintRequest(this, Utils->Creator, GetHook()).Send(); if (fp) ServerInstance->Logs->Log("m_spanningtree", DEFAULT, std::string("Server SSL fingerprint ") + fp); if (auth_fingerprint) { /* Require fingerprint to exist and match */ if (!fp || link.Fingerprint != std::string(fp)) return false; } if (auth_challenge) { std::string our_hmac = MakePass(link.RecvPass, ourchallenge); /* Straight string compare of hashes */ return our_hmac == theirs; } /* Straight string compare of plaintext */ return link.RecvPass == theirs; }
// During idle time make random moves if Random! has been selected void SimpleGoPanel::Idle(wxIdleEvent& event) { if(!frame->playmenu->IsChecked(ID_RANDOM)) { if(!gnugopause && ((curmove%2==1 && frame->whitelevel>0) || (curmove%2==0 && frame->blacklevel>0))) frame->MakeGNUGoMove(); return; } int x = 1+rand()%boardsize, y = 1+rand()%boardsize; char attempts[21][21], temp[21][21]; memset(attempts, 0, BOARDMEMORYLEN); int count = 0; while(count<boardsize*boardsize) { while(attempts[x][y]==1) { x = 1+rand()%boardsize; y = 1+rand()%boardsize; } memcpy(temp, board, BOARDMEMORYLEN); if(ValidMove(temp, x, y, curmove%2+1)) { MakeMove(x, y); #ifdef __WXMSW__ event.RequestMore(); #endif return; } count++; attempts[x][y] = 1; } MakePass(); #ifdef __WXMSW__ event.RequestMore(); #endif }
bool TreeSocket::ComparePass(const Link& link, const std::string &theirs) { capab->auth_fingerprint = !link.Fingerprint.empty(); capab->auth_challenge = !capab->ourchallenge.empty() && !capab->theirchallenge.empty(); std::string fp; if (GetIOHook()) { SocketCertificateRequest req(this, Utils->Creator); if (req.cert) { fp = req.cert->GetFingerprint(); } } if (capab->auth_challenge) { std::string our_hmac = MakePass(link.RecvPass, capab->ourchallenge); /* Straight string compare of hashes */ if (our_hmac != theirs) return false; } else { /* Straight string compare of plaintext */ if (link.RecvPass != theirs) return false; } if (capab->auth_fingerprint) { /* Require fingerprint to exist and match */ if (link.Fingerprint != fp) { ServerInstance->SNO->WriteToSnoMask('l',"Invalid SSL fingerprint on link %s: need \"%s\" got \"%s\"", link.Name.c_str(), link.Fingerprint.c_str(), fp.c_str()); SendError("Provided invalid SSL fingerprint " + fp + " - expected " + link.Fingerprint); return false; } } else if (!fp.empty()) { ServerInstance->SNO->WriteToSnoMask('l', "SSL fingerprint for link %s is \"%s\". " "You can improve security by specifying this in <link:fingerprint>.", link.Name.c_str(), fp.c_str()); } return true; }
// Process a key press // left/right moves through history; 'p' passes the turn void SimpleGoPanel::KeyDown(wxKeyEvent& event) { if(event.GetKeyCode()==WXK_LEFT&&curmove>0) { gnugopause = true; gnugoscore = false; curmove--; UpdateBoard(); } else if(event.GetKeyCode()==WXK_RIGHT&&curmove<totmove) { gnugoscore = false; curmove++; UpdateBoard(); } else if(event.GetKeyCode()=='P'&&!event.AltDown()) MakePass(); else if(event.GetKeyCode()==WXK_ESCAPE) { gnugopause = true; frame->playmenu->Check(ID_RANDOM, false); } event.Skip(); }