Add update of gateway call to records creted through udp punching

This commit is contained in:
Geoffrey Merck F4FXL - KC3FRA 2018-11-18 21:38:40 +01:00
parent ee9f3e1816
commit 65d7081f29
3 changed files with 27 additions and 7 deletions

View file

@ -65,7 +65,7 @@ CGatewayData* CCacheManager::findGateway(const wxString& gateway)
if (gr == NULL)
return NULL;
return new CGatewayData(gateway, gr->getAddress(), gr->getProtocol());
return new CGatewayData(gateway, gr->getAddress(), gr->getProtocol(), gr->getG2Port());
}
CRepeaterData* CCacheManager::findRepeater(const wxString& repeater)
@ -87,7 +87,7 @@ CRepeaterData* CCacheManager::findRepeater(const wxString& repeater)
if (gr == NULL)
return NULL;
return new CRepeaterData(repeater, gr->getGateway(), gr->getAddress(), gr->getProtocol());
return new CRepeaterData(repeater, gr->getGateway(), gr->getAddress(), gr->getProtocol(), gr->getG2Port());
}
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)

View file

@ -77,11 +77,12 @@ private:
class CRepeaterData {
public:
CRepeaterData(const wxString& repeater, const wxString& gateway, in_addr address, DSTAR_PROTOCOL protocol) :
CRepeaterData(const wxString& repeater, const wxString& gateway, in_addr address, DSTAR_PROTOCOL protocol, unsigned int g2Port) :
m_repeater(repeater),
m_gateway(gateway),
m_address(address),
m_protocol(protocol)
m_protocol(protocol),
m_g2Port(g2Port)
{
}
@ -105,19 +106,26 @@ public:
return m_protocol;
}
unsigned int getG2Port() const
{
return m_g2Port;
}
private:
wxString m_repeater;
wxString m_gateway;
in_addr m_address;
DSTAR_PROTOCOL m_protocol;
unsigned int m_g2Port;
};
class CGatewayData {
public:
CGatewayData(const wxString& gateway, in_addr address, DSTAR_PROTOCOL protocol) :
CGatewayData(const wxString& gateway, in_addr address, DSTAR_PROTOCOL protocol, unsigned int g2Port) :
m_gateway(gateway),
m_address(address),
m_protocol(protocol)
m_protocol(protocol),
m_g2Port(g2Port)
{
}
@ -136,10 +144,16 @@ public:
return m_protocol;
}
unsigned int getG2Port() const
{
return m_g2Port;
}
private:
wxString m_gateway;
in_addr m_address;
DSTAR_PROTOCOL m_protocol;
unsigned int m_g2Port;
};
class CCacheManager {

View file

@ -43,6 +43,12 @@ void CGatewayCache::update(const wxString& gateway, const wxString& address, DST
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->getGateway().empty())
rec->setGateway(gateway);
}
if (rec == NULL)
// A brand new record is needed
m_cache[gateway] = new CGatewayRecord(gateway, addr_in, G2_DV_PORT, protocol, addrLock, protoLock);
@ -53,7 +59,7 @@ void CGatewayCache::update(const wxString& gateway, const wxString& address, DST
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
//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) {