int upx::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: addHostGroup(); break; case 1: updateHostGroup(); break; case 2: delHostGroup(); break; case 3: addHost(); break; case 4: delHost(); break; case 5: groupClicked((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 6: saveSettings(); break; case 7: saveLog2File(); break; case 8: addGame(); break; case 9: updateGame(); break; case 10: deleteGame(); break; case 11: calcGigest(); break; case 12: gameRefresh(); break; case 13: addGameHost(); break; case 14: deleteGameHost(); break; case 15: gameStop(); break; case 16: gameStart(); break; case 17: diffGameFiles(); break; case 18: syncGameFiles(); break; case 19: selectGamePath(); break; case 20: selectGameItem(); break; default: ; } _id -= 21; } return _id; }
void HostCatcher::addHostList( SimpleVector<HostAddress *> * inHostList ) { int numToAdd = inHostList->size(); for( int i=0; i<numToAdd; i++ ) { addHost( *( inHostList->getElement( i ) ) ); } }
void RemoteManager::addNewHost() { QString host = ui->hostname->text().trimmed(); if(!host.isEmpty()) { bool found = false; for(int i = 0; i < m_Ctx.Config().RemoteHosts.count(); i++) { QString hostname = m_Ctx.Config().RemoteHosts[i]->hostname; if(hostname.compare(host, Qt::CaseInsensitive) == 0) { found = true; break; } } if(!found) { RemoteHost *h = new RemoteHost(); h->hostname = host; h->runCommand = ui->runCommand->text().trimmed(); m_Ctx.Config().RemoteHosts.push_back(h); m_Ctx.Config().Save(); addHost(h); } } ui->hostname->setText(host); on_hostname_textEdited(host); }
//------------------------------------------------------------------------------------------------ void Window::addGatewaysTab() { QWidget * w = new QWidget; gwEdit = new QLineEdit; gwEdit->setValidator(new IP4Validator(this)); connect(gwEdit, SIGNAL(textChanged(const QString &)), this, SLOT(gwTextChanged(const QString &))); addGw = new QPushButton; addGw->setIcon(QIcon(":/images/plus.png")); connect(addGw, SIGNAL(clicked()), this, SLOT(addHost())); addGw->setEnabled(false); QHBoxLayout * h1 = new QHBoxLayout; h1->addWidget(gwEdit); h1->addWidget(addGw); gwList = new QListWidget; gwList->setSelectionMode(QAbstractItemView::SingleSelection); gwList->setSortingEnabled(false); connect(gwList, SIGNAL(itemSelectionChanged()), this, SLOT(gatewaySelectionChanged())); upGw = new QPushButton; upGw->setIcon(QIcon(":/images/arrow-up.png")); connect(upGw, SIGNAL(clicked()), this, SLOT(upHost())); downGw = new QPushButton; downGw->setIcon(QIcon(":/images/arrow-down.png")); connect(downGw, SIGNAL(clicked()), this, SLOT(downHost())); delGw = new QPushButton; delGw->setIcon(QIcon(":/images/minus.png")); connect(delGw, SIGNAL(clicked()), this, SLOT(delHost())); QGridLayout * g = new QGridLayout; g->addWidget(gwList, 0, 0, 4, 1); g->addWidget(upGw, 0, 1); g->addWidget(downGw, 1, 1); g->addWidget(delGw, 2, 1); QVBoxLayout * vl = new QVBoxLayout; vl->addLayout(h1); vl->addSpacing(10); vl->addLayout(g); w->setLayout(vl); tabs->addTab(w, QIcon(":/images/network-ip-local.png"), tr("Gateways")); checkButtons(); }
void CRedisProxyCfg::getGroupNode(TiXmlElement* pNode) { CGroupInfo groupTmp; set_groupAttribute(pNode->FirstAttribute(), groupTmp); TiXmlElement* pNext = pNode->FirstChildElement(); for (; pNext != NULL; pNext = pNext->NextSiblingElement()) { if (0 == strcasecmp(pNext->Value(), "hash_min")) { if (NULL == pNext->GetText()) { set_hashMin(groupTmp, 0); continue; } set_hashMin(groupTmp, atoi(pNext->GetText())); continue; } if (0 == strcasecmp(pNext->Value(), "hash_max")) { if (NULL == pNext->GetText()) { set_hashMax(groupTmp, 0); continue; } set_hashMax(groupTmp, atoi(pNext->GetText())); continue; } if (0 == strcasecmp(pNext->Value(), "weight")) { if (NULL == pNext->GetText()) { set_weight(groupTmp, 0); continue; } set_weight(groupTmp, (unsigned int)atoi(pNext->GetText())); continue; } if (0 == strcasecmp(pNext->Value(), "name")) { set_groupName(groupTmp, pNext->GetText()); continue; } if (0 == strcasecmp(pNext->Value(), "host")) { CHostInfo hostInfo; set_hostAttribute(pNext->FirstAttribute(), hostInfo); TiXmlElement* hostContactEle = (TiXmlElement* )pNext->FirstChildElement(); set_hostEle(hostContactEle, hostInfo); addHost(groupTmp, hostInfo); } } m_groupInfo->push_back(groupTmp); }
RemoteManager::RemoteManager(ICaptureContext &ctx, MainWindow *main) : QDialog(NULL), ui(new Ui::RemoteManager), m_Ctx(ctx), m_Main(main) { ui->setupUi(this); m_ExternalRef.release(1); ui->hosts->setFont(Formatter::PreferredFont()); ui->hostname->setFont(Formatter::PreferredFont()); ui->runCommand->setFont(Formatter::PreferredFont()); ui->hosts->setColumns({tr("Hostname"), tr("Running")}); ui->hosts->header()->setSectionResizeMode(0, QHeaderView::Stretch); ui->hosts->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); lookupsProgressFlow = new QWidget(this); FlowLayout *flow = new FlowLayout(lookupsProgressFlow, 0, 3, 3); lookupsProgressFlow->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); flow->addWidget(ui->progressIcon); flow->addWidget(ui->progressText); flow->addWidget(ui->progressCount); QVBoxLayout *vertical = new QVBoxLayout(this); vertical->addWidget(ui->hosts); vertical->addWidget(lookupsProgressFlow); vertical->addWidget(ui->bottomLayout->parentWidget()); m_Ctx.Config().AddAndroidHosts(); for(RemoteHost *h : m_Ctx.Config().RemoteHosts) addHost(h); on_hosts_itemSelectionChanged(); }
_Hosts::_Hosts(QWidget *parent) : QWidget(parent) { hosts = new QListWidget(this); add = new QPushButton(QIcon::fromTheme("list-add"), "", this); del = new QPushButton(QIcon::fromTheme("list-remove"), "", this); name = new QLineEdit(this); name->setPlaceholderText("Host name"); port = new QLineEdit(this); port->setPlaceholderText("Port"); colon = new QLabel(":", this); panelLayout = new QHBoxLayout(this); panel = new QWidget(this); panelLayout->addWidget(add, 2); panelLayout->addWidget(name, 40); panelLayout->addWidget(colon, 1); panelLayout->addWidget(port, 8); panelLayout->addWidget(del, 2); panel->setLayout(panelLayout); baseLayout = new QVBoxLayout(this); baseLayout->addWidget(hosts); baseLayout->addWidget(panel); baseWdg = new QWidget(this); baseWdg->setLayout(baseLayout); baseWdg->setVisible(false); useHosts = new QCheckBox("Use Hosts", this); commonLayout = new QVBoxLayout(this); commonLayout->addWidget(useHosts); commonLayout->addWidget(baseWdg); setLayout(commonLayout); connect(useHosts, SIGNAL(toggled(bool)), baseWdg, SLOT(setVisible(bool))); connect(add, SIGNAL(clicked()), this, SLOT(addHost())); connect(del, SIGNAL(clicked()), this, SLOT(delHost())); setFullHostMode(true); setOneHostMode(false); }
void SensorBrowserModel::hostAdded(KSGRD::SensorAgent *sensorAgent, const QString &hostName) { addHost(sensorAgent,hostName); update(); }
void start_dnsmasq(void) { FILE *fp; struct dns_lists *dns_list = NULL; int ret; int i; if (nvram_match("dhcp_dnsmasq", "1") && nvram_match("lan_proto", "dhcp") && nvram_match("dnsmasq_enable", "0")) { nvram_set("dnsmasq_enable", "1"); nvram_commit(); } if (!nvram_invmatch("dnsmasq_enable", "0")) { stop_dnsmasq(); return; } usejffs = 0; if (nvram_match("dhcpd_usejffs", "1")) { if (!(fp = fopen("/jffs/dnsmasq.leases", "a"))) { usejffs = 0; } else { fclose(fp); usejffs = 1; } } /* * Write configuration file based on current information */ if (!(fp = fopen("/tmp/dnsmasq.conf", "w"))) { perror("/tmp/dnsmasq.conf"); return; } // fprintf(fp, "bind-interfaces\n"); if (nvram_match("chilli_enable", "1")) { if (canlan()) fprintf(fp, "interface=%s", get_wdev()); else fprintf(fp, "interface=%s,", get_wdev()); } else if (nvram_match("pptpd_enable", "1")) { if (canlan()) fprintf(fp, "listen-address=%s,%s", "127.0.0.1", nvram_safe_get("lan_ipaddr")); else fprintf(fp, "listen-address=%s", "127.0.0.1"); } else { if (canlan()) fprintf(fp, "interface=%s", nvram_safe_get("lan_ifname")); else fprintf(fp, "interface="); } int mdhcpcount = 0; if (nvram_get("mdhcpd_count") != NULL) { mdhcpcount = atoi(nvram_safe_get("mdhcpd_count")); for (i = 0; i < mdhcpcount; i++) { if (strlen(nvram_nget("%s_ipaddr", getmdhcp(0, i))) == 0 || strlen(nvram_nget("%s_netmask", getmdhcp(0, i))) == 0) continue; if (canlan() || i > 0) { if (nvram_match("pptpd_enable", "1")) fprintf(fp, ",%s", nvram_nget("%s_ipaddr", getmdhcp(0, i))); else fprintf(fp, ",%s", getmdhcp(0, i)); } else { if (nvram_match("pptpd_enable", "1")) fprintf(fp, "%s", nvram_nget("%s_ipaddr", getmdhcp(0, i))); else fprintf(fp, "%s", getmdhcp(0, i)); } } } fprintf(fp, "\n"); fprintf(fp, "resolv-file=/tmp/resolv.dnsmasq\n" "all-servers\n"); // /* * Domain */ if (nvram_match("dhcp_domain", "wan")) { if (nvram_invmatch("wan_domain", "")) fprintf(fp, "domain=%s\n", nvram_safe_get("wan_domain")); else if (nvram_invmatch("wan_get_domain", "")) fprintf(fp, "domain=%s\n", nvram_safe_get("wan_get_domain")); } else { if (nvram_invmatch("lan_domain", "")) fprintf(fp, "domain=%s\n", nvram_safe_get("lan_domain")); } /* * DD-WRT use dnsmasq as DHCP replacement */ //bs mod if (hasdhcp()) { /* * DHCP leasefile */ if (nvram_match("dhcpd_usenvram", "1")) { fprintf(fp, "leasefile-ro\n"); fprintf(fp, "dhcp-script=%s\n", "/etc/lease_update.sh"); } else { if (usejffs) fprintf(fp, "dhcp-leasefile=/jffs/dnsmasq.leases\n"); else fprintf(fp, "dhcp-leasefile=/tmp/dnsmasq.leases\n"); } int dhcp_max = 0; if (landhcp()) dhcp_max += atoi(nvram_safe_get("dhcp_num")) + atoi(nvram_safe_get("static_leasenum")); for (i = 0; i < mdhcpcount; i++) { if (strlen(nvram_nget("%s_ipaddr", getmdhcp(0, i))) == 0 || strlen(nvram_nget("%s_netmask", getmdhcp(0, i))) == 0) continue; dhcp_max += atoi(getmdhcp(3, i)); } fprintf(fp, "dhcp-lease-max=%d\n", dhcp_max); if (landhcp()) fprintf(fp, "dhcp-option=lan,3,%s\n", nvram_safe_get("lan_ipaddr")); for (i = 0; i < mdhcpcount; i++) { if (strlen(nvram_nget("%s_ipaddr", getmdhcp(0, i))) == 0 || strlen(nvram_nget("%s_netmask", getmdhcp(0, i))) == 0) continue; fprintf(fp, "dhcp-option=%s,3,", getmdhcp(0, i)); fprintf(fp, "%s\n", nvram_nget("%s_ipaddr", getmdhcp(0, i))); } if (nvram_invmatch("wan_wins", "") && nvram_invmatch("wan_wins", "0.0.0.0")) fprintf(fp, "dhcp-option=44,%s\n", nvram_safe_get("wan_wins")); if (nvram_match("dns_dnsmasq", "0")) { dns_list = get_dns_list(); if (dns_list && (strlen(dns_list->dns_server[0]) > 0 || strlen(dns_list->dns_server[1]) > 0 || strlen(dns_list->dns_server[2]) > 0)) { fprintf(fp, "dhcp-option=6"); if (strlen(dns_list->dns_server[0]) > 0) fprintf(fp, ",%s", dns_list->dns_server[0]); if (strlen(dns_list->dns_server[1]) > 0) fprintf(fp, ",%s", dns_list->dns_server[1]); if (strlen(dns_list->dns_server[2]) > 0) fprintf(fp, ",%s", dns_list->dns_server[2]); fprintf(fp, "\n"); } if (dns_list) free(dns_list); } if (nvram_match("auth_dnsmasq", "1")) fprintf(fp, "dhcp-authoritative\n"); if (landhcp()) { fprintf(fp, "dhcp-range=lan,"); fprintf(fp, "%d.%d.%d.%s,", get_single_ip(nvram_safe_get("lan_ipaddr"), 0), get_single_ip(nvram_safe_get("lan_ipaddr"), 1), get_single_ip(nvram_safe_get("lan_ipaddr"), 2), nvram_safe_get("dhcp_start")); if (nvram_match("dhcp_num", "0")) { fprintf(fp, "static,"); } else { fprintf(fp, "%d.%d.%d.%d,", get_single_ip(nvram_safe_get ("lan_ipaddr"), 0), get_single_ip(nvram_safe_get ("lan_ipaddr"), 1), get_single_ip(nvram_safe_get ("lan_ipaddr"), 2), atoi(nvram_safe_get("dhcp_start")) + atoi(nvram_safe_get("dhcp_num")) - 1); } fprintf(fp, "%s,", nvram_safe_get("lan_netmask")); fprintf(fp, "%sm\n", nvram_safe_get("dhcp_lease")); } for (i = 0; i < mdhcpcount; i++) { if (strcmp(getmdhcp(1, i), "On")) continue; if (strlen(nvram_nget("%s_ipaddr", getmdhcp(0, i))) == 0 || strlen(nvram_nget("%s_netmask", getmdhcp(0, i))) == 0) continue; fprintf(fp, "dhcp-range=%s,", getmdhcp(0, i)); fprintf(fp, "%d.%d.%d.", get_single_ip(nvram_nget ("%s_ipaddr", getmdhcp(0, i)), 0), get_single_ip(nvram_nget ("%s_ipaddr", getmdhcp(0, i)), 1), get_single_ip(nvram_nget ("%s_ipaddr", getmdhcp(0, i)), 2)); fprintf(fp, "%s,", getmdhcp(2, i)); fprintf(fp, "%d.%d.%d.", get_single_ip(nvram_nget ("%s_ipaddr", getmdhcp(0, i)), 0), get_single_ip(nvram_nget ("%s_ipaddr", getmdhcp(0, i)), 1), get_single_ip(nvram_nget ("%s_ipaddr", getmdhcp(0, i)), 2)); int end = atoi(getmdhcp(2, i)); end += atoi(getmdhcp(3, i)); fprintf(fp, "%d,", end); fprintf(fp, "%s,", nvram_nget("%s_netmask", getmdhcp(0, i))); fprintf(fp, "%sm\n", getmdhcp(4, i)); } int leasenum = atoi(nvram_safe_get("static_leasenum")); if (leasenum > 0) { char *lease = nvram_safe_get("static_leases"); char *leasebuf = (char *)malloc(strlen(lease) + 1); char *cp = leasebuf; strcpy(leasebuf, lease); for (i = 0; i < leasenum; i++) { char *mac = strsep(&leasebuf, "="); char *host = strsep(&leasebuf, "="); char *ip = strsep(&leasebuf, "="); char *time = strsep(&leasebuf, " "); if (mac == NULL || host == NULL || ip == NULL) continue; if (!time || strlen(time) == 0) fprintf(fp, "dhcp-host=%s,%s,%s,infinite\n", mac, host, ip); else fprintf(fp, "dhcp-host=%s,%s,%s,%sm\n", mac, host, ip, time); addHost(host, ip); } free(cp); } } /* stop dns rebinding for private addresses */ if (nvram_match("dnsmasq_no_dns_rebind", "1")) { fprintf(fp, "stop-dns-rebind\n"); } /* * Additional options */ if (nvram_invmatch("dnsmasq_options", "")) { fwritenvram("dnsmasq_options", fp); } fclose(fp); dns_to_resolv(); chmod("/etc/lease_update.sh", 0700); ret = eval("dnsmasq", "--conf-file=/tmp/dnsmasq.conf"); dd_syslog(LOG_INFO, "dnsmasq : dnsmasq daemon successfully started\n"); cprintf("done\n"); return; }