Esempio n. 1
0
void HostsTool::readyread()
{
    QString get = QString::fromUtf8( reply->readAll());
    if(!get.isEmpty())
    {
        ui->textEdit->append("<p style=\"color:green\">>>服务器获取hosts成功</p>");
#ifdef Q_OS_WIND32
        QFile hosts("C:\\Windows\\System32\\drivers\\etc\\hosts");
        if(hosts.exists())
        {
            if(hosts.setPermissions(QFile::WriteGroup)&&hosts.setPermissions(QFile::WriteOwner)&&hosts.setPermissions(QFile::WriteUser))
            {
                ui->textEdit->append("<p style=\"color:green\">>>设置权限成功</p>");
                hosts.remove();
                QFile file("C:\\Windows\\System32\\drivers\\etc\\hosts");
                file.open( QIODevice::WriteOnly|QFile::Text);
                QTextStream stream(&file);
                stream<<get;
                file.close();
                ui->textEdit->append("<p style=\"color:green\">>>配置hosts完成!</p>");
            }else {
                ui->textEdit->append("<body style=\" font-family;'微软雅黑\'; font-size:10pt; font-weight:72; font-style:normal;\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" color:#ff0000;\">&gt;&gt;设置权限失败,请执行:</span></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">·使用管理员账号登陆</span></p></body>");
            }
        }else{
            QFile file("C:\\Windows\\System32\\drivers\\etc\\hosts");
            file.open( QIODevice::WriteOnly|QFile::Text);
            QTextStream stream(&file);
            stream<<get;
            file.close();
        }
#endif
#ifdef Q_OS_LINUX
        QFile hosts("/etc/hosts");
        if(hosts.setPermissions(QFile::WriteGroup)&&hosts.setPermissions(QFile::WriteOwner)&&hosts.setPermissions(QFile::WriteUser))
        {
            ui->textEdit->append("<p style=\"color:green\">>>设置权限成功</p>");
            hosts.remove();
            QFile file("/etc/hosts");
            file.open( QIODevice::WriteOnly|QFile::Text);
            QTextStream stream(&file);
            stream<<get;
            file.close();
            ui->textEdit->append("<p style=\"color:green\">>>配置hosts完成!</p>");
        }else {
            ui->textEdit->append("<body style=\" font-family;'微软雅黑\'; font-size:10pt; font-weight:72; font-style:normal;\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" color:#ff0000;\">&gt;&gt;设置权限失败,请执行:</span></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">·使用管理员账号登陆</span></p></body>");
        }
#endif
    }else{
        ui->textEdit->append("<body style=\" font-family;'微软雅黑\'; font-size:10pt; font-weight:72; font-style:normal;\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" color:#ff0000;\">&gt;&gt;从服务器获取hosts失败,请执行:</span></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">·打开网络连接</span></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">·检查hosts源是否存在</span></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">·更换hosts源</span></p></body>");
    }
}
Esempio n. 2
0
		bp::dict
		get_couple_groupset(int group, const std::string &groupset_id) const {
			auto groupset = impl.couples().get_couple_groupset(group, groupset_id);

			bp::dict result;

			result["free_effective_space"] = groupset.free_effective_space();
			result["free_reserved_space"] = groupset.free_reserved_space();

			result["type"] = groupset.type();
			result["status"] = groupset.status();
			result["id"] = groupset.id();

			bp::list group_ids;
			for (int g : groupset.group_ids()) {
				group_ids.append(g);
			}

			result["group_ids"] = group_ids;

			gil_guard_t gil_guard;
			result["hosts"] = detail::convert(groupset.hosts(), gil_guard);
			result["settings"] = detail::convert(groupset.settings(), gil_guard);

			return result;
		}
Esempio n. 3
0
bool CReflectors::load()
{
	bool ret = m_socket.open();
	if (!ret)
		return false;

	CHosts hosts(m_hostsFile);
	ret = hosts.read();
	if (!ret)
		return false;

	std::vector<CYSFHost*>& hostList = hosts.list();

	for (std::vector<CYSFHost*>::const_iterator it = hostList.begin(); it != hostList.end(); ++it) {
		in_addr address = CUDPSocket::lookup((*it)->m_address);

		if (address.s_addr != INADDR_NONE) {
			CYSFReflector* reflector = new CYSFReflector;
			reflector->m_address = address;
			reflector->m_port    = (*it)->m_port;
			m_reflectors.push_back(reflector);
		}
	}

	m_it = m_reflectors.begin();

	m_timer.start();

	return true;
}
Esempio n. 4
0
int main(int argc, char *argv[])
{
    Node root("root");

    Node etc("etc");
    root.add(&etc);
    Leaf hosts("hosts");
    etc.add(&hosts);
    Node apache("apache");
    etc.add(&apache);
    Leaf httpd("httpd.conf");
    apache.add(&httpd);


    Node home("home");
    root.add(&home);
    Node admin("admin");
    home.add(&admin);
    Leaf doc("document.txt");
    admin.add(&doc);

    Node piero("piero");
    home.add(&piero);
    Leaf song("song.mp3");
    piero.add(&song);

    root.dump();
}
Esempio n. 5
0
void DCAwarePolicy::PerDCHostMap::add_host_to_dc(const std::string& dc, const SharedRefPtr<Host>& host) {
  ScopedWriteLock wl(&rwlock_);
  Map::iterator i = map_.find(dc);
  if (i == map_.end()) {
    CopyOnWriteHostVec hosts(new HostVec());
    hosts->push_back(host);
    map_.insert(Map::value_type(dc, hosts));
  } else {
    add_host(i->second, host);
  }
}
Esempio n. 6
0
/**
 *  @details This method displays or saves the host summary report with a column
 *           header (MAC Address, IPv4 Address, IPv6 Address), a column header
 *           separator using the character '=", the MAC, IPv4 and IPv6 addresses
 *           for hosts found sorted by MAC address, a footer separator using the
 *           character '=', and a host count summary.
 *  @throws std::runtime_error if the output file cannot be opened or written to
 */
void IPForensics::results() {
  std::stringstream result;
  // output hosts
  result << ipf::kHeader1 << std::endl << ipf::kHeader2 << std::endl;
  for (Host h : hosts()) {
    result << h << std::endl;
  }
  // output summary
  size_t hosts = hosts_.size(), v4 = 0, v6 = 0, dual = 0;
  for (Host h : hosts_) {
    if (!h.ipv4().empty() && h.ipv6().empty()) ++v4;
    if (!h.ipv6().empty() && h.ipv4().empty()) ++v6;
    if (!h.ipv4().empty() && !h.ipv6().empty()) ++dual;
  }
  double pc = static_cast<double>(dual + v6) / static_cast<double>(hosts) * 100;
  result << ipf::kFooter1 << '\n';
  result << "Hosts: " << hosts;
  result << "; IPv4 only: " << v4;
  result << "; IPv6 only: " << v6;
  result << "; dual-stack: " << dual;
  result << std::fixed << std::setprecision(0);
  result << "; migrated: " << pc << "%" << std::endl;
  // display or save results
  if (out_file_.empty()) {
    std::cout << result.str();
  } else {
    std::ofstream ofs(out_file_, std::ofstream::out);
    if (!ofs.is_open()) {
      throw std::runtime_error("Could not open output file " + out_file_);
    }
    ofs << result.str();
    if (ofs.bad()) {
      ofs.close();
      throw std::runtime_error("Could not write to output file " + out_file_);
    }
    ofs.close();
  }
}
Esempio n. 7
0
void CNetClient::PostPlayerAssignmentsToScript()
{
	JSContext* cx = GetScriptInterface().GetContext();
	JSAutoRequest rq(cx);

	JS::RootedValue msg(cx);
	GetScriptInterface().Eval("({'type':'players', 'hosts':{}})", &msg);

	JS::RootedValue hosts(cx);
	GetScriptInterface().GetProperty(msg, "hosts", &hosts);

	for (PlayerAssignmentMap::iterator it = m_PlayerAssignments.begin(); it != m_PlayerAssignments.end(); ++it)
	{
		JS::RootedValue host(cx);
		GetScriptInterface().Eval("({})", &host);
		GetScriptInterface().SetProperty(host, "name", std::wstring(it->second.m_Name), false);
		GetScriptInterface().SetProperty(host, "player", it->second.m_PlayerID, false);
		GetScriptInterface().SetProperty(host, "status", it->second.m_Status, false);
		GetScriptInterface().SetProperty(hosts, it->first.c_str(), host, false);
	}

	PushGuiMessage(msg);
}
PluginFactory::PluginFactory(QObject *parent) : QWebPluginFactory(parent) {

	QFile hosts(QDir::homePath()+"/.lightweight2/whitelistPluginHosts");
	if (hosts.exists()) {
		hosts.open(QFile::ReadOnly);
		QString line;
		while (hosts.bytesAvailable()) {
			line = QString::fromUtf8(hosts.readLine());
			if (line.endsWith("\n")) line.chop(1);
			m_knownHosts.append(line);
		}
		hosts.close();
	}
	m_knownHosts.removeDuplicates();

	foreach (QString host, m_knownHosts)
		qDebug() << "Allowed plugins for: " << host;

	QSettings s;
	allowAll = s.value("allowpluginsforall", "true").toBool();

	m_allowedHostSession.append(m_knownHosts);
	m_allowedHosts.append(m_knownHosts);
}
void
QvisRecentPathRemovalWindow::UpdateWindow(bool doAll)
{
    if(fileServer->HostChanged() || fileServer->PathChanged() || doAll)
    {
        // Clear out the paths vector.
        paths.clear();

        // Display the file paths for all of the hosts.
        stringVector hosts(fileServer->GetRecentHosts());
        for(size_t i = 0; i < hosts.size(); ++i)
        {
            const stringVector &p = fileServer->GetRecentPaths(hosts[i]);
            for(size_t j = 0; j < p.size(); ++j)
                paths.push_back(QualifiedFilename(hosts[i], p[j], "a"));
        }

        // Make sure the paths are sorted.
        std::sort(paths.begin(), paths.end());

        // Update the window's widgets.
        UpdateWidgets();
    }
}
void PluginFactory::saveAllowedHosts() {
	QFile hosts(QDir::homePath()+"/.lightweight2/whitelistPluginHosts");
	hosts.open(QFile::WriteOnly);
	foreach (QString host, m_allowedHosts) {
		hosts.write(host.toUtf8()+"\n");
	}