mirror of
https://github.com/g4klx/ircDDBGateway.git
synced 2026-01-10 10:20:02 +01:00
Add G2 port caching
This commit is contained in:
parent
21b1b967be
commit
bf4738c8a2
|
|
@ -91,6 +91,11 @@ CRepeaterData* CCacheManager::findRepeater(const wxString& repeater)
|
|||
}
|
||||
|
||||
void CCacheManager::updateUser(const wxString& user, const wxString& repeater, const wxString& gateway, const wxString& address, const wxString& timestamp, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
{
|
||||
updateUser(user, repeater, gateway, address, G2_DV_PORT, true, timestamp, protocol, addrLock, protoLock);
|
||||
}
|
||||
|
||||
void CCacheManager::updateUser(const wxString& user, const wxString& repeater, const wxString& gateway, const wxString& address, unsigned int g2Port, bool ignoreG2Port, const wxString& timestamp, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
{
|
||||
wxMutexLocker locker(m_mutex);
|
||||
|
||||
|
|
@ -103,10 +108,15 @@ void CCacheManager::updateUser(const wxString& user, const wxString& repeater, c
|
|||
if (!repeater7.IsSameAs(gateway7))
|
||||
m_repeaterCache.update(repeater, gateway);
|
||||
|
||||
m_gatewayCache.update(gateway, address, protocol, addrLock, protoLock);
|
||||
updateGateway(gateway, address, g2Port, ignoreG2Port, protocol, addrLock, protoLock);
|
||||
}
|
||||
|
||||
void CCacheManager::updateRepeater(const wxString& repeater, const wxString& gateway, const wxString& address, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
{
|
||||
updateRepeater(repeater, gateway, address, G2_DV_PORT, true, protocol, addrLock, protoLock);
|
||||
}
|
||||
|
||||
void CCacheManager::updateRepeater(const wxString& repeater, const wxString& gateway, const wxString& address, unsigned int g2Port, bool ignoreG2Port, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
{
|
||||
wxMutexLocker locker(m_mutex);
|
||||
|
||||
|
|
@ -117,12 +127,24 @@ void CCacheManager::updateRepeater(const wxString& repeater, const wxString& gat
|
|||
if (!repeater7.IsSameAs(gateway7))
|
||||
m_repeaterCache.update(repeater, gateway);
|
||||
|
||||
m_gatewayCache.update(gateway, address, protocol, addrLock, protoLock);
|
||||
updateGateway(gateway, address, g2Port, ignoreG2Port, protocol, addrLock, protoLock);
|
||||
}
|
||||
|
||||
void CCacheManager::updateGateway(const wxString& gateway, const wxString& address, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
{
|
||||
updateGateway(gateway, address, G2_DV_PORT, true, protocol, addrLock, protoLock);
|
||||
}
|
||||
|
||||
void CCacheManager::updateGateway(const wxString& gateway, const wxString& address, unsigned int g2Port, bool ignoreG2Port, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
{
|
||||
wxMutexLocker locker(m_mutex);
|
||||
|
||||
m_gatewayCache.update(gateway, address, protocol, addrLock, protoLock);
|
||||
m_gatewayCache.update(gateway, address, g2Port, ignoreG2Port, protocol, addrLock, protoLock);
|
||||
}
|
||||
|
||||
void CCacheManager::updateGatewayG2(const wxString& gateway, const wxString& address, unsigned int g2Port)
|
||||
{
|
||||
CGatewayRecord* gr = m_gatewayCache.find(gateway);
|
||||
DSTAR_PROTOCOL protocol = gr != NULL? gr->getProtocol() : DP_UNKNOWN;
|
||||
updateGateway(gateway, address, g2Port, false, protocol, false, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,9 +146,14 @@ public:
|
|||
|
||||
void updateUser(const wxString& user, const wxString& repeater, const wxString& gateway, const wxString& address, const wxString& timeStamp, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock);
|
||||
void updateRepeater(const wxString& repeater, const wxString& gateway, const wxString& address, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock);
|
||||
void updateGateway(const wxString& gateway, const wxString& address, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock);
|
||||
void updateGateway(const wxString& gateway, const wxString& address, DSTAR_PROTOCOL protocol,bool addrLock, bool protoLock);
|
||||
void updateGatewayG2(const wxString& gateway, const wxString& address, unsigned int g2Port);
|
||||
|
||||
private:
|
||||
void updateUser(const wxString& user, const wxString& repeater, const wxString& gateway, const wxString& address, unsigned int g2Port, bool ignoreG2Port, const wxString& timeStamp, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock);
|
||||
void updateRepeater(const wxString& repeater, const wxString& gateway, const wxString& address, unsigned int g2Port, bool ignoreG2Port, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock);
|
||||
void updateGateway(const wxString& gateway, const wxString& address, unsigned int g2Port, bool ignoreG2Port, DSTAR_PROTOCOL protocol,bool addrLock, bool protoLock);
|
||||
|
||||
wxMutex m_mutex;
|
||||
CUserCache m_userCache;
|
||||
CGatewayCache m_gatewayCache;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ CGatewayRecord* CGatewayCache::find(const wxString& gateway)
|
|||
return m_cache[gateway];
|
||||
}
|
||||
|
||||
void CGatewayCache::update(const wxString& gateway, const wxString& address, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
void CGatewayCache::update(const wxString& gateway, const wxString& address, unsigned int g2Port, bool ignoreG2Port, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
{
|
||||
CGatewayRecord* rec = m_cache[gateway];
|
||||
|
||||
|
|
@ -45,10 +45,10 @@ void CGatewayCache::update(const wxString& gateway, const wxString& address, DST
|
|||
|
||||
if (rec == NULL)
|
||||
// A brand new record is needed
|
||||
m_cache[gateway] = new CGatewayRecord(gateway, addr_in, protocol, addrLock, protoLock);
|
||||
m_cache[gateway] = new CGatewayRecord(gateway, addr_in, g2Port, protocol, addrLock, protoLock);
|
||||
else
|
||||
// Update an existing record
|
||||
rec->setData(addr_in, protocol, addrLock, protoLock);
|
||||
rec->setData(addr_in, g2Port, ignoreG2Port, protocol, addrLock, protoLock);
|
||||
}
|
||||
|
||||
unsigned int CGatewayCache::getCount() const
|
||||
|
|
|
|||
|
|
@ -35,9 +35,10 @@
|
|||
|
||||
class CGatewayRecord {
|
||||
public:
|
||||
CGatewayRecord(const wxString& gateway, in_addr address, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock) :
|
||||
CGatewayRecord(const wxString& gateway, in_addr address, unsigned int g2Port, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock) :
|
||||
m_gateway(gateway),
|
||||
m_address(address),
|
||||
m_g2Port(g2Port),
|
||||
m_protocol(DP_UNKNOWN),
|
||||
m_addrLock(addrLock),
|
||||
m_protoLock(false)
|
||||
|
|
@ -63,8 +64,16 @@ public:
|
|||
return m_protocol;
|
||||
}
|
||||
|
||||
void setData(in_addr address, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
unsigned int g2Port() const
|
||||
{
|
||||
return m_g2Port;
|
||||
}
|
||||
|
||||
void setData(in_addr address, unsigned int g2Port, bool ignoreG2Port, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock)
|
||||
{
|
||||
if(!ignoreG2Port)
|
||||
m_g2Port = g2Port;
|
||||
|
||||
if (!m_addrLock) {
|
||||
m_address = address;
|
||||
m_addrLock = addrLock;
|
||||
|
|
@ -80,10 +89,9 @@ public:
|
|||
|
||||
private:
|
||||
wxString m_gateway;
|
||||
in_addr m_address;
|
||||
|
||||
in_addr m_address;
|
||||
//the incoming G2 port, usually the default one unless the calling hotspot is behind a NAT, therefore keep track of it and use it to answer back instead of the default one
|
||||
unsigned int m_G2Port;
|
||||
unsigned int m_g2Port;
|
||||
DSTAR_PROTOCOL m_protocol;
|
||||
bool m_addrLock;
|
||||
bool m_protoLock;
|
||||
|
|
@ -98,7 +106,7 @@ public:
|
|||
|
||||
CGatewayRecord* find(const wxString& gateway);
|
||||
|
||||
void update(const wxString& gateway, const wxString& address, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock);
|
||||
void update(const wxString& gateway, const wxString& address, unsigned int g2port, bool ignoreG2Port, DSTAR_PROTOCOL protocol, bool addrLock, bool protoLock);
|
||||
|
||||
unsigned int getCount() const;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue