int main(int argc, char *argv[]) { auto desc = create_descriptions(); auto vm = parse_options(argc, argv, desc); if(vm.count("help")) { std::cout << desc << std::endl; return 1; } Botan::LibraryInitializer init; QApplication a{argc, argv}; fg::main_window_context c; c.home = vm["home"].as<std::string>(); c.host = vm["host"].as<std::string>(); c.port = vm["port"].as<std::string>(); c.debug = vm.count("debug"); CREATE_LOG(c.home); c.user = fg::setup_user(c.home); if(!c.user) return 0; fg::main_window w{c}; w.show(); return a.exec(); }
int main(int argc, char *argv[]) { auto desc = create_descriptions(); auto vm = parse_options(argc, argv, desc); if(vm.count("help")) { std::cout << desc << std::endl; return 1; } QApplication a{argc, argv}; fg::main_window_context c; c.home = vm["home"].as<std::string>(); c.host = vm["host"].as<std::string>(); c.port = vm["port"].as<std::string>(); if(!user_setup(c.home)) return 0; fg::main_window w{c}; w.show(); return a.exec(); }
int main(int argc, char *argv[]) try { auto desc = create_descriptions(); auto vm = parse_options(argc, argv, desc); if(vm.count("help")) { std::cout << desc << std::endl; return 1; } fu::setup_env(); fu::set_assert_dialog_callback(assert_dialog); QApplication a{argc, argv}; fg::main_window_context c; c.home = vm["home"].as<std::string>(); c.host = vm["host"].as<std::string>(); c.port = get_port(c.home, vm["port"].as<int>()); c.debug = vm.count("debug"); CREATE_LOG(c.home); fg::setup_gui(); c.user = fg::setup_user(c.home); if(!c.user) return 0; fg::main_window w{c}; w.show(); auto rc = a.exec(); LOG << "firestr shutting down..." << std::endl; return rc; } catch(std::exception& e) { LOG << "program quit prematurely: " << e.what() << std::endl; return 1; } catch(...) { LOG << "program quit prematurely: unknown reason" << std::endl; return 1; }
int main(int argc, char *argv[]) { auto desc = create_descriptions(); auto vm = parse_options(argc, argv, desc); if(vm.count("help")) { std::cout << desc << std::endl; return 1; } Botan::LibraryInitializer init; auto iterations = vm["messages"].as<int>(); auto total_iterations = iterations; auto robust = vm["robust"].as<bool>(); size_t bytes_per_message = vm["size"].as<int>(); n::connection_manager src{POOL_SIZE, static_cast<n::port_type>(SRC_PORT)}; n::connection_manager dst{POOL_SIZE, static_cast<n::port_type>(DST_PORT)}; auto data = u::to_bytes(std::string(bytes_per_message, 'm')); u::bytes got_data; n::endpoint ep; auto start = std::chrono::high_resolution_clock::now(); while(iterations) try { src.send(DST_ADDR, data, robust); while(!dst.receive(ep, got_data)); //spin until we get something CHECK(got_data == data); iterations--; } catch(std::exception& e) { LOG << "error getting message: " << e.what() << std::endl; } catch(...) { LOG << "unknown error getting message: " << std::endl; } auto end = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count(); auto sec = duration / 1000000000.0; auto total_bytes_sent = total_iterations * data.size(); auto time_per_byte = duration / total_bytes_sent; auto kb_per_sec = (total_bytes_sent/1024) / sec; auto time_per_message = (duration / total_iterations) / 1000000.0; std::cout << "messages: " << total_iterations << " time: " << sec << "s" << std::endl; std::cout << "bytes per message: " << bytes_per_message << std::endl; std::cout << "sent bytes: " << total_bytes_sent<< std::endl; std::cout << "kb per sec: " << kb_per_sec << std::endl; std::cout << "time/byte: " << time_per_byte << "ns" << std::endl; std::cout << "time/message: " << time_per_message << "ms" << std::endl; }
int main(int argc, char *argv[]) { CREATE_LOG("./"); auto desc = create_descriptions(); auto vm = parse_options(argc, argv, desc); if(vm.count("help")) { std::cout << desc << std::endl; return 1; } Botan::LibraryInitializer init; auto host = vm["host"].as<std::string>(); auto port = vm["port"].as<int>(); auto pass = vm.count("pass") ? vm["pass"].as<std::string>() : prompt_pass(); auto key = vm["key"].as<std::string>(); auto pkey = load_private_key(key, pass); CHECK(pkey); n::connection_manager con{POOL_SIZE, static_cast<n::port_type>(port)}; sc::encrypted_channels sec{*pkey}; user_info_map users; u::bytes data; while(true) try { n::endpoint ep; if(!con.receive(ep, data)) { u::sleep_thread(THREAD_SLEEP); continue; } //decrypt message auto sid = n::make_address_str(ep); sc::encryption_type et; data = sec.decrypt(sid, data, et); data = u::uncompress(data); //parse message m::message m; u::decode(data, m); if(m.meta.type == ms::GREET_REGISTER) { if(et != sc::encryption_type::asymmetric) continue; ms::greet_register r{m}; register_user(con, sec, ep, r, users); } else if(m.meta.type == ms::GREET_FIND_REQUEST) { if(et != sc::encryption_type::asymmetric) continue; ms::greet_find_request r{m}; find_user(con, sec, ep, r, users); } else if(m.meta.type == ms::GREET_KEY_REQUEST) { ms::greet_key_request r{m}; send_pub_key(con, sec, ep, r, users, *pkey); } } catch(std::exception& e) { LOG << "error parsing message: " << e.what() << std::endl; } catch(...) { LOG << "unknown error parsing message: " << std::endl; } }
int main(int argc, char *argv[]) { CREATE_LOG("./"); auto desc = create_descriptions(); auto vm = parse_options(argc, argv, desc); if(vm.count("help")) { std::cout << desc << std::endl; return 1; } Botan::LibraryInitializer init; auto host = vm["host"].as<std::string>(); auto port = vm["port"].as<std::string>(); auto pass = vm.count("pass") ? vm["pass"].as<std::string>() : prompt_pass(); auto key = vm["key"].as<std::string>(); auto pkey = load_private_key(key, pass); CHECK(pkey); //it is important the tcp_connection manager is created before //the input tcp_connection is made. This is because tcp on //linux requires that binds to the same port are made before //a listen is made. n::connection_manager con{POOL_SIZE, port}; sc::session_library sec{*pkey}; user_info_map users; u::bytes data; while(true) try { n::endpoint ep; if(!con.receive(ep, data)) { u::sleep_thread(THREAD_SLEEP); continue; } //decrypt message auto sid = n::make_address_str(ep); data = sec.decrypt(sid, data); //parse message m::message m; u::decode(data, m); if(m.meta.type == ms::GREET_REGISTER) { ms::greet_register r{m}; register_user(con, sec, ep, r, users); } else if(m.meta.type == ms::GREET_FIND_REQUEST) { ms::greet_find_request r{m}; find_user(con, sec, ep, r, users); } else if(m.meta.type == ms::GREET_KEY_REQUEST) { ms::greet_key_request r{m}; send_pub_key(con, sec, ep, r, users, *pkey); } } catch(std::exception& e) { LOG << "error parsing message: " << e.what() << std::endl; LOG << "message: " << u::to_str(data) << std::endl; } catch(...) { LOG << "unknown error parsing message: " << std::endl; LOG << "message: " << u::to_str(data) << std::endl; } }