diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index 64050a31f..db3cbca85 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -510,11 +510,55 @@ public: virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port) = 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; - virtual bool setExtAddress( const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0; - virtual bool setDynDNS(const RsPeerId &id, const std::string &addr) = 0; - virtual bool setNetworkMode(const RsPeerId &ssl_id, uint32_t netMode) = 0; + /** + * @brief Add URL locator for given peer + * @jsonapi{development} + * @param[in] sslId SSL id of the peer, own id is accepted too + * @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 getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status_flags) = 0; diff --git a/libretroshare/src/util/rsurl.cc b/libretroshare/src/util/rsurl.cc index 3775f8436..563f151cc 100644 --- a/libretroshare/src/util/rsurl.cc +++ b/libretroshare/src/util/rsurl.cc @@ -18,6 +18,7 @@ #include "rsurl.h" +#include "serialiser/rstypeserializer.h" #include #include @@ -254,6 +255,14 @@ RsUrl& RsUrl::setFragment(const std::string& fragment) 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::ipv6WrapOpen("["); /*static*/ const std::string RsUrl::ipv6Separator(":"); diff --git a/libretroshare/src/util/rsurl.h b/libretroshare/src/util/rsurl.h index 49215ffa4..b1975d574 100644 --- a/libretroshare/src/util/rsurl.h +++ b/libretroshare/src/util/rsurl.h @@ -20,6 +20,8 @@ #include #include +#include "serialiser/rsserializable.h" + /** * Very simplistic and minimal URL helper class for RetroShare, after looking * 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 * scheme://host[:port][/path][?query][#fragment] */ -struct RsUrl +struct RsUrl : RsSerializable { RsUrl(); RsUrl(const std::string& urlStr); @@ -78,6 +80,10 @@ struct RsUrl inline bool operator!=(const RsUrl& rhs) const { 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 ipv6WrapOpen; static const std::string ipv6Separator;