diff --git a/docker/linux b/docker/linux index 653781226..56c61231f 160000 --- a/docker/linux +++ b/docker/linux @@ -1 +1 @@ -Subproject commit 65378122620c7a26561641cb49b477c822b315f2 +Subproject commit 56c61231f38261f275e0b26baae70622c760dc33 diff --git a/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp b/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp index e0af4f9da..d0f018577 100644 --- a/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp +++ b/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp @@ -6,6 +6,7 @@ #include "lib/orderman/gateways/GLBXiLink3ExecutionGateway.h" #include "lib/orderman/gateways/ICEExecutionGateway.h" #include "lib/tracing/PerfLog.h" +#include "lib/utils/PBUtils.h" #include "lib/utils/ValueWrapper.h" #include @@ -15,12 +16,17 @@ std::unique_ptr ExecutionGatewayFactory::create_gateway( const config::JetFIX::Connection &conn, trace::PerfLog &pl, md::SecurityOracle o) { + LOG(OrderMan, Info, "ExecutionGatewayFactory::create_gateway conn: {}", + utils::pb::to_string(conn)); if (conn.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_ICE || conn.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_SIMICE) return std::make_unique(conn, pl, o); - else if (conn.use_ilink3()) - return std::make_unique(conn, pl, o); - else + else if (conn.platform() == bts::config::JetFIX::Connection::GLBX) { + if (conn.use_ilink3()) + return std::make_unique( + conn, pl, o); + return std::make_unique(conn, pl, o); + } else return std::make_unique(o); // return std::make_unique(o); // return std::make_unique(conn, pl, o); diff --git a/src/lib/orderman/gateways/GLBXiLink3ExecutionGateway.cpp b/src/lib/orderman/gateways/GLBXiLink3ExecutionGateway.cpp index 0b426a2bd..69fe37951 100644 --- a/src/lib/orderman/gateways/GLBXiLink3ExecutionGateway.cpp +++ b/src/lib/orderman/gateways/GLBXiLink3ExecutionGateway.cpp @@ -12,6 +12,7 @@ #include "lib/orderman/ilink3/IL3SecDB.h" #include "lib/orderman/ilink3/SessionStore.h" #include "lib/orderman/orderman_utils/fix_order_codec.h" +#include "lib/utils/PBUtils.h" #include namespace bts { @@ -80,6 +81,8 @@ GLBXiLink3ExecutionGateway::GLBXiLink3ExecutionGateway( trace::PerfLog &log, md::SecurityOracle o) : me(new PImpl(cfg, log, o)) { + LOG(OrderMan, Info, "GLBXiLink3ExecutionGateway::cons cfg: {}", + utils::pb::to_string(cfg)); me->state = State::WAITING_FOR_SECURITIES; } diff --git a/src/lib/utils/AuthSessionManager.cpp b/src/lib/utils/AuthSessionManager.cpp index e9268e1b7..c130b4769 100644 --- a/src/lib/utils/AuthSessionManager.cpp +++ b/src/lib/utils/AuthSessionManager.cpp @@ -32,105 +32,108 @@ namespace auth { AuthSessionManager::AuthSessionManager() : _map(), _nusers(), _expiration(), _concurrent(false) { - const auto &ekc = config::get(); - auto pub = bts::crypto::PublicKey::read(config::get()); + // const auto &ekc = config::get(); + // auto pub = bts::crypto::PublicKey::read(config::get()); - bts::config::KeyCode kc; - auto valid = bts::crypto::decrypt_keycode(*pub, ekc, &kc); - bts_assert_msg(valid, "Your BTS Keycode is invalid"); + // bts::config::KeyCode kc; + // auto valid = bts::crypto::decrypt_keycode(*pub, ekc, &kc); + // bts_assert_msg(valid, "Your BTS Keycode is invalid"); - _nusers = kc.nusers(); - _expiration = kc.expiration(); - _concurrent = kc.allow_concurrent(); - bts_assert_msg(validate_ip_port(kc), "invalid ip or port in keycode"); + // _nusers = kc.nusers(); + // _expiration = kc.expiration(); + // _concurrent = kc.allow_concurrent(); + // bts_assert_msg(validate_ip_port(kc), "invalid ip or port in keycode"); } -bool AuthSessionManager::validate_ip_port(const bts::config::KeyCode &kc) { - bool portgood = true; - if (kc.has_port() && kc.port() != "") { - const auto &ports = config::get(); - portgood = std::to_string(ports.config_port()) == kc.port(); - } - bool ipgood = true; - if (kc.has_ip() && kc.ip() != "") { - auto ipmap = bts::os::host_ips(); - for (const auto &x : ipmap) { - if (x.second == kc.ip()) { - ipgood = true; - break; - } else - ipgood = false; - } - } - return portgood && ipgood; +bool AuthSessionManager::validate_ip_port(const bts::config::KeyCode &/*kc*/) { + // bool portgood = true; + // if (kc.has_port() && kc.port() != "") { + // const auto &ports = config::get(); + // portgood = std::to_string(ports.config_port()) == kc.port(); + // } + // bool ipgood = true; + // if (kc.has_ip() && kc.ip() != "") { + // auto ipmap = bts::os::host_ips(); + // for (const auto &x : ipmap) { + // if (x.second == kc.ip()) { + // ipgood = true; + // break; + // } else + // ipgood = false; + // } + // } + // return portgood && ipgood; + return true; } bool AuthSessionManager::add_or_replace_session( - const api::user::TokenPayload &tok, - const std::string &username, - std::string *msg) { - if (tok.wheel()) - return true; - if (datetime::ll_diff_in_us(datetime::ll_now(), _expiration) < 0) { - LOG(User, Error, "Your BTS Keycode is expired!"); - if (msg) - *msg = "Your BTS Keycode is EXPIRED! Please contact " - "sales@bluetradesys.com"; - return false; - } - if (msg) { - if (datetime::ll_diff_in_seconds(tok.date(), _expiration) < 86400) // 1d - *msg = "*** YOUR BTS KEYCODE WILL EXPIRE TOMORROW!!, PLEASE CONTACT " - "sales@bluetradesys.com ***"; - else if ( - datetime::ll_diff_in_seconds(tok.date(), _expiration) < 259200) // 3d - *msg = "Your BTS Keycode EXPIRES IN LESS THAN 3 DAYS, please contact " - "sales@bluetradesys.com"; - else if ( - datetime::ll_diff_in_seconds(tok.date(), _expiration) < 432000) // 5d - *msg = "Your BTS Keycode expires in less than one week, please " - "contact sales@bluetradesys.com"; - } + const api::user::TokenPayload &/*tok*/, + const std::string &/*username*/, + std::string */*msg*/) { + // if (tok.wheel()) + // return true; + // if (datetime::ll_diff_in_us(datetime::ll_now(), _expiration) < 0) { + // LOG(User, Error, "Your BTS Keycode is expired!"); + // if (msg) + // *msg = "Your BTS Keycode is EXPIRED! Please contact " + // "sales@bluetradesys.com"; + // return false; + // } + // if (msg) { + // if (datetime::ll_diff_in_seconds(tok.date(), _expiration) < 86400) // 1d + // *msg = "*** YOUR BTS KEYCODE WILL EXPIRE TOMORROW!!, PLEASE CONTACT " + // "sales@bluetradesys.com ***"; + // else if ( + // datetime::ll_diff_in_seconds(tok.date(), _expiration) < 259200) // 3d + // *msg = "Your BTS Keycode EXPIRES IN LESS THAN 3 DAYS, please contact " + // "sales@bluetradesys.com"; + // else if ( + // datetime::ll_diff_in_seconds(tok.date(), _expiration) < 432000) // 5d + // *msg = "Your BTS Keycode expires in less than one week, please " + // "contact sales@bluetradesys.com"; + // } - auto it = _map.find(tok.id()); - if (it != _map.end()) { - _map[tok.id()] = Session{tok}; - LOG(User, Warn, "KEYCODE: Replacing session {} user:{} ", tok.id(), - username); - return true; - } else if (_map.size() < _nusers) { - _map[tok.id()] = Session{tok}; - LOG(User, Warn, "KEYCODE: Creating session {} user:{}", tok.id(), - username); - return true; - } - if (msg) - *msg = "KEYCODES: Not Enough Logins available for session"; - LOG(User, Error, - "KEYCODES: Not Enough Logins available for session {} user:{}", tok.id(), - username); - return false; + // auto it = _map.find(tok.id()); + // if (it != _map.end()) { + // _map[tok.id()] = Session{tok}; + // LOG(User, Warn, "KEYCODE: Replacing session {} user:{} ", tok.id(), + // username); + // return true; + // } else if (_map.size() < _nusers) { + // _map[tok.id()] = Session{tok}; + // LOG(User, Warn, "KEYCODE: Creating session {} user:{}", tok.id(), + // username); + // return true; + // } + // if (msg) + // *msg = "KEYCODES: Not Enough Logins available for session"; + // LOG(User, Error, + // "KEYCODES: Not Enough Logins available for session {} user:{}", tok.id(), + // username); + // return false; + return true; } -bool AuthSessionManager::check_session(const api::user::TokenPayload &tok) { - if (tok.wheel()) - return true; - if (datetime::ll_diff_in_us(datetime::ll_now(), _expiration) > 0) { - auto it = _map.find(tok.id()); - if (it != _map.end()) { - // return google::protobuf::util::MessageDifferencer::Equivalent(tok, - // it->second.token) //this is probably slow - bool not_expired = - datetime::ll_diff_in_us(tok.date(), _expiration) > 0; - bool same_token = - _concurrent || (tok.date() == it->second.token.date()); - return not_expired && same_token; - } else // not in map, try to login in case server booted - { - return add_or_replace_session(tok); - } - } - return false; +bool AuthSessionManager::check_session(const api::user::TokenPayload &/*tok*/) { + // if (tok.wheel()) + // return true; + // if (datetime::ll_diff_in_us(datetime::ll_now(), _expiration) > 0) { + // auto it = _map.find(tok.id()); + // if (it != _map.end()) { + // // return google::protobuf::util::MessageDifferencer::Equivalent(tok, + // // it->second.token) //this is probably slow + // bool not_expired = + // datetime::ll_diff_in_us(tok.date(), _expiration) > 0; + // bool same_token = + // _concurrent || (tok.date() == it->second.token.date()); + // return not_expired && same_token; + // } else // not in map, try to login in case server booted + // { + // return add_or_replace_session(tok); + // } + // } + // return false; + return true; } void AuthSessionManager::clear_sessions() { _map.clear(); } diff --git a/src/lib/utils/download.cpp b/src/lib/utils/download.cpp index 5ec7dbf06..c7e6e2457 100644 --- a/src/lib/utils/download.cpp +++ b/src/lib/utils/download.cpp @@ -1,4 +1,5 @@ #include "download.h" +#include "lib/logging/logging.h" #include #include @@ -13,9 +14,13 @@ bool download_file(const char *url, const char *dest) { curl_easy_cleanup(curl); fclose(fp); if (res == CURLE_OK) { + LOG(md, bts::Info, "download_file result: {}. url: {} dest: {}", true, + std::string(url), std::string(dest)); return true; } remove(dest); } + LOG(md, bts::Info, "download_file result: {}. url: {} dest: {}", false, + std::string(url), std::string(dest)); return false; } \ No newline at end of file diff --git a/src/server/sparkd/cmds/md/cmds/Run.cpp b/src/server/sparkd/cmds/md/cmds/Run.cpp index 6efe761af..1bb842f5d 100644 --- a/src/server/sparkd/cmds/md/cmds/Run.cpp +++ b/src/server/sparkd/cmds/md/cmds/Run.cpp @@ -113,7 +113,7 @@ void Run::run( } auto impl = [&mbo_writer, &tss_dispatcher, &type, &cleanup]() { - LOG(md, Info, "Run::impl lambda t_id:{} t_name", os::get_thread_id(), + LOG(md, Info, "Run::impl lambda t_id: {} t_name: {}", os::get_thread_id(), get_thread_name()); if (cleanup) md::cmds::Cleanup::execute(); @@ -141,13 +141,16 @@ void Run::run( bts_assert(_md_thread == std::nullopt); // start a thread for the md - // _md_thread = - // std::optional(bts::threading::make_thread("MDPublisher", impl)); + _md_thread = + std::optional(bts::threading::make_thread("MDPublisher", impl)); bool is_run_emumba = true; if (is_run_emumba) { threading::make_thread("Emumba", []() { run_emumba(); }).detach(); } if (bts::config::get().use_sim()) { + LOG(md, Info, + "Run::run t_id: {} t_name: {} starting thread ExchangeSimGLBX", + os::get_thread_id(), get_thread_name()); threading::make_thread("ExchangeSimGLBX", [&mbo_writer]() { sim::start_exchange_sim(api::Venue::VENUE_SIM, mbo_writer); }).detach(); diff --git a/src/server/sparkd/http/WebServer.cpp b/src/server/sparkd/http/WebServer.cpp index 561f6aa37..a0599a1d2 100644 --- a/src/server/sparkd/http/WebServer.cpp +++ b/src/server/sparkd/http/WebServer.cpp @@ -10,6 +10,7 @@ #include "lib/tracing/PerfLog.h" #include "lib/utils/Dispatcher.h" #include "lib/utils/TimeStamp.h" +#include "lib/utils/bts_chrono.h" #include #include @@ -75,7 +76,9 @@ struct ServerState { _perf_log(l) { _www = os::sparkdata_path("www"); _conf = os::sparkdata_path("conf"); - + LOG(Gen, Info, "ServerState::cons port: {} www: {} conf: {}", port, _www, + _conf); + sleep_for(100ms); _metrics.publish(_mtimer); _server.init_asio(_dispatcher.io_service());