]> git.stg.codes - stg.git/blob - projects/sgauthstress/user.cpp
Connect users on add
[stg.git] / projects / sgauthstress / user.cpp
1 #include <sys/socket.h>
2 #include <netinet/in.h>
3
4 #include <cstring>
5
6 #include "user.h"
7 #include "stg/ia_packets.h"
8
9 USER::USER(const std::string & l,
10            const std::string & pwd,
11            uint32_t i)
12     : login(l),
13       password(pwd),
14       ip(i),
15       aliveTimeout(0),
16       userTimeout(0),
17       phase(1),
18       phaseChangeTime(0),
19       rnd(0)
20 {
21 unsigned char key[IA_PASSWD_LEN];
22 memset(key, 0, IA_PASSWD_LEN);
23 strncpy((char *)key, password.c_str(), IA_PASSWD_LEN);
24 Blowfish_Init(&ctx, key, IA_PASSWD_LEN);
25
26 sock = socket(AF_INET, SOCK_DGRAM, 0);
27 }
28
29 USER::~USER()
30 {
31 close(sock);
32 }