Пример #1
0
G2Packet* CQuery::ToG2Packet(CEndPoint* pAddr, quint32 nKey)
{
	G2Packet* pPacket = G2Packet::New("Q2", true);

	//bool bWantURL = true;
	bool bWantDN = (!m_sDescriptiveName.isEmpty());
	bool bWantMD = !m_sMetadata.isEmpty();
	//bool bWantPFS = true;

	if(pAddr)
	{
		G2Packet* pUDP = pPacket->WritePacket("UDP", 10);
		pUDP->WriteHostAddress(pAddr);
		pUDP->WriteIntLE(nKey);
	}

	if(bWantDN)
	{
		pPacket->WritePacket("DN", m_sDescriptiveName.toUtf8().size())->WriteString(m_sDescriptiveName, false);
	}
	if(bWantMD)
	{
		pPacket->WritePacket("MD", m_sMetadata.toUtf8().size())->WriteString(m_sMetadata, false);
	}

	foreach(CHash pHash, m_lHashes)
	{
		pPacket->WritePacket("URN", pHash.GetFamilyName().size() + CHash::ByteCount(pHash.getAlgorithm()) + 1);
		pPacket->WriteString(pHash.GetFamilyName() + "\0" + pHash.RawValue(), false);
	}
Пример #2
0
void CG2Node::SendStartups()
{
	if( Network.IsListening() )
    {
        IPv4_ENDPOINT addr = Network.GetLocalAddress();
		G2Packet* pPacket = G2Packet::New("PI", true);
		pPacket->WritePacket("UDP", 6);
		pPacket->WriteHostAddress(&addr);
		pPacket->WritePacket("TFW", 0);
		SendPacket(pPacket, false, true);
    }

	SendLNI();
}