Jelajahi Sumber

InputRoku: avoid enumerating network interfaces on every SSDP packet

This reduces network usage, _and_ improves the accuracy of our response.
Rodger Combs 7 tahun lalu
induk
melakukan
76f33f48e0
2 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 3 3
      src/input/InputRoku.cpp
  2. 1 1
      src/input/InputRoku.h

+ 3 - 3
src/input/InputRoku.cpp

@@ -66,11 +66,11 @@ void InputRoku::ssdpRead()
 void InputRoku::parseSSDPData(const QByteArray& data, const QHostAddress& sender, quint16 port)
 {
   if (data.contains("M-SEARCH * HTTP/1.1"))
-    m_ssdpSocket->writeDatagram(getSSDPPacket(), sender, port);
+    m_ssdpSocket->writeDatagram(getSSDPPacket(sender), sender, port);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-QByteArray InputRoku::getSSDPPacket()
+QByteArray InputRoku::getSSDPPacket(const QHostAddress& sender)
 {
   QByteArray packetData;
 
@@ -82,7 +82,7 @@ QByteArray InputRoku::getSSDPPacket()
   packetData.append("Server: Roku UPnP/1.0 MiniUPnPd/1.4\r\n");
 
   packetData.append("Location: http://");
-  packetData.append(Utils::PrimaryIPv4Address());
+  packetData.append(sender.toString());
   packetData.append(":8060/\r\n");
 
   packetData.append("USN: uuid:roku:ecp:");

+ 1 - 1
src/input/InputRoku.h

@@ -29,7 +29,7 @@ private:
 
   void ssdpRead();
   void parseSSDPData(const QByteArray& data, const QHostAddress& sender, quint16 port);
-  QByteArray getSSDPPacket();
+  QByteArray getSSDPPacket(const QHostAddress& sender);
   void handleRootInfo(qhttp::server::QHttpRequest* request, qhttp::server::QHttpResponse* response);
 };