Ticket #12084: backendserver_hostname.patch

File backendserver_hostname.patch, 1.1 KB (added by oncaphillis@…, 10 years ago)

Let MythCoreContext::GetBackendServerIP do gethostname

  • mythtv/libs/libmythbase/mythcorecontext.cpp

    diff --git a/mythtv/libs/libmythbase/mythcorecontext.cpp b/mythtv/libs/libmythbase/mythcorecontext.cpp
    index 2637544..4fe6840 100644
    a b  
    1212#include <QNetworkInterface>
    1313#include <QNetworkAddressEntry>
    1414#include <QLocale>
     15#include <netdb.h>
     16#include <sstream>
    1517
    1618#include <cmath>
    1719#include <cstdarg>
    QString MythCoreContext::GetBackendServerIP(const QString &host) 
    898900#endif
    899901    if (!ServerPool::DefaultListenIPv4().isEmpty())
    900902        addr4 = GetSettingOnHost("BackendServerIP", host, "");
     903    {
     904        hostent *h = ::gethostbyname(addr4.toAscii().data());
     905
     906        std::cerr << "H=" << h << std::endl;
     907
     908        if(h!=NULL)
     909        {
     910            unsigned char *addr = reinterpret_cast<unsigned char *>(h->h_addr_list[0]);
     911            std::stringstream ss;
     912            for(int i=0;i<4;i++)
     913            {
     914                ss << (i==0 ? "" : "." ) << (int)addr[i];
     915            }
     916            addr4 = QString::fromStdString(ss.str());
     917        }
     918    }
    901919
    902920    if (addr6.isEmpty())
    903921    {