2 #include <sys/socket.h>
3 #include <netinet/in.h>
4 #include <unistd.h> // close
11 #include "stg/ia_packets.h"
12 #include "stg/common.h"
14 USER::USER(const std::string & l,
15 const std::string & pwd,
27 unsigned char key[IA_PASSWD_LEN];
28 memset(key, 0, IA_PASSWD_LEN);
29 strncpy((char *)key, password.c_str(), IA_PASSWD_LEN);
30 Blowfish_Init(&ctx, key, IA_PASSWD_LEN);
33 USER::USER(const USER & rvalue)
34 : login(rvalue.login),
35 password(rvalue.password),
37 aliveTimeout(rvalue.aliveTimeout),
38 userTimeout(rvalue.userTimeout),
44 unsigned char key[IA_PASSWD_LEN];
45 memset(key, 0, IA_PASSWD_LEN);
46 strncpy((char *)key, password.c_str(), IA_PASSWD_LEN);
47 Blowfish_Init(&ctx, key, IA_PASSWD_LEN);
56 USER & USER::operator=(const USER & rvalue)
59 password = rvalue.password;
61 aliveTimeout = rvalue.aliveTimeout;
62 userTimeout = rvalue.userTimeout;
68 unsigned char key[IA_PASSWD_LEN];
69 memset(key, 0, IA_PASSWD_LEN);
70 strncpy((char *)key, password.c_str(), IA_PASSWD_LEN);
71 Blowfish_Init(&ctx, key, IA_PASSWD_LEN);
76 bool USER::InitNetwork()
78 sock = socket(AF_INET, SOCK_DGRAM, 0);
82 throw std::runtime_error(std::string("USER::USER() - socket creation error: '") + strerror(errno) + "', ip: " + inet_ntostring(ip) + ", login: " + login);
85 struct sockaddr_in addr;
87 addr.sin_family = AF_INET;
88 addr.sin_addr.s_addr = ip;
89 addr.sin_port = htons(5554); // :(
91 int res = bind(sock, (struct sockaddr *)&addr, sizeof(addr));
94 throw std::runtime_error(std::string("USER::USER() - bind error: '") + strerror(errno) + "', ip: " + inet_ntostring(ip) + ", login: " + login);