diff --git a/bazaar/ProtectClient/ProtectClient.cpp b/bazaar/ProtectClient/ProtectClient.cpp index 0004aca0d..b79760783 100644 --- a/bazaar/ProtectClient/ProtectClient.cpp +++ b/bazaar/ProtectClient/ProtectClient.cpp @@ -25,7 +25,7 @@ ProtectClient::ProtectClient() // setup timeout for http server // a couple of seconds should be enough ! - client.TimeoutMsecs(2000); + client.Timeout(2000); } ProtectClient::~ProtectClient() @@ -121,7 +121,9 @@ VectorMap ProtectClient::SendMap(VectorMap const & postData += HexString((*cypher)(StoreAsXML(dataMap, "ProtectClient"))); client.Post(postData); - String contents = client.ExecuteRedirect(); + + // WARNING -- PREVIOUSLY WAS ExecuteRedirect -- check on remote server!!! + String contents = client.Execute(); // if contents start with "ERROR", just fetch the error desc // and put it in result map diff --git a/bazaar/ProtectClient/ProtectClient.h b/bazaar/ProtectClient/ProtectClient.h index 4e783ec8b..775d46044 100644 --- a/bazaar/ProtectClient/ProtectClient.h +++ b/bazaar/ProtectClient/ProtectClient.h @@ -1,7 +1,6 @@ #ifndef _ProtectClient_h_ #define _ProtectClient_h_ -#include #include #include @@ -15,7 +14,7 @@ class ProtectClient private: // the HTTP client - HttpClient client; + HttpRequest client; // last error code for failed operations int lastError; @@ -96,7 +95,7 @@ class ProtectClient void SetCypher(Cypher *c); // sets server's URL - ProtectClient &SetURL(String const &url) { client.URL(url); return *this; } + ProtectClient &SetURL(String const &url) { client.Url(url); return *this; } // sets communication key ProtectClient &SetCommunicationKey(String const &_key) { communicationKey = _key; return *this; } diff --git a/bazaar/ProtectClient/ProtectClient.upp b/bazaar/ProtectClient/ProtectClient.upp index 922539f15..3e0406174 100644 --- a/bazaar/ProtectClient/ProtectClient.upp +++ b/bazaar/ProtectClient/ProtectClient.upp @@ -3,7 +3,6 @@ description "Copy protection Protect package - client side\377"; uses Core, Cypher, - Web, ProductVersion; file diff --git a/bazaar/ProtectClient/init b/bazaar/ProtectClient/init index 52d27cdcf..dd444ddb7 100644 --- a/bazaar/ProtectClient/init +++ b/bazaar/ProtectClient/init @@ -2,9 +2,8 @@ #define _ProtectClient_icpp_init_stub #include "Core/init" #include "Cypher/init" -#include "Web/init" #include "ProductVersion/init" -#define BLITZ_INDEX__ Ff67c7a83ae1614721772180b50291b82 +#define BLITZ_INDEX__ F8430d8a06de87be1b24a1104c83a82fc #include "ProtectTranslations.icpp" #undef BLITZ_INDEX__ #endif diff --git a/bazaar/ProtectServer/ProtectServer.cpp b/bazaar/ProtectServer/ProtectServer.cpp index b71090995..18030d227 100644 --- a/bazaar/ProtectServer/ProtectServer.cpp +++ b/bazaar/ProtectServer/ProtectServer.cpp @@ -62,7 +62,7 @@ bool ValidateEMail(const char *address) } // constructor - defaults to port 8787 and connection timeout of 5 minutes (300 sec.) -ProtectServer::ProtectServer(int port) : ScgiServer(port) +ProtectServer::ProtectServer(int port) : Scgi(port) { // setup default cypher cypher = new Snow2; @@ -216,7 +216,7 @@ bool ProtectServer::SendMACAlert(String const &eMail, Vector const &mail body += "E-Mails connected to this one by MAC addresses :\n"; for(int i = 0; i < mails.GetCount(); i++) body += mails[i] + "\n"; - smtp.Text(body, "text/plain; charset=utf-8"); + smtp.Body(body, "text/plain; charset=utf-8"); return smtp.Send(); } @@ -279,7 +279,7 @@ bool ProtectServer::ProcessMACList(String const &mail, String const &MACList, bo void ProtectServer::OnAccepted() { - Cout() << "Accepted connection from client " << FormatIP(clientIP) << "\n"; + Cout() << "Accepted connection from client " << ClientIP() << "\n"; } void ProtectServer::OnRequest() @@ -290,20 +290,20 @@ void ProtectServer::OnRequest() String IV; // we handle just POST requests, GET not allowed - if(HasPostData()) + if(Post().GetCount()) { // all requests besides PROTECT_ACTIVATE go through post - if(post.Find("IV") < 0) + if(Post().Find("IV") < 0) err = PROTECT_MISSING_IV; else { - IV = ScanHexString(post.GetString("IV")); - if(post.Find("DATA") < 0) + IV = ScanHexString(Post().Get("IV")); + if(Post().Find("DATA") < 0) err = PROTECT_MISSING_DATA; else { cypher->SetKey(communicationKey, IV); - String decoded = (*cypher)(ScanHexString(post.GetString("DATA"))); + String decoded = (*cypher)(ScanHexString(Post().Get("DATA"))); LoadFromXML(data, decoded); } } @@ -337,11 +337,11 @@ void ProtectServer::OnRequest() results.Add("ERRORMSG", ProtectMessage(results.Get("ERROR"))); // encodes results and send back to client - clientSock.Write("Content-Type: text/plain\r\n\r\n"); + ClientSock().Put("Content-Type: text/plain\r\n\r\n"); cypher->SetKey(communicationKey); - clientSock.Write("IV=" + HexString(cypher->GetNonce()) + "\r\n"); + ClientSock().Put("IV=" + HexString(cypher->GetNonce()) + "\r\n"); String encoded = HexString((*cypher)(StoreAsXML(results, "ProtectServer"))); - clientSock.Write("DATA=" + encoded + "\r\n"); + ClientSock().Put("DATA=" + encoded + "\r\n"); } void ProtectServer::OnClosed() @@ -355,7 +355,7 @@ void ProtectServer::OnClosed() if(now - lastDBCleanupTime > dbCleanupTime) DBCleanup(); - Cout() << "Connection with " << FormatIP(clientIP) << " closed\n"; + Cout() << "Connection with " << ClientIP() << " closed\n"; } // process client request @@ -775,7 +775,7 @@ bool ProtectServer::SendActivationMail(VectorMap const &userData, smtp.To(userData.Get("EMAIL")); smtp.Subject(subject); // smtp.From(serverVars.Get("SERVER_NAME")); - smtp.Text(body, mime); + smtp.Body(body, mime); return smtp.Send(); } @@ -838,7 +838,7 @@ void ProtectServer::Run(void) } // runs the SCGI server - ScgiServer::Run(); + Scgi::Run(); } END_UPP_NAMESPACE diff --git a/bazaar/ProtectServer/ProtectServer.h b/bazaar/ProtectServer/ProtectServer.h index ee35e8562..37d616450 100644 --- a/bazaar/ProtectServer/ProtectServer.h +++ b/bazaar/ProtectServer/ProtectServer.h @@ -2,15 +2,17 @@ #define _ProtectServer_h_ #include -#include +#include + #include +#include #include #include "ProtectDB.h" NAMESPACE_UPP -class ProtectServer : public ScgiServer +class ProtectServer : public Scgi { private: @@ -27,7 +29,7 @@ class ProtectServer : public ScgiServer ProtectDB db; // mailer for activation mails - SmtpMail smtp; + Smtp smtp; // last ID cleanup time Time lastIDCleanupTime; @@ -136,7 +138,7 @@ public: ProtectDB &GetDB(void) { return db; } // gets mailer - SmtpMail &GetSmtp(void) { return smtp; } + Smtp &GetSmtp(void) { return smtp; } // sets application key (to be returned on auth success) ProtectServer &SetAppKey(String const &k) { appKey = k; return *this; } diff --git a/bazaar/ProtectServer/ProtectServer.upp b/bazaar/ProtectServer/ProtectServer.upp index 73c2a8a00..3a1c9ea88 100644 --- a/bazaar/ProtectServer/ProtectServer.upp +++ b/bazaar/ProtectServer/ProtectServer.upp @@ -3,8 +3,9 @@ description "Copy protection Protect package - server side\377"; uses Core, Cypher, - Web, - ProtectClient; + ProtectClient, + Core/SMTP, + Scgi; uses(USE_SQLITE) plugin\sqlite3; diff --git a/bazaar/ProtectServer/init b/bazaar/ProtectServer/init index 74166ac89..f883a97b6 100644 --- a/bazaar/ProtectServer/init +++ b/bazaar/ProtectServer/init @@ -2,8 +2,9 @@ #define _ProtectServer_icpp_init_stub #include "Core/init" #include "Cypher/init" -#include "Web/init" #include "ProtectClient/init" +#include "Core/SMTP/init" +#include "Scgi/init" #include "plugin\sqlite3/init" #include "MySql/init" #endif diff --git a/bazaar/ProtectServerDemo/main.cpp b/bazaar/ProtectServerDemo/main.cpp index 6410efcf0..95167bc3f 100644 --- a/bazaar/ProtectServerDemo/main.cpp +++ b/bazaar/ProtectServerDemo/main.cpp @@ -19,6 +19,7 @@ CONSOLE_APP_MAIN .GetSmtp() .Host("localhost") .Port(25) +// .Auth("user", "password") // use if mail server requires auth ; server .SetWelcomeSubject("ProtectDemo user activation")