1 #include <sys/socket.h>
2 #include <netinet/in.h>
9 #include "stg/ia_packets.h"
10 #include "stg/common.h"
12 USER::USER(const std::string & l,
13 const std::string & pwd,
25 unsigned char key[IA_PASSWD_LEN];
26 memset(key, 0, IA_PASSWD_LEN);
27 strncpy((char *)key, password.c_str(), IA_PASSWD_LEN);
28 Blowfish_Init(&ctx, key, IA_PASSWD_LEN);
31 USER::USER(const USER & rvalue)
32 : login(rvalue.login),
33 password(rvalue.password),
35 aliveTimeout(rvalue.aliveTimeout),
36 userTimeout(rvalue.userTimeout),
42 unsigned char key[IA_PASSWD_LEN];
43 memset(key, 0, IA_PASSWD_LEN);
44 strncpy((char *)key, password.c_str(), IA_PASSWD_LEN);
45 Blowfish_Init(&ctx, key, IA_PASSWD_LEN);
54 const USER & USER::operator=(const USER & rvalue)
57 password = rvalue.password;
59 aliveTimeout = rvalue.aliveTimeout;
60 userTimeout = rvalue.userTimeout;
66 unsigned char key[IA_PASSWD_LEN];
67 memset(key, 0, IA_PASSWD_LEN);
68 strncpy((char *)key, password.c_str(), IA_PASSWD_LEN);
69 Blowfish_Init(&ctx, key, IA_PASSWD_LEN);
74 bool USER::InitNetwork()
76 sock = socket(AF_INET, SOCK_DGRAM, 0);
80 throw std::runtime_error(std::string("USER::USER() - socket creation error: '") + strerror(errno) + "', ip: " + inet_ntostring(ip) + ", login: " + login);
83 struct sockaddr_in addr;
85 addr.sin_family = AF_INET;
86 addr.sin_addr.s_addr = ip;
87 addr.sin_port = htons(5554); // :(
89 int res = bind(sock, (struct sockaddr *)&addr, sizeof(addr));
92 throw std::runtime_error(std::string("USER::USER() - bind error: '") + strerror(errno) + "', ip: " + inet_ntostring(ip) + ", login: " + login);