diff --git a/Common/CacheManager.cpp b/Common/CacheManager.cpp index a9dbe1b..682ad58 100644 --- a/Common/CacheManager.cpp +++ b/Common/CacheManager.cpp @@ -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) diff --git a/Common/CacheManager.h b/Common/CacheManager.h index 2226aee..dc38392 100644 --- a/Common/CacheManager.h +++ b/Common/CacheManager.h @@ -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 { diff --git a/Common/GatewayCache.cpp b/Common/GatewayCache.cpp index 83bc62a..436817b 100644 --- a/Common/GatewayCache.cpp +++ b/Common/GatewayCache.cpp @@ -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) {