[Libreoffice-commits] online.git: loolwsd/Storage.cpp

Andras Timar andras.timar at collabora.com
Tue Apr 19 13:32:55 UTC 2016


 loolwsd/Storage.cpp |   23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 090c246be46c6590c080d6aeccf55f8e4d772578
Author: Andras Timar <andras.timar at collabora.com>
Date:   Tue Apr 19 15:32:22 2016 +0200

    bccu#1696 - enable WOPI connection from the same host (by IP address) by default

diff --git a/loolwsd/Storage.cpp b/loolwsd/Storage.cpp
index 39ec21e..62a0ead 100644
--- a/loolwsd/Storage.cpp
+++ b/loolwsd/Storage.cpp
@@ -96,7 +96,24 @@ void StorageBase::initialize()
 
 bool isLocalhost(const std::string& targetHost)
 {
-    std::string targetAddress = Poco::Net::DNS::resolveOne(targetHost).toString();
+    std::string targetAddress;
+    try
+    {
+        targetAddress = Poco::Net::DNS::resolveOne(targetHost).toString();
+    }
+    catch (const Poco::Exception& exc)
+    {
+        Log::warn("Poco::Net::DNS::resolveOne(\"" + targetHost + "\") failed: " + exc.displayText());
+        try
+        {
+            targetAddress = Poco::Net::IPAddress(targetHost).toString();
+        }
+        catch (const Poco::Exception& exc1)
+        {
+            Log::warn("Poco::Net::IPAddress(\"" + targetHost + "\") failed: " + exc1.displayText());
+        }
+    }
+
     Poco::Net::NetworkInterface::NetworkInterfaceList list = Poco::Net::NetworkInterface::list(true,true);
     for (unsigned i = 0; i < list.size(); i++)
     {
@@ -104,8 +121,12 @@ bool isLocalhost(const std::string& targetHost)
         std::string address = netif.address().toString();
         address = address.substr(0, address.find("%",0));
         if (address == targetAddress)
+        {
+            Log::info("WOPI host is on the same host as the WOPI client: \"" + targetAddress + "\". Connection is allowed.");
             return true;
+        }
     }
+    Log::info("WOPI host is not on the same host as the WOPI client: \"" + targetAddress + "\". Connection is not allowed.");
     return false;
 }
 


More information about the Libreoffice-commits mailing list