Index: src/event/HTTPServer.h =================================================================== --- src/event/HTTPServer.h (revision 415) +++ src/event/HTTPServer.h (revision 416) @@ -79,6 +79,39 @@ } /** + * Return interface. + * + * @return Interface. + */ + inline const char *getInterface(void) const + throw() + { + return iface; + } + + /** + * Return address. + * + * @return Address. + */ + inline const char *getAddress(void) const + throw() + { + return addr; + } + + /** + * Return port. + * + * @return Port. + */ + inline const uint16_t getPort(void) const + throw() + { + return port; + } + + /** * Return server connection. * * @return Connection. Index: src/event/HTTPHandler.h =================================================================== --- src/event/HTTPHandler.h (revision 415) +++ src/event/HTTPHandler.h (revision 416) @@ -320,12 +320,11 @@ * * @param csk Client socket. * @param addr Client destination. - * @param msg HTTP message. + * @param req HTTP request. * @return Server. * @throws NetworkException If unable to handle client. */ - HTTPServer *selectServer(const int csk, const struct sockaddr_in &addr, - const HTTPMessage *msg) const + HTTPServer *selectServer(const int csk, const struct sockaddr_in &addr, HTTPRequest *req) const throw(NetworkException *); /** Index: src/event/ProxyHTTPHandler.cc =================================================================== --- src/event/ProxyHTTPHandler.cc (revision 415) +++ src/event/ProxyHTTPHandler.cc (revision 416) @@ -22,6 +22,7 @@ using namespace std; using namespace util; using namespace event; +using namespace weblock; ProxyHTTPHandler::ProxyHTTPHandler(void) throw(ConfigException *, NetworkException *) @@ -144,7 +145,7 @@ ClientConnection *cconn = req->getClientConnection(); HTTPServer *server = cconn->getServer(); if (!server) { - server = selectServer(cconn->getSocket(), cconn->getAddress(), msg); + server = selectServer(cconn->getSocket(), cconn->getAddress(), req); cconn->setServer(server); } @@ -266,7 +267,7 @@ HTTPServer * ProxyHTTPHandler::selectServer(const int csk, - const struct sockaddr_in &addr, const HTTPMessage *msg) const + const struct sockaddr_in &addr, HTTPRequest *req) const throw(NetworkException *) { HTTPServer *server = NULL; @@ -280,8 +281,8 @@ case THREAT: // Is this message a threat? - if (!msg->getAnalysisStatus(ANALYSIS_SIGNATURE_PASS) || - !msg->getAnalysisStatus(ANALYSIS_ANOMALY_PASS)) + if (!req->getAnalysisStatus(ANALYSIS_SIGNATURE_PASS) || + !req->getAnalysisStatus(ANALYSIS_ANOMALY_PASS)) stype = RESTRICTED; for (HTTPServerList::const_iterator it = httpsrv.begin(); it != httpsrv.end(); it++) { @@ -292,6 +293,20 @@ } } + // XXX: Rewrite Host: field hack + StringIMap &headers = req->getHeaders(); + if (headers.find("Host") != headers.end()) { + const char *src = server->getAddress(); + char *dst = const_cast(headers["Host"]); + + while (*dst && *src) + *dst++ = *src++; + while (*dst) + *dst++ = ' '; + + D_NETWORK("rewrote destination host [%s]", headers["Host"]); + } + return server; } Index: src/revision.h =================================================================== --- src/revision.h (revision 415) +++ src/revision.h (revision 416) @@ -1,8 +1,8 @@ -// Automatically generated by mkrev [Thu Aug 24 19:29:08 PDT 2006] +// Automatically generated by mkrev [Fri Aug 25 14:10:28 PDT 2006] #ifndef __REVISION_H #define __REVISION_H -#define PACKAGE_REVISION "408" +#define PACKAGE_REVISION "415" #endif // __REVISION_H