Complete moving all connection related data out of the hub_user object.
This commit is contained in:
parent
cfb450c3fc
commit
86ba3ca86f
|
@ -42,8 +42,9 @@ static void inf_create_user()
|
||||||
{
|
{
|
||||||
if (inf_user) return;
|
if (inf_user) return;
|
||||||
inf_user = (struct hub_user*) hub_malloc_zero(sizeof(struct hub_user));
|
inf_user = (struct hub_user*) hub_malloc_zero(sizeof(struct hub_user));
|
||||||
|
inf_user->connection = (struct net_connection*) hub_malloc_zero(sizeof(struct net_connection));
|
||||||
inf_user->id.sid = 1;
|
inf_user->id.sid = 1;
|
||||||
inf_user->net.connection.sd = -1;
|
inf_user->connection->sd = -1;
|
||||||
inf_user->limits.upload_slots = 1;
|
inf_user->limits.upload_slots = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
static struct hub_info um_hub;
|
static struct hub_info um_hub;
|
||||||
static struct hub_user um_user[MAX_USERS];
|
static struct hub_user um_user[MAX_USERS];
|
||||||
|
static struct net_connection um_cons[MAX_USERS];
|
||||||
|
|
||||||
EXO_TEST(um_test_setup, {
|
EXO_TEST(um_test_setup, {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -11,9 +12,12 @@ EXO_TEST(um_test_setup, {
|
||||||
|
|
||||||
for (i = 0; i < MAX_USERS; i++)
|
for (i = 0; i < MAX_USERS; i++)
|
||||||
{
|
{
|
||||||
|
memset(&um_cons[i], 0, sizeof(struct net_connection));
|
||||||
|
um_cons[i].sd = -1;
|
||||||
|
|
||||||
memset(&um_user[i], 0, sizeof(struct hub_user));
|
memset(&um_user[i], 0, sizeof(struct hub_user));
|
||||||
um_user[i].id.sid = i+1;
|
um_user[i].id.sid = i+1;
|
||||||
um_user[i].net.connection.sd = -1;
|
um_user[i].connection = &um_cons[i];
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
|
@ -443,7 +443,7 @@ const char* acl_password_generate_challenge(struct acl_handle* acl, struct hub_u
|
||||||
uint64_t tiger_res[3];
|
uint64_t tiger_res[3];
|
||||||
static char tiger_buf[MAX_CID_LEN+1];
|
static char tiger_buf[MAX_CID_LEN+1];
|
||||||
|
|
||||||
snprintf(buf, 32, "%d%d%d", (int) user->net.tm_connected, (int) user->id.sid, (int) user->net.connection.sd);
|
snprintf(buf, 32, "%d%d%d", (int) user->tm_connected, (int) user->id.sid, (int) user->connection->sd);
|
||||||
|
|
||||||
tiger((uint64_t*) buf, strlen(buf), (uint64_t*) tiger_res);
|
tiger((uint64_t*) buf, strlen(buf), (uint64_t*) tiger_res);
|
||||||
base32_encode((unsigned char*) tiger_res, TIGERSIZE, tiger_buf);
|
base32_encode((unsigned char*) tiger_res, TIGERSIZE, tiger_buf);
|
||||||
|
|
|
@ -290,7 +290,7 @@ static int command_version(struct hub_info* hub, struct hub_user* user, struct h
|
||||||
static int command_myip(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
static int command_myip(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||||
{
|
{
|
||||||
char tmp[128];
|
char tmp[128];
|
||||||
snprintf(tmp, 128, "Your address is \"%s\"", ip_convert_to_string(&user->net.connection.ipaddr));
|
snprintf(tmp, 128, "Your address is \"%s\"", net_con_get_peer_address(user->connection));
|
||||||
return command_status(hub, user, cmd, tmp);
|
return command_status(hub, user, cmd, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ static int command_getip(struct hub_info* hub, struct hub_user* user, struct hub
|
||||||
if (!target)
|
if (!target)
|
||||||
return command_status_user_not_found(hub, user, cmd, nick);
|
return command_status_user_not_found(hub, user, cmd, nick);
|
||||||
|
|
||||||
snprintf(tmp, 128, "%s has address \"%s\"", nick, ip_convert_to_string(&target->net.connection.ipaddr));
|
snprintf(tmp, 128, "%s has address \"%s\"", nick, net_con_get_peer_address(user->connection));
|
||||||
return command_status(hub, user, cmd, tmp);
|
return command_status(hub, user, cmd, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ static int command_whoip(struct hub_info* hub, struct hub_user* user, struct hub
|
||||||
{
|
{
|
||||||
strcat(buffer, u->id.nick);
|
strcat(buffer, u->id.nick);
|
||||||
strcat(buffer, " (");
|
strcat(buffer, " (");
|
||||||
strcat(buffer, ip_convert_to_string(&u->net.connection.ipaddr));
|
strcat(buffer, net_con_get_peer_address(u->connection));
|
||||||
strcat(buffer, ")\n");
|
strcat(buffer, ")\n");
|
||||||
u = (struct hub_user*) list_get_next(users);
|
u = (struct hub_user*) list_get_next(users);
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ int hub_handle_support(struct hub_info* hub, struct hub_user* u, struct adc_mess
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
hub_send_handshake(hub, u);
|
hub_send_handshake(hub, u);
|
||||||
net_con_set_timeout(&u->net.connection, TIMEOUT_HANDSHAKE);
|
net_con_set_timeout(u->connection, TIMEOUT_HANDSHAKE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1018,8 +1018,8 @@ void hub_disconnect_user(struct hub_info* hub, struct hub_user* user, int reason
|
||||||
}
|
}
|
||||||
|
|
||||||
/* stop reading from user */
|
/* stop reading from user */
|
||||||
net_shutdown_r(user->net.connection.sd);
|
net_shutdown_r(user->connection->sd);
|
||||||
net_con_close(&user->net.connection);
|
net_con_close(user->connection);
|
||||||
|
|
||||||
LOG_TRACE("hub_disconnect_user(), user=%p, reason=%d, state=%d", user, reason, user->state);
|
LOG_TRACE("hub_disconnect_user(), user=%p, reason=%d, state=%d", user, reason, user->state);
|
||||||
|
|
||||||
|
@ -1047,7 +1047,7 @@ void hub_logout_log(struct hub_info* hub, struct hub_user* user)
|
||||||
loginfo->time = time(NULL);
|
loginfo->time = time(NULL);
|
||||||
strcpy(loginfo->cid, user->id.cid);
|
strcpy(loginfo->cid, user->id.cid);
|
||||||
strcpy(loginfo->nick, user->id.nick);
|
strcpy(loginfo->nick, user->id.nick);
|
||||||
memcpy(&loginfo->addr, &user->net.connection.ipaddr, sizeof(struct ip_addr_encap));
|
memcpy(&loginfo->addr, &user->connection->ipaddr, sizeof(struct ip_addr_encap));
|
||||||
loginfo->reason = user->quit_reason;
|
loginfo->reason = user->quit_reason;
|
||||||
|
|
||||||
list_append(hub->logout_info, loginfo);
|
list_append(hub->logout_info, loginfo);
|
||||||
|
|
|
@ -22,26 +22,26 @@
|
||||||
static void log_user_login(struct hub_user* u)
|
static void log_user_login(struct hub_user* u)
|
||||||
{
|
{
|
||||||
const char* cred = get_user_credential_string(u->credentials);
|
const char* cred = get_user_credential_string(u->credentials);
|
||||||
const char* addr = ip_convert_to_string(&u->net.connection.ipaddr);
|
const char* addr = net_con_get_peer_address(u->connection);
|
||||||
LOG_USER("LoginOK %s/%s %s \"%s\" (%s) \"%s\"", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, cred, u->user_agent);
|
LOG_USER("LoginOK %s/%s %s \"%s\" (%s) \"%s\"", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, cred, u->user_agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void log_user_login_error(struct hub_user* u, enum status_message msg)
|
static void log_user_login_error(struct hub_user* u, enum status_message msg)
|
||||||
{
|
{
|
||||||
const char* addr = ip_convert_to_string(&u->net.connection.ipaddr);
|
const char* addr = net_con_get_peer_address(u->connection);
|
||||||
const char* message = hub_get_status_message_log(u->hub, msg);
|
const char* message = hub_get_status_message_log(u->hub, msg);
|
||||||
LOG_USER("LoginError %s/%s %s \"%s\" (%s) \"%s\"", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, message, u->user_agent);
|
LOG_USER("LoginError %s/%s %s \"%s\" (%s) \"%s\"", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, message, u->user_agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void log_user_logout(struct hub_user* u, const char* message)
|
static void log_user_logout(struct hub_user* u, const char* message)
|
||||||
{
|
{
|
||||||
const char* addr = ip_convert_to_string(&u->net.connection.ipaddr);
|
const char* addr = net_con_get_peer_address(u->connection);
|
||||||
LOG_USER("Logout %s/%s %s \"%s\" (%s)", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, message);
|
LOG_USER("Logout %s/%s %s \"%s\" (%s)", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void log_user_nick_change(struct hub_user* u, const char* nick)
|
static void log_user_nick_change(struct hub_user* u, const char* nick)
|
||||||
{
|
{
|
||||||
const char* addr = ip_convert_to_string(&u->net.connection.ipaddr);
|
const char* addr = net_con_get_peer_address(u->connection);
|
||||||
LOG_USER("NickChange %s/%s %s \"%s\" -> \"%s\"", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, nick);
|
LOG_USER("NickChange %s/%s %s \"%s\" -> \"%s\"", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ void on_login_success(struct hub_info* hub, struct hub_user* u)
|
||||||
hub_send_motd(hub, u);
|
hub_send_motd(hub, u);
|
||||||
|
|
||||||
/* reset timeout */
|
/* reset timeout */
|
||||||
net_con_set_timeout(&u->net.connection, TIMEOUT_IDLE);
|
net_con_set_timeout(u->connection, TIMEOUT_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_login_failure(struct hub_info* hub, struct hub_user* u, enum status_message msg)
|
void on_login_failure(struct hub_info* hub, struct hub_user* u, enum status_message msg)
|
||||||
|
|
|
@ -186,7 +186,7 @@ static int check_required_login_flags(struct hub_info* hub, struct hub_user* use
|
||||||
*/
|
*/
|
||||||
int check_network(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
int check_network(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||||
{
|
{
|
||||||
const char* address = ip_convert_to_string(&user->net.connection.ipaddr);
|
const char* address = net_con_get_peer_address(user->connection);
|
||||||
|
|
||||||
/* Check for NAT override address */
|
/* Check for NAT override address */
|
||||||
if (acl_is_ip_nat_override(hub->acl, address))
|
if (acl_is_ip_nat_override(hub->acl, address))
|
||||||
|
|
|
@ -55,7 +55,7 @@ void debug_sendq_recv(struct hub_user* user, int received, int max, const char*
|
||||||
int net_user_send(void* ptr, const void* buf, size_t len)
|
int net_user_send(void* ptr, const void* buf, size_t len)
|
||||||
{
|
{
|
||||||
struct hub_user* user = (struct hub_user*) ptr;
|
struct hub_user* user = (struct hub_user*) ptr;
|
||||||
int ret = net_con_send(&user->net.connection, buf, len);
|
int ret = net_con_send(user->connection, buf, len);
|
||||||
#ifdef DEBUG_SENDQ
|
#ifdef DEBUG_SENDQ
|
||||||
debug_sendq_send(user, ret, len);
|
debug_sendq_send(user, ret, len);
|
||||||
#endif
|
#endif
|
||||||
|
@ -70,7 +70,7 @@ int net_user_send(void* ptr, const void* buf, size_t len)
|
||||||
int net_user_recv(void* ptr, void* buf, size_t len)
|
int net_user_recv(void* ptr, void* buf, size_t len)
|
||||||
{
|
{
|
||||||
struct hub_user* user = (struct hub_user*) ptr;
|
struct hub_user* user = (struct hub_user*) ptr;
|
||||||
int ret = net_con_recv(&user->net.connection, buf, len);
|
int ret = net_con_recv(user->connection, buf, len);
|
||||||
#ifdef DEBUG_SENDQ
|
#ifdef DEBUG_SENDQ
|
||||||
debug_sendq_recv(user, ret, len, buf);
|
debug_sendq_recv(user, ret, len, buf);
|
||||||
#endif
|
#endif
|
||||||
|
@ -80,7 +80,7 @@ int net_user_recv(void* ptr, void* buf, size_t len)
|
||||||
int handle_net_read(struct hub_user* user)
|
int handle_net_read(struct hub_user* user)
|
||||||
{
|
{
|
||||||
static char buf[MAX_RECV_BUF];
|
static char buf[MAX_RECV_BUF];
|
||||||
struct hub_recvq* q = user->net.recv_queue;
|
struct hub_recvq* q = user->recv_queue;
|
||||||
size_t buf_size = hub_recvq_get(q, buf, MAX_RECV_BUF);
|
size_t buf_size = hub_recvq_get(q, buf, MAX_RECV_BUF);
|
||||||
ssize_t size = net_user_recv(user, &buf[buf_size], MAX_RECV_BUF - buf_size);
|
ssize_t size = net_user_recv(user, &buf[buf_size], MAX_RECV_BUF - buf_size);
|
||||||
|
|
||||||
|
@ -159,9 +159,9 @@ int handle_net_read(struct hub_user* user)
|
||||||
int handle_net_write(struct hub_user* user)
|
int handle_net_write(struct hub_user* user)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
while (hub_sendq_get_bytes(user->net.send_queue))
|
while (hub_sendq_get_bytes(user->send_queue))
|
||||||
{
|
{
|
||||||
ret = hub_sendq_send(user->net.send_queue, net_user_send, user);
|
ret = hub_sendq_send(user->send_queue, net_user_send, user);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ int handle_net_write(struct hub_user* user)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return quit_socket_error;
|
return quit_socket_error;
|
||||||
|
|
||||||
if (hub_sendq_get_bytes(user->net.send_queue))
|
if (hub_sendq_get_bytes(user->send_queue))
|
||||||
{
|
{
|
||||||
user_net_io_want_write(user);
|
user_net_io_want_write(user);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,10 +80,10 @@ static inline int check_send_queue(struct hub_info* hub, struct hub_user* user,
|
||||||
if (user_flag_get(user, flag_user_list))
|
if (user_flag_get(user, flag_user_list))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ((user->net.send_queue->size + msg->length) > get_max_send_queue(hub))
|
if ((user->send_queue->size + msg->length) > get_max_send_queue(hub))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (user->net.send_queue->size > get_max_send_queue_soft(hub) && msg->priority < 0)
|
if (user->send_queue->size > get_max_send_queue_soft(hub) && msg->priority < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -97,17 +97,17 @@ int route_to_user(struct hub_info* hub, struct hub_user* user, struct adc_messag
|
||||||
free(data);
|
free(data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (hub_sendq_is_empty(user->net.send_queue) && !user_flag_get(user, flag_pipeline))
|
if (hub_sendq_is_empty(user->send_queue) && !user_flag_get(user, flag_pipeline))
|
||||||
{
|
{
|
||||||
/* Perform oportunistic write */
|
/* Perform oportunistic write */
|
||||||
hub_sendq_add(user->net.send_queue, msg);
|
hub_sendq_add(user->send_queue, msg);
|
||||||
handle_net_write(user);
|
handle_net_write(user);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (check_send_queue(hub, user, msg) >= 0)
|
if (check_send_queue(hub, user, msg) >= 0)
|
||||||
{
|
{
|
||||||
hub_sendq_add(user->net.send_queue, msg);
|
hub_sendq_add(user->send_queue, msg);
|
||||||
if (!user_flag_get(user, flag_pipeline))
|
if (!user_flag_get(user, flag_pipeline))
|
||||||
user_net_io_want_write(user);
|
user_net_io_want_write(user);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ int route_to_user(struct hub_info* hub, struct hub_user* user, struct adc_messag
|
||||||
|
|
||||||
int route_flush_pipeline(struct hub_info* hub, struct hub_user* u)
|
int route_flush_pipeline(struct hub_info* hub, struct hub_user* u)
|
||||||
{
|
{
|
||||||
if (hub_sendq_is_empty(u->net.send_queue))
|
if (hub_sendq_is_empty(u->send_queue))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
handle_net_write(u);
|
handle_net_write(u);
|
||||||
|
@ -197,7 +197,7 @@ int route_info_message(struct hub_info* hub, struct hub_user* u)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct adc_message* cmd = adc_msg_copy(u->info);
|
struct adc_message* cmd = adc_msg_copy(u->info);
|
||||||
const char* address = ip_convert_to_string(&u->net.connection.ipaddr);
|
const char* address = net_con_get_peer_address(u->connection);
|
||||||
struct hub_user* user = 0;
|
struct hub_user* user = 0;
|
||||||
|
|
||||||
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR);
|
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR);
|
||||||
|
|
|
@ -46,12 +46,13 @@ struct hub_user* user_create(struct hub_info* hub, int sd, struct ip_addr_encap*
|
||||||
if (user == NULL)
|
if (user == NULL)
|
||||||
return NULL; /* OOM */
|
return NULL; /* OOM */
|
||||||
|
|
||||||
user->net.tm_connected = time(NULL);
|
user->tm_connected = time(NULL);
|
||||||
user->net.send_queue = hub_sendq_create();
|
user->send_queue = hub_sendq_create();
|
||||||
user->net.recv_queue = hub_recvq_create();
|
user->recv_queue = hub_recvq_create();
|
||||||
|
|
||||||
net_con_initialize(&user->net.connection, sd, addr, net_event, user, NET_EVENT_READ);
|
user->connection = (struct net_connection*) hub_malloc(sizeof(struct net_connection));
|
||||||
net_con_set_timeout(&user->net.connection, TIMEOUT_CONNECTED);
|
net_con_initialize(user->connection, sd, addr, net_event, user, NET_EVENT_READ);
|
||||||
|
net_con_set_timeout(user->connection, TIMEOUT_CONNECTED);
|
||||||
|
|
||||||
user_set_state(user, state_protocol);
|
user_set_state(user, state_protocol);
|
||||||
return user;
|
return user;
|
||||||
|
@ -62,8 +63,8 @@ void user_destroy(struct hub_user* user)
|
||||||
{
|
{
|
||||||
LOG_TRACE("user_destroy(), user=%p", user);
|
LOG_TRACE("user_destroy(), user=%p", user);
|
||||||
|
|
||||||
hub_recvq_destroy(user->net.recv_queue);
|
hub_recvq_destroy(user->recv_queue);
|
||||||
hub_sendq_destroy(user->net.send_queue);
|
hub_sendq_destroy(user->send_queue);
|
||||||
|
|
||||||
adc_msg_free(user->info);
|
adc_msg_free(user->info);
|
||||||
user_clear_feature_cast_support(user);
|
user_clear_feature_cast_support(user);
|
||||||
|
@ -314,12 +315,12 @@ int user_is_registered(struct hub_user* user)
|
||||||
|
|
||||||
void user_net_io_want_write(struct hub_user* user)
|
void user_net_io_want_write(struct hub_user* user)
|
||||||
{
|
{
|
||||||
net_con_update(&user->net.connection, NET_EVENT_READ | NET_EVENT_WRITE);
|
net_con_update(user->connection, NET_EVENT_READ | NET_EVENT_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void user_net_io_want_read(struct hub_user* user)
|
void user_net_io_want_read(struct hub_user* user)
|
||||||
{
|
{
|
||||||
net_con_update(&user->net.connection, NET_EVENT_READ);
|
net_con_update(user->connection, NET_EVENT_READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* user_get_quit_reason_string(enum user_quit_reason reason)
|
const char* user_get_quit_reason_string(enum user_quit_reason reason)
|
||||||
|
|
|
@ -97,17 +97,8 @@ struct hub_user_limits
|
||||||
size_t hub_count_total; /** The number of hubs connected to in total */
|
size_t hub_count_total; /** The number of hubs connected to in total */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hub_user_net_io
|
|
||||||
{
|
|
||||||
struct net_connection connection; /** Connection data */
|
|
||||||
struct hub_recvq* recv_queue;
|
|
||||||
struct hub_sendq* send_queue;
|
|
||||||
time_t tm_connected; /** time when user connected */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hub_user
|
struct hub_user
|
||||||
{
|
{
|
||||||
struct hub_user_net_io net; /** Network information data */
|
|
||||||
enum user_state state; /** see enum user_state */
|
enum user_state state; /** see enum user_state */
|
||||||
enum user_credentials credentials; /** see enum user_credentials */
|
enum user_credentials credentials; /** see enum user_credentials */
|
||||||
struct hub_user_info id; /** Contains nick name and CID */
|
struct hub_user_info id; /** Contains nick name and CID */
|
||||||
|
@ -116,6 +107,10 @@ struct hub_user
|
||||||
struct linked_list* feature_cast; /** Features supported by feature cast */
|
struct linked_list* feature_cast; /** Features supported by feature cast */
|
||||||
struct adc_message* info; /** ADC 'INF' message (broadcasted to everyone joining the hub) */
|
struct adc_message* info; /** ADC 'INF' message (broadcasted to everyone joining the hub) */
|
||||||
struct hub_info* hub; /** The hub instance this user belong to */
|
struct hub_info* hub; /** The hub instance this user belong to */
|
||||||
|
struct hub_recvq* recv_queue;
|
||||||
|
struct hub_sendq* send_queue;
|
||||||
|
struct net_connection* connection; /** Connection data */
|
||||||
|
time_t tm_connected; /** time when user connected */
|
||||||
struct hub_user_limits limits; /** Data used for limitation */
|
struct hub_user_limits limits; /** Data used for limitation */
|
||||||
enum user_quit_reason quit_reason; /** Quit reason (see user_quit_reason) */
|
enum user_quit_reason quit_reason; /** Quit reason (see user_quit_reason) */
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ size_t uman_get_user_by_addr(struct hub_info* hub, struct linked_list* users, st
|
||||||
struct hub_user* user = (struct hub_user*) list_get_first(hub->users->list); /* iterate users - only on incoming INF msg */
|
struct hub_user* user = (struct hub_user*) list_get_first(hub->users->list); /* iterate users - only on incoming INF msg */
|
||||||
while (user)
|
while (user)
|
||||||
{
|
{
|
||||||
if (ip_in_range(&user->net.connection.ipaddr, range))
|
if (ip_in_range(&user->connection->ipaddr, range))
|
||||||
{
|
{
|
||||||
list_append(users, user);
|
list_append(users, user);
|
||||||
num++;
|
num++;
|
||||||
|
|
|
@ -104,6 +104,11 @@ static void net_con_event(int fd, short ev, void *arg)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* net_con_get_peer_address(struct net_connection* con)
|
||||||
|
{
|
||||||
|
return ip_convert_to_string(&con->ipaddr);
|
||||||
|
}
|
||||||
|
|
||||||
void net_con_initialize(struct net_connection* con, int sd, struct ip_addr_encap* addr, net_connection_cb callback, const void* ptr, int ev)
|
void net_con_initialize(struct net_connection* con, int sd, struct ip_addr_encap* addr, net_connection_cb callback, const void* ptr, int ev)
|
||||||
{
|
{
|
||||||
int events = net_con_convert_to_libevent_mask(ev);
|
int events = net_con_convert_to_libevent_mask(ev);
|
||||||
|
|
|
@ -72,6 +72,12 @@ extern ssize_t net_con_recv(struct net_connection* con, void* buf, size_t len);
|
||||||
extern void net_con_set_timeout(struct net_connection* con, int seconds);
|
extern void net_con_set_timeout(struct net_connection* con, int seconds);
|
||||||
extern void net_con_clear_timeout(struct net_connection* con);
|
extern void net_con_clear_timeout(struct net_connection* con);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation of the ipaddr member.
|
||||||
|
* NOTE: Static buffer.
|
||||||
|
*/
|
||||||
|
extern const char* net_con_get_peer_address(struct net_connection* con);
|
||||||
|
|
||||||
#ifdef SSL_SUPPORT
|
#ifdef SSL_SUPPORT
|
||||||
/**
|
/**
|
||||||
* Start SSL_accept()
|
* Start SSL_accept()
|
||||||
|
|
Loading…
Reference in New Issue