#include <sys/time.h>
#include <pthread.h>
+
#include <cstring>
#include <ctime>
#include <string>
struct IA_USER
{
IA_USER()
+ : lastSendAlive(0),
+ rnd(random()),
+ port(0),
+ protoVer(0),
+ password("NO PASSWORD")
{
- //phase = 1;
- //phaseTime = 0;
- lastSendAlive = 0;
- rnd = random();
- port = 0;
- password = "NO PASSWORD";
// +++ Preparing CTX +++
- unsigned char keyL[PASSWD_LEN]; // ðÁÒÏÌØ ÄÌÑ ÛÉÆÒÏ×ËÉ
+ unsigned char keyL[PASSWD_LEN];
memset(keyL, 0, PASSWD_LEN);
strncpy((char *)keyL, password.c_str(), PASSWD_LEN);
Blowfish_Init(&ctx, keyL, PASSWD_LEN);
};
IA_USER(const IA_USER & u)
+ : user(u.user),
+ phase(u.phase),
+ lastSendAlive(u.lastSendAlive),
+ rnd(u.rnd),
+ port(u.port),
+ messagesToSend(u.messagesToSend),
+ protoVer(u.protoVer),
+ password(u.password)
{
- user = u.user;
- phase = u.phase;
- //phaseTime = u.phaseTime;
- lastSendAlive = u.lastSendAlive;
- rnd = u.rnd;
- password = u.password;
- protoVer = u.protoVer;
- port = u.port;
#ifdef IA_DEBUG
aliveSent = u.aliveSent;
#endif
virtual ~AUTH_IA();
void SetUsers(USERS * u) { users = u; };
- void SetTariffs(TARIFFS *){};
- void SetAdmins(ADMINS *){};
- void SetTraffcounter(TRAFFCOUNTER *){};
- void SetStore(BASE_STORE *){};
+ void SetTariffs(TARIFFS *) {};
+ void SetAdmins(ADMINS *) {};
+ void SetTraffcounter(TRAFFCOUNTER *) {};
+ void SetStore(BASE_STORE *) {};
void SetStgSettings(const SETTINGS * s) { stgSettings = s; };
void SetSettings(const MODULE_SETTINGS & s) { settings = s; };
int ParseSettings();
uint16_t GetStartPosition() const { return 50; };
uint16_t GetStopPosition() const { return 50; };
- void DelUser(user_iter u);
-
int SendMessage(const STG_MSG & msg, uint32_t ip) const;
private:
static void * RunTimeouter(void * d);
int PrepareNet();
int FinalizeNet();
+ void DelUser(user_iter u);
int RecvData(char * buffer, int bufferSize);
int CheckHeader(const char * buffer, int * protoVer);
int PacketProcessor(char * buff, int dataLen, uint32_t sip, uint16_t sport, int protoVer, user_iter * user);
int Timeouter();
- void InitEncrypt(BLOWFISH_CTX * ctx, const string & password);
- void Decrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8);
- void Encrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8);
-
int SendError(uint32_t ip, uint16_t port, int protoVer, const string & text);
int Send(uint32_t ip, uint16_t port, const char * buffer, int len);
int RealSendMessage6(const STG_MSG & msg, uint32_t ip, IA_USER & user);