mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-16 15:17:13 +02:00
Update POCO to 1.11.0
This commit is contained in:
@ -55,6 +55,13 @@ public:
|
||||
/// Depending on the address family, the socket
|
||||
/// will be either an IPv4 or an IPv6 socket.
|
||||
|
||||
DatagramSocket(const SocketAddress& address, bool reuseAddress, bool reusePort);
|
||||
/// Creates a datagram socket and binds it
|
||||
/// to the given address.
|
||||
///
|
||||
/// Depending on the address family, the socket
|
||||
/// will be either an IPv4 or an IPv6 socket.
|
||||
|
||||
DatagramSocket(const Socket& socket);
|
||||
/// Creates the DatagramSocket with the SocketImpl
|
||||
/// from another socket. The SocketImpl must be
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
void setContentType(const std::string& mediaType);
|
||||
/// Sets the content type for this message.
|
||||
///
|
||||
/// Specify NO_CONTENT_TYPE to remove the
|
||||
/// Specify UNKNOWN_CONTENT_TYPE to remove the
|
||||
/// Content-Type header.
|
||||
|
||||
void setContentType(const MediaType& mediaType);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include "Poco/Net/Net.h"
|
||||
#include "Poco/Net/HTTPClientSession.h"
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/URI.h"
|
||||
#include "Poco/SingletonHolder.h"
|
||||
@ -31,7 +32,6 @@ namespace Net {
|
||||
|
||||
|
||||
class HTTPSessionInstantiator;
|
||||
class HTTPClientSession;
|
||||
|
||||
|
||||
class Net_API HTTPSessionFactory
|
||||
@ -52,6 +52,9 @@ public:
|
||||
HTTPSessionFactory(const std::string& proxyHost, Poco::UInt16 proxyPort);
|
||||
/// Creates the HTTPSessionFactory and sets the proxy host and port.
|
||||
|
||||
HTTPSessionFactory(const HTTPClientSession::ProxyConfig& proxyConfig);
|
||||
/// Creates the HTTPSessionFactory and sets the proxy configuration.
|
||||
|
||||
~HTTPSessionFactory();
|
||||
/// Destroys the HTTPSessionFactory.
|
||||
|
||||
@ -78,22 +81,28 @@ public:
|
||||
|
||||
const std::string& proxyHost() const;
|
||||
/// Returns the proxy host, if one has been set, or an empty string otherwise.
|
||||
|
||||
|
||||
Poco::UInt16 proxyPort() const;
|
||||
/// Returns the proxy port number, if one has been set, or zero otherwise.
|
||||
|
||||
void setProxy(const std::string& proxyHost, Poco::UInt16 proxyPort);
|
||||
/// Sets the proxy host and port number.
|
||||
|
||||
|
||||
void setProxyCredentials(const std::string& username, const std::string& password);
|
||||
/// Sets the username and password for proxy authorization (Basic auth only).
|
||||
|
||||
const std::string& proxyUsername() const;
|
||||
/// Returns the username for proxy authorization.
|
||||
|
||||
|
||||
const std::string& proxyPassword() const;
|
||||
/// Returns the password for proxy authorization.
|
||||
|
||||
void setProxyConfig(const HTTPClientSession::ProxyConfig& proxyConfig);
|
||||
/// Sets the proxy configuration.
|
||||
|
||||
const HTTPClientSession::ProxyConfig& getProxyConfig() const;
|
||||
/// Returns the proxy configuration.
|
||||
|
||||
static HTTPSessionFactory& defaultFactory();
|
||||
/// Returns the default HTTPSessionFactory.
|
||||
|
||||
@ -109,14 +118,11 @@ private:
|
||||
|
||||
HTTPSessionFactory(const HTTPSessionFactory&);
|
||||
HTTPSessionFactory& operator = (const HTTPSessionFactory&);
|
||||
|
||||
|
||||
typedef std::map<std::string, InstantiatorInfo> Instantiators;
|
||||
|
||||
Instantiators _instantiators;
|
||||
std::string _proxyHost;
|
||||
Poco::UInt16 _proxyPort;
|
||||
std::string _proxyUsername;
|
||||
std::string _proxyPassword;
|
||||
HTTPClientSession::ProxyConfig _proxyConfig;
|
||||
|
||||
mutable Poco::FastMutex _mutex;
|
||||
};
|
||||
@ -127,25 +133,31 @@ private:
|
||||
//
|
||||
inline const std::string& HTTPSessionFactory::proxyHost() const
|
||||
{
|
||||
return _proxyHost;
|
||||
return _proxyConfig.host;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::UInt16 HTTPSessionFactory::proxyPort() const
|
||||
{
|
||||
return _proxyPort;
|
||||
return _proxyConfig.port;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HTTPSessionFactory::proxyUsername() const
|
||||
{
|
||||
return _proxyUsername;
|
||||
return _proxyConfig.username;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HTTPSessionFactory::proxyPassword() const
|
||||
{
|
||||
return _proxyPassword;
|
||||
return _proxyConfig.password;
|
||||
}
|
||||
|
||||
|
||||
inline const HTTPClientSession::ProxyConfig& HTTPSessionFactory::getProxyConfig() const
|
||||
{
|
||||
return _proxyConfig;
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
#include "Poco/Net/Net.h"
|
||||
#include "Poco/Net/HTTPSession.h"
|
||||
#include "Poco/Net/HTTPClientSession.h"
|
||||
#include "Poco/URI.h"
|
||||
|
||||
|
||||
@ -27,9 +27,6 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
class HTTPClientSession;
|
||||
|
||||
|
||||
class Net_API HTTPSessionInstantiator
|
||||
/// A factory for HTTPClientSession objects.
|
||||
///
|
||||
@ -55,31 +52,15 @@ public:
|
||||
/// Unregisters the factory with the global HTTPSessionFactory.
|
||||
|
||||
protected:
|
||||
void setProxy(const std::string& host, Poco::UInt16 port);
|
||||
/// Sets the proxy host and port.
|
||||
/// Called by HTTPSessionFactory.
|
||||
|
||||
const std::string& proxyHost() const;
|
||||
/// Returns the proxy post.
|
||||
void setProxyConfig(const HTTPClientSession::ProxyConfig& proxyConfig);
|
||||
/// Sets the proxy configuration.
|
||||
|
||||
Poco::UInt16 proxyPort() const;
|
||||
/// Returns the proxy port.
|
||||
|
||||
void setProxyCredentials(const std::string& username, const std::string& password);
|
||||
/// Sets the username and password for proxy authorization (Basic auth only).
|
||||
|
||||
const std::string& proxyUsername() const;
|
||||
/// Returns the username for proxy authorization.
|
||||
|
||||
const std::string& proxyPassword() const;
|
||||
/// Returns the password for proxy authorization.
|
||||
const HTTPClientSession::ProxyConfig& getProxyConfig() const;
|
||||
/// Returns the proxy configuration.
|
||||
|
||||
private:
|
||||
std::string _proxyHost;
|
||||
Poco::UInt16 _proxyPort;
|
||||
std::string _proxyUsername;
|
||||
std::string _proxyPassword;
|
||||
|
||||
HTTPClientSession::ProxyConfig _proxyConfig;
|
||||
|
||||
friend class HTTPSessionFactory;
|
||||
};
|
||||
|
||||
@ -87,27 +68,9 @@ private:
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const std::string& HTTPSessionInstantiator::proxyHost() const
|
||||
inline const HTTPClientSession::ProxyConfig& HTTPSessionInstantiator::getProxyConfig() const
|
||||
{
|
||||
return _proxyHost;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::UInt16 HTTPSessionInstantiator::proxyPort() const
|
||||
{
|
||||
return _proxyPort;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HTTPSessionInstantiator::proxyUsername() const
|
||||
{
|
||||
return _proxyUsername;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HTTPSessionInstantiator::proxyPassword() const
|
||||
{
|
||||
return _proxyPassword;
|
||||
return _proxyConfig;
|
||||
}
|
||||
|
||||
|
||||
|
8
vendor/POCO/Net/include/Poco/Net/HostEntry.h
vendored
8
vendor/POCO/Net/include/Poco/Net/HostEntry.h
vendored
@ -76,6 +76,14 @@ public:
|
||||
/// for the host.
|
||||
|
||||
private:
|
||||
template <typename C>
|
||||
void removeDuplicates(C& list)
|
||||
{
|
||||
std::sort(list.begin(), list.end());
|
||||
auto last = std::unique(list.begin(), list.end());
|
||||
list.erase(last, list.end());
|
||||
}
|
||||
|
||||
std::string _name;
|
||||
AliasList _aliases;
|
||||
AddressList _addresses;
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
|
||||
virtual int packetSize() const = 0;
|
||||
/// Returns the total size of packet (ICMP header + data) in number of octets.
|
||||
/// Must be overriden.
|
||||
/// Must be overridden.
|
||||
|
||||
virtual int maxPacketSize() const;
|
||||
/// Returns the maximum permitted size of packet in number of octets.
|
||||
@ -60,16 +60,16 @@ public:
|
||||
virtual struct timeval time(Poco::UInt8* buffer = 0, int length = 0) const = 0;
|
||||
/// Returns current epoch time if either argument is equal to zero.
|
||||
/// Otherwise, it extracts the time value from the supplied buffer.
|
||||
///
|
||||
///
|
||||
/// Supplied buffer includes IP header, ICMP header and data.
|
||||
/// Must be overriden.
|
||||
/// Must be overridden.
|
||||
|
||||
virtual bool validReplyID(unsigned char* buffer, int length) const = 0;
|
||||
/// Returns true if the extracted id is recognized
|
||||
/// Returns true if the extracted id is recognized
|
||||
/// (i.e. equals the process id).
|
||||
///
|
||||
///
|
||||
/// Supplied buffer includes IP header, ICMP header and data.
|
||||
/// Must be overriden.
|
||||
/// Must be overridden.
|
||||
|
||||
virtual std::string errorDescription(Poco::UInt8* buffer, int length, int& type, int& code) = 0;
|
||||
/// Returns error description string.
|
||||
@ -79,11 +79,11 @@ public:
|
||||
/// assigned to the type and code respectively.
|
||||
///
|
||||
/// Supplied buffer includes IP header, ICMP header and data.
|
||||
/// Must be overriden.
|
||||
/// Must be overridden.
|
||||
|
||||
virtual std::string typeDescription(int typeId) = 0;
|
||||
/// Returns the description of the packet type.
|
||||
/// Must be overriden.
|
||||
/// Must be overridden.
|
||||
|
||||
static const Poco::UInt16 MAX_PACKET_SIZE;
|
||||
static const Poco::UInt16 MAX_PAYLOAD_SIZE;
|
||||
@ -98,7 +98,7 @@ protected:
|
||||
|
||||
virtual void initPacket() = 0;
|
||||
/// (Re)assembles the packet.
|
||||
/// Must be overriden.
|
||||
/// Must be overridden.
|
||||
|
||||
Poco::UInt16 checksum(Poco::UInt16 *addr, Poco::Int32 len);
|
||||
/// Calculates the checksum for supplied buffer.
|
||||
@ -107,7 +107,7 @@ private:
|
||||
Poco::UInt16 _seq;
|
||||
Poco::UInt8* _pPacket;
|
||||
int _dataSize;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -61,7 +61,6 @@ public:
|
||||
#define POCO_RESTORE_TIMESTAMP_REQUEST
|
||||
#undef TIMESTAMP_REQUEST
|
||||
#endif
|
||||
|
||||
enum MessageType
|
||||
{
|
||||
ECHO_REPLY,
|
||||
@ -84,9 +83,8 @@ public:
|
||||
MESSAGE_TYPE_UNKNOWN, // non-standard default, must remain last but one
|
||||
MESSAGE_TYPE_LENGTH // length indicator, must remain last
|
||||
};
|
||||
|
||||
#if defined(POCO_RESTORE_TIMESTAMP_REQUEST)
|
||||
#pragma pop_macro("TIMESTAMP_REQUEST")
|
||||
#pragma pop_macro("TIMESTAMP_REQUEST")
|
||||
#undef POCO_RESTORE_TIMESTAMP_REQUEST
|
||||
#endif
|
||||
|
||||
|
@ -124,6 +124,7 @@ public:
|
||||
/// by a colon) can also be specified.
|
||||
/// * host: (optional) Host name included in syslog messages. If not specified, the host's real domain name or
|
||||
/// IP address will be used.
|
||||
/// * buffer: UDP socket send buffer size in bytes. If not specified, the system default is used.
|
||||
|
||||
std::string getProperty(const std::string& name) const;
|
||||
/// Returns the value of the property with the given name.
|
||||
@ -136,6 +137,7 @@ public:
|
||||
static const std::string PROP_FORMAT;
|
||||
static const std::string PROP_LOGHOST;
|
||||
static const std::string PROP_HOST;
|
||||
static const std::string PROP_BUFFER;
|
||||
static const std::string STRUCTURED_DATA;
|
||||
|
||||
protected:
|
||||
@ -148,6 +150,7 @@ private:
|
||||
std::string _host;
|
||||
int _facility;
|
||||
bool _bsdFormat;
|
||||
int _buffer;
|
||||
DatagramSocket _socket;
|
||||
SocketAddress _socketAddress;
|
||||
bool _open;
|
||||
|
@ -63,6 +63,13 @@ public:
|
||||
/// Creates the RemoteSyslogListener, listening on the given port number
|
||||
/// and using the number of threads for message processing.
|
||||
|
||||
RemoteSyslogListener(Poco::UInt16 port, bool reusePort, int threads);
|
||||
/// Creates the RemoteSyslogListener, listening on the given port number
|
||||
/// and using the number of threads for message processing.
|
||||
///
|
||||
/// If reusePort is true, the underlying UDP socket will bind
|
||||
/// with the reusePort flag set.
|
||||
|
||||
void setProperty(const std::string& name, const std::string& value);
|
||||
/// Sets the property with the given value.
|
||||
///
|
||||
@ -70,9 +77,13 @@ public:
|
||||
/// * port: The UDP port number where to listen for UDP packets
|
||||
/// containing syslog messages. If 0 is specified, does not
|
||||
/// listen for UDP messages.
|
||||
/// * reusePort: If set to true, allows multiple instances
|
||||
/// binding to the same port number.
|
||||
/// * threads: The number of parser threads processing
|
||||
/// received syslog messages. Defaults to 1. A maximum
|
||||
/// of 16 threads is supported.
|
||||
/// * buffer: The UDP socket receive buffer size in bytes. If not
|
||||
/// specified, the system default is used.
|
||||
|
||||
std::string getProperty(const std::string& name) const;
|
||||
/// Returns the value of the property with the given name.
|
||||
@ -95,7 +106,9 @@ public:
|
||||
/// Registers the channel with the global LoggingFactory.
|
||||
|
||||
static const std::string PROP_PORT;
|
||||
static const std::string PROP_REUSE_PORT;
|
||||
static const std::string PROP_THREADS;
|
||||
static const std::string PROP_BUFFER;
|
||||
|
||||
static const std::string LOG_PROP_APP;
|
||||
static const std::string LOG_PROP_HOST;
|
||||
@ -111,7 +124,9 @@ private:
|
||||
Poco::ThreadPool _threadPool;
|
||||
Poco::NotificationQueue _queue;
|
||||
Poco::UInt16 _port;
|
||||
bool _reusePort;
|
||||
int _threads;
|
||||
int _buffer;
|
||||
};
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace Net {
|
||||
struct NTLMContextImpl;
|
||||
|
||||
|
||||
class NTLMContext
|
||||
class Net_API NTLMContext
|
||||
/// An opaque context class for working with SSPI NTLM authentication.
|
||||
{
|
||||
public:
|
||||
@ -49,7 +49,7 @@ private:
|
||||
NTLMContext();
|
||||
NTLMContext(const NTLMContext&);
|
||||
NTLMContext& operator = (const NTLMContext&);
|
||||
|
||||
|
||||
friend class SSPINTLMProvider;
|
||||
};
|
||||
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
/// If reuseAddress is true, sets the SO_REUSEADDR
|
||||
/// socket option.
|
||||
|
||||
virtual void bind(const SocketAddress& address, bool reuseAddress, bool reusePort );
|
||||
virtual void bind(const SocketAddress& address, bool reuseAddress, bool reusePort);
|
||||
/// Bind a local address to the socket.
|
||||
///
|
||||
/// This is usually only done when establishing a server
|
||||
@ -115,7 +115,7 @@ public:
|
||||
/// If the library has not been built with IPv6 support,
|
||||
/// a Poco::NotImplementedException will be thrown.
|
||||
|
||||
virtual void bind6(const SocketAddress& address, bool reuseAddress, bool reusePort, bool ipV6Only);
|
||||
virtual void bind6(const SocketAddress& address, bool reuseAddress, bool reusePort, bool ipV6Only);
|
||||
/// Bind a local IPv6 address to the socket.
|
||||
///
|
||||
/// This is usually only done when establishing a server
|
||||
|
2
vendor/POCO/Net/include/Poco/Net/UDPClient.h
vendored
2
vendor/POCO/Net/include/Poco/Net/UDPClient.h
vendored
@ -65,7 +65,7 @@ public:
|
||||
|
||||
virtual int handleResponse(char* buffer, int length);
|
||||
/// Handles responses from UDP server. For non-POCO UDP servers,
|
||||
/// this function should be overriden in inheriting class.
|
||||
/// this function should be overridden in inheriting class.
|
||||
|
||||
void setOption(int opt, int val);
|
||||
/// Sets socket option.
|
||||
|
@ -313,7 +313,7 @@ public:
|
||||
virtual void processData(char*)
|
||||
/// Caled when data is received by reader.
|
||||
///
|
||||
/// No-op here, must be overriden by inheriting
|
||||
/// No-op here, must be overridden by inheriting
|
||||
/// class in order to do useful work.
|
||||
{
|
||||
};
|
||||
@ -322,7 +322,7 @@ public:
|
||||
/// Caled when error is detected by reader.
|
||||
///
|
||||
/// Only functional if stream pointer is provided
|
||||
/// to the handler, otherwise it must be overriden
|
||||
/// to the handler, otherwise it must be overridden
|
||||
/// by inheriting class in order to do useful work.
|
||||
{
|
||||
if (_pErr) *_pErr << error(buf) << std::endl;
|
||||
|
18
vendor/POCO/Net/include/Poco/Net/WebSocket.h
vendored
18
vendor/POCO/Net/include/Poco/Net/WebSocket.h
vendored
@ -150,6 +150,9 @@ public:
|
||||
///
|
||||
/// The result of the handshake can be obtained from the response
|
||||
/// object.
|
||||
///
|
||||
/// The HTTPClientSession session object must no longer be used after setting
|
||||
/// up the WebSocket.
|
||||
|
||||
WebSocket(HTTPClientSession& cs, HTTPRequest& request, HTTPResponse& response, HTTPCredentials& credentials);
|
||||
/// Creates a client-side WebSocket, using the given
|
||||
@ -165,6 +168,9 @@ public:
|
||||
///
|
||||
/// The result of the handshake can be obtained from the response
|
||||
/// object.
|
||||
///
|
||||
/// The HTTPClientSession session object must no longer be used after setting
|
||||
/// up the WebSocket.
|
||||
|
||||
WebSocket(const Socket& socket);
|
||||
/// Creates a WebSocket from another Socket, which must be a WebSocket,
|
||||
@ -218,9 +224,11 @@ public:
|
||||
/// A WebSocketException will also be thrown if a malformed
|
||||
/// or incomplete frame is received.
|
||||
///
|
||||
/// Returns the number of bytes received.
|
||||
/// A return value of 0 means that the peer has
|
||||
/// Returns the number of payload bytes received.
|
||||
/// A return value of 0, with flags also 0, means that the peer has
|
||||
/// shut down or closed the connection.
|
||||
/// A return value of 0, with non-zero flags, indicates an
|
||||
/// reception of an empty frame (e.g., in case of a PING).
|
||||
///
|
||||
/// Throws a TimeoutException if a receive timeout has
|
||||
/// been set and nothing is received within that interval.
|
||||
@ -248,9 +256,11 @@ public:
|
||||
/// DoS attack (memory exhaustion) by sending a WebSocket frame
|
||||
/// header with a huge payload size.
|
||||
///
|
||||
/// Returns the number of bytes received.
|
||||
/// A return value of 0 means that the peer has
|
||||
/// Returns the number of payload bytes received.
|
||||
/// A return value of 0, with flags also 0, means that the peer has
|
||||
/// shut down or closed the connection.
|
||||
/// A return value of 0, with non-zero flags, indicates an
|
||||
/// reception of an empty frame (e.g., in case of a PING).
|
||||
///
|
||||
/// Throws a TimeoutException if a receive timeout has
|
||||
/// been set and nothing is received within that interval.
|
||||
|
6
vendor/POCO/Net/src/DatagramSocket.cpp
vendored
6
vendor/POCO/Net/src/DatagramSocket.cpp
vendored
@ -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
vendor/POCO/Net/src/HTTPClientSession.cpp
vendored
2
vendor/POCO/Net/src/HTTPClientSession.cpp
vendored
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
42
vendor/POCO/Net/src/HTTPSessionFactory.cpp
vendored
42
vendor/POCO/Net/src/HTTPSessionFactory.cpp
vendored
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
19
vendor/POCO/Net/src/HTTPSessionInstantiator.cpp
vendored
19
vendor/POCO/Net/src/HTTPSessionInstantiator.cpp
vendored
@ -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
|
||||
|
8
vendor/POCO/Net/src/HostEntry.cpp
vendored
8
vendor/POCO/Net/src/HostEntry.cpp
vendored
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
30
vendor/POCO/Net/src/ICMPv4PacketImpl.cpp
vendored
30
vendor/POCO/Net/src/ICMPv4PacketImpl.cpp
vendored
@ -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
vendor/POCO/Net/src/IPAddressImpl.cpp
vendored
5
vendor/POCO/Net/src/IPAddressImpl.cpp
vendored
@ -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"
|
||||
|
13
vendor/POCO/Net/src/NetworkInterface.cpp
vendored
13
vendor/POCO/Net/src/NetworkInterface.cpp
vendored
@ -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);
|
||||
|
82
vendor/POCO/Net/src/PollSet.cpp
vendored
82
vendor/POCO/Net/src/PollSet.cpp
vendored
@ -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
vendor/POCO/Net/src/RemoteSyslogChannel.cpp
vendored
17
vendor/POCO/Net/src/RemoteSyslogChannel.cpp
vendored
@ -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);
|
||||
|
75
vendor/POCO/Net/src/RemoteSyslogListener.cpp
vendored
75
vendor/POCO/Net/src/RemoteSyslogListener.cpp
vendored
@ -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
vendor/POCO/Net/src/SMTPClientSession.cpp
vendored
3
vendor/POCO/Net/src/SMTPClientSession.cpp
vendored
@ -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 << '>';
|
||||
|
5
vendor/POCO/Net/src/SocketImpl.cpp
vendored
5
vendor/POCO/Net/src/SocketImpl.cpp
vendored
@ -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;
|
||||
|
8
vendor/POCO/Net/src/TCPServerDispatcher.cpp
vendored
8
vendor/POCO/Net/src/TCPServerDispatcher.cpp
vendored
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
1
vendor/POCO/Net/src/WebSocket.cpp
vendored
1
vendor/POCO/Net/src/WebSocket.cpp
vendored
@ -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
vendor/POCO/Net/src/WebSocketImpl.cpp
vendored
2
vendor/POCO/Net/src/WebSocketImpl.cpp
vendored
@ -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;
|
||||
|
11
vendor/POCO/Net/testsuite/src/DNSTest.cpp
vendored
11
vendor/POCO/Net/testsuite/src/DNSTest.cpp
vendored
@ -88,6 +88,17 @@ void DNSTest::testHostByAddress()
|
||||
|
||||
void DNSTest::testResolve()
|
||||
{
|
||||
HostEntry he1 = DNS::hostByName("localhost");
|
||||
|
||||
auto a = he1.addresses();
|
||||
sort(a.begin(), a.end());
|
||||
auto itA = std::unique(a.begin(), a.end());
|
||||
assertTrue (itA == a.end());
|
||||
|
||||
auto b = he1.aliases();
|
||||
sort(b.begin(), b.end());
|
||||
auto itB = std::unique(b.begin(), b.end());
|
||||
assertTrue (itB == b.end());
|
||||
}
|
||||
|
||||
|
||||
|
19
vendor/POCO/Net/testsuite/src/EchoServer.cpp
vendored
19
vendor/POCO/Net/testsuite/src/EchoServer.cpp
vendored
@ -23,7 +23,8 @@ using Poco::Net::SocketAddress;
|
||||
EchoServer::EchoServer():
|
||||
_socket(SocketAddress()),
|
||||
_thread("EchoServer"),
|
||||
_stop(false)
|
||||
_stop(false),
|
||||
_done(false)
|
||||
{
|
||||
_thread.start(*this);
|
||||
_ready.wait();
|
||||
@ -33,7 +34,8 @@ EchoServer::EchoServer():
|
||||
EchoServer::EchoServer(const Poco::Net::SocketAddress& address):
|
||||
_socket(address),
|
||||
_thread("EchoServer"),
|
||||
_stop(false)
|
||||
_stop(false),
|
||||
_done(false)
|
||||
{
|
||||
_thread.start(*this);
|
||||
_ready.wait();
|
||||
@ -78,5 +80,18 @@ void EchoServer::run()
|
||||
}
|
||||
}
|
||||
}
|
||||
_done = true;
|
||||
}
|
||||
|
||||
|
||||
void EchoServer::stop()
|
||||
{
|
||||
_stop = true;
|
||||
}
|
||||
|
||||
|
||||
bool EchoServer::done()
|
||||
{
|
||||
return _done;
|
||||
}
|
||||
|
||||
|
11
vendor/POCO/Net/testsuite/src/EchoServer.h
vendored
11
vendor/POCO/Net/testsuite/src/EchoServer.h
vendored
@ -36,15 +36,22 @@ public:
|
||||
Poco::UInt16 port() const;
|
||||
/// Returns the port the echo server is
|
||||
/// listening on.
|
||||
|
||||
|
||||
void run();
|
||||
/// Does the work.
|
||||
|
||||
|
||||
void stop();
|
||||
/// Sets the stop flag.
|
||||
|
||||
bool done();
|
||||
/// Retruns true if if server is done.
|
||||
|
||||
private:
|
||||
Poco::Net::ServerSocket _socket;
|
||||
Poco::Thread _thread;
|
||||
Poco::Event _ready;
|
||||
bool _stop;
|
||||
bool _done;
|
||||
};
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ void MulticastSocketTest::testMulticast()
|
||||
assertTrue (std::string(buffer, n) == "hello");
|
||||
ms.close();
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
|
@ -75,7 +75,7 @@ void NetworkInterfaceTest::testMap()
|
||||
std::cout << "=============" << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -119,7 +119,7 @@ void NetworkInterfaceTest::testList()
|
||||
std::cout << "==============" << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -139,7 +139,7 @@ void NetworkInterfaceTest::testForName()
|
||||
assertTrue (ifc.name() == it->second.name());
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -184,7 +184,7 @@ void NetworkInterfaceTest::testForAddress()
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -204,7 +204,7 @@ void NetworkInterfaceTest::testForIndex()
|
||||
assertTrue (ifc.index() == it->second.index());
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -231,7 +231,7 @@ void NetworkInterfaceTest::testMapIpOnly()
|
||||
std::cout << "MAC Address:" << mac << std::endl;
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -251,7 +251,7 @@ void NetworkInterfaceTest::testMapUpOnly()
|
||||
assertTrue (it->second.isUp());
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -298,7 +298,7 @@ void NetworkInterfaceTest::testListMapConformance()
|
||||
|
||||
assertTrue (counter == l.size());
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
|
77
vendor/POCO/Net/testsuite/src/PollSetTest.cpp
vendored
77
vendor/POCO/Net/testsuite/src/PollSetTest.cpp
vendored
@ -28,6 +28,7 @@ using Poco::Net::ConnectionRefusedException;
|
||||
using Poco::Net::PollSet;
|
||||
using Poco::Timespan;
|
||||
using Poco::Stopwatch;
|
||||
using Poco::Thread;
|
||||
|
||||
|
||||
PollSetTest::PollSetTest(const std::string& name): CppUnit::TestCase(name)
|
||||
@ -76,7 +77,7 @@ void PollSetTest::testPoll()
|
||||
assertTrue (sm.find(ss1) != sm.end());
|
||||
assertTrue (sm.find(ss2) == sm.end());
|
||||
assertTrue (sm.find(ss1)->second == PollSet::POLL_WRITE);
|
||||
assertTrue (sw.elapsed() < 100000);
|
||||
assertTrue (sw.elapsed() < 1100000);
|
||||
|
||||
ps.update(ss1, PollSet::POLL_READ);
|
||||
|
||||
@ -87,7 +88,7 @@ void PollSetTest::testPoll()
|
||||
assertTrue (sm.find(ss1) != sm.end());
|
||||
assertTrue (sm.find(ss2) == sm.end());
|
||||
assertTrue (sm.find(ss1)->second == PollSet::POLL_READ);
|
||||
assertTrue (sw.elapsed() < 100000);
|
||||
assertTrue (sw.elapsed() < 1100000);
|
||||
|
||||
int n = ss1.receiveBytes(buffer, sizeof(buffer));
|
||||
assertTrue (n == 5);
|
||||
@ -100,7 +101,7 @@ void PollSetTest::testPoll()
|
||||
assertTrue (sm.find(ss1) == sm.end());
|
||||
assertTrue (sm.find(ss2) != sm.end());
|
||||
assertTrue (sm.find(ss2)->second == PollSet::POLL_READ);
|
||||
assertTrue (sw.elapsed() < 100000);
|
||||
assertTrue (sw.elapsed() < 1100000);
|
||||
|
||||
n = ss2.receiveBytes(buffer, sizeof(buffer));
|
||||
assertTrue (n == 5);
|
||||
@ -125,6 +126,74 @@ void PollSetTest::testPoll()
|
||||
}
|
||||
|
||||
|
||||
void PollSetTest::testPollNoServer()
|
||||
{
|
||||
#ifndef POCO_OS_FAMILY_WINDOWS
|
||||
StreamSocket ss1;
|
||||
StreamSocket ss2;
|
||||
|
||||
ss1.connectNB(SocketAddress("127.0.0.1", 0xFEFE));
|
||||
ss2.connectNB(SocketAddress("127.0.0.1", 0xFEFF));
|
||||
PollSet ps;
|
||||
assertTrue(ps.empty());
|
||||
ps.add(ss1, PollSet::POLL_READ);
|
||||
ps.add(ss2, PollSet::POLL_READ);
|
||||
assertTrue(!ps.empty());
|
||||
assertTrue(ps.has(ss1));
|
||||
assertTrue(ps.has(ss2));
|
||||
PollSet::SocketModeMap sm;
|
||||
Stopwatch sw; sw.start();
|
||||
do
|
||||
{
|
||||
sm = ps.poll(Timespan(1000000));
|
||||
if (sw.elapsedSeconds() > 10) fail();
|
||||
} while (sm.size() < 2);
|
||||
assertTrue(sm.size() == 2);
|
||||
for (auto s : sm)
|
||||
assertTrue(0 != (s.second | PollSet::POLL_ERROR));
|
||||
#endif // POCO_OS_FAMILY_WINDOWS
|
||||
}
|
||||
|
||||
|
||||
void PollSetTest::testPollClosedServer()
|
||||
{
|
||||
#ifndef POCO_OS_FAMILY_WINDOWS
|
||||
EchoServer echoServer1;
|
||||
EchoServer echoServer2;
|
||||
StreamSocket ss1;
|
||||
StreamSocket ss2;
|
||||
|
||||
ss1.connect(SocketAddress("127.0.0.1", echoServer1.port()));
|
||||
ss2.connect(SocketAddress("127.0.0.1", echoServer2.port()));
|
||||
|
||||
PollSet ps;
|
||||
assertTrue(ps.empty());
|
||||
ps.add(ss1, PollSet::POLL_READ);
|
||||
ps.add(ss2, PollSet::POLL_READ);
|
||||
assertTrue(!ps.empty());
|
||||
assertTrue(ps.has(ss1));
|
||||
assertTrue(ps.has(ss2));
|
||||
|
||||
echoServer1.stop();
|
||||
ss1.sendBytes("HELLO", 5);
|
||||
while (!echoServer1.done()) Thread::sleep(10);
|
||||
echoServer2.stop();
|
||||
ss2.sendBytes("HELLO", 5);
|
||||
while (!echoServer2.done()) Thread::sleep(10);
|
||||
PollSet::SocketModeMap sm;
|
||||
Stopwatch sw; sw.start();
|
||||
do
|
||||
{
|
||||
sm = ps.poll(Timespan(1000000));
|
||||
if (sw.elapsedSeconds() > 10) fail();
|
||||
} while (sm.size() < 2);
|
||||
assertTrue(sm.size() == 2);
|
||||
assertTrue(0 == ss1.receiveBytes(0, 0));
|
||||
assertTrue(0 == ss2.receiveBytes(0, 0));
|
||||
#endif // POCO_OS_FAMILY_WINDOWS
|
||||
}
|
||||
|
||||
|
||||
void PollSetTest::setUp()
|
||||
{
|
||||
}
|
||||
@ -140,6 +209,8 @@ CppUnit::Test* PollSetTest::suite()
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("PollSetTest");
|
||||
|
||||
CppUnit_addTest(pSuite, PollSetTest, testPoll);
|
||||
CppUnit_addTest(pSuite, PollSetTest, testPollNoServer);
|
||||
CppUnit_addTest(pSuite, PollSetTest, testPollClosedServer);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
2
vendor/POCO/Net/testsuite/src/PollSetTest.h
vendored
2
vendor/POCO/Net/testsuite/src/PollSetTest.h
vendored
@ -25,6 +25,8 @@ public:
|
||||
~PollSetTest();
|
||||
|
||||
void testPoll();
|
||||
void testPollNoServer();
|
||||
void testPollClosedServer();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
@ -119,7 +119,7 @@ void SocketAddressTest::testSocketAddress()
|
||||
}
|
||||
|
||||
SocketAddress sa10("www6.pocoproject.org", 80);
|
||||
assertTrue (sa10.host().toString() == "54.93.62.90" || sa10.host().toString() == "[2001:4801:7828:101:be76:4eff:fe10:1455]");
|
||||
assertTrue (sa10.host().toString() == "54.93.62.90" || sa10.host().toString() == "2001:4801:7828:101:be76:4eff:fe10:1455");
|
||||
|
||||
SocketAddress sa11(SocketAddress::IPv4, "www6.pocoproject.org", 80);
|
||||
assertTrue (sa11.host().toString() == "54.93.62.90");
|
||||
|
@ -324,6 +324,7 @@ namespace
|
||||
_data.resize(1);
|
||||
_reactor.addEventHandler(_socket, Observer<DataServiceHandler, ReadableNotification>(*this, &DataServiceHandler::onReadable));
|
||||
_reactor.addEventHandler(_socket, Observer<DataServiceHandler, ShutdownNotification>(*this, &DataServiceHandler::onShutdown));
|
||||
_socket.setBlocking(false);
|
||||
}
|
||||
|
||||
~DataServiceHandler()
|
||||
@ -336,28 +337,32 @@ namespace
|
||||
{
|
||||
pNf->release();
|
||||
char buffer[64];
|
||||
int n = _socket.receiveBytes(&buffer[0], sizeof(buffer));
|
||||
if (n > 0)
|
||||
int n = 0;
|
||||
do
|
||||
{
|
||||
_data[_pos].append(buffer, n);
|
||||
std::size_t pos;
|
||||
pos = _data[_pos].find('\n');
|
||||
if(pos != std::string::npos)
|
||||
n = _socket.receiveBytes(&buffer[0], sizeof(buffer));
|
||||
if (n > 0)
|
||||
{
|
||||
if (pos == _data[_pos].size() - 1)
|
||||
_data[_pos].append(buffer, n);
|
||||
std::size_t pos;
|
||||
pos = _data[_pos].find('\n');
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
_data[_pos].erase(pos, 1);
|
||||
_data.push_back(std::string());
|
||||
if (pos == _data[_pos].size() - 1)
|
||||
{
|
||||
_data[_pos].erase(pos, 1);
|
||||
_data.push_back(std::string());
|
||||
}
|
||||
else
|
||||
{
|
||||
_data.push_back(_data[_pos].substr(pos + 1));
|
||||
_data[_pos].erase(pos);
|
||||
}
|
||||
++_pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
_data.push_back(_data[_pos].substr(pos + 1));
|
||||
_data[_pos].erase(pos);
|
||||
}
|
||||
++_pos;
|
||||
}
|
||||
}
|
||||
else return;
|
||||
else break;
|
||||
} while (true);
|
||||
}
|
||||
|
||||
void onShutdown(ShutdownNotification* pNf)
|
||||
@ -500,7 +505,6 @@ void SocketReactorTest::testDataCollection()
|
||||
" \"data\":123"
|
||||
"}\n");
|
||||
sock.sendBytes(data0.data(), static_cast<int>(data0.size()));
|
||||
|
||||
std::string data1("{"
|
||||
" \"src\":\"127.0.0.1\","
|
||||
" \"id\":\"test1\","
|
||||
@ -517,7 +521,6 @@ void SocketReactorTest::testDataCollection()
|
||||
" ]"
|
||||
"}\n");
|
||||
sock.sendBytes(data1.data(), static_cast<int>(data1.size()));
|
||||
|
||||
std::string data2 = "{"
|
||||
" \"src\":\"127.0.0.1\","
|
||||
" \"id\":\"test2\","
|
||||
|
Reference in New Issue
Block a user