[Libreoffice-commits] online.git: 5 commits - net/ServerSocket.hpp tools/Tool.cpp wsd/LOOLWSD.cpp
Tor Lillqvist
tml at collabora.com
Tue Jul 10 20:15:23 UTC 2018
net/ServerSocket.hpp | 14 +++++++-------
tools/Tool.cpp | 6 +++---
wsd/LOOLWSD.cpp | 2 +-
3 files changed, 11 insertions(+), 11 deletions(-)
New commits:
commit bc0f76d6ad173f7b58035203e6af561a29b8285a
Author: Tor Lillqvist <tml at collabora.com>
Date: Tue Jul 10 23:14:16 2018 +0300
It's /lool/convert-to, not /convert-to
(But it doesn't seem to work anyway any more.)
Change-Id: I53261cd24d945dc47e156ff16240679beeb85f6a
diff --git a/tools/Tool.cpp b/tools/Tool.cpp
index 5d7aaa9b1..f056ddb91 100644
--- a/tools/Tool.cpp
+++ b/tools/Tool.cpp
@@ -101,7 +101,7 @@ public:
else
session = new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort());
- Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, "/convert-to");
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, "/lool/convert-to");
try {
Poco::Net::HTMLForm form;
commit 32036fcadf23ce7dea586e834be6a4364e3d256c
Author: Tor Lillqvist <tml at collabora.com>
Date: Tue Jul 10 23:10:19 2018 +0300
We can pass a std::string directly to LOG_ERR()
Change-Id: I10027e680ad009eb04e44913323ca91c61821b87
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index b7a954869..93bd56e3f 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2029,7 +2029,7 @@ private:
if (!allowPostFrom(socket->clientAddress()))
{
- LOG_ERR("client address DENY: " << socket->clientAddress().c_str());
+ LOG_ERR("client address DENY: " << socket->clientAddress());
std::ostringstream oss;
oss << "HTTP/1.1 403\r\n"
commit a97c8c3455b6f0da1c96674ff6be0d8a133d0d3c
Author: Tor Lillqvist <tml at collabora.com>
Date: Tue Jul 10 22:50:11 2018 +0300
Fis our use of inet_ntop() etc
We had:
auto ipv4 = (struct sockaddr_in *)&clientInfo.sin_addr
even if the clientInfo variable itself was a struct sockaddr_in.
And then we also had:
auto ipv6 = (struct sockaddr_in6 *)&clientInfo.sin_addr
which makes even less sense.
Instead, make clientInfo into a struct sockaddr_in6, which is big
enough to also to be interpreted as a sockaddr_in. Pass the address of
the correct field, either sin_addr or sin6_addr, to inet_ntop(). (Note
that sin_addr in sockaddr_in has a different offset than sin6_addr in
sockaddr_in6.)
At least on my Fedora 28, when I connect using IPv4, accept4() still
returns the client address as an IPv4 mapped IPv6 address, that is
::ffff:192.168.1.113 for 192.168.1.113. So the sample
net.post_allow.host value in loolwsd.xml.in should probably be changed
to have that ::ffff: prefix, too.
Change-Id: I0ad774616b210d94b904982e2f7dc928adc879ed
diff --git a/net/ServerSocket.hpp b/net/ServerSocket.hpp
index afd4b97f4..f0ad38ad3 100644
--- a/net/ServerSocket.hpp
+++ b/net/ServerSocket.hpp
@@ -61,8 +61,8 @@ public:
{
// Accept a connection (if any) and set it to non-blocking.
// There still need the client's address to filter request from POST(call from REST) here.
- struct sockaddr_in clientInfo;
- socklen_t addrlen = sizeof(struct sockaddr_in);
+ struct sockaddr_in6 clientInfo;
+ socklen_t addrlen = sizeof(clientInfo);
const int rc = ::accept4(getFD(), (struct sockaddr *)&clientInfo, &addrlen, SOCK_NONBLOCK);
LOG_DBG("Accepted socket #" << rc << ", creating socket object.");
try
@@ -73,21 +73,21 @@ public:
char addrstr[INET6_ADDRSTRLEN];
const void *inAddr;
- if (clientInfo.sin_family == AF_INET)
+ if (clientInfo.sin6_family == AF_INET)
{
- auto ipv4 = (struct sockaddr_in *)&clientInfo.sin_addr;
+ auto ipv4 = (struct sockaddr_in *)&clientInfo;
inAddr = &(ipv4->sin_addr);
}
else
{
- auto ipv6 = (struct sockaddr_in6 *)&clientInfo.sin_addr;
+ auto ipv6 = (struct sockaddr_in6 *)&clientInfo;
inAddr = &(ipv6->sin6_addr);
}
- inet_ntop(clientInfo.sin_family, inAddr, addrstr, sizeof(addrstr));
+ inet_ntop(clientInfo.sin6_family, inAddr, addrstr, sizeof(addrstr));
std::shared_ptr<Socket> _socket = _sockFactory->create(rc);
_socket->_clientAddress = addrstr;
- LOG_DBG("Accepted socket has family " << clientInfo.sin_family <<
+ LOG_DBG("Accepted socket has family " << clientInfo.sin6_family <<
" address " << _socket->_clientAddress);
return _socket;
}
commit 73dbf27ede697344c9dcc607321ae4b0b77d03fa
Author: Tor Lillqvist <tml at collabora.com>
Date: Tue Jul 10 21:22:07 2018 +0300
The std::string compare() method is like strcmp(): it returns 0 on equality
Change-Id: I4d080afd98419cbdaa531cc6f2c306533bbc1737
diff --git a/tools/Tool.cpp b/tools/Tool.cpp
index 92819eb74..5d7aaa9b1 100644
--- a/tools/Tool.cpp
+++ b/tools/Tool.cpp
@@ -96,7 +96,7 @@ public:
Poco::URI uri(_app._serverURI);
Poco::Net::HTTPClientSession *session;
- if (_app._serverURI.compare(0, 5, "https"))
+ if (_app._serverURI.compare(0, 5, "https") == 0)
session = new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort());
else
session = new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort());
commit c783485a3b4979af540b08d186aaca101679a175
Author: Tor Lillqvist <tml at collabora.com>
Date: Tue Jul 10 21:15:47 2018 +0300
The option is called "server" and not "uri"
(It's the parameter of that option that is called "uri".)
Change-Id: If247a932bf8879b4eb626d850e813c3e8d5a7d60
diff --git a/tools/Tool.cpp b/tools/Tool.cpp
index 14d6f3fc8..92819eb74 100644
--- a/tools/Tool.cpp
+++ b/tools/Tool.cpp
@@ -208,7 +208,7 @@ void Tool::handleOption(const std::string& optionName,
_destinationDir = value;
else if (optionName == "parallelism")
_numWorkers = std::max(std::stoi(value), 1);
- else if (optionName == "uri")
+ else if (optionName == "server")
_serverURI = value;
else if (optionName == "no-check-certificate")
{
More information about the Libreoffice-commits
mailing list