17#ifndef Net_SocketDefs_INCLUDED
18#define Net_SocketDefs_INCLUDED
27#if defined(POCO_OS_FAMILY_WINDOWS
)
28 #include "Poco/UnWindows.h"
32 #define POCO_INVALID_SOCKET INVALID_SOCKET
33 #define poco_socket_t SOCKET
34 #define poco_socklen_t int
35 #define poco_ioctl_request_t int
36 #define poco_closesocket(s) closesocket(s)
37 #define POCO_EINTR WSAEINTR
38 #define POCO_EACCES WSAEACCES
39 #define POCO_EFAULT WSAEFAULT
40 #define POCO_EINVAL WSAEINVAL
41 #define POCO_EMFILE WSAEMFILE
42 #define POCO_EAGAIN WSAEWOULDBLOCK
43 #define POCO_EWOULDBLOCK WSAEWOULDBLOCK
44 #define POCO_EINPROGRESS WSAEINPROGRESS
45 #define POCO_EALREADY WSAEALREADY
46 #define POCO_ENOTSOCK WSAENOTSOCK
47 #define POCO_EDESTADDRREQ WSAEDESTADDRREQ
48 #define POCO_EMSGSIZE WSAEMSGSIZE
49 #define POCO_EPROTOTYPE WSAEPROTOTYPE
50 #define POCO_ENOPROTOOPT WSAENOPROTOOPT
51 #define POCO_EPROTONOSUPPORT WSAEPROTONOSUPPORT
52 #define POCO_ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
53 #define POCO_ENOTSUP WSAEOPNOTSUPP
54 #define POCO_EPFNOSUPPORT WSAEPFNOSUPPORT
55 #define POCO_EAFNOSUPPORT WSAEAFNOSUPPORT
56 #define POCO_EADDRINUSE WSAEADDRINUSE
57 #define POCO_EADDRNOTAVAIL WSAEADDRNOTAVAIL
58 #define POCO_ENETDOWN WSAENETDOWN
59 #define POCO_ENETUNREACH WSAENETUNREACH
60 #define POCO_ENETRESET WSAENETRESET
61 #define POCO_ECONNABORTED WSAECONNABORTED
62 #define POCO_ECONNRESET WSAECONNRESET
63 #define POCO_ENOBUFS WSAENOBUFS
64 #define POCO_EISCONN WSAEISCONN
65 #define POCO_ENOTCONN WSAENOTCONN
66 #define POCO_ESHUTDOWN WSAESHUTDOWN
67 #define POCO_ETIMEDOUT WSAETIMEDOUT
68 #define POCO_ECONNREFUSED WSAECONNREFUSED
69 #define POCO_EHOSTDOWN WSAEHOSTDOWN
70 #define POCO_EHOSTUNREACH WSAEHOSTUNREACH
71 #define POCO_ESYSNOTREADY WSASYSNOTREADY
72 #define POCO_ENOTINIT WSANOTINITIALISED
73 #define POCO_HOST_NOT_FOUND WSAHOST_NOT_FOUND
74 #define POCO_TRY_AGAIN WSATRY_AGAIN
75 #define POCO_NO_RECOVERY WSANO_RECOVERY
76 #define POCO_NO_DATA WSANO_DATA
77 #ifndef ADDRESS_FAMILY
78 #define ADDRESS_FAMILY USHORT
80#elif defined(POCO_VXWORKS)
85 #include <resolvLib.h>
88 #include <netinet/tcp.h>
89 #define POCO_INVALID_SOCKET -1
90 #define poco_socket_t int
91 #define poco_socklen_t int
92 #define poco_ioctl_request_t int
93 #define poco_closesocket(s) ::close(s)
94 #define POCO_EINTR EINTR
95 #define POCO_EACCES EACCES
96 #define POCO_EFAULT EFAULT
97 #define POCO_EINVAL EINVAL
98 #define POCO_EMFILE EMFILE
99 #define POCO_EAGAIN EAGAIN
100 #define POCO_EWOULDBLOCK EWOULDBLOCK
101 #define POCO_EINPROGRESS EINPROGRESS
102 #define POCO_EALREADY EALREADY
103 #define POCO_ENOTSOCK ENOTSOCK
104 #define POCO_EDESTADDRREQ EDESTADDRREQ
105 #define POCO_EMSGSIZE EMSGSIZE
106 #define POCO_EPROTOTYPE EPROTOTYPE
107 #define POCO_ENOPROTOOPT ENOPROTOOPT
108 #define POCO_EPROTONOSUPPORT EPROTONOSUPPORT
109 #define POCO_ESOCKTNOSUPPORT ESOCKTNOSUPPORT
110 #define POCO_ENOTSUP ENOTSUP
111 #define POCO_EPFNOSUPPORT EPFNOSUPPORT
112 #define POCO_EAFNOSUPPORT EAFNOSUPPORT
113 #define POCO_EADDRINUSE EADDRINUSE
114 #define POCO_EADDRNOTAVAIL EADDRNOTAVAIL
115 #define POCO_ENETDOWN ENETDOWN
116 #define POCO_ENETUNREACH ENETUNREACH
117 #define POCO_ENETRESET ENETRESET
118 #define POCO_ECONNABORTED ECONNABORTED
119 #define POCO_ECONNRESET ECONNRESET
120 #define POCO_ENOBUFS ENOBUFS
121 #define POCO_EISCONN EISCONN
122 #define POCO_ENOTCONN ENOTCONN
123 #define POCO_ESHUTDOWN ESHUTDOWN
124 #define POCO_ETIMEDOUT ETIMEDOUT
125 #define POCO_ECONNREFUSED ECONNREFUSED
126 #define POCO_EHOSTDOWN EHOSTDOWN
127 #define POCO_EHOSTUNREACH EHOSTUNREACH
128 #define POCO_ESYSNOTREADY -4
129 #define POCO_ENOTINIT -5
130 #define POCO_HOST_NOT_FOUND HOST_NOT_FOUND
131 #define POCO_TRY_AGAIN TRY_AGAIN
132 #define POCO_NO_RECOVERY NO_RECOVERY
133 #define POCO_NO_DATA NO_DATA
134#elif defined(POCO_OS_FAMILY_UNIX)
137 #include <sys/types.h>
138 #include <sys/socket.h>
142 #if POCO_OS != POCO_OS_HPUX
143 #include <sys/select.h>
145 #include <sys/ioctl.h>
146 #include <arpa/inet.h>
147 #include <netinet/in.h>
148 #include <netinet/tcp.h>
150 #if defined(POCO_OS_FAMILY_UNIX)
151 #if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_ANDROID)
155 #elif (POCO_OS == POCO_OS_HPUX)
164 #if (POCO_OS == POCO_OS_SOLARIS) || (POCO_OS == POCO_OS_MAC_OS_X)
165 #include <sys/sockio.h>
166 #include <sys/filio.h>
168 #define POCO_INVALID_SOCKET -1
169 #define poco_socket_t int
170 #define poco_socklen_t socklen_t
171 #define poco_fcntl_request_t int
172 #if defined(POCO_OS_FAMILY_BSD)
173 #define poco_ioctl_request_t unsigned long
175 #define poco_ioctl_request_t int
177 #define poco_closesocket(s) ::close(s)
178 #define POCO_EINTR EINTR
179 #define POCO_EACCES EACCES
180 #define POCO_EFAULT EFAULT
181 #define POCO_EINVAL EINVAL
182 #define POCO_EMFILE EMFILE
183 #define POCO_EAGAIN EAGAIN
184 #define POCO_EWOULDBLOCK EWOULDBLOCK
185 #define POCO_EINPROGRESS EINPROGRESS
186 #define POCO_EALREADY EALREADY
187 #define POCO_ENOTSOCK ENOTSOCK
188 #define POCO_EDESTADDRREQ EDESTADDRREQ
189 #define POCO_EMSGSIZE EMSGSIZE
190 #define POCO_EPROTOTYPE EPROTOTYPE
191 #define POCO_ENOPROTOOPT ENOPROTOOPT
192 #define POCO_EPROTONOSUPPORT EPROTONOSUPPORT
193 #if defined(ESOCKTNOSUPPORT)
194 #define POCO_ESOCKTNOSUPPORT ESOCKTNOSUPPORT
196 #define POCO_ESOCKTNOSUPPORT -1
198 #define POCO_ENOTSUP ENOTSUP
199 #define POCO_EPFNOSUPPORT EPFNOSUPPORT
200 #define POCO_EAFNOSUPPORT EAFNOSUPPORT
201 #define POCO_EADDRINUSE EADDRINUSE
202 #define POCO_EADDRNOTAVAIL EADDRNOTAVAIL
203 #define POCO_ENETDOWN ENETDOWN
204 #define POCO_ENETUNREACH ENETUNREACH
205 #define POCO_ENETRESET ENETRESET
206 #define POCO_ECONNABORTED ECONNABORTED
207 #define POCO_ECONNRESET ECONNRESET
208 #define POCO_ENOBUFS ENOBUFS
209 #define POCO_EISCONN EISCONN
210 #define POCO_ENOTCONN ENOTCONN
211 #if defined(ESHUTDOWN)
212 #define POCO_ESHUTDOWN ESHUTDOWN
214 #define POCO_ESHUTDOWN -2
216 #define POCO_ETIMEDOUT ETIMEDOUT
217 #define POCO_ECONNREFUSED ECONNREFUSED
218 #if defined(EHOSTDOWN)
219 #define POCO_EHOSTDOWN EHOSTDOWN
221 #define POCO_EHOSTDOWN -3
223 #define POCO_EHOSTUNREACH EHOSTUNREACH
224 #define POCO_ESYSNOTREADY -4
225 #define POCO_ENOTINIT -5
226 #define POCO_HOST_NOT_FOUND HOST_NOT_FOUND
227 #define POCO_TRY_AGAIN TRY_AGAIN
228 #define POCO_NO_RECOVERY NO_RECOVERY
229 #define POCO_NO_DATA NO_DATA
234 #define POCO_HAVE_SALEN 1
239 #define POCO_HAVE_ADDRINFO 1
244 #define POCO_BROKEN_TIMEOUTS 1
248#if defined(POCO_HAVE_ADDRINFO
)
253 #define AI_CANONNAME 0
255 #ifndef AI_NUMERICHOST
256 #define AI_NUMERICHOST 0
258 #ifndef AI_NUMERICSERV
259 #define AI_NUMERICSERV 0
264 #ifndef AI_ADDRCONFIG
265 #define AI_ADDRCONFIG 0
268 #define AI_V4MAPPED 0
273#if defined(POCO_HAVE_SALEN)
274 #define poco_set_sa_len(pSA, len) (pSA)->sa_len = (len)
275 #define poco_set_sin_len(pSA) (pSA)->sin_len = sizeof(struct sockaddr_in)
276 #if defined(POCO_HAVE_IPv6)
277 #define poco_set_sin6_len(pSA) (pSA)->sin6_len = sizeof(struct sockaddr_in6)
279 #if defined(POCO_OS_FAMILY_UNIX)
280 #define poco_set_sun_len(pSA, len) (pSA)->sun_len = (len)
283 #define poco_set_sa_len(pSA, len) (void) 0
284 #define poco_set_sin_len(pSA) (void) 0
285 #define poco_set_sin6_len(pSA) (void) 0
286 #define poco_set_sun_len(pSA, len) (void) 0
291 #define INADDR_NONE 0xffffffff
295 #define INADDR_ANY 0x00000000
299 #define INADDR_BROADCAST 0xffffffff
303 #define INADDR_LOOPBACK 0x7f000001
306#ifndef INADDR_UNSPEC_GROUP
307 #define INADDR_UNSPEC_GROUP 0xe0000000
310#ifndef INADDR_ALLHOSTS_GROUP
311 #define INADDR_ALLHOSTS_GROUP 0xe0000001
314#ifndef INADDR_ALLRTRS_GROUP
315 #define INADDR_ALLRTRS_GROUP 0xe0000002
318#ifndef INADDR_MAX_LOCAL_GROUP
319 #define INADDR_MAX_LOCAL_GROUP 0xe00000ff
322#if defined(POCO_ARCH_BIG_ENDIAN)
323 #define poco_ntoh_16(x) (x)
324 #define poco_ntoh_32(x) (x)
326 #define poco_ntoh_16(x)
327 ((((x) >> 8
) & 0x00ff
) | (((x) << 8
) & 0xff00
))
328 #define poco_ntoh_32(x)
329 ((((x) >> 24
) & 0x000000ff
) | (((x) >> 8
) & 0x0000ff00
) | (((x) << 8
) & 0x00ff0000
) | (((x) << 24
) & 0xff000000
))
335#if !defined(s6_addr16)
336 #if defined(POCO_OS_FAMILY_WINDOWS
)
337 #define s6_addr16 u.Word
339 #define s6_addr16 __u6_addr.__u6_addr16
344#if !defined(s6_addr32)
345 #if defined(POCO_OS_FAMILY_UNIX)
346 #if (POCO_OS == POCO_OS_SOLARIS)
347 #define s6_addr32 _S6_un._S6_u32
349 #define s6_addr32 __u6_addr.__u6_addr32
359#if defined(POCO_OS_FAMILY_WINDOWS
)
360 typedef WSABUF SocketBuf;
361#elif defined(POCO_OS_FAMILY_UNIX)
380 #if defined(POCO_OS_FAMILY_UNIX)
#define POCO_EXTERNAL_OPENSSL
#define POCO_DO_JOIN2(X, Y)
#define POCO_DO_JOIN(X, Y)
#define OPENSSL_VERSION_PREREQ(maj, min)
RSAPaddingMode
The padding mode used for RSA public key encryption.
@ RSA_PADDING_PKCS1_OAEP
PKCS #1 v1.5 padding. This currently is the most widely used mode.
#define POCO_EXTERNAL_OPENSSL_SLPRO
virtual std::unique_ptr< ArkApi::ICommands > & GetCommands()=0
void WriteRequest(std::function< void(bool, std::string)> callback, bool success, std::string result)
std::string GetResponse(Poco::Net::HTTPClientSession *session, Poco::Net::HTTPResponse &response)
Poco::Net::HTTPRequest ConstructRequest(const std::string &url, Poco::Net::HTTPClientSession *&session, const std::vector< std::string > &headers, const std::string &request_type)
std::vector< RequestData > RequestsVec_
Requests(Requests &&)=delete
ARK_API bool CreateGetRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, std::vector< std::string > headers={})
Creates an async GET Request that runs in another thread but calls the callback from the main thread.
ARK_API bool CreatePostRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, const std::vector< std::string > &post_ids, const std::vector< std::string > &post_data, std::vector< std::string > headers={})
Creates an async POST Request that runs in another thread but calls the callback from the main thread...
Requests & operator=(Requests &&)=delete
ARK_API bool CreateDeleteRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, std::vector< std::string > headers={})
Creates an async DELETE Request that runs in another thread but calls the callback from the main thre...
Requests & operator=(const Requests &)=delete
ARK_API bool CreatePostRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, const std::string &post_data, std::vector< std::string > headers={})
Creates an async POST Request with application/x-www-form-urlencoded content type that runs in anothe...
static ARK_API Requests & Get()
ARK_API bool CreatePostRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, const std::string &post_data, const std::string &content_type, std::vector< std::string > headers={})
Creates an async POST Request that runs in another thread but calls the callback from the main thread...
std::unique_ptr< impl > pimpl
Requests(const Requests &)=delete
virtual void AddOnTickCallback(const FString &id, const std::function< void(float)> &callback)=0
Added function will be called every frame.
virtual bool RemoveOnTickCallback(const FString &id)=0
Removes a on-tick callback.
static std::shared_ptr< spdlog::logger > & GetLog()
static std::string what(const char *msg, const char *file, int line, const char *text=0)
static void bugcheck(const char *msg, const char *file, int line)
static void nullPointer(const char *ptr, const char *file, int line)
static void debugger(const char *msg, const char *file, int line)
static void debugger(const char *file, int line)
static void bugcheck(const char *file, int line)
static void assertion(const char *cond, const char *file, int line, const char *text=0)
static void unexpected(const char *file, int line)
This class represents a X509 Certificate.
std::string displayText() const
Returns the exception code if defined.
void init(const Params ¶ms)
void setSessionCacheSize(std::size_t size)
Returns true iff the session cache is enabled.
std::size_t getSessionCacheSize() const
Context::VerificationMode verificationMode() const
Returns true iff the context is for use by a server.
void requireMinimumProtocol(Protocols protocol)
void enableExtendedCertificateVerification(bool flag=true)
void setInvalidCertificateHandler(InvalidCertificateHandlerPtr pInvalidCertificageHandler)
Usage _usage
Create a SSL_CTX object according to Context configuration.
Usage usage() const
Returns the underlying OpenSSL SSL Context object.
SSL_CTX * sslContext() const
long getSessionTimeout() const
void usePrivateKey(const Poco::Crypto::RSAKey &key)
Add one trusted certification authority to be used by the Context.
void enableSessionCache(bool flag=true)
Returns the verification mode.
void addCertificateAuthority(const Poco::Crypto::X509Certificate &certificate)
Adds a certificate for certificate chain validation.
void usePrivateKey(const Poco::Crypto::EVPPKey &pkey)
bool extendedCertificateVerificationEnabled() const
bool isForServerUse() const
void addChainCertificate(const Poco::Crypto::X509Certificate &certificate)
bool _ocspStaplingResponseVerification
bool ocspStaplingResponseVerificationEnabled() const
bool _extendedCertificateVerification
@ SERVER_USE
DEPRECATED. Context is used by a client.
@ TLSV1_2_CLIENT_USE
DEPRECATED. Context is used by a server requiring TLSv1.1 (OpenSSL 1.0.0 or newer).
@ TLSV1_CLIENT_USE
DEPRECATED. Context is used by a server.
@ TLSV1_3_SERVER_USE
DEPRECATED. Context is used by a client requiring TLSv1.3 (OpenSSL 1.1.1 or newer).
@ CLIENT_USE
Context is used by a client for TLSv1 or higher. Use requireMinimumProtocol() or disableProtocols() t...
@ TLSV1_2_SERVER_USE
DEPRECATED. Context is used by a client requiring TLSv1.2 (OpenSSL 1.0.1 or newer).
@ TLSV1_SERVER_USE
DEPRECATED. Context is used by a client requiring TLSv1.
@ TLSV1_3_CLIENT_USE
DEPRECATED. Context is used by a server requiring TLSv1.2 (OpenSSL 1.0.1 or newer).
@ TLS_SERVER_USE
Context is used by a client for TLSv1 or higher. Use requireMinimumProtocol() or disableProtocols() t...
@ TLSV1_1_CLIENT_USE
DEPRECATED. Context is used by a server requiring TLSv1.
@ TLSV1_1_SERVER_USE
DEPRECATED. Context is used by a client requiring TLSv1.1 (OpenSSL 1.0.0 or newer).
void useCertificate(const Poco::Crypto::X509Certificate &certificate)
Destroys the Context.
void preferServerCiphers()
Context(Usage usage, const Params ¶ms)
InvalidCertificateHandlerPtr _pInvalidCertificateHandler
void setSessionTimeout(long seconds)
InvalidCertificateHandlerPtr getInvalidCertificateHandler() const
void disableStatelessSessionResumption()
bool sessionCacheEnabled() const
void disableProtocols(int protocols)
virtual std::istream & receiveResponse(HTTPResponse &response)
virtual std::ostream & sendRequest(HTTPRequest &request)
Returns the connection timeout for HTTP connections.
static const std::string HTTP_1_1
void setContentLength(std::streamsize length)
Returns the HTTP version for this message.
HTTPRequest(const std::string &method, const std::string &uri, const std::string &version)
Creates a HTTP/1.0 request with the given method and URI.
static const std::string HTTP_GET
static const std::string HTTP_DELETE
static const std::string HTTP_POST
const std::string & getReason() const
Sets the HTTP reason phrase.
HTTPResponse(HTTPStatus status)
HTTPStatus getStatus() const
HTTPSClientSession(const std::string &host, Poco::UInt16 port, Context::Ptr pContext, Session::Ptr pSession)
std::string proxyRequestPrefix() const
Sends the given HTTPRequest over an existing connection.
HTTPSClientSession(Context::Ptr pContext, Session::Ptr pSession)
Session::Ptr sslSession()
HTTPSClientSession(Context::Ptr pContext)
Creates a HTTPSClientSession using the given host and port.
void proxyAuthenticate(HTTPRequest &request)
Checks if we can reuse a persistent connection.
int read(char *buffer, std::streamsize length)
HTTPSClientSession(const HTTPSClientSession &)
void connect(const SocketAddress &address)
Refills the internal buffer.
HTTPSClientSession(const SecureStreamSocket &socket, Session::Ptr pSession)
X509Certificate serverCertificate()
HTTPSClientSession & operator=(const HTTPSClientSession &)
HTTPSClientSession(const std::string &host, Poco::UInt16 port=HTTPS_PORT)
HTTPSClientSession(const SecureStreamSocket &socket)
Creates an unconnected HTTPSClientSession.
HTTPSClientSession(const std::string &host, Poco::UInt16 port, Context::Ptr pContext)
RejectCertificateHandler(bool handleErrorsOnServerSide)
void initializeClient(PrivateKeyPassphraseHandlerPtr ptrPassphraseHandler, InvalidCertificateHandlerPtr ptrHandler, Context::Ptr ptrContext)
static SSLManager & instance()
static std::string convertCertificateError(long errCode)
static std::string getLastError()
Converts an SSL certificate handling error code into an error message.
static void clearErrorStack()
Returns the last error from the error stack.
This stream discards all characters written to it.
static std::streamsize copyStream(std::istream &istr, std::ostream &ostr, std::size_t bufferSize=8192)
const std::string & getHost() const
Sets the user-info part of the URI.
const std::string & getScheme() const
URI(const std::string &uri)
Creates an empty URI.
unsigned short getPort() const
Sets the host part of the URI.
std::string getPathAndQuery() const
Returns the encoded path, query and fragment parts of the URI.
std::unique_ptr< IBaseApi > game_api
void Crypto_API uninitializeCrypto()
void Crypto_API initializeCrypto()
std::vector< SocketBuf > SocketBufVec
void NetSSL_API initializeSSL()
void Net_API uninitializeNetwork()
void Net_API initializeNetwork()
void NetSSL_API uninitializeSSL()
#define OPENSSL_VERSION_NUMBER
struct ssl_ctx_st SSL_CTX
#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT
#define SSL_VERIFY_CLIENT_ONCE
std::function< void(bool, std::string)> callback
Family
Possible address families for socket addresses.
std::string privateKeyFile
Initializes the struct with default values.
std::string certificateFile
bool ocspStaplingVerification
VerificationMode verificationMode
static std::string escape(const std::string &s, bool strictJSON=false)