mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
@G10h4ck reimplemented the code to add a peer with location and IPs in acceptInvite().
Remove the redundant code and use the new function for importFriendlist(). This was not tested - i use the same code in SyncFriends plugin and tested it there.
This commit is contained in:
parent
7784660d67
commit
dd36f81038
@ -2044,48 +2044,10 @@ bool FriendList::importFriendlist(QString &fileName, bool &errorPeers, bool &err
|
|||||||
|
|
||||||
// load everything needed from the pubkey string
|
// load everything needed from the pubkey string
|
||||||
std::string pubkey = sslIDElem.attribute("certificate").toStdString();
|
std::string pubkey = sslIDElem.attribute("certificate").toStdString();
|
||||||
if(rsPeers->loadDetailsFromStringCert(pubkey, rsPeerDetails, error_code)) {
|
ServicePermissionFlags service_perm_flags(sslIDElem.attribute("service_perm_flags").toInt());
|
||||||
if(rsPeers->loadCertificateFromString(pubkey, rsPeerID, rsPgpID, error_string)) {
|
if (!rsPeers->acceptInvite(pubkey, service_perm_flags)) {
|
||||||
ServicePermissionFlags service_perm_flags(sslIDElem.attribute("service_perm_flags").toInt());
|
|
||||||
|
|
||||||
// everything is loaded - start setting things
|
|
||||||
if (!rsPeerDetails.id.isNull() && !rsPeerDetails.gpg_id.isNull()) {
|
|
||||||
// pgp and ssl ID are available
|
|
||||||
rsPeers->addFriend(rsPeerDetails.id, rsPeerDetails.gpg_id, service_perm_flags);
|
|
||||||
if(rsPeerDetails.isHiddenNode) {
|
|
||||||
// for hidden notes
|
|
||||||
if (!rsPeerDetails.hiddenNodeAddress.empty() && rsPeerDetails.hiddenNodePort)
|
|
||||||
rsPeers->setHiddenNode(rsPeerDetails.id, rsPeerDetails.hiddenNodeAddress, rsPeerDetails.hiddenNodePort);
|
|
||||||
} else {
|
|
||||||
// for normal nodes
|
|
||||||
if (!rsPeerDetails.extAddr.empty() && rsPeerDetails.extPort)
|
|
||||||
rsPeers->setExtAddress(rsPeerDetails.id, rsPeerDetails.extAddr, rsPeerDetails.extPort);
|
|
||||||
if (!rsPeerDetails.localAddr.empty() && rsPeerDetails.localPort)
|
|
||||||
rsPeers->setLocalAddress(rsPeerDetails.id, rsPeerDetails.localAddr, rsPeerDetails.localPort);
|
|
||||||
if (!rsPeerDetails.dyndns.empty())
|
|
||||||
rsPeers->setDynDNS(rsPeerDetails.id, rsPeerDetails.dyndns);
|
|
||||||
if (!rsPeerDetails.location.empty())
|
|
||||||
rsPeers->setLocation(rsPeerDetails.id, rsPeerDetails.location);
|
|
||||||
for(auto&& ipr : rsPeerDetails.ipAddressList)
|
|
||||||
rsPeers->addPeerLocator(
|
|
||||||
rsPeerDetails.id,
|
|
||||||
RsUrl(ipr.substr(0, ipr.find(' '))) );
|
|
||||||
}
|
|
||||||
} else if (!rsPeerDetails.gpg_id.isNull()) {
|
|
||||||
// only pgp id is avaiable
|
|
||||||
RsPeerId pid;
|
|
||||||
rsPeers->addFriend(pid, rsPeerDetails.gpg_id, service_perm_flags);
|
|
||||||
} else {
|
|
||||||
errorPeers = true;
|
|
||||||
std::cerr << "FriendList::importFriendlist(): error while processing SSL id: " << sslIDElem.attribute("sslID", "invalid").toStdString() << std::endl;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
errorPeers = true;
|
|
||||||
std::cerr << "FriendList::importFriendlist(): failed to get peer detaisl from public key (SSL id: " << sslIDElem.attribute("sslID", "invalid").toStdString() << " - error: " << error_string << ")" << std::endl;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
errorPeers = true;
|
errorPeers = true;
|
||||||
std::cerr << "FriendList::importFriendlist(): failed to get peer detaisl from public key (SSL id: " << sslIDElem.attribute("sslID", "invalid").toStdString() << " - error: " << error_code << ")" << std::endl;
|
std::cerr << "FriendList::importFriendlist(): failed to get peer detaisl from public key (SSL id: " << sslIDElem.attribute("sslID", "invalid").toStdString() << ")" << std::endl;
|
||||||
}
|
}
|
||||||
sslIDElem = sslIDElem.nextSiblingElement("sslID");
|
sslIDElem = sslIDElem.nextSiblingElement("sslID");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user