Fix #1772 by decprecating cli_wallet -H

This commit is contained in:
Peter Conrad 2019-05-28 21:32:33 +02:00 committed by Nathan Hourt
parent 1c0de74aa7
commit a31e56f531
No known key found for this signature in database
GPG key ID: B4344309A110851E

View file

@ -29,10 +29,8 @@
#include <fc/io/json.hpp> #include <fc/io/json.hpp>
#include <fc/io/stdio.hpp> #include <fc/io/stdio.hpp>
#include <fc/network/http/server.hpp>
#include <fc/network/http/websocket.hpp> #include <fc/network/http/websocket.hpp>
#include <fc/rpc/cli.hpp> #include <fc/rpc/cli.hpp>
#include <fc/rpc/http_api.hpp>
#include <fc/rpc/websocket_api.hpp> #include <fc/rpc/websocket_api.hpp>
#include <graphene/app/api.hpp> #include <graphene/app/api.hpp>
@ -80,7 +78,8 @@ int main( int argc, char** argv )
("rpc-endpoint,r", bpo::value<string>()->implicit_value("127.0.0.1:8091"), "Endpoint for wallet websocket RPC to listen on") ("rpc-endpoint,r", bpo::value<string>()->implicit_value("127.0.0.1:8091"), "Endpoint for wallet websocket RPC to listen on")
("rpc-tls-endpoint,t", bpo::value<string>()->implicit_value("127.0.0.1:8092"), "Endpoint for wallet websocket TLS RPC to listen on") ("rpc-tls-endpoint,t", bpo::value<string>()->implicit_value("127.0.0.1:8092"), "Endpoint for wallet websocket TLS RPC to listen on")
("rpc-tls-certificate,c", bpo::value<string>()->implicit_value("server.pem"), "PEM certificate for wallet websocket TLS RPC") ("rpc-tls-certificate,c", bpo::value<string>()->implicit_value("server.pem"), "PEM certificate for wallet websocket TLS RPC")
("rpc-http-endpoint,H", bpo::value<string>()->implicit_value("127.0.0.1:8093"), "Endpoint for wallet HTTP RPC to listen on") ("rpc-http-endpoint,H", bpo::value<string>()->implicit_value("127.0.0.1:8093"),
"Endpoint for wallet HTTP RPC to listen on (DEPRECATED, use rpc-endpoint instead)")
("daemon,d", "Run the wallet in daemon mode" ) ("daemon,d", "Run the wallet in daemon mode" )
("wallet-file,w", bpo::value<string>()->implicit_value("wallet.json"), "wallet to load") ("wallet-file,w", bpo::value<string>()->implicit_value("wallet.json"), "wallet to load")
("chain-id", bpo::value<string>(), "chain ID to connect to"); ("chain-id", bpo::value<string>(), "chain ID to connect to");
@ -175,7 +174,7 @@ int main( int argc, char** argv )
fc::http::websocket_client client; fc::http::websocket_client client;
idump((wdata.ws_server)); idump((wdata.ws_server));
auto con = client.connect( wdata.ws_server ); auto con = client.connect( wdata.ws_server );
auto apic = std::make_shared<fc::rpc::websocket_api_connection>(*con, GRAPHENE_MAX_NESTED_OBJECTS); auto apic = std::make_shared<fc::rpc::websocket_api_connection>(con, GRAPHENE_MAX_NESTED_OBJECTS);
auto remote_api = apic->get_remote_api< login_api >(1); auto remote_api = apic->get_remote_api< login_api >(1);
edump((wdata.ws_user)(wdata.ws_password) ); edump((wdata.ws_user)(wdata.ws_password) );
@ -214,11 +213,11 @@ int main( int argc, char** argv )
_websocket_server->on_connection([&wapi]( const fc::http::websocket_connection_ptr& c ){ _websocket_server->on_connection([&wapi]( const fc::http::websocket_connection_ptr& c ){
std::cout << "here... \n"; std::cout << "here... \n";
wlog("." ); wlog("." );
auto wsc = std::make_shared<fc::rpc::websocket_api_connection>(*c, GRAPHENE_MAX_NESTED_OBJECTS); auto wsc = std::make_shared<fc::rpc::websocket_api_connection>(c, GRAPHENE_MAX_NESTED_OBJECTS);
wsc->register_api(wapi); wsc->register_api(wapi);
c->set_session_data( wsc ); c->set_session_data( wsc );
}); });
ilog( "Listening for incoming RPC requests on ${p}", ("p", options.at("rpc-endpoint").as<string>() )); ilog( "Listening for incoming HTTP and WS RPC requests on ${p}", ("p", options.at("rpc-endpoint").as<string>() ));
_websocket_server->listen( fc::ip::endpoint::from_string(options.at("rpc-endpoint").as<string>()) ); _websocket_server->listen( fc::ip::endpoint::from_string(options.at("rpc-endpoint").as<string>()) );
_websocket_server->start_accept(); _websocket_server->start_accept();
} }
@ -227,35 +226,32 @@ int main( int argc, char** argv )
if( options.count( "rpc-tls-certificate" ) ) if( options.count( "rpc-tls-certificate" ) )
cert_pem = options.at("rpc-tls-certificate").as<string>(); cert_pem = options.at("rpc-tls-certificate").as<string>();
auto _websocket_tls_server = std::make_shared<fc::http::websocket_tls_server>(cert_pem); auto _websocket_tls_server = std::make_shared<fc::http::websocket_tls_server>(cert_pem, "");
if( options.count("rpc-tls-endpoint") ) if( options.count("rpc-tls-endpoint") )
{ {
_websocket_tls_server->on_connection([&]( const fc::http::websocket_connection_ptr& c ){ _websocket_tls_server->on_connection([&]( const fc::http::websocket_connection_ptr& c ){
auto wsc = std::make_shared<fc::rpc::websocket_api_connection>(*c, GRAPHENE_MAX_NESTED_OBJECTS); auto wsc = std::make_shared<fc::rpc::websocket_api_connection>(c, GRAPHENE_MAX_NESTED_OBJECTS);
wsc->register_api(wapi); wsc->register_api(wapi);
c->set_session_data( wsc ); c->set_session_data( wsc );
}); });
ilog( "Listening for incoming TLS RPC requests on ${p}", ("p", options.at("rpc-tls-endpoint").as<string>() )); ilog( "Listening for incoming HTTPS and WSS RPC requests on ${p}",
("p", options.at("rpc-tls-endpoint").as<string>()) );
_websocket_tls_server->listen( fc::ip::endpoint::from_string(options.at("rpc-tls-endpoint").as<string>()) ); _websocket_tls_server->listen( fc::ip::endpoint::from_string(options.at("rpc-tls-endpoint").as<string>()) );
_websocket_tls_server->start_accept(); _websocket_tls_server->start_accept();
} }
auto _http_server = std::make_shared<fc::http::server>(); auto _http_ws_server = std::make_shared<fc::http::websocket_server>();
if( options.count("rpc-http-endpoint" ) ) if( options.count("rpc-http-endpoint" ) )
{ {
ilog( "Listening for incoming HTTP RPC requests on ${p}", ("p", options.at("rpc-http-endpoint").as<string>() ) ); ilog( "Listening for incoming HTTP and WS RPC requests on ${p}",
_http_server->listen( fc::ip::endpoint::from_string( options.at( "rpc-http-endpoint" ).as<string>() ) ); ("p", options.at("rpc-http-endpoint").as<string>()) );
// _http_ws_server->on_connection([&wapi]( const fc::http::websocket_connection_ptr& c ){
// due to implementation, on_request() must come AFTER listen() auto wsc = std::make_shared<fc::rpc::websocket_api_connection>(c, GRAPHENE_MAX_NESTED_OBJECTS);
// wsc->register_api(wapi);
_http_server->on_request( c->set_session_data( wsc );
[&wapi]( const fc::http::request& req, const fc::http::server::response& resp ) });
{ _http_ws_server->listen( fc::ip::endpoint::from_string(options.at("rpc-http-endpoint").as<string>()) );
std::shared_ptr< fc::rpc::http_api_connection > conn = _http_ws_server->start_accept();
std::make_shared< fc::rpc::http_api_connection >( GRAPHENE_MAX_NESTED_OBJECTS );
conn->register_api( wapi );
conn->on_request( req, resp );
} );
} }
if( !options.count( "daemon" ) ) if( !options.count( "daemon" ) )