int main(int argc, char *argv[] ) { char line[100]; const char *file = argv[1]; const char *output_file = argv[2]; int num_ips = count_ips(file); char ip_array[num_ips][sizeof line]; FILE *fp = fopen(file,"r"); int i; for (i = 0; i < num_ips; i++) { fgets(line, sizeof line, fp); strcpy(ip_array[i], line); } fclose(fp); hostname_to_ip("www.msn.com", host_to_ip); for (i = 0; i < num_ips; i++) { test_proxy(ip_array[i], output_file, atoi(argv[3])); } return 0; }
void execute_line(char *cmdbuf) { int argc; char *argv[MAXARGS]; argc = parse(cmdbuf, argv); if (argc == 0) return; if (!strcmp(argv[0], "noop")) test_noop(); else if (!strcmp(argv[0], "connect") || !strcmp(argv[0], "c")) test_connect(argc, argv); else if (!strcmp(argv[0], "disconnect") || !strcmp(argv[0], "d")) test_disconnect(); else if (!strcmp(argv[0], "host")) test_host(); else if (!strcmp(argv[0], "motd") || !strcmp(argv[0], "m")) test_motd(); else if (!strcmp(argv[0], "query") || !strcmp(argv[0], "qy")) test_query(argc, argv); else if (!strcmp(argv[0], "auth") || !strcmp(argv[0], "a")) test_krb5_auth(); else if (!strcmp(argv[0], "proxy") || !strcmp(argv[0], "p")) test_proxy(argc, argv); else if (!strcmp(argv[0], "access")) test_access(argc, argv); else if (!strcmp(argv[0], "dcm")) test_dcm(); else if (!strcmp(argv[0], "script") || !strcmp(argv[0], "s")) test_script(argc, argv); else if (!strcmp(argv[0], "list_requests") || !strcmp(argv[0], "lr") || !strcmp(argv[0], "?")) test_list_requests(); else if (!strcmp(argv[0], "quit") || !strcmp(argv[0], "Q")) quit = 1; else if (!strcmp(argv[0], "version") || !strcmp(argv[0], "v")) test_version(argc, argv); else if (!strcmp(argv[0], "krb4_auth") || !strcmp(argv[0], "4")) test_auth(); else { fprintf(stderr, "moira: Unknown request \"%s\". " "Type \"?\" for a request list.\n", argv[0]); } }
void testEcho(Instance*& instance) { checkInstance(instance); const sg::Properties& prop = sg::Service::instance()->getProperties(); if (!instance->connection().get()) { auto_ptr<base::net::FilterCreatorStrategyBase> ssl_filter; #ifndef NO_SSL if (prop.getWithDef<int>("echo_server.use_ssl", 0)) { ssl_filter.reset( new base::net::SSLFilterCreatorStrategy( prop.getWithDef<string>("echo_server.pem_file", ""), prop.getWithDef<string>("echo_server.pem_password", ""), base::net::SSLFilter::AllowInvalidCertificates)); } #endif sg::ChannelFactoryT<sg::ConnectionHandler, base::net::OPT_NODELAY> sslfactory(instance->stubs(), ssl_filter); instance->connection() = sslfactory.createHandler(base::net::SockAddr( prop.get<string>("echo_server.address"))); } sg::Proxy test_proxy(instance->connection()); //sg::Targets target; //target.add("im"); //test_proxy.target(target); // echo /* modules::module_test_methods::rpc::EchoRequest echo_req; echo_req.mutable_data()->resize(120, 't'); modules::module_test_methods::rpc::EchoResponse echo_resp; test_proxy.call<modules::module_test_methods::rpc::Echo>(echo_req, &echo_resp); LOG(debug, echo_resp.data()); */ vector<boost::shared_ptr<sg::SyncRequest> > requests; for (int i=0; i<request_count_eachtime; ++i) { modules::module_test_methods::rpc::EchoRequest echo_req; echo_req.mutable_data()->resize(120, 't'); sg::Body body; boost::shared_ptr<sg::SyncRequest> sp_request = instance->connection()->createSyncRequest(body.data().targets()); requests.push_back(sp_request); body.addRequest<modules::module_test_methods::rpc::Echo>(sp_request->getSeq(), 60000, echo_req); instance->connection()->sendMessageBody(sg::rpc::OP_REQUEST, body.data()); } sg::RequestResults result; for (int i=0; i<request_count_eachtime; ++i) { requests[i]->waitResult(60000, &result); } }