mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2026-06-16 23:07:10 +02:00
Update POCO to 1.11.0
This commit is contained in:
+6
@@ -40,6 +40,12 @@ DatagramSocket::DatagramSocket(const SocketAddress& address, bool reuseAddress):
|
||||
}
|
||||
|
||||
|
||||
DatagramSocket::DatagramSocket(const SocketAddress& address, bool reuseAddress, bool reusePort): Socket(new DatagramSocketImpl(address.family()))
|
||||
{
|
||||
bind(address, reuseAddress, reusePort);
|
||||
}
|
||||
|
||||
|
||||
DatagramSocket::DatagramSocket(const Socket& socket): Socket(socket)
|
||||
{
|
||||
if (!dynamic_cast<DatagramSocketImpl*>(impl()))
|
||||
|
||||
+2
@@ -464,6 +464,7 @@ void HTTPClientSession::proxyAuthenticateImpl(HTTPRequest& request, const ProxyC
|
||||
_proxyDigestCreds.setPassword(proxyConfig.password);
|
||||
proxyAuthenticateDigest(request);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROXY_AUTH_NTLM:
|
||||
if (_ntlmProxyAuthenticated)
|
||||
@@ -478,6 +479,7 @@ void HTTPClientSession::proxyAuthenticateImpl(HTTPRequest& request, const ProxyC
|
||||
proxyAuthenticateNTLM(request);
|
||||
_ntlmProxyAuthenticated = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+27
-15
@@ -27,15 +27,20 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
HTTPSessionFactory::HTTPSessionFactory():
|
||||
_proxyPort(0)
|
||||
HTTPSessionFactory::HTTPSessionFactory()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
HTTPSessionFactory::HTTPSessionFactory(const std::string& proxyHost, Poco::UInt16 proxyPort):
|
||||
_proxyHost(proxyHost),
|
||||
_proxyPort(proxyPort)
|
||||
HTTPSessionFactory::HTTPSessionFactory(const std::string& proxyHost, Poco::UInt16 proxyPort)
|
||||
{
|
||||
_proxyConfig.host = proxyHost;
|
||||
_proxyConfig.port = proxyPort;
|
||||
}
|
||||
|
||||
|
||||
HTTPSessionFactory::HTTPSessionFactory(const HTTPClientSession::ProxyConfig& proxyConfig):
|
||||
_proxyConfig(proxyConfig)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,7 +60,7 @@ void HTTPSessionFactory::registerProtocol(const std::string& protocol, HTTPSessi
|
||||
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
std::pair<Instantiators::iterator, bool> tmp = _instantiators.insert(make_pair(protocol, InstantiatorInfo(pSessionInstantiator)));
|
||||
if (!tmp.second)
|
||||
if (!tmp.second)
|
||||
{
|
||||
++tmp.first->second.cnt;
|
||||
delete pSessionInstantiator;
|
||||
@@ -66,7 +71,7 @@ void HTTPSessionFactory::registerProtocol(const std::string& protocol, HTTPSessi
|
||||
void HTTPSessionFactory::unregisterProtocol(const std::string& protocol)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
|
||||
Instantiators::iterator it = _instantiators.find(protocol);
|
||||
if (it != _instantiators.end())
|
||||
{
|
||||
@@ -84,7 +89,7 @@ void HTTPSessionFactory::unregisterProtocol(const std::string& protocol)
|
||||
bool HTTPSessionFactory::supportsProtocol(const std::string& protocol)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
|
||||
Instantiators::iterator it = _instantiators.find(protocol);
|
||||
return it != _instantiators.end();
|
||||
}
|
||||
@@ -93,14 +98,13 @@ bool HTTPSessionFactory::supportsProtocol(const std::string& protocol)
|
||||
HTTPClientSession* HTTPSessionFactory::createClientSession(const Poco::URI& uri)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
|
||||
if (uri.isRelative()) throw Poco::UnknownURISchemeException("Relative URIs are not supported by HTTPSessionFactory.");
|
||||
|
||||
Instantiators::iterator it = _instantiators.find(uri.getScheme());
|
||||
if (it != _instantiators.end())
|
||||
{
|
||||
it->second.pIn->setProxy(_proxyHost, _proxyPort);
|
||||
it->second.pIn->setProxyCredentials(_proxyUsername, _proxyPassword);
|
||||
it->second.pIn->setProxyConfig(_proxyConfig);
|
||||
return it->second.pIn->createClientSession(uri);
|
||||
}
|
||||
else throw Poco::UnknownURISchemeException(uri.getScheme());
|
||||
@@ -111,8 +115,8 @@ void HTTPSessionFactory::setProxy(const std::string& host, Poco::UInt16 port)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
_proxyHost = host;
|
||||
_proxyPort = port;
|
||||
_proxyConfig.host = host;
|
||||
_proxyConfig.port = port;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,8 +124,16 @@ void HTTPSessionFactory::setProxyCredentials(const std::string& username, const
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
_proxyUsername = username;
|
||||
_proxyPassword = password;
|
||||
_proxyConfig.username = username;
|
||||
_proxyConfig.password = password;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSessionFactory::setProxyConfig(const HTTPClientSession::ProxyConfig& proxyConfig)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
_proxyConfig = proxyConfig;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+5
-14
@@ -24,8 +24,7 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
HTTPSessionInstantiator::HTTPSessionInstantiator():
|
||||
_proxyPort(0)
|
||||
HTTPSessionInstantiator::HTTPSessionInstantiator()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -39,10 +38,9 @@ HTTPClientSession* HTTPSessionInstantiator::createClientSession(const Poco::URI&
|
||||
{
|
||||
poco_assert (uri.getScheme() == "http");
|
||||
HTTPClientSession* pSession = new HTTPClientSession(uri.getHost(), uri.getPort());
|
||||
if (!proxyHost().empty())
|
||||
if (!getProxyConfig().host.empty())
|
||||
{
|
||||
pSession->setProxy(proxyHost(), proxyPort());
|
||||
pSession->setProxyCredentials(proxyUsername(), proxyPassword());
|
||||
pSession->setProxyConfig(getProxyConfig());
|
||||
}
|
||||
return pSession;
|
||||
}
|
||||
@@ -60,18 +58,11 @@ void HTTPSessionInstantiator::unregisterInstantiator()
|
||||
}
|
||||
|
||||
|
||||
void HTTPSessionInstantiator::setProxy(const std::string& host, Poco::UInt16 port)
|
||||
void HTTPSessionInstantiator::setProxyConfig(const HTTPClientSession::ProxyConfig& proxyConfig)
|
||||
{
|
||||
_proxyHost = host;
|
||||
_proxyPort = port;
|
||||
_proxyConfig = proxyConfig;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSessionInstantiator::setProxyCredentials(const std::string& username, const std::string& password)
|
||||
{
|
||||
_proxyUsername = username;
|
||||
_proxyPassword = password;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
Vendored
+6
-2
@@ -25,11 +25,11 @@ HostEntry::HostEntry()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
HostEntry::HostEntry(struct hostent* entry)
|
||||
{
|
||||
poco_check_ptr (entry);
|
||||
|
||||
|
||||
_name = entry->h_name;
|
||||
char** alias = entry->h_aliases;
|
||||
if (alias)
|
||||
@@ -40,6 +40,8 @@ HostEntry::HostEntry(struct hostent* entry)
|
||||
++alias;
|
||||
}
|
||||
}
|
||||
removeDuplicates(_aliases);
|
||||
|
||||
char** address = entry->h_addr_list;
|
||||
if (address)
|
||||
{
|
||||
@@ -49,6 +51,7 @@ HostEntry::HostEntry(struct hostent* entry)
|
||||
++address;
|
||||
}
|
||||
}
|
||||
removeDuplicates(_addresses);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +83,7 @@ HostEntry::HostEntry(struct addrinfo* ainfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
removeDuplicates(_addresses);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+15
-15
@@ -43,7 +43,7 @@ const UInt8 ICMPv4PacketImpl::TIME_EXCEEDED_TYPE = 11;
|
||||
const Poco::UInt8 ICMPv4PacketImpl::PARAMETER_PROBLEM_TYPE = 12;
|
||||
|
||||
|
||||
const std::string ICMPv4PacketImpl::MESSAGE_TYPE[] =
|
||||
const std::string ICMPv4PacketImpl::MESSAGE_TYPE[] =
|
||||
{
|
||||
"Echo Reply",
|
||||
"ICMP 1",
|
||||
@@ -66,7 +66,7 @@ const std::string ICMPv4PacketImpl::MESSAGE_TYPE[] =
|
||||
};
|
||||
|
||||
|
||||
const std::string ICMPv4PacketImpl::DESTINATION_UNREACHABLE_CODE[] =
|
||||
const std::string ICMPv4PacketImpl::DESTINATION_UNREACHABLE_CODE[] =
|
||||
{
|
||||
"Net unreachable",
|
||||
"Host unreachable",
|
||||
@@ -78,7 +78,7 @@ const std::string ICMPv4PacketImpl::DESTINATION_UNREACHABLE_CODE[] =
|
||||
};
|
||||
|
||||
|
||||
const std::string ICMPv4PacketImpl::REDIRECT_MESSAGE_CODE[] =
|
||||
const std::string ICMPv4PacketImpl::REDIRECT_MESSAGE_CODE[] =
|
||||
{
|
||||
"Redirect datagrams for the network",
|
||||
"Redirect datagrams for the host",
|
||||
@@ -88,7 +88,7 @@ const std::string ICMPv4PacketImpl::REDIRECT_MESSAGE_CODE[] =
|
||||
};
|
||||
|
||||
|
||||
const std::string ICMPv4PacketImpl::TIME_EXCEEDED_CODE[] =
|
||||
const std::string ICMPv4PacketImpl::TIME_EXCEEDED_CODE[] =
|
||||
{
|
||||
"Time to live exceeded in transit",
|
||||
"Fragment reassembly time exceeded",
|
||||
@@ -96,7 +96,7 @@ const std::string ICMPv4PacketImpl::TIME_EXCEEDED_CODE[] =
|
||||
};
|
||||
|
||||
|
||||
const std::string ICMPv4PacketImpl::PARAMETER_PROBLEM_CODE[] =
|
||||
const std::string ICMPv4PacketImpl::PARAMETER_PROBLEM_CODE[] =
|
||||
{
|
||||
"Pointer indicates the error",
|
||||
"Unknown code"
|
||||
@@ -156,8 +156,8 @@ struct timeval ICMPv4PacketImpl::time(Poco::UInt8* buffer, int length) const
|
||||
}
|
||||
else
|
||||
{
|
||||
struct timeval* ptv = (struct timeval*) data(buffer, length);
|
||||
if (ptv) tv = *ptv;
|
||||
struct timeval* ptv = reinterpret_cast<struct timeval*>(data(buffer, length));
|
||||
if (ptv) std::memcpy(&tv, ptv, sizeof(tv));
|
||||
else throw InvalidArgumentException("Invalid packet.");
|
||||
}
|
||||
return tv;
|
||||
@@ -172,13 +172,13 @@ ICMPv4PacketImpl::Header* ICMPv4PacketImpl::header(Poco::UInt8* buffer, int leng
|
||||
if ((offset + sizeof(Header)) > length) return 0;
|
||||
|
||||
buffer += offset;
|
||||
return (Header *) buffer;
|
||||
return reinterpret_cast<Header*>(buffer);
|
||||
}
|
||||
|
||||
|
||||
Poco::UInt8* ICMPv4PacketImpl::data(Poco::UInt8* buffer, int length) const
|
||||
{
|
||||
return ((Poco::UInt8*) header(buffer, length)) + sizeof(Header);
|
||||
return (reinterpret_cast<Poco::UInt8*>(header(buffer, length))) + sizeof(Header);
|
||||
}
|
||||
|
||||
|
||||
@@ -220,31 +220,31 @@ std::string ICMPv4PacketImpl::errorDescription(unsigned char* buffer, int length
|
||||
else
|
||||
err << DESTINATION_UNREACHABLE_CODE[DESTINATION_UNREACHABLE_UNKNOWN];
|
||||
break;
|
||||
|
||||
|
||||
case SOURCE_QUENCH_TYPE:
|
||||
err << "Source quench";
|
||||
break;
|
||||
|
||||
|
||||
case REDIRECT_MESSAGE_TYPE:
|
||||
if (code >= REDIRECT_NETWORK && code < REDIRECT_MESSAGE_UNKNOWN)
|
||||
if (code >= REDIRECT_NETWORK && code < REDIRECT_MESSAGE_UNKNOWN)
|
||||
err << REDIRECT_MESSAGE_CODE[code];
|
||||
else
|
||||
err << REDIRECT_MESSAGE_CODE[REDIRECT_MESSAGE_UNKNOWN];
|
||||
break;
|
||||
|
||||
case TIME_EXCEEDED_TYPE:
|
||||
if (code >= TIME_TO_LIVE || code < TIME_EXCEEDED_UNKNOWN)
|
||||
if (code >= TIME_TO_LIVE && code < TIME_EXCEEDED_UNKNOWN)
|
||||
err << TIME_EXCEEDED_CODE[code];
|
||||
else
|
||||
err << TIME_EXCEEDED_CODE[TIME_EXCEEDED_UNKNOWN];
|
||||
break;
|
||||
|
||||
|
||||
case PARAMETER_PROBLEM_TYPE:
|
||||
if (POINTER_INDICATES_THE_ERROR != code)
|
||||
code = PARAMETER_PROBLEM_UNKNOWN;
|
||||
err << PARAMETER_PROBLEM_CODE[code] << ": error in octet #" << pointer;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
err << "Unknown type.";
|
||||
break;
|
||||
|
||||
+5
@@ -12,6 +12,11 @@
|
||||
//
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_WINSOCK_DEPRECATED_NO_WARNINGS)
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
|
||||
#include "Poco/Net/IPAddressImpl.h"
|
||||
#include "Poco/Net/NetException.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
|
||||
+11
-2
@@ -38,6 +38,11 @@
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable:4996) // deprecation warnings
|
||||
#endif
|
||||
|
||||
|
||||
using Poco::NumberFormatter;
|
||||
using Poco::FastMutex;
|
||||
using Poco::format;
|
||||
@@ -238,8 +243,12 @@ NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& name,
|
||||
void NetworkInterfaceImpl::setPhyParams()
|
||||
{
|
||||
#if !defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_VXWORKS)
|
||||
struct ifreq ifr;
|
||||
std::strncpy(ifr.ifr_name, _name.c_str(), IFNAMSIZ);
|
||||
struct ifreq ifr{};
|
||||
std::size_t szFrom = _name.size();
|
||||
std::size_t szTo = IFNAMSIZ - 1;
|
||||
std::size_t sz = szFrom <= szTo ? szFrom : szTo;
|
||||
std::strncpy(ifr.ifr_name, _name.c_str(), sz);
|
||||
|
||||
DatagramSocket ds(SocketAddress::IPv4);
|
||||
|
||||
ds.impl()->ioctl(SIOCGIFFLAGS, &ifr);
|
||||
|
||||
Vendored
+65
-17
@@ -263,10 +263,8 @@ public:
|
||||
if (it->fd == fd)
|
||||
{
|
||||
it->events = 0;
|
||||
if (mode & PollSet::POLL_READ)
|
||||
it->events |= POLLIN;
|
||||
if (mode & PollSet::POLL_WRITE)
|
||||
it->events |= POLLOUT;
|
||||
it->revents = 0;
|
||||
setMode(it->fd, it->events, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,11 +305,7 @@ public:
|
||||
pfd.fd = it->first;
|
||||
pfd.events = 0;
|
||||
pfd.revents = 0;
|
||||
if (it->second & PollSet::POLL_READ)
|
||||
pfd.events |= POLLIN;
|
||||
if (it->second & PollSet::POLL_WRITE)
|
||||
pfd.events |= POLLOUT;
|
||||
|
||||
setMode(pfd.fd, pfd.events, it->second);
|
||||
_pollfds.push_back(pfd);
|
||||
}
|
||||
_addMap.clear();
|
||||
@@ -325,9 +319,15 @@ public:
|
||||
{
|
||||
Poco::Timestamp start;
|
||||
#ifdef _WIN32
|
||||
rc = WSAPoll(&_pollfds[0], static_cast<ULONG>(_pollfds.size()), static_cast<INT>(timeout.totalMilliseconds()));
|
||||
rc = WSAPoll(&_pollfds[0], static_cast<ULONG>(_pollfds.size()), static_cast<INT>(remainingTime.totalMilliseconds()));
|
||||
// see https://github.com/pocoproject/poco/issues/3248
|
||||
if ((remainingTime > 0) && (rc > 0) && !hasSignaledFDs())
|
||||
{
|
||||
rc = -1;
|
||||
WSASetLastError(WSAEINTR);
|
||||
}
|
||||
#else
|
||||
rc = ::poll(&_pollfds[0], _pollfds.size(), timeout.totalMilliseconds());
|
||||
rc = ::poll(&_pollfds[0], _pollfds.size(), remainingTime.totalMilliseconds());
|
||||
#endif
|
||||
if (rc < 0 && SocketImpl::lastError() == POCO_EINTR)
|
||||
{
|
||||
@@ -352,16 +352,20 @@ public:
|
||||
std::map<poco_socket_t, Socket>::const_iterator its = _socketMap.find(it->fd);
|
||||
if (its != _socketMap.end())
|
||||
{
|
||||
if (it->revents & POLLIN)
|
||||
if ((it->revents & POLLIN)
|
||||
#ifdef _WIN32
|
||||
|| (it->revents & POLLHUP)
|
||||
#endif
|
||||
)
|
||||
result[its->second] |= PollSet::POLL_READ;
|
||||
if (it->revents & POLLOUT)
|
||||
if ((it->revents & POLLOUT)
|
||||
#ifdef _WIN32
|
||||
&& (_wantPOLLOUT.find(it->fd) != _wantPOLLOUT.end())
|
||||
#endif
|
||||
)
|
||||
result[its->second] |= PollSet::POLL_WRITE;
|
||||
if (it->revents & POLLERR)
|
||||
result[its->second] |= PollSet::POLL_ERROR;
|
||||
#ifdef _WIN32
|
||||
if (it->revents & POLLHUP)
|
||||
result[its->second] |= PollSet::POLL_READ;
|
||||
#endif
|
||||
}
|
||||
it->revents = 0;
|
||||
}
|
||||
@@ -372,8 +376,52 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
void setMode(poco_socket_t fd, short& target, int mode)
|
||||
{
|
||||
if (mode & PollSet::POLL_READ)
|
||||
target |= POLLIN;
|
||||
|
||||
if (mode & PollSet::POLL_WRITE)
|
||||
_wantPOLLOUT.insert(fd);
|
||||
else
|
||||
_wantPOLLOUT.erase(fd);
|
||||
target |= POLLOUT;
|
||||
}
|
||||
|
||||
bool hasSignaledFDs()
|
||||
{
|
||||
for (const auto& pollfd : _pollfds)
|
||||
{
|
||||
if ((pollfd.revents | POLLOUT) &&
|
||||
(_wantPOLLOUT.find(pollfd.fd) != _wantPOLLOUT.end()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void setMode(poco_socket_t fd, short& target, int mode)
|
||||
{
|
||||
if (mode & PollSet::POLL_READ)
|
||||
target |= POLLIN;
|
||||
|
||||
if (mode & PollSet::POLL_WRITE)
|
||||
target |= POLLOUT;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
mutable Poco::FastMutex _mutex;
|
||||
std::map<poco_socket_t, Socket> _socketMap;
|
||||
#ifdef _WIN32
|
||||
std::set<poco_socket_t> _wantPOLLOUT;
|
||||
#endif
|
||||
std::map<poco_socket_t, int> _addMap;
|
||||
std::set<poco_socket_t> _removeSet;
|
||||
std::vector<pollfd> _pollfds;
|
||||
|
||||
+17
@@ -16,6 +16,7 @@
|
||||
#include "Poco/Message.h"
|
||||
#include "Poco/DateTimeFormatter.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
#include "Poco/NumberParser.h"
|
||||
#include "Poco/Net/SocketAddress.h"
|
||||
#include "Poco/Net/DNS.h"
|
||||
#include "Poco/LoggingFactory.h"
|
||||
@@ -34,6 +35,7 @@ const std::string RemoteSyslogChannel::PROP_FACILITY("facility");
|
||||
const std::string RemoteSyslogChannel::PROP_FORMAT("format");
|
||||
const std::string RemoteSyslogChannel::PROP_LOGHOST("loghost");
|
||||
const std::string RemoteSyslogChannel::PROP_HOST("host");
|
||||
const std::string RemoteSyslogChannel::PROP_BUFFER("buffer");
|
||||
const std::string RemoteSyslogChannel::STRUCTURED_DATA("structured-data");
|
||||
|
||||
|
||||
@@ -42,6 +44,7 @@ RemoteSyslogChannel::RemoteSyslogChannel():
|
||||
_name("-"),
|
||||
_facility(SYSLOG_USER),
|
||||
_bsdFormat(false),
|
||||
_buffer(0),
|
||||
_open(false)
|
||||
{
|
||||
}
|
||||
@@ -52,6 +55,7 @@ RemoteSyslogChannel::RemoteSyslogChannel(const std::string& address, const std::
|
||||
_name(name),
|
||||
_facility(facility),
|
||||
_bsdFormat(bsdFormat),
|
||||
_buffer(0),
|
||||
_open(false)
|
||||
{
|
||||
if (_name.empty()) _name = "-";
|
||||
@@ -95,6 +99,11 @@ void RemoteSyslogChannel::open()
|
||||
}
|
||||
}
|
||||
|
||||
if (_buffer)
|
||||
{
|
||||
_socket.setSendBufferSize(_buffer);
|
||||
}
|
||||
|
||||
_open = true;
|
||||
}
|
||||
|
||||
@@ -233,6 +242,10 @@ void RemoteSyslogChannel::setProperty(const std::string& name, const std::string
|
||||
{
|
||||
_bsdFormat = (value == "bsd" || value == "rfc3164");
|
||||
}
|
||||
else if (name == PROP_BUFFER)
|
||||
{
|
||||
_buffer = Poco::NumberParser::parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Channel::setProperty(name, value);
|
||||
@@ -314,6 +327,10 @@ std::string RemoteSyslogChannel::getProperty(const std::string& name) const
|
||||
{
|
||||
return _bsdFormat ? "rfc3164" : "rfc5424";
|
||||
}
|
||||
else if (name == PROP_BUFFER)
|
||||
{
|
||||
return Poco::NumberFormatter::format(_buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Channel::getProperty(name);
|
||||
|
||||
+55
-20
@@ -52,21 +52,21 @@ public:
|
||||
_sourceAddress(sourceAddress)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
~MessageNotification()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const std::string& message() const
|
||||
{
|
||||
return _message;
|
||||
}
|
||||
|
||||
|
||||
const Poco::Net::SocketAddress& sourceAddress() const
|
||||
{
|
||||
return _sourceAddress;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
std::string _message;
|
||||
Poco::Net::SocketAddress _sourceAddress;
|
||||
@@ -86,8 +86,8 @@ public:
|
||||
WAITTIME_MILLISEC = 1000,
|
||||
BUFFER_SIZE = 65536
|
||||
};
|
||||
|
||||
RemoteUDPListener(Poco::NotificationQueue& queue, Poco::UInt16 port);
|
||||
|
||||
RemoteUDPListener(Poco::NotificationQueue& queue, Poco::UInt16 port, bool reusePort, int buffer);
|
||||
~RemoteUDPListener();
|
||||
|
||||
void run();
|
||||
@@ -100,11 +100,15 @@ private:
|
||||
};
|
||||
|
||||
|
||||
RemoteUDPListener::RemoteUDPListener(Poco::NotificationQueue& queue, Poco::UInt16 port):
|
||||
RemoteUDPListener::RemoteUDPListener(Poco::NotificationQueue& queue, Poco::UInt16 port, bool reusePort, int buffer):
|
||||
_queue(queue),
|
||||
_socket(Poco::Net::SocketAddress(Poco::Net::IPAddress(), port)),
|
||||
_socket(Poco::Net::SocketAddress(Poco::Net::IPAddress(), port), false, reusePort),
|
||||
_stopped(false)
|
||||
{
|
||||
if (buffer > 0)
|
||||
{
|
||||
_socket.setReceiveBufferSize(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +256,7 @@ void SyslogParser::parse(const std::string& line, Poco::Message& message)
|
||||
// the next field decide if we parse an old BSD message or a new syslog message
|
||||
// BSD: expects a month value in string form: Jan, Feb...
|
||||
// SYSLOG expects a version number: 1
|
||||
|
||||
|
||||
if (Poco::Ascii::isDigit(line[pos]))
|
||||
{
|
||||
parseNew(line, severity, fac, pos, message);
|
||||
@@ -271,10 +275,10 @@ void SyslogParser::parsePrio(const std::string& line, std::size_t& pos, RemoteSy
|
||||
poco_assert (line[pos] == '<');
|
||||
++pos;
|
||||
std::size_t start = pos;
|
||||
|
||||
|
||||
while (pos < line.size() && Poco::Ascii::isDigit(line[pos]))
|
||||
++pos;
|
||||
|
||||
|
||||
poco_assert (line[pos] == '>');
|
||||
poco_assert (pos - start > 0);
|
||||
std::string valStr = line.substr(start, pos - start);
|
||||
@@ -282,7 +286,7 @@ void SyslogParser::parsePrio(const std::string& line, std::size_t& pos, RemoteSy
|
||||
|
||||
int val = Poco::NumberParser::parse(valStr);
|
||||
poco_assert (val >= 0 && val <= (RemoteSyslogChannel::SYSLOG_LOCAL7 + RemoteSyslogChannel::SYSLOG_DEBUG));
|
||||
|
||||
|
||||
Poco::UInt16 pri = static_cast<Poco::UInt16>(val);
|
||||
// now get the lowest 3 bits
|
||||
severity = static_cast<RemoteSyslogChannel::Severity>(pri & 0x0007u);
|
||||
@@ -311,7 +315,7 @@ void SyslogParser::parseNew(const std::string& line, RemoteSyslogChannel::Severi
|
||||
logEntry[RemoteSyslogListener::LOG_PROP_HOST] = hostName;
|
||||
logEntry[RemoteSyslogListener::LOG_PROP_APP] = appName;
|
||||
logEntry[RemoteSyslogListener::LOG_PROP_STRUCTURED_DATA] = sd;
|
||||
|
||||
|
||||
if (hasDate)
|
||||
logEntry.setTime(date.timestamp());
|
||||
int lval(0);
|
||||
@@ -406,7 +410,7 @@ std::string SyslogParser::parseStructuredData(const std::string& line, std::size
|
||||
std::string sd;
|
||||
if (pos < line.size())
|
||||
{
|
||||
if (line[pos] == '-')
|
||||
if (line[pos] == '-')
|
||||
{
|
||||
++pos;
|
||||
}
|
||||
@@ -493,7 +497,9 @@ Poco::Message::Priority SyslogParser::convert(RemoteSyslogChannel::Severity seve
|
||||
|
||||
|
||||
const std::string RemoteSyslogListener::PROP_PORT("port");
|
||||
const std::string RemoteSyslogListener::PROP_REUSE_PORT("reusePort");
|
||||
const std::string RemoteSyslogListener::PROP_THREADS("threads");
|
||||
const std::string RemoteSyslogListener::PROP_BUFFER("buffer");
|
||||
|
||||
const std::string RemoteSyslogListener::LOG_PROP_APP("app");
|
||||
const std::string RemoteSyslogListener::LOG_PROP_HOST("host");
|
||||
@@ -504,7 +510,9 @@ RemoteSyslogListener::RemoteSyslogListener():
|
||||
_pListener(0),
|
||||
_pParser(0),
|
||||
_port(RemoteSyslogChannel::SYSLOG_PORT),
|
||||
_threads(1)
|
||||
_reusePort(false),
|
||||
_threads(1),
|
||||
_buffer(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -513,7 +521,9 @@ RemoteSyslogListener::RemoteSyslogListener(Poco::UInt16 port):
|
||||
_pListener(0),
|
||||
_pParser(0),
|
||||
_port(port),
|
||||
_threads(1)
|
||||
_reusePort(false),
|
||||
_threads(1),
|
||||
_buffer(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -522,7 +532,20 @@ RemoteSyslogListener::RemoteSyslogListener(Poco::UInt16 port, int threads):
|
||||
_pListener(0),
|
||||
_pParser(0),
|
||||
_port(port),
|
||||
_threads(threads)
|
||||
_reusePort(false),
|
||||
_threads(threads),
|
||||
_buffer(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RemoteSyslogListener::RemoteSyslogListener(Poco::UInt16 port, bool reusePort, int threads):
|
||||
_pListener(0),
|
||||
_pParser(0),
|
||||
_port(port),
|
||||
_reusePort(reusePort),
|
||||
_threads(threads),
|
||||
_buffer(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -556,6 +579,10 @@ void RemoteSyslogListener::setProperty(const std::string& name, const std::strin
|
||||
else
|
||||
throw Poco::InvalidArgumentException("Not a valid port number", value);
|
||||
}
|
||||
else if (name == PROP_REUSE_PORT)
|
||||
{
|
||||
_reusePort = Poco::NumberParser::parseBool(value);
|
||||
}
|
||||
else if (name == PROP_THREADS)
|
||||
{
|
||||
int val = Poco::NumberParser::parse(value);
|
||||
@@ -564,7 +591,11 @@ void RemoteSyslogListener::setProperty(const std::string& name, const std::strin
|
||||
else
|
||||
throw Poco::InvalidArgumentException("Invalid number of threads", value);
|
||||
}
|
||||
else
|
||||
else if (name == PROP_BUFFER)
|
||||
{
|
||||
_buffer = Poco::NumberParser::parse(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
SplitterChannel::setProperty(name, value);
|
||||
}
|
||||
@@ -575,9 +606,13 @@ std::string RemoteSyslogListener::getProperty(const std::string& name) const
|
||||
{
|
||||
if (name == PROP_PORT)
|
||||
return Poco::NumberFormatter::format(_port);
|
||||
else if (name == PROP_REUSE_PORT)
|
||||
return Poco::NumberFormatter::format(_reusePort);
|
||||
else if (name == PROP_THREADS)
|
||||
return Poco::NumberFormatter::format(_threads);
|
||||
else
|
||||
else if (name == PROP_BUFFER)
|
||||
return Poco::NumberFormatter::format(_buffer);
|
||||
else
|
||||
return SplitterChannel::getProperty(name);
|
||||
}
|
||||
|
||||
@@ -588,7 +623,7 @@ void RemoteSyslogListener::open()
|
||||
_pParser = new SyslogParser(_queue, this);
|
||||
if (_port > 0)
|
||||
{
|
||||
_pListener = new RemoteUDPListener(_queue, _port);
|
||||
_pListener = new RemoteUDPListener(_queue, _port, _reusePort, _buffer);
|
||||
}
|
||||
for (int i = 0; i < _threads; i++)
|
||||
{
|
||||
|
||||
+3
@@ -419,6 +419,7 @@ void SMTPClientSession::sendCommands(const MailMessage& message, const Recipient
|
||||
std::ostringstream recipient;
|
||||
if (pRecipients)
|
||||
{
|
||||
if (pRecipients->empty()) throw Poco::InvalidArgumentException("attempting to send message with empty recipients list");
|
||||
for (const auto& rec: *pRecipients)
|
||||
{
|
||||
recipient << '<' << rec << '>';
|
||||
@@ -429,6 +430,7 @@ void SMTPClientSession::sendCommands(const MailMessage& message, const Recipient
|
||||
}
|
||||
else
|
||||
{
|
||||
if (message.recipients().empty()) throw Poco::InvalidArgumentException("attempting to send message with empty recipients list");
|
||||
for (const auto& rec: message.recipients())
|
||||
{
|
||||
recipient << '<' << rec.getAddress() << '>';
|
||||
@@ -465,6 +467,7 @@ void SMTPClientSession::sendAddresses(const std::string& from, const Recipients&
|
||||
|
||||
std::ostringstream recipient;
|
||||
|
||||
if (recipients.empty()) throw Poco::InvalidArgumentException("attempting to send message with empty recipients list");
|
||||
for (const auto& rec: recipients)
|
||||
{
|
||||
recipient << '<' << rec << '>';
|
||||
|
||||
Vendored
+5
@@ -51,6 +51,11 @@
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable:4996) // deprecation warnings
|
||||
#endif
|
||||
|
||||
|
||||
using Poco::IOException;
|
||||
using Poco::TimeoutException;
|
||||
using Poco::InvalidArgumentException;
|
||||
|
||||
+7
-1
@@ -50,6 +50,11 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class StopNotification: public Notification
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
TCPServerDispatcher::TCPServerDispatcher(TCPServerConnectionFactory::Ptr pFactory, Poco::ThreadPool& threadPool, TCPServerParams::Ptr pParams):
|
||||
_rc(1),
|
||||
_pParams(pParams),
|
||||
@@ -166,9 +171,10 @@ void TCPServerDispatcher::enqueue(const StreamSocket& socket)
|
||||
|
||||
void TCPServerDispatcher::stop()
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
_stopped = true;
|
||||
_queue.clear();
|
||||
_queue.wakeUpAll();
|
||||
_queue.enqueueNotification(new StopNotification);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
+1
@@ -236,6 +236,7 @@ WebSocketImpl* WebSocket::completeHandshake(HTTPClientSession& cs, HTTPResponse&
|
||||
std::string WebSocket::createKey()
|
||||
{
|
||||
Poco::Random rnd;
|
||||
rnd.seed();
|
||||
std::ostringstream ostr;
|
||||
Poco::Base64Encoder base64(ostr);
|
||||
Poco::BinaryWriter writer(base64);
|
||||
|
||||
+2
@@ -203,6 +203,7 @@ int WebSocketImpl::receiveBytes(void* buffer, int length, int)
|
||||
{
|
||||
char mask[4];
|
||||
bool useMask;
|
||||
_frameFlags = 0;
|
||||
int payloadLength = receiveHeader(mask, useMask);
|
||||
if (payloadLength <= 0)
|
||||
return payloadLength;
|
||||
@@ -216,6 +217,7 @@ int WebSocketImpl::receiveBytes(Poco::Buffer<char>& buffer, int, const Poco::Tim
|
||||
{
|
||||
char mask[4];
|
||||
bool useMask;
|
||||
_frameFlags = 0;
|
||||
int payloadLength = receiveHeader(mask, useMask);
|
||||
if (payloadLength <= 0)
|
||||
return payloadLength;
|
||||
|
||||
Reference in New Issue
Block a user