mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-13 16:45:49 -04:00
replaces SSLIdType by indirect type RsPeerId and PGPIdType with RsPgpId whenever applicable
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7163 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d391da3c4c
commit
886a8974db
68 changed files with 622 additions and 766 deletions
|
@ -524,7 +524,7 @@ int DirEntry::print(std::string &out)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileIndex::FileIndex(const SSLIdType& pid)
|
FileIndex::FileIndex(const RsPeerId& pid)
|
||||||
{
|
{
|
||||||
root = new PersonEntry(pid);
|
root = new PersonEntry(pid);
|
||||||
registerEntry(root) ;
|
registerEntry(root) ;
|
||||||
|
@ -862,7 +862,7 @@ int FileIndex::loadIndex(const std::string& filename, const RsFileHash& expected
|
||||||
/* finished parse, last dir is root */
|
/* finished parse, last dir is root */
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
SSLIdType pid = root -> id;
|
RsPeerId pid = root -> id;
|
||||||
FileIndex::unregisterEntry((void*)root) ;
|
FileIndex::unregisterEntry((void*)root) ;
|
||||||
delete root; /* to clean up old entries */
|
delete root; /* to clean up old entries */
|
||||||
root = new PersonEntry(pid);
|
root = new PersonEntry(pid);
|
||||||
|
|
|
@ -174,7 +174,7 @@ class PersonEntry: public DirEntry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
PersonEntry(const SSLIdType& pid) : id(pid) { return; }
|
PersonEntry(const RsPeerId& pid) : id(pid) { return; }
|
||||||
virtual ~PersonEntry() { return; }
|
virtual ~PersonEntry() { return; }
|
||||||
|
|
||||||
DirEntry &operator=(DirEntry &src)
|
DirEntry &operator=(DirEntry &src)
|
||||||
|
@ -186,7 +186,7 @@ DirEntry &operator=(DirEntry &src)
|
||||||
virtual uint32_t type() const { return DIR_TYPE_PERSON ; }
|
virtual uint32_t type() const { return DIR_TYPE_PERSON ; }
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
SSLIdType id;
|
RsPeerId id;
|
||||||
|
|
||||||
/* Inherited members from FileEntry:
|
/* Inherited members from FileEntry:
|
||||||
int size - count for dirs
|
int size - count for dirs
|
||||||
|
@ -209,7 +209,7 @@ class Expression;
|
||||||
class FileIndex
|
class FileIndex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileIndex(const SSLIdType& pid);
|
FileIndex(const RsPeerId& pid);
|
||||||
~FileIndex();
|
~FileIndex();
|
||||||
|
|
||||||
/* control root entries */
|
/* control root entries */
|
||||||
|
|
|
@ -168,7 +168,7 @@ int FileIndexStore::loadCache(const RsCacheData &data)
|
||||||
|
|
||||||
|
|
||||||
/* Search Interface - For Directory Access */
|
/* Search Interface - For Directory Access */
|
||||||
int FileIndexStore::RequestDirDetails(const SSLIdType& uid, const std::string& path, DirDetails& details) const
|
int FileIndexStore::RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails& details) const
|
||||||
{
|
{
|
||||||
lockData();
|
lockData();
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ class ftPendingRequest
|
||||||
public:
|
public:
|
||||||
ftPendingRequest(const std::string& fname, const RsFileHash& hash,
|
ftPendingRequest(const std::string& fname, const RsFileHash& hash,
|
||||||
uint64_t size, const std::string& dest, TransferRequestFlags flags,
|
uint64_t size, const std::string& dest, TransferRequestFlags flags,
|
||||||
const std::list<SSLIdType> &srcIds, uint16_t state)
|
const std::list<RsPeerId> &srcIds, uint16_t state)
|
||||||
: mName(fname), mHash(hash), mSize(size),
|
: mName(fname), mHash(hash), mSize(size),
|
||||||
mDest(dest), mFlags(flags), mSrcIds(srcIds), mState(state) { return; }
|
mDest(dest), mFlags(flags), mSrcIds(srcIds), mState(state) { return; }
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class ftPendingRequest
|
||||||
uint64_t mSize;
|
uint64_t mSize;
|
||||||
std::string mDest;
|
std::string mDest;
|
||||||
TransferRequestFlags mFlags;
|
TransferRequestFlags mFlags;
|
||||||
std::list<SSLIdType> mSrcIds;
|
std::list<RsPeerId> mSrcIds;
|
||||||
uint16_t mState;
|
uint16_t mState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
||||||
|
|
||||||
bool FileRequest(const std::string& fname, const RsFileHash& hash,
|
bool FileRequest(const std::string& fname, const RsFileHash& hash,
|
||||||
uint64_t size, const std::string& dest, TransferRequestFlags flags,
|
uint64_t size, const std::string& dest, TransferRequestFlags flags,
|
||||||
const std::list<SSLIdType> &sourceIds, uint16_t state = ftFileControl::DOWNLOADING);
|
const std::list<RsPeerId> &sourceIds, uint16_t state = ftFileControl::DOWNLOADING);
|
||||||
|
|
||||||
/// Do we already have this file, either in download or in file lists ?
|
/// Do we already have this file, either in download or in file lists ?
|
||||||
bool alreadyHaveFile(const RsFileHash& hash, FileInfo &info);
|
bool alreadyHaveFile(const RsFileHash& hash, FileInfo &info);
|
||||||
|
@ -184,12 +184,12 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
||||||
|
|
||||||
/// Returns true is full source availability can be assumed for this peer.
|
/// Returns true is full source availability can be assumed for this peer.
|
||||||
///
|
///
|
||||||
bool assumeAvailability(const SSLIdType& peer_id) const ;
|
bool assumeAvailability(const RsPeerId& peer_id) const ;
|
||||||
|
|
||||||
/* pqiMonitor callback (also provided mConnMgr pointer!) */
|
/* pqiMonitor callback (also provided mConnMgr pointer!) */
|
||||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||||
void addFileSource(const RsFileHash& hash,const SSLIdType& peer_id) ;
|
void addFileSource(const RsFileHash& hash,const RsPeerId& peer_id) ;
|
||||||
void removeFileSource(const RsFileHash& hash,const SSLIdType& peer_id) ;
|
void removeFileSource(const RsFileHash& hash,const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
||||||
bool completeFile(const RsFileHash& hash);
|
bool completeFile(const RsFileHash& hash);
|
||||||
bool handleAPendingRequest();
|
bool handleAPendingRequest();
|
||||||
|
|
||||||
bool setPeerState(ftTransferModule *tm, const SSLIdType& id,
|
bool setPeerState(ftTransferModule *tm, const RsPeerId& id,
|
||||||
uint32_t maxrate, bool online);
|
uint32_t maxrate, bool online);
|
||||||
|
|
||||||
time_t last_save_time ;
|
time_t last_save_time ;
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ftFileCreator: public ftFileProvider
|
||||||
~ftFileCreator();
|
~ftFileCreator();
|
||||||
|
|
||||||
/* overloaded from FileProvider */
|
/* overloaded from FileProvider */
|
||||||
virtual bool getFileData(const SSLIdType& peer_id,uint64_t offset, uint32_t &chunk_size, void *data);
|
virtual bool getFileData(const RsPeerId& peer_id,uint64_t offset, uint32_t &chunk_size, void *data);
|
||||||
bool finished() ;
|
bool finished() ;
|
||||||
uint64_t getRecvd();
|
uint64_t getRecvd();
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ class ftFileCreator: public ftFileProvider
|
||||||
// - no chunkmap info is available. In such a case, the chunk info is irrelevant and false is returned.
|
// - no chunkmap info is available. In such a case, the chunk info is irrelevant and false is returned.
|
||||||
// - the chunk info is too old. In tis case, true is returned, and the chunks info can be used.
|
// - the chunk info is too old. In tis case, true is returned, and the chunks info can be used.
|
||||||
//
|
//
|
||||||
bool getMissingChunk(const SSLIdType& peer_id,uint32_t size_hint,uint64_t& offset, uint32_t& size,bool& is_chunk_map_too_old);
|
bool getMissingChunk(const RsPeerId& peer_id,uint32_t size_hint,uint64_t& offset, uint32_t& size,bool& is_chunk_map_too_old);
|
||||||
|
|
||||||
// Takes care of purging any inactive chunks. This should be called regularly, because some peers may disconnect
|
// Takes care of purging any inactive chunks. This should be called regularly, because some peers may disconnect
|
||||||
// and let inactive chunks not finished.
|
// and let inactive chunks not finished.
|
||||||
|
@ -99,11 +99,11 @@ class ftFileCreator: public ftFileProvider
|
||||||
void removeInactiveChunks() ;
|
void removeInactiveChunks() ;
|
||||||
|
|
||||||
// removes the designated file source from the chunkmap.
|
// removes the designated file source from the chunkmap.
|
||||||
void removeFileSource(const SSLIdType& peer_id) ;
|
void removeFileSource(const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
// Get all available sources for this chunk
|
// Get all available sources for this chunk
|
||||||
//
|
//
|
||||||
void getSourcesList(uint32_t chunk_number,std::vector<SSLIdType>& sources) ;
|
void getSourcesList(uint32_t chunk_number,std::vector<RsPeerId>& sources) ;
|
||||||
|
|
||||||
// Returns resets the time stamp of the last data receive.
|
// Returns resets the time stamp of the last data receive.
|
||||||
time_t lastRecvTimeStamp() ;
|
time_t lastRecvTimeStamp() ;
|
||||||
|
@ -124,11 +124,11 @@ class ftFileCreator: public ftFileProvider
|
||||||
|
|
||||||
// This is called when receiving the availability map from a source peer, for the file being handled.
|
// This is called when receiving the availability map from a source peer, for the file being handled.
|
||||||
//
|
//
|
||||||
void setSourceMap(const SSLIdType& peer_id,const CompressedChunkMap& map) ;
|
void setSourceMap(const RsPeerId& peer_id,const CompressedChunkMap& map) ;
|
||||||
|
|
||||||
// Returns true id the given file source is complete.
|
// Returns true id the given file source is complete.
|
||||||
//
|
//
|
||||||
bool sourceIsComplete(const SSLIdType& peer_id) ;
|
bool sourceIsComplete(const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class ftFileCreator: public ftFileProvider
|
||||||
uint64_t mEnd;
|
uint64_t mEnd;
|
||||||
|
|
||||||
std::map<uint64_t, ftChunk> mChunks;
|
std::map<uint64_t, ftChunk> mChunks;
|
||||||
std::map<SSLIdType,ZeroInitCounter> mChunksPerPeer ;
|
std::map<RsPeerId,ZeroInitCounter> mChunksPerPeer ;
|
||||||
|
|
||||||
ChunkMap chunkMap ;
|
ChunkMap chunkMap ;
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ bool ftFileProvider::FileDetails(FileInfo &info)
|
||||||
info.peers.clear() ;
|
info.peers.clear() ;
|
||||||
float total_transfer_rate = 0.0f ;
|
float total_transfer_rate = 0.0f ;
|
||||||
|
|
||||||
for(std::map<SSLIdType,PeerUploadInfo>::const_iterator it(uploading_peers.begin());it!=uploading_peers.end();++it)
|
for(std::map<RsPeerId,PeerUploadInfo>::const_iterator it(uploading_peers.begin());it!=uploading_peers.end();++it)
|
||||||
{
|
{
|
||||||
TransferInfo inf ;
|
TransferInfo inf ;
|
||||||
inf.peerId = it->first ;
|
inf.peerId = it->first ;
|
||||||
|
@ -109,13 +109,13 @@ bool ftFileProvider::purgeOldPeers(time_t now,uint32_t max_duration)
|
||||||
std::cerr << "ftFileProvider::purgeOldPeers(): " << (void*)this << ": examining peers." << std::endl ;
|
std::cerr << "ftFileProvider::purgeOldPeers(): " << (void*)this << ": examining peers." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
bool ret = true ;
|
bool ret = true ;
|
||||||
for(std::map<SSLIdType,PeerUploadInfo>::iterator it(uploading_peers.begin());it!=uploading_peers.end();)
|
for(std::map<RsPeerId,PeerUploadInfo>::iterator it(uploading_peers.begin());it!=uploading_peers.end();)
|
||||||
if( (*it).second.lastTS+max_duration < (uint32_t)now)
|
if( (*it).second.lastTS+max_duration < (uint32_t)now)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_FT_FILE_PROVIDER
|
#ifdef DEBUG_FT_FILE_PROVIDER
|
||||||
std::cerr << "ftFileProvider::purgeOldPeers(): " << (void*)this << ": peer " << it->first << " is too old. Removing." << std::endl ;
|
std::cerr << "ftFileProvider::purgeOldPeers(): " << (void*)this << ": peer " << it->first << " is too old. Removing." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
std::map<SSLIdType,PeerUploadInfo>::iterator tmp = it ;
|
std::map<RsPeerId,PeerUploadInfo>::iterator tmp = it ;
|
||||||
++tmp ;
|
++tmp ;
|
||||||
uploading_peers.erase(it) ;
|
uploading_peers.erase(it) ;
|
||||||
it=tmp ;
|
it=tmp ;
|
||||||
|
@ -139,7 +139,7 @@ void ftFileProvider::getAvailabilityMap(CompressedChunkMap& cmap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ftFileProvider::getFileData(const SSLIdType& peer_id,uint64_t offset, uint32_t &chunk_size, void *data)
|
bool ftFileProvider::getFileData(const RsPeerId& peer_id,uint64_t offset, uint32_t &chunk_size, void *data)
|
||||||
{
|
{
|
||||||
/* dodgey checking outside of mutex...
|
/* dodgey checking outside of mutex...
|
||||||
* much check again inside FileAttrs().
|
* much check again inside FileAttrs().
|
||||||
|
@ -250,7 +250,7 @@ void ftFileProvider::PeerUploadInfo::updateStatus(uint64_t offset,uint32_t data_
|
||||||
total_size += req_size ;
|
total_size += req_size ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ftFileProvider::setClientMap(const SSLIdType& peer_id,const CompressedChunkMap& cmap)
|
void ftFileProvider::setClientMap(const RsPeerId& peer_id,const CompressedChunkMap& cmap)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ void ftFileProvider::setClientMap(const SSLIdType& peer_id,const CompressedChunk
|
||||||
uploading_peers[peer_id].client_chunk_map_stamp = time(NULL) ;
|
uploading_peers[peer_id].client_chunk_map_stamp = time(NULL) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ftFileProvider::getClientMap(const SSLIdType& peer_id,CompressedChunkMap& cmap,bool& map_is_too_old)
|
void ftFileProvider::getClientMap(const RsPeerId& peer_id,CompressedChunkMap& cmap,bool& map_is_too_old)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ftFileProvider
|
||||||
ftFileProvider(const std::string& path, uint64_t size, const RsFileHash& hash);
|
ftFileProvider(const std::string& path, uint64_t size, const RsFileHash& hash);
|
||||||
virtual ~ftFileProvider();
|
virtual ~ftFileProvider();
|
||||||
|
|
||||||
virtual bool getFileData(const SSLIdType& peer_id,uint64_t offset, uint32_t &chunk_size, void *data);
|
virtual bool getFileData(const RsPeerId& peer_id,uint64_t offset, uint32_t &chunk_size, void *data);
|
||||||
virtual bool FileDetails(FileInfo &info);
|
virtual bool FileDetails(FileInfo &info);
|
||||||
RsFileHash getHash();
|
RsFileHash getHash();
|
||||||
uint64_t getFileSize();
|
uint64_t getFileSize();
|
||||||
|
|
|
@ -103,7 +103,7 @@ ftTransferModule::~ftTransferModule()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ftTransferModule::setFileSources(const std::list<SSLIdType>& peerIds)
|
bool ftTransferModule::setFileSources(const std::list<RsPeerId>& peerIds)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ bool ftTransferModule::setFileSources(const std::list<SSLIdType>& peerIds)
|
||||||
std::cerr << " List of peers: " ;
|
std::cerr << " List of peers: " ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::list<SSLIdType>::const_iterator it;
|
std::list<RsPeerId>::const_iterator it;
|
||||||
for(it = peerIds.begin(); it != peerIds.end(); it++)
|
for(it = peerIds.begin(); it != peerIds.end(); it++)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ bool ftTransferModule::setFileSources(const std::list<SSLIdType>& peerIds)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
peerInfo pInfo(*it);
|
peerInfo pInfo(*it);
|
||||||
mFileSources.insert(std::pair<SSLIdType,peerInfo>(*it,pInfo));
|
mFileSources.insert(std::pair<RsPeerId,peerInfo>(*it,pInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FT_DEBUG
|
#ifdef FT_DEBUG
|
||||||
|
@ -133,10 +133,10 @@ bool ftTransferModule::setFileSources(const std::list<SSLIdType>& peerIds)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ftTransferModule::getFileSources(std::list<SSLIdType> &peerIds)
|
bool ftTransferModule::getFileSources(std::list<RsPeerId> &peerIds)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
std::map<SSLIdType,peerInfo>::iterator it;
|
std::map<RsPeerId,peerInfo>::iterator it;
|
||||||
for(it = mFileSources.begin(); it != mFileSources.end(); it++)
|
for(it = mFileSources.begin(); it != mFileSources.end(); it++)
|
||||||
{
|
{
|
||||||
peerIds.push_back(it->first);
|
peerIds.push_back(it->first);
|
||||||
|
@ -144,17 +144,17 @@ bool ftTransferModule::getFileSources(std::list<SSLIdType> &peerIds)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ftTransferModule::addFileSource(const SSLIdType& peerId)
|
bool ftTransferModule::addFileSource(const RsPeerId& peerId)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
std::map<SSLIdType,peerInfo>::iterator mit;
|
std::map<RsPeerId,peerInfo>::iterator mit;
|
||||||
mit = mFileSources.find(peerId);
|
mit = mFileSources.find(peerId);
|
||||||
|
|
||||||
if (mit == mFileSources.end())
|
if (mit == mFileSources.end())
|
||||||
{
|
{
|
||||||
/* add in new source */
|
/* add in new source */
|
||||||
peerInfo pInfo(peerId);
|
peerInfo pInfo(peerId);
|
||||||
mFileSources.insert(std::pair<SSLIdType,peerInfo>(peerId,pInfo));
|
mFileSources.insert(std::pair<RsPeerId,peerInfo>(peerId,pInfo));
|
||||||
mit = mFileSources.find(peerId);
|
mit = mFileSources.find(peerId);
|
||||||
|
|
||||||
mMultiplexor->sendChunkMapRequest(peerId, mHash,false) ;
|
mMultiplexor->sendChunkMapRequest(peerId, mHash,false) ;
|
||||||
|
@ -177,10 +177,10 @@ bool ftTransferModule::addFileSource(const SSLIdType& peerId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ftTransferModule::removeFileSource(const SSLIdType& peerId)
|
bool ftTransferModule::removeFileSource(const RsPeerId& peerId)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
std::map<SSLIdType,peerInfo>::iterator mit;
|
std::map<RsPeerId,peerInfo>::iterator mit;
|
||||||
mit = mFileSources.find(peerId);
|
mit = mFileSources.find(peerId);
|
||||||
|
|
||||||
if (mit != mFileSources.end())
|
if (mit != mFileSources.end())
|
||||||
|
@ -199,7 +199,7 @@ bool ftTransferModule::removeFileSource(const SSLIdType& peerId)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ftTransferModule::setPeerState(const SSLIdType& peerId,uint32_t state,uint32_t maxRate)
|
bool ftTransferModule::setPeerState(const RsPeerId& peerId,uint32_t state,uint32_t maxRate)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
#ifdef FT_DEBUG
|
#ifdef FT_DEBUG
|
||||||
|
@ -209,7 +209,7 @@ bool ftTransferModule::setPeerState(const SSLIdType& peerId,uint32_t state,uint3
|
||||||
std::cerr << " maxRate: " << maxRate << std::endl;
|
std::cerr << " maxRate: " << maxRate << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::map<SSLIdType,peerInfo>::iterator mit;
|
std::map<RsPeerId,peerInfo>::iterator mit;
|
||||||
mit = mFileSources.find(peerId);
|
mit = mFileSources.find(peerId);
|
||||||
|
|
||||||
if (mit == mFileSources.end())
|
if (mit == mFileSources.end())
|
||||||
|
@ -229,7 +229,7 @@ bool ftTransferModule::setPeerState(const SSLIdType& peerId,uint32_t state,uint3
|
||||||
// Start it off at zero....
|
// Start it off at zero....
|
||||||
// (mit->second).actualRate=maxRate; /* should give big kick in right direction */
|
// (mit->second).actualRate=maxRate; /* should give big kick in right direction */
|
||||||
|
|
||||||
std::list<SSLIdType>::iterator it;
|
std::list<RsPeerId>::iterator it;
|
||||||
it = std::find(mOnlinePeers.begin(), mOnlinePeers.end(), peerId);
|
it = std::find(mOnlinePeers.begin(), mOnlinePeers.end(), peerId);
|
||||||
|
|
||||||
if (state!=PQIPEER_NOT_ONLINE)
|
if (state!=PQIPEER_NOT_ONLINE)
|
||||||
|
@ -247,10 +247,10 @@ bool ftTransferModule::setPeerState(const SSLIdType& peerId,uint32_t state,uint3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ftTransferModule::getPeerState(const SSLIdType& peerId,uint32_t &state,uint32_t &tfRate)
|
bool ftTransferModule::getPeerState(const RsPeerId& peerId,uint32_t &state,uint32_t &tfRate)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
std::map<SSLIdType,peerInfo>::iterator mit;
|
std::map<RsPeerId,peerInfo>::iterator mit;
|
||||||
mit = mFileSources.find(peerId);
|
mit = mFileSources.find(peerId);
|
||||||
|
|
||||||
if (mit == mFileSources.end()) return false;
|
if (mit == mFileSources.end()) return false;
|
||||||
|
@ -267,10 +267,10 @@ bool ftTransferModule::getPeerState(const SSLIdType& peerId,uint32_t &state,uint
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ftTransferModule::getDataRate(const SSLIdType& peerId)
|
uint32_t ftTransferModule::getDataRate(const RsPeerId& peerId)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
std::map<SSLIdType,peerInfo>::iterator mit;
|
std::map<RsPeerId,peerInfo>::iterator mit;
|
||||||
mit = mFileSources.find(peerId);
|
mit = mFileSources.find(peerId);
|
||||||
if (mit == mFileSources.end())
|
if (mit == mFileSources.end())
|
||||||
{
|
{
|
||||||
|
@ -296,7 +296,7 @@ time_t ftTransferModule::lastActvTimeStamp()
|
||||||
}
|
}
|
||||||
|
|
||||||
//interface to client module
|
//interface to client module
|
||||||
bool ftTransferModule::recvFileData(const SSLIdType& peerId, uint64_t offset, uint32_t chunk_size, void *data)
|
bool ftTransferModule::recvFileData(const RsPeerId& peerId, uint64_t offset, uint32_t chunk_size, void *data)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
#ifdef FT_DEBUG
|
#ifdef FT_DEBUG
|
||||||
|
@ -310,7 +310,7 @@ bool ftTransferModule::recvFileData(const SSLIdType& peerId, uint64_t offset, ui
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
|
|
||||||
std::map<SSLIdType,peerInfo>::iterator mit;
|
std::map<RsPeerId,peerInfo>::iterator mit;
|
||||||
mit = mFileSources.find(peerId);
|
mit = mFileSources.find(peerId);
|
||||||
|
|
||||||
if (mit == mFileSources.end())
|
if (mit == mFileSources.end())
|
||||||
|
@ -332,7 +332,7 @@ bool ftTransferModule::recvFileData(const SSLIdType& peerId, uint64_t offset, ui
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ftTransferModule::locked_requestData(const SSLIdType& peerId, uint64_t offset, uint32_t chunk_size)
|
void ftTransferModule::locked_requestData(const RsPeerId& peerId, uint64_t offset, uint32_t chunk_size)
|
||||||
{
|
{
|
||||||
#ifdef FT_DEBUG
|
#ifdef FT_DEBUG
|
||||||
std::cerr << "ftTransferModule::requestData()";
|
std::cerr << "ftTransferModule::requestData()";
|
||||||
|
@ -347,7 +347,7 @@ void ftTransferModule::locked_requestData(const SSLIdType& peerId, uint64_t offs
|
||||||
mMultiplexor->sendDataRequest(peerId, mHash, mSize, offset,chunk_size);
|
mMultiplexor->sendDataRequest(peerId, mHash, mSize, offset,chunk_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ftTransferModule::locked_getChunk(const SSLIdType& peer_id,uint32_t size_hint,uint64_t &offset, uint32_t &chunk_size)
|
bool ftTransferModule::locked_getChunk(const RsPeerId& peer_id,uint32_t size_hint,uint64_t &offset, uint32_t &chunk_size)
|
||||||
{
|
{
|
||||||
#ifdef FT_DEBUG
|
#ifdef FT_DEBUG
|
||||||
std::cerr << "ftTransferModule::locked_getChunk()";
|
std::cerr << "ftTransferModule::locked_getChunk()";
|
||||||
|
@ -427,7 +427,7 @@ bool ftTransferModule::queryInactive()
|
||||||
if (mFileStatus.stat == ftFileStatus::PQIFILE_CHECKING)
|
if (mFileStatus.stat == ftFileStatus::PQIFILE_CHECKING)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
std::map<SSLIdType,peerInfo>::iterator mit;
|
std::map<RsPeerId,peerInfo>::iterator mit;
|
||||||
for(mit = mFileSources.begin(); mit != mFileSources.end(); mit++)
|
for(mit = mFileSources.begin(); mit != mFileSources.end(); mit++)
|
||||||
{
|
{
|
||||||
locked_tickPeerTransfer(mit->second);
|
locked_tickPeerTransfer(mit->second);
|
||||||
|
@ -496,7 +496,7 @@ int ftTransferModule::tick()
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
std::cerr << "Peers: ";
|
std::cerr << "Peers: ";
|
||||||
std::map<SSLIdType,peerInfo>::iterator it;
|
std::map<RsPeerId,peerInfo>::iterator it;
|
||||||
for(it = mFileSources.begin(); it != mFileSources.end(); it++)
|
for(it = mFileSources.begin(); it != mFileSources.end(); it++)
|
||||||
{
|
{
|
||||||
std::cerr << " " << it->first;
|
std::cerr << " " << it->first;
|
||||||
|
@ -645,7 +645,7 @@ void ftTransferModule::adjustSpeed()
|
||||||
{
|
{
|
||||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||||
|
|
||||||
std::map<SSLIdType,peerInfo>::iterator mit;
|
std::map<RsPeerId,peerInfo>::iterator mit;
|
||||||
|
|
||||||
|
|
||||||
actualRate = 0;
|
actualRate = 0;
|
||||||
|
|
|
@ -56,7 +56,7 @@ class HashThread ;
|
||||||
class peerInfo
|
class peerInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
peerInfo(const SSLIdType& peerId_in):peerId(peerId_in),state(PQIPEER_NOT_ONLINE),desiredRate(0),actualRate(0),
|
peerInfo(const RsPeerId& peerId_in):peerId(peerId_in),state(PQIPEER_NOT_ONLINE),desiredRate(0),actualRate(0),
|
||||||
lastTS(0),
|
lastTS(0),
|
||||||
recvTS(0), lastTransfers(0), nResets(0),
|
recvTS(0), lastTransfers(0), nResets(0),
|
||||||
rtt(0), rttActive(false), rttStart(0), rttOffset(0),
|
rtt(0), rttActive(false), rttStart(0), rttOffset(0),
|
||||||
|
@ -64,7 +64,7 @@ public:
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
peerInfo(const SSLIdType& peerId_in,uint32_t state_in,uint32_t maxRate_in):
|
peerInfo(const RsPeerId& peerId_in,uint32_t state_in,uint32_t maxRate_in):
|
||||||
peerId(peerId_in),state(state_in),desiredRate(maxRate_in),actualRate(0),
|
peerId(peerId_in),state(state_in),desiredRate(maxRate_in),actualRate(0),
|
||||||
lastTS(0),
|
lastTS(0),
|
||||||
recvTS(0), lastTransfers(0), nResets(0),
|
recvTS(0), lastTransfers(0), nResets(0),
|
||||||
|
@ -73,7 +73,7 @@ public:
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SSLIdType peerId;
|
RsPeerId peerId;
|
||||||
uint32_t state;
|
uint32_t state;
|
||||||
double desiredRate;
|
double desiredRate;
|
||||||
double actualRate;
|
double actualRate;
|
||||||
|
@ -124,13 +124,13 @@ public:
|
||||||
~ftTransferModule();
|
~ftTransferModule();
|
||||||
|
|
||||||
//interface to download controller
|
//interface to download controller
|
||||||
bool setFileSources(const std::list<SSLIdType>& peerIds);
|
bool setFileSources(const std::list<RsPeerId>& peerIds);
|
||||||
bool addFileSource(const SSLIdType& peerId);
|
bool addFileSource(const RsPeerId& peerId);
|
||||||
bool removeFileSource(const SSLIdType& peerId);
|
bool removeFileSource(const RsPeerId& peerId);
|
||||||
bool setPeerState(const SSLIdType& peerId,uint32_t state,uint32_t maxRate); //state = ONLINE/OFFLINE
|
bool setPeerState(const RsPeerId& peerId,uint32_t state,uint32_t maxRate); //state = ONLINE/OFFLINE
|
||||||
bool getFileSources(std::list<SSLIdType> &peerIds);
|
bool getFileSources(std::list<RsPeerId> &peerIds);
|
||||||
bool getPeerState(const SSLIdType& peerId,uint32_t &state,uint32_t &tfRate);
|
bool getPeerState(const RsPeerId& peerId,uint32_t &state,uint32_t &tfRate);
|
||||||
uint32_t getDataRate(const SSLIdType& peerId);
|
uint32_t getDataRate(const RsPeerId& peerId);
|
||||||
bool cancelTransfer();
|
bool cancelTransfer();
|
||||||
bool cancelFileTransferUpward();
|
bool cancelFileTransferUpward();
|
||||||
bool completeFileTransfer();
|
bool completeFileTransfer();
|
||||||
|
@ -138,11 +138,11 @@ public:
|
||||||
void forceCheck() ;
|
void forceCheck() ;
|
||||||
|
|
||||||
//interface to multiplex module
|
//interface to multiplex module
|
||||||
bool recvFileData(const SSLIdType& peerId, uint64_t offset, uint32_t chunk_size, void *data);
|
bool recvFileData(const RsPeerId& peerId, uint64_t offset, uint32_t chunk_size, void *data);
|
||||||
void locked_requestData(const SSLIdType& peerId, uint64_t offset, uint32_t chunk_size);
|
void locked_requestData(const RsPeerId& peerId, uint64_t offset, uint32_t chunk_size);
|
||||||
|
|
||||||
//interface to file creator
|
//interface to file creator
|
||||||
bool locked_getChunk(const SSLIdType& peer_id,uint32_t size_hint,uint64_t &offset, uint32_t &chunk_size);
|
bool locked_getChunk(const RsPeerId& peer_id,uint32_t size_hint,uint64_t &offset, uint32_t &chunk_size);
|
||||||
bool locked_storeData(uint64_t offset, uint32_t chunk_size, void *data);
|
bool locked_storeData(uint64_t offset, uint32_t chunk_size, void *data);
|
||||||
|
|
||||||
int tick();
|
int tick();
|
||||||
|
@ -180,8 +180,8 @@ private:
|
||||||
|
|
||||||
RsMutex tfMtx; /* below is mutex protected */
|
RsMutex tfMtx; /* below is mutex protected */
|
||||||
|
|
||||||
std::list<SSLIdType> mOnlinePeers;
|
std::list<RsPeerId> mOnlinePeers;
|
||||||
std::map<SSLIdType,peerInfo> mFileSources;
|
std::map<RsPeerId,peerInfo> mFileSources;
|
||||||
|
|
||||||
uint16_t mFlag; //2:file canceled, 1:transfer complete, 0: not complete, 3: checking hash, 4: checking chunks
|
uint16_t mFlag; //2:file canceled, 1:transfer complete, 0: not complete, 3: checking hash, 4: checking chunks
|
||||||
double desiredRate;
|
double desiredRate;
|
||||||
|
|
|
@ -558,7 +558,7 @@ bool RsGRouterRoutingInfoItem::serialise(void *data,uint32_t& size) const
|
||||||
std::ostream& RsGRouterPublishKeyItem::print(std::ostream& o, uint16_t)
|
std::ostream& RsGRouterPublishKeyItem::print(std::ostream& o, uint16_t)
|
||||||
{
|
{
|
||||||
o << "GRouterPublishKeyItem:" << std::endl ;
|
o << "GRouterPublishKeyItem:" << std::endl ;
|
||||||
o << " POW bytes : \""<< PGPIdType(pow_bytes).toStdString() << "\"" << std::endl ;
|
o << " POW bytes : \""<< RsPgpId(pow_bytes).toStdString() << "\"" << std::endl ;
|
||||||
o << " direct origin: \""<< PeerId() << "\"" << std::endl ;
|
o << " direct origin: \""<< PeerId() << "\"" << std::endl ;
|
||||||
o << " Key: " << published_key.toStdString() << std::endl ;
|
o << " Key: " << published_key.toStdString() << std::endl ;
|
||||||
o << " Req. Id: " << std::hex << diffusion_id << std::dec << std::endl ;
|
o << " Req. Id: " << std::hex << diffusion_id << std::dec << std::endl ;
|
||||||
|
|
|
@ -207,7 +207,7 @@ class RsGRouterMatrixFriendListItem: public RsGRouterItem
|
||||||
|
|
||||||
// packet data
|
// packet data
|
||||||
//
|
//
|
||||||
std::vector<SSLIdType> reverse_friend_indices ;
|
std::vector<RsPeerId> reverse_friend_indices ;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsGRouterRoutingInfoItem: public RsGRouterItem, public GRouterRoutingInfo, public RsGRouterNonCopyableObject
|
class RsGRouterRoutingInfoItem: public RsGRouterItem, public GRouterRoutingInfo, public RsGRouterNonCopyableObject
|
||||||
|
|
|
@ -33,7 +33,7 @@ GRouterMatrix::GRouterMatrix()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GRouterMatrix::addRoutingClue( const GRouterKeyId& key_id,const GRouterServiceId& sid,float distance,
|
bool GRouterMatrix::addRoutingClue( const GRouterKeyId& key_id,const GRouterServiceId& sid,float distance,
|
||||||
const std::string& desc_string,const SSLIdType& source_friend)
|
const std::string& desc_string,const RsPeerId& source_friend)
|
||||||
{
|
{
|
||||||
// 1 - get the friend index.
|
// 1 - get the friend index.
|
||||||
//
|
//
|
||||||
|
@ -76,18 +76,18 @@ bool GRouterMatrix::addRoutingClue( const GRouterKeyId& key_id,const GRouterServ
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
uint32_t GRouterMatrix::getFriendId_const(const SSLIdType& source_friend) const
|
uint32_t GRouterMatrix::getFriendId_const(const RsPeerId& source_friend) const
|
||||||
{
|
{
|
||||||
std::map<SSLIdType,uint32_t>::const_iterator it = _friend_indices.find(source_friend) ;
|
std::map<RsPeerId,uint32_t>::const_iterator it = _friend_indices.find(source_friend) ;
|
||||||
|
|
||||||
if(it == _friend_indices.end())
|
if(it == _friend_indices.end())
|
||||||
return _reverse_friend_indices.size() ;
|
return _reverse_friend_indices.size() ;
|
||||||
else
|
else
|
||||||
return it->second ;
|
return it->second ;
|
||||||
}
|
}
|
||||||
uint32_t GRouterMatrix::getFriendId(const SSLIdType& source_friend)
|
uint32_t GRouterMatrix::getFriendId(const RsPeerId& source_friend)
|
||||||
{
|
{
|
||||||
std::map<SSLIdType,uint32_t>::const_iterator it = _friend_indices.find(source_friend) ;
|
std::map<RsPeerId,uint32_t>::const_iterator it = _friend_indices.find(source_friend) ;
|
||||||
|
|
||||||
if(it == _friend_indices.end())
|
if(it == _friend_indices.end())
|
||||||
{
|
{
|
||||||
|
@ -130,7 +130,7 @@ void GRouterMatrix::debugDump() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GRouterMatrix::computeRoutingProbabilities(const GRouterKeyId& key_id, const std::list<SSLIdType>& friends, std::map<SSLIdType,float>& probas) const
|
bool GRouterMatrix::computeRoutingProbabilities(const GRouterKeyId& key_id, const std::list<RsPeerId>& friends, std::map<RsPeerId,float>& probas) const
|
||||||
{
|
{
|
||||||
// Routing probabilities are computed according to routing clues
|
// Routing probabilities are computed according to routing clues
|
||||||
//
|
//
|
||||||
|
@ -156,7 +156,7 @@ bool GRouterMatrix::computeRoutingProbabilities(const GRouterKeyId& key_id, cons
|
||||||
}
|
}
|
||||||
const std::vector<float>& w(it2->second) ;
|
const std::vector<float>& w(it2->second) ;
|
||||||
|
|
||||||
for(std::list<SSLIdType>::const_iterator it(friends.begin());it!=friends.end();++it)
|
for(std::list<RsPeerId>::const_iterator it(friends.begin());it!=friends.end();++it)
|
||||||
{
|
{
|
||||||
uint32_t findex = getFriendId_const(*it) ;
|
uint32_t findex = getFriendId_const(*it) ;
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ bool GRouterMatrix::computeRoutingProbabilities(const GRouterKeyId& key_id, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
if(total > 0.0f)
|
if(total > 0.0f)
|
||||||
for(std::map<SSLIdType,float>::iterator it(probas.begin());it!=probas.end();++it)
|
for(std::map<RsPeerId,float>::iterator it(probas.begin());it!=probas.end();++it)
|
||||||
it->second /= total ;
|
it->second /= total ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
|
|
|
@ -51,7 +51,7 @@ class GRouterMatrix
|
||||||
// the computation accounts for the time at which the info was received and the
|
// the computation accounts for the time at which the info was received and the
|
||||||
// weight of each routing hit record.
|
// weight of each routing hit record.
|
||||||
//
|
//
|
||||||
bool computeRoutingProbabilities(const GRouterKeyId& id, const std::list<SSLIdType>& friends, std::map<SSLIdType,float>& probas) const ;
|
bool computeRoutingProbabilities(const GRouterKeyId& id, const std::list<RsPeerId>& friends, std::map<RsPeerId,float>& probas) const ;
|
||||||
|
|
||||||
// Update routing probabilities for each key, accounting for all received events, but without
|
// Update routing probabilities for each key, accounting for all received events, but without
|
||||||
// activity information
|
// activity information
|
||||||
|
@ -60,7 +60,7 @@ class GRouterMatrix
|
||||||
|
|
||||||
// Record one routing clue. The events can possibly be merged in time buckets.
|
// Record one routing clue. The events can possibly be merged in time buckets.
|
||||||
//
|
//
|
||||||
bool addRoutingClue(const GRouterKeyId& id,const GRouterServiceId& sid,float distance,const std::string& desc_string,const SSLIdType& source_friend) ;
|
bool addRoutingClue(const GRouterKeyId& id,const GRouterServiceId& sid,float distance,const std::string& desc_string,const RsPeerId& source_friend) ;
|
||||||
|
|
||||||
// Dump info in terminal.
|
// Dump info in terminal.
|
||||||
//
|
//
|
||||||
|
@ -72,11 +72,11 @@ class GRouterMatrix
|
||||||
private:
|
private:
|
||||||
// returns the friend id, possibly creating a new id.
|
// returns the friend id, possibly creating a new id.
|
||||||
//
|
//
|
||||||
uint32_t getFriendId(const SSLIdType& id) ;
|
uint32_t getFriendId(const RsPeerId& id) ;
|
||||||
|
|
||||||
// returns the friend id. If not exist, returns _reverse_friend_indices.size()
|
// returns the friend id. If not exist, returns _reverse_friend_indices.size()
|
||||||
//
|
//
|
||||||
uint32_t getFriendId_const(const SSLIdType& id) const;
|
uint32_t getFriendId_const(const RsPeerId& id) const;
|
||||||
|
|
||||||
// List of events received and computed routing probabilities
|
// List of events received and computed routing probabilities
|
||||||
//
|
//
|
||||||
|
@ -90,8 +90,8 @@ class GRouterMatrix
|
||||||
// Routing weights. These are the result of a time convolution of the routing clues and weights
|
// Routing weights. These are the result of a time convolution of the routing clues and weights
|
||||||
// recorded in _routing_clues.
|
// recorded in _routing_clues.
|
||||||
//
|
//
|
||||||
std::map<SSLIdType,uint32_t> _friend_indices ; // index for each friend to lookup in the routing matrix Not saved.
|
std::map<RsPeerId,uint32_t> _friend_indices ; // index for each friend to lookup in the routing matrix Not saved.
|
||||||
std::vector<SSLIdType> _reverse_friend_indices ;// SSLid corresponding to each friend index. Saved.
|
std::vector<RsPeerId> _reverse_friend_indices ;// SSLid corresponding to each friend index. Saved.
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ class GRouterPublishedKeyInfo
|
||||||
|
|
||||||
struct FriendTrialRecord
|
struct FriendTrialRecord
|
||||||
{
|
{
|
||||||
SSLIdType friend_id ; // id of the friend
|
RsPeerId friend_id ; // id of the friend
|
||||||
time_t time_stamp ; // time of the last tried
|
time_t time_stamp ; // time of the last tried
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class GRouterRoutingInfo
|
||||||
|
|
||||||
uint32_t status_flags ; // pending, waiting, etc.
|
uint32_t status_flags ; // pending, waiting, etc.
|
||||||
std::list<FriendTrialRecord> tried_friends ; // list of friends to which the item was sent ordered with time.
|
std::list<FriendTrialRecord> tried_friends ; // list of friends to which the item was sent ordered with time.
|
||||||
SSLIdType origin ; // which friend sent us that item
|
RsPeerId origin ; // which friend sent us that item
|
||||||
time_t received_time ; // time at which the item was received
|
time_t received_time ; // time at which the item was received
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -176,12 +176,12 @@ void p3GRouter::routePendingObjects()
|
||||||
std::cerr << "Cached Items : " << _pending_messages.size() << std::endl;
|
std::cerr << "Cached Items : " << _pending_messages.size() << std::endl;
|
||||||
|
|
||||||
std::list<std::string> lst_tmp ;
|
std::list<std::string> lst_tmp ;
|
||||||
std::list<SSLIdType> lst ;
|
std::list<RsPeerId> lst ;
|
||||||
mLinkMgr->getOnlineList(lst_tmp) ;
|
mLinkMgr->getOnlineList(lst_tmp) ;
|
||||||
SSLIdType own_id( mLinkMgr->getOwnId() );
|
RsPeerId own_id( mLinkMgr->getOwnId() );
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator it(lst_tmp.begin());it!=lst_tmp.end();++it)
|
for(std::list<std::string>::const_iterator it(lst_tmp.begin());it!=lst_tmp.end();++it)
|
||||||
lst.push_back(SSLIdType(*it)) ;
|
lst.push_back(RsPeerId(*it)) ;
|
||||||
|
|
||||||
for(std::map<GRouterMsgPropagationId, GRouterRoutingInfo>::iterator it(_pending_messages.begin());it!=_pending_messages.end();)
|
for(std::map<GRouterMsgPropagationId, GRouterRoutingInfo>::iterator it(_pending_messages.begin());it!=_pending_messages.end();)
|
||||||
if((it->second.status_flags & RS_GROUTER_ROUTING_STATE_PEND) || (it->second.status_flags == RS_GROUTER_ROUTING_STATE_SENT && it->second.tried_friends.front().time_stamp+RS_GROUTER_ROUTING_WAITING_TIME < now))
|
if((it->second.status_flags & RS_GROUTER_ROUTING_STATE_PEND) || (it->second.status_flags == RS_GROUTER_ROUTING_STATE_SENT && it->second.tried_friends.front().time_stamp+RS_GROUTER_ROUTING_WAITING_TIME < now))
|
||||||
|
@ -193,8 +193,8 @@ void p3GRouter::routePendingObjects()
|
||||||
std::cerr << " Flags : " << it->second.status_flags << std::endl;
|
std::cerr << " Flags : " << it->second.status_flags << std::endl;
|
||||||
std::cerr << " Probabilities: " << std::endl;
|
std::cerr << " Probabilities: " << std::endl;
|
||||||
|
|
||||||
std::map<SSLIdType,float> probas ; // friends probabilities for online friend list.
|
std::map<RsPeerId,float> probas ; // friends probabilities for online friend list.
|
||||||
SSLIdType routed_friend ; // friend chosen for the next hop
|
RsPeerId routed_friend ; // friend chosen for the next hop
|
||||||
float best_proba = 0.0f; // temp variable used to select the best proba
|
float best_proba = 0.0f; // temp variable used to select the best proba
|
||||||
bool should_remove = false ; // should we remove this from the map?
|
bool should_remove = false ; // should we remove this from the map?
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ void p3GRouter::routePendingObjects()
|
||||||
|
|
||||||
bool friend_found = false ;
|
bool friend_found = false ;
|
||||||
|
|
||||||
for(std::map<SSLIdType,float>::const_iterator it2(probas.begin());it2!=probas.end();++it2)
|
for(std::map<RsPeerId,float>::const_iterator it2(probas.begin());it2!=probas.end();++it2)
|
||||||
{
|
{
|
||||||
std::cerr << " " << it2->first.toStdString() << " : " << it2->second << std::endl;
|
std::cerr << " " << it2->first.toStdString() << " : " << it2->second << std::endl;
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ void p3GRouter::handleRecvPublishKeyItem(RsGRouterPublishKeyItem *item)
|
||||||
|
|
||||||
// update the route matrix
|
// update the route matrix
|
||||||
|
|
||||||
_routing_matrix.addRoutingClue(item->published_key,item->service_id,item->randomized_distance,item->description_string,SSLIdType(item->PeerId())) ;
|
_routing_matrix.addRoutingClue(item->published_key,item->service_id,item->randomized_distance,item->description_string,RsPeerId(item->PeerId())) ;
|
||||||
|
|
||||||
// forward the key to other peers according to key forwarding cache
|
// forward the key to other peers according to key forwarding cache
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ void p3GRouter::handleRecvDataItem(RsGRouterGenericDataItem *item)
|
||||||
else
|
else
|
||||||
info.status_flags = RS_GROUTER_ROUTING_STATE_PEND ;
|
info.status_flags = RS_GROUTER_ROUTING_STATE_PEND ;
|
||||||
|
|
||||||
info.origin = SSLIdType(item->PeerId()) ;
|
info.origin = RsPeerId(item->PeerId()) ;
|
||||||
info.received_time = time(NULL) ;
|
info.received_time = time(NULL) ;
|
||||||
|
|
||||||
_pending_messages[item->routing_id] = info ;
|
_pending_messages[item->routing_id] = info ;
|
||||||
|
@ -588,7 +588,7 @@ void p3GRouter::sendData(const GRouterKeyId& destination, RsGRouterGenericDataIt
|
||||||
|
|
||||||
info.data_item = item ;
|
info.data_item = item ;
|
||||||
info.status_flags = RS_GROUTER_ROUTING_STATE_PEND ;
|
info.status_flags = RS_GROUTER_ROUTING_STATE_PEND ;
|
||||||
info.origin = SSLIdType(mLinkMgr->getOwnId()) ;
|
info.origin = RsPeerId(mLinkMgr->getOwnId()) ;
|
||||||
info.received_time = time(NULL) ;
|
info.received_time = time(NULL) ;
|
||||||
|
|
||||||
// Make sure we have a unique id (at least locally).
|
// Make sure we have a unique id (at least locally).
|
||||||
|
@ -606,7 +606,7 @@ void p3GRouter::sendData(const GRouterKeyId& destination, RsGRouterGenericDataIt
|
||||||
_pending_messages[propagation_id] = info ;
|
_pending_messages[propagation_id] = info ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3GRouter::sendACK(const SSLIdType& peer, GRouterMsgPropagationId mid, uint32_t ack_flags)
|
void p3GRouter::sendACK(const RsPeerId& peer, GRouterMsgPropagationId mid, uint32_t ack_flags)
|
||||||
{
|
{
|
||||||
RsGRouterACKItem *item = new RsGRouterACKItem ;
|
RsGRouterACKItem *item = new RsGRouterACKItem ;
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
||||||
// Sends an ACK to the origin of the msg. This is used to notify for
|
// Sends an ACK to the origin of the msg. This is used to notify for
|
||||||
// unfound route, or message correctly received, depending on the particular situation.
|
// unfound route, or message correctly received, depending on the particular situation.
|
||||||
//
|
//
|
||||||
void sendACK(const SSLIdType& peer,GRouterMsgPropagationId mid, uint32_t flags) ;
|
void sendACK(const RsPeerId& peer,GRouterMsgPropagationId mid, uint32_t flags) ;
|
||||||
|
|
||||||
//===================================================//
|
//===================================================//
|
||||||
// Interface with RsGRouter //
|
// Interface with RsGRouter //
|
||||||
|
|
|
@ -237,7 +237,7 @@ bool GrpCircleVetting::canSend(const SSLIdType& peerId, const RsGxsCircleId& cir
|
||||||
{
|
{
|
||||||
if(mCircles->isLoaded(circleId))
|
if(mCircles->isLoaded(circleId))
|
||||||
{
|
{
|
||||||
const PGPIdType& pgpId = rsPeers->getGPGId(peerId);
|
const RsPgpId& pgpId = rsPeers->getGPGId(peerId);
|
||||||
return mCircles->canSend(circleId, pgpId);
|
return mCircles->canSend(circleId, pgpId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,7 @@ public:
|
||||||
virtual bool cleared() = 0;
|
virtual bool cleared() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool canSend(const SSLIdType& peerId, const RsGxsCircleId& circleId);
|
bool canSend(const RsPeerId& peerId, const RsGxsCircleId& circleId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ ops_parse_cb_return_t cb_get_passphrase(const ops_parser_content_t *content_,ops
|
||||||
|
|
||||||
if(cbinfo->cryptinfo.keydata->nuids > 0)
|
if(cbinfo->cryptinfo.keydata->nuids > 0)
|
||||||
uid_hint = std::string((const char *)cbinfo->cryptinfo.keydata->uids[0].user_id) ;
|
uid_hint = std::string((const char *)cbinfo->cryptinfo.keydata->uids[0].user_id) ;
|
||||||
uid_hint += "(" + PGPIdType(cbinfo->cryptinfo.keydata->key_id).toStdString()+")" ;
|
uid_hint += "(" + RsPgpId(cbinfo->cryptinfo.keydata->key_id).toStdString()+")" ;
|
||||||
|
|
||||||
passwd = PGPHandler::passphraseCallback()(NULL,uid_hint.c_str(),NULL,prev_was_bad) ;
|
passwd = PGPHandler::passphraseCallback()(NULL,uid_hint.c_str(),NULL,prev_was_bad) ;
|
||||||
*(content->secret_key_passphrase.passphrase)= (char *)ops_mallocz(passwd.length()+1) ;
|
*(content->secret_key_passphrase.passphrase)= (char *)ops_mallocz(passwd.length()+1) ;
|
||||||
|
@ -126,7 +126,7 @@ PGPHandler::PGPHandler(const std::string& pubring, const std::string& secring,co
|
||||||
int i=0 ;
|
int i=0 ;
|
||||||
while( (keydata = ops_keyring_get_key_by_index(_pubring,i)) != NULL )
|
while( (keydata = ops_keyring_get_key_by_index(_pubring,i)) != NULL )
|
||||||
{
|
{
|
||||||
PGPCertificateInfo& cert(_public_keyring_map[ PGPIdType(keydata->key_id) ]) ;
|
PGPCertificateInfo& cert(_public_keyring_map[ RsPgpId(keydata->key_id) ]) ;
|
||||||
|
|
||||||
// Init all certificates.
|
// Init all certificates.
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ PGPHandler::PGPHandler(const std::string& pubring, const std::string& secring,co
|
||||||
i=0 ;
|
i=0 ;
|
||||||
while( (keydata = ops_keyring_get_key_by_index(_secring,i)) != NULL )
|
while( (keydata = ops_keyring_get_key_by_index(_secring,i)) != NULL )
|
||||||
{
|
{
|
||||||
initCertificateInfo(_secret_keyring_map[ PGPIdType(keydata->key_id) ],keydata,i) ;
|
initCertificateInfo(_secret_keyring_map[ RsPgpId(keydata->key_id) ],keydata,i) ;
|
||||||
++i ;
|
++i ;
|
||||||
}
|
}
|
||||||
_secring_last_update_time = time(NULL) ;
|
_secring_last_update_time = time(NULL) ;
|
||||||
|
@ -246,7 +246,7 @@ bool PGPHandler::validateAndUpdateSignatures(PGPCertificateInfo& cert,const ops_
|
||||||
if(result != NULL)
|
if(result != NULL)
|
||||||
for(size_t i=0;i<result->valid_count;++i)
|
for(size_t i=0;i<result->valid_count;++i)
|
||||||
{
|
{
|
||||||
PGPIdType signer_id(result->valid_sigs[i].signer_id);
|
RsPgpId signer_id(result->valid_sigs[i].signer_id);
|
||||||
|
|
||||||
if(cert.signers.find(signer_id) == cert.signers.end())
|
if(cert.signers.find(signer_id) == cert.signers.end())
|
||||||
{
|
{
|
||||||
|
@ -282,7 +282,7 @@ bool PGPHandler::printKeys() const
|
||||||
std::cerr << "Printing details of all " << std::dec << _public_keyring_map.size() << " keys: " << std::endl;
|
std::cerr << "Printing details of all " << std::dec << _public_keyring_map.size() << " keys: " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(std::map<PGPIdType,PGPCertificateInfo>::const_iterator it(_public_keyring_map.begin()); it != _public_keyring_map.end(); it++)
|
for(std::map<RsPgpId,PGPCertificateInfo>::const_iterator it(_public_keyring_map.begin()); it != _public_keyring_map.end(); it++)
|
||||||
{
|
{
|
||||||
std::cerr << "PGP Key: " << it->first.toStdString() << std::endl;
|
std::cerr << "PGP Key: " << it->first.toStdString() << std::endl;
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ bool PGPHandler::printKeys() const
|
||||||
std::cerr << "\tfingerprint : " << it->second._fpr.toStdString() << std::endl;
|
std::cerr << "\tfingerprint : " << it->second._fpr.toStdString() << std::endl;
|
||||||
std::cerr << "\tSigners : " << it->second.signers.size() << std::endl;
|
std::cerr << "\tSigners : " << it->second.signers.size() << std::endl;
|
||||||
|
|
||||||
std::set<PGPIdType>::const_iterator sit;
|
std::set<RsPgpId>::const_iterator sit;
|
||||||
for(sit = it->second.signers.begin(); sit != it->second.signers.end(); sit++)
|
for(sit = it->second.signers.begin(); sit != it->second.signers.end(); sit++)
|
||||||
{
|
{
|
||||||
std::cerr << "\t\tSigner ID:" << (*sit).toStdString() << ", Name: " ;
|
std::cerr << "\t\tSigner ID:" << (*sit).toStdString() << ", Name: " ;
|
||||||
|
@ -314,18 +314,18 @@ bool PGPHandler::printKeys() const
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::haveSecretKey(const PGPIdType& id) const
|
bool PGPHandler::haveSecretKey(const RsPgpId& id) const
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
return locked_getSecretKey(id) != NULL ;
|
return locked_getSecretKey(id) != NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PGPCertificateInfo *PGPHandler::getCertificateInfo(const PGPIdType& id) const
|
const PGPCertificateInfo *PGPHandler::getCertificateInfo(const RsPgpId& id) const
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
std::map<PGPIdType,PGPCertificateInfo>::const_iterator it( _public_keyring_map.find(id) ) ;
|
std::map<RsPgpId,PGPCertificateInfo>::const_iterator it( _public_keyring_map.find(id) ) ;
|
||||||
|
|
||||||
if(it != _public_keyring_map.end())
|
if(it != _public_keyring_map.end())
|
||||||
return &it->second;
|
return &it->second;
|
||||||
|
@ -333,7 +333,7 @@ const PGPCertificateInfo *PGPHandler::getCertificateInfo(const PGPIdType& id) co
|
||||||
return NULL ;
|
return NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::availableGPGCertificatesWithPrivateKeys(std::list<PGPIdType>& ids)
|
bool PGPHandler::availableGPGCertificatesWithPrivateKeys(std::list<RsPgpId>& ids)
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
// go through secret keyring, and check that we have the pubkey as well.
|
// go through secret keyring, and check that we have the pubkey as well.
|
||||||
|
@ -350,17 +350,17 @@ bool PGPHandler::availableGPGCertificatesWithPrivateKeys(std::list<PGPIdType>& i
|
||||||
#else
|
#else
|
||||||
if(keydata->key.pkey.algorithm == OPS_PKA_RSA)
|
if(keydata->key.pkey.algorithm == OPS_PKA_RSA)
|
||||||
#endif
|
#endif
|
||||||
ids.push_back(PGPIdType(keydata->key_id)) ;
|
ids.push_back(RsPgpId(keydata->key_id)) ;
|
||||||
#ifdef DEBUG_PGPHANDLER
|
#ifdef DEBUG_PGPHANDLER
|
||||||
else
|
else
|
||||||
std::cerr << "Skipping keypair " << PGPIdType(keydata->key_id).toStdString() << ", unsupported algorithm: " << keydata->key.pkey.algorithm << std::endl;
|
std::cerr << "Skipping keypair " << RsPgpId(keydata->key_id).toStdString() << ", unsupported algorithm: " << keydata->key.pkey.algorithm << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passphrase, PGPIdType& pgpId, std::string& errString)
|
bool PGPHandler::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passphrase, RsPgpId& pgpId, std::string& errString)
|
||||||
{
|
{
|
||||||
// Some basic checks
|
// Some basic checks
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ bool PGPHandler::GeneratePGPCertificate(const std::string& name, const std::stri
|
||||||
|
|
||||||
// 4 - copy the encrypted private key to the private keyring
|
// 4 - copy the encrypted private key to the private keyring
|
||||||
|
|
||||||
pgpId = PGPIdType(tmp_secring->keys[0].key_id) ;
|
pgpId = RsPgpId(tmp_secring->keys[0].key_id) ;
|
||||||
addNewKeyToOPSKeyring(_secring,tmp_secring->keys[0]) ;
|
addNewKeyToOPSKeyring(_secring,tmp_secring->keys[0]) ;
|
||||||
initCertificateInfo(_secret_keyring_map[ pgpId ],&tmp_secring->keys[0],_secring->nkeys-1) ;
|
initCertificateInfo(_secret_keyring_map[ pgpId ],&tmp_secring->keys[0],_secring->nkeys-1) ;
|
||||||
|
|
||||||
|
@ -546,18 +546,18 @@ std::string PGPHandler::makeRadixEncodedPGPKey(const ops_keydata_t *key,bool inc
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ops_keydata_t *PGPHandler::locked_getSecretKey(const PGPIdType& id) const
|
const ops_keydata_t *PGPHandler::locked_getSecretKey(const RsPgpId& id) const
|
||||||
{
|
{
|
||||||
std::map<PGPIdType,PGPCertificateInfo>::const_iterator res = _secret_keyring_map.find(id) ;
|
std::map<RsPgpId,PGPCertificateInfo>::const_iterator res = _secret_keyring_map.find(id) ;
|
||||||
|
|
||||||
if(res == _secret_keyring_map.end())
|
if(res == _secret_keyring_map.end())
|
||||||
return NULL ;
|
return NULL ;
|
||||||
else
|
else
|
||||||
return ops_keyring_get_key_by_index(_secring,res->second._key_index) ;
|
return ops_keyring_get_key_by_index(_secring,res->second._key_index) ;
|
||||||
}
|
}
|
||||||
const ops_keydata_t *PGPHandler::locked_getPublicKey(const PGPIdType& id,bool stamp_the_key) const
|
const ops_keydata_t *PGPHandler::locked_getPublicKey(const RsPgpId& id,bool stamp_the_key) const
|
||||||
{
|
{
|
||||||
std::map<PGPIdType,PGPCertificateInfo>::const_iterator res = _public_keyring_map.find(id) ;
|
std::map<RsPgpId,PGPCertificateInfo>::const_iterator res = _public_keyring_map.find(id) ;
|
||||||
|
|
||||||
if(res == _public_keyring_map.end())
|
if(res == _public_keyring_map.end())
|
||||||
return NULL ;
|
return NULL ;
|
||||||
|
@ -580,7 +580,7 @@ const ops_keydata_t *PGPHandler::locked_getPublicKey(const PGPIdType& id,bool st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PGPHandler::SaveCertificateToString(const PGPIdType& id,bool include_signatures) const
|
std::string PGPHandler::SaveCertificateToString(const RsPgpId& id,bool include_signatures) const
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
const ops_keydata_t *key = locked_getPublicKey(id,false) ;
|
const ops_keydata_t *key = locked_getPublicKey(id,false) ;
|
||||||
|
@ -594,7 +594,7 @@ std::string PGPHandler::SaveCertificateToString(const PGPIdType& id,bool include
|
||||||
return makeRadixEncodedPGPKey(key,include_signatures) ;
|
return makeRadixEncodedPGPKey(key,include_signatures) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::exportPublicKey(const PGPIdType& id,unsigned char *& mem_block,size_t& mem_size,bool armoured,bool include_signatures) const
|
bool PGPHandler::exportPublicKey(const RsPgpId& id,unsigned char *& mem_block,size_t& mem_size,bool armoured,bool include_signatures) const
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
const ops_keydata_t *key = locked_getPublicKey(id,false) ;
|
const ops_keydata_t *key = locked_getPublicKey(id,false) ;
|
||||||
|
@ -640,7 +640,7 @@ bool PGPHandler::exportPublicKey(const PGPIdType& id,unsigned char *& mem_block,
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::exportGPGKeyPair(const std::string& filename,const PGPIdType& exported_key_id) const
|
bool PGPHandler::exportGPGKeyPair(const std::string& filename,const RsPgpId& exported_key_id) const
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ bool PGPHandler::exportGPGKeyPair(const std::string& filename,const PGPIdType& e
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::getGPGDetailsFromBinaryBlock(const unsigned char *mem_block,size_t mem_size,PGPIdType& key_id, std::string& name, std::list<PGPIdType>& signers) const
|
bool PGPHandler::getGPGDetailsFromBinaryBlock(const unsigned char *mem_block,size_t mem_size,RsPgpId& key_id, std::string& name, std::list<RsPgpId>& signers) const
|
||||||
{
|
{
|
||||||
ops_keyring_t *tmp_keyring = allocateOPSKeyring();
|
ops_keyring_t *tmp_keyring = allocateOPSKeyring();
|
||||||
ops_memory_t *mem = ops_memory_new() ;
|
ops_memory_t *mem = ops_memory_new() ;
|
||||||
|
@ -705,7 +705,7 @@ bool PGPHandler::getGPGDetailsFromBinaryBlock(const unsigned char *mem_block,siz
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
key_id = PGPIdType(tmp_keyring->keys[0].key_id) ;
|
key_id = RsPgpId(tmp_keyring->keys[0].key_id) ;
|
||||||
name = std::string((char *)tmp_keyring->keys[0].uids[0].user_id) ;
|
name = std::string((char *)tmp_keyring->keys[0].uids[0].user_id) ;
|
||||||
|
|
||||||
// now parse signatures.
|
// now parse signatures.
|
||||||
|
@ -731,11 +731,11 @@ bool PGPHandler::getGPGDetailsFromBinaryBlock(const unsigned char *mem_block,siz
|
||||||
// Parse signers.
|
// Parse signers.
|
||||||
//
|
//
|
||||||
|
|
||||||
std::set<PGPIdType> signers_set ; // Use a set to remove duplicates.
|
std::set<RsPgpId> signers_set ; // Use a set to remove duplicates.
|
||||||
|
|
||||||
if(result != NULL)
|
if(result != NULL)
|
||||||
for(size_t i=0;i<result->valid_count;++i)
|
for(size_t i=0;i<result->valid_count;++i)
|
||||||
signers_set.insert(PGPIdType(result->valid_sigs[i].signer_id)) ;
|
signers_set.insert(RsPgpId(result->valid_sigs[i].signer_id)) ;
|
||||||
|
|
||||||
ops_validate_result_free(result) ;
|
ops_validate_result_free(result) ;
|
||||||
|
|
||||||
|
@ -746,13 +746,13 @@ bool PGPHandler::getGPGDetailsFromBinaryBlock(const unsigned char *mem_block,siz
|
||||||
|
|
||||||
signers.clear() ;
|
signers.clear() ;
|
||||||
|
|
||||||
for(std::set<PGPIdType>::const_iterator it(signers_set.begin());it!=signers_set.end();++it)
|
for(std::set<RsPgpId>::const_iterator it(signers_set.begin());it!=signers_set.end();++it)
|
||||||
signers.push_back(*it) ;
|
signers.push_back(*it) ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::importGPGKeyPair(const std::string& filename,PGPIdType& imported_key_id,std::string& import_error)
|
bool PGPHandler::importGPGKeyPair(const std::string& filename,RsPgpId& imported_key_id,std::string& import_error)
|
||||||
{
|
{
|
||||||
import_error = "" ;
|
import_error = "" ;
|
||||||
|
|
||||||
|
@ -866,7 +866,7 @@ bool PGPHandler::importGPGKeyPair(const std::string& filename,PGPIdType& importe
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
imported_key_id = PGPIdType(pubkey->key_id) ;
|
imported_key_id = RsPgpId(pubkey->key_id) ;
|
||||||
|
|
||||||
if(locked_getSecretKey(imported_key_id) == NULL)
|
if(locked_getSecretKey(imported_key_id) == NULL)
|
||||||
{
|
{
|
||||||
|
@ -934,7 +934,7 @@ void PGPHandler::addNewKeyToOPSKeyring(ops_keyring_t *kr,const ops_keydata_t& ke
|
||||||
kr->nkeys++ ;
|
kr->nkeys++ ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::LoadCertificateFromString(const std::string& pgp_cert,PGPIdType& id,std::string& error_string)
|
bool PGPHandler::LoadCertificateFromString(const std::string& pgp_cert,RsPgpId& id,std::string& error_string)
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
#ifdef DEBUG_PGPHANDLER
|
#ifdef DEBUG_PGPHANDLER
|
||||||
|
@ -1028,7 +1028,7 @@ bool PGPHandler::LoadCertificateFromString(const std::string& pgp_cert,PGPIdType
|
||||||
std::cerr << "Key already in public keyring." << std::endl;
|
std::cerr << "Key already in public keyring." << std::endl;
|
||||||
|
|
||||||
if(tmp_keyring->nkeys > 0)
|
if(tmp_keyring->nkeys > 0)
|
||||||
id = PGPIdType(tmp_keyring->keys[0].key_id) ;
|
id = RsPgpId(tmp_keyring->keys[0].key_id) ;
|
||||||
else
|
else
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
|
@ -1040,10 +1040,10 @@ bool PGPHandler::LoadCertificateFromString(const std::string& pgp_cert,PGPIdType
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::locked_addOrMergeKey(ops_keyring_t *keyring,std::map<PGPIdType,PGPCertificateInfo>& kmap,const ops_keydata_t *keydata)
|
bool PGPHandler::locked_addOrMergeKey(ops_keyring_t *keyring,std::map<RsPgpId,PGPCertificateInfo>& kmap,const ops_keydata_t *keydata)
|
||||||
{
|
{
|
||||||
bool ret = false ;
|
bool ret = false ;
|
||||||
PGPIdType id(keydata->key_id) ;
|
RsPgpId id(keydata->key_id) ;
|
||||||
|
|
||||||
#ifdef DEBUG_PGPHANDLER
|
#ifdef DEBUG_PGPHANDLER
|
||||||
std::cerr << "AddOrMergeKey():" << std::endl;
|
std::cerr << "AddOrMergeKey():" << std::endl;
|
||||||
|
@ -1052,7 +1052,7 @@ bool PGPHandler::locked_addOrMergeKey(ops_keyring_t *keyring,std::map<PGPIdType,
|
||||||
|
|
||||||
// See if the key is already in the keyring
|
// See if the key is already in the keyring
|
||||||
const ops_keydata_t *existing_key = NULL;
|
const ops_keydata_t *existing_key = NULL;
|
||||||
std::map<PGPIdType,PGPCertificateInfo>::const_iterator res = kmap.find(id) ;
|
std::map<RsPgpId,PGPCertificateInfo>::const_iterator res = kmap.find(id) ;
|
||||||
|
|
||||||
// Checks that
|
// Checks that
|
||||||
// - the key is referenced by keyid
|
// - the key is referenced by keyid
|
||||||
|
@ -1094,7 +1094,7 @@ bool PGPHandler::locked_addOrMergeKey(ops_keyring_t *keyring,std::map<PGPIdType,
|
||||||
|
|
||||||
return ret ;
|
return ret ;
|
||||||
}
|
}
|
||||||
// bool PGPHandler::encryptTextToString(const PGPIdType& key_id,const std::string& text,std::string& outstring)
|
// bool PGPHandler::encryptTextToString(const RsPgpId& key_id,const std::string& text,std::string& outstring)
|
||||||
// {
|
// {
|
||||||
// RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
// RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
//
|
//
|
||||||
|
@ -1125,7 +1125,7 @@ bool PGPHandler::locked_addOrMergeKey(ops_keyring_t *keyring,std::map<PGPIdType,
|
||||||
//
|
//
|
||||||
// return true ;
|
// return true ;
|
||||||
// }
|
// }
|
||||||
bool PGPHandler::encryptTextToFile(const PGPIdType& key_id,const std::string& text,const std::string& outfile)
|
bool PGPHandler::encryptTextToFile(const RsPgpId& key_id,const std::string& text,const std::string& outfile)
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
|
@ -1172,7 +1172,7 @@ bool PGPHandler::encryptTextToFile(const PGPIdType& key_id,const std::string& te
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::encryptDataBin(const PGPIdType& key_id,const void *data, const uint32_t len, unsigned char *encrypted_data, unsigned int *encrypted_data_len)
|
bool PGPHandler::encryptDataBin(const RsPgpId& key_id,const void *data, const uint32_t len, unsigned char *encrypted_data, unsigned int *encrypted_data_len)
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
|
@ -1232,7 +1232,7 @@ bool PGPHandler::encryptDataBin(const PGPIdType& key_id,const void *data, const
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::decryptDataBin(const PGPIdType& /*key_id*/,const void *encrypted_data, const uint32_t encrypted_len, unsigned char *data, unsigned int *data_len)
|
bool PGPHandler::decryptDataBin(const RsPgpId& /*key_id*/,const void *encrypted_data, const uint32_t encrypted_len, unsigned char *data, unsigned int *data_len)
|
||||||
{
|
{
|
||||||
int out_length ;
|
int out_length ;
|
||||||
unsigned char *out ;
|
unsigned char *out ;
|
||||||
|
@ -1251,7 +1251,7 @@ bool PGPHandler::decryptDataBin(const PGPIdType& /*key_id*/,const void *encrypte
|
||||||
return (bool)res ;
|
return (bool)res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::decryptTextFromFile(const PGPIdType&,std::string& text,const std::string& inputfile)
|
bool PGPHandler::decryptTextFromFile(const RsPgpId&,std::string& text,const std::string& inputfile)
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
|
@ -1285,7 +1285,7 @@ bool PGPHandler::decryptTextFromFile(const PGPIdType&,std::string& text,const st
|
||||||
return (bool)res ;
|
return (bool)res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::SignDataBin(const PGPIdType& id,const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,bool use_raw_signature)
|
bool PGPHandler::SignDataBin(const RsPgpId& id,const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,bool use_raw_signature)
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
// need to find the key and to decrypt it.
|
// need to find the key and to decrypt it.
|
||||||
|
@ -1301,7 +1301,7 @@ bool PGPHandler::SignDataBin(const PGPIdType& id,const void *data, const uint32_
|
||||||
std::string uid_hint ;
|
std::string uid_hint ;
|
||||||
if(key->nuids > 0)
|
if(key->nuids > 0)
|
||||||
uid_hint = std::string((const char *)key->uids[0].user_id) ;
|
uid_hint = std::string((const char *)key->uids[0].user_id) ;
|
||||||
uid_hint += "(" + PGPIdType(key->key_id).toStdString()+")" ;
|
uid_hint += "(" + RsPgpId(key->key_id).toStdString()+")" ;
|
||||||
|
|
||||||
#ifdef DEBUG_PGPHANDLER
|
#ifdef DEBUG_PGPHANDLER
|
||||||
ops_fingerprint_t f ;
|
ops_fingerprint_t f ;
|
||||||
|
@ -1360,7 +1360,7 @@ bool PGPHandler::SignDataBin(const PGPIdType& id,const void *data, const uint32_
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::privateSignCertificate(const PGPIdType& ownId,const PGPIdType& id_of_key_to_sign)
|
bool PGPHandler::privateSignCertificate(const RsPgpId& ownId,const RsPgpId& id_of_key_to_sign)
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
|
@ -1389,7 +1389,7 @@ bool PGPHandler::privateSignCertificate(const PGPIdType& ownId,const PGPIdType&
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string passphrase = _passphrase_callback(NULL,PGPIdType(skey->key_id).toStdString().c_str(),"Please enter passwd for encrypting your key : ",false) ;
|
std::string passphrase = _passphrase_callback(NULL,RsPgpId(skey->key_id).toStdString().c_str(),"Please enter passwd for encrypting your key : ",false) ;
|
||||||
|
|
||||||
ops_secret_key_t *secret_key = ops_decrypt_secret_key_from_data(skey,passphrase.c_str()) ;
|
ops_secret_key_t *secret_key = ops_decrypt_secret_key_from_data(skey,passphrase.c_str()) ;
|
||||||
|
|
||||||
|
@ -1423,7 +1423,7 @@ bool PGPHandler::privateSignCertificate(const PGPIdType& ownId,const PGPIdType&
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PGPHandler::updateOwnSignatureFlag(const PGPIdType& own_id)
|
void PGPHandler::updateOwnSignatureFlag(const RsPgpId& own_id)
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
|
@ -1436,14 +1436,14 @@ void PGPHandler::updateOwnSignatureFlag(const PGPIdType& own_id)
|
||||||
|
|
||||||
PGPCertificateInfo& own_cert(_public_keyring_map[ own_id ]) ;
|
PGPCertificateInfo& own_cert(_public_keyring_map[ own_id ]) ;
|
||||||
|
|
||||||
for(std::map<PGPIdType,PGPCertificateInfo>::iterator it=_public_keyring_map.begin();it!=_public_keyring_map.end();++it)
|
for(std::map<RsPgpId,PGPCertificateInfo>::iterator it=_public_keyring_map.begin();it!=_public_keyring_map.end();++it)
|
||||||
locked_updateOwnSignatureFlag(it->second,it->first,own_cert,own_id) ;
|
locked_updateOwnSignatureFlag(it->second,it->first,own_cert,own_id) ;
|
||||||
}
|
}
|
||||||
void PGPHandler::updateOwnSignatureFlag(const PGPIdType& cert_id,const PGPIdType& own_id)
|
void PGPHandler::updateOwnSignatureFlag(const RsPgpId& cert_id,const RsPgpId& own_id)
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
std::map<PGPIdType,PGPCertificateInfo>::iterator it( _public_keyring_map.find(cert_id) ) ;
|
std::map<RsPgpId,PGPCertificateInfo>::iterator it( _public_keyring_map.find(cert_id) ) ;
|
||||||
|
|
||||||
if(it == _public_keyring_map.end())
|
if(it == _public_keyring_map.end())
|
||||||
{
|
{
|
||||||
|
@ -1457,7 +1457,7 @@ void PGPHandler::updateOwnSignatureFlag(const PGPIdType& cert_id,const PGPIdType
|
||||||
|
|
||||||
locked_updateOwnSignatureFlag(cert,cert_id,own_cert,own_id) ;
|
locked_updateOwnSignatureFlag(cert,cert_id,own_cert,own_id) ;
|
||||||
}
|
}
|
||||||
void PGPHandler::locked_updateOwnSignatureFlag(PGPCertificateInfo& cert,const PGPIdType& cert_id,PGPCertificateInfo& own_cert,const PGPIdType& own_id_str)
|
void PGPHandler::locked_updateOwnSignatureFlag(PGPCertificateInfo& cert,const RsPgpId& cert_id,PGPCertificateInfo& own_cert,const RsPgpId& own_id_str)
|
||||||
{
|
{
|
||||||
if(cert.signers.find(own_id_str) != cert.signers.end())
|
if(cert.signers.find(own_id_str) != cert.signers.end())
|
||||||
cert._flags |= PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE ;
|
cert._flags |= PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE ;
|
||||||
|
@ -1470,7 +1470,7 @@ void PGPHandler::locked_updateOwnSignatureFlag(PGPCertificateInfo& cert,const PG
|
||||||
cert._flags &= ~PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_SIGNED_ME ;
|
cert._flags &= ~PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_SIGNED_ME ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::getKeyFingerprint(const PGPIdType& id,PGPFingerprintType& fp) const
|
bool PGPHandler::getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
|
@ -1491,7 +1491,7 @@ bool PGPHandler::VerifySignBin(const void *literal_data, uint32_t literal_data_l
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
PGPIdType id = PGPIdType(key_fingerprint.toByteArray() + PGPFingerprintType::SIZE_IN_BYTES - PGPIdType::SIZE_IN_BYTES) ;
|
RsPgpId id = RsPgpId(key_fingerprint.toByteArray() + PGPFingerprintType::SIZE_IN_BYTES - RsPgpId::SIZE_IN_BYTES) ;
|
||||||
const ops_keydata_t *key = locked_getPublicKey(id,true) ;
|
const ops_keydata_t *key = locked_getPublicKey(id,true) ;
|
||||||
|
|
||||||
if(key == NULL)
|
if(key == NULL)
|
||||||
|
@ -1524,11 +1524,11 @@ bool PGPHandler::VerifySignBin(const void *literal_data, uint32_t literal_data_l
|
||||||
return ops_validate_detached_signature(literal_data,literal_data_length,sign,sign_len,key) ;
|
return ops_validate_detached_signature(literal_data,literal_data_length,sign,sign_len,key) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PGPHandler::setAcceptConnexion(const PGPIdType& id,bool b)
|
void PGPHandler::setAcceptConnexion(const RsPgpId& id,bool b)
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||||
|
|
||||||
std::map<PGPIdType,PGPCertificateInfo>::iterator res = _public_keyring_map.find(id) ;
|
std::map<RsPgpId,PGPCertificateInfo>::iterator res = _public_keyring_map.find(id) ;
|
||||||
|
|
||||||
if(res != _public_keyring_map.end())
|
if(res != _public_keyring_map.end())
|
||||||
{
|
{
|
||||||
|
@ -1539,32 +1539,32 @@ void PGPHandler::setAcceptConnexion(const PGPIdType& id,bool b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::getGPGFilteredList(std::list<PGPIdType>& list,bool (*filter)(const PGPCertificateInfo&)) const
|
bool PGPHandler::getGPGFilteredList(std::list<RsPgpId>& list,bool (*filter)(const PGPCertificateInfo&)) const
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP directory.
|
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP directory.
|
||||||
list.clear() ;
|
list.clear() ;
|
||||||
|
|
||||||
for(std::map<PGPIdType,PGPCertificateInfo>::const_iterator it(_public_keyring_map.begin());it!=_public_keyring_map.end();++it)
|
for(std::map<RsPgpId,PGPCertificateInfo>::const_iterator it(_public_keyring_map.begin());it!=_public_keyring_map.end();++it)
|
||||||
if( filter == NULL || (*filter)(it->second) )
|
if( filter == NULL || (*filter)(it->second) )
|
||||||
list.push_back(PGPIdType(it->first)) ;
|
list.push_back(RsPgpId(it->first)) ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::isGPGId(const PGPIdType &id)
|
bool PGPHandler::isGPGId(const RsPgpId &id)
|
||||||
{
|
{
|
||||||
return _public_keyring_map.find(id) != _public_keyring_map.end() ;
|
return _public_keyring_map.find(id) != _public_keyring_map.end() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::isGPGSigned(const PGPIdType &id)
|
bool PGPHandler::isGPGSigned(const RsPgpId &id)
|
||||||
{
|
{
|
||||||
std::map<PGPIdType,PGPCertificateInfo>::const_iterator res = _public_keyring_map.find(id) ;
|
std::map<RsPgpId,PGPCertificateInfo>::const_iterator res = _public_keyring_map.find(id) ;
|
||||||
return res != _public_keyring_map.end() && (res->second._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE) ;
|
return res != _public_keyring_map.end() && (res->second._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::isGPGAccepted(const PGPIdType &id)
|
bool PGPHandler::isGPGAccepted(const RsPgpId &id)
|
||||||
{
|
{
|
||||||
std::map<PGPIdType,PGPCertificateInfo>::const_iterator res = _public_keyring_map.find(id) ;
|
std::map<RsPgpId,PGPCertificateInfo>::const_iterator res = _public_keyring_map.find(id) ;
|
||||||
return (res != _public_keyring_map.end()) && (res->second._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_ACCEPT_CONNEXION) ;
|
return (res != _public_keyring_map.end()) && (res->second._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_ACCEPT_CONNEXION) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1592,7 +1592,7 @@ bool PGPHandler::mergeKeySignatures(ops_keydata_t *dst,const ops_keydata_t *src)
|
||||||
// First sort all signatures into lists to see which is new, which is not new
|
// First sort all signatures into lists to see which is new, which is not new
|
||||||
|
|
||||||
#ifdef DEBUG_PGPHANDLER
|
#ifdef DEBUG_PGPHANDLER
|
||||||
std::cerr << "Merging signatures for key " << PGPIdType(dst->key_id).toStdString() << std::endl;
|
std::cerr << "Merging signatures for key " << RsPgpId(dst->key_id).toStdString() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
std::set<ops_packet_t> dst_packets ;
|
std::set<ops_packet_t> dst_packets ;
|
||||||
|
|
||||||
|
@ -1627,7 +1627,7 @@ bool PGPHandler::mergeKeySignatures(ops_keydata_t *dst,const ops_keydata_t *src)
|
||||||
return to_add.size() > 0 ;
|
return to_add.size() > 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::privateTrustCertificate(const PGPIdType& id,int trustlvl)
|
bool PGPHandler::privateTrustCertificate(const RsPgpId& id,int trustlvl)
|
||||||
{
|
{
|
||||||
if(trustlvl < 0 || trustlvl >= 6 || trustlvl == 1)
|
if(trustlvl < 0 || trustlvl >= 6 || trustlvl == 1)
|
||||||
{
|
{
|
||||||
|
@ -1635,7 +1635,7 @@ bool PGPHandler::privateTrustCertificate(const PGPIdType& id,int trustlvl)
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<PGPIdType,PGPCertificateInfo>::iterator it = _public_keyring_map.find(id);
|
std::map<RsPgpId,PGPCertificateInfo>::iterator it = _public_keyring_map.find(id);
|
||||||
|
|
||||||
if(it == _public_keyring_map.end())
|
if(it == _public_keyring_map.end())
|
||||||
{
|
{
|
||||||
|
@ -1670,17 +1670,17 @@ void PGPHandler::locked_readPrivateTrustDatabase()
|
||||||
std::cerr << " private trust database not found. No trust info loaded." << std::endl ;
|
std::cerr << " private trust database not found. No trust info loaded." << std::endl ;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
std::map<PGPIdType,PGPCertificateInfo>::iterator it ;
|
std::map<RsPgpId,PGPCertificateInfo>::iterator it ;
|
||||||
PrivateTrustPacket trustpacket;
|
PrivateTrustPacket trustpacket;
|
||||||
int n_packets = 0 ;
|
int n_packets = 0 ;
|
||||||
|
|
||||||
while(fread((void*)&trustpacket,sizeof(PrivateTrustPacket),1,fdb) == 1)
|
while(fread((void*)&trustpacket,sizeof(PrivateTrustPacket),1,fdb) == 1)
|
||||||
{
|
{
|
||||||
it = _public_keyring_map.find(PGPIdType(trustpacket.user_id)) ;
|
it = _public_keyring_map.find(RsPgpId(trustpacket.user_id)) ;
|
||||||
|
|
||||||
if(it == _public_keyring_map.end())
|
if(it == _public_keyring_map.end())
|
||||||
{
|
{
|
||||||
std::cerr << " (WW) Trust packet found for unknown key id " << PGPIdType(trustpacket.user_id).toStdString() << std::endl;
|
std::cerr << " (WW) Trust packet found for unknown key id " << RsPgpId(trustpacket.user_id).toStdString() << std::endl;
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
if(trustpacket.trust_level > 6)
|
if(trustpacket.trust_level > 6)
|
||||||
|
@ -1715,9 +1715,9 @@ bool PGPHandler::locked_writePrivateTrustDatabase()
|
||||||
}
|
}
|
||||||
PrivateTrustPacket trustpacket ;
|
PrivateTrustPacket trustpacket ;
|
||||||
|
|
||||||
for(std::map<PGPIdType,PGPCertificateInfo>::iterator it = _public_keyring_map.begin();it!=_public_keyring_map.end() ;++it)
|
for(std::map<RsPgpId,PGPCertificateInfo>::iterator it = _public_keyring_map.begin();it!=_public_keyring_map.end() ;++it)
|
||||||
{
|
{
|
||||||
memcpy(trustpacket.user_id,PGPIdType(it->first).toByteArray(),PGP_KEY_ID_SIZE) ;
|
memcpy(trustpacket.user_id,RsPgpId(it->first).toByteArray(),PGP_KEY_ID_SIZE) ;
|
||||||
trustpacket.trust_level = it->second._trustLvl ;
|
trustpacket.trust_level = it->second._trustLvl ;
|
||||||
trustpacket.time_stamp = it->second._time_stamp ;
|
trustpacket.time_stamp = it->second._time_stamp ;
|
||||||
|
|
||||||
|
@ -1843,7 +1843,7 @@ bool PGPHandler::locked_syncTrustDatabase()
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
void PGPHandler::locked_mergeKeyringFromDisk( ops_keyring_t *keyring,
|
void PGPHandler::locked_mergeKeyringFromDisk( ops_keyring_t *keyring,
|
||||||
std::map<PGPIdType,PGPCertificateInfo>& kmap,
|
std::map<RsPgpId,PGPCertificateInfo>& kmap,
|
||||||
const std::string& keyring_file)
|
const std::string& keyring_file)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_PGPHANDLER
|
#ifdef DEBUG_PGPHANDLER
|
||||||
|
@ -1869,7 +1869,7 @@ void PGPHandler::locked_mergeKeyringFromDisk( ops_keyring_t *keyring,
|
||||||
ops_keyring_free(tmp_keyring) ;
|
ops_keyring_free(tmp_keyring) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PGPHandler::removeKeysFromPGPKeyring(const std::list<PGPIdType>& keys_to_remove,std::string& backup_file,uint32_t& error_code)
|
bool PGPHandler::removeKeysFromPGPKeyring(const std::list<RsPgpId>& keys_to_remove,std::string& backup_file,uint32_t& error_code)
|
||||||
{
|
{
|
||||||
// 1 - lock everything.
|
// 1 - lock everything.
|
||||||
//
|
//
|
||||||
|
@ -1878,7 +1878,7 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::list<PGPIdType>& keys_to_re
|
||||||
|
|
||||||
error_code = PGP_KEYRING_REMOVAL_ERROR_NO_ERROR ;
|
error_code = PGP_KEYRING_REMOVAL_ERROR_NO_ERROR ;
|
||||||
|
|
||||||
for(std::list<PGPIdType>::const_iterator it(keys_to_remove.begin());it!=keys_to_remove.end();++it)
|
for(std::list<RsPgpId>::const_iterator it(keys_to_remove.begin());it!=keys_to_remove.end();++it)
|
||||||
if(locked_getSecretKey(*it) != NULL)
|
if(locked_getSecretKey(*it) != NULL)
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) PGPHandler:: can't remove key " << (*it).toStdString() << " since its shared by a secret key! Operation cancelled." << std::endl;
|
std::cerr << "(EE) PGPHandler:: can't remove key " << (*it).toStdString() << " since its shared by a secret key! Operation cancelled." << std::endl;
|
||||||
|
@ -1914,7 +1914,7 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::list<PGPIdType>& keys_to_re
|
||||||
|
|
||||||
// Remove keys from the keyring, and update the keyring map.
|
// Remove keys from the keyring, and update the keyring map.
|
||||||
//
|
//
|
||||||
for(std::list<PGPIdType>::const_iterator it(keys_to_remove.begin());it!=keys_to_remove.end();++it)
|
for(std::list<RsPgpId>::const_iterator it(keys_to_remove.begin());it!=keys_to_remove.end();++it)
|
||||||
{
|
{
|
||||||
if(locked_getSecretKey(*it) != NULL)
|
if(locked_getSecretKey(*it) != NULL)
|
||||||
{
|
{
|
||||||
|
@ -1922,7 +1922,7 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::list<PGPIdType>& keys_to_re
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<PGPIdType,PGPCertificateInfo>::iterator res = _public_keyring_map.find(*it) ;
|
std::map<RsPgpId,PGPCertificateInfo>::iterator res = _public_keyring_map.find(*it) ;
|
||||||
|
|
||||||
if(res == _public_keyring_map.end())
|
if(res == _public_keyring_map.end())
|
||||||
{
|
{
|
||||||
|
@ -1930,7 +1930,7 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::list<PGPIdType>& keys_to_re
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(res->second._key_index >= (unsigned int)_pubring->nkeys || PGPIdType(_pubring->keys[res->second._key_index].key_id) != *it)
|
if(res->second._key_index >= (unsigned int)_pubring->nkeys || RsPgpId(_pubring->keys[res->second._key_index].key_id) != *it)
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) PGPHandler:: can't remove key " << (*it).toStdString() << ". Inconsistency found." << std::endl;
|
std::cerr << "(EE) PGPHandler:: can't remove key " << (*it).toStdString() << ". Inconsistency found." << std::endl;
|
||||||
error_code = PGP_KEYRING_REMOVAL_ERROR_DATA_INCONSISTENCY ;
|
error_code = PGP_KEYRING_REMOVAL_ERROR_DATA_INCONSISTENCY ;
|
||||||
|
@ -1952,7 +1952,7 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::list<PGPIdType>& keys_to_re
|
||||||
const ops_keydata_t *keydata ;
|
const ops_keydata_t *keydata ;
|
||||||
while( (keydata = ops_keyring_get_key_by_index(_pubring,i)) != NULL )
|
while( (keydata = ops_keyring_get_key_by_index(_pubring,i)) != NULL )
|
||||||
{
|
{
|
||||||
PGPCertificateInfo& cert(_public_keyring_map[ PGPIdType(keydata->key_id) ]) ;
|
PGPCertificateInfo& cert(_public_keyring_map[ RsPgpId(keydata->key_id) ]) ;
|
||||||
cert._key_index = i ;
|
cert._key_index = i ;
|
||||||
++i ;
|
++i ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <util/rsthreads.h>
|
#include <util/rsthreads.h>
|
||||||
#include <retroshare/rsids.h>
|
#include <retroshare/rstypes.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <openpgpsdk/types.h>
|
#include <openpgpsdk/types.h>
|
||||||
|
@ -27,7 +27,7 @@ class PGPCertificateInfo
|
||||||
std::string _email;
|
std::string _email;
|
||||||
std::string _comment;
|
std::string _comment;
|
||||||
|
|
||||||
std::set<PGPIdType> signers;
|
std::set<RsPgpId> signers;
|
||||||
|
|
||||||
uint32_t _trustLvl;
|
uint32_t _trustLvl;
|
||||||
uint32_t _validLvl;
|
uint32_t _validLvl;
|
||||||
|
@ -37,7 +37,7 @@ class PGPCertificateInfo
|
||||||
mutable time_t _time_stamp ; // last time the key was used (received, used for signature verification, etc)
|
mutable time_t _time_stamp ; // last time the key was used (received, used for signature verification, etc)
|
||||||
|
|
||||||
PGPFingerprintType _fpr; /* fingerprint */
|
PGPFingerprintType _fpr; /* fingerprint */
|
||||||
// PGPIdType _key_id ;
|
// RsPgpId _key_id ;
|
||||||
|
|
||||||
uint32_t _key_index ; // index to array of keys in the public keyring
|
uint32_t _key_index ; // index to array of keys in the public keyring
|
||||||
|
|
||||||
|
@ -70,68 +70,68 @@ class PGPHandler
|
||||||
/**
|
/**
|
||||||
* @param ids list of gpg certificate ids (note, not the actual certificates)
|
* @param ids list of gpg certificate ids (note, not the actual certificates)
|
||||||
*/
|
*/
|
||||||
bool getGPGFilteredList(std::list<PGPIdType>& list,bool (*filter)(const PGPCertificateInfo&) = NULL) const ;
|
bool getGPGFilteredList(std::list<RsPgpId>& list,bool (*filter)(const PGPCertificateInfo&) = NULL) const ;
|
||||||
bool haveSecretKey(const PGPIdType& id) const ;
|
bool haveSecretKey(const RsPgpId& id) const ;
|
||||||
|
|
||||||
bool importGPGKeyPair(const std::string& filename,PGPIdType& imported_id,std::string& import_error) ;
|
bool importGPGKeyPair(const std::string& filename,RsPgpId& imported_id,std::string& import_error) ;
|
||||||
bool exportGPGKeyPair(const std::string& filename,const PGPIdType& exported_id) const ;
|
bool exportGPGKeyPair(const std::string& filename,const RsPgpId& exported_id) const ;
|
||||||
|
|
||||||
bool availableGPGCertificatesWithPrivateKeys(std::list<PGPIdType>& ids);
|
bool availableGPGCertificatesWithPrivateKeys(std::list<RsPgpId>& ids);
|
||||||
bool GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, PGPIdType& pgpId, std::string& errString) ;
|
bool GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, RsPgpId& pgpId, std::string& errString) ;
|
||||||
|
|
||||||
bool LoadCertificateFromString(const std::string& pem, PGPIdType& gpg_id, std::string& error_string);
|
bool LoadCertificateFromString(const std::string& pem, RsPgpId& gpg_id, std::string& error_string);
|
||||||
|
|
||||||
std::string SaveCertificateToString(const PGPIdType& id,bool include_signatures) const ;
|
std::string SaveCertificateToString(const RsPgpId& id,bool include_signatures) const ;
|
||||||
bool exportPublicKey(const PGPIdType& id,unsigned char *& mem,size_t& mem_size,bool armoured,bool include_signatures) const ;
|
bool exportPublicKey(const RsPgpId& id,unsigned char *& mem,size_t& mem_size,bool armoured,bool include_signatures) const ;
|
||||||
|
|
||||||
bool SignDataBin(const PGPIdType& id,const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,bool make_raw_signature=false) ;
|
bool SignDataBin(const RsPgpId& id,const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,bool make_raw_signature=false) ;
|
||||||
bool VerifySignBin(const void *data, uint32_t data_len, unsigned char *sign, unsigned int sign_len, const PGPFingerprintType& withfingerprint) ;
|
bool VerifySignBin(const void *data, uint32_t data_len, unsigned char *sign, unsigned int sign_len, const PGPFingerprintType& withfingerprint) ;
|
||||||
bool privateSignCertificate(const PGPIdType& own_id,const PGPIdType& id_of_key_to_sign) ;
|
bool privateSignCertificate(const RsPgpId& own_id,const RsPgpId& id_of_key_to_sign) ;
|
||||||
|
|
||||||
// The client should supply a memory chunk to store the data. The length will be updated to the real length of the data.
|
// The client should supply a memory chunk to store the data. The length will be updated to the real length of the data.
|
||||||
//
|
//
|
||||||
bool encryptDataBin(const PGPIdType& key_id,const void *data, const uint32_t len, unsigned char *encrypted_data, unsigned int *encrypted_data_len) ;
|
bool encryptDataBin(const RsPgpId& key_id,const void *data, const uint32_t len, unsigned char *encrypted_data, unsigned int *encrypted_data_len) ;
|
||||||
bool decryptDataBin(const PGPIdType& key_id,const void *data, const uint32_t len, unsigned char *decrypted_data, unsigned int *decrypted_data_len) ;
|
bool decryptDataBin(const RsPgpId& key_id,const void *data, const uint32_t len, unsigned char *decrypted_data, unsigned int *decrypted_data_len) ;
|
||||||
|
|
||||||
bool encryptTextToFile(const PGPIdType& key_id,const std::string& text,const std::string& outfile) ;
|
bool encryptTextToFile(const RsPgpId& key_id,const std::string& text,const std::string& outfile) ;
|
||||||
bool decryptTextFromFile(const PGPIdType& key_id,std::string& text,const std::string& encrypted_inputfile) ;
|
bool decryptTextFromFile(const RsPgpId& key_id,std::string& text,const std::string& encrypted_inputfile) ;
|
||||||
//bool encryptTextToString(const PGPIdType& key_id,const std::string& text,std::string& outstring) ;
|
//bool encryptTextToString(const RsPgpId& key_id,const std::string& text,std::string& outstring) ;
|
||||||
//bool decryptTextFromString(const PGPIdType& key_id,const std::string& encrypted_text,std::string& outstring) ;
|
//bool decryptTextFromString(const RsPgpId& key_id,const std::string& encrypted_text,std::string& outstring) ;
|
||||||
|
|
||||||
bool getKeyFingerprint(const PGPIdType& id,PGPFingerprintType& fp) const ;
|
bool getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const ;
|
||||||
void setAcceptConnexion(const PGPIdType&,bool) ;
|
void setAcceptConnexion(const RsPgpId&,bool) ;
|
||||||
|
|
||||||
void updateOwnSignatureFlag(const PGPIdType& ownId) ;
|
void updateOwnSignatureFlag(const RsPgpId& ownId) ;
|
||||||
void updateOwnSignatureFlag(const PGPIdType& pgp_id,const PGPIdType& ownId) ;
|
void updateOwnSignatureFlag(const RsPgpId& pgp_id,const RsPgpId& ownId) ;
|
||||||
|
|
||||||
void locked_updateOwnSignatureFlag(PGPCertificateInfo&, const PGPIdType&, PGPCertificateInfo&, const PGPIdType&) ;
|
void locked_updateOwnSignatureFlag(PGPCertificateInfo&, const RsPgpId&, PGPCertificateInfo&, const RsPgpId&) ;
|
||||||
|
|
||||||
// Removes the given keys from the keyring. Also backup the keyring to a file which name is automatically generated
|
// Removes the given keys from the keyring. Also backup the keyring to a file which name is automatically generated
|
||||||
// and given pack for proper display.
|
// and given pack for proper display.
|
||||||
//
|
//
|
||||||
bool removeKeysFromPGPKeyring(const std::list<PGPIdType>& key_ids,std::string& backup_file,uint32_t& error_code) ;
|
bool removeKeysFromPGPKeyring(const std::list<RsPgpId>& key_ids,std::string& backup_file,uint32_t& error_code) ;
|
||||||
|
|
||||||
//bool isKeySupported(const PGPIdType& id) const ;
|
//bool isKeySupported(const RsPgpId& id) const ;
|
||||||
|
|
||||||
bool privateTrustCertificate(const PGPIdType& id,int valid_level) ;
|
bool privateTrustCertificate(const RsPgpId& id,int valid_level) ;
|
||||||
|
|
||||||
// Write keyring
|
// Write keyring
|
||||||
|
|
||||||
//bool writeSecretKeyring() ;
|
//bool writeSecretKeyring() ;
|
||||||
//bool writePublicKeyring() ;
|
//bool writePublicKeyring() ;
|
||||||
|
|
||||||
const PGPCertificateInfo *getCertificateInfo(const PGPIdType& id) const ;
|
const PGPCertificateInfo *getCertificateInfo(const RsPgpId& id) const ;
|
||||||
|
|
||||||
bool isGPGId(const PGPIdType &id);
|
bool isGPGId(const RsPgpId &id);
|
||||||
bool isGPGSigned(const PGPIdType &id);
|
bool isGPGSigned(const RsPgpId &id);
|
||||||
bool isGPGAccepted(const PGPIdType &id);
|
bool isGPGAccepted(const RsPgpId &id);
|
||||||
|
|
||||||
static void setPassphraseCallback(PassphraseCallback cb) ;
|
static void setPassphraseCallback(PassphraseCallback cb) ;
|
||||||
static PassphraseCallback passphraseCallback() { return _passphrase_callback ; }
|
static PassphraseCallback passphraseCallback() { return _passphrase_callback ; }
|
||||||
|
|
||||||
// Gets info about the key. Who are the signers, what's the owner's name, etc.
|
// Gets info about the key. Who are the signers, what's the owner's name, etc.
|
||||||
//
|
//
|
||||||
bool getGPGDetailsFromBinaryBlock(const unsigned char *mem,size_t mem_size,PGPIdType& key_id, std::string& name, std::list<PGPIdType>& signers) const ;
|
bool getGPGDetailsFromBinaryBlock(const unsigned char *mem,size_t mem_size,RsPgpId& key_id, std::string& name, std::list<RsPgpId>& signers) const ;
|
||||||
|
|
||||||
// Debug stuff.
|
// Debug stuff.
|
||||||
virtual bool printKeys() const ;
|
virtual bool printKeys() const ;
|
||||||
|
@ -152,8 +152,8 @@ class PGPHandler
|
||||||
//
|
//
|
||||||
bool validateAndUpdateSignatures(PGPCertificateInfo& cert,const ops_keydata_t *keydata) ;
|
bool validateAndUpdateSignatures(PGPCertificateInfo& cert,const ops_keydata_t *keydata) ;
|
||||||
|
|
||||||
const ops_keydata_t *locked_getPublicKey(const PGPIdType&,bool stamp_the_key) const;
|
const ops_keydata_t *locked_getPublicKey(const RsPgpId&,bool stamp_the_key) const;
|
||||||
const ops_keydata_t *locked_getSecretKey(const PGPIdType&) const ;
|
const ops_keydata_t *locked_getSecretKey(const RsPgpId&) const ;
|
||||||
|
|
||||||
void locked_readPrivateTrustDatabase() ;
|
void locked_readPrivateTrustDatabase() ;
|
||||||
bool locked_writePrivateTrustDatabase() ;
|
bool locked_writePrivateTrustDatabase() ;
|
||||||
|
@ -161,8 +161,8 @@ class PGPHandler
|
||||||
bool locked_syncPublicKeyring() ;
|
bool locked_syncPublicKeyring() ;
|
||||||
bool locked_syncTrustDatabase() ;
|
bool locked_syncTrustDatabase() ;
|
||||||
|
|
||||||
void locked_mergeKeyringFromDisk(ops_keyring_t *keyring, std::map<PGPIdType,PGPCertificateInfo>& kmap, const std::string& keyring_file) ;
|
void locked_mergeKeyringFromDisk(ops_keyring_t *keyring, std::map<RsPgpId,PGPCertificateInfo>& kmap, const std::string& keyring_file) ;
|
||||||
bool locked_addOrMergeKey(ops_keyring_t *keyring,std::map<PGPIdType,PGPCertificateInfo>& kmap,const ops_keydata_t *keydata) ;
|
bool locked_addOrMergeKey(ops_keyring_t *keyring,std::map<RsPgpId,PGPCertificateInfo>& kmap,const ops_keydata_t *keydata) ;
|
||||||
|
|
||||||
// Members.
|
// Members.
|
||||||
//
|
//
|
||||||
|
@ -171,8 +171,8 @@ class PGPHandler
|
||||||
ops_keyring_t *_pubring ;
|
ops_keyring_t *_pubring ;
|
||||||
ops_keyring_t *_secring ;
|
ops_keyring_t *_secring ;
|
||||||
|
|
||||||
std::map<PGPIdType,PGPCertificateInfo> _public_keyring_map ; // used for fast access to keys. Gives the index in the keyring.
|
std::map<RsPgpId,PGPCertificateInfo> _public_keyring_map ; // used for fast access to keys. Gives the index in the keyring.
|
||||||
std::map<PGPIdType,PGPCertificateInfo> _secret_keyring_map ;
|
std::map<RsPgpId,PGPCertificateInfo> _secret_keyring_map ;
|
||||||
|
|
||||||
const std::string _pubring_path ;
|
const std::string _pubring_path ;
|
||||||
const std::string _secring_path ;
|
const std::string _secring_path ;
|
||||||
|
|
|
@ -154,7 +154,7 @@ RsCertificate::RsCertificate(const RsPeerDetails& Detail, const unsigned char *b
|
||||||
if(!Detail.isOnlyGPGdetail)
|
if(!Detail.isOnlyGPGdetail)
|
||||||
{
|
{
|
||||||
only_pgp = false ;
|
only_pgp = false ;
|
||||||
location_id = SSLIdType( Detail.id ) ;
|
location_id = RsPeerId( Detail.id ) ;
|
||||||
location_name = Detail.location ;
|
location_name = Detail.location ;
|
||||||
|
|
||||||
if (Detail.isHiddenNode)
|
if (Detail.isHiddenNode)
|
||||||
|
@ -203,7 +203,7 @@ RsCertificate::RsCertificate(const RsPeerDetails& Detail, const unsigned char *b
|
||||||
only_pgp = true ;
|
only_pgp = true ;
|
||||||
hidden_node = false;
|
hidden_node = false;
|
||||||
hidden_node_address = "";
|
hidden_node_address = "";
|
||||||
location_id = SSLIdType() ;
|
location_id = RsPeerId() ;
|
||||||
location_name = "" ;
|
location_name = "" ;
|
||||||
memset(ipv4_internal_ip_and_port,0,6) ;
|
memset(ipv4_internal_ip_and_port,0,6) ;
|
||||||
memset(ipv4_external_ip_and_port,0,6) ;
|
memset(ipv4_external_ip_and_port,0,6) ;
|
||||||
|
@ -304,7 +304,7 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
location_id = SSLIdType(buf) ;
|
location_id = RsPeerId(buf) ;
|
||||||
buf = &buf[s] ;
|
buf = &buf[s] ;
|
||||||
only_pgp = false ;
|
only_pgp = false ;
|
||||||
break ;
|
break ;
|
||||||
|
|
|
@ -61,7 +61,7 @@ class RsCertificate
|
||||||
size_t binary_pgp_key_size ;
|
size_t binary_pgp_key_size ;
|
||||||
|
|
||||||
std::string location_name ;
|
std::string location_name ;
|
||||||
SSLIdType location_id ;
|
RsPeerId location_id ;
|
||||||
std::string pgp_version ;
|
std::string pgp_version ;
|
||||||
std::string dns_name ;
|
std::string dns_name ;
|
||||||
std::string hidden_node_address;
|
std::string hidden_node_address;
|
||||||
|
|
|
@ -61,12 +61,12 @@ bool AuthGPG::decryptTextFromFile(std::string& text,const std::string& inputfile
|
||||||
return PGPHandler::decryptTextFromFile(mOwnGpgId,text,inputfile) ;
|
return PGPHandler::decryptTextFromFile(mOwnGpgId,text,inputfile) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::removeKeysFromPGPKeyring(const std::list<PGPIdType>& pgp_ids,std::string& backup_file,uint32_t& error_code)
|
bool AuthGPG::removeKeysFromPGPKeyring(const std::list<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code)
|
||||||
{
|
{
|
||||||
std::list<PGPIdType> pids ;
|
std::list<RsPgpId> pids ;
|
||||||
|
|
||||||
for(std::list<PGPIdType>::const_iterator it(pgp_ids.begin());it!=pgp_ids.end();++it)
|
for(std::list<RsPgpId>::const_iterator it(pgp_ids.begin());it!=pgp_ids.end();++it)
|
||||||
pids.push_back(PGPIdType(*it)) ;
|
pids.push_back(RsPgpId(*it)) ;
|
||||||
|
|
||||||
return PGPHandler::removeKeysFromPGPKeyring(pids,backup_file,error_code) ;
|
return PGPHandler::removeKeysFromPGPKeyring(pids,backup_file,error_code) ;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ bool AuthGPG::encryptTextToFile(const std::string& text,const std::string& outfi
|
||||||
|
|
||||||
// bool AuthGPG::encryptTextToString(const std::string& pgp_id,const std::string& text,std::string& outstr)
|
// bool AuthGPG::encryptTextToString(const std::string& pgp_id,const std::string& text,std::string& outstr)
|
||||||
// {
|
// {
|
||||||
// return PGPHandler::encryptTextToString(PGPIdType(pgp_id),text,outstr) ;
|
// return PGPHandler::encryptTextToString(RsPgpId(pgp_id),text,outstr) ;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
std::string pgp_pwd_callback(void * /*hook*/, const char *uid_hint, const char * /*passphrase_info*/, int prev_was_bad)
|
std::string pgp_pwd_callback(void * /*hook*/, const char *uid_hint, const char * /*passphrase_info*/, int prev_was_bad)
|
||||||
|
@ -141,11 +141,11 @@ AuthGPG::AuthGPG(const std::string& path_to_public_keyring,const std::string& pa
|
||||||
*/
|
*/
|
||||||
//bool AuthGPG::availableGPGCertificatesWithPrivateKeys(std::list<std::string> &ids)
|
//bool AuthGPG::availableGPGCertificatesWithPrivateKeys(std::list<std::string> &ids)
|
||||||
//{
|
//{
|
||||||
// std::list<PGPIdType> pids ;
|
// std::list<RsPgpId> pids ;
|
||||||
//
|
//
|
||||||
// PGPHandler::availableGPGCertificatesWithPrivateKeys(pids) ;
|
// PGPHandler::availableGPGCertificatesWithPrivateKeys(pids) ;
|
||||||
//
|
//
|
||||||
// for(std::list<PGPIdType>::const_iterator it(pids.begin());it!=pids.end();++it)
|
// for(std::list<RsPgpId>::const_iterator it(pids.begin());it!=pids.end();++it)
|
||||||
// ids.push_back( (*it).toStdString() ) ;
|
// ids.push_back( (*it).toStdString() ) ;
|
||||||
//
|
//
|
||||||
// /* return false if there are no private keys */
|
// /* return false if there are no private keys */
|
||||||
|
@ -159,11 +159,11 @@ AuthGPG::AuthGPG(const std::string& path_to_public_keyring,const std::string& pa
|
||||||
* This function must be called successfully (return == 1)
|
* This function must be called successfully (return == 1)
|
||||||
* before anything else can be done. (except above fn).
|
* before anything else can be done. (except above fn).
|
||||||
*/
|
*/
|
||||||
int AuthGPG::GPGInit(const PGPIdType &ownId)
|
int AuthGPG::GPGInit(const RsPgpId &ownId)
|
||||||
{
|
{
|
||||||
std::cerr << "AuthGPG::GPGInit() called with own gpg id : " << ownId.toStdString() << std::endl;
|
std::cerr << "AuthGPG::GPGInit() called with own gpg id : " << ownId.toStdString() << std::endl;
|
||||||
|
|
||||||
mOwnGpgId = PGPIdType(ownId);
|
mOwnGpgId = RsPgpId(ownId);
|
||||||
|
|
||||||
//force the validity of the private key. When set to unknown, it caused signature and text encryptions bugs
|
//force the validity of the private key. When set to unknown, it caused signature and text encryptions bugs
|
||||||
privateTrustCertificate(ownId, 5);
|
privateTrustCertificate(ownId, 5);
|
||||||
|
@ -263,7 +263,7 @@ void AuthGPG::processServices()
|
||||||
std::cerr << "AuthGPGimpl::processServices() Process load operation" << std::endl;
|
std::cerr << "AuthGPGimpl::processServices() Process load operation" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
std::string error_string ;
|
std::string error_string ;
|
||||||
PGPIdType pgp_id ;
|
RsPgpId pgp_id ;
|
||||||
LoadCertificateFromString(loadOrSave->m_certGpg, pgp_id,error_string);
|
LoadCertificateFromString(loadOrSave->m_certGpg, pgp_id,error_string);
|
||||||
loadOrSave->m_certGpgId = pgp_id;
|
loadOrSave->m_certGpgId = pgp_id;
|
||||||
}
|
}
|
||||||
|
@ -317,12 +317,12 @@ bool AuthGPG::VerifySignature(const void *data, int datalen, const void *sig, un
|
||||||
return PGPHandler::VerifySignBin((unsigned char*)data,datalen,(unsigned char*)sig,siglen,withfingerprint) ;
|
return PGPHandler::VerifySignBin((unsigned char*)data,datalen,(unsigned char*)sig,siglen,withfingerprint) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::exportProfile(const std::string& fname,const PGPIdType& exported_id)
|
bool AuthGPG::exportProfile(const std::string& fname,const RsPgpId& exported_id)
|
||||||
{
|
{
|
||||||
return PGPHandler::exportGPGKeyPair(fname,exported_id) ;
|
return PGPHandler::exportGPGKeyPair(fname,exported_id) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::importProfile(const std::string& fname,PGPIdType& imported_id,std::string& import_error)
|
bool AuthGPG::importProfile(const std::string& fname,RsPgpId& imported_id,std::string& import_error)
|
||||||
{
|
{
|
||||||
return PGPHandler::importGPGKeyPair(fname,imported_id,import_error) ;
|
return PGPHandler::importGPGKeyPair(fname,imported_id,import_error) ;
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ bool AuthGPG::active()
|
||||||
return gpgKeySelected;
|
return gpgKeySelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, PGPIdType& pgpId, std::string& errString)
|
bool AuthGPG::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, RsPgpId& pgpId, std::string& errString)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ bool AuthGPG::GeneratePGPCertificate(const std::string& name, const std::stri
|
||||||
}
|
}
|
||||||
|
|
||||||
/**** These Two are common */
|
/**** These Two are common */
|
||||||
std::string AuthGPG::getGPGName(const PGPIdType& id,bool *success)
|
std::string AuthGPG::getGPGName(const RsPgpId& id,bool *success)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ std::string AuthGPG::getGPGName(const PGPIdType& id,bool *success)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**** These Two are common */
|
/**** These Two are common */
|
||||||
std::string AuthGPG::getGPGEmail(const PGPIdType& id,bool *success)
|
std::string AuthGPG::getGPGEmail(const RsPgpId& id,bool *success)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
const PGPCertificateInfo *info = getCertificateInfo(id) ;
|
const PGPCertificateInfo *info = getCertificateInfo(id) ;
|
||||||
|
@ -381,7 +381,7 @@ std::string AuthGPG::getGPGEmail(const PGPIdType& id,bool *success)
|
||||||
|
|
||||||
/**** GPG versions ***/
|
/**** GPG versions ***/
|
||||||
|
|
||||||
const PGPIdType& AuthGPG::getGPGOwnId()
|
const RsPgpId& AuthGPG::getGPGOwnId()
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
return mOwnGpgId ;
|
return mOwnGpgId ;
|
||||||
|
@ -392,7 +392,7 @@ std::string AuthGPG::getGPGOwnName()
|
||||||
return getGPGName(mOwnGpgId) ;
|
return getGPGName(mOwnGpgId) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::getGPGAllList(std::list<PGPIdType> &ids)
|
bool AuthGPG::getGPGAllList(std::list<RsPgpId> &ids)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ const PGPCertificateInfo *AuthGPG::getCertInfoFromStdString(const std::string& p
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return PGPHandler::getCertificateInfo(PGPIdType(pgp_id)) ;
|
return PGPHandler::getCertificateInfo(RsPgpId(pgp_id)) ;
|
||||||
}
|
}
|
||||||
catch(std::exception& e)
|
catch(std::exception& e)
|
||||||
{
|
{
|
||||||
|
@ -412,11 +412,11 @@ const PGPCertificateInfo *AuthGPG::getCertInfoFromStdString(const std::string& p
|
||||||
return NULL ;
|
return NULL ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool AuthGPG::haveSecretKey(const PGPIdType& id) const
|
bool AuthGPG::haveSecretKey(const RsPgpId& id) const
|
||||||
{
|
{
|
||||||
return PGPHandler::haveSecretKey(id) ;
|
return PGPHandler::haveSecretKey(id) ;
|
||||||
}
|
}
|
||||||
bool AuthGPG::isKeySupported(const PGPIdType& id) const
|
bool AuthGPG::isKeySupported(const RsPgpId& id) const
|
||||||
{
|
{
|
||||||
const PGPCertificateInfo *pc = getCertificateInfo(id) ;
|
const PGPCertificateInfo *pc = getCertificateInfo(id) ;
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ bool AuthGPG::isKeySupported(const PGPIdType& id) const
|
||||||
return !(pc->_flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_UNSUPPORTED_ALGORITHM) ;
|
return !(pc->_flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_UNSUPPORTED_ALGORITHM) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::getGPGDetails(const PGPIdType& pgp_id, RsPeerDetails &d)
|
bool AuthGPG::getGPGDetails(const RsPgpId& pgp_id, RsPeerDetails &d)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
|
|
||||||
|
@ -447,7 +447,7 @@ bool AuthGPG::getGPGDetails(const PGPIdType& pgp_id, RsPeerDetails &d)
|
||||||
d.ownsign = cert._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE;
|
d.ownsign = cert._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE;
|
||||||
d.gpgSigners.clear() ;
|
d.gpgSigners.clear() ;
|
||||||
|
|
||||||
for(std::set<PGPIdType>::const_iterator it(cert.signers.begin());it!=cert.signers.end();++it)
|
for(std::set<RsPgpId>::const_iterator it(cert.signers.begin());it!=cert.signers.end();++it)
|
||||||
d.gpgSigners.push_back( *it ) ;
|
d.gpgSigners.push_back( *it ) ;
|
||||||
|
|
||||||
d.fpr = cert._fpr ;
|
d.fpr = cert._fpr ;
|
||||||
|
@ -457,7 +457,7 @@ bool AuthGPG::getGPGDetails(const PGPIdType& pgp_id, RsPeerDetails &d)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::getGPGFilteredList(std::list<PGPIdType>& list,bool (*filter)(const PGPCertificateInfo&))
|
bool AuthGPG::getGPGFilteredList(std::list<RsPgpId>& list,bool (*filter)(const PGPCertificateInfo&))
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
|
|
||||||
|
@ -468,28 +468,28 @@ static bool filter_Validity(const PGPCertificateInfo& /*info*/) { return true ;
|
||||||
static bool filter_Accepted(const PGPCertificateInfo& info) { return info._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_ACCEPT_CONNEXION ; }
|
static bool filter_Accepted(const PGPCertificateInfo& info) { return info._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_ACCEPT_CONNEXION ; }
|
||||||
static bool filter_OwnSigned(const PGPCertificateInfo& info) { return info._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE ; }
|
static bool filter_OwnSigned(const PGPCertificateInfo& info) { return info._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE ; }
|
||||||
|
|
||||||
bool AuthGPG::getGPGValidList(std::list<PGPIdType> &ids)
|
bool AuthGPG::getGPGValidList(std::list<RsPgpId> &ids)
|
||||||
{
|
{
|
||||||
return getGPGFilteredList(ids,&filter_Validity);
|
return getGPGFilteredList(ids,&filter_Validity);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::getGPGAcceptedList(std::list<PGPIdType> &ids)
|
bool AuthGPG::getGPGAcceptedList(std::list<RsPgpId> &ids)
|
||||||
{
|
{
|
||||||
return getGPGFilteredList(ids,&filter_Accepted);
|
return getGPGFilteredList(ids,&filter_Accepted);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::getGPGSignedList(std::list<PGPIdType> &ids)
|
bool AuthGPG::getGPGSignedList(std::list<RsPgpId> &ids)
|
||||||
{
|
{
|
||||||
return getGPGFilteredList(ids,&filter_OwnSigned);
|
return getGPGFilteredList(ids,&filter_OwnSigned);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::getCachedGPGCertificate(const PGPIdType &id, std::string &certificate)
|
bool AuthGPG::getCachedGPGCertificate(const RsPgpId &id, std::string &certificate)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
#ifdef LIMIT_CERTIFICATE_SIZE
|
#ifdef LIMIT_CERTIFICATE_SIZE
|
||||||
certificate = PGPHandler::SaveCertificateToString(PGPIdType(id),false) ;
|
certificate = PGPHandler::SaveCertificateToString(RsPgpId(id),false) ;
|
||||||
#else
|
#else
|
||||||
certificate = PGPHandler::SaveCertificateToString(PGPIdType(id),true) ;
|
certificate = PGPHandler::SaveCertificateToString(RsPgpId(id),true) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #ifdef LIMIT_CERTIFICATE_SIZE
|
// #ifdef LIMIT_CERTIFICATE_SIZE
|
||||||
|
@ -511,7 +511,7 @@ bool AuthGPG::getCachedGPGCertificate(const PGPIdType &id, std::string &certific
|
||||||
|
|
||||||
|
|
||||||
/* SKTAN : do not know how to use std::string id */
|
/* SKTAN : do not know how to use std::string id */
|
||||||
std::string AuthGPG::SaveCertificateToString(const PGPIdType &id,bool include_signatures)
|
std::string AuthGPG::SaveCertificateToString(const RsPgpId &id,bool include_signatures)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ bool AuthGPG::getCachedGPGCertificate(const PGPIdType &id, std::string &certific
|
||||||
}
|
}
|
||||||
|
|
||||||
/* import to GnuPG and other Certificates */
|
/* import to GnuPG and other Certificates */
|
||||||
bool AuthGPG::LoadCertificateFromString(const std::string &str, PGPIdType& gpg_id,std::string& error_string)
|
bool AuthGPG::LoadCertificateFromString(const std::string &str, RsPgpId& gpg_id,std::string& error_string)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||||
|
|
||||||
|
@ -546,7 +546,7 @@ bool AuthGPG::LoadCertificateFromString(const std::string &str, PGPIdType& gpg_i
|
||||||
/*************************************/
|
/*************************************/
|
||||||
|
|
||||||
/* These take PGP Ids */
|
/* These take PGP Ids */
|
||||||
bool AuthGPG::AllowConnection(const PGPIdType& gpg_id, bool accept)
|
bool AuthGPG::AllowConnection(const RsPgpId& gpg_id, bool accept)
|
||||||
{
|
{
|
||||||
#ifdef GPG_DEBUG
|
#ifdef GPG_DEBUG
|
||||||
std::cerr << "AuthGPG::AllowConnection(" << gpg_id << ")" << std::endl;
|
std::cerr << "AuthGPG::AllowConnection(" << gpg_id << ")" << std::endl;
|
||||||
|
@ -566,7 +566,7 @@ bool AuthGPG::AllowConnection(const PGPIdType& gpg_id, bool accept)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These take PGP Ids */
|
/* These take PGP Ids */
|
||||||
bool AuthGPG::SignCertificateLevel0(const PGPIdType &id)
|
bool AuthGPG::SignCertificateLevel0(const RsPgpId &id)
|
||||||
{
|
{
|
||||||
#ifdef GPG_DEBUG
|
#ifdef GPG_DEBUG
|
||||||
std::cerr << "AuthGPG::SignCertificat(" << id << ")" << std::endl;
|
std::cerr << "AuthGPG::SignCertificat(" << id << ")" << std::endl;
|
||||||
|
@ -575,7 +575,7 @@ bool AuthGPG::SignCertificateLevel0(const PGPIdType &id)
|
||||||
return privateSignCertificate(id) ;
|
return privateSignCertificate(id) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::RevokeCertificate(const PGPIdType &id)
|
bool AuthGPG::RevokeCertificate(const RsPgpId &id)
|
||||||
{
|
{
|
||||||
/* remove unused parameter warnings */
|
/* remove unused parameter warnings */
|
||||||
(void) id;
|
(void) id;
|
||||||
|
@ -587,7 +587,7 @@ bool AuthGPG::RevokeCertificate(const PGPIdType &id)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::TrustCertificate(const PGPIdType& id, int trustlvl)
|
bool AuthGPG::TrustCertificate(const RsPgpId& id, int trustlvl)
|
||||||
{
|
{
|
||||||
#ifdef GPG_DEBUG
|
#ifdef GPG_DEBUG
|
||||||
std::cerr << "AuthGPG::TrustCertificate(" << id << ", " << trustlvl << ")" << std::endl;
|
std::cerr << "AuthGPG::TrustCertificate(" << id << ", " << trustlvl << ")" << std::endl;
|
||||||
|
@ -595,9 +595,9 @@ bool AuthGPG::TrustCertificate(const PGPIdType& id, int trustlvl)
|
||||||
return privateTrustCertificate(id, trustlvl) ;
|
return privateTrustCertificate(id, trustlvl) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::encryptDataBin(const PGPIdType& pgp_id,const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen)
|
bool AuthGPG::encryptDataBin(const RsPgpId& pgp_id,const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen)
|
||||||
{
|
{
|
||||||
return PGPHandler::encryptDataBin(PGPIdType(pgp_id),data,datalen,sign,signlen) ;
|
return PGPHandler::encryptDataBin(RsPgpId(pgp_id),data,datalen,sign,signlen) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::decryptDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen)
|
bool AuthGPG::decryptDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen)
|
||||||
|
@ -616,7 +616,7 @@ bool AuthGPG::VerifySignBin(const void *data, uint32_t datalen, unsigned char *s
|
||||||
|
|
||||||
/* Sign/Trust stuff */
|
/* Sign/Trust stuff */
|
||||||
|
|
||||||
int AuthGPG::privateSignCertificate(const PGPIdType &id)
|
int AuthGPG::privateSignCertificate(const RsPgpId &id)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
|
|
||||||
|
@ -626,7 +626,7 @@ int AuthGPG::privateSignCertificate(const PGPIdType &id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* revoke the signature on Certificate */
|
/* revoke the signature on Certificate */
|
||||||
int AuthGPG::privateRevokeCertificate(const PGPIdType &/*id*/)
|
int AuthGPG::privateRevokeCertificate(const RsPgpId &/*id*/)
|
||||||
{
|
{
|
||||||
//RsStackMutex stack(gpgMtx); /******* LOCKED ******/
|
//RsStackMutex stack(gpgMtx); /******* LOCKED ******/
|
||||||
std::cerr << __PRETTY_FUNCTION__ << ": not implemented!" << std::endl;
|
std::cerr << __PRETTY_FUNCTION__ << ": not implemented!" << std::endl;
|
||||||
|
@ -634,7 +634,7 @@ int AuthGPG::privateRevokeCertificate(const PGPIdType &/*id*/)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AuthGPG::privateTrustCertificate(const PGPIdType& id, int trustlvl)
|
int AuthGPG::privateTrustCertificate(const RsPgpId& id, int trustlvl)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
|
|
||||||
|
@ -666,7 +666,7 @@ bool AuthGPG::saveList(bool& cleanup, std::list<RsItem*>& lst)
|
||||||
#ifdef GPG_DEBUG
|
#ifdef GPG_DEBUG
|
||||||
std::cerr << "AuthGPG::saveList() called" << std::endl ;
|
std::cerr << "AuthGPG::saveList() called" << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
std::list<PGPIdType> ids ;
|
std::list<RsPgpId> ids ;
|
||||||
getGPGAcceptedList(ids) ; // needs to be done before the lock
|
getGPGAcceptedList(ids) ; // needs to be done before the lock
|
||||||
|
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
|
@ -676,7 +676,7 @@ bool AuthGPG::saveList(bool& cleanup, std::list<RsItem*>& lst)
|
||||||
// Now save config for network digging strategies
|
// Now save config for network digging strategies
|
||||||
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
|
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
|
||||||
|
|
||||||
for (std::list<PGPIdType>::const_iterator it(ids.begin()); it != ids.end(); ++it)
|
for (std::list<RsPgpId>::const_iterator it(ids.begin()); it != ids.end(); ++it)
|
||||||
if((*it) != mOwnGpgId) // skip our own id.
|
if((*it) != mOwnGpgId) // skip our own id.
|
||||||
{
|
{
|
||||||
RsTlvKeyValue kv;
|
RsTlvKeyValue kv;
|
||||||
|
@ -715,7 +715,7 @@ bool AuthGPG::loadList(std::list<RsItem*>& load)
|
||||||
std::list<RsTlvKeyValue>::iterator kit;
|
std::list<RsTlvKeyValue>::iterator kit;
|
||||||
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); kit++)
|
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); kit++)
|
||||||
if (kit->key != mOwnGpgId.toStdString())
|
if (kit->key != mOwnGpgId.toStdString())
|
||||||
PGPHandler::setAcceptConnexion(PGPIdType(kit->key), (kit->value == "TRUE"));
|
PGPHandler::setAcceptConnexion(RsPgpId(kit->key), (kit->value == "TRUE"));
|
||||||
}
|
}
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
class AuthGPGOperationLoadOrSave : public AuthGPGOperation
|
class AuthGPGOperationLoadOrSave : public AuthGPGOperation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AuthGPGOperationLoadOrSave(bool load, const PGPIdType &gpgId, const std::string &gpgCert, void *userdata)
|
AuthGPGOperationLoadOrSave(bool load, const RsPgpId &gpgId, const std::string &gpgCert, void *userdata)
|
||||||
: AuthGPGOperation(userdata)
|
: AuthGPGOperation(userdata)
|
||||||
{
|
{
|
||||||
m_load = load;
|
m_load = load;
|
||||||
|
@ -82,7 +82,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool m_load;
|
bool m_load;
|
||||||
PGPIdType m_certGpgId; // set for save & load.
|
RsPgpId m_certGpgId; // set for save & load.
|
||||||
std::string m_certGpg; // set for load
|
std::string m_certGpg; // set for load
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||||
/**
|
/**
|
||||||
* @param ids list of gpg certificate ids (note, not the actual certificates)
|
* @param ids list of gpg certificate ids (note, not the actual certificates)
|
||||||
*/
|
*/
|
||||||
//virtual bool availableGPGCertificatesWithPrivateKeys(std::list<PGPIdType> &ids);
|
//virtual bool availableGPGCertificatesWithPrivateKeys(std::list<RsPgpId> &ids);
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
/************************* STAGE 1 ***********************************************/
|
/************************* STAGE 1 ***********************************************/
|
||||||
|
@ -134,8 +134,8 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||||
|
|
||||||
/* Init by generating new Own PGP Cert, or selecting existing PGP Cert */
|
/* Init by generating new Own PGP Cert, or selecting existing PGP Cert */
|
||||||
|
|
||||||
virtual int GPGInit(const PGPIdType &ownId);
|
virtual int GPGInit(const RsPgpId &ownId);
|
||||||
virtual bool GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, PGPIdType &pgpId, std::string &errString);
|
virtual bool GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, RsPgpId &pgpId, std::string &errString);
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
/************************* STAGE 3 ***********************************************/
|
/************************* STAGE 3 ***********************************************/
|
||||||
|
@ -148,25 +148,25 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||||
* provide access to details in cache list.
|
* provide access to details in cache list.
|
||||||
*
|
*
|
||||||
****/
|
****/
|
||||||
virtual std::string getGPGName(const PGPIdType &pgp_id,bool *success = NULL);
|
virtual std::string getGPGName(const RsPgpId &pgp_id,bool *success = NULL);
|
||||||
virtual std::string getGPGEmail(const PGPIdType &pgp_id,bool *success = NULL);
|
virtual std::string getGPGEmail(const RsPgpId &pgp_id,bool *success = NULL);
|
||||||
|
|
||||||
/* PGP web of trust management */
|
/* PGP web of trust management */
|
||||||
virtual const PGPIdType& getGPGOwnId();
|
virtual const RsPgpId& getGPGOwnId();
|
||||||
virtual std::string getGPGOwnName();
|
virtual std::string getGPGOwnName();
|
||||||
|
|
||||||
//virtual std::string getGPGOwnEmail();
|
//virtual std::string getGPGOwnEmail();
|
||||||
virtual bool isKeySupported(const PGPIdType &id) const ;
|
virtual bool isKeySupported(const RsPgpId &id) const ;
|
||||||
virtual bool haveSecretKey(const PGPIdType &id) const ;
|
virtual bool haveSecretKey(const RsPgpId &id) const ;
|
||||||
virtual bool getGPGDetails(const PGPIdType& id, RsPeerDetails &d);
|
virtual bool getGPGDetails(const RsPgpId& id, RsPeerDetails &d);
|
||||||
virtual bool getGPGAllList(std::list<PGPIdType> &ids);
|
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
||||||
virtual bool getGPGValidList(std::list<PGPIdType> &ids);
|
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
|
||||||
virtual bool getGPGAcceptedList(std::list<PGPIdType> &ids);
|
virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids);
|
||||||
virtual bool getGPGSignedList(std::list<PGPIdType> &ids);
|
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
|
||||||
virtual bool importProfile(const std::string& filename,PGPIdType& gpg_id,std::string& import_error) ;
|
virtual bool importProfile(const std::string& filename,RsPgpId& gpg_id,std::string& import_error) ;
|
||||||
virtual bool exportProfile(const std::string& filename,const PGPIdType& gpg_id) ;
|
virtual bool exportProfile(const std::string& filename,const RsPgpId& gpg_id) ;
|
||||||
|
|
||||||
virtual bool removeKeysFromPGPKeyring(const std::list<PGPIdType>& pgp_ids,std::string& backup_file,uint32_t& error_code) ;
|
virtual bool removeKeysFromPGPKeyring(const std::list<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code) ;
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
/************************* STAGE 4 ***********************************************/
|
/************************* STAGE 4 ***********************************************/
|
||||||
|
@ -175,11 +175,11 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||||
* STAGE 4: Loading and Saving Certificates. (Strings and Files)
|
* STAGE 4: Loading and Saving Certificates. (Strings and Files)
|
||||||
*
|
*
|
||||||
****/
|
****/
|
||||||
virtual bool LoadCertificateFromString(const std::string &pem, PGPIdType& gpg_id,std::string& error_string);
|
virtual bool LoadCertificateFromString(const std::string &pem, RsPgpId& gpg_id,std::string& error_string);
|
||||||
virtual std::string SaveCertificateToString(const PGPIdType &id,bool include_signatures) ;
|
virtual std::string SaveCertificateToString(const RsPgpId &id,bool include_signatures) ;
|
||||||
|
|
||||||
// Cached certificates.
|
// Cached certificates.
|
||||||
bool getCachedGPGCertificate(const PGPIdType &id, std::string &certificate);
|
bool getCachedGPGCertificate(const RsPgpId &id, std::string &certificate);
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
/************************* STAGE 6 ***********************************************/
|
/************************* STAGE 6 ***********************************************/
|
||||||
|
@ -191,12 +191,12 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||||
* done in gpgroot already.
|
* done in gpgroot already.
|
||||||
*
|
*
|
||||||
****/
|
****/
|
||||||
virtual bool AllowConnection(const PGPIdType &gpg_id, bool accept);
|
virtual bool AllowConnection(const RsPgpId &gpg_id, bool accept);
|
||||||
|
|
||||||
virtual bool SignCertificateLevel0(const PGPIdType &id);
|
virtual bool SignCertificateLevel0(const RsPgpId &id);
|
||||||
virtual bool RevokeCertificate(const PGPIdType &id); /* Particularly hard - leave for later */
|
virtual bool RevokeCertificate(const RsPgpId &id); /* Particularly hard - leave for later */
|
||||||
|
|
||||||
virtual bool TrustCertificate(const PGPIdType& id, int trustlvl); //trustlvl is 2 for none, 3 for marginal and 4 for full trust
|
virtual bool TrustCertificate(const RsPgpId& id, int trustlvl); //trustlvl is 2 for none, 3 for marginal and 4 for full trust
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
/************************* STAGE 7 ***********************************************/
|
/************************* STAGE 7 ***********************************************/
|
||||||
|
@ -210,7 +210,7 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||||
virtual bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen);
|
virtual bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen);
|
||||||
virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const PGPFingerprintType& withfingerprint);
|
virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const PGPFingerprintType& withfingerprint);
|
||||||
|
|
||||||
virtual bool encryptDataBin(const PGPIdType& pgp_id,const void *data, const uint32_t len, unsigned char *encr, unsigned int *encrlen);
|
virtual bool encryptDataBin(const RsPgpId& pgp_id,const void *data, const uint32_t len, unsigned char *encr, unsigned int *encrlen);
|
||||||
virtual bool decryptDataBin(const void *data, const uint32_t len, unsigned char *decr, unsigned int *decrlen);
|
virtual bool decryptDataBin(const void *data, const uint32_t len, unsigned char *decr, unsigned int *decrlen);
|
||||||
|
|
||||||
virtual bool decryptTextFromFile( std::string& text,const std::string& filename);
|
virtual bool decryptTextFromFile( std::string& text,const std::string& filename);
|
||||||
|
@ -219,7 +219,7 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||||
// virtual bool decryptTextFromString( std::string& encrypted_text,std::string& clear_string);
|
// virtual bool decryptTextFromString( std::string& encrypted_text,std::string& clear_string);
|
||||||
// virtual bool encryptTextToString (const std::string& pgp_id,const std::string& clear_text,std::string& encrypted_string);
|
// virtual bool encryptTextToString (const std::string& pgp_id,const std::string& clear_text,std::string& encrypted_string);
|
||||||
|
|
||||||
bool getGPGFilteredList(std::list<PGPIdType>& list,bool (*filter)(const PGPCertificateInfo&) = NULL) ;
|
bool getGPGFilteredList(std::list<RsPgpId>& list,bool (*filter)(const PGPCertificateInfo&) = NULL) ;
|
||||||
|
|
||||||
//END of PGP public functions
|
//END of PGP public functions
|
||||||
|
|
||||||
|
@ -256,9 +256,9 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||||
bool VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, const PGPFingerprintType& withfingerprint);
|
bool VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, const PGPFingerprintType& withfingerprint);
|
||||||
|
|
||||||
/* Sign/Trust stuff */
|
/* Sign/Trust stuff */
|
||||||
int privateSignCertificate(const PGPIdType &id);
|
int privateSignCertificate(const RsPgpId &id);
|
||||||
int privateRevokeCertificate(const PGPIdType &id); /* revoke the signature on Certificate */
|
int privateRevokeCertificate(const RsPgpId &id); /* revoke the signature on Certificate */
|
||||||
int privateTrustCertificate(const PGPIdType& id, int trustlvl);
|
int privateTrustCertificate(const RsPgpId& id, int trustlvl);
|
||||||
|
|
||||||
// store all keys in map mKeyList to avoid calling gpgme exe repeatedly
|
// store all keys in map mKeyList to avoid calling gpgme exe repeatedly
|
||||||
//bool storeAllKeys();
|
//bool storeAllKeys();
|
||||||
|
@ -293,7 +293,7 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||||
|
|
||||||
time_t mStoreKeyTime;
|
time_t mStoreKeyTime;
|
||||||
|
|
||||||
PGPIdType mOwnGpgId;
|
RsPgpId mOwnGpgId;
|
||||||
bool gpgKeySelected;
|
bool gpgKeySelected;
|
||||||
bool _force_sync_database ;
|
bool _force_sync_database ;
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@ AuthSSL::AuthSSL()
|
||||||
static int verify_x509_callback(int preverify_ok, X509_STORE_CTX *ctx);
|
static int verify_x509_callback(int preverify_ok, X509_STORE_CTX *ctx);
|
||||||
|
|
||||||
|
|
||||||
sslcert::sslcert(X509 *x509, const SSLIdType& pid)
|
sslcert::sslcert(X509 *x509, const RsPeerId& pid)
|
||||||
{
|
{
|
||||||
certificate = x509;
|
certificate = x509;
|
||||||
id = pid;
|
id = pid;
|
||||||
|
@ -250,7 +250,7 @@ sslcert::sslcert(X509 *x509, const SSLIdType& pid)
|
||||||
location = getX509LocString(x509->cert_info->subject);
|
location = getX509LocString(x509->cert_info->subject);
|
||||||
email = "";
|
email = "";
|
||||||
|
|
||||||
issuer = PGPIdType(std::string(getX509CNString(x509->cert_info->issuer)));
|
issuer = RsPgpId(std::string(getX509CNString(x509->cert_info->issuer)));
|
||||||
|
|
||||||
authed = false;
|
authed = false;
|
||||||
}
|
}
|
||||||
|
@ -529,7 +529,7 @@ SSL_CTX *AuthSSLimpl::getCTX()
|
||||||
return sslctx;
|
return sslctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SSLIdType& AuthSSLimpl::OwnId()
|
const RsPeerId& AuthSSLimpl::OwnId()
|
||||||
{
|
{
|
||||||
#ifdef AUTHSSL_DEBUG
|
#ifdef AUTHSSL_DEBUG
|
||||||
// std::cerr << "AuthSSLimpl::OwnId()" << std::endl;
|
// std::cerr << "AuthSSLimpl::OwnId()" << std::endl;
|
||||||
|
@ -622,7 +622,7 @@ bool AuthSSLimpl::SignDataBin(const void *data, const uint32_t len,
|
||||||
|
|
||||||
|
|
||||||
bool AuthSSLimpl::VerifySignBin(const void *data, const uint32_t len,
|
bool AuthSSLimpl::VerifySignBin(const void *data, const uint32_t len,
|
||||||
unsigned char *sign, unsigned int signlen, const SSLIdType& sslId)
|
unsigned char *sign, unsigned int signlen, const RsPeerId& sslId)
|
||||||
{
|
{
|
||||||
/* find certificate.
|
/* find certificate.
|
||||||
* if we don't have - fail.
|
* if we don't have - fail.
|
||||||
|
@ -895,7 +895,7 @@ bool AuthSSLimpl::AuthX509WithGPG(X509 *x509,uint32_t& diagnostic)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extract CN for peer Id */
|
/* extract CN for peer Id */
|
||||||
PGPIdType issuer(std::string(getX509CNString(x509->cert_info->issuer)));
|
RsPgpId issuer(std::string(getX509CNString(x509->cert_info->issuer)));
|
||||||
RsPeerDetails pd;
|
RsPeerDetails pd;
|
||||||
#ifdef AUTHSSL_DEBUG
|
#ifdef AUTHSSL_DEBUG
|
||||||
std::cerr << "Checking GPG issuer : " << issuer.toStdString() << std::endl ;
|
std::cerr << "Checking GPG issuer : " << issuer.toStdString() << std::endl ;
|
||||||
|
@ -1016,7 +1016,7 @@ err:
|
||||||
|
|
||||||
|
|
||||||
/* validate + get id */
|
/* validate + get id */
|
||||||
bool AuthSSLimpl::ValidateCertificate(X509 *x509, SSLIdType &peerId)
|
bool AuthSSLimpl::ValidateCertificate(X509 *x509, RsPeerId &peerId)
|
||||||
{
|
{
|
||||||
uint32_t auth_diagnostic ;
|
uint32_t auth_diagnostic ;
|
||||||
|
|
||||||
|
@ -1068,7 +1068,7 @@ static int verify_x509_callback(int preverify_ok, X509_STORE_CTX *ctx)
|
||||||
|
|
||||||
if(x509 != NULL)
|
if(x509 != NULL)
|
||||||
{
|
{
|
||||||
PGPIdType gpgid (std::string(getX509CNString(x509->cert_info->issuer)));
|
RsPgpId gpgid (std::string(getX509CNString(x509->cert_info->issuer)));
|
||||||
if(gpgid.isNull())
|
if(gpgid.isNull())
|
||||||
{
|
{
|
||||||
std::cerr << "verify_x509_callback(): wrong PGP id \"" << std::string(getX509CNString(x509->cert_info->issuer)) << "\"" << std::endl;
|
std::cerr << "verify_x509_callback(): wrong PGP id \"" << std::string(getX509CNString(x509->cert_info->issuer)) << "\"" << std::endl;
|
||||||
|
@ -1153,7 +1153,7 @@ int AuthSSLimpl::VerifyX509Callback(int preverify_ok, X509_STORE_CTX *ctx)
|
||||||
std::cerr << "(WW) Certificate was rejected because authentication failed. Diagnostic = " << auth_diagnostic << std::endl;
|
std::cerr << "(WW) Certificate was rejected because authentication failed. Diagnostic = " << auth_diagnostic << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PGPIdType pgpid = PGPIdType(std::string(getX509CNString(X509_STORE_CTX_get_current_cert(ctx)->cert_info->issuer)));
|
RsPgpId pgpid = RsPgpId(std::string(getX509CNString(X509_STORE_CTX_get_current_cert(ctx)->cert_info->issuer)));
|
||||||
|
|
||||||
if (pgpid != AuthGPG::getAuthGPG()->getGPGOwnId() && !AuthGPG::getAuthGPG()->isGPGAccepted(pgpid))
|
if (pgpid != AuthGPG::getAuthGPG()->getGPGOwnId() && !AuthGPG::getAuthGPG()->isGPGAccepted(pgpid))
|
||||||
{
|
{
|
||||||
|
@ -1204,7 +1204,7 @@ int AuthSSLimpl::VerifyX509Callback(int preverify_ok, X509_STORE_CTX *ctx)
|
||||||
/********************************************************************************/
|
/********************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen, const SSLIdType& peerId)
|
bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen, const RsPeerId& peerId)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(sslMtx); /******* LOCKED ******/
|
RsStackMutex stack(sslMtx); /******* LOCKED ******/
|
||||||
|
|
||||||
|
@ -1400,7 +1400,7 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
|
||||||
/********************************************************************************/
|
/********************************************************************************/
|
||||||
/********************************************************************************/
|
/********************************************************************************/
|
||||||
|
|
||||||
void AuthSSLimpl::setCurrentConnectionAttemptInfo(const PGPIdType& gpg_id,const SSLIdType& ssl_id,const std::string& ssl_cn)
|
void AuthSSLimpl::setCurrentConnectionAttemptInfo(const RsPgpId& gpg_id,const RsPeerId& ssl_id,const std::string& ssl_cn)
|
||||||
{
|
{
|
||||||
#ifdef AUTHSSL_DEBUG
|
#ifdef AUTHSSL_DEBUG
|
||||||
std::cerr << "AuthSSL: registering connection attempt from:" << std::endl;
|
std::cerr << "AuthSSL: registering connection attempt from:" << std::endl;
|
||||||
|
@ -1412,7 +1412,7 @@ void AuthSSLimpl::setCurrentConnectionAttemptInfo(const PGPIdType& gpg_id,const
|
||||||
_last_sslid_to_connect = ssl_id ;
|
_last_sslid_to_connect = ssl_id ;
|
||||||
_last_sslcn_to_connect = ssl_cn ;
|
_last_sslcn_to_connect = ssl_cn ;
|
||||||
}
|
}
|
||||||
void AuthSSLimpl::getCurrentConnectionAttemptInfo(PGPIdType& gpg_id,SSLIdType& ssl_id,std::string& ssl_cn)
|
void AuthSSLimpl::getCurrentConnectionAttemptInfo(RsPgpId& gpg_id,RsPeerId& ssl_id,std::string& ssl_cn)
|
||||||
{
|
{
|
||||||
gpg_id = _last_gpgid_to_connect ;
|
gpg_id = _last_gpgid_to_connect ;
|
||||||
ssl_id = _last_sslid_to_connect ;
|
ssl_id = _last_sslid_to_connect ;
|
||||||
|
@ -1420,8 +1420,8 @@ void AuthSSLimpl::getCurrentConnectionAttemptInfo(PGPIdType& gpg_id,SSLIdType& s
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store for discovery */
|
/* store for discovery */
|
||||||
bool AuthSSLimpl::FailedCertificate(X509 *x509, const PGPIdType& gpgid,
|
bool AuthSSLimpl::FailedCertificate(X509 *x509, const RsPgpId& gpgid,
|
||||||
const SSLIdType& sslid,
|
const RsPeerId& sslid,
|
||||||
const std::string& sslcn,
|
const std::string& sslcn,
|
||||||
const struct sockaddr_storage& addr,
|
const struct sockaddr_storage& addr,
|
||||||
bool incoming)
|
bool incoming)
|
||||||
|
@ -1491,7 +1491,7 @@ bool AuthSSLimpl::FailedCertificate(X509 *x509, const PGPIdType& gpgid,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthSSLimpl::CheckCertificate(const SSLIdType& id, X509 *x509)
|
bool AuthSSLimpl::CheckCertificate(const RsPeerId& id, X509 *x509)
|
||||||
{
|
{
|
||||||
(void) id; /* remove unused parameter warning */
|
(void) id; /* remove unused parameter warning */
|
||||||
|
|
||||||
|
@ -1508,9 +1508,9 @@ bool AuthSSLimpl::CheckCertificate(const SSLIdType& id, X509 *x509)
|
||||||
|
|
||||||
|
|
||||||
/* Locked search -> internal help function */
|
/* Locked search -> internal help function */
|
||||||
bool AuthSSLimpl::locked_FindCert(const SSLIdType& id, sslcert **cert)
|
bool AuthSSLimpl::locked_FindCert(const RsPeerId& id, sslcert **cert)
|
||||||
{
|
{
|
||||||
std::map<SSLIdType, sslcert *>::iterator it;
|
std::map<RsPeerId, sslcert *>::iterator it;
|
||||||
|
|
||||||
if (mCerts.end() != (it = mCerts.find(id)))
|
if (mCerts.end() != (it = mCerts.find(id)))
|
||||||
{
|
{
|
||||||
|
@ -1523,9 +1523,9 @@ bool AuthSSLimpl::locked_FindCert(const SSLIdType& id, sslcert **cert)
|
||||||
|
|
||||||
/* Remove Certificate */
|
/* Remove Certificate */
|
||||||
|
|
||||||
bool AuthSSLimpl::RemoveX509(SSLIdType id)
|
bool AuthSSLimpl::RemoveX509(RsPeerId id)
|
||||||
{
|
{
|
||||||
std::map<SSLIdType, sslcert *>::iterator it;
|
std::map<RsPeerId, sslcert *>::iterator it;
|
||||||
|
|
||||||
RsStackMutex stack(sslMtx); /******* LOCKED ******/
|
RsStackMutex stack(sslMtx); /******* LOCKED ******/
|
||||||
|
|
||||||
|
@ -1576,7 +1576,7 @@ bool AuthSSLimpl::LocalStoreCert(X509* x509)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do a search */
|
/* do a search */
|
||||||
std::map<SSLIdType, sslcert *>::iterator it;
|
std::map<RsPeerId, sslcert *>::iterator it;
|
||||||
|
|
||||||
if (mCerts.end() != (it = mCerts.find(peerId)))
|
if (mCerts.end() != (it = mCerts.find(peerId)))
|
||||||
{
|
{
|
||||||
|
@ -1632,7 +1632,7 @@ bool AuthSSLimpl::saveList(bool& cleanup, std::list<RsItem*>& lst)
|
||||||
|
|
||||||
// Now save config for network digging strategies
|
// Now save config for network digging strategies
|
||||||
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
|
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
|
||||||
std::map<SSLIdType, sslcert*>::iterator mapIt;
|
std::map<RsPeerId, sslcert*>::iterator mapIt;
|
||||||
for (mapIt = mCerts.begin(); mapIt != mCerts.end(); mapIt++) {
|
for (mapIt = mCerts.begin(); mapIt != mCerts.end(); mapIt++) {
|
||||||
if (mapIt->first == mOwnId) {
|
if (mapIt->first == mOwnId) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1670,7 +1670,7 @@ bool AuthSSLimpl::loadList(std::list<RsItem*>& load)
|
||||||
|
|
||||||
std::list<RsTlvKeyValue>::iterator kit;
|
std::list<RsTlvKeyValue>::iterator kit;
|
||||||
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); kit++) {
|
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); kit++) {
|
||||||
if (SSLIdType(kit->key) == mOwnId) {
|
if (RsPeerId(kit->key) == mOwnId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,17 +61,17 @@ class AuthSSL;
|
||||||
class sslcert
|
class sslcert
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
sslcert(X509* x509, const SSLIdType& id);
|
sslcert(X509* x509, const RsPeerId& id);
|
||||||
sslcert();
|
sslcert();
|
||||||
|
|
||||||
/* certificate parameters */
|
/* certificate parameters */
|
||||||
SSLIdType id;
|
RsPeerId id;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string location;
|
std::string location;
|
||||||
std::string org;
|
std::string org;
|
||||||
std::string email;
|
std::string email;
|
||||||
|
|
||||||
PGPIdType issuer;
|
RsPgpId issuer;
|
||||||
PGPFingerprintType fpr;
|
PGPFingerprintType fpr;
|
||||||
|
|
||||||
/* Auth settings */
|
/* Auth settings */
|
||||||
|
@ -102,7 +102,7 @@ virtual bool CloseAuth() = 0;
|
||||||
/*********** Overloaded Functions from p3AuthMgr **********/
|
/*********** Overloaded Functions from p3AuthMgr **********/
|
||||||
|
|
||||||
/* get Certificate Id */
|
/* get Certificate Id */
|
||||||
virtual const SSLIdType& OwnId() = 0;
|
virtual const RsPeerId& OwnId() = 0;
|
||||||
virtual std::string getOwnLocation() = 0;
|
virtual std::string getOwnLocation() = 0;
|
||||||
|
|
||||||
/* Load/Save certificates */
|
/* Load/Save certificates */
|
||||||
|
@ -116,10 +116,10 @@ virtual bool SignDataBin(std::string, unsigned char*, unsigned int*) = 0;
|
||||||
virtual bool SignDataBin(const void*, uint32_t, unsigned char*, unsigned int*) = 0;
|
virtual bool SignDataBin(const void*, uint32_t, unsigned char*, unsigned int*) = 0;
|
||||||
virtual bool VerifyOwnSignBin(const void*, uint32_t, unsigned char*, unsigned int) = 0;
|
virtual bool VerifyOwnSignBin(const void*, uint32_t, unsigned char*, unsigned int) = 0;
|
||||||
virtual bool VerifySignBin(const void *data, const uint32_t len,
|
virtual bool VerifySignBin(const void *data, const uint32_t len,
|
||||||
unsigned char *sign, unsigned int signlen, const SSLIdType& sslId) = 0;
|
unsigned char *sign, unsigned int signlen, const RsPeerId& sslId) = 0;
|
||||||
|
|
||||||
// return : false if encrypt failed
|
// return : false if encrypt failed
|
||||||
virtual bool encrypt(void *&out, int &outlen, const void *in, int inlen, const SSLIdType& peerId) = 0;
|
virtual bool encrypt(void *&out, int &outlen, const void *in, int inlen, const RsPeerId& peerId) = 0;
|
||||||
// return : false if decrypt fails
|
// return : false if decrypt fails
|
||||||
virtual bool decrypt(void *&out, int &outlen, const void *in, int inlen) = 0;
|
virtual bool decrypt(void *&out, int &outlen, const void *in, int inlen) = 0;
|
||||||
|
|
||||||
|
@ -129,17 +129,17 @@ virtual bool AuthX509WithGPG(X509 *x509,uint32_t& auth_diagnostic)=0;
|
||||||
|
|
||||||
|
|
||||||
virtual int VerifyX509Callback(int preverify_ok, X509_STORE_CTX *ctx) = 0;
|
virtual int VerifyX509Callback(int preverify_ok, X509_STORE_CTX *ctx) = 0;
|
||||||
virtual bool ValidateCertificate(X509 *x509, SSLIdType& peerId) = 0; /* validate + get id */
|
virtual bool ValidateCertificate(X509 *x509, RsPeerId& peerId) = 0; /* validate + get id */
|
||||||
|
|
||||||
public: /* SSL specific functions used in pqissl/pqissllistener */
|
public: /* SSL specific functions used in pqissl/pqissllistener */
|
||||||
virtual SSL_CTX *getCTX() = 0;
|
virtual SSL_CTX *getCTX() = 0;
|
||||||
|
|
||||||
/* Restored these functions: */
|
/* Restored these functions: */
|
||||||
virtual void setCurrentConnectionAttemptInfo(const PGPIdType& gpg_id,const SSLIdType& ssl_id,const std::string& ssl_cn) = 0 ;
|
virtual void setCurrentConnectionAttemptInfo(const RsPgpId& gpg_id,const RsPeerId& ssl_id,const std::string& ssl_cn) = 0 ;
|
||||||
virtual void getCurrentConnectionAttemptInfo( PGPIdType& gpg_id, SSLIdType& ssl_id, std::string& ssl_cn) = 0 ;
|
virtual void getCurrentConnectionAttemptInfo( RsPgpId& gpg_id, RsPeerId& ssl_id, std::string& ssl_cn) = 0 ;
|
||||||
|
|
||||||
virtual bool FailedCertificate(X509 *x509, const PGPIdType& gpgid,const SSLIdType& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming) = 0; /* store for discovery */
|
virtual bool FailedCertificate(X509 *x509, const RsPgpId& gpgid,const RsPeerId& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming) = 0; /* store for discovery */
|
||||||
virtual bool CheckCertificate(const SSLIdType& peerId, X509 *x509) = 0; /* check that they are exact match */
|
virtual bool CheckCertificate(const RsPeerId& peerId, X509 *x509) = 0; /* check that they are exact match */
|
||||||
|
|
||||||
static void setAuthSSL_debug(AuthSSL*) ; // used for debug only. The real function is InitSSL()
|
static void setAuthSSL_debug(AuthSSL*) ; // used for debug only. The real function is InitSSL()
|
||||||
static AuthSSL *instance_ssl ;
|
static AuthSSL *instance_ssl ;
|
||||||
|
@ -162,7 +162,7 @@ virtual bool CloseAuth();
|
||||||
/*********** Overloaded Functions from p3AuthMgr **********/
|
/*********** Overloaded Functions from p3AuthMgr **********/
|
||||||
|
|
||||||
/* get Certificate Id */
|
/* get Certificate Id */
|
||||||
virtual const SSLIdType& OwnId();
|
virtual const RsPeerId& OwnId();
|
||||||
virtual std::string getOwnLocation();
|
virtual std::string getOwnLocation();
|
||||||
|
|
||||||
/* Load/Save certificates */
|
/* Load/Save certificates */
|
||||||
|
@ -176,10 +176,10 @@ virtual bool SignDataBin(std::string, unsigned char*, unsigned int*);
|
||||||
virtual bool SignDataBin(const void*, uint32_t, unsigned char*, unsigned int*);
|
virtual bool SignDataBin(const void*, uint32_t, unsigned char*, unsigned int*);
|
||||||
virtual bool VerifyOwnSignBin(const void*, uint32_t, unsigned char*, unsigned int);
|
virtual bool VerifyOwnSignBin(const void*, uint32_t, unsigned char*, unsigned int);
|
||||||
virtual bool VerifySignBin(const void *data, const uint32_t len,
|
virtual bool VerifySignBin(const void *data, const uint32_t len,
|
||||||
unsigned char *sign, unsigned int signlen, const SSLIdType& sslId);
|
unsigned char *sign, unsigned int signlen, const RsPeerId& sslId);
|
||||||
|
|
||||||
// return : false if encrypt failed
|
// return : false if encrypt failed
|
||||||
virtual bool encrypt(void *&out, int &outlen, const void *in, int inlen, const SSLIdType& peerId);
|
virtual bool encrypt(void *&out, int &outlen, const void *in, int inlen, const RsPeerId& peerId);
|
||||||
// return : false if decrypt fails
|
// return : false if decrypt fails
|
||||||
virtual bool decrypt(void *&out, int &outlen, const void *in, int inlen);
|
virtual bool decrypt(void *&out, int &outlen, const void *in, int inlen);
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ virtual bool AuthX509WithGPG(X509 *x509,uint32_t& auth_diagnostic);
|
||||||
|
|
||||||
|
|
||||||
virtual int VerifyX509Callback(int preverify_ok, X509_STORE_CTX *ctx);
|
virtual int VerifyX509Callback(int preverify_ok, X509_STORE_CTX *ctx);
|
||||||
virtual bool ValidateCertificate(X509 *x509, SSLIdType& peerId); /* validate + get id */
|
virtual bool ValidateCertificate(X509 *x509, RsPeerId& peerId); /* validate + get id */
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
|
@ -204,24 +204,24 @@ virtual bool ValidateCertificate(X509 *x509, SSLIdType& peerId); /* validate +
|
||||||
virtual SSL_CTX *getCTX();
|
virtual SSL_CTX *getCTX();
|
||||||
|
|
||||||
/* Restored these functions: */
|
/* Restored these functions: */
|
||||||
virtual void setCurrentConnectionAttemptInfo(const PGPIdType& gpg_id,const SSLIdType& ssl_id,const std::string& ssl_cn) ;
|
virtual void setCurrentConnectionAttemptInfo(const RsPgpId& gpg_id,const RsPeerId& ssl_id,const std::string& ssl_cn) ;
|
||||||
virtual void getCurrentConnectionAttemptInfo( PGPIdType& gpg_id, SSLIdType& ssl_id, std::string& ssl_cn) ;
|
virtual void getCurrentConnectionAttemptInfo( RsPgpId& gpg_id, RsPeerId& ssl_id, std::string& ssl_cn) ;
|
||||||
virtual bool FailedCertificate(X509 *x509, const PGPIdType& gpgid,const SSLIdType& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming); /* store for discovery */
|
virtual bool FailedCertificate(X509 *x509, const RsPgpId& gpgid,const RsPeerId& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming); /* store for discovery */
|
||||||
virtual bool CheckCertificate(const SSLIdType& peerId, X509 *x509); /* check that they are exact match */
|
virtual bool CheckCertificate(const RsPeerId& peerId, X509 *x509); /* check that they are exact match */
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool LocalStoreCert(X509* x509);
|
bool LocalStoreCert(X509* x509);
|
||||||
bool RemoveX509(const SSLIdType id);
|
bool RemoveX509(const RsPeerId id);
|
||||||
|
|
||||||
/*********** LOCKED Functions ******/
|
/*********** LOCKED Functions ******/
|
||||||
bool locked_FindCert(const SSLIdType& id, sslcert **cert);
|
bool locked_FindCert(const RsPeerId& id, sslcert **cert);
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
/* these variables are constants -> don't need to protect */
|
/* these variables are constants -> don't need to protect */
|
||||||
SSL_CTX *sslctx;
|
SSL_CTX *sslctx;
|
||||||
SSLIdType mOwnId;
|
RsPeerId mOwnId;
|
||||||
sslcert *mOwnCert;
|
sslcert *mOwnCert;
|
||||||
|
|
||||||
RsMutex sslMtx; /* protects all below */
|
RsMutex sslMtx; /* protects all below */
|
||||||
|
@ -232,11 +232,11 @@ bool locked_FindCert(const SSLIdType& id, sslcert **cert);
|
||||||
|
|
||||||
int init;
|
int init;
|
||||||
|
|
||||||
std::map<SSLIdType, sslcert *> mCerts;
|
std::map<RsPeerId, sslcert *> mCerts;
|
||||||
|
|
||||||
PGPIdType _last_gpgid_to_connect ;
|
RsPgpId _last_gpgid_to_connect ;
|
||||||
std::string _last_sslcn_to_connect ;
|
std::string _last_sslcn_to_connect ;
|
||||||
SSLIdType _last_sslid_to_connect ;
|
RsPeerId _last_sslid_to_connect ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MRK_AUTH_SSL_HEADER
|
#endif // MRK_AUTH_SSL_HEADER
|
||||||
|
|
|
@ -1029,7 +1029,7 @@ bool p3LinkMgrIMPL::connectResult(const RsPeerId &id, bool success, uint32_t fla
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// from pqissl, when a connection failed due to security
|
// from pqissl, when a connection failed due to security
|
||||||
void p3LinkMgrIMPL::notifyDeniedConnection(const PGPIdType& gpgid,const RsPeerId& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming)
|
void p3LinkMgrIMPL::notifyDeniedConnection(const RsPgpId& gpgid,const RsPeerId& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming)
|
||||||
{
|
{
|
||||||
std::cerr << "p3LinkMgrIMPL::notifyDeniedConnection()";
|
std::cerr << "p3LinkMgrIMPL::notifyDeniedConnection()";
|
||||||
std::cerr << " pgpid: " << gpgid;
|
std::cerr << " pgpid: " << gpgid;
|
||||||
|
|
|
@ -94,7 +94,7 @@ class peerConnectState
|
||||||
public:
|
public:
|
||||||
peerConnectState(); /* init */
|
peerConnectState(); /* init */
|
||||||
|
|
||||||
SSLIdType id;
|
RsPeerId id;
|
||||||
|
|
||||||
/***** Below here not stored permanently *****/
|
/***** Below here not stored permanently *****/
|
||||||
|
|
||||||
|
@ -155,26 +155,26 @@ class p3LinkMgr: public pqiConnectCb
|
||||||
virtual ~p3LinkMgr() { return; }
|
virtual ~p3LinkMgr() { return; }
|
||||||
|
|
||||||
|
|
||||||
virtual const SSLIdType& getOwnId() = 0;
|
virtual const RsPeerId& getOwnId() = 0;
|
||||||
virtual bool isOnline(const SSLIdType &ssl_id) = 0;
|
virtual bool isOnline(const RsPeerId &ssl_id) = 0;
|
||||||
virtual void getOnlineList(std::list<SSLIdType> &ssl_peers) = 0;
|
virtual void getOnlineList(std::list<RsPeerId> &ssl_peers) = 0;
|
||||||
virtual bool getPeerName(const SSLIdType &ssl_id, std::string &name) = 0;
|
virtual bool getPeerName(const RsPeerId &ssl_id, std::string &name) = 0;
|
||||||
virtual uint32_t getLinkType(const SSLIdType &ssl_id) = 0;
|
virtual uint32_t getLinkType(const RsPeerId &ssl_id) = 0;
|
||||||
|
|
||||||
/**************** handle monitors *****************/
|
/**************** handle monitors *****************/
|
||||||
virtual void addMonitor(pqiMonitor *mon) = 0;
|
virtual void addMonitor(pqiMonitor *mon) = 0;
|
||||||
virtual void removeMonitor(pqiMonitor *mon) = 0;
|
virtual void removeMonitor(pqiMonitor *mon) = 0;
|
||||||
|
|
||||||
/****************** Connections *******************/
|
/****************** Connections *******************/
|
||||||
virtual bool connectAttempt(const SSLIdType &id, struct sockaddr_storage &raddr,
|
virtual bool connectAttempt(const RsPeerId &id, struct sockaddr_storage &raddr,
|
||||||
struct sockaddr_storage &proxyaddr, struct sockaddr_storage &srcaddr,
|
struct sockaddr_storage &proxyaddr, struct sockaddr_storage &srcaddr,
|
||||||
uint32_t &delay, uint32_t &period, uint32_t &type, uint32_t &flags, uint32_t &bandwidth,
|
uint32_t &delay, uint32_t &period, uint32_t &type, uint32_t &flags, uint32_t &bandwidth,
|
||||||
std::string &domain_addr, uint16_t &domain_port) = 0;
|
std::string &domain_addr, uint16_t &domain_port) = 0;
|
||||||
|
|
||||||
virtual bool connectResult(const SSLIdType &id, bool success, uint32_t flags, const struct sockaddr_storage &remote_peer_address) = 0;
|
virtual bool connectResult(const RsPeerId &id, bool success, uint32_t flags, const struct sockaddr_storage &remote_peer_address) = 0;
|
||||||
virtual bool retryConnect(const SSLIdType &id) = 0;
|
virtual bool retryConnect(const RsPeerId &id) = 0;
|
||||||
|
|
||||||
virtual void notifyDeniedConnection(const PGPIdType& gpgid,const SSLIdType& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming) = 0;
|
virtual void notifyDeniedConnection(const RsPgpId& gpgid,const RsPeerId& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming) = 0;
|
||||||
|
|
||||||
/* Network Addresses */
|
/* Network Addresses */
|
||||||
virtual bool setLocalAddress(const struct sockaddr_storage &addr) = 0;
|
virtual bool setLocalAddress(const struct sockaddr_storage &addr) = 0;
|
||||||
|
@ -182,12 +182,12 @@ virtual bool getLocalAddress(struct sockaddr_storage &addr) = 0;
|
||||||
|
|
||||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||||
|
|
||||||
virtual void getFriendList(std::list<SSLIdType> &ssl_peers) = 0; // ONLY used by p3peers.cc USE p3PeerMgr instead.
|
virtual void getFriendList(std::list<RsPeerId> &ssl_peers) = 0; // ONLY used by p3peers.cc USE p3PeerMgr instead.
|
||||||
virtual bool getFriendNetStatus(const SSLIdType &id, peerConnectState &state) = 0; // ONLY used by p3peers.cc
|
virtual bool getFriendNetStatus(const RsPeerId &id, peerConnectState &state) = 0; // ONLY used by p3peers.cc
|
||||||
|
|
||||||
|
|
||||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||||
virtual int addFriend(const SSLIdType &ssl_id, bool isVisible) = 0;
|
virtual int addFriend(const RsPeerId &ssl_id, bool isVisible) = 0;
|
||||||
/******* overloaded from pqiConnectCb *************/
|
/******* overloaded from pqiConnectCb *************/
|
||||||
// THESE MUSTn't BE specfied HERE - as overloaded from pqiConnectCb.
|
// THESE MUSTn't BE specfied HERE - as overloaded from pqiConnectCb.
|
||||||
//virtual void peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
//virtual void peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||||
|
@ -212,11 +212,11 @@ class p3LinkMgrIMPL: public p3LinkMgr
|
||||||
/* EXTERNAL INTERFACE */
|
/* EXTERNAL INTERFACE */
|
||||||
/************************************************************************************************/
|
/************************************************************************************************/
|
||||||
|
|
||||||
virtual const SSLIdType& getOwnId();
|
virtual const RsPeerId& getOwnId();
|
||||||
virtual bool isOnline(const SSLIdType &ssl_id);
|
virtual bool isOnline(const RsPeerId &ssl_id);
|
||||||
virtual void getOnlineList(std::list<SSLIdType> &ssl_peers);
|
virtual void getOnlineList(std::list<RsPeerId> &ssl_peers);
|
||||||
virtual bool getPeerName(const SSLIdType &ssl_id, std::string &name);
|
virtual bool getPeerName(const RsPeerId &ssl_id, std::string &name);
|
||||||
virtual uint32_t getLinkType(const SSLIdType &ssl_id);
|
virtual uint32_t getLinkType(const RsPeerId &ssl_id);
|
||||||
|
|
||||||
|
|
||||||
/**************** handle monitors *****************/
|
/**************** handle monitors *****************/
|
||||||
|
@ -224,32 +224,32 @@ virtual void addMonitor(pqiMonitor *mon);
|
||||||
virtual void removeMonitor(pqiMonitor *mon);
|
virtual void removeMonitor(pqiMonitor *mon);
|
||||||
|
|
||||||
/****************** Connections *******************/
|
/****************** Connections *******************/
|
||||||
virtual bool connectAttempt(const SSLIdType &id, struct sockaddr_storage &raddr,
|
virtual bool connectAttempt(const RsPeerId &id, struct sockaddr_storage &raddr,
|
||||||
struct sockaddr_storage &proxyaddr, struct sockaddr_storage &srcaddr,
|
struct sockaddr_storage &proxyaddr, struct sockaddr_storage &srcaddr,
|
||||||
uint32_t &delay, uint32_t &period, uint32_t &type, uint32_t &flags, uint32_t &bandwidth,
|
uint32_t &delay, uint32_t &period, uint32_t &type, uint32_t &flags, uint32_t &bandwidth,
|
||||||
std::string &domain_addr, uint16_t &domain_port);
|
std::string &domain_addr, uint16_t &domain_port);
|
||||||
|
|
||||||
virtual bool connectResult(const SSLIdType &id, bool success, uint32_t flags, const struct sockaddr_storage &remote_peer_address);
|
virtual bool connectResult(const RsPeerId &id, bool success, uint32_t flags, const struct sockaddr_storage &remote_peer_address);
|
||||||
virtual bool retryConnect(const SSLIdType &id);
|
virtual bool retryConnect(const RsPeerId &id);
|
||||||
|
|
||||||
virtual void notifyDeniedConnection(const PGPIdType& gpgid,const SSLIdType& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming);
|
virtual void notifyDeniedConnection(const RsPgpId& gpgid,const RsPeerId& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming);
|
||||||
|
|
||||||
/* Network Addresses */
|
/* Network Addresses */
|
||||||
virtual bool setLocalAddress(const struct sockaddr_storage &addr);
|
virtual bool setLocalAddress(const struct sockaddr_storage &addr);
|
||||||
virtual bool getLocalAddress(struct sockaddr_storage &addr);
|
virtual bool getLocalAddress(struct sockaddr_storage &addr);
|
||||||
|
|
||||||
/******* overloaded from pqiConnectCb *************/
|
/******* overloaded from pqiConnectCb *************/
|
||||||
virtual void peerStatus(const SSLIdType& id, const pqiIpAddrSet &addrs,
|
virtual void peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs,
|
||||||
uint32_t type, uint32_t flags, uint32_t source);
|
uint32_t type, uint32_t flags, uint32_t source);
|
||||||
virtual void peerConnectRequest(const SSLIdType& id, const struct sockaddr_storage &raddr,
|
virtual void peerConnectRequest(const RsPeerId& id, const struct sockaddr_storage &raddr,
|
||||||
const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
|
const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
|
||||||
uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth);
|
uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth);
|
||||||
|
|
||||||
|
|
||||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||||
|
|
||||||
virtual void getFriendList(std::list<SSLIdType> &ssl_peers); // ONLY used by p3peers.cc USE p3PeerMgr instead.
|
virtual void getFriendList(std::list<RsPeerId> &ssl_peers); // ONLY used by p3peers.cc USE p3PeerMgr instead.
|
||||||
virtual bool getFriendNetStatus(const SSLIdType &id, peerConnectState &state); // ONLY used by p3peers.cc
|
virtual bool getFriendNetStatus(const RsPeerId &id, peerConnectState &state); // ONLY used by p3peers.cc
|
||||||
|
|
||||||
/************************************************************************************************/
|
/************************************************************************************************/
|
||||||
/* Extra IMPL Functions (used by p3PeerMgr, p3NetMgr + Setup) */
|
/* Extra IMPL Functions (used by p3PeerMgr, p3NetMgr + Setup) */
|
||||||
|
@ -260,11 +260,11 @@ virtual bool getFriendNetStatus(const SSLIdType &id, peerConnectState &state); /
|
||||||
void tick();
|
void tick();
|
||||||
|
|
||||||
/* THIS COULD BE ADDED TO INTERFACE */
|
/* THIS COULD BE ADDED TO INTERFACE */
|
||||||
void setFriendVisibility(const SSLIdType &id, bool isVisible);
|
void setFriendVisibility(const RsPeerId &id, bool isVisible);
|
||||||
|
|
||||||
/* add/remove friends */
|
/* add/remove friends */
|
||||||
virtual int addFriend(const SSLIdType &ssl_id, bool isVisible);
|
virtual int addFriend(const RsPeerId &ssl_id, bool isVisible);
|
||||||
int removeFriend(const SSLIdType &ssl_id);
|
int removeFriend(const RsPeerId &ssl_id);
|
||||||
|
|
||||||
void printPeerLists(std::ostream &out);
|
void printPeerLists(std::ostream &out);
|
||||||
|
|
||||||
|
@ -284,12 +284,12 @@ void statusTick();
|
||||||
void tickMonitors();
|
void tickMonitors();
|
||||||
|
|
||||||
/* connect attempts UDP */
|
/* connect attempts UDP */
|
||||||
bool tryConnectUDP(const SSLIdType &id, const struct sockaddr_storage &rUdpAddr,
|
bool tryConnectUDP(const RsPeerId &id, const struct sockaddr_storage &rUdpAddr,
|
||||||
const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
|
const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
|
||||||
uint32_t flags, uint32_t delay, uint32_t bandwidth);
|
uint32_t flags, uint32_t delay, uint32_t bandwidth);
|
||||||
|
|
||||||
/* connect attempts TCP */
|
/* connect attempts TCP */
|
||||||
bool retryConnectTCP(const SSLIdType &id);
|
bool retryConnectTCP(const RsPeerId &id);
|
||||||
|
|
||||||
void locked_ConnectAttempt_SpecificAddress(peerConnectState *peer, const struct sockaddr_storage &remoteAddr);
|
void locked_ConnectAttempt_SpecificAddress(peerConnectState *peer, const struct sockaddr_storage &remoteAddr);
|
||||||
void locked_ConnectAttempt_CurrentAddresses(peerConnectState *peer, const struct sockaddr_storage &localAddr, const struct sockaddr_storage &serverAddr);
|
void locked_ConnectAttempt_CurrentAddresses(peerConnectState *peer, const struct sockaddr_storage &localAddr, const struct sockaddr_storage &serverAddr);
|
||||||
|
@ -330,8 +330,8 @@ private:
|
||||||
|
|
||||||
//peerConnectState mOwnState;
|
//peerConnectState mOwnState;
|
||||||
|
|
||||||
std::map<SSLIdType, peerConnectState> mFriendList;
|
std::map<RsPeerId, peerConnectState> mFriendList;
|
||||||
std::map<SSLIdType, peerConnectState> mOthersList;
|
std::map<RsPeerId, peerConnectState> mOthersList;
|
||||||
|
|
||||||
std::list<RsPeerGroupItem *> groupList;
|
std::list<RsPeerGroupItem *> groupList;
|
||||||
uint32_t lastGroupId;
|
uint32_t lastGroupId;
|
||||||
|
|
|
@ -108,7 +108,7 @@ std::string textPeerConnectState(peerState &state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const PGPIdType& gpg_own_id, const std::string& gpg_own_name, const std::string& ssl_own_location)
|
p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_id, const std::string& gpg_own_name, const std::string& ssl_own_location)
|
||||||
:p3Config(CONFIG_TYPE_PEERS), mPeerMtx("p3PeerMgr"), mStatusChanged(false)
|
:p3Config(CONFIG_TYPE_PEERS), mPeerMtx("p3PeerMgr"), mStatusChanged(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ bool p3PeerMgrIMPL::getPeerName(const RsPeerId &ssl_id, std::string &name)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3PeerMgrIMPL::getGpgId(const RsPeerId &ssl_id, PGPIdType &gpgId)
|
bool p3PeerMgrIMPL::getGpgId(const RsPeerId &ssl_id, RsPgpId &gpgId)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ int p3PeerMgrIMPL::getFriendCount(bool ssl, bool online)
|
||||||
|
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
std::set<PGPIdType> gpgIds;
|
std::set<RsPgpId> gpgIds;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
std::map<RsPeerId, peerState>::iterator it;
|
std::map<RsPeerId, peerState>::iterator it;
|
||||||
|
@ -517,7 +517,7 @@ int p3PeerMgrIMPL::getFriendCount(bool ssl, bool online)
|
||||||
}
|
}
|
||||||
|
|
||||||
// count all gpg id's
|
// count all gpg id's
|
||||||
std::list<PGPIdType> gpgIds;
|
std::list<RsPgpId> gpgIds;
|
||||||
AuthGPG::getAuthGPG()->getGPGAcceptedList(gpgIds);
|
AuthGPG::getAuthGPG()->getGPGAcceptedList(gpgIds);
|
||||||
|
|
||||||
// add own gpg id, if we have more than one location
|
// add own gpg id, if we have more than one location
|
||||||
|
@ -621,11 +621,11 @@ bool p3PeerMgrIMPL::haveOnceConnected()
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
|
|
||||||
bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const PGPIdType& input_gpg_id, uint32_t netMode, uint16_t vs_disc, uint16_t vs_dht, time_t lastContact,ServicePermissionFlags service_flags)
|
bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg_id, uint32_t netMode, uint16_t vs_disc, uint16_t vs_dht, time_t lastContact,ServicePermissionFlags service_flags)
|
||||||
{
|
{
|
||||||
bool notifyLinkMgr = false;
|
bool notifyLinkMgr = false;
|
||||||
RsPeerId id = input_id ;
|
RsPeerId id = input_id ;
|
||||||
PGPIdType gpg_id = input_gpg_id ;
|
RsPgpId gpg_id = input_gpg_id ;
|
||||||
|
|
||||||
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::addFriend() id: " + id.toStdString());
|
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::addFriend() id: " + id.toStdString());
|
||||||
|
|
||||||
|
@ -786,7 +786,7 @@ bool p3PeerMgrIMPL::removeFriend(const RsPgpId &id)
|
||||||
if (mFriendList.end() != (it = mFriendList.find(*rit)))
|
if (mFriendList.end() != (it = mFriendList.find(*rit)))
|
||||||
mFriendList.erase(it);
|
mFriendList.erase(it);
|
||||||
|
|
||||||
std::map<PGPIdType,ServicePermissionFlags>::iterator it2 = mFriendsPermissionFlags.find(id) ;
|
std::map<RsPgpId,ServicePermissionFlags>::iterator it2 = mFriendsPermissionFlags.find(id) ;
|
||||||
|
|
||||||
if(it2 != mFriendsPermissionFlags.end())
|
if(it2 != mFriendsPermissionFlags.end())
|
||||||
mFriendsPermissionFlags.erase(it2);
|
mFriendsPermissionFlags.erase(it2);
|
||||||
|
@ -828,7 +828,7 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
|
||||||
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::removeFriend() id: " + id.toStdString());
|
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::removeFriend() id: " + id.toStdString());
|
||||||
|
|
||||||
std::list<RsPeerId> sslid_toRemove; // This is a list of SSLIds.
|
std::list<RsPeerId> sslid_toRemove; // This is a list of SSLIds.
|
||||||
std::list<PGPIdType> pgpid_toRemove; // This is a list of SSLIds.
|
std::list<RsPgpId> pgpid_toRemove; // This is a list of SSLIds.
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
@ -861,9 +861,9 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
|
||||||
if (mFriendList.end() != (it = mFriendList.find(*rit)))
|
if (mFriendList.end() != (it = mFriendList.find(*rit)))
|
||||||
mFriendList.erase(it);
|
mFriendList.erase(it);
|
||||||
|
|
||||||
std::map<PGPIdType,ServicePermissionFlags>::iterator it2 ;
|
std::map<RsPgpId,ServicePermissionFlags>::iterator it2 ;
|
||||||
|
|
||||||
for(std::list<PGPIdType>::iterator rit = pgpid_toRemove.begin(); rit != pgpid_toRemove.end(); rit++)
|
for(std::list<RsPgpId>::iterator rit = pgpid_toRemove.begin(); rit != pgpid_toRemove.end(); rit++)
|
||||||
if (mFriendsPermissionFlags.end() != (it2 = mFriendsPermissionFlags.find(*rit)))
|
if (mFriendsPermissionFlags.end() != (it2 = mFriendsPermissionFlags.find(*rit)))
|
||||||
mFriendsPermissionFlags.erase(it2);
|
mFriendsPermissionFlags.erase(it2);
|
||||||
|
|
||||||
|
@ -1559,7 +1559,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||||
|
|
||||||
RsPeerServicePermissionItem *sitem = new RsPeerServicePermissionItem ;
|
RsPeerServicePermissionItem *sitem = new RsPeerServicePermissionItem ;
|
||||||
|
|
||||||
for(std::map<PGPIdType,ServicePermissionFlags>::const_iterator it(mFriendsPermissionFlags.begin());it!=mFriendsPermissionFlags.end();++it)
|
for(std::map<RsPgpId,ServicePermissionFlags>::const_iterator it(mFriendsPermissionFlags.begin());it!=mFriendsPermissionFlags.end();++it)
|
||||||
{
|
{
|
||||||
sitem->pgp_ids.push_back(it->first) ;
|
sitem->pgp_ids.push_back(it->first) ;
|
||||||
sitem->service_flags.push_back(it->second) ;
|
sitem->service_flags.push_back(it->second) ;
|
||||||
|
@ -1644,7 +1644,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||||
if (pitem)
|
if (pitem)
|
||||||
{
|
{
|
||||||
RsPeerId peer_id(pitem->pid) ;
|
RsPeerId peer_id(pitem->pid) ;
|
||||||
PGPIdType peer_pgp_id(pitem->gpg_id) ;
|
RsPgpId peer_pgp_id(pitem->gpg_id) ;
|
||||||
|
|
||||||
if (peer_id == ownId)
|
if (peer_id == ownId)
|
||||||
{
|
{
|
||||||
|
@ -2022,7 +2022,7 @@ bool p3PeerMgrIMPL::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
|
||||||
}
|
}
|
||||||
|
|
||||||
// groupId == "" && assign == false -> remove from all groups
|
// groupId == "" && assign == false -> remove from all groups
|
||||||
bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType> &peerIds, bool assign)
|
bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign)
|
||||||
{
|
{
|
||||||
if (groupId.empty() && assign == true) {
|
if (groupId.empty() && assign == true) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2042,9 +2042,9 @@ bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::li
|
||||||
if (groupId.empty() || (*groupIt)->id == groupId) {
|
if (groupId.empty() || (*groupIt)->id == groupId) {
|
||||||
RsPeerGroupItem *groupItem = *groupIt;
|
RsPeerGroupItem *groupItem = *groupIt;
|
||||||
|
|
||||||
std::list<PGPIdType>::const_iterator peerIt;
|
std::list<RsPgpId>::const_iterator peerIt;
|
||||||
for (peerIt = peerIds.begin(); peerIt != peerIds.end(); peerIt++) {
|
for (peerIt = peerIds.begin(); peerIt != peerIds.end(); peerIt++) {
|
||||||
std::list<PGPIdType>::iterator peerIt1 = std::find(groupItem->peerIds.begin(), groupItem->peerIds.end(), *peerIt);
|
std::list<RsPgpId>::iterator peerIt1 = std::find(groupItem->peerIds.begin(), groupItem->peerIds.end(), *peerIt);
|
||||||
if (assign) {
|
if (assign) {
|
||||||
if (peerIt1 == groupItem->peerIds.end()) {
|
if (peerIt1 == groupItem->peerIds.end()) {
|
||||||
groupItem->peerIds.push_back(*peerIt);
|
groupItem->peerIds.push_back(*peerIt);
|
||||||
|
@ -2083,7 +2083,7 @@ bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::li
|
||||||
|
|
||||||
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const RsPeerId& ssl_id)
|
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const RsPeerId& ssl_id)
|
||||||
{
|
{
|
||||||
PGPIdType gpg_id ;
|
RsPgpId gpg_id ;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
@ -2100,12 +2100,12 @@ ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const RsPeerId& ssl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const PGPIdType& pgp_id)
|
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const RsPgpId& pgp_id)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
std::map<PGPIdType,ServicePermissionFlags>::const_iterator it = mFriendsPermissionFlags.find( pgp_id ) ;
|
std::map<RsPgpId,ServicePermissionFlags>::const_iterator it = mFriendsPermissionFlags.find( pgp_id ) ;
|
||||||
|
|
||||||
if(it == mFriendsPermissionFlags.end())
|
if(it == mFriendsPermissionFlags.end())
|
||||||
return RS_SERVICE_PERM_ALL ;
|
return RS_SERVICE_PERM_ALL ;
|
||||||
|
@ -2113,7 +2113,7 @@ ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const PGPIdType& pg
|
||||||
return it->second ;
|
return it->second ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void p3PeerMgrIMPL::setServicePermissionFlags(const PGPIdType& pgp_id, const ServicePermissionFlags& flags)
|
void p3PeerMgrIMPL::setServicePermissionFlags(const RsPgpId& pgp_id, const ServicePermissionFlags& flags)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
|
@ -2131,7 +2131,7 @@ void p3PeerMgrIMPL::setServicePermissionFlags(const PGPIdType& pgp_id, const Ser
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
bool p3PeerMgrIMPL::removeAllFriendLocations(const PGPIdType &gpgid)
|
bool p3PeerMgrIMPL::removeAllFriendLocations(const RsPgpId &gpgid)
|
||||||
{
|
{
|
||||||
std::list<RsPeerId> sslIds;
|
std::list<RsPeerId> sslIds;
|
||||||
if (!getAssociatedPeers(gpgid, sslIds))
|
if (!getAssociatedPeers(gpgid, sslIds))
|
||||||
|
@ -2149,7 +2149,7 @@ bool p3PeerMgrIMPL::removeAllFriendLocations(const PGPIdType &gpgid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool p3PeerMgrIMPL::getAssociatedPeers(const PGPIdType &gpg_id, std::list<RsPeerId> &ids)
|
bool p3PeerMgrIMPL::getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId> &ids)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ class peerState
|
||||||
peerState(); /* init */
|
peerState(); /* init */
|
||||||
|
|
||||||
RsPeerId id;
|
RsPeerId id;
|
||||||
PGPIdType gpg_id;
|
RsPgpId gpg_id;
|
||||||
|
|
||||||
uint32_t netMode; /* EXT / UPNP / UDP / HIDDEN / INVALID */
|
uint32_t netMode; /* EXT / UPNP / UDP / HIDDEN / INVALID */
|
||||||
/* visState */
|
/* visState */
|
||||||
|
@ -114,15 +114,15 @@ class p3PeerMgr
|
||||||
p3PeerMgr() { return; }
|
p3PeerMgr() { return; }
|
||||||
virtual ~p3PeerMgr() { return; }
|
virtual ~p3PeerMgr() { return; }
|
||||||
|
|
||||||
virtual bool addFriend(const RsPeerId &ssl_id, const PGPIdType &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
||||||
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
|
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
|
||||||
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL)) = 0;
|
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL)) = 0;
|
||||||
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0;
|
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0;
|
||||||
|
|
||||||
virtual bool isFriend(const RsPeerId& ssl_id) = 0;
|
virtual bool isFriend(const RsPeerId& ssl_id) = 0;
|
||||||
|
|
||||||
virtual bool getAssociatedPeers(const PGPIdType &gpg_id, std::list<RsPeerId> &ids) = 0;
|
virtual bool getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId> &ids) = 0;
|
||||||
virtual bool removeAllFriendLocations(const PGPIdType &gpgid) = 0;
|
virtual bool removeAllFriendLocations(const RsPgpId &gpgid) = 0;
|
||||||
|
|
||||||
|
|
||||||
/******************** Groups **********************/
|
/******************** Groups **********************/
|
||||||
|
@ -133,11 +133,11 @@ virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) =
|
||||||
virtual bool removeGroup(const std::string &groupId) = 0;
|
virtual bool removeGroup(const std::string &groupId) = 0;
|
||||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
||||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType> &peerIds, bool assign) = 0;
|
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
|
||||||
|
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const PGPIdType& gpg_id) =0;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) =0;
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) =0;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) =0;
|
||||||
virtual void setServicePermissionFlags(const PGPIdType& gpg_id,const ServicePermissionFlags& flags) =0;
|
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) =0;
|
||||||
|
|
||||||
/**************** Set Net Info ****************/
|
/**************** Set Net Info ****************/
|
||||||
/*
|
/*
|
||||||
|
@ -179,7 +179,7 @@ virtual bool getFriendNetStatus(const RsPeerId &id, peerState &state) = 0;
|
||||||
virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state) = 0;
|
virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state) = 0;
|
||||||
|
|
||||||
virtual bool getPeerName(const RsPeerId &ssl_id, std::string &name) = 0;
|
virtual bool getPeerName(const RsPeerId &ssl_id, std::string &name) = 0;
|
||||||
virtual bool getGpgId(const RsPeerId &sslId, PGPIdType &gpgId) = 0;
|
virtual bool getGpgId(const RsPeerId &sslId, RsPgpId &gpgId) = 0;
|
||||||
virtual uint32_t getConnectionType(const RsPeerId &sslId) = 0;
|
virtual uint32_t getConnectionType(const RsPeerId &sslId) = 0;
|
||||||
|
|
||||||
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr) = 0;
|
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr) = 0;
|
||||||
|
@ -214,7 +214,7 @@ class p3PeerMgrIMPL: public p3PeerMgr, public p3Config
|
||||||
/* EXTERNAL INTERFACE */
|
/* EXTERNAL INTERFACE */
|
||||||
/************************************************************************************************/
|
/************************************************************************************************/
|
||||||
|
|
||||||
virtual bool addFriend(const RsPeerId&ssl_id, const PGPIdType&gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
virtual bool addFriend(const RsPeerId&ssl_id, const RsPgpId&gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
||||||
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
|
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
|
||||||
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL));
|
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL));
|
||||||
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId);
|
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId);
|
||||||
|
@ -222,8 +222,8 @@ virtual bool removeFriend(const RsPgpId &pgp_id);
|
||||||
|
|
||||||
virtual bool isFriend(const RsPeerId &ssl_id);
|
virtual bool isFriend(const RsPeerId &ssl_id);
|
||||||
|
|
||||||
virtual bool getAssociatedPeers(const PGPIdType &gpg_id, std::list<RsPeerId> &ids);
|
virtual bool getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId> &ids);
|
||||||
virtual bool removeAllFriendLocations(const PGPIdType &gpgid);
|
virtual bool removeAllFriendLocations(const RsPgpId &gpgid);
|
||||||
|
|
||||||
|
|
||||||
/******************** Groups **********************/
|
/******************** Groups **********************/
|
||||||
|
@ -234,11 +234,11 @@ virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||||
virtual bool removeGroup(const std::string &groupId);
|
virtual bool removeGroup(const std::string &groupId);
|
||||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
||||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType> &peerIds, bool assign);
|
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign);
|
||||||
|
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const PGPIdType& gpg_id) ;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ;
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) ;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) ;
|
||||||
virtual void setServicePermissionFlags(const PGPIdType& gpg_id,const ServicePermissionFlags& flags) ;
|
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ;
|
||||||
|
|
||||||
/**************** Set Net Info ****************/
|
/**************** Set Net Info ****************/
|
||||||
/*
|
/*
|
||||||
|
@ -279,7 +279,7 @@ virtual bool getFriendNetStatus(const RsPeerId &id, peerState &state);
|
||||||
virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state);
|
virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state);
|
||||||
|
|
||||||
virtual bool getPeerName(const RsPeerId& ssl_id, std::string& name);
|
virtual bool getPeerName(const RsPeerId& ssl_id, std::string& name);
|
||||||
virtual bool getGpgId(const RsPeerId& sslId, PGPIdType& gpgId);
|
virtual bool getGpgId(const RsPeerId& sslId, RsPgpId& gpgId);
|
||||||
virtual uint32_t getConnectionType(const RsPeerId& sslId);
|
virtual uint32_t getConnectionType(const RsPeerId& sslId);
|
||||||
|
|
||||||
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr);
|
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr);
|
||||||
|
@ -301,7 +301,7 @@ virtual bool haveOnceConnected();
|
||||||
/************************************************************************************************/
|
/************************************************************************************************/
|
||||||
|
|
||||||
p3PeerMgrIMPL( const RsPeerId& ssl_own_id,
|
p3PeerMgrIMPL( const RsPeerId& ssl_own_id,
|
||||||
const PGPIdType& gpg_own_id,
|
const RsPgpId& gpg_own_id,
|
||||||
const std::string& gpg_own_name,
|
const std::string& gpg_own_name,
|
||||||
const std::string& ssl_own_location) ;
|
const std::string& ssl_own_location) ;
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ private:
|
||||||
|
|
||||||
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
|
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
|
||||||
|
|
||||||
std::map<PGPIdType, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key
|
std::map<RsPgpId, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key
|
||||||
|
|
||||||
struct sockaddr_storage mProxyServerAddress;
|
struct sockaddr_storage mProxyServerAddress;
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,7 +98,7 @@ const uint32_t RS_STUN_FRIEND_OF_FRIEND = 0x0040;
|
||||||
class pqipeer
|
class pqipeer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SSLIdType id;
|
RsPeerId id;
|
||||||
std::string name;
|
std::string name;
|
||||||
uint32_t state;
|
uint32_t state;
|
||||||
uint32_t actions;
|
uint32_t actions;
|
||||||
|
|
|
@ -1222,7 +1222,7 @@ int pqissl::Extract_Failed_SSL_Certificate()
|
||||||
RsPeerId sslid ;
|
RsPeerId sslid ;
|
||||||
getX509id(peercert, sslid) ;
|
getX509id(peercert, sslid) ;
|
||||||
|
|
||||||
PGPIdType gpgid(getX509CNString(peercert->cert_info->issuer));
|
RsPgpId gpgid(getX509CNString(peercert->cert_info->issuer));
|
||||||
std::string sslcn = getX509CNString(peercert->cert_info->subject);
|
std::string sslcn = getX509CNString(peercert->cert_info->subject);
|
||||||
|
|
||||||
AuthSSL::getAuthSSL()->FailedCertificate(peercert, gpgid,sslid,sslcn,remote_addr, false);
|
AuthSSL::getAuthSSL()->FailedCertificate(peercert, gpgid,sslid,sslcn,remote_addr, false);
|
||||||
|
|
|
@ -383,7 +383,7 @@ int pqissllistenbase::continueSSL(IncomingSSLInfo& incoming_connexion_info, bool
|
||||||
|
|
||||||
// clear the connection info that will be filled in by the callback.
|
// clear the connection info that will be filled in by the callback.
|
||||||
//
|
//
|
||||||
AuthSSL::getAuthSSL()->setCurrentConnectionAttemptInfo(PGPIdType(),RsPeerId(),std::string()) ;
|
AuthSSL::getAuthSSL()->setCurrentConnectionAttemptInfo(RsPgpId(),RsPeerId(),std::string()) ;
|
||||||
|
|
||||||
int err = SSL_accept(incoming_connexion_info.ssl);
|
int err = SSL_accept(incoming_connexion_info.ssl);
|
||||||
|
|
||||||
|
@ -836,7 +836,7 @@ int pqissllistener::completeConnection(int fd, IncomingSSLInfo& info)
|
||||||
AuthSSL::getAuthSSL()->CheckCertificate(newPeerId, peercert);
|
AuthSSL::getAuthSSL()->CheckCertificate(newPeerId, peercert);
|
||||||
|
|
||||||
/* now need to get GPG id too */
|
/* now need to get GPG id too */
|
||||||
PGPIdType pgpid(std::string(getX509CNString(peercert->cert_info->issuer)));
|
RsPgpId pgpid(std::string(getX509CNString(peercert->cert_info->issuer)));
|
||||||
mPeerMgr->addFriend(newPeerId, pgpid);
|
mPeerMgr->addFriend(newPeerId, pgpid);
|
||||||
|
|
||||||
X509_free(peercert);
|
X509_free(peercert);
|
||||||
|
|
|
@ -89,8 +89,8 @@ int finaliseAccepts();
|
||||||
{
|
{
|
||||||
SSL *ssl ;
|
SSL *ssl ;
|
||||||
sockaddr_storage addr ;
|
sockaddr_storage addr ;
|
||||||
PGPIdType gpgid ;
|
RsPgpId gpgid ;
|
||||||
SSLIdType sslid ;
|
RsPeerId sslid ;
|
||||||
std::string sslcn ;
|
std::string sslcn ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -693,7 +693,7 @@ bool CheckX509Certificate(X509 */*x509*/)
|
||||||
|
|
||||||
|
|
||||||
// Not dependent on sslroot. load, and detroys the X509 memory.
|
// Not dependent on sslroot. load, and detroys the X509 memory.
|
||||||
int LoadCheckX509(const char *cert_file, PGPIdType& issuerName, std::string &location, RsPeerId &userId)
|
int LoadCheckX509(const char *cert_file, RsPgpId& issuerName, std::string &location, RsPeerId &userId)
|
||||||
{
|
{
|
||||||
/* This function loads the X509 certificate from the file,
|
/* This function loads the X509 certificate from the file,
|
||||||
* and checks the certificate
|
* and checks the certificate
|
||||||
|
@ -728,7 +728,7 @@ int LoadCheckX509(const char *cert_file, PGPIdType& issuerName, std::string &loc
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
// extract the name.
|
// extract the name.
|
||||||
issuerName = PGPIdType(std::string(getX509CNString(x509->cert_info->issuer)));
|
issuerName = RsPgpId(std::string(getX509CNString(x509->cert_info->issuer)));
|
||||||
location = getX509LocString(x509->cert_info->subject);
|
location = getX509LocString(x509->cert_info->subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ int pem_passwd_cb(char *buf, int size, int rwflag, void *password);
|
||||||
|
|
||||||
bool CheckX509Certificate(X509 *x509);
|
bool CheckX509Certificate(X509 *x509);
|
||||||
// Not dependent on sslroot. load, and detroys the X509 memory.
|
// Not dependent on sslroot. load, and detroys the X509 memory.
|
||||||
int LoadCheckX509(const char *cert_file, PGPIdType& issuer, std::string &location, RsPeerId& userId);
|
int LoadCheckX509(const char *cert_file, RsPgpId& issuer, std::string &location, RsPeerId& userId);
|
||||||
|
|
||||||
|
|
||||||
std::string getX509NameString(X509_NAME *name);
|
std::string getX509NameString(X509_NAME *name);
|
||||||
|
|
|
@ -44,7 +44,7 @@ class RsDisc
|
||||||
virtual ~RsDisc() { return; }
|
virtual ~RsDisc() { return; }
|
||||||
|
|
||||||
virtual bool getDiscFriends(const RsPeerId &id, std::list<RsPeerId>& friends) = 0;
|
virtual bool getDiscFriends(const RsPeerId &id, std::list<RsPeerId>& friends) = 0;
|
||||||
virtual bool getDiscPgpFriends(const PGPIdType &pgpid, std::list<PGPIdType>& gpg_friends) = 0;
|
virtual bool getDiscPgpFriends(const RsPgpId &pgpid, std::list<RsPgpId>& gpg_friends) = 0;
|
||||||
virtual bool getPeerVersion(const RsPeerId &id, std::string &versions) = 0;
|
virtual bool getPeerVersion(const RsPeerId &id, std::string &versions) = 0;
|
||||||
virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount) = 0;
|
virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount) = 0;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ extern RsGxsCircles *rsGxsCircles;
|
||||||
|
|
||||||
|
|
||||||
typedef std::string RsGxsCircleId;
|
typedef std::string RsGxsCircleId;
|
||||||
typedef PGPIdType RsPgpId;
|
typedef RsPgpId RsPgpId;
|
||||||
typedef std::string RsCircleInternalId;
|
typedef std::string RsCircleInternalId;
|
||||||
|
|
||||||
#define GXS_CIRCLE_TYPE_PUBLIC 0x0001
|
#define GXS_CIRCLE_TYPE_PUBLIC 0x0001
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
//
|
//
|
||||||
// To use this class, derive your own ID type from it. Examples include:
|
// To use this class, derive your own ID type from it. Examples include:
|
||||||
//
|
//
|
||||||
// class PGPIdType: public t_RsGenericIdType<8>
|
// class RsPgpId: public t_RsGenericIdType<8>
|
||||||
// {
|
// {
|
||||||
// [..]
|
// [..]
|
||||||
// };
|
// };
|
||||||
|
@ -210,7 +210,7 @@ static const uint32_t RS_GENERIC_ID_GXS_MSG_ID_TYPE = 0x0007 ;
|
||||||
static const uint32_t RS_GENERIC_ID_GXS_CIRCLE_ID_TYPE = 0x0008 ;
|
static const uint32_t RS_GENERIC_ID_GXS_CIRCLE_ID_TYPE = 0x0008 ;
|
||||||
|
|
||||||
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_SSL_ID_TYPE> SSLIdType ;
|
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_SSL_ID_TYPE> SSLIdType ;
|
||||||
typedef t_RsGenericIdType< PGP_KEY_ID_SIZE , true, RS_GENERIC_ID_PGP_ID_TYPE> PGPIdType;
|
typedef t_RsGenericIdType< PGP_KEY_ID_SIZE , true, RS_GENERIC_ID_PGP_ID_TYPE> PGPIdType ;
|
||||||
typedef t_RsGenericIdType< SHA1_SIZE , false, RS_GENERIC_ID_SHA1_ID_TYPE> Sha1CheckSum ;
|
typedef t_RsGenericIdType< SHA1_SIZE , false, RS_GENERIC_ID_SHA1_ID_TYPE> Sha1CheckSum ;
|
||||||
typedef t_RsGenericIdType< PGP_KEY_FINGERPRINT_SIZE, true, RS_GENERIC_ID_PGP_FINGERPRINT_TYPE> PGPFingerprintType ;
|
typedef t_RsGenericIdType< PGP_KEY_FINGERPRINT_SIZE, true, RS_GENERIC_ID_PGP_FINGERPRINT_TYPE> PGPFingerprintType ;
|
||||||
|
|
||||||
|
|
|
@ -137,13 +137,13 @@ namespace RsAccounts
|
||||||
std::string AccountDirectory();
|
std::string AccountDirectory();
|
||||||
|
|
||||||
// PGP Accounts.
|
// PGP Accounts.
|
||||||
int GetPGPLogins(std::list<PGPIdType> &pgpIds);
|
int GetPGPLogins(std::list<RsPgpId> &pgpIds);
|
||||||
int GetPGPLoginDetails(const PGPIdType& id, std::string &name, std::string &email);
|
int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
|
||||||
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, PGPIdType &pgpId, std::string &errString);
|
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, std::string &errString);
|
||||||
|
|
||||||
// PGP Support Functions.
|
// PGP Support Functions.
|
||||||
bool ExportIdentity(const std::string& fname,const PGPIdType& pgp_id) ;
|
bool ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
|
||||||
bool ImportIdentity(const std::string& fname,PGPIdType& imported_pgp_id,std::string& import_error) ;
|
bool ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
||||||
void GetUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
|
void GetUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
|
||||||
bool CopyGnuPGKeyrings() ;
|
bool CopyGnuPGKeyrings() ;
|
||||||
|
|
||||||
|
@ -153,10 +153,10 @@ namespace RsAccounts
|
||||||
bool GetPreferredAccountId(RsPeerId &id);
|
bool GetPreferredAccountId(RsPeerId &id);
|
||||||
bool GetAccountIds(std::list<RsPeerId> &ids);
|
bool GetAccountIds(std::list<RsPeerId> &ids);
|
||||||
bool GetAccountDetails(const RsPeerId &id,
|
bool GetAccountDetails(const RsPeerId &id,
|
||||||
PGPIdType &gpgId, std::string &gpgName,
|
RsPgpId &gpgId, std::string &gpgName,
|
||||||
std::string &gpgEmail, std::string &location);
|
std::string &gpgEmail, std::string &location);
|
||||||
|
|
||||||
bool GenerateSSLCertificate(const PGPIdType& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString);
|
bool GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ struct DistantChatInviteInfo
|
||||||
{
|
{
|
||||||
DistantChatPeerId pid ; // pid to contact the invite and refer to it.
|
DistantChatPeerId pid ; // pid to contact the invite and refer to it.
|
||||||
std::string encrypted_radix64_string ; // encrypted radix string used to for the chat link
|
std::string encrypted_radix64_string ; // encrypted radix string used to for the chat link
|
||||||
PGPIdType destination_pgp_id ; // pgp is of the destination of the chat link
|
RsPgpId destination_pgp_id ; // pgp is of the destination of the chat link
|
||||||
time_t time_of_validity ; // time when te invite becomes unusable
|
time_t time_of_validity ; // time when te invite becomes unusable
|
||||||
uint32_t invite_flags ; // used to keep track of wether signature was ok or not.
|
uint32_t invite_flags ; // used to keep track of wether signature was ok or not.
|
||||||
};
|
};
|
||||||
|
@ -240,7 +240,7 @@ extern RsMsgs *rsMsgs;
|
||||||
|
|
||||||
struct DistantOfflineMessengingInvite
|
struct DistantOfflineMessengingInvite
|
||||||
{
|
{
|
||||||
PGPIdType issuer_pgp_id ;
|
RsPgpId issuer_pgp_id ;
|
||||||
Sha1CheckSum hash ;
|
Sha1CheckSum hash ;
|
||||||
time_t time_of_validity ;
|
time_t time_of_validity ;
|
||||||
};
|
};
|
||||||
|
@ -295,7 +295,7 @@ virtual bool createDistantOfflineMessengingInvite(time_t validity_time_stamp, Di
|
||||||
virtual bool getDistantOfflineMessengingInvites(std::vector<DistantOfflineMessengingInvite>& invites) = 0 ;
|
virtual bool getDistantOfflineMessengingInvites(std::vector<DistantOfflineMessengingInvite>& invites) = 0 ;
|
||||||
virtual void enableDistantMessaging(bool b) = 0;
|
virtual void enableDistantMessaging(bool b) = 0;
|
||||||
virtual bool distantMessagingEnabled() = 0;
|
virtual bool distantMessagingEnabled() = 0;
|
||||||
virtual bool getDistantMessagePeerId(const PGPIdType& pgp_id, DistantMsgPeerId& peerId) = 0;
|
virtual bool getDistantMessagePeerId(const RsPgpId& pgp_id, DistantMsgPeerId& peerId) = 0;
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Chat */
|
/* Chat */
|
||||||
|
@ -348,11 +348,11 @@ virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::str
|
||||||
/* Distant chat */
|
/* Distant chat */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
|
||||||
virtual bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
|
virtual bool createDistantChatInvite(const RsPgpId& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
|
||||||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
|
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,DistantChatPeerId& pid,uint32_t& error_code) = 0;
|
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,DistantChatPeerId& pid,uint32_t& error_code) = 0;
|
||||||
virtual bool initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code) = 0;
|
virtual bool initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code) = 0;
|
||||||
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,PGPIdType& pgp_id) = 0;
|
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,RsPgpId& pgp_id) = 0;
|
||||||
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid) = 0;
|
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid) = 0;
|
||||||
virtual bool removeDistantChatInvite(const DistantChatPeerId& pid) = 0 ;
|
virtual bool removeDistantChatInvite(const DistantChatPeerId& pid) = 0 ;
|
||||||
|
|
||||||
|
|
|
@ -188,18 +188,18 @@ class RsPeerDetails
|
||||||
/* Auth details */
|
/* Auth details */
|
||||||
bool isOnlyGPGdetail;
|
bool isOnlyGPGdetail;
|
||||||
RsPeerId id;
|
RsPeerId id;
|
||||||
PGPIdType gpg_id;
|
RsPgpId gpg_id;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string email;
|
std::string email;
|
||||||
std::string location;
|
std::string location;
|
||||||
std::string org;
|
std::string org;
|
||||||
|
|
||||||
PGPIdType issuer;
|
RsPgpId issuer;
|
||||||
|
|
||||||
PGPFingerprintType fpr; /* pgp fingerprint */
|
PGPFingerprintType fpr; /* pgp fingerprint */
|
||||||
std::string authcode; // (cyril) what is this used for ?????
|
std::string authcode; // (cyril) what is this used for ?????
|
||||||
std::list<PGPIdType> gpgSigners;
|
std::list<RsPgpId> gpgSigners;
|
||||||
|
|
||||||
uint32_t trustLvl;
|
uint32_t trustLvl;
|
||||||
uint32_t validLvl;
|
uint32_t validLvl;
|
||||||
|
@ -274,7 +274,7 @@ public:
|
||||||
std::string name;
|
std::string name;
|
||||||
uint32_t flag;
|
uint32_t flag;
|
||||||
|
|
||||||
std::list<PGPIdType> peerIds;
|
std::list<RsPgpId> peerIds;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
|
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
|
||||||
|
@ -293,7 +293,7 @@ class RsPeers
|
||||||
/* Peer Details (Net & Auth) */
|
/* Peer Details (Net & Auth) */
|
||||||
virtual const RsPeerId& getOwnId() = 0;
|
virtual const RsPeerId& getOwnId() = 0;
|
||||||
|
|
||||||
virtual bool haveSecretKey(const PGPIdType& gpg_id) = 0 ;
|
virtual bool haveSecretKey(const RsPgpId& gpg_id) = 0 ;
|
||||||
|
|
||||||
virtual bool getOnlineList(std::list<RsPeerId> &ssl_ids) = 0;
|
virtual bool getOnlineList(std::list<RsPeerId> &ssl_ids) = 0;
|
||||||
virtual bool getFriendList(std::list<RsPeerId> &ssl_ids) = 0;
|
virtual bool getFriendList(std::list<RsPeerId> &ssl_ids) = 0;
|
||||||
|
@ -301,30 +301,30 @@ class RsPeers
|
||||||
|
|
||||||
virtual bool isOnline(const RsPeerId &ssl_id) = 0;
|
virtual bool isOnline(const RsPeerId &ssl_id) = 0;
|
||||||
virtual bool isFriend(const RsPeerId &ssl_id) = 0;
|
virtual bool isFriend(const RsPeerId &ssl_id) = 0;
|
||||||
virtual bool isGPGAccepted(const PGPIdType &gpg_id_is_friend) = 0; //
|
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend) = 0; //
|
||||||
virtual std::string getPeerName(const RsPeerId &ssl_id) = 0;
|
virtual std::string getPeerName(const RsPeerId &ssl_id) = 0;
|
||||||
virtual std::string getGPGName(const PGPIdType& gpg_id) = 0;
|
virtual std::string getGPGName(const RsPgpId& gpg_id) = 0;
|
||||||
virtual bool getPeerDetails(const RsPeerId& ssl_id, RsPeerDetails &d) = 0;
|
virtual bool getPeerDetails(const RsPeerId& ssl_id, RsPeerDetails &d) = 0;
|
||||||
virtual bool getGPGDetails(const PGPIdType& gpg_id, RsPeerDetails &d) = 0;
|
virtual bool getGPGDetails(const RsPgpId& gpg_id, RsPeerDetails &d) = 0;
|
||||||
|
|
||||||
/* Using PGP Ids */
|
/* Using PGP Ids */
|
||||||
virtual const PGPIdType& getGPGOwnId() = 0;
|
virtual const RsPgpId& getGPGOwnId() = 0;
|
||||||
virtual PGPIdType getGPGId(const RsPeerId& sslid) = 0; //return the gpg id of the given ssl id
|
virtual RsPgpId getGPGId(const RsPeerId& sslid) = 0; //return the gpg id of the given ssl id
|
||||||
virtual bool isKeySupported(const PGPIdType& gpg_ids) = 0;
|
virtual bool isKeySupported(const RsPgpId& gpg_ids) = 0;
|
||||||
virtual bool getGPGAcceptedList(std::list<PGPIdType> &gpg_ids) = 0;
|
virtual bool getGPGAcceptedList(std::list<RsPgpId> &gpg_ids) = 0;
|
||||||
virtual bool getGPGSignedList(std::list<PGPIdType> &gpg_ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key
|
virtual bool getGPGSignedList(std::list<RsPgpId> &gpg_ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key
|
||||||
virtual bool getGPGValidList(std::list<PGPIdType> &gpg_ids) = 0;
|
virtual bool getGPGValidList(std::list<RsPgpId> &gpg_ids) = 0;
|
||||||
virtual bool getGPGAllList(std::list<PGPIdType> &gpg_ids) = 0;
|
virtual bool getGPGAllList(std::list<RsPgpId> &gpg_ids) = 0;
|
||||||
virtual bool getAssociatedSSLIds(const PGPIdType& gpg_id, std::list<RsPeerId>& ids) = 0;
|
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId>& ids) = 0;
|
||||||
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) = 0;
|
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) = 0;
|
||||||
|
|
||||||
/* Add/Remove Friends */
|
/* Add/Remove Friends */
|
||||||
virtual bool addFriend(const RsPeerId &ssl_id, const PGPIdType &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL) = 0;
|
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL) = 0;
|
||||||
virtual bool removeFriend(const PGPIdType& pgp_id) = 0;
|
virtual bool removeFriend(const RsPgpId& pgp_id) = 0;
|
||||||
virtual bool removeFriendLocation(const RsPeerId& sslId) = 0;
|
virtual bool removeFriendLocation(const RsPeerId& sslId) = 0;
|
||||||
|
|
||||||
/* keyring management */
|
/* keyring management */
|
||||||
virtual bool removeKeysFromPGPKeyring(const std::list<PGPIdType>& pgp_ids,std::string& backup_file,uint32_t& error_code)=0 ;
|
virtual bool removeKeysFromPGPKeyring(const std::list<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code)=0 ;
|
||||||
|
|
||||||
/* Network Stuff */
|
/* Network Stuff */
|
||||||
virtual bool connectAttempt(const RsPeerId& ssl_id) = 0;
|
virtual bool connectAttempt(const RsPeerId& ssl_id) = 0;
|
||||||
|
@ -349,12 +349,12 @@ class RsPeers
|
||||||
/* Auth Stuff */
|
/* Auth Stuff */
|
||||||
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures) = 0;
|
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures) = 0;
|
||||||
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) = 0;
|
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) = 0;
|
||||||
virtual bool GetPGPBase64StringAndCheckSum(const PGPIdType& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0 ;
|
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0 ;
|
||||||
virtual std::string GetRetroshareInvite(bool include_signatures) = 0;
|
virtual std::string GetRetroshareInvite(bool include_signatures) = 0;
|
||||||
virtual bool hasExportMinimal() = 0 ;
|
virtual bool hasExportMinimal() = 0 ;
|
||||||
|
|
||||||
// Add keys to the keyring
|
// Add keys to the keyring
|
||||||
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,PGPIdType& pgp_id, std::string& error_string) = 0;
|
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string) = 0;
|
||||||
|
|
||||||
// Gets the GPG details, but does not add the key to the keyring.
|
// Gets the GPG details, but does not add the key to the keyring.
|
||||||
virtual bool loadDetailsFromStringCert(const std::string& certGPG, RsPeerDetails &pd,uint32_t& error_code) = 0;
|
virtual bool loadDetailsFromStringCert(const std::string& certGPG, RsPeerDetails &pd,uint32_t& error_code) = 0;
|
||||||
|
@ -364,8 +364,8 @@ class RsPeers
|
||||||
virtual bool saveCertificateToFile(const RsPeerId& id, const std::string &fname) = 0;
|
virtual bool saveCertificateToFile(const RsPeerId& id, const std::string &fname) = 0;
|
||||||
virtual std::string saveCertificateToString(const RsPeerId &id) = 0;
|
virtual std::string saveCertificateToString(const RsPeerId &id) = 0;
|
||||||
|
|
||||||
virtual bool signGPGCertificate(const PGPIdType &gpg_id) = 0;
|
virtual bool signGPGCertificate(const RsPgpId &gpg_id) = 0;
|
||||||
virtual bool trustGPGCertificate(const PGPIdType &gpg_id, uint32_t trustlvl) = 0;
|
virtual bool trustGPGCertificate(const RsPgpId &gpg_id, uint32_t trustlvl) = 0;
|
||||||
|
|
||||||
/* Group Stuff */
|
/* Group Stuff */
|
||||||
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
|
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
|
||||||
|
@ -374,8 +374,8 @@ class RsPeers
|
||||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
||||||
// groupId == "" && assign == false -> remove from all groups
|
// groupId == "" && assign == false -> remove from all groups
|
||||||
virtual bool assignPeerToGroup(const std::string &groupId, const PGPIdType& peerId, bool assign) = 0;
|
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId& peerId, bool assign) = 0;
|
||||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType> &peerIds, bool assign) = 0;
|
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
|
||||||
|
|
||||||
/* Group sharing permission */
|
/* Group sharing permission */
|
||||||
|
|
||||||
|
@ -392,9 +392,9 @@ class RsPeers
|
||||||
|
|
||||||
/* Service permission flags */
|
/* Service permission flags */
|
||||||
|
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const PGPIdType& gpg_id) = 0;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) = 0;
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) = 0;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) = 0;
|
||||||
virtual void setServicePermissionFlags(const PGPIdType& gpg_id,const ServicePermissionFlags& flags) = 0;
|
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -56,7 +56,7 @@ struct TurtleFileInfo
|
||||||
struct TurtleRequestDisplayInfo
|
struct TurtleRequestDisplayInfo
|
||||||
{
|
{
|
||||||
uint32_t request_id ; // Id of the request
|
uint32_t request_id ; // Id of the request
|
||||||
SSLIdType source_peer_id ; // Peer that relayed the request
|
RsPeerId source_peer_id ; // Peer that relayed the request
|
||||||
uint32_t age ; // Age in seconds
|
uint32_t age ; // Age in seconds
|
||||||
uint32_t depth ; // Depth of the request. Might be altered.
|
uint32_t depth ; // Depth of the request. Might be altered.
|
||||||
};
|
};
|
||||||
|
@ -136,7 +136,7 @@ class RsTurtle
|
||||||
virtual void getTrafficStatistics(TurtleTrafficStatisticsInfo& info) const = 0;
|
virtual void getTrafficStatistics(TurtleTrafficStatisticsInfo& info) const = 0;
|
||||||
|
|
||||||
// Convenience function.
|
// Convenience function.
|
||||||
virtual bool isTurtlePeer(const SSLIdType& peer_id) const = 0 ;
|
virtual bool isTurtlePeer(const RsPeerId& peer_id) const = 0 ;
|
||||||
|
|
||||||
// Hardcore handles
|
// Hardcore handles
|
||||||
virtual void setMaxTRForwardRate(int max_tr_up_rate) = 0 ;
|
virtual void setMaxTRForwardRate(int max_tr_up_rate) = 0 ;
|
||||||
|
|
|
@ -116,7 +116,7 @@ bool p3Msgs::distantMessagingEnabled()
|
||||||
{
|
{
|
||||||
return mMsgSrv->distantMessagingEnabled();
|
return mMsgSrv->distantMessagingEnabled();
|
||||||
}
|
}
|
||||||
bool p3Msgs::getDistantMessagePeerId(const PGPIdType& pgp_id,DistantMsgPeerId &pid)
|
bool p3Msgs::getDistantMessagePeerId(const RsPgpId& pgp_id,DistantMsgPeerId &pid)
|
||||||
{
|
{
|
||||||
return mMsgSrv->getDistantMessagePeerId(pgp_id,pid);
|
return mMsgSrv->getDistantMessagePeerId(pgp_id,pid);
|
||||||
}
|
}
|
||||||
|
@ -371,7 +371,7 @@ void p3Msgs::getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites)
|
||||||
{
|
{
|
||||||
mChatSrv->getPendingChatLobbyInvites(invites) ;
|
mChatSrv->getPendingChatLobbyInvites(invites) ;
|
||||||
}
|
}
|
||||||
bool p3Msgs::createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_string)
|
bool p3Msgs::createDistantChatInvite(const RsPgpId& pgp_id,time_t time_of_validity,std::string& encrypted_string)
|
||||||
{
|
{
|
||||||
return mChatSrv->createDistantChatInvite(pgp_id,time_of_validity,encrypted_string) ;
|
return mChatSrv->createDistantChatInvite(pgp_id,time_of_validity,encrypted_string) ;
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,7 @@ bool p3Msgs::initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t&
|
||||||
{
|
{
|
||||||
return mChatSrv->initiateDistantChatConnexion(pid,error_code) ;
|
return mChatSrv->initiateDistantChatConnexion(pid,error_code) ;
|
||||||
}
|
}
|
||||||
bool p3Msgs::getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,PGPIdType& pgp_id)
|
bool p3Msgs::getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,RsPgpId& pgp_id)
|
||||||
{
|
{
|
||||||
return mChatSrv->getDistantChatStatus(pid,status,pgp_id) ;
|
return mChatSrv->getDistantChatStatus(pid,status,pgp_id) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ class p3Msgs: public RsMsgs
|
||||||
|
|
||||||
virtual void enableDistantMessaging(bool b) ;
|
virtual void enableDistantMessaging(bool b) ;
|
||||||
virtual bool distantMessagingEnabled() ;
|
virtual bool distantMessagingEnabled() ;
|
||||||
virtual bool getDistantMessagePeerId(const PGPIdType& pgp_id,DistantMsgPeerId& pid) ;
|
virtual bool getDistantMessagePeerId(const RsPgpId& pgp_id,DistantMsgPeerId& pid) ;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* gets avatar from peer, image data in jpeg format
|
* gets avatar from peer, image data in jpeg format
|
||||||
|
@ -194,11 +194,11 @@ class p3Msgs: public RsMsgs
|
||||||
virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id);
|
virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id);
|
||||||
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,uint32_t privacy_type) ;
|
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,uint32_t privacy_type) ;
|
||||||
|
|
||||||
virtual bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
|
virtual bool createDistantChatInvite(const RsPgpId& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
|
||||||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
|
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,DistantChatPeerId& pid,uint32_t& error_code) ;
|
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,DistantChatPeerId& pid,uint32_t& error_code) ;
|
||||||
virtual bool initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code) ;
|
virtual bool initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code) ;
|
||||||
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,PGPIdType& pgp_id) ;
|
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,RsPgpId& pgp_id) ;
|
||||||
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid) ;
|
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid) ;
|
||||||
virtual bool removeDistantChatInvite(const DistantChatPeerId& pid) ;
|
virtual bool removeDistantChatInvite(const DistantChatPeerId& pid) ;
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@ bool p3Peers::isFriend(const RsPeerId &ssl_id)
|
||||||
return mPeerMgr->isFriend(ssl_id);
|
return mPeerMgr->isFriend(ssl_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::haveSecretKey(const PGPIdType& id)
|
bool p3Peers::haveSecretKey(const RsPgpId& id)
|
||||||
{
|
{
|
||||||
return AuthGPG::getAuthGPG()->haveSecretKey(id) ;
|
return AuthGPG::getAuthGPG()->haveSecretKey(id) ;
|
||||||
}
|
}
|
||||||
|
@ -453,18 +453,18 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::isKeySupported(const PGPIdType& id)
|
bool p3Peers::isKeySupported(const RsPgpId& id)
|
||||||
{
|
{
|
||||||
return AuthGPG::getAuthGPG()->isKeySupported(id);
|
return AuthGPG::getAuthGPG()->isKeySupported(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string p3Peers::getGPGName(const PGPIdType &gpg_id)
|
std::string p3Peers::getGPGName(const RsPgpId &gpg_id)
|
||||||
{
|
{
|
||||||
/* get from mAuthMgr as it should have more peers? */
|
/* get from mAuthMgr as it should have more peers? */
|
||||||
return AuthGPG::getAuthGPG()->getGPGName(gpg_id);
|
return AuthGPG::getAuthGPG()->getGPGName(gpg_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::isGPGAccepted(const PGPIdType &gpg_id_is_friend)
|
bool p3Peers::isGPGAccepted(const RsPgpId &gpg_id_is_friend)
|
||||||
{
|
{
|
||||||
/* get from mAuthMgr as it should have more peers? */
|
/* get from mAuthMgr as it should have more peers? */
|
||||||
return AuthGPG::getAuthGPG()->isGPGAccepted(gpg_id_is_friend);
|
return AuthGPG::getAuthGPG()->isGPGAccepted(gpg_id_is_friend);
|
||||||
|
@ -490,7 +490,7 @@ std::string p3Peers::getPeerName(const RsPeerId& ssl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool p3Peers::getGPGAllList(std::list<PGPIdType> &ids)
|
bool p3Peers::getGPGAllList(std::list<RsPgpId> &ids)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::getGPGAllList()" << std::endl;
|
std::cerr << "p3Peers::getGPGAllList()" << std::endl;
|
||||||
|
@ -501,7 +501,7 @@ bool p3Peers::getGPGAllList(std::list<PGPIdType> &ids)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::getGPGValidList(std::list<PGPIdType> &ids)
|
bool p3Peers::getGPGValidList(std::list<RsPgpId> &ids)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::getPGPOthersList()" << std::endl;
|
std::cerr << "p3Peers::getPGPOthersList()" << std::endl;
|
||||||
|
@ -512,7 +512,7 @@ bool p3Peers::getGPGValidList(std::list<PGPIdType> &ids)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::getGPGSignedList(std::list<PGPIdType> &ids)
|
bool p3Peers::getGPGSignedList(std::list<RsPgpId> &ids)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::getPGPOthersList()" << std::endl;
|
std::cerr << "p3Peers::getPGPOthersList()" << std::endl;
|
||||||
|
@ -523,7 +523,7 @@ bool p3Peers::getGPGSignedList(std::list<PGPIdType> &ids)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::getGPGAcceptedList(std::list<PGPIdType> &ids)
|
bool p3Peers::getGPGAcceptedList(std::list<RsPgpId> &ids)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::getGPGAcceptedList()" << std::endl;
|
std::cerr << "p3Peers::getGPGAcceptedList()" << std::endl;
|
||||||
|
@ -533,7 +533,7 @@ bool p3Peers::getGPGAcceptedList(std::list<PGPIdType> &ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool p3Peers::getAssociatedSSLIds(const PGPIdType &gpg_id, std::list<RsPeerId> &ids)
|
bool p3Peers::getAssociatedSSLIds(const RsPgpId &gpg_id, std::list<RsPeerId> &ids)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::getAssociatedSSLIds() for id : " << gpg_id << std::endl;
|
std::cerr << "p3Peers::getAssociatedSSLIds() for id : " << gpg_id << std::endl;
|
||||||
|
@ -547,7 +547,7 @@ bool p3Peers::gpgSignData(const void *data, const uint32_t len, unsigned char
|
||||||
return AuthGPG::getAuthGPG()->SignDataBin(data,len,sign,signlen);
|
return AuthGPG::getAuthGPG()->SignDataBin(data,len,sign,signlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::getGPGDetails(const PGPIdType &pgp_id, RsPeerDetails &d)
|
bool p3Peers::getGPGDetails(const RsPgpId &pgp_id, RsPeerDetails &d)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::getPgpDetails() called for id : " << pgp_id << std::endl;
|
std::cerr << "p3Peers::getPgpDetails() called for id : " << pgp_id << std::endl;
|
||||||
|
@ -562,7 +562,7 @@ bool p3Peers::getGPGDetails(const PGPIdType &pgp_id, RsPeerDetails &d)
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PGPIdType& p3Peers::getGPGOwnId()
|
const RsPgpId& p3Peers::getGPGOwnId()
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::getPGPOwnId()" << std::endl;
|
std::cerr << "p3Peers::getPGPOwnId()" << std::endl;
|
||||||
|
@ -572,7 +572,7 @@ const PGPIdType& p3Peers::getGPGOwnId()
|
||||||
return AuthGPG::getAuthGPG()->getGPGOwnId();
|
return AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||||
}
|
}
|
||||||
|
|
||||||
PGPIdType p3Peers::getGPGId(const RsPeerId& sslid)
|
RsPgpId p3Peers::getGPGId(const RsPeerId& sslid)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::getPGPId()" << std::endl;
|
std::cerr << "p3Peers::getPGPId()" << std::endl;
|
||||||
|
@ -588,7 +588,7 @@ PGPIdType p3Peers::getGPGId(const RsPeerId& sslid)
|
||||||
return pcs.gpg_id;
|
return pcs.gpg_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PGPIdType();
|
return RsPgpId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ PGPIdType p3Peers::getGPGId(const RsPeerId& sslid)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Add/Remove Friends */
|
/* Add/Remove Friends */
|
||||||
bool p3Peers::addFriend(const RsPeerId &ssl_id, const PGPIdType &gpg_id,ServicePermissionFlags perm_flags)
|
bool p3Peers::addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags perm_flags)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
|
@ -646,7 +646,7 @@ bool p3Peers::addFriend(const RsPeerId &ssl_id, const PGPIdType &gpg_id,Service
|
||||||
return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VS_DISC_FULL, RS_VS_DHT_FULL, now, perm_flags);
|
return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VS_DISC_FULL, RS_VS_DHT_FULL, now, perm_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::removeKeysFromPGPKeyring(const std::list<PGPIdType>& pgp_ids,std::string& backup_file,uint32_t& error_code)
|
bool p3Peers::removeKeysFromPGPKeyring(const std::list<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code)
|
||||||
{
|
{
|
||||||
return AuthGPG::getAuthGPG()->removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ;
|
return AuthGPG::getAuthGPG()->removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ;
|
||||||
}
|
}
|
||||||
|
@ -662,7 +662,7 @@ bool p3Peers::removeFriendLocation(const RsPeerId &sslId)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::removeFriend(const PGPIdType& gpgId)
|
bool p3Peers::removeFriend(const RsPgpId& gpgId)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::removeFriend() " << gpgId << std::endl;
|
std::cerr << "p3Peers::removeFriend() " << gpgId << std::endl;
|
||||||
|
@ -960,7 +960,7 @@ std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures)
|
||||||
unsigned char *mem_block = NULL;
|
unsigned char *mem_block = NULL;
|
||||||
size_t mem_block_size = 0;
|
size_t mem_block_size = 0;
|
||||||
|
|
||||||
if(!AuthGPG::getAuthGPG()->exportPublicKey(PGPIdType(pgp_id),mem_block,mem_block_size,false,include_signatures))
|
if(!AuthGPG::getAuthGPG()->exportPublicKey(RsPgpId(pgp_id),mem_block,mem_block_size,false,include_signatures))
|
||||||
{
|
{
|
||||||
std::cerr << "Cannot output certificate for id \"" << pgp_id << "\". Sorry." << std::endl;
|
std::cerr << "Cannot output certificate for id \"" << pgp_id << "\". Sorry." << std::endl;
|
||||||
return "" ;
|
return "" ;
|
||||||
|
@ -977,7 +977,7 @@ std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool p3Peers::GetPGPBase64StringAndCheckSum( const PGPIdType& gpg_id,
|
bool p3Peers::GetPGPBase64StringAndCheckSum( const RsPgpId& gpg_id,
|
||||||
std::string& gpg_base64_string,
|
std::string& gpg_base64_string,
|
||||||
std::string& gpg_base64_checksum)
|
std::string& gpg_base64_checksum)
|
||||||
{
|
{
|
||||||
|
@ -1017,7 +1017,7 @@ std::string p3Peers::GetRetroshareInvite(const RsPeerId& ssl_id,bool include_sig
|
||||||
unsigned char *mem_block = NULL;
|
unsigned char *mem_block = NULL;
|
||||||
size_t mem_block_size = 0;
|
size_t mem_block_size = 0;
|
||||||
|
|
||||||
if(!AuthGPG::getAuthGPG()->exportPublicKey(PGPIdType(Detail.gpg_id),mem_block,mem_block_size,false,include_signatures))
|
if(!AuthGPG::getAuthGPG()->exportPublicKey(RsPgpId(Detail.gpg_id),mem_block,mem_block_size,false,include_signatures))
|
||||||
{
|
{
|
||||||
std::cerr << "Cannot output certificate for id \"" << Detail.gpg_id << "\". Sorry." << std::endl;
|
std::cerr << "Cannot output certificate for id \"" << Detail.gpg_id << "\". Sorry." << std::endl;
|
||||||
return "" ;
|
return "" ;
|
||||||
|
@ -1037,10 +1037,10 @@ std::string p3Peers::GetRetroshareInvite(const RsPeerId& ssl_id,bool include_sig
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
bool p3Peers::loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id, PGPIdType& gpg_id, std::string& error_string)
|
bool p3Peers::loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id, RsPgpId& gpg_id, std::string& error_string)
|
||||||
{
|
{
|
||||||
RsCertificate crt(cert) ;
|
RsCertificate crt(cert) ;
|
||||||
PGPIdType gpgid ;
|
RsPgpId gpgid ;
|
||||||
|
|
||||||
bool res = AuthGPG::getAuthGPG()->LoadCertificateFromString(crt.armouredPGPKey(),gpgid,error_string) ;
|
bool res = AuthGPG::getAuthGPG()->LoadCertificateFromString(crt.armouredPGPKey(),gpgid,error_string) ;
|
||||||
|
|
||||||
|
@ -1145,7 +1145,7 @@ std::string p3Peers::saveCertificateToString(const RsPeerId &id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::signGPGCertificate(const PGPIdType &id)
|
bool p3Peers::signGPGCertificate(const RsPgpId &id)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::SignCertificate() " << id;
|
std::cerr << "p3Peers::SignCertificate() " << id;
|
||||||
|
@ -1158,7 +1158,7 @@ bool p3Peers::signGPGCertificate(const PGPIdType &id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool p3Peers::trustGPGCertificate(const PGPIdType &id, uint32_t trustlvl)
|
bool p3Peers::trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::TrustCertificate() " << id;
|
std::cerr << "p3Peers::TrustCertificate() " << id;
|
||||||
|
@ -1220,15 +1220,15 @@ bool p3Peers::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
|
||||||
return mPeerMgr->getGroupInfoList(groupInfoList);
|
return mPeerMgr->getGroupInfoList(groupInfoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::assignPeerToGroup(const std::string &groupId, const PGPIdType& peerId, bool assign)
|
bool p3Peers::assignPeerToGroup(const std::string &groupId, const RsPgpId& peerId, bool assign)
|
||||||
{
|
{
|
||||||
std::list<PGPIdType> peerIds;
|
std::list<RsPgpId> peerIds;
|
||||||
peerIds.push_back(peerId);
|
peerIds.push_back(peerId);
|
||||||
|
|
||||||
return assignPeersToGroup(groupId, peerIds, assign);
|
return assignPeersToGroup(groupId, peerIds, assign);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType> &peerIds, bool assign)
|
bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::assignPeersToGroup()" << std::endl;
|
std::cerr << "p3Peers::assignPeersToGroup()" << std::endl;
|
||||||
|
@ -1251,7 +1251,7 @@ FileSearchFlags p3Peers::computePeerPermissionFlags(const RsPeerId& peer_ssl_id,
|
||||||
//
|
//
|
||||||
|
|
||||||
bool found = false ;
|
bool found = false ;
|
||||||
PGPIdType pgp_id = getGPGId(peer_ssl_id) ;
|
RsPgpId pgp_id = getGPGId(peer_ssl_id) ;
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator it(directory_parent_groups.begin());it!=directory_parent_groups.end() && !found;++it)
|
for(std::list<std::string>::const_iterator it(directory_parent_groups.begin());it!=directory_parent_groups.end() && !found;++it)
|
||||||
{
|
{
|
||||||
|
@ -1262,7 +1262,7 @@ FileSearchFlags p3Peers::computePeerPermissionFlags(const RsPeerId& peer_ssl_id,
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::list<PGPIdType>::const_iterator it2(info.peerIds.begin());it2!=info.peerIds.end() && !found;++it2)
|
for(std::list<RsPgpId>::const_iterator it2(info.peerIds.begin());it2!=info.peerIds.end() && !found;++it2)
|
||||||
if(*it2 == pgp_id)
|
if(*it2 == pgp_id)
|
||||||
found = true ;
|
found = true ;
|
||||||
}
|
}
|
||||||
|
@ -1307,7 +1307,7 @@ std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail)
|
||||||
out << " signers:";
|
out << " signers:";
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
|
|
||||||
std::list<PGPIdType>::const_iterator it;
|
std::list<RsPgpId>::const_iterator it;
|
||||||
for(it = detail.gpgSigners.begin();
|
for(it = detail.gpgSigners.begin();
|
||||||
it != detail.gpgSigners.end(); it++)
|
it != detail.gpgSigners.end(); it++)
|
||||||
{
|
{
|
||||||
|
@ -1348,11 +1348,11 @@ ServicePermissionFlags p3Peers::servicePermissionFlags(const RsPeerId& ssl_id)
|
||||||
{
|
{
|
||||||
return mPeerMgr->servicePermissionFlags(ssl_id) ;
|
return mPeerMgr->servicePermissionFlags(ssl_id) ;
|
||||||
}
|
}
|
||||||
ServicePermissionFlags p3Peers::servicePermissionFlags(const PGPIdType& gpg_id)
|
ServicePermissionFlags p3Peers::servicePermissionFlags(const RsPgpId& gpg_id)
|
||||||
{
|
{
|
||||||
return mPeerMgr->servicePermissionFlags(gpg_id) ;
|
return mPeerMgr->servicePermissionFlags(gpg_id) ;
|
||||||
}
|
}
|
||||||
void p3Peers::setServicePermissionFlags(const PGPIdType& gpg_id,const ServicePermissionFlags& flags)
|
void p3Peers::setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags)
|
||||||
{
|
{
|
||||||
mPeerMgr->setServicePermissionFlags(gpg_id,flags) ;
|
mPeerMgr->setServicePermissionFlags(gpg_id,flags) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ virtual bool OthersChanged();
|
||||||
/* Peer Details (Net & Auth) */
|
/* Peer Details (Net & Auth) */
|
||||||
virtual const RsPeerId& getOwnId();
|
virtual const RsPeerId& getOwnId();
|
||||||
|
|
||||||
virtual bool haveSecretKey(const PGPIdType& gpg_id) ;
|
virtual bool haveSecretKey(const RsPgpId& gpg_id) ;
|
||||||
|
|
||||||
|
|
||||||
virtual bool getOnlineList(std::list<RsPeerId> &ids);
|
virtual bool getOnlineList(std::list<RsPeerId> &ids);
|
||||||
|
@ -56,30 +56,30 @@ virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCou
|
||||||
|
|
||||||
virtual bool isOnline(const RsPeerId &id);
|
virtual bool isOnline(const RsPeerId &id);
|
||||||
virtual bool isFriend(const RsPeerId &id);
|
virtual bool isFriend(const RsPeerId &id);
|
||||||
virtual bool isGPGAccepted(const PGPIdType &gpg_id_is_friend); //
|
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend); //
|
||||||
virtual std::string getGPGName(const PGPIdType &gpg_id);
|
virtual std::string getGPGName(const RsPgpId &gpg_id);
|
||||||
virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id);
|
virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id);
|
||||||
virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d);
|
virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d);
|
||||||
|
|
||||||
/* Using PGP Ids */
|
/* Using PGP Ids */
|
||||||
virtual const PGPIdType& getGPGOwnId();
|
virtual const RsPgpId& getGPGOwnId();
|
||||||
virtual PGPIdType getGPGId(const RsPeerId &ssl_id);
|
virtual RsPgpId getGPGId(const RsPeerId &ssl_id);
|
||||||
virtual bool isKeySupported(const PGPIdType& ids);
|
virtual bool isKeySupported(const RsPgpId& ids);
|
||||||
virtual bool getGPGAcceptedList(std::list<PGPIdType> &ids);
|
virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids);
|
||||||
virtual bool getGPGSignedList(std::list<PGPIdType> &ids);
|
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
|
||||||
virtual bool getGPGValidList(std::list<PGPIdType> &ids);
|
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
|
||||||
virtual bool getGPGAllList(std::list<PGPIdType> &ids);
|
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
||||||
virtual bool getGPGDetails(const PGPIdType &id, RsPeerDetails &d);
|
virtual bool getGPGDetails(const RsPgpId &id, RsPeerDetails &d);
|
||||||
virtual bool getAssociatedSSLIds(const PGPIdType& gpg_id, std::list<RsPeerId> &ids);
|
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &ids);
|
||||||
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) ;
|
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) ;
|
||||||
|
|
||||||
/* Add/Remove Friends */
|
/* Add/Remove Friends */
|
||||||
virtual bool addFriend(const RsPeerId &ssl_id, const PGPIdType &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL);
|
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL);
|
||||||
virtual bool removeFriend(const PGPIdType& gpgid);
|
virtual bool removeFriend(const RsPgpId& gpgid);
|
||||||
virtual bool removeFriendLocation(const RsPeerId& sslId);
|
virtual bool removeFriendLocation(const RsPeerId& sslId);
|
||||||
|
|
||||||
/* keyring management */
|
/* keyring management */
|
||||||
virtual bool removeKeysFromPGPKeyring(const std::list<PGPIdType>& pgp_ids,std::string& backup_file,uint32_t& error_code);
|
virtual bool removeKeysFromPGPKeyring(const std::list<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code);
|
||||||
|
|
||||||
/* Network Stuff */
|
/* Network Stuff */
|
||||||
virtual bool connectAttempt(const RsPeerId &id);
|
virtual bool connectAttempt(const RsPeerId &id);
|
||||||
|
@ -107,19 +107,19 @@ virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) ;
|
||||||
|
|
||||||
// same but for own id
|
// same but for own id
|
||||||
virtual std::string GetRetroshareInvite(bool include_signatures);
|
virtual std::string GetRetroshareInvite(bool include_signatures);
|
||||||
virtual bool GetPGPBase64StringAndCheckSum(const PGPIdType& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) ;
|
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) ;
|
||||||
|
|
||||||
virtual bool hasExportMinimal() ;
|
virtual bool hasExportMinimal() ;
|
||||||
|
|
||||||
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,PGPIdType& pgp_id, std::string& error_string);
|
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string);
|
||||||
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code);
|
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code);
|
||||||
|
|
||||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code);
|
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code);
|
||||||
virtual bool saveCertificateToFile(const RsPeerId &id, const std::string &fname);
|
virtual bool saveCertificateToFile(const RsPeerId &id, const std::string &fname);
|
||||||
virtual std::string saveCertificateToString(const RsPeerId &id);
|
virtual std::string saveCertificateToString(const RsPeerId &id);
|
||||||
|
|
||||||
virtual bool signGPGCertificate(const PGPIdType &id);
|
virtual bool signGPGCertificate(const RsPgpId &id);
|
||||||
virtual bool trustGPGCertificate(const PGPIdType &id, uint32_t trustlvl);
|
virtual bool trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl);
|
||||||
|
|
||||||
/* Group Stuff */
|
/* Group Stuff */
|
||||||
virtual bool addGroup(RsGroupInfo &groupInfo);
|
virtual bool addGroup(RsGroupInfo &groupInfo);
|
||||||
|
@ -127,16 +127,16 @@ virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||||
virtual bool removeGroup(const std::string &groupId);
|
virtual bool removeGroup(const std::string &groupId);
|
||||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
||||||
virtual bool assignPeerToGroup(const std::string &groupId, const PGPIdType &peerId, bool assign);
|
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId &peerId, bool assign);
|
||||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType>& peerIds, bool assign);
|
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId>& peerIds, bool assign);
|
||||||
|
|
||||||
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ;
|
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ;
|
||||||
|
|
||||||
// service permission stuff
|
// service permission stuff
|
||||||
|
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const PGPIdType& gpg_id) ;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ;
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id) ;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id) ;
|
||||||
virtual void setServicePermissionFlags(const PGPIdType& gpg_id,const ServicePermissionFlags& flags) ;
|
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ bool RsAccountsDetail::selectAccountByString(const std::string &prefUserString)
|
||||||
// try both.
|
// try both.
|
||||||
//
|
//
|
||||||
RsPeerId ssl_id(prefUserString) ;
|
RsPeerId ssl_id(prefUserString) ;
|
||||||
PGPIdType pgp_id(prefUserString) ;
|
RsPgpId pgp_id(prefUserString) ;
|
||||||
|
|
||||||
std::cerr << "RsAccountsDetail::selectAccountByString(" << prefUserString << ")" << std::endl;
|
std::cerr << "RsAccountsDetail::selectAccountByString(" << prefUserString << ")" << std::endl;
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ bool RsAccountsDetail::getAccountIds(std::list<RsPeerId> &ids)
|
||||||
|
|
||||||
|
|
||||||
bool RsAccountsDetail::getAccountDetails(const RsPeerId &id,
|
bool RsAccountsDetail::getAccountDetails(const RsPeerId &id,
|
||||||
PGPIdType &gpgId, std::string &gpgName,
|
RsPgpId &gpgId, std::string &gpgName,
|
||||||
std::string &gpgEmail, std::string &location)
|
std::string &gpgEmail, std::string &location)
|
||||||
{
|
{
|
||||||
std::map<RsPeerId, AccountDetails>::iterator it;
|
std::map<RsPeerId, AccountDetails>::iterator it;
|
||||||
|
@ -787,12 +787,12 @@ std::string RsAccountsDetail::PathDataDirectory()
|
||||||
|
|
||||||
|
|
||||||
/* Generating GPGme Account */
|
/* Generating GPGme Account */
|
||||||
int RsAccountsDetail::GetPGPLogins(std::list<PGPIdType> &pgpIds) {
|
int RsAccountsDetail::GetPGPLogins(std::list<RsPgpId> &pgpIds) {
|
||||||
AuthGPG::getAuthGPG()->availableGPGCertificatesWithPrivateKeys(pgpIds);
|
AuthGPG::getAuthGPG()->availableGPGCertificatesWithPrivateKeys(pgpIds);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RsAccountsDetail::GetPGPLoginDetails(const PGPIdType& id, std::string &name, std::string &email)
|
int RsAccountsDetail::GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email)
|
||||||
{
|
{
|
||||||
#ifdef GPG_DEBUG
|
#ifdef GPG_DEBUG
|
||||||
std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"" << std::endl;
|
std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"" << std::endl;
|
||||||
|
@ -818,7 +818,7 @@ int RsAccountsDetail::GetPGPLoginDetails(const PGPIdType& id, std::string &
|
||||||
/* Before any SSL stuff can be loaded, the correct PGP must be selected / generated:
|
/* Before any SSL stuff can be loaded, the correct PGP must be selected / generated:
|
||||||
**/
|
**/
|
||||||
|
|
||||||
bool RsAccountsDetail::SelectPGPAccount(const PGPIdType& pgpId)
|
bool RsAccountsDetail::SelectPGPAccount(const RsPgpId& pgpId)
|
||||||
{
|
{
|
||||||
bool retVal = false;
|
bool retVal = false;
|
||||||
|
|
||||||
|
@ -836,7 +836,7 @@ bool RsAccountsDetail::SelectPGPAccount(const PGPIdType& pgpId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RsAccountsDetail::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, PGPIdType &pgpId, std::string &errString)
|
bool RsAccountsDetail::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, RsPgpId &pgpId, std::string &errString)
|
||||||
{
|
{
|
||||||
return AuthGPG::getAuthGPG()->GeneratePGPCertificate(name, email, passwd, pgpId, errString);
|
return AuthGPG::getAuthGPG()->GeneratePGPCertificate(name, email, passwd, pgpId, errString);
|
||||||
}
|
}
|
||||||
|
@ -848,12 +848,12 @@ void RsAccountsDetail::getUnsupportedKeys(std::map<std::string,std::vector<std::
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccountsDetail::exportIdentity(const std::string& fname,const PGPIdType& id)
|
bool RsAccountsDetail::exportIdentity(const std::string& fname,const RsPgpId& id)
|
||||||
{
|
{
|
||||||
return AuthGPG::getAuthGPG()->exportProfile(fname,id);
|
return AuthGPG::getAuthGPG()->exportProfile(fname,id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccountsDetail::importIdentity(const std::string& fname,PGPIdType& id,std::string& import_error)
|
bool RsAccountsDetail::importIdentity(const std::string& fname,RsPgpId& id,std::string& import_error)
|
||||||
{
|
{
|
||||||
return AuthGPG::getAuthGPG()->importProfile(fname,id,import_error);
|
return AuthGPG::getAuthGPG()->importProfile(fname,id,import_error);
|
||||||
}
|
}
|
||||||
|
@ -916,7 +916,7 @@ bool RsAccountsDetail::copyGnuPGKeyrings()
|
||||||
|
|
||||||
|
|
||||||
/* Create SSL Certificates */
|
/* Create SSL Certificates */
|
||||||
bool RsAccountsDetail::GenerateSSLCertificate(const PGPIdType& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
|
bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
|
||||||
{
|
{
|
||||||
/* select the PGP Identity first */
|
/* select the PGP Identity first */
|
||||||
if (!SelectPGPAccount(pgp_id))
|
if (!SelectPGPAccount(pgp_id))
|
||||||
|
@ -1044,7 +1044,7 @@ bool RsAccountsDetail::GenerateSSLCertificate(const PGPIdType& pgp_id, const
|
||||||
/* try to load it, and get Id */
|
/* try to load it, and get Id */
|
||||||
|
|
||||||
std::string location;
|
std::string location;
|
||||||
PGPIdType pgpid_retrieved;
|
RsPgpId pgpid_retrieved;
|
||||||
|
|
||||||
if (LoadCheckX509(cert_name.c_str(), pgpid_retrieved, location, sslId) == 0) {
|
if (LoadCheckX509(cert_name.c_str(), pgpid_retrieved, location, sslId) == 0) {
|
||||||
std::cerr << "RsInit::GenerateSSLCertificate() Cannot check own signature, maybe the files are corrupted." << std::endl;
|
std::cerr << "RsInit::GenerateSSLCertificate() Cannot check own signature, maybe the files are corrupted." << std::endl;
|
||||||
|
@ -1241,28 +1241,28 @@ std::string RsAccounts::PGPDirectory() { return rsAccounts.PathPGPDirectory(); }
|
||||||
std::string RsAccounts::AccountDirectory() { return rsAccounts.PathAccountDirectory(); }
|
std::string RsAccounts::AccountDirectory() { return rsAccounts.PathAccountDirectory(); }
|
||||||
|
|
||||||
// PGP Accounts.
|
// PGP Accounts.
|
||||||
int RsAccounts::GetPGPLogins(std::list<PGPIdType> &pgpIds)
|
int RsAccounts::GetPGPLogins(std::list<RsPgpId> &pgpIds)
|
||||||
{
|
{
|
||||||
return rsAccounts.GetPGPLogins(pgpIds);
|
return rsAccounts.GetPGPLogins(pgpIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
int RsAccounts::GetPGPLoginDetails(const PGPIdType& id, std::string &name, std::string &email)
|
int RsAccounts::GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email)
|
||||||
{
|
{
|
||||||
return rsAccounts.GetPGPLoginDetails(id, name, email);
|
return rsAccounts.GetPGPLoginDetails(id, name, email);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccounts::GeneratePGPCertificate(const std::string &name, const std::string& email, const std::string& passwd, PGPIdType &pgpId, std::string &errString)
|
bool RsAccounts::GeneratePGPCertificate(const std::string &name, const std::string& email, const std::string& passwd, RsPgpId &pgpId, std::string &errString)
|
||||||
{
|
{
|
||||||
return rsAccounts.GeneratePGPCertificate(name, email, passwd, pgpId, errString);
|
return rsAccounts.GeneratePGPCertificate(name, email, passwd, pgpId, errString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PGP Support Functions.
|
// PGP Support Functions.
|
||||||
bool RsAccounts::ExportIdentity(const std::string& fname,const PGPIdType& pgp_id)
|
bool RsAccounts::ExportIdentity(const std::string& fname,const RsPgpId& pgp_id)
|
||||||
{
|
{
|
||||||
return rsAccounts.exportIdentity(fname,pgp_id);
|
return rsAccounts.exportIdentity(fname,pgp_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccounts::ImportIdentity(const std::string& fname,PGPIdType& imported_pgp_id,std::string& import_error)
|
bool RsAccounts::ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error)
|
||||||
{
|
{
|
||||||
return rsAccounts.importIdentity(fname,imported_pgp_id,import_error);
|
return rsAccounts.importIdentity(fname,imported_pgp_id,import_error);
|
||||||
}
|
}
|
||||||
|
@ -1294,13 +1294,13 @@ bool RsAccounts::GetAccountIds(std::list<RsPeerId> &ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccounts::GetAccountDetails(const RsPeerId &id,
|
bool RsAccounts::GetAccountDetails(const RsPeerId &id,
|
||||||
PGPIdType &pgpId, std::string &pgpName,
|
RsPgpId &pgpId, std::string &pgpName,
|
||||||
std::string &pgpEmail, std::string &location)
|
std::string &pgpEmail, std::string &location)
|
||||||
{
|
{
|
||||||
return rsAccounts.getAccountDetails(id, pgpId, pgpName, pgpEmail, location);
|
return rsAccounts.getAccountDetails(id, pgpId, pgpName, pgpEmail, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccounts::GenerateSSLCertificate(const PGPIdType& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
|
bool RsAccounts::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
|
||||||
{
|
{
|
||||||
return rsAccounts.GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString);
|
return rsAccounts.GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class AccountDetails
|
||||||
RsPeerId mSslId;
|
RsPeerId mSslId;
|
||||||
std::string mAccountDir;
|
std::string mAccountDir;
|
||||||
|
|
||||||
PGPIdType mPgpId;
|
RsPgpId mPgpId;
|
||||||
std::string mPgpName;
|
std::string mPgpName;
|
||||||
std::string mPgpEmail;
|
std::string mPgpEmail;
|
||||||
|
|
||||||
|
@ -86,15 +86,15 @@ class RsAccountsDetail
|
||||||
|
|
||||||
// PGP Accounts.
|
// PGP Accounts.
|
||||||
|
|
||||||
int GetPGPLogins(std::list<PGPIdType> &pgpIds);
|
int GetPGPLogins(std::list<RsPgpId> &pgpIds);
|
||||||
int GetPGPLoginDetails(const PGPIdType& id, std::string &name, std::string &email);
|
int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
|
||||||
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, PGPIdType &pgpId, std::string &errString);
|
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, std::string &errString);
|
||||||
|
|
||||||
bool SelectPGPAccount(const PGPIdType& pgpId);
|
bool SelectPGPAccount(const RsPgpId& pgpId);
|
||||||
|
|
||||||
// PGP Support Functions.
|
// PGP Support Functions.
|
||||||
bool exportIdentity(const std::string& fname,const PGPIdType& pgp_id) ;
|
bool exportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
|
||||||
bool importIdentity(const std::string& fname,PGPIdType& imported_pgp_id,std::string& import_error) ;
|
bool importIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
||||||
void getUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
|
void getUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
|
||||||
bool copyGnuPGKeyrings() ;
|
bool copyGnuPGKeyrings() ;
|
||||||
|
|
||||||
|
@ -105,14 +105,14 @@ class RsAccountsDetail
|
||||||
|
|
||||||
// Details of Rs Account.
|
// Details of Rs Account.
|
||||||
bool getPreferredAccountId(RsPeerId &id);
|
bool getPreferredAccountId(RsPeerId &id);
|
||||||
bool getAccountDetails(const RsPeerId &id, PGPIdType& gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
|
bool getAccountDetails(const RsPeerId &id, RsPgpId& gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
|
||||||
|
|
||||||
bool getAccountOptions(bool &ishidden, bool isFirstTimeRun);
|
bool getAccountOptions(bool &ishidden, bool isFirstTimeRun);
|
||||||
|
|
||||||
|
|
||||||
bool getAccountIds(std::list<RsPeerId> &ids);
|
bool getAccountIds(std::list<RsPeerId> &ids);
|
||||||
|
|
||||||
bool GenerateSSLCertificate(const PGPIdType& gpg_id,
|
bool GenerateSSLCertificate(const RsPgpId& gpg_id,
|
||||||
const std::string& org, const std::string& loc,
|
const std::string& org, const std::string& loc,
|
||||||
const std::string& country, const bool ishiddenloc,
|
const std::string& country, const bool ishiddenloc,
|
||||||
const std::string& passwd, RsPeerId &sslId,
|
const std::string& passwd, RsPeerId &sslId,
|
||||||
|
|
|
@ -657,7 +657,7 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath
|
||||||
return 3; // invalid PreferredAccount;
|
return 3; // invalid PreferredAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
PGPIdType pgpId;
|
RsPgpId pgpId;
|
||||||
std::string pgpName, pgpEmail, location;
|
std::string pgpName, pgpEmail, location;
|
||||||
|
|
||||||
if (!rsAccounts.getAccountDetails(accountId, pgpId, pgpName, pgpEmail, location))
|
if (!rsAccounts.getAccountDetails(accountId, pgpId, pgpName, pgpEmail, location))
|
||||||
|
|
|
@ -215,137 +215,6 @@ bool setRawUFloat32(void *data,uint32_t size,uint32_t *offset,float f)
|
||||||
return setRawUInt32(data, size, offset, n);
|
return setRawUInt32(data, size, offset, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getRawSha1(void *data,uint32_t size,uint32_t *offset,Sha1CheckSum& cs)
|
|
||||||
{
|
|
||||||
uint32_t len = Sha1CheckSum::SIZE_IN_BYTES ; // SHA1 length in bytes = 20
|
|
||||||
|
|
||||||
/* check there is space for string */
|
|
||||||
if (size < *offset + len)
|
|
||||||
{
|
|
||||||
std::cerr << "getRawSha1() not enough size" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool ok = true ;
|
|
||||||
|
|
||||||
cs = Sha1CheckSum(&((uint8_t*)data)[*offset]) ;
|
|
||||||
*offset += Sha1CheckSum::SIZE_IN_BYTES ;
|
|
||||||
|
|
||||||
return ok ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool setRawSha1(void *data,uint32_t size,uint32_t *offset,const Sha1CheckSum& cs)
|
|
||||||
{
|
|
||||||
uint32_t len = Sha1CheckSum::SIZE_IN_BYTES ; // SHA1 length in bytes
|
|
||||||
|
|
||||||
if (size < *offset + len)
|
|
||||||
{
|
|
||||||
std::cerr << "setRawSha1() Not enough size" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ok = true ;
|
|
||||||
/* pack it in */
|
|
||||||
memcpy((void *) &(((uint8_t *) data)[*offset]), cs.toByteArray(), Sha1CheckSum::SIZE_IN_BYTES) ;
|
|
||||||
offset += Sha1CheckSum::SIZE_IN_BYTES ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
bool getRawPGPId(void *data,uint32_t size,uint32_t *offset,PGPIdType& cs)
|
|
||||||
{
|
|
||||||
uint32_t len = PGPIdType::SIZE_IN_BYTES ; // SSL id type
|
|
||||||
|
|
||||||
/* check there is space for string */
|
|
||||||
if (size < *offset + len)
|
|
||||||
{
|
|
||||||
std::cerr << "getRawPGPId() not enough size" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool ok = true ;
|
|
||||||
|
|
||||||
cs = PGPIdType(&((uint8_t*)data)[*offset]) ;
|
|
||||||
*offset += len ;
|
|
||||||
|
|
||||||
return ok ;
|
|
||||||
}
|
|
||||||
bool getRawSSLId(void *data,uint32_t size,uint32_t *offset,SSLIdType& cs)
|
|
||||||
{
|
|
||||||
uint32_t len = 16 ; // SSL id type
|
|
||||||
|
|
||||||
/* check there is space for string */
|
|
||||||
if (size < *offset + len)
|
|
||||||
{
|
|
||||||
std::cerr << "getRawSha1() not enough size" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool ok = true ;
|
|
||||||
|
|
||||||
cs = SSLIdType(&((uint8_t*)data)[*offset]) ;
|
|
||||||
*offset += 16 ;
|
|
||||||
|
|
||||||
return ok ;
|
|
||||||
}
|
|
||||||
bool setRawPGPId(void *data,uint32_t size,uint32_t *offset,const PGPIdType& cs)
|
|
||||||
{
|
|
||||||
uint32_t len = PGPIdType::SIZE_IN_BYTES ; // SHA1 length in bytes
|
|
||||||
|
|
||||||
if (size < *offset + len)
|
|
||||||
{
|
|
||||||
std::cerr << "setRawPGPId() Not enough size" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy((void *) &(((uint8_t *) data)[*offset]), cs.toByteArray(), PGPIdType::SIZE_IN_BYTES);
|
|
||||||
*offset += PGPIdType::SIZE_IN_BYTES ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
bool setRawSSLId(void *data,uint32_t size,uint32_t *offset,const SSLIdType& cs)
|
|
||||||
{
|
|
||||||
uint32_t len = 16 ; // SHA1 length in bytes
|
|
||||||
|
|
||||||
if (size < *offset + len)
|
|
||||||
{
|
|
||||||
std::cerr << "setRawSha1() Not enough size" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy((void *) &(((uint8_t *) data)[*offset]), cs.toByteArray(), 16);
|
|
||||||
*offset += 16 ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
bool getRawPGPFingerprint(void *data,uint32_t size,uint32_t *offset,PGPFingerprintType& cs)
|
|
||||||
{
|
|
||||||
uint32_t len = 20 ; // SSL id type
|
|
||||||
|
|
||||||
/* check there is space for string */
|
|
||||||
if (size < *offset + len)
|
|
||||||
{
|
|
||||||
std::cerr << "getRawPGPFingerprint() not enough size" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool ok = true ;
|
|
||||||
|
|
||||||
cs = PGPFingerprintType(&((uint8_t*)data)[*offset]) ;
|
|
||||||
*offset += 20 ;
|
|
||||||
|
|
||||||
return ok ;
|
|
||||||
}
|
|
||||||
bool setRawPGPFingerprint(void *data,uint32_t size,uint32_t *offset,const PGPFingerprintType& cs)
|
|
||||||
{
|
|
||||||
uint32_t len = 20 ; // SHA1 length in bytes
|
|
||||||
|
|
||||||
if (size < *offset + len)
|
|
||||||
{
|
|
||||||
std::cerr << "setRawPGPFingerprint() Not enough size" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy((void *) &(((uint8_t *) data)[*offset]), cs.toByteArray(), 20);
|
|
||||||
*offset += 20 ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
bool getRawString(void *data, uint32_t size, uint32_t *offset, std::string &outStr)
|
bool getRawString(void *data, uint32_t size, uint32_t *offset, std::string &outStr)
|
||||||
{
|
{
|
||||||
uint32_t len = 0;
|
uint32_t len = 0;
|
||||||
|
|
|
@ -66,18 +66,6 @@ bool setRawUFloat32(void *data, uint32_t size, uint32_t *offset, float in);
|
||||||
bool getRawString(void *data, uint32_t size, uint32_t *offset, std::string &outStr);
|
bool getRawString(void *data, uint32_t size, uint32_t *offset, std::string &outStr);
|
||||||
bool setRawString(void *data, uint32_t size, uint32_t *offset, const std::string &inStr);
|
bool setRawString(void *data, uint32_t size, uint32_t *offset, const std::string &inStr);
|
||||||
|
|
||||||
bool getRawSha1(void *data, uint32_t size, uint32_t *offset, Sha1CheckSum& outStr);
|
|
||||||
bool setRawSha1(void *data, uint32_t size, uint32_t *offset, const Sha1CheckSum& inStr);
|
|
||||||
|
|
||||||
bool setRawSSLId(void *data, uint32_t size, uint32_t *offset, const SSLIdType& inStr);
|
|
||||||
bool getRawSSLId(void *data, uint32_t size, uint32_t *offset, SSLIdType& outStr);
|
|
||||||
|
|
||||||
bool setRawPGPId(void *data, uint32_t size, uint32_t *offset, const PGPIdType& inStr);
|
|
||||||
bool getRawPGPId(void *data, uint32_t size, uint32_t *offset, PGPIdType& outStr);
|
|
||||||
|
|
||||||
bool setRawPGPFingerprint(void *data, uint32_t size, uint32_t *offset, const PGPFingerprintType& inStr);
|
|
||||||
bool getRawPGPFingerprint(void *data, uint32_t size, uint32_t *offset, PGPFingerprintType& outStr);
|
|
||||||
|
|
||||||
bool setRawTimeT(void *data, uint32_t size, uint32_t *offset, const time_t& inStr);
|
bool setRawTimeT(void *data, uint32_t size, uint32_t *offset, const time_t& inStr);
|
||||||
bool getRawTimeT(void *data, uint32_t size, uint32_t *offset, time_t& outStr);
|
bool getRawTimeT(void *data, uint32_t size, uint32_t *offset, time_t& outStr);
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ uint32_t RsFileConfigSerialiser::sizeTransfer(RsFileTransfer *item)
|
||||||
uint32_t s = 8; /* header */
|
uint32_t s = 8; /* header */
|
||||||
s += item->file.TlvSize();
|
s += item->file.TlvSize();
|
||||||
s += item->allPeerIds.TlvSize();
|
s += item->allPeerIds.TlvSize();
|
||||||
s += SSLIdType::SIZE_IN_BYTES;
|
s += RsPeerId::SIZE_IN_BYTES;
|
||||||
s += 2; /* state */
|
s += 2; /* state */
|
||||||
s += 2; /* in/out */
|
s += 2; /* in/out */
|
||||||
s += 8; /* transferred */
|
s += 8; /* transferred */
|
||||||
|
@ -239,7 +239,7 @@ bool RsFileConfigSerialiser::serialiseTransfer(RsFileTransfer *item, void *d
|
||||||
ok &= item->file.SetTlv(data, tlvsize, &offset);
|
ok &= item->file.SetTlv(data, tlvsize, &offset);
|
||||||
ok &= item->allPeerIds.SetTlv(data, tlvsize, &offset);
|
ok &= item->allPeerIds.SetTlv(data, tlvsize, &offset);
|
||||||
|
|
||||||
ok &= setRawSSLId(data, tlvsize, &offset, item->cPeerId);
|
ok &= item->cPeerId.serialise(data, tlvsize, offset) ;
|
||||||
|
|
||||||
ok &= setRawUInt16(data, tlvsize, &offset, item->state);
|
ok &= setRawUInt16(data, tlvsize, &offset, item->state);
|
||||||
ok &= setRawUInt16(data, tlvsize, &offset, item->in);
|
ok &= setRawUInt16(data, tlvsize, &offset, item->in);
|
||||||
|
@ -305,7 +305,7 @@ RsFileTransfer *RsFileConfigSerialiser::deserialiseTransfer(void *data, uint32_t
|
||||||
ok &= item->file.GetTlv(data, rssize, &offset);
|
ok &= item->file.GetTlv(data, rssize, &offset);
|
||||||
ok &= item->allPeerIds.GetTlv(data, rssize, &offset);
|
ok &= item->allPeerIds.GetTlv(data, rssize, &offset);
|
||||||
|
|
||||||
ok &= getRawSSLId(data, rssize, &offset, item->cPeerId);
|
ok &= item->cPeerId.deserialise(data, rssize, offset) ;
|
||||||
|
|
||||||
/* data */
|
/* data */
|
||||||
ok &= getRawUInt16(data, rssize, &offset, &(item->state));
|
ok &= getRawUInt16(data, rssize, &offset, &(item->state));
|
||||||
|
@ -1184,7 +1184,7 @@ std::ostream &RsPeerGroupItem::print(std::ostream &out, uint16_t indent)
|
||||||
printIndent(out, int_Indent);
|
printIndent(out, int_Indent);
|
||||||
out << "groupFlag: " << flag << std::endl;
|
out << "groupFlag: " << flag << std::endl;
|
||||||
|
|
||||||
std::list<PGPIdType>::iterator it;
|
std::list<RsPgpId>::iterator it;
|
||||||
for (it = peerIds.begin(); it != peerIds.end(); it++) {
|
for (it = peerIds.begin(); it != peerIds.end(); it++) {
|
||||||
printIndent(out, int_Indent);
|
printIndent(out, int_Indent);
|
||||||
out << "peerId: " << *it << std::endl;
|
out << "peerId: " << *it << std::endl;
|
||||||
|
@ -1222,9 +1222,9 @@ uint32_t RsPeerConfigSerialiser::sizeGroup(RsPeerGroupItem *i)
|
||||||
s += GetTlvStringSize(i->name);
|
s += GetTlvStringSize(i->name);
|
||||||
s += 4; /* flag */
|
s += 4; /* flag */
|
||||||
|
|
||||||
std::list<PGPIdType>::iterator it;
|
std::list<RsPgpId>::iterator it;
|
||||||
for (it = i->peerIds.begin(); it != i->peerIds.end(); it++) {
|
for (it = i->peerIds.begin(); it != i->peerIds.end(); it++) {
|
||||||
s += PGPIdType::SIZE_IN_BYTES ;
|
s += RsPgpId::SIZE_IN_BYTES ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
@ -1260,9 +1260,9 @@ bool RsPeerConfigSerialiser::serialiseGroup(RsPeerGroupItem *item, void *data, u
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
|
||||||
|
|
||||||
std::list<PGPIdType>::iterator it;
|
std::list<RsPgpId>::iterator it;
|
||||||
for (it = item->peerIds.begin(); it != item->peerIds.end(); it++) {
|
for (it = item->peerIds.begin(); it != item->peerIds.end(); it++) {
|
||||||
ok &= setRawPGPId(data, tlvsize, &offset, *it);
|
ok &= (*it).serialise(data, tlvsize, offset) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(offset != tlvsize)
|
if(offset != tlvsize)
|
||||||
|
@ -1313,11 +1313,10 @@ RsPeerGroupItem *RsPeerConfigSerialiser::deserialiseGroup(void *data, uint32_t *
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
|
||||||
|
|
||||||
PGPIdType peerId;
|
RsPgpId peerId;
|
||||||
while (offset != rssize)
|
while (offset != rssize)
|
||||||
{
|
{
|
||||||
ok &= getRawPGPId(data, rssize, &offset, peerId);
|
ok &= peerId.deserialise(data, rssize, offset) ;
|
||||||
|
|
||||||
item->peerIds.push_back(peerId);
|
item->peerIds.push_back(peerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1354,7 +1353,7 @@ uint32_t RsPeerConfigSerialiser::sizePermissions(RsPeerServicePermissionItem *i)
|
||||||
|
|
||||||
for(uint32_t j=0;j<i->pgp_ids.size();++j)
|
for(uint32_t j=0;j<i->pgp_ids.size();++j)
|
||||||
{
|
{
|
||||||
s += PGPIdType::SIZE_IN_BYTES ;//GetTlvStringSize(i->pgp_ids[j]) ;
|
s += RsPgpId::SIZE_IN_BYTES ;//GetTlvStringSize(i->pgp_ids[j]) ;
|
||||||
s += 4; /* flag */
|
s += 4; /* flag */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1390,7 +1389,7 @@ bool RsPeerConfigSerialiser::serialisePermissions(RsPeerServicePermissionItem *i
|
||||||
|
|
||||||
for(uint32_t i=0;i<item->pgp_ids.size();++i)
|
for(uint32_t i=0;i<item->pgp_ids.size();++i)
|
||||||
{
|
{
|
||||||
ok &= setRawPGPId(data, tlvsize, &offset, item->pgp_ids[i]);
|
ok &= item->pgp_ids[i].serialise(data, tlvsize, offset) ;
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->service_flags[i].toUInt32());
|
ok &= setRawUInt32(data, tlvsize, &offset, item->service_flags[i].toUInt32());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1445,7 +1444,7 @@ RsPeerServicePermissionItem *RsPeerConfigSerialiser::deserialisePermissions(void
|
||||||
for(uint32_t i=0;i<s;++i)
|
for(uint32_t i=0;i<s;++i)
|
||||||
{
|
{
|
||||||
uint32_t flags ;
|
uint32_t flags ;
|
||||||
ok &= getRawPGPId(data, rssize, &offset, item->pgp_ids[i]);
|
ok &= item->pgp_ids[i].deserialise(data, rssize, offset) ;
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &flags);
|
ok &= getRawUInt32(data, rssize, &offset, &flags);
|
||||||
|
|
||||||
item->service_flags[i] = ServicePermissionFlags(flags) ;
|
item->service_flags[i] = ServicePermissionFlags(flags) ;
|
||||||
|
|
|
@ -109,7 +109,7 @@ class RsPeerServicePermissionItem : public RsItem
|
||||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||||
|
|
||||||
/* Mandatory */
|
/* Mandatory */
|
||||||
std::vector<PGPIdType> pgp_ids ;
|
std::vector<RsPgpId> pgp_ids ;
|
||||||
std::vector<ServicePermissionFlags> service_flags ;
|
std::vector<ServicePermissionFlags> service_flags ;
|
||||||
};
|
};
|
||||||
class RsPeerGroupItem : public RsItem
|
class RsPeerGroupItem : public RsItem
|
||||||
|
@ -131,7 +131,7 @@ public:
|
||||||
std::string name;
|
std::string name;
|
||||||
uint32_t flag;
|
uint32_t flag;
|
||||||
|
|
||||||
std::list<PGPIdType> peerIds;
|
std::list<RsPgpId> peerIds;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ virtual ~RsDiscPgpCertItem();
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||||
|
|
||||||
PGPIdType pgpId;
|
RsPgpId pgpId;
|
||||||
std::string pgpCert;
|
std::string pgpCert;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ virtual ~RsDiscContactItem();
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||||
|
|
||||||
PGPIdType pgpId;
|
RsPgpId pgpId;
|
||||||
RsPeerId sslId;
|
RsPeerId sslId;
|
||||||
|
|
||||||
// COMMON
|
// COMMON
|
||||||
|
|
|
@ -193,9 +193,9 @@ uint32_t RsFileTransferChunkMapItem::serial_size()
|
||||||
uint32_t RsFileTransferSingleChunkCrcItem::serial_size()
|
uint32_t RsFileTransferSingleChunkCrcItem::serial_size()
|
||||||
{
|
{
|
||||||
uint32_t s = 8; /* header */
|
uint32_t s = 8; /* header */
|
||||||
s += hash.serial_size() ; // hash
|
s += hash.serial_size() ; // hash
|
||||||
s += 4 ; // chunk number
|
s += 4 ; // chunk number
|
||||||
s += 20 ; // sha1
|
s += check_sum.serial_size() ; // sha1
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ bool RsFileTransferSingleChunkCrcItem::serialise(void *data, uint32_t& pktsize)
|
||||||
ok &= hash.serialise(data, tlvsize, offset) ;
|
ok &= hash.serialise(data, tlvsize, offset) ;
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, chunk_number) ;
|
ok &= setRawUInt32(data, tlvsize, &offset, chunk_number) ;
|
||||||
|
|
||||||
setRawSha1(data,tlvsize,&offset,check_sum) ;
|
ok &= check_sum.serialise(data,tlvsize,offset) ;
|
||||||
|
|
||||||
//ok &= setRawUInt32(data, tlvsize, &offset, check_sum.fourbytes[0]) ;
|
//ok &= setRawUInt32(data, tlvsize, &offset, check_sum.fourbytes[0]) ;
|
||||||
//ok &= setRawUInt32(data, tlvsize, &offset, check_sum.fourbytes[1]) ;
|
//ok &= setRawUInt32(data, tlvsize, &offset, check_sum.fourbytes[1]) ;
|
||||||
|
@ -779,7 +779,7 @@ RsFileTransferItem *RsFileTransferSerialiser::deserialise_RsFileTransferSingleCh
|
||||||
offset += 8;
|
offset += 8;
|
||||||
ok &= item->hash.deserialise(data, rssize, offset) ;
|
ok &= item->hash.deserialise(data, rssize, offset) ;
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->chunk_number));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->chunk_number));
|
||||||
getRawSha1(data,rssize,&offset,item->check_sum) ;
|
ok &= item->check_sum.deserialise(data,rssize,offset) ;
|
||||||
|
|
||||||
if (offset != rssize)
|
if (offset != rssize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -336,7 +336,7 @@ class RsPrivateChatDistantInviteConfigItem: public RsChatItem
|
||||||
unsigned char aes_key[16] ;
|
unsigned char aes_key[16] ;
|
||||||
RsFileHash hash ;
|
RsFileHash hash ;
|
||||||
std::string encrypted_radix64_string ;
|
std::string encrypted_radix64_string ;
|
||||||
PGPIdType destination_pgp_id ;
|
RsPgpId destination_pgp_id ;
|
||||||
uint32_t time_of_validity ;
|
uint32_t time_of_validity ;
|
||||||
uint32_t last_hit_time ;
|
uint32_t last_hit_time ;
|
||||||
uint32_t flags ;
|
uint32_t flags ;
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "retroshare/rsids.h"
|
#include "retroshare/rstypes.h"
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
* This is the Top-Level serialiser/deserialise,
|
* This is the Top-Level serialiser/deserialise,
|
||||||
|
@ -86,8 +86,8 @@ class RsItem: public RsMemoryManagement::SmallObject
|
||||||
void print_string(std::string &out, uint16_t indent = 0);
|
void print_string(std::string &out, uint16_t indent = 0);
|
||||||
|
|
||||||
/* source / destination id */
|
/* source / destination id */
|
||||||
const SSLIdType& PeerId() const { return peerId; }
|
const RsPeerId& PeerId() const { return peerId; }
|
||||||
void PeerId(const SSLIdType& id) { peerId = id; }
|
void PeerId(const RsPeerId& id) { peerId = id; }
|
||||||
|
|
||||||
/* complete id */
|
/* complete id */
|
||||||
uint32_t PacketId() const;
|
uint32_t PacketId() const;
|
||||||
|
@ -106,7 +106,7 @@ class RsItem: public RsMemoryManagement::SmallObject
|
||||||
inline void setPriorityLevel(uint8_t l) { _priority_level = l ;}
|
inline void setPriorityLevel(uint8_t l) { _priority_level = l ;}
|
||||||
private:
|
private:
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
SSLIdType peerId;
|
RsPeerId peerId;
|
||||||
uint8_t _priority_level ;
|
uint8_t _priority_level ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ template<class ID_CLASS,uint32_t TLV_TYPE> class t_RsTlvIdSet: public RsTlvItem
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef t_RsTlvIdSet<RsPeerId,TLV_TYPE_PEERSET> RsTlvPeerIdSet ;
|
typedef t_RsTlvIdSet<RsPeerId,TLV_TYPE_PEERSET> RsTlvPeerIdSet ;
|
||||||
typedef t_RsTlvIdSet<PGPIdType,TLV_TYPE_PGPIDSET> RsTlvPgpIdSet ;
|
typedef t_RsTlvIdSet<RsPgpId,TLV_TYPE_PGPIDSET> RsTlvPgpIdSet ;
|
||||||
typedef t_RsTlvIdSet<Sha1CheckSum,TLV_TYPE_HASHSET> RsTlvHashSet ;
|
typedef t_RsTlvIdSet<Sha1CheckSum,TLV_TYPE_HASHSET> RsTlvHashSet ;
|
||||||
|
|
||||||
class RsTlvServiceIdSet: public RsTlvItem
|
class RsTlvServiceIdSet: public RsTlvItem
|
||||||
|
|
|
@ -464,7 +464,7 @@ bool p3ChatService::isOnline(const DistantChatPeerId& pid)
|
||||||
// check if the id is a tunnel id or a peer id.
|
// check if the id is a tunnel id or a peer id.
|
||||||
|
|
||||||
uint32_t status ;
|
uint32_t status ;
|
||||||
PGPIdType pgp_id ;
|
RsPgpId pgp_id ;
|
||||||
|
|
||||||
std::string hash ;
|
std::string hash ;
|
||||||
if(getDistantChatStatus(pid,status,pgp_id))
|
if(getDistantChatStatus(pid,status,pgp_id))
|
||||||
|
@ -3386,7 +3386,7 @@ void p3ChatService::sendTurtleData(RsChatItem *item)
|
||||||
mTurtle->sendTurtleData(virtual_peer_id,gitem) ;
|
mTurtle->sendTurtleData(virtual_peer_id,gitem) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_radix64_string)
|
bool p3ChatService::createDistantChatInvite(const RsPgpId& pgp_id,time_t time_of_validity,std::string& encrypted_radix64_string)
|
||||||
{
|
{
|
||||||
// create the invite
|
// create the invite
|
||||||
|
|
||||||
|
@ -3424,7 +3424,7 @@ bool p3ChatService::createDistantChatInvite(const PGPIdType& pgp_id,time_t time_
|
||||||
uint32_t header_size = DISTANT_CHAT_AES_KEY_SIZE + DISTANT_CHAT_HASH_SIZE + PGP_KEY_ID_SIZE;
|
uint32_t header_size = DISTANT_CHAT_AES_KEY_SIZE + DISTANT_CHAT_HASH_SIZE + PGP_KEY_ID_SIZE;
|
||||||
unsigned char *data = new unsigned char[header_size+800] ;
|
unsigned char *data = new unsigned char[header_size+800] ;
|
||||||
|
|
||||||
PGPIdType OwnId(AuthGPG::getAuthGPG()->getGPGOwnId());
|
RsPgpId OwnId(AuthGPG::getAuthGPG()->getGPGOwnId());
|
||||||
|
|
||||||
memcpy(data ,Sha1CheckSum(hash).toByteArray(),DISTANT_CHAT_HASH_SIZE) ;
|
memcpy(data ,Sha1CheckSum(hash).toByteArray(),DISTANT_CHAT_HASH_SIZE) ;
|
||||||
memcpy(data+DISTANT_CHAT_HASH_SIZE ,invite.aes_key ,DISTANT_CHAT_AES_KEY_SIZE) ;
|
memcpy(data+DISTANT_CHAT_HASH_SIZE ,invite.aes_key ,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||||
|
@ -3498,7 +3498,7 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
||||||
|
|
||||||
uint32_t header_size = DISTANT_CHAT_HASH_SIZE + DISTANT_CHAT_AES_KEY_SIZE + PGP_KEY_ID_SIZE ;
|
uint32_t header_size = DISTANT_CHAT_HASH_SIZE + DISTANT_CHAT_AES_KEY_SIZE + PGP_KEY_ID_SIZE ;
|
||||||
|
|
||||||
PGPIdType pgp_id( data + DISTANT_CHAT_HASH_SIZE + DISTANT_CHAT_AES_KEY_SIZE ) ;
|
RsPgpId pgp_id( data + DISTANT_CHAT_HASH_SIZE + DISTANT_CHAT_AES_KEY_SIZE ) ;
|
||||||
|
|
||||||
#ifdef DEBUG_DISTANT_CHAT
|
#ifdef DEBUG_DISTANT_CHAT
|
||||||
std::cerr << "Got this PGP id: " << pgp_id.toStdString() << std::endl;
|
std::cerr << "Got this PGP id: " << pgp_id.toStdString() << std::endl;
|
||||||
|
@ -3559,7 +3559,7 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
||||||
|
|
||||||
bool p3ChatService::initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code)
|
bool p3ChatService::initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code)
|
||||||
{
|
{
|
||||||
PGPIdType pgp_id ;
|
RsPgpId pgp_id ;
|
||||||
unsigned char aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
unsigned char aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
||||||
|
|
||||||
TurtleFileHash hash = hashFromVirtualPeerId(pid) ;
|
TurtleFileHash hash = hashFromVirtualPeerId(pid) ;
|
||||||
|
@ -3587,7 +3587,7 @@ bool p3ChatService::initiateDistantChatConnexion(const DistantChatPeerId& pid,ui
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::startClientDistantChatConnection(const RsFileHash& hash,const PGPIdType& pgp_id,const unsigned char *aes_key_buf)
|
void p3ChatService::startClientDistantChatConnection(const RsFileHash& hash,const RsPgpId& pgp_id,const unsigned char *aes_key_buf)
|
||||||
{
|
{
|
||||||
DistantChatPeerInfo info ;
|
DistantChatPeerInfo info ;
|
||||||
|
|
||||||
|
@ -3677,7 +3677,7 @@ bool p3ChatService::getDistantChatInviteList(std::vector<DistantChatInviteInfo>&
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,PGPIdType& pgp_id)
|
bool p3ChatService::getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,RsPgpId& pgp_id)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
|
|
@ -327,21 +327,21 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
// Creates the invite if the public key of the distant peer is available.
|
// Creates the invite if the public key of the distant peer is available.
|
||||||
// Om success, stores the invite in the map above, so that we can respond to tunnel requests.
|
// Om success, stores the invite in the map above, so that we can respond to tunnel requests.
|
||||||
//
|
//
|
||||||
bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& enc_b64_string) ;
|
bool createDistantChatInvite(const RsPgpId& pgp_id,time_t time_of_validity,std::string& enc_b64_string) ;
|
||||||
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
|
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
|
||||||
bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t time_of_validity,DistantChatPeerId& pid,uint32_t& error_code) ; // from encrypted data
|
bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t time_of_validity,DistantChatPeerId& pid,uint32_t& error_code) ; // from encrypted data
|
||||||
bool initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code) ; // from known hash of a decrypted link
|
bool initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code) ; // from known hash of a decrypted link
|
||||||
bool closeDistantChatConnexion(const DistantChatPeerId& pid) ;
|
bool closeDistantChatConnexion(const DistantChatPeerId& pid) ;
|
||||||
bool removeDistantChatInvite(const DistantChatPeerId& pid) ;
|
bool removeDistantChatInvite(const DistantChatPeerId& pid) ;
|
||||||
|
|
||||||
virtual bool getDistantChatStatus(const DistantChatPeerId& hash,uint32_t& status,PGPIdType& pgp_id) ;
|
virtual bool getDistantChatStatus(const DistantChatPeerId& hash,uint32_t& status,RsPgpId& pgp_id) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct DistantChatInvite
|
struct DistantChatInvite
|
||||||
{
|
{
|
||||||
unsigned char aes_key[16] ;
|
unsigned char aes_key[16] ;
|
||||||
std::string encrypted_radix64_string ;
|
std::string encrypted_radix64_string ;
|
||||||
PGPIdType destination_pgp_id ;
|
RsPgpId destination_pgp_id ;
|
||||||
time_t time_of_validity ;
|
time_t time_of_validity ;
|
||||||
time_t last_hit_time ;
|
time_t last_hit_time ;
|
||||||
uint32_t flags ;
|
uint32_t flags ;
|
||||||
|
@ -352,7 +352,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
unsigned char aes_key[16] ; // key to encrypt packets
|
unsigned char aes_key[16] ; // key to encrypt packets
|
||||||
uint32_t status ; // info: do we have a tunnel ?
|
uint32_t status ; // info: do we have a tunnel ?
|
||||||
RsPeerId virtual_peer_id; // given by the turtle router. Identifies the tunnel.
|
RsPeerId virtual_peer_id; // given by the turtle router. Identifies the tunnel.
|
||||||
PGPIdType pgp_id ; // pgp id of the peer we're talking to.
|
RsPgpId pgp_id ; // pgp id of the peer we're talking to.
|
||||||
RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server.
|
RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
||||||
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
||||||
void markDistantChatAsClosed(const TurtleVirtualPeerId& vpid) ;
|
void markDistantChatAsClosed(const TurtleVirtualPeerId& vpid) ;
|
||||||
void startClientDistantChatConnection(const RsFileHash& hash,const PGPIdType& pgp_id,const unsigned char *aes_key_buf) ;
|
void startClientDistantChatConnection(const RsFileHash& hash,const RsPgpId& pgp_id,const unsigned char *aes_key_buf) ;
|
||||||
bool findHashForVirtualPeerId(const TurtleVirtualPeerId& pid,RsFileHash& hash) ;
|
bool findHashForVirtualPeerId(const TurtleVirtualPeerId& pid,RsFileHash& hash) ;
|
||||||
|
|
||||||
// Utility functions
|
// Utility functions
|
||||||
|
|
|
@ -961,7 +961,7 @@ void p3discovery2::recvPGPCertificateRequest(const SSLID &fromId, const RsDiscPg
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::list<PGPIdType>::const_iterator it;
|
std::list<RsPgpId>::const_iterator it;
|
||||||
for(it = item->pgpIdSet.ids.begin(); it != item->pgpIdSet.ids.end(); it++)
|
for(it = item->pgpIdSet.ids.begin(); it != item->pgpIdSet.ids.end(); it++)
|
||||||
{
|
{
|
||||||
// NB: This doesn't include own certificates? why not.
|
// NB: This doesn't include own certificates? why not.
|
||||||
|
|
|
@ -41,8 +41,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef PGPIdType PGPID;
|
typedef RsPgpId PGPID;
|
||||||
typedef SSLIdType SSLID;
|
typedef RsPeerId SSLID;
|
||||||
|
|
||||||
class DiscSslInfo
|
class DiscSslInfo
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,7 @@ virtual ~p3discovery2();
|
||||||
|
|
||||||
/* external interface */
|
/* external interface */
|
||||||
virtual bool getDiscFriends(const RsPeerId &id, std::list<RsPeerId> &friends);
|
virtual bool getDiscFriends(const RsPeerId &id, std::list<RsPeerId> &friends);
|
||||||
virtual bool getDiscPgpFriends(const PGPIdType &pgpid, std::list<PGPIdType> &gpg_friends);
|
virtual bool getDiscPgpFriends(const RsPgpId &pgpid, std::list<RsPgpId> &gpg_friends);
|
||||||
virtual bool getPeerVersion(const RsPeerId &id, std::string &version);
|
virtual bool getPeerVersion(const RsPeerId &id, std::string &version);
|
||||||
virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount);
|
virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount);
|
||||||
|
|
||||||
|
|
|
@ -1952,7 +1952,7 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
PGPFingerprintType ownFinger;
|
PGPFingerprintType ownFinger;
|
||||||
PGPIdType ownId(AuthGPG::getAuthGPG()->getGPGOwnId());
|
RsPgpId ownId(AuthGPG::getAuthGPG()->getGPGOwnId());
|
||||||
|
|
||||||
std::cerr << "p3IdService::service_CreateGroup() OwnPgpID: " << ownId.toStdString();
|
std::cerr << "p3IdService::service_CreateGroup() OwnPgpID: " << ownId.toStdString();
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -1960,7 +1960,7 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte
|
||||||
#ifdef GXSID_GEN_DUMMY_DATA
|
#ifdef GXSID_GEN_DUMMY_DATA
|
||||||
if (item->group.mMeta.mAuthorId != "")
|
if (item->group.mMeta.mAuthorId != "")
|
||||||
{
|
{
|
||||||
ownId = PGPIdType(item->group.mMeta.mAuthorId);
|
ownId = RsPgpId(item->group.mMeta.mAuthorId);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2233,7 +2233,7 @@ bool p3IdService::pgphash_process()
|
||||||
SSGxsIdGroup ssdata;
|
SSGxsIdGroup ssdata;
|
||||||
ssdata.load(pg.mMeta.mServiceString); // attempt load - okay if fails.
|
ssdata.load(pg.mMeta.mServiceString); // attempt load - okay if fails.
|
||||||
|
|
||||||
PGPIdType pgpId;
|
RsPgpId pgpId;
|
||||||
|
|
||||||
if (checkId(pg, pgpId))
|
if (checkId(pg, pgpId))
|
||||||
{
|
{
|
||||||
|
@ -2276,7 +2276,7 @@ bool p3IdService::pgphash_process()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool p3IdService::checkId(const RsGxsIdGroup &grp, PGPIdType &pgpId)
|
bool p3IdService::checkId(const RsGxsIdGroup &grp, RsPgpId &pgpId)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_IDS
|
#ifdef DEBUG_IDS
|
||||||
std::cerr << "p3IdService::checkId() Starting Match Check for RsGxsId: ";
|
std::cerr << "p3IdService::checkId() Starting Match Check for RsGxsId: ";
|
||||||
|
@ -2308,7 +2308,7 @@ bool p3IdService::checkId(const RsGxsIdGroup &grp, PGPIdType &pgpId)
|
||||||
|
|
||||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<PGPIdType, PGPFingerprintType>::iterator mit;
|
std::map<RsPgpId, PGPFingerprintType>::iterator mit;
|
||||||
for(mit = mPgpFingerprintMap.begin(); mit != mPgpFingerprintMap.end(); mit++)
|
for(mit = mPgpFingerprintMap.begin(); mit != mPgpFingerprintMap.end(); mit++)
|
||||||
{
|
{
|
||||||
GxsIdPgpHash hash;
|
GxsIdPgpHash hash;
|
||||||
|
@ -2386,17 +2386,17 @@ void p3IdService::getPgpIdList()
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif // DEBUG_IDS
|
#endif // DEBUG_IDS
|
||||||
|
|
||||||
std::list<PGPIdType> list;
|
std::list<RsPgpId> list;
|
||||||
AuthGPG::getAuthGPG()->getGPGFilteredList(list);
|
AuthGPG::getAuthGPG()->getGPGFilteredList(list);
|
||||||
|
|
||||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
mPgpFingerprintMap.clear();
|
mPgpFingerprintMap.clear();
|
||||||
|
|
||||||
std::list<PGPIdType>::iterator it;
|
std::list<RsPgpId>::iterator it;
|
||||||
for(it = list.begin(); it != list.end(); it++)
|
for(it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
PGPIdType pgpId(*it);
|
RsPgpId pgpId(*it);
|
||||||
PGPFingerprintType fp;
|
PGPFingerprintType fp;
|
||||||
AuthGPG::getAuthGPG()->getKeyFingerprint(pgpId, fp);
|
AuthGPG::getAuthGPG()->getKeyFingerprint(pgpId, fp);
|
||||||
|
|
||||||
|
@ -2854,7 +2854,7 @@ void p3IdService::generateDummy_OwnIds()
|
||||||
|
|
||||||
/* grab all the gpg ids... and make some ids */
|
/* grab all the gpg ids... and make some ids */
|
||||||
|
|
||||||
PGPIdType ownId = rsPeers->getGPGOwnId();
|
RsPgpId ownId = rsPeers->getGPGOwnId();
|
||||||
|
|
||||||
// generate some ownIds.
|
// generate some ownIds.
|
||||||
int genCount = 0;
|
int genCount = 0;
|
||||||
|
@ -2889,8 +2889,8 @@ void p3IdService::generateDummy_FriendPGP()
|
||||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
// Now Generate for friends.
|
// Now Generate for friends.
|
||||||
std::list<PGPIdType> gpgids;
|
std::list<RsPgpId> gpgids;
|
||||||
std::list<PGPIdType>::const_iterator it;
|
std::list<RsPgpId>::const_iterator it;
|
||||||
rsPeers->getGPGAllList(gpgids);
|
rsPeers->getGPGAllList(gpgids);
|
||||||
|
|
||||||
RsGxsIdGroup id;
|
RsGxsIdGroup id;
|
||||||
|
|
|
@ -344,12 +344,12 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
||||||
bool pgphash_handlerequest(uint32_t token);
|
bool pgphash_handlerequest(uint32_t token);
|
||||||
bool pgphash_process();
|
bool pgphash_process();
|
||||||
|
|
||||||
bool checkId(const RsGxsIdGroup &grp, PGPIdType &pgp_id);
|
bool checkId(const RsGxsIdGroup &grp, RsPgpId &pgp_id);
|
||||||
void getPgpIdList();
|
void getPgpIdList();
|
||||||
|
|
||||||
/* MUTEX PROTECTED DATA (mIdMtx - maybe should use a 2nd?) */
|
/* MUTEX PROTECTED DATA (mIdMtx - maybe should use a 2nd?) */
|
||||||
|
|
||||||
std::map<PGPIdType, PGPFingerprintType> mPgpFingerprintMap;
|
std::map<RsPgpId, PGPFingerprintType> mPgpFingerprintMap;
|
||||||
std::list<RsGxsIdGroup> mGroupsToProcess;
|
std::list<RsGxsIdGroup> mGroupsToProcess;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
|
|
@ -91,7 +91,7 @@ p3MsgService::p3MsgService(p3LinkMgr *lm)
|
||||||
#ifdef GROUTER
|
#ifdef GROUTER
|
||||||
// Debug stuff. Create a random key and register it.
|
// Debug stuff. Create a random key and register it.
|
||||||
const RsPeerId& own_ssl_id = rsPeers->getOwnId() ;
|
const RsPeerId& own_ssl_id = rsPeers->getOwnId() ;
|
||||||
const PGPIdType& gpg_id = rsPeers->getGPGOwnId() ;
|
const RsPgpId& gpg_id = rsPeers->getGPGOwnId() ;
|
||||||
|
|
||||||
RsPeerDetails d;
|
RsPeerDetails d;
|
||||||
rsPeers->getPeerDetails(gpg_id,d) ;
|
rsPeers->getPeerDetails(gpg_id,d) ;
|
||||||
|
@ -1090,7 +1090,7 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
||||||
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
|
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
|
||||||
if (msg)
|
if (msg)
|
||||||
{
|
{
|
||||||
std::list<PGPIdType>::iterator it ;
|
std::list<RsPgpId>::iterator it ;
|
||||||
|
|
||||||
// Update destination ids in place of distant message hash, since this Outgoing message is for display
|
// Update destination ids in place of distant message hash, since this Outgoing message is for display
|
||||||
//
|
//
|
||||||
|
@ -1792,7 +1792,7 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const RsPeerId &to)
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3MsgService::encryptMessage(const PGPIdType& pgp_id,RsMsgItem *item)
|
bool p3MsgService::encryptMessage(const RsPgpId& pgp_id,RsMsgItem *item)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DISTANT_MSG
|
#ifdef DEBUG_DISTANT_MSG
|
||||||
std::cerr << "Encrypting message with public key " << pgp_id << " in place." << std::endl;
|
std::cerr << "Encrypting message with public key " << pgp_id << " in place." << std::endl;
|
||||||
|
@ -1813,7 +1813,7 @@ bool p3MsgService::encryptMessage(const PGPIdType& pgp_id,RsMsgItem *item)
|
||||||
#ifdef DEBUG_DISTANT_MSG
|
#ifdef DEBUG_DISTANT_MSG
|
||||||
std::cerr << " adding own key ID " << AuthGPG::getAuthGPG()->getGPGOwnId() << std::endl;
|
std::cerr << " adding own key ID " << AuthGPG::getAuthGPG()->getGPGOwnId() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
memcpy(&data[1], PGPIdType(AuthGPG::getAuthGPG()->getGPGOwnId()).toByteArray(), PGP_KEY_ID_SIZE) ;
|
memcpy(&data[1], RsPgpId(AuthGPG::getAuthGPG()->getGPGOwnId()).toByteArray(), PGP_KEY_ID_SIZE) ;
|
||||||
|
|
||||||
// 1 - serialise the whole message item into a binary chunk.
|
// 1 - serialise the whole message item into a binary chunk.
|
||||||
//
|
//
|
||||||
|
@ -1982,7 +1982,7 @@ bool p3MsgService::decryptMessage(const std::string& mId)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PGPIdType senders_id(&decrypted_data[1]) ;
|
RsPgpId senders_id(&decrypted_data[1]) ;
|
||||||
|
|
||||||
#ifdef DEBUG_DISTANT_MSG
|
#ifdef DEBUG_DISTANT_MSG
|
||||||
std::cerr << " Sender's ID: " << senders_id.toStdString() << std::endl;
|
std::cerr << " Sender's ID: " << senders_id.toStdString() << std::endl;
|
||||||
|
@ -2038,7 +2038,7 @@ bool p3MsgService::decryptMessage(const std::string& mId)
|
||||||
item->print(std::cerr,0) ;
|
item->print(std::cerr,0) ;
|
||||||
#endif
|
#endif
|
||||||
RsPeerId own_id ;
|
RsPeerId own_id ;
|
||||||
const PGPIdType& own_pgp_id = AuthGPG::getAuthGPG()->getGPGOwnId();
|
const RsPgpId& own_pgp_id = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||||
getDistantMessagePeerId(own_pgp_id,own_id) ;
|
getDistantMessagePeerId(own_pgp_id,own_id) ;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -2159,7 +2159,7 @@ void p3MsgService::enableDistantMessaging(bool b)
|
||||||
|
|
||||||
// Debug stuff. Create a random key and register it.
|
// Debug stuff. Create a random key and register it.
|
||||||
const RsPeerId& own_ssl_id = rsPeers->getOwnId() ;
|
const RsPeerId& own_ssl_id = rsPeers->getOwnId() ;
|
||||||
const PGPIdType& gpg_id = rsPeers->getGPGOwnId() ;
|
const RsPgpId& gpg_id = rsPeers->getGPGOwnId() ;
|
||||||
|
|
||||||
RsPeerDetails d;
|
RsPeerDetails d;
|
||||||
rsPeers->getPeerDetails(gpg_id,d) ;
|
rsPeers->getPeerDetails(gpg_id,d) ;
|
||||||
|
@ -2212,7 +2212,7 @@ bool p3MsgService::distantMessagingEnabled()
|
||||||
}
|
}
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
bool p3MsgService::getDistantMessagePeerId(const PGPIdType& pgp_id,DistantMsgPeerId& peer_id)
|
bool p3MsgService::getDistantMessagePeerId(const RsPgpId& pgp_id,DistantMsgPeerId& peer_id)
|
||||||
{
|
{
|
||||||
if(!AuthGPG::getAuthGPG()->isKeySupported(pgp_id))
|
if(!AuthGPG::getAuthGPG()->isKeySupported(pgp_id))
|
||||||
return false ;
|
return false ;
|
||||||
|
@ -2227,7 +2227,7 @@ bool p3MsgService::getDistantMessagePeerId(const PGPIdType& pgp_id,DistantMsgPee
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
bool p3MsgService::getDistantMessageHash(const PGPIdType& pgp_id,Sha1CheckSum& hash)
|
bool p3MsgService::getDistantMessageHash(const RsPgpId& pgp_id,Sha1CheckSum& hash)
|
||||||
{
|
{
|
||||||
if(!AuthGPG::getAuthGPG()->isKeySupported(pgp_id))
|
if(!AuthGPG::getAuthGPG()->isKeySupported(pgp_id))
|
||||||
return false ;
|
return false ;
|
||||||
|
|
|
@ -132,10 +132,10 @@ int checkOutgoingMessages();
|
||||||
|
|
||||||
void enableDistantMessaging(bool b) ;
|
void enableDistantMessaging(bool b) ;
|
||||||
bool distantMessagingEnabled() ;
|
bool distantMessagingEnabled() ;
|
||||||
bool getDistantMessagePeerId(const PGPIdType& pgp_id,DistantMsgPeerId &peer_id) ;
|
bool getDistantMessagePeerId(const RsPgpId& pgp_id,DistantMsgPeerId &peer_id) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool getDistantMessageHash(const PGPIdType& pgp_id,Sha1CheckSum &hash) ;
|
bool getDistantMessageHash(const RsPgpId& pgp_id,Sha1CheckSum &hash) ;
|
||||||
void sendPrivateMsgItem(const Sha1CheckSum& hash,RsMsgItem *) ;
|
void sendPrivateMsgItem(const Sha1CheckSum& hash,RsMsgItem *) ;
|
||||||
|
|
||||||
// This maps contains the current invitations to respond to.
|
// This maps contains the current invitations to respond to.
|
||||||
|
@ -158,7 +158,7 @@ int checkOutgoingMessages();
|
||||||
|
|
||||||
// Utility functions
|
// Utility functions
|
||||||
|
|
||||||
bool encryptMessage(const PGPIdType& pgp_id,RsMsgItem *msg) ;
|
bool encryptMessage(const RsPgpId& pgp_id,RsMsgItem *msg) ;
|
||||||
bool locked_findHashForVirtualPeerId(const RsPeerId& pid,Sha1CheckSum& hash) ;
|
bool locked_findHashForVirtualPeerId(const RsPeerId& pid,Sha1CheckSum& hash) ;
|
||||||
|
|
||||||
void manageDistantPeers() ;
|
void manageDistantPeers() ;
|
||||||
|
|
|
@ -292,23 +292,23 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
|
||||||
/************* Communication with clients *******************/
|
/************* Communication with clients *******************/
|
||||||
/// Does the turtle router manages tunnels to this peer ? (this is not a
|
/// Does the turtle router manages tunnels to this peer ? (this is not a
|
||||||
/// real id, but a fake one, that the turtle router is capable of connecting with a tunnel id).
|
/// real id, but a fake one, that the turtle router is capable of connecting with a tunnel id).
|
||||||
virtual bool isTurtlePeer(const SSLIdType& peer_id) const ;
|
virtual bool isTurtlePeer(const RsPeerId& peer_id) const ;
|
||||||
|
|
||||||
/// sets/gets the max number of forwarded tunnel requests per second.
|
/// sets/gets the max number of forwarded tunnel requests per second.
|
||||||
virtual void setMaxTRForwardRate(int max_tr_up_rate) ;
|
virtual void setMaxTRForwardRate(int max_tr_up_rate) ;
|
||||||
virtual int getMaxTRForwardRate() const ;
|
virtual int getMaxTRForwardRate() const ;
|
||||||
|
|
||||||
/// Examines the peer id, finds the turtle tunnel in it, and respond yes if the tunnel is ok and operational.
|
/// Examines the peer id, finds the turtle tunnel in it, and respond yes if the tunnel is ok and operational.
|
||||||
bool isOnline(const SSLIdType& peer_id) const ;
|
bool isOnline(const RsPeerId& peer_id) const ;
|
||||||
|
|
||||||
/// Returns a unique peer id, corresponding to the given tunnel.
|
/// Returns a unique peer id, corresponding to the given tunnel.
|
||||||
SSLIdType getTurtlePeerId(TurtleTunnelId tid) const ;
|
RsPeerId getTurtlePeerId(TurtleTunnelId tid) const ;
|
||||||
|
|
||||||
/// returns the list of virtual peers for all tunnels.
|
/// returns the list of virtual peers for all tunnels.
|
||||||
void getSourceVirtualPeersList(const TurtleFileHash& hash,std::list<pqipeer>& list) ;
|
void getSourceVirtualPeersList(const TurtleFileHash& hash,std::list<pqipeer>& list) ;
|
||||||
|
|
||||||
/// Send a data request into the correct tunnel for the given file hash
|
/// Send a data request into the correct tunnel for the given file hash
|
||||||
void sendTurtleData(const SSLIdType& virtual_peer_id, RsTurtleGenericTunnelItem *item) ;
|
void sendTurtleData(const RsPeerId& virtual_peer_id, RsTurtleGenericTunnelItem *item) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//--------------------------- Admin/Helper functions -------------------------//
|
//--------------------------- Admin/Helper functions -------------------------//
|
||||||
|
@ -352,7 +352,7 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
|
||||||
|
|
||||||
/// specific routing functions for handling particular packets.
|
/// specific routing functions for handling particular packets.
|
||||||
void handleRecvGenericTunnelItem(RsTurtleGenericTunnelItem *item);
|
void handleRecvGenericTunnelItem(RsTurtleGenericTunnelItem *item);
|
||||||
bool getTunnelServiceInfo(TurtleTunnelId, SSLIdType& virtual_peer_id, RsFileHash& hash, RsTurtleClientService*&) ;
|
bool getTunnelServiceInfo(TurtleTunnelId, RsPeerId& virtual_peer_id, RsFileHash& hash, RsTurtleClientService*&) ;
|
||||||
|
|
||||||
// following functions should go to ftServer
|
// following functions should go to ftServer
|
||||||
void handleSearchRequest(RsTurtleSearchRequestItem *item);
|
void handleSearchRequest(RsTurtleSearchRequestItem *item);
|
||||||
|
@ -369,7 +369,7 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
|
||||||
void returnSearchResult(RsTurtleSearchResultItem *item) ;
|
void returnSearchResult(RsTurtleSearchResultItem *item) ;
|
||||||
|
|
||||||
/// Returns true if the file with given hash is hosted locally, and accessible in anonymous mode the supplied peer.
|
/// Returns true if the file with given hash is hosted locally, and accessible in anonymous mode the supplied peer.
|
||||||
virtual bool performLocalHashSearch(const TurtleFileHash& hash,const SSLIdType& client_peer_id,RsTurtleClientService *& service);
|
virtual bool performLocalHashSearch(const TurtleFileHash& hash,const RsPeerId& client_peer_id,RsTurtleClientService *& service);
|
||||||
|
|
||||||
//--------------------------- Local variables --------------------------------//
|
//--------------------------- Local variables --------------------------------//
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue