Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
NetSSL.h
Go to the documentation of this file.
1//
2// NetSSL.h
3//
4// Library: NetSSL_OpenSSL
5// Package: SSLCore
6// Module: OpenSSL
7//
8// Basic definitions for the Poco OpenSSL library.
9// This file must be the first file included by every other OpenSSL
10// header file.
11//
12// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
13// and Contributors.
14//
15// SPDX-License-Identifier: BSL-1.0
16//
17
18
19#ifndef NetSSL_NetSSL_INCLUDED
20#define NetSSL_NetSSL_INCLUDED
21
22
23#include "Poco/Net/Net.h"
24#include "Poco/Crypto/Crypto.h"
25
26
27//
28// The following block is the standard way of creating macros which make exporting
29// from a DLL simpler. All files within this DLL are compiled with the NetSSL_EXPORTS
30// symbol defined on the command line. this symbol should not be defined on any project
31// that uses this DLL. This way any other project whose source files include this file see
32// NetSSL_API functions as being imported from a DLL, wheras this DLL sees symbols
33// defined with this macro as being exported.
34//
35#if (defined(_WIN32) || defined(__CYGWIN__)) && defined(POCO_DLL)
36 #if defined(NetSSL_EXPORTS)
37 #define NetSSL_API __declspec(dllexport)
38 #else
39 #define NetSSL_API __declspec(dllimport)
40 #endif
41#endif
42
43
44#if !defined(NetSSL_API)
45 #if !defined(POCO_NO_GCC_API_ATTRIBUTE) && defined (__GNUC__) && (__GNUC__ >= 4)
46 #define NetSSL_API __attribute__ ((visibility ("default")))
47 #else
48 #define NetSSL_API
49 #endif
50#endif
51
52
53//
54// Automatically link NetSSL and OpenSSL libraries.
55//
56#if defined(_MSC_VER)
57 #if !defined(POCO_NO_AUTOMATIC_LIBS)
58 #if !defined(NetSSL_EXPORTS)
59 #pragma comment(lib, "PocoNetSSL" POCO_LIB_SUFFIX)
60 #endif
61 #endif // POCO_NO_AUTOMATIC_LIBS
62#endif
63
64
65namespace Poco {
66namespace Net {
67
68
70 /// Initialize the NetSSL library, as well as the underlying OpenSSL
71 /// libraries, by calling Poco::Crypto::OpenSSLInitializer::initialize().
72 ///
73 /// Should be called before using any class from the NetSSL library.
74 /// The NetSSL will be initialized automatically, through
75 /// Poco::Crypto::OpenSSLInitializer instances or similar mechanisms
76 /// when creating Context or SSLManager instances.
77 /// However, it is recommended to call initializeSSL()
78 /// in any case at application startup.
79 ///
80 /// Can be called multiple times; however, for every call to
81 /// initializeSSL(), a matching call to uninitializeSSL()
82 /// must be performed.
83
84
86 /// Uninitializes the NetSSL library by calling
87 /// Poco::Crypto::OpenSSLInitializer::uninitialize() and
88 /// shutting down the SSLManager.
89
90
91} } // namespace Poco::Net
92
93
94#endif // NetSSL_NetSSL_INCLUDED
#define ARK_API
Definition Base.h:9
#define NetSSL_API
Definition NetSSL.h:48
virtual std::unique_ptr< ArkApi::ICommands > & GetCommands()=0
std::mutex RequestMutex_
Definition Requests.cpp:47
void WriteRequest(std::function< void(bool, std::string)> callback, bool success, std::string result)
Definition Requests.cpp:73
std::string GetResponse(Poco::Net::HTTPClientSession *session, Poco::Net::HTTPResponse &response)
Definition Requests.cpp:107
Poco::Net::HTTPRequest ConstructRequest(const std::string &url, Poco::Net::HTTPClientSession *&session, const std::vector< std::string > &headers, const std::string &request_type)
Definition Requests.cpp:79
std::vector< RequestData > RequestsVec_
Definition Requests.cpp:46
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.
Definition Requests.cpp:129
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...
Definition Requests.cpp:238
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...
Definition Requests.cpp:292
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...
Definition Requests.cpp:162
static ARK_API Requests & Get()
Definition Requests.cpp:67
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...
Definition Requests.cpp:200
std::unique_ptr< impl > pimpl
Definition Requests.h:84
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.
Definition Logger.h:9
static std::shared_ptr< spdlog::logger > & GetLog()
Definition Logger.h:22
std::string displayText() const
Returns the exception code if defined.
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)
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()
This stream discards all characters written to it.
Definition NullStream.h:77
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.
Definition URI.h:385
const std::string & getScheme() const
Definition URI.h:373
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.
void error(const T &)
Definition IBaseApi.h:9
std::unique_ptr< IBaseApi > game_api
Definition IBaseApi.h:25
void NetSSL_API initializeSSL()
void NetSSL_API uninitializeSSL()
Definition format.h:408
Definition json.hpp:4518
std::function< void(bool, std::string)> callback
Definition Requests.cpp:41
static std::string escape(const std::string &s, bool strictJSON=false)