mirror of
https://github.com/g4klx/ircDDBGateway.git
synced 2026-04-07 07:14:09 +00:00
Constrain G2 stuff to specific functions
Code is much more lighter !
This commit is contained in:
parent
1f76e03cf5
commit
cda4300f34
5 changed files with 63 additions and 40 deletions
|
|
@ -36,19 +36,48 @@ CGatewayRecord* CGatewayCache::find(const wxString& gateway)
|
|||
return m_cache[gateway];
|
||||
}
|
||||
|
||||
void CGatewayCache::update(const wxString& gateway, const wxString& address, unsigned int g2Port, bool ignoreG2Port, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
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)
|
||||
// A brand new record is needed
|
||||
m_cache[gateway] = new CGatewayRecord(gateway, addr_in, g2Port, protocol, addrLock, protoLock);
|
||||
m_cache[gateway] = new CGatewayRecord(gateway, addr_in, G2_DV_PORT, protocol, addrLock, protoLock);
|
||||
else
|
||||
// Update an existing record
|
||||
rec->setData(addr_in, g2Port, ignoreG2Port, protocol, addrLock, protoLock);
|
||||
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 getway 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue