mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Bazaar/Protect : removed Web package dependencies
git-svn-id: svn://ultimatepp.org/upp/trunk@6175 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
2498916537
commit
f944aa5727
9 changed files with 33 additions and 29 deletions
|
|
@ -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<String, Value> ProtectClient::SendMap(VectorMap<String, Value> 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
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef _ProtectClient_h_
|
||||
#define _ProtectClient_h_
|
||||
|
||||
#include <Web/Web.h>
|
||||
#include <Cypher/Cypher.h>
|
||||
|
||||
#include<ProductVersion/ProductVersion.h>
|
||||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ description "Copy protection Protect package - client side\377";
|
|||
uses
|
||||
Core,
|
||||
Cypher,
|
||||
Web,
|
||||
ProductVersion;
|
||||
|
||||
file
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<String> 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<String, Value> 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
|
||||
|
|
|
|||
|
|
@ -2,15 +2,17 @@
|
|||
#define _ProtectServer_h_
|
||||
|
||||
#include <Core/Core.h>
|
||||
#include <Web/Web.h>
|
||||
#include <Core/SMTP/SMTP.h>
|
||||
|
||||
#include <Cypher/Cypher.h>
|
||||
#include <Scgi/Scgi.h>
|
||||
|
||||
#include <ProtectClient/ProtectStatus.h>
|
||||
#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; }
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue