Remove WS client
This commit is contained in:
parent
abda10d884
commit
6f2bc4584f
4 changed files with 61 additions and 10 deletions
|
|
@ -3,19 +3,19 @@
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
|
||||||
#include <boost/property_tree/ptree.hpp>
|
|
||||||
#include <boost/xpressive/xpressive.hpp>
|
|
||||||
|
|
||||||
#include <boost/asio/buffers_iterator.hpp>
|
#include <boost/asio/buffers_iterator.hpp>
|
||||||
#include <boost/asio/connect.hpp>
|
#include <boost/asio/connect.hpp>
|
||||||
#include <boost/asio/ssl/error.hpp>
|
#include <boost/asio/ssl/error.hpp>
|
||||||
#include <boost/asio/ssl/stream.hpp>
|
#include <boost/asio/ssl/stream.hpp>
|
||||||
#include <boost/beast/http.hpp>
|
#include <boost/beast/http.hpp>
|
||||||
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
|
#include <boost/property_tree/ptree.hpp>
|
||||||
|
#include <boost/xpressive/xpressive.hpp>
|
||||||
|
|
||||||
#include <fc/crypto/base64.hpp>
|
|
||||||
#include <fc/log/logger.hpp>
|
#include <fc/log/logger.hpp>
|
||||||
|
|
||||||
|
#include <graphene/peerplays_sidechain/common/utils.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace peerplays_sidechain {
|
namespace graphene { namespace peerplays_sidechain {
|
||||||
|
|
||||||
rpc_client::rpc_client(std::string _url, std::string _user, std::string _password, bool _debug_rpc_calls) :
|
rpc_client::rpc_client(std::string _url, std::string _user, std::string _password, bool _debug_rpc_calls) :
|
||||||
|
|
@ -52,7 +52,8 @@ rpc_client::rpc_client(std::string _url, std::string _user, std::string _passwor
|
||||||
target = "/";
|
target = "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
authorization = "Basic " + fc::base64_encode(user + ":" + password);
|
authorization = "Basic " + base64_encode(user + ":" + password);
|
||||||
|
|
||||||
results = resolver.resolve(host, port);
|
results = resolver.resolve(host, port);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,51 @@
|
||||||
#include <graphene/peerplays_sidechain/common/utils.hpp>
|
#include <graphene/peerplays_sidechain/common/utils.hpp>
|
||||||
|
|
||||||
|
#include <boost/archive/iterators/base64_from_binary.hpp>
|
||||||
|
#include <boost/archive/iterators/binary_from_base64.hpp>
|
||||||
|
//#include <boost/archive/iterators/ostream_iterator.hpp>
|
||||||
|
#include <boost/archive/iterators/transform_width.hpp>
|
||||||
|
|
||||||
|
namespace graphene { namespace peerplays_sidechain {
|
||||||
|
|
||||||
|
const std::string base64_padding[] = {"", "==", "="};
|
||||||
|
|
||||||
|
std::string base64_encode(const std::string &s) {
|
||||||
|
using namespace boost::archive::iterators;
|
||||||
|
|
||||||
|
typedef base64_from_binary<transform_width<const char *, 6, 8>> base64_enc;
|
||||||
|
|
||||||
|
std::stringstream os;
|
||||||
|
std::copy(base64_enc(s.c_str()), base64_enc(s.c_str() + s.size()), std::ostream_iterator<char>(os));
|
||||||
|
os << base64_padding[s.size() % 3];
|
||||||
|
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string base64_decode(const std::string &s) {
|
||||||
|
using namespace boost::archive::iterators;
|
||||||
|
|
||||||
|
typedef transform_width<binary_from_base64<const char *>, 8, 6> base64_dec;
|
||||||
|
|
||||||
|
std::stringstream os;
|
||||||
|
unsigned int size = s.size();
|
||||||
|
if (size && s[size - 1] == '=') {
|
||||||
|
--size;
|
||||||
|
if (size && s[size - 1] == '=')
|
||||||
|
--size;
|
||||||
|
}
|
||||||
|
if (size == 0)
|
||||||
|
return std::string();
|
||||||
|
|
||||||
|
std::copy(base64_dec(s.data()), base64_dec(s.data() + size), std::ostream_iterator<char>(os));
|
||||||
|
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
std::string object_id_to_string(graphene::chain::object_id_type id) {
|
std::string object_id_to_string(graphene::chain::object_id_type id) {
|
||||||
std::string object_id = fc::to_string(id.space()) + "." +
|
std::string object_id = fc::to_string(id.space()) + "." +
|
||||||
fc::to_string(id.type()) + "." +
|
fc::to_string(id.type()) + "." +
|
||||||
fc::to_string(id.instance());
|
fc::to_string(id.instance());
|
||||||
return object_id;
|
return object_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}} // namespace graphene::peerplays_sidechain
|
||||||
|
|
|
||||||
|
|
@ -23,16 +23,16 @@ protected:
|
||||||
std::string send_post_request(std::string method, std::string params, bool show_log);
|
std::string send_post_request(std::string method, std::string params, bool show_log);
|
||||||
|
|
||||||
std::string url;
|
std::string url;
|
||||||
|
std::string user;
|
||||||
|
std::string password;
|
||||||
|
bool debug_rpc_calls;
|
||||||
|
|
||||||
std::string protocol;
|
std::string protocol;
|
||||||
std::string host;
|
std::string host;
|
||||||
std::string port;
|
std::string port;
|
||||||
std::string target;
|
std::string target;
|
||||||
std::string authorization;
|
std::string authorization;
|
||||||
|
|
||||||
std::string user;
|
|
||||||
std::string password;
|
|
||||||
bool debug_rpc_calls;
|
|
||||||
|
|
||||||
uint32_t request_id;
|
uint32_t request_id;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,11 @@
|
||||||
|
|
||||||
#include <graphene/chain/protocol/asset.hpp>
|
#include <graphene/chain/protocol/asset.hpp>
|
||||||
|
|
||||||
|
namespace graphene { namespace peerplays_sidechain {
|
||||||
|
|
||||||
|
std::string base64_encode(const std::string &s);
|
||||||
|
std::string base64_decode(const std::string &s);
|
||||||
|
|
||||||
std::string object_id_to_string(graphene::chain::object_id_type id);
|
std::string object_id_to_string(graphene::chain::object_id_type id);
|
||||||
|
|
||||||
|
}} // namespace graphene::peerplays_sidechain
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue