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,
24 unsigned char key[IA_PASSWD_LEN];
25 memset(key, 0, IA_PASSWD_LEN);
26 strncpy((char *)key, password.c_str(), IA_PASSWD_LEN);
27 Blowfish_Init(&ctx, key, IA_PASSWD_LEN);
30 USER::USER(const USER & rvalue)
31 : login(rvalue.login),
32 password(rvalue.password),
34 aliveTimeout(rvalue.aliveTimeout),
35 userTimeout(rvalue.userTimeout),
40 unsigned char key[IA_PASSWD_LEN];
41 memset(key, 0, IA_PASSWD_LEN);
42 strncpy((char *)key, password.c_str(), IA_PASSWD_LEN);
43 Blowfish_Init(&ctx, key, IA_PASSWD_LEN);
51 const USER & USER::operator=(const USER & rvalue)
54 password = rvalue.password;
56 aliveTimeout = rvalue.aliveTimeout;
57 userTimeout = rvalue.userTimeout;
62 unsigned char key[IA_PASSWD_LEN];
63 memset(key, 0, IA_PASSWD_LEN);
64 strncpy((char *)key, password.c_str(), IA_PASSWD_LEN);
65 Blowfish_Init(&ctx, key, IA_PASSWD_LEN);
70 bool USER::InitNetwork()
72 sock = socket(AF_INET, SOCK_DGRAM, 0);
74 struct sockaddr_in addr;
76 addr.sin_family = AF_INET;
77 addr.sin_addr.s_addr = ip;
78 addr.sin_port = htons(5554); // :(
80 int res = bind(sock, (struct sockaddr *)&addr, sizeof(addr));
83 throw std::runtime_error(std::string("USER::USER() - bind error: '") + strerror(errno) + "', ip: " + inet_ntostring(ip) + ", login: " + login);