mirror of
https://github.com/g4klx/ircDDBGateway.git
synced 2026-04-07 07:14:09 +00:00
Revert "Merge pull request #16 from F4FXL/UDPHolePunching"
This reverts commitcc2c68aff9, reversing changes made to05e66c15d1.
This commit is contained in:
parent
fe42c30df0
commit
d87d121c8d
16 changed files with 53 additions and 324 deletions
|
|
@ -38,56 +38,19 @@ CGatewayRecord* CGatewayCache::find(const wxString& gateway)
|
|||
|
||||
void CGatewayCache::update(const wxString& gateway, const wxString& address, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
{
|
||||
CGatewayRecord* rec = m_cache[gateway];
|
||||
|
||||
in_addr addr_in;
|
||||
addr_in.s_addr = ::inet_addr(address.mb_str());
|
||||
|
||||
CGatewayRecord* rec = m_cache[gateway];
|
||||
|
||||
if(rec == NULL) {
|
||||
rec = findByAddress(addr_in);//did this gateway punch to us and we do not have a gateway set for it ?
|
||||
if(rec != NULL && rec->getGateway().empty() && rec->getProtocol() == protocol)
|
||||
rec->setGateway(gateway);
|
||||
else
|
||||
rec = NULL;
|
||||
}
|
||||
|
||||
if (rec == NULL)
|
||||
// A brand new record is needed
|
||||
m_cache[gateway] = new CGatewayRecord(gateway, addr_in, G2_DV_PORT, protocol, addrLock, protoLock);
|
||||
m_cache[gateway] = new CGatewayRecord(gateway, addr_in, protocol, addrLock, protoLock);
|
||||
else
|
||||
// Update an existing record
|
||||
rec->setData(addr_in, protocol, addrLock, protoLock);
|
||||
}
|
||||
|
||||
void CGatewayCache::updateG2(const wxString& gateway, in_addr address, unsigned int g2Port)
|
||||
{
|
||||
//empty gateway means we are coming from udp hole punching, let see if we have an gateway with matching address
|
||||
CGatewayRecord* rec = gateway.empty()? findByAddress(address) : m_cache[gateway];
|
||||
|
||||
if (rec == NULL) {
|
||||
// A brand new record is needed
|
||||
m_cache[gateway] = new CGatewayRecord(gateway, address, g2Port, DP_UNKNOWN, false, false);
|
||||
}
|
||||
else {
|
||||
// Update an existing record
|
||||
if(rec->getGateway().empty())//if this is a record created from a punch call, set its gateway
|
||||
rec->setGateway(gateway);
|
||||
|
||||
rec->setG2Data(address, g2Port);
|
||||
}
|
||||
}
|
||||
|
||||
CGatewayRecord* CGatewayCache::findByAddress(in_addr address)
|
||||
{
|
||||
for (CGatewayCache_t::iterator it = m_cache.begin(); it != m_cache.end(); ++it) {
|
||||
if(it-> second != NULL
|
||||
&& it->second->getAddress().s_addr == address.s_addr)
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int CGatewayCache::getCount() const
|
||||
{
|
||||
return m_cache.size();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue