@@ -107,6 +107,7 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, void *logCbData)
107107 m_clientIpAddress (std::make_shared<std::string>(" " )),
108108 m_httpVersion(" " ),
109109 m_serverIpAddress(std::make_shared<std::string>(" " )),
110+ m_requestHostName(std::make_shared<std::string>(" " )),
110111 m_uri(" " ),
111112 m_uri_no_query_string_decoded(std::make_shared<std::string>(" " )),
112113 m_ARGScombinedSizeDouble(0 ),
@@ -183,6 +184,7 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, char *id, void *logCb
183184 m_clientIpAddress(std::make_shared<std::string>(" " )),
184185 m_httpVersion(" " ),
185186 m_serverIpAddress(std::make_shared<std::string>(" " )),
187+ m_requestHostName(std::make_shared<std::string>(" " )),
186188 m_uri(" " ),
187189 m_uri_no_query_string_decoded(std::make_shared<std::string>(" " )),
188190 m_ARGScombinedSizeDouble(0 ),
@@ -319,6 +321,7 @@ int Transaction::processConnection(const char *client, int cPort,
319321 const char *server, int sPort ) {
320322 m_clientIpAddress = std::unique_ptr<std::string>(new std::string (client));
321323 m_serverIpAddress = std::unique_ptr<std::string>(new std::string (server));
324+ m_requestHostName = std::unique_ptr<std::string>(new std::string (server));
322325 this ->m_clientPort = cPort;
323326 this ->m_serverPort = sPort ;
324327 ms_dbg (4 , " Transaction context created." );
@@ -2358,5 +2361,52 @@ extern "C" int msc_update_status_code(Transaction *transaction, int status) {
23582361}
23592362
23602363
2364+ /* *
2365+ * @name setRequestHostName
2366+ * @brief Set request's host name
2367+ *
2368+ * With this method it is possible to set the request's hostname.
2369+ *
2370+ * @note This function expects a NULL terminated string.
2371+ *
2372+ * @param hostname hostname.
2373+ *
2374+ * @returns If the operation was successful or not.
2375+ * @retval true Operation was successful.
2376+ * @retval false Operation failed.
2377+ *
2378+ */
2379+ int Transaction::setRequestHostName (const std::string& hostname) {
2380+
2381+ if (hostname != " " ) {
2382+ m_requestHostName = std::unique_ptr<std::string>(new std::string (hostname));
2383+ }
2384+
2385+ return true ;
2386+ }
2387+
2388+
2389+ /* *
2390+ * @name msc_set_request_hostname
2391+ * @brief Set request's host name
2392+ *
2393+ * With this method it is possible to set request's hostname.
2394+ *
2395+ * @note This function expects a NULL terminated string.
2396+ *
2397+ * @param transaction ModSecurity transaction.
2398+ * @param hostname hostname.
2399+ *
2400+ * @returns If the operation was successful or not.
2401+ * @retval 1 Operation was successful.
2402+ * @retval 0 Operation failed.
2403+ *
2404+ */
2405+ extern " C" int msc_set_request_hostname (Transaction *transaction,
2406+ const unsigned char *hostname) {
2407+ return transaction->setRequestHostName (reinterpret_cast <const char *>(hostname));
2408+ }
2409+
2410+
23612411} // namespace modsecurity
23622412
0 commit comments