void AutoBan::setFromConf(){ char* banIps = g_conf.m_banIps; char *start = banIps; do { while(*banIps && !isspace(*banIps)) banIps++; long ip = atoip(start, banIps - start); if(ip) { if(!addIp(ip, DENY)) { log(LOG_WARN, "autoban: malloc failed, couldn't add IP."); } } while(*banIps && isspace(*banIps)) banIps++; start = banIps; } while(*banIps); char* allowIps = g_conf.m_allowIps; start = allowIps; do { while(*allowIps && !isspace(*allowIps)) allowIps++; long ip = atoip(start, allowIps - start); if(ip) { if(!addIp(ip, ALLOW)) { log(LOG_WARN, "autoban: malloc failed, couldn't add IP."); } } while(*allowIps && isspace(*allowIps)) allowIps++; start = allowIps; } while(*allowIps); }
int SonosEsp::discoverSonos(){ _numberOfDevices=0; WiFiUDP Udp; Udp.begin(1900); IPAddress sonosIP; bool timedOut = false; unsigned long timeLimit = 15000; unsigned long firstSearch = millis(); do { Serial.println("Sending M-SEARCH multicast"); Udp.beginPacketMulticast(IPAddress(239, 255, 255, 250), 1900, WiFi.localIP()); Udp.write("M-SEARCH * HTTP/1.1\r\n" "HOST: 239.255.255.250:1900\r\n" "MAN: \"ssdp:discover\"\r\n" "MX: 1\r\n" "ST: urn:schemas-upnp-org:device:ZonePlayer:1\r\n"); Udp.endPacket(); unsigned long lastSearch = millis(); while((millis() - lastSearch) < 5000){ int packetSize = Udp.parsePacket(); if(packetSize){ char packetBuffer[255]; //Serial.print("Received packet of size "); //Serial.println(packetSize); //Serial.print("From "); sonosIP = Udp.remoteIP(); //xxx if new IP, it should be put in an array addIp(sonosIP); //found = true; Serial.print(sonosIP); Serial.print(", port "); Serial.println(Udp.remotePort()); // read the packet into packetBufffer int len = Udp.read(packetBuffer, 255); if (len > 0) { packetBuffer[len] = 0; } //Serial.println("Contents:"); //Serial.println(packetBuffer); } delay(50); } } while((millis()-firstSearch)<timeLimit); //if (!found) { //sonosIP.fromString("0.0.0.0"); xxx //} return _numberOfDevices; }
void IpAddressItemModel::refreshIpList() { // Clear current IP list clear(); // Load IP list QList<QHostAddress> addrs = QNetworkInterface::allAddresses(); for(QList<QHostAddress>::iterator iter = addrs.begin(); iter != addrs.end(); ++iter) { if(iter->protocol() == QAbstractSocket::IPv4Protocol) { QString addr = iter->toString(); if(addr != "127.0.0.1") addIp(addr); } } }
void IpWidget::createActions() { connect(ui->pushButton_ipAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced())); // ip mode connect(ui->checkBox_ip, SIGNAL(stateChanged(int)), this, SLOT(ipEnable(int))); connect(ui->comboBox_ip, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeIpMode(QString))); // ipv6 mode connect(ui->checkBox_ip6, SIGNAL(stateChanged(int)), this, SLOT(ip6Enable(int))); connect(ui->comboBox_ip6, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeIp6Mode(QString))); // dhcp client connect(ui->comboBox_dhcp, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDhcpClient(QString))); // buttons connect(ui->pushButton_ipAddress, SIGNAL(clicked(bool)), this, SLOT(addIp())); connect(ui->lineEdit_ipAddress, SIGNAL(returnPressed()), this, SLOT(addIp())); connect(ui->pushButton_ipRoutes, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes())); connect(ui->pushButton_ipAddress6, SIGNAL(clicked(bool)), this, SLOT(addIp6())); connect(ui->lineEdit_ipAddress6, SIGNAL(returnPressed()), this, SLOT(addIp6())); connect(ui->pushButton_ipRoutes6, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes6())); connect(ui->pushButton_custom, SIGNAL(clicked(bool)), this, SLOT(addCustom())); connect(ui->lineEdit_custom, SIGNAL(returnPressed()), this, SLOT(addCustom())); connect(ui->pushButton_dns, SIGNAL(clicked(bool)), this, SLOT(addDns())); connect(ui->lineEdit_dns, SIGNAL(returnPressed()), this, SLOT(addDns())); connect(ui->pushButton_dnsOptions, SIGNAL(clicked(bool)), this, SLOT(addDnsOpt())); connect(ui->lineEdit_dnsOptions, SIGNAL(returnPressed()), this, SLOT(addDnsOpt())); } void IpWidget::createFilter() {