void WpaGui::addNetwork() { NetworkConfig *nc = new NetworkConfig(); if (nc == NULL) return; nc->setWpaGui(this); nc->newNetwork(); nc->show(); nc->exec(); }
void ScanResults::bssSelected(QTreeWidgetItem *sel) { NetworkConfig *nc = new NetworkConfig(); if (nc == NULL) return; nc->setWpaGui(wpagui); nc->paramsFromScanResults(sel); nc->show(); nc->exec(); }
void ConnectionSettingsPage::saveAutoWidgetValue(const QString &widgetName, const QVariant &value) { if (!isEnabled()) return; NetworkConfig *config = Client::networkConfig(); if (widgetName == "pingTimeoutEnabled") config->requestSetPingTimeoutEnabled(value.toBool()); else if (widgetName == "pingInterval") config->requestSetPingInterval(value.toInt()); else if (widgetName == "maxPingCount") config->requestSetMaxPingCount(value.toInt()); else if (widgetName == "autoWhoEnabled") config->requestSetAutoWhoEnabled(value.toBool()); else if (widgetName == "autoWhoInterval") config->requestSetAutoWhoInterval(value.toInt()); else if (widgetName == "autoWhoNickLimit") config->requestSetAutoWhoNickLimit(value.toInt()); else if (widgetName == "autoWhoDelay") config->requestSetAutoWhoDelay(value.toInt()); else if (widgetName == "standardCtcp") config->requestSetStandardCtcp(value.toBool()); else SettingsPage::saveAutoWidgetValue(widgetName, value); }
SocketWriteThread::SocketWriteThread(SOCKET socket, Service* service, bool serverservice, NetworkConfig& network_configuration) : mService(0), mCompCryptor(0), mSocket(0), mIsRunning(false) { mSocket = socket; mService = service; // amount of reliables to process per pass - we dont want stalling or drowning the receiver in packetbursts // remember we have hundreds of clientsessions but only one serversession // however without respective Priority queues this can lead to lag if(serverservice) { reliablePackets = 10000; unReliablePackets = 20000; mServerService = true; mMessageMaxSize = network_configuration.getServerToServerReliableSize(); } else { reliablePackets = 50; unReliablePackets = 500; mServerService = false; mMessageMaxSize = network_configuration.getServerToClientReliableSize(); } // We do have a global clock object, don't use seperate clock and times for every process. // mClock = new Anh_Utils::Clock(); // Create our CompCryptor object. mCompCryptor = new CompCryptor(); // start our thread boost::thread t(std::tr1::bind(&SocketWriteThread::run, this)); mThread = boost::move(t); #ifdef _WIN32 HANDLE mtheHandle = mThread.native_handle(); SetPriorityClass(mtheHandle,REALTIME_PRIORITY_CLASS); #endif //our thread load values //mThreadTime = mLastThreadTime = 0; mLastTime = Anh_Utils::Clock::getSingleton()->getLocalTime(); //lastThreadProcessingTime = threadProcessingTime = 0; }
void WpaGui::editNetwork() { QString sel(networkSelect->currentText()); int pos = sel.find(':'); if (pos < 0) { printf("Invalid selectNetwork '%s'\n", sel.ascii()); return; } sel.truncate(pos); NetworkConfig *nc = new NetworkConfig(); if (nc == NULL) return; nc->setWpaGui(this); nc->paramsFromConfig(sel.toInt()); nc->show(); nc->exec(); }
QVariant ConnectionSettingsPage::loadAutoWidgetValue(const QString &widgetName) { if (!isEnabled()) return QVariant(); NetworkConfig *config = Client::networkConfig(); if (widgetName == "pingTimeoutEnabled") return config->pingTimeoutEnabled(); if (widgetName == "pingInterval") return config->pingInterval(); if (widgetName == "maxPingCount") return config->maxPingCount(); if (widgetName == "autoWhoEnabled") return config->autoWhoEnabled(); if (widgetName == "autoWhoInterval") return config->autoWhoInterval(); if (widgetName == "autoWhoNickLimit") return config->autoWhoNickLimit(); if (widgetName == "autoWhoDelay") return config->autoWhoDelay(); if (widgetName == "standardCtcp") return config->standardCtcp(); return SettingsPage::loadAutoWidgetValue(widgetName); }
void ZmqSocketListener() { z_context = zmq_ctx_new(); void *responder = zmq_socket(z_context, ZMQ_REP); // const char* addr = "tcp://*:5555"; const char* addr = network_config.GetSocketBinding(); int rc = zmq_bind(responder, addr); const int BUFF_SIZE = 1024; while (listening) { char buffer[BUFF_SIZE]; rc = zmq_recv(responder, &buffer, BUFF_SIZE, 0); if (rc > 0 && rc < BUFF_SIZE) { try { std::string s(buffer, rc); // split the string by vertical tab // first entry is the command (registry key) // second entry is the command parameters auto pivot = s.find('\v'); if (-1 != pivot && pivot < s.length()) { auto cmd = s.substr(0, pivot); auto params = s.substr(pivot + 1, s.length()); auto exe = command_config.GetRegistryEntry(cmd); ShellExecute(NULL, "open", exe.c_str(), params.c_str(), NULL, SW_SHOWNORMAL); } else { ShellExecute(NULL, "open", s.c_str(), NULL, NULL, SW_SHOWNORMAL); } zmq_send(responder, "OK", 3, 0); } catch (std::exception& ex) { std::cerr << "exception caught: " << ex.what() << '\n'; } } } zmq_close(responder); }
void WpaGui::editNetwork(const QString &sel) { QString cmd(sel); int id = -1; if (cmd.contains(QRegExp("^\\d+:"))) { cmd.truncate(cmd.indexOf(':')); id = cmd.toInt(); } NetworkConfig *nc = new NetworkConfig(); if (nc == NULL) return; nc->setWpaGui(this); if (id >= 0) nc->paramsFromConfig(id); else nc->newNetwork(); nc->show(); nc->exec(); }
Service::Service(NetworkManager* networkManager, bool serverservice, uint32 id, int8* localAddress, uint16 localPort,uint32 mfHeapSize, NetworkConfig& network_configuration) : mNetworkManager(networkManager), mSocketReadThread(0), mSocketWriteThread(0), mLocalSocket(0), avgTime(0), avgPacketsbuild (0), mLocalAddress(0), mLocalPort(0), mQueued(false), mServerService(serverservice) { mCallBack = NULL; mId = id; lasttime = Anh_Utils::Clock::getSingleton()->getLocalTime(); assert(strlen(localAddress) < 256 && "Address length should be less than 256"); strcpy(mLocalAddressName, localAddress); mLocalAddress = inet_addr(localAddress); mLocalPort = htons(localPort); #if(ANH_PLATFORM == ANH_PLATFORM_WIN32) // Startup the windows socket layer if it's not already started. if (!mSocketsSubsystemInitComplete) { mSocketsSubsystemInitComplete = true; WSADATA data; WSAStartup(MAKEWORD(2,0), &data); } #endif //WIN32 // Create our socket descriptors SOCKET mLocalSocket = socket(PF_INET, SOCK_DGRAM, 0); // Bind to our listen port. sockaddr_in server; server.sin_family = AF_INET; server.sin_port = mLocalPort; server.sin_addr.s_addr = INADDR_ANY; // Attempt to bind to our socket bind(mLocalSocket, (struct sockaddr*)&server, sizeof(server)); // We need to call connect on the socket to an address before we can know which address we have. // The address specified in the connect call determines which interface our socket is associated with // based on routing. 1.1.1.1 should give us the default adaptor. Not sure what to do one multihomed hosts yet. // struct sockaddr toAddr; // int32 sent, toLen = sizeof(toAddr); /* toAddr.sa_family = AF_INET; *((uint32*)&toAddr.sa_data[2]) = 0; *((uint16*)&(toAddr.sa_data[0])) = 0; // This connect will make the socket only acceept packets from the destination. Need to reset at end. //sent = sendto(mLocalSocket, mSendBuffer, 1, 0, &toAddr, toLen); sent = connect(mLocalSocket, &toAddr, toLen); */ //set the socketbuffer so we dont suffer internal dataloss int value; int valuelength = sizeof(value); value = 524288; int configvalue = network_configuration.getUdpBufferSize(); //gLogger->log(LogManager::INFORMATION, "UDPBuffer set to %ukb", configvalue); LOG(INFO) << "UDP buffer size set to " << configvalue << "kb"; if(configvalue < 128) configvalue = 128; if(configvalue > 16384) configvalue = 16384; value = configvalue *1024; setsockopt(mLocalSocket,SOL_SOCKET,SO_RCVBUF,(char*)&value,valuelength); int temp = 1; //9 is IP_DONTFRAG (PK told me to put that here so we know wtf 9 means :P setsockopt(mLocalSocket, IPPROTO_IP, 9, (char*)&temp, sizeof(temp)); // Create our read/write socket classes mSocketWriteThread = new SocketWriteThread(mLocalSocket,this,mServerService, network_configuration); mSocketReadThread = new SocketReadThread(mLocalSocket, mSocketWriteThread,this,mfHeapSize, mServerService, network_configuration); // Query the stack for the actual address and port we got and store it in the service. //getsockname(mLocalSocket, (sockaddr*)&server, &serverLen); //mLocalAddress = server.sin_addr.s_addr; //mLocalPort = server.sin_port; /* // Reset the connect call to universe. toAddr.sa_family = AF_INET; *((uint32*)&toAddr.sa_data[2]) = 0; *((uint16*)&(toAddr.sa_data[0])) = 0; sent = connect(mLocalSocket, &toAddr, toLen); */ }