38 soap_init(soap.get());
39 soap_set_imode(soap.get(), SOAP_C_UTFSTRING);
40 soap_set_omode(soap.get(), SOAP_C_UTFSTRING);
42#if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
43 soap->bind_flags = SO_REUSEADDR;
47 soap->accept_timeout = 3;
48 soap->recv_timeout = 5;
49 soap->send_timeout = 5;
50 if (!soap_valid_socket(soap_bind(soap.get(), host.c_str(), port, 100)))
52 TC_LOG_ERROR(
"network.soap",
"Couldn't bind to {}:{}", host, port);
56 TC_LOG_INFO(
"network.soap",
"Bound to http://{}:{}", host, port);
58 return new std::thread([soap = std::move(soap)]
62 if (!soap_valid_socket(soap_accept(soap.get())))
65 struct soap* thread_soap = soap_copy(soap.get());
66 TC_LOG_DEBUG(
"network.soap",
"Accepted connection from IP={}", Trinity::Net::make_address_v4(thread_soap->ip).to_string());
74 TC_LOG_TRACE(
"network.soap",
"SOAPWorkingThread::process_message");
76 soap_serve(soap_message);
77 soap_destroy(soap_message);
78 soap_end(soap_message);
79 soap_free(soap_message);
89 if (!soap->userid || !soap->passwd)
91 TC_LOG_INFO(
"network.soap",
"Client didn't provide login information");
98 TC_LOG_INFO(
"network.soap",
"Client used invalid username '{}'", soap->userid);
104 TC_LOG_INFO(
"network.soap",
"Invalid password for account '{}'", soap->userid);
110 TC_LOG_INFO(
"network.soap",
"{}'s gmlevel is too low", soap->userid);
114 if (!command || !*command)
115 return soap_sender_fault(soap,
"Command can not be empty",
"The supplied command was an empty string");
117 TC_LOG_INFO(
"network.soap",
"Received command '{}'", command);
124 sWorld->QueueCliCommand(cmd);
131 char* printBuffer = soap_strdup(soap, connection.
m_printBuffer.c_str());
134 *result = printBuffer;
138 return soap_sender_fault(soap, printBuffer, printBuffer);
154{ {
"SOAP-ENV",
"http://schemas.xmlsoap.org/soap/envelope/",
nullptr,
nullptr },
155 {
"SOAP-ENC",
"http://schemas.xmlsoap.org/soap/encoding/",
nullptr,
nullptr },
156 {
"xsi",
"http://www.w3.org/1999/XMLSchema-instance",
"http://www.w3.org/*/XMLSchema-instance",
nullptr },
157 {
"xsd",
"http://www.w3.org/1999/XMLSchema",
"http://www.w3.org/*/XMLSchema",
nullptr },
158 {
"ns1",
"urn:TC",
nullptr,
nullptr },
159 {
nullptr,
nullptr,
nullptr,
nullptr }
#define TC_LOG_DEBUG(filterType__, message__,...)
#define TC_LOG_ERROR(filterType__, message__,...)
#define TC_LOG_INFO(filterType__, message__,...)
#define TC_LOG_TRACE(filterType__, message__,...)
std::thread * CreateSoapThread(const std::string &host, uint16 port)
struct Namespace namespaces[]
void process_message(struct soap *soap_message)
int ns1__executeCommand(soap *soap, char *command, char **result)
static uint32 GetSecurity(uint32 accountId, int32 realmId)
static bool CheckPassword(std::string username, std::string password)
static uint32 GetId(std::string_view username)
static void commandFinished(void *callbackArg, bool success)
bool hasCommandSucceeded() const
static void print(void *callbackArg, std::string_view msg)
std::string m_printBuffer
void setCommandSuccess(bool val)
std::promise< void > finishedPromise
std::unique_ptr< T, Impl::stateful_unique_ptr_deleter< Ptr, Del > > make_unique_ptr_with_deleter(Ptr ptr, Del deleter)
Storage class for commands issued for delayed execution.