mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 14:12:43 -04:00
commit
be1f2f7a30
6 changed files with 93 additions and 14 deletions
|
@ -449,7 +449,7 @@ void RsControlModule::handleImportPgp(Request &req, Response &resp)
|
||||||
|
|
||||||
RsPgpId pgp_id;
|
RsPgpId pgp_id;
|
||||||
std::string error_string;
|
std::string error_string;
|
||||||
if(RsAccounts::ImportIdentityFromString(key_string, pgp_id, error_string))
|
if(RsAccounts::importIdentityFromString(key_string, pgp_id, error_string))
|
||||||
{
|
{
|
||||||
resp.mDataStream << makeKeyValueReference("pgp_id", pgp_id);
|
resp.mDataStream << makeKeyValueReference("pgp_id", pgp_id);
|
||||||
resp.setOk();
|
resp.setOk();
|
||||||
|
|
|
@ -151,7 +151,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Get current account id. Beware that an account may be selected
|
* @brief Get current account id. Beware that an account may be selected
|
||||||
* without actually logging in.
|
* without actually logging in.
|
||||||
* @jsonapi{development}
|
* @jsonapi{development,unauthenticated}
|
||||||
* @param[out] id storage for current account id
|
* @param[out] id storage for current account id
|
||||||
* @return false if account hasn't been selected yet, true otherwise
|
* @return false if account hasn't been selected yet, true otherwise
|
||||||
*/
|
*/
|
||||||
|
@ -176,9 +176,26 @@ public:
|
||||||
static int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
|
static int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
|
||||||
static bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
|
static bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
|
||||||
|
|
||||||
// PGP Support Functions.
|
/**
|
||||||
static bool ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
|
* @brief Export full encrypted PGP identity to file
|
||||||
static bool ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
* @jsonapi{development}
|
||||||
|
* @param[in] filePath path of certificate file
|
||||||
|
* @param[in] pgpId PGP id to export
|
||||||
|
* @return true on success, false otherwise
|
||||||
|
*/
|
||||||
|
static bool ExportIdentity( const std::string& filePath,
|
||||||
|
const RsPgpId& pgpId );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Import full encrypted PGP identity from file
|
||||||
|
* @jsonapi{development,unauthenticated}
|
||||||
|
* @param[in] filePath path of certificate file
|
||||||
|
* @param[out] pgpId storage for the PGP fingerprint of the imported key
|
||||||
|
* @param[out] errorMsg storage for eventual human readable error message
|
||||||
|
* @return true on success, false otherwise
|
||||||
|
*/
|
||||||
|
static bool ImportIdentity(
|
||||||
|
const std::string& filePath, RsPgpId& pgpId, std::string& errorMsg );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Import full encrypted PGP identity from string
|
* @brief Import full encrypted PGP identity from string
|
||||||
|
@ -188,7 +205,7 @@ public:
|
||||||
* @param[out] errorMsg storage for eventual human readable error message
|
* @param[out] errorMsg storage for eventual human readable error message
|
||||||
* @return true on success, false otherwise
|
* @return true on success, false otherwise
|
||||||
*/
|
*/
|
||||||
static bool ImportIdentityFromString(
|
static bool importIdentityFromString(
|
||||||
const std::string& data, RsPgpId& pgpId,
|
const std::string& data, RsPgpId& pgpId,
|
||||||
std::string& errorMsg );
|
std::string& errorMsg );
|
||||||
|
|
||||||
|
|
|
@ -510,11 +510,55 @@ public:
|
||||||
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port) = 0;
|
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port) = 0;
|
||||||
virtual bool isHiddenNode(const RsPeerId &id) = 0;
|
virtual bool isHiddenNode(const RsPeerId &id) = 0;
|
||||||
|
|
||||||
virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator) = 0;
|
/**
|
||||||
virtual bool setLocalAddress(const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
|
* @brief Add URL locator for given peer
|
||||||
virtual bool setExtAddress( const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
|
* @jsonapi{development}
|
||||||
virtual bool setDynDNS(const RsPeerId &id, const std::string &addr) = 0;
|
* @param[in] sslId SSL id of the peer, own id is accepted too
|
||||||
virtual bool setNetworkMode(const RsPeerId &ssl_id, uint32_t netMode) = 0;
|
* @param[in] locator peer url locator
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool addPeerLocator(const RsPeerId& sslId, const RsUrl& locator) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set local IPv4 address for the given peer
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] sslId SSL id of the peer, own id is accepted too
|
||||||
|
* @param[in] addr string representation of the local IPv4 address
|
||||||
|
* @param[in] port local listening port
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool setLocalAddress(
|
||||||
|
const RsPeerId& sslId, const std::string& addr, uint16_t port ) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set external IPv4 address for given peer
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] sslId SSL id of the peer, own id is accepted too
|
||||||
|
* @param[in] addr string representation of the external IPv4 address
|
||||||
|
* @param[in] port external listening port
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool setExtAddress(
|
||||||
|
const RsPeerId& sslId, const std::string &addr, uint16_t port ) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set (dynamical) domain name associated to the given peer
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] sslId SSL id of the peer, own id is accepted too
|
||||||
|
* @param[in] addr domain name string representation
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool setDynDNS(const RsPeerId& sslId, const std::string& addr) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set network mode of the given peer
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] sslId SSL id of the peer, own id is accepted too
|
||||||
|
* @param[in] netMode one of RS_NETMODE_*
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool setNetworkMode(const RsPeerId &sslId, uint32_t netMode) = 0;
|
||||||
|
|
||||||
virtual bool setVisState(const RsPeerId &ssl_id, uint16_t vs_disc, uint16_t vs_dht) = 0;
|
virtual bool setVisState(const RsPeerId &ssl_id, uint16_t vs_disc, uint16_t vs_dht) = 0;
|
||||||
|
|
||||||
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status_flags) = 0;
|
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status_flags) = 0;
|
||||||
|
|
|
@ -1347,9 +1347,12 @@ bool RsAccounts::ImportIdentity(const std::string& fname,RsPgpId& imported_pg
|
||||||
return rsAccountsDetails->importIdentity(fname,imported_pgp_id,import_error);
|
return rsAccountsDetails->importIdentity(fname,imported_pgp_id,import_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccounts::ImportIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error)
|
bool RsAccounts::importIdentityFromString(
|
||||||
|
const std::string& data, RsPgpId& imported_pgp_id,
|
||||||
|
std::string& import_error )
|
||||||
{
|
{
|
||||||
return rsAccountsDetails->importIdentityFromString(data,imported_pgp_id,import_error);
|
return rsAccountsDetails->
|
||||||
|
importIdentityFromString(data, imported_pgp_id, import_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ bool RsAccounts::exportIdentityToString(
|
/*static*/ bool RsAccounts::exportIdentityToString(
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "rsurl.h"
|
#include "rsurl.h"
|
||||||
|
#include "serialiser/rstypeserializer.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -254,6 +255,14 @@ RsUrl& RsUrl::setFragment(const std::string& fragment)
|
||||||
return decoded.str();
|
return decoded.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsUrl::serial_process( RsGenericSerializer::SerializeJob j,
|
||||||
|
RsGenericSerializer::SerializeContext& ctx )
|
||||||
|
{
|
||||||
|
std::string urlString = toString();
|
||||||
|
RS_SERIAL_PROCESS(urlString);
|
||||||
|
fromString(urlString);
|
||||||
|
}
|
||||||
|
|
||||||
/*static*/ const std::string RsUrl::schemeSeparator("://");
|
/*static*/ const std::string RsUrl::schemeSeparator("://");
|
||||||
/*static*/ const std::string RsUrl::ipv6WrapOpen("[");
|
/*static*/ const std::string RsUrl::ipv6WrapOpen("[");
|
||||||
/*static*/ const std::string RsUrl::ipv6Separator(":");
|
/*static*/ const std::string RsUrl::ipv6Separator(":");
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include "serialiser/rsserializable.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Very simplistic and minimal URL helper class for RetroShare, after looking
|
* Very simplistic and minimal URL helper class for RetroShare, after looking
|
||||||
* for a small and self-contained C/C++ URL parsing and manipulation library,
|
* for a small and self-contained C/C++ URL parsing and manipulation library,
|
||||||
|
@ -31,7 +33,7 @@
|
||||||
* Anyway this should support most common URLs of the form
|
* Anyway this should support most common URLs of the form
|
||||||
* scheme://host[:port][/path][?query][#fragment]
|
* scheme://host[:port][/path][?query][#fragment]
|
||||||
*/
|
*/
|
||||||
struct RsUrl
|
struct RsUrl : RsSerializable
|
||||||
{
|
{
|
||||||
RsUrl();
|
RsUrl();
|
||||||
RsUrl(const std::string& urlStr);
|
RsUrl(const std::string& urlStr);
|
||||||
|
@ -78,6 +80,10 @@ struct RsUrl
|
||||||
inline bool operator!=(const RsUrl& rhs) const
|
inline bool operator!=(const RsUrl& rhs) const
|
||||||
{ return toString() != rhs.toString(); }
|
{ return toString() != rhs.toString(); }
|
||||||
|
|
||||||
|
/// @see RsSerializable
|
||||||
|
virtual void serial_process(RsGenericSerializer::SerializeJob j,
|
||||||
|
RsGenericSerializer::SerializeContext& ctx);
|
||||||
|
|
||||||
static const std::string schemeSeparator;
|
static const std::string schemeSeparator;
|
||||||
static const std::string ipv6WrapOpen;
|
static const std::string ipv6WrapOpen;
|
||||||
static const std::string ipv6Separator;
|
static const std::string ipv6Separator;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue