Merge pull request #10 from F4FXL/UDPHolePunching

Add UDP Hole Punching for G2
This commit is contained in:
Jonathan Naylor 2018-11-02 02:31:06 -07:00 committed by GitHub
commit cf5c32b585
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View file

@ -144,6 +144,18 @@ CAMBEData* CG2ProtocolHandler::readAMBE()
return data;
}
void CG2ProtocolHandler::punchUDPHole(const wxString& address)
{
unsigned char buffer[1];
::memset(buffer, 0, 1);
in_addr addr = CUDPReaderWriter::lookup(address);
//wxLogError(wxT("Punching hole to %s"), address.mb_str());
m_socket.write(buffer, 1, addr, G2_DV_PORT);
}
void CG2ProtocolHandler::close()
{
m_socket.close();

View file

@ -52,6 +52,8 @@ public:
CHeaderData* readHeader();
CAMBEData* readAMBE();
void punchUDPHole(const wxString& addr);
void close();
private:

View file

@ -719,6 +719,7 @@ void CIRCDDBGatewayThread::processIrcDDB()
if (!address.IsEmpty()) {
wxLogMessage(wxT("USER: %s %s %s %s"), user.c_str(), repeater.c_str(), gateway.c_str(), address.c_str());
m_cache.updateUser(user, repeater, gateway, address, timestamp, DP_DEXTRA, false, false);
m_g2Handler->punchUDPHole(address);
} else {
wxLogMessage(wxT("USER: %s NOT FOUND"), user.c_str());
}
@ -735,6 +736,7 @@ void CIRCDDBGatewayThread::processIrcDDB()
if (!address.IsEmpty()) {
wxLogMessage(wxT("REPEATER: %s %s %s"), repeater.c_str(), gateway.c_str(), address.c_str());
m_cache.updateRepeater(repeater, gateway, address, DP_DEXTRA, false, false);
m_g2Handler->punchUDPHole(address);
} else {
wxLogMessage(wxT("REPEATER: %s NOT FOUND"), repeater.c_str());
}
@ -752,6 +754,7 @@ void CIRCDDBGatewayThread::processIrcDDB()
if (!address.IsEmpty()) {
wxLogMessage(wxT("GATEWAY: %s %s"), gateway.c_str(), address.c_str());
m_cache.updateGateway(gateway, address, DP_DEXTRA, false, false);
m_g2Handler->punchUDPHole(address);
} else {
wxLogMessage(wxT("GATEWAY: %s NOT FOUND"), gateway.c_str());
}