void CKadNode::InsertAddress(const CNodeAddress& Address) { AddressMap::iterator I = m_AddressMap.insert(AddressMap::value_type(Address.GetProtocol(), Address)); if(I->second.GetPassKey() == 0) // node may use a custom passkey I->second.SetPassKey(GetPassKey()); else { // Note: custom PCK's are actually allowed, but not used yet those an custom apsskey ist most likelly a bug ASSERT(I->second.GetPassKey() == GetPassKey()); } }
void ChooseUserPage::initializePage () { connect (wizard (), &QDialog::accepted, this, &ChooseUserPage::SaveCredentials); QSettings settings (QCoreApplication::organizationName (), QCoreApplication::applicationName () + "_Dolozhee"); settings.beginGroup ("Credentials"); const QString& login = settings.value ("Login").toString (); settings.endGroup (); if (login.isEmpty ()) return; Ui_.Existing_->setChecked (true); Ui_.Login_->setText (login); const QString& text = tr ("Please enter password for user %1:") .arg (login); const QString& pass = Util::GetPassword (GetPassKey (), text, Proxy_); Ui_.Password_->setText (pass); }
void ChooseUserPage::SaveCredentials () { if (GetUser () != User::Existing) return; QSettings settings (QCoreApplication::organizationName (), QCoreApplication::applicationName () + "_Dolozhee"); settings.beginGroup ("Credentials"); settings.setValue ("Login", GetLogin ()); settings.endGroup (); Util::SavePassword (GetPassword (), GetPassKey (), Proxy_); }
void RoomHandler::HandlePasswordRequired () { const auto& text = tr ("This room is password-protected. Please enter the " "password required to join this room."); const QString& pass = Util::GetPassword (GetPassKey (), text, &Core::Instance (), !HadRequestedPassword_); if (pass.isEmpty ()) { Leave (QString ()); return; } HadRequestedPassword_ = true; Room_->setPassword (pass); Join (); }
void CKadNode::UpdateAddress(const CNodeAddress& Address) { if(Address.GetProtocol() == CSafeAddress::eInvalid) { LogLine(LOG_ERROR, L"Atempted to add an invalid address to a kad node!"); return; } m_uLastSeen = GetTime(); // Note: The map layout is important: // For each protocol we have 0 or 1 verifyed addresses and 0 or 1 unverifyed addresses // The most recent addresses are located at the top // For the most purposes we howeever selelct always the verifyed address // If a new verifyed address is added all older addresses are removed // if a new unverifyed address is added older unverifyed addresses are removed // those we keep never more than 2 adresses for each protocol bool bAdd = true; for(AddressMap::iterator I = m_AddressMap.find(Address.GetProtocol()); I != m_AddressMap.end() && I->first == Address.GetProtocol();) { bool bAux = false; if(Address.Compare(I->second) == 0 || (bAux = (Address.Compare(I->second, true) == 0))) // Note: this comparation compares only addresses, not additional informations { if(Address.IsVerifyed()) { I->second.SetVerifyed(); I->second.SetAssistent(Address.GetAssistent()); // only verifyed (signed) adresses can set or clear the Assistent } if(Address.GetFirstSeen() < I->second.GetFirstSeen()) I->second.SetFirstSeen(Address.GetFirstSeen()); if(Address.GetLastSeen() > I->second.GetLastSeen()) I->second.SetLastSeen(Address.GetLastSeen()); if(Address.GetClass() < I->second.GetClass()) I->second.SetClass(Address.GetClass()); if(bAux) { // the Aux port is the port on which we see the node communicating but not its primary port // when we try to talk to the node we always go for the primary port if(Address.IsVerifyed()) { I->second.SetAuxPort(I->second.GetPort()); I->second.SetPort(Address.GetPort()); } else I->second.SetAuxPort(Address.GetPort()); } bAdd = false; break; } else if(!I->second.IsVerifyed()) // we dont keep unverifyed address es I = m_AddressMap.erase(I); else I++; } // insert new address at the top AddressMap::iterator I = m_AddressMap.find(Address.GetProtocol()); if(bAdd) { I = m_AddressMap.insert(I, AddressMap::value_type(Address.GetProtocol(), Address)); if(I->second.GetPassKey() == 0) // node may use a custom passkey I->second.SetPassKey(GetPassKey()); else { // Note: custom PCK's are actually allowed, but nut used yet those an custom apsskey ist most likelly a bug ASSERT(I->second.GetPassKey() == GetPassKey()); } } if(Address.IsVerifyed()) // if the address is a verifyed one, remove all other with same protocol { for(AddressMap::iterator J = ++I; J != m_AddressMap.end() && J->first == Address.GetProtocol();) J = m_AddressMap.erase(J); } }