Renamed all "struct user" to hub_user in order to resolve a naming conflict on OpenWRT.
Basically: sed -i 's/struct user/struct hub_user/g' `find -type f`
This commit is contained in:
parent
2ac5cc19cb
commit
367871e476
@ -10,8 +10,8 @@ static void create_test_user()
|
||||
if (g_user)
|
||||
return;
|
||||
|
||||
g_user = (struct user*) malloc(sizeof(struct user));
|
||||
memset(g_user, 0, sizeof(struct user));
|
||||
g_user = (struct hub_user*) malloc(sizeof(struct hub_user));
|
||||
memset(g_user, 0, sizeof(struct hub_user));
|
||||
memcpy(g_user->id.nick, "exotic-tester", 13);
|
||||
g_user->sid = 1;
|
||||
}
|
||||
|
@ -5,15 +5,15 @@
|
||||
#define USER_NICK "Friend"
|
||||
#define USER_SID "AAAB"
|
||||
|
||||
static struct user* inf_user = 0;
|
||||
static struct hub_user* inf_user = 0;
|
||||
static struct hub_info* inf_hub = 0;
|
||||
|
||||
extern int hub_handle_info_login(struct hub_info* hub, struct user* user, struct adc_message* cmd);
|
||||
extern int hub_handle_info_login(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd);
|
||||
|
||||
static void inf_create_hub()
|
||||
{
|
||||
inf_hub = (struct hub_info*) hub_malloc_zero(sizeof(struct hub_info));
|
||||
inf_hub->users = (struct user_manager*) hub_malloc_zero(sizeof(struct user_manager));
|
||||
inf_hub->users = (struct hub_user_manager*) hub_malloc_zero(sizeof(struct hub_user_manager));
|
||||
inf_hub->users->list = list_create();
|
||||
inf_hub->users->free_sid = 1;
|
||||
|
||||
@ -40,7 +40,7 @@ static void inf_destroy_hub()
|
||||
static void inf_create_user()
|
||||
{
|
||||
if (inf_user) return;
|
||||
inf_user = (struct user*) hub_malloc_zero(sizeof(struct user));
|
||||
inf_user = (struct hub_user*) hub_malloc_zero(sizeof(struct hub_user));
|
||||
inf_user->id.sid = 1;
|
||||
inf_user->net.sd = -1;
|
||||
inf_user->limits.upload_slots = 1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <uhub.h>
|
||||
static struct user* g_user = 0;
|
||||
static struct hub_user* g_user = 0;
|
||||
static const char* test_string1 = "IINF AAfoo BBbar CCwhat\n";
|
||||
static const char* test_string2 = "BMSG AAAB Hello\\sWorld!\n";
|
||||
static const char* test_string3 = "BINF AAAB IDAN7ZMSLIEBL53OPTM7WXGSTXUS3XOY6KQS5LBGX NIFriend DEstuff SL3 SS0 SF0 VEQuickDC/0.4.17 US6430 SUADC0,TCP4,UDP4 I4127.0.0.1 HO5 HN1 AW\n";
|
||||
@ -11,8 +11,8 @@ static void create_test_user()
|
||||
if (g_user)
|
||||
return;
|
||||
|
||||
g_user = (struct user*) malloc(sizeof(struct user));
|
||||
memset(g_user, 0, sizeof(struct user));
|
||||
g_user = (struct hub_user*) malloc(sizeof(struct hub_user));
|
||||
memset(g_user, 0, sizeof(struct hub_user));
|
||||
memcpy(g_user->id.nick, "exotic-tester", 13);
|
||||
g_user->id.sid = 1;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#define MAX_USERS 64
|
||||
|
||||
static struct hub_info um_hub;
|
||||
static struct user um_user[MAX_USERS];
|
||||
static struct hub_user um_user[MAX_USERS];
|
||||
|
||||
EXO_TEST(um_test_setup, {
|
||||
int i = 0;
|
||||
@ -11,7 +11,7 @@ EXO_TEST(um_test_setup, {
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
memset(&um_user[i], 0, sizeof(struct user));
|
||||
memset(&um_user[i], 0, sizeof(struct hub_user));
|
||||
um_user[i].id.sid = i+1;
|
||||
um_user[i].net.sd = -1;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ struct adc_message* adc_msg_copy(const struct adc_message* cmd)
|
||||
}
|
||||
|
||||
|
||||
struct adc_message* adc_msg_parse_verify(struct user* u, const char* line, size_t length)
|
||||
struct adc_message* adc_msg_parse_verify(struct hub_user* u, const char* line, size_t length)
|
||||
{
|
||||
struct adc_message* command = adc_msg_parse(line, length);
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef HAVE_UHUB_COMMAND_H
|
||||
#define HAVE_UHUB_COMMAND_H
|
||||
|
||||
struct user;
|
||||
struct hub_user;
|
||||
|
||||
struct adc_message
|
||||
{
|
||||
@ -70,7 +70,7 @@ extern struct adc_message* adc_msg_copy(const struct adc_message* cmd);
|
||||
* The message is only considered valid if the user who sent it
|
||||
* is the rightful origin of the message.
|
||||
*/
|
||||
extern struct adc_message* adc_msg_parse_verify(struct user* u, const char* string, size_t length);
|
||||
extern struct adc_message* adc_msg_parse_verify(struct hub_user* u, const char* string, size_t length);
|
||||
|
||||
/**
|
||||
* This will parse 'string' and return it as a adc_message struct, or
|
||||
|
@ -28,7 +28,7 @@ extern sid_t string_to_sid(const char* sid);
|
||||
|
||||
struct sid_map
|
||||
{
|
||||
struct user* ptr;
|
||||
struct hub_user* ptr;
|
||||
struct sid_map* next;
|
||||
};
|
||||
|
||||
@ -58,7 +58,7 @@ struct sid_pool
|
||||
|
||||
|
||||
extern void sid_initialize(struct sid_pool*);
|
||||
extern sid_t sid_alloc(struct sid_pool*, struct user*);
|
||||
extern sid_t sid_alloc(struct sid_pool*, struct hub_user*);
|
||||
extern void sid_free(struct sid_pool*, sid_t);
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ static int check_cmd_user(const char* cmd, int status, struct linked_list* list,
|
||||
{
|
||||
char* data;
|
||||
char* data_extra;
|
||||
struct user_access_info* info = 0;
|
||||
struct hub_user_access_info* info = 0;
|
||||
|
||||
if (!strncmp(line, cmd, strlen(cmd)))
|
||||
{
|
||||
@ -86,7 +86,7 @@ static int check_cmd_user(const char* cmd, int status, struct linked_list* list,
|
||||
return -1;
|
||||
}
|
||||
|
||||
info = hub_malloc_zero(sizeof(struct user_access_info));
|
||||
info = hub_malloc_zero(sizeof(struct hub_user_access_info));
|
||||
|
||||
if (!info)
|
||||
{
|
||||
@ -336,7 +336,7 @@ int acl_initialize(struct hub_config* config, struct acl_handle* handle)
|
||||
|
||||
static void acl_free_access_info(void* ptr)
|
||||
{
|
||||
struct user_access_info* info = (struct user_access_info*) ptr;
|
||||
struct hub_user_access_info* info = (struct hub_user_access_info*) ptr;
|
||||
if (info)
|
||||
{
|
||||
hub_free(info->username);
|
||||
@ -400,16 +400,16 @@ int acl_shutdown(struct acl_handle* handle)
|
||||
}
|
||||
|
||||
|
||||
struct user_access_info* acl_get_access_info(struct acl_handle* handle, const char* name)
|
||||
struct hub_user_access_info* acl_get_access_info(struct acl_handle* handle, const char* name)
|
||||
{
|
||||
struct user_access_info* info = (struct user_access_info*) list_get_first(handle->users);
|
||||
struct hub_user_access_info* info = (struct hub_user_access_info*) list_get_first(handle->users);
|
||||
while (info)
|
||||
{
|
||||
if (strcasecmp(info->username, name) == 0)
|
||||
{
|
||||
return info;
|
||||
}
|
||||
info = (struct user_access_info*) list_get_next(handle->users);
|
||||
info = (struct hub_user_access_info*) list_get_next(handle->users);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -444,7 +444,7 @@ int acl_is_user_denied(struct acl_handle* handle, const char* data)
|
||||
|
||||
int acl_user_ban_nick(struct acl_handle* handle, const char* nick)
|
||||
{
|
||||
struct user_access_info* info = hub_malloc_zero(sizeof(struct user_access_info));
|
||||
struct hub_user_access_info* info = hub_malloc_zero(sizeof(struct hub_user_access_info));
|
||||
if (!info)
|
||||
{
|
||||
LOG_ERROR("ACL error: Out of memory!");
|
||||
@ -456,7 +456,7 @@ int acl_user_ban_nick(struct acl_handle* handle, const char* nick)
|
||||
|
||||
int acl_user_ban_cid(struct acl_handle* handle, const char* cid)
|
||||
{
|
||||
struct user_access_info* info = hub_malloc_zero(sizeof(struct user_access_info));
|
||||
struct hub_user_access_info* info = hub_malloc_zero(sizeof(struct hub_user_access_info));
|
||||
if (!info)
|
||||
{
|
||||
LOG_ERROR("ACL error: Out of memory!");
|
||||
@ -523,7 +523,7 @@ int acl_check_ip_range(struct ip_addr_encap* addr, struct ip_ban_record* info)
|
||||
* seconds since the unix epoch (modulus 1 million)
|
||||
* and the SID of the user (0-1 million).
|
||||
*/
|
||||
const char* acl_password_generate_challenge(struct acl_handle* acl, struct user* user)
|
||||
const char* acl_password_generate_challenge(struct acl_handle* acl, struct hub_user* user)
|
||||
{
|
||||
char buf[32];
|
||||
uint64_t tiger_res[3];
|
||||
@ -538,10 +538,10 @@ const char* acl_password_generate_challenge(struct acl_handle* acl, struct user*
|
||||
}
|
||||
|
||||
|
||||
int acl_password_verify(struct acl_handle* acl, struct user* user, const char* password)
|
||||
int acl_password_verify(struct acl_handle* acl, struct hub_user* user, const char* password)
|
||||
{
|
||||
char buf[1024];
|
||||
struct user_access_info* access;
|
||||
struct hub_user_access_info* access;
|
||||
const char* challenge;
|
||||
char raw_challenge[64];
|
||||
char password_calc[64];
|
||||
|
@ -21,7 +21,7 @@
|
||||
#define HAVE_UHUB_ACL_H
|
||||
|
||||
struct hub_config;
|
||||
struct user;
|
||||
struct hub_user;
|
||||
struct ip_addr_encap;
|
||||
|
||||
enum user_credentials
|
||||
@ -38,7 +38,7 @@ enum user_credentials
|
||||
|
||||
const char* get_user_credential_string(enum user_credentials cred);
|
||||
|
||||
struct user_access_info
|
||||
struct hub_user_access_info
|
||||
{
|
||||
char* username; /* name of user, cid or IP range */
|
||||
char* password; /* password */
|
||||
@ -65,7 +65,7 @@ struct acl_handle
|
||||
extern int acl_initialize(struct hub_config* config, struct acl_handle* handle);
|
||||
extern int acl_shutdown(struct acl_handle* handle);
|
||||
|
||||
extern struct user_access_info* acl_get_access_info(struct acl_handle* handle, const char* name);
|
||||
extern struct hub_user_access_info* acl_get_access_info(struct acl_handle* handle, const char* name);
|
||||
extern int acl_is_cid_banned(struct acl_handle* handle, const char* cid);
|
||||
extern int acl_is_ip_banned(struct acl_handle* handle, const char* ip_address);
|
||||
extern int acl_is_ip_nat_override(struct acl_handle* handle, const char* ip_address);
|
||||
@ -80,7 +80,7 @@ extern int acl_user_unban_cid(struct acl_handle* handle, const char* cid);
|
||||
|
||||
extern int acl_check_ip_range(struct ip_addr_encap* addr, struct ip_ban_record* info);
|
||||
|
||||
extern const char* acl_password_generate_challenge(struct acl_handle* acl, struct user* user);
|
||||
extern const char* acl_password_generate_challenge(struct acl_handle* acl, struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Verify a password.
|
||||
@ -88,6 +88,6 @@ extern const char* acl_password_generate_challenge(struct acl_handle* acl, struc
|
||||
* @param password the hashed password (based on the nonce).
|
||||
* @return 1 if the password matches, or 0 if the password is incorrect.
|
||||
*/
|
||||
extern int acl_password_verify(struct acl_handle* acl, struct user* user, const char* password);
|
||||
extern int acl_password_verify(struct acl_handle* acl, struct hub_user* user, const char* password);
|
||||
|
||||
#endif /* HAVE_UHUB_ACL_H */
|
||||
|
@ -33,7 +33,7 @@ struct hub_command
|
||||
struct linked_list* args;
|
||||
};
|
||||
|
||||
typedef int (*command_handler)(struct hub_info* hub, struct user* user, struct hub_command*);
|
||||
typedef int (*command_handler)(struct hub_info* hub, struct hub_user* user, struct hub_command*);
|
||||
|
||||
struct commands_handler
|
||||
{
|
||||
@ -92,7 +92,7 @@ static struct hub_command* command_create(const char* message)
|
||||
return cmd;
|
||||
}
|
||||
|
||||
static void send_message(struct hub_info* hub, struct user* user, const char* message)
|
||||
static void send_message(struct hub_info* hub, struct hub_user* user, const char* message)
|
||||
{
|
||||
char* buffer = adc_msg_escape(message);
|
||||
struct adc_message* command = adc_msg_construct(ADC_CMD_IMSG, strlen(buffer) + 6);
|
||||
@ -102,7 +102,7 @@ static void send_message(struct hub_info* hub, struct user* user, const char* me
|
||||
hub_free(buffer);
|
||||
}
|
||||
|
||||
static int command_access_denied(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_access_denied(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
char temp[128];
|
||||
snprintf(temp, 128, "*** %s: Access denied.", cmd->prefix);
|
||||
@ -110,7 +110,7 @@ static int command_access_denied(struct hub_info* hub, struct user* user, struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int command_not_found(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_not_found(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
char temp[128];
|
||||
snprintf(temp, 128, "*** %s: Command not found", cmd->prefix);
|
||||
@ -118,7 +118,7 @@ static int command_not_found(struct hub_info* hub, struct user* user, struct hub
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int command_status_user_not_found(struct hub_info* hub, struct user* user, struct hub_command* cmd, const char* nick)
|
||||
static int command_status_user_not_found(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd, const char* nick)
|
||||
{
|
||||
char temp[128];
|
||||
snprintf(temp, 128, "*** %s: No user \"%s\"", cmd->prefix, nick);
|
||||
@ -147,7 +147,7 @@ const char* command_get_syntax(struct commands_handler* handler)
|
||||
return args;
|
||||
}
|
||||
|
||||
static int command_arg_mismatch(struct hub_info* hub, struct user* user, struct hub_command* cmd, struct commands_handler* handler)
|
||||
static int command_arg_mismatch(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd, struct commands_handler* handler)
|
||||
{
|
||||
char temp[256];
|
||||
const char* args = command_get_syntax(handler);
|
||||
@ -157,7 +157,7 @@ static int command_arg_mismatch(struct hub_info* hub, struct user* user, struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int command_status(struct hub_info* hub, struct user* user, struct hub_command* cmd, const char* message)
|
||||
static int command_status(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd, const char* message)
|
||||
{
|
||||
char temp[1024];
|
||||
snprintf(temp, 1024, "*** %s: %s", cmd->prefix, message);
|
||||
@ -165,7 +165,7 @@ static int command_status(struct hub_info* hub, struct user* user, struct hub_co
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int command_stats(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_stats(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
char temp[128];
|
||||
snprintf(temp, 128, "%zu users, peak: %zu. Network (up/down): %d/%d KB/s, peak: %d/%d KB/s",
|
||||
@ -178,7 +178,7 @@ static int command_stats(struct hub_info* hub, struct user* user, struct hub_com
|
||||
return command_status(hub, user, cmd, temp);
|
||||
}
|
||||
|
||||
static int command_help(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_help(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
size_t n;
|
||||
char msg[MAX_HELP_MSG];
|
||||
@ -199,7 +199,7 @@ static int command_help(struct hub_info* hub, struct user* user, struct hub_comm
|
||||
return command_status(hub, user, cmd, msg);
|
||||
}
|
||||
|
||||
static int command_uptime(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_uptime(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
char tmp[128];
|
||||
size_t d;
|
||||
@ -231,10 +231,10 @@ static int command_uptime(struct hub_info* hub, struct user* user, struct hub_co
|
||||
return command_status(hub, user, cmd, tmp);
|
||||
}
|
||||
|
||||
static int command_kick(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_kick(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
char* nick = list_get_first(cmd->args);
|
||||
struct user* target = uman_get_user_by_nick(hub, nick);
|
||||
struct hub_user* target = uman_get_user_by_nick(hub, nick);
|
||||
|
||||
if (!target)
|
||||
return command_status_user_not_found(hub, user, cmd, nick);
|
||||
@ -246,10 +246,10 @@ static int command_kick(struct hub_info* hub, struct user* user, struct hub_comm
|
||||
return command_status(hub, user, cmd, nick);
|
||||
}
|
||||
|
||||
static int command_ban(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_ban(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
char* nick = list_get_first(cmd->args);
|
||||
struct user* target = uman_get_user_by_nick(hub, nick);
|
||||
struct hub_user* target = uman_get_user_by_nick(hub, nick);
|
||||
|
||||
if (!target)
|
||||
return command_status_user_not_found(hub, user, cmd, nick);
|
||||
@ -264,41 +264,41 @@ static int command_ban(struct hub_info* hub, struct user* user, struct hub_comma
|
||||
return command_status(hub, user, cmd, nick);
|
||||
}
|
||||
|
||||
static int command_unban(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_unban(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
return command_status(hub, user, cmd, "Not implemented");
|
||||
}
|
||||
|
||||
static int command_reload(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_reload(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
hub->status = hub_status_restart;
|
||||
return command_status(hub, user, cmd, "Reloading configuration...");
|
||||
}
|
||||
|
||||
static int command_shutdown(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_shutdown(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
hub->status = hub_status_shutdown;
|
||||
return command_status(hub, user, cmd, "Hub shutting down...");
|
||||
}
|
||||
|
||||
static int command_version(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_version(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
return command_status(hub, user, cmd, "Powered by " PRODUCT "/" VERSION);
|
||||
}
|
||||
|
||||
static int command_myip(struct hub_info* hub, struct 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];
|
||||
snprintf(tmp, 128, "Your address is \"%s\"", ip_convert_to_string(&user->net.ipaddr));
|
||||
return command_status(hub, user, cmd, tmp);
|
||||
}
|
||||
|
||||
static int command_getip(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_getip(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
char tmp[128];
|
||||
|
||||
char* nick = list_get_first(cmd->args);
|
||||
struct user* target = uman_get_user_by_nick(hub, nick);
|
||||
struct hub_user* target = uman_get_user_by_nick(hub, nick);
|
||||
|
||||
if (!target)
|
||||
return command_status_user_not_found(hub, user, cmd, nick);
|
||||
@ -308,7 +308,7 @@ static int command_getip(struct hub_info* hub, struct user* user, struct hub_com
|
||||
}
|
||||
|
||||
#ifdef CRASH_DEBUG
|
||||
static int command_crash(struct hub_info* hub, struct user* user, struct hub_command* cmd)
|
||||
static int command_crash(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
void (*crash)(void) = NULL;
|
||||
crash();
|
||||
@ -316,7 +316,7 @@ static int command_crash(struct hub_info* hub, struct user* user, struct hub_com
|
||||
}
|
||||
#endif
|
||||
|
||||
int command_dipatcher(struct hub_info* hub, struct user* user, const char* message)
|
||||
int command_dipatcher(struct hub_info* hub, struct hub_user* user, const char* message)
|
||||
{
|
||||
size_t n = 0;
|
||||
int rc;
|
||||
|
@ -23,7 +23,7 @@
|
||||
#define CHAT_MSG_IGNORED 0
|
||||
#define CHAT_MSG_INVALID -1
|
||||
|
||||
typedef int (*plugin_event_chat_message)(struct hub_info*, struct user*, struct adc_message*);
|
||||
typedef int (*plugin_event_chat_message)(struct hub_info*, struct hub_user*, struct adc_message*);
|
||||
|
||||
struct command_info
|
||||
{
|
||||
@ -32,4 +32,4 @@ struct command_info
|
||||
plugin_event_chat_message function;
|
||||
};
|
||||
|
||||
int command_dipatcher(struct hub_info* hub, struct user* user, const char* message);
|
||||
int command_dipatcher(struct hub_info* hub, struct hub_user* user, const char* message);
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
struct hub_info* g_hub = 0;
|
||||
|
||||
int hub_handle_message(struct hub_info* hub, struct user* u, const char* line, size_t length)
|
||||
int hub_handle_message(struct hub_info* hub, struct hub_user* u, const char* line, size_t length)
|
||||
{
|
||||
int ret = 0;
|
||||
struct adc_message* cmd = 0;
|
||||
@ -92,7 +92,7 @@ int hub_handle_message(struct hub_info* hub, struct user* u, const char* line, s
|
||||
}
|
||||
|
||||
|
||||
int hub_handle_support(struct hub_info* hub, struct user* u, struct adc_message* cmd)
|
||||
int hub_handle_support(struct hub_info* hub, struct hub_user* u, struct adc_message* cmd)
|
||||
{
|
||||
int ret = 0;
|
||||
int index = 0;
|
||||
@ -155,7 +155,7 @@ int hub_handle_support(struct hub_info* hub, struct user* u, struct adc_message*
|
||||
}
|
||||
|
||||
|
||||
int hub_handle_password(struct hub_info* hub, struct user* u, struct adc_message* cmd)
|
||||
int hub_handle_password(struct hub_info* hub, struct hub_user* u, struct adc_message* cmd)
|
||||
{
|
||||
char* password = adc_msg_get_argument(cmd, 0);
|
||||
int ret = 0;
|
||||
@ -178,7 +178,7 @@ int hub_handle_password(struct hub_info* hub, struct user* u, struct adc_message
|
||||
}
|
||||
|
||||
|
||||
int hub_handle_chat_message(struct hub_info* hub, struct user* u, struct adc_message* cmd)
|
||||
int hub_handle_chat_message(struct hub_info* hub, struct hub_user* u, struct adc_message* cmd)
|
||||
{
|
||||
char* message = adc_msg_get_argument(cmd, 0);
|
||||
int ret = 0;
|
||||
@ -204,7 +204,7 @@ int hub_handle_chat_message(struct hub_info* hub, struct user* u, struct adc_mes
|
||||
return ret;
|
||||
}
|
||||
|
||||
void hub_send_support(struct hub_info* hub, struct user* u)
|
||||
void hub_send_support(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
if (user_is_connecting(u) || user_is_logged_in(u))
|
||||
{
|
||||
@ -213,7 +213,7 @@ void hub_send_support(struct hub_info* hub, struct user* u)
|
||||
}
|
||||
|
||||
|
||||
void hub_send_sid(struct hub_info* hub, struct user* u)
|
||||
void hub_send_sid(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
struct adc_message* command;
|
||||
if (user_is_connecting(u))
|
||||
@ -227,7 +227,7 @@ void hub_send_sid(struct hub_info* hub, struct user* u)
|
||||
}
|
||||
|
||||
|
||||
void hub_send_ping(struct hub_info* hub, struct user* user)
|
||||
void hub_send_ping(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
/* This will just send a newline, despite appearing to do more below. */
|
||||
struct adc_message* ping = adc_msg_construct(0, 0);
|
||||
@ -240,7 +240,7 @@ void hub_send_ping(struct hub_info* hub, struct user* user)
|
||||
}
|
||||
|
||||
|
||||
void hub_send_hubinfo(struct hub_info* hub, struct user* u)
|
||||
void hub_send_hubinfo(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
struct adc_message* info = adc_msg_copy(hub->command_info);
|
||||
int value = 0;
|
||||
@ -306,7 +306,7 @@ void hub_send_hubinfo(struct hub_info* hub, struct user* u)
|
||||
}
|
||||
}
|
||||
|
||||
void hub_send_handshake(struct hub_info* hub, struct user* u)
|
||||
void hub_send_handshake(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
user_flag_set(u, flag_pipeline);
|
||||
hub_send_support(hub, u);
|
||||
@ -320,7 +320,7 @@ void hub_send_handshake(struct hub_info* hub, struct user* u)
|
||||
}
|
||||
}
|
||||
|
||||
void hub_send_motd(struct hub_info* hub, struct user* u)
|
||||
void hub_send_motd(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
if (hub->command_motd)
|
||||
{
|
||||
@ -328,7 +328,7 @@ void hub_send_motd(struct hub_info* hub, struct user* u)
|
||||
}
|
||||
}
|
||||
|
||||
void hub_send_password_challenge(struct hub_info* hub, struct user* u)
|
||||
void hub_send_password_challenge(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
struct adc_message* igpa;
|
||||
igpa = adc_msg_construct(ADC_CMD_IGPA, 38);
|
||||
@ -341,7 +341,7 @@ void hub_send_password_challenge(struct hub_info* hub, struct user* u)
|
||||
static void hub_event_dispatcher(void* callback_data, struct event_data* message)
|
||||
{
|
||||
struct hub_info* hub = (struct hub_info*) callback_data;
|
||||
struct user* user = (struct user*) message->ptr;
|
||||
struct hub_user* user = (struct hub_user*) message->ptr;
|
||||
assert(hub != NULL);
|
||||
|
||||
switch (message->id)
|
||||
@ -633,7 +633,7 @@ void hub_free_variables(struct hub_info* hub)
|
||||
*/
|
||||
static inline int is_nick_in_use(struct hub_info* hub, const char* nick)
|
||||
{
|
||||
struct user* lookup = uman_get_user_by_nick(hub, nick);
|
||||
struct hub_user* lookup = uman_get_user_by_nick(hub, nick);
|
||||
if (lookup)
|
||||
{
|
||||
return 1;
|
||||
@ -647,7 +647,7 @@ static inline int is_nick_in_use(struct hub_info* hub, const char* nick)
|
||||
*/
|
||||
static inline int is_cid_in_use(struct hub_info* hub, const char* cid)
|
||||
{
|
||||
struct user* lookup = uman_get_user_by_cid(hub, cid);
|
||||
struct hub_user* lookup = uman_get_user_by_cid(hub, cid);
|
||||
if (lookup)
|
||||
{
|
||||
return 1;
|
||||
@ -672,7 +672,7 @@ static void set_status_code(enum msg_status_level level, int code, char buffer[4
|
||||
* @param msg See enum status_message
|
||||
* @param level See enum status_level
|
||||
*/
|
||||
void hub_send_status(struct hub_info* hub, struct user* user, enum status_message msg, enum msg_status_level level)
|
||||
void hub_send_status(struct hub_info* hub, struct hub_user* user, enum status_message msg, enum msg_status_level level)
|
||||
{
|
||||
struct hub_config* cfg = hub->config;
|
||||
struct adc_message* cmd = adc_msg_construct(ADC_CMD_ISTA, 6);
|
||||
@ -910,7 +910,7 @@ void hub_event_loop(struct hub_info* hub)
|
||||
while (hub->status == hub_status_running || hub->status == hub_status_disabled);
|
||||
}
|
||||
|
||||
void hub_schedule_destroy_user(struct hub_info* hub, struct user* user)
|
||||
void hub_schedule_destroy_user(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
struct event_data post;
|
||||
memset(&post, 0, sizeof(post));
|
||||
@ -919,7 +919,7 @@ void hub_schedule_destroy_user(struct hub_info* hub, struct user* user)
|
||||
event_queue_post(hub->queue, &post);
|
||||
}
|
||||
|
||||
void hub_disconnect_user(struct hub_info* hub, struct user* user, int reason)
|
||||
void hub_disconnect_user(struct hub_info* hub, struct hub_user* user, int reason)
|
||||
{
|
||||
struct event_data post;
|
||||
int need_notify = 0;
|
||||
|
@ -88,7 +88,7 @@ struct hub_info
|
||||
struct event_queue* queue;
|
||||
struct event_base* evbase;
|
||||
struct hub_config* config;
|
||||
struct user_manager* users;
|
||||
struct hub_user_manager* users;
|
||||
struct acl_handle* acl;
|
||||
struct adc_message* command_info; /* The hub's INF command */
|
||||
struct adc_message* command_support; /* The hub's SUP command */
|
||||
@ -113,87 +113,87 @@ struct hub_info
|
||||
*
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
extern int hub_handle_message(struct hub_info* hub, struct user* u, const char* message, size_t length);
|
||||
extern int hub_handle_message(struct hub_info* hub, struct hub_user* u, const char* message, size_t length);
|
||||
|
||||
/**
|
||||
* Handle protocol support/subscription messages received clients.
|
||||
*
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
extern int hub_handle_support(struct hub_info* hub, struct user* u, struct adc_message* cmd);
|
||||
extern int hub_handle_support(struct hub_info* hub, struct hub_user* u, struct adc_message* cmd);
|
||||
|
||||
/**
|
||||
* Handle password messages received from clients.
|
||||
*
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
extern int hub_handle_password(struct hub_info* hub, struct user* u, struct adc_message* cmd);
|
||||
extern int hub_handle_password(struct hub_info* hub, struct hub_user* u, struct adc_message* cmd);
|
||||
|
||||
/**
|
||||
* Handle chat messages received from clients.
|
||||
* @return 0 on success, -1 on error.
|
||||
*/
|
||||
extern int hub_handle_chat_message(struct hub_info* hub, struct user* u, struct adc_message* cmd);
|
||||
extern int hub_handle_chat_message(struct hub_info* hub, struct hub_user* u, struct adc_message* cmd);
|
||||
|
||||
/**
|
||||
* Used internally by hub_handle_info
|
||||
* @return 1 if nickname is OK, or 0 if nickname is not accepted.
|
||||
*/
|
||||
extern int hub_handle_info_check_nick(struct hub_info* hub, struct user* u, struct adc_message* cmd);
|
||||
extern int hub_handle_info_check_nick(struct hub_info* hub, struct hub_user* u, struct adc_message* cmd);
|
||||
|
||||
/**
|
||||
* Used internally by hub_handle_info
|
||||
* @return 1 if CID/PID is OK, or 0 if not valid.
|
||||
*/
|
||||
extern int hub_handle_info_check_cid(struct hub_info* hub, struct user* u, struct adc_message* cmd);
|
||||
extern int hub_handle_info_check_cid(struct hub_info* hub, struct hub_user* u, struct adc_message* cmd);
|
||||
|
||||
/**
|
||||
* Send the support line for the hub to a particular user.
|
||||
* Only used during the initial handshake.
|
||||
*/
|
||||
extern void hub_send_support(struct hub_info* hub, struct user* u);
|
||||
extern void hub_send_support(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* Send a message assigning a SID for a user.
|
||||
* This is only sent after hub_send_support() during initial handshake.
|
||||
*/
|
||||
extern void hub_send_sid(struct hub_info* hub, struct user* u);
|
||||
extern void hub_send_sid(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* Send a 'ping' message to user.
|
||||
*/
|
||||
extern void hub_send_ping(struct hub_info* hub, struct user* user);
|
||||
extern void hub_send_ping(struct hub_info* hub, struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Send a message containing hub information to a particular user.
|
||||
* This is sent during user connection, but can safely be sent at any
|
||||
* point later.
|
||||
*/
|
||||
extern void hub_send_hubinfo(struct hub_info* hub, struct user* u);
|
||||
extern void hub_send_hubinfo(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* Send handshake. This basically calls
|
||||
* hub_send_support() and hub_send_sid()
|
||||
*/
|
||||
extern void hub_send_handshake(struct hub_info* hub, struct user* u);
|
||||
extern void hub_send_handshake(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* Send a welcome message containing the message of the day to
|
||||
* one particular user. This can be sent in any point in time.
|
||||
*/
|
||||
extern void hub_send_motd(struct hub_info* hub, struct user* u);
|
||||
extern void hub_send_motd(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* Send a password challenge to a user.
|
||||
* This is only used if the user tries to access the hub using a
|
||||
* password protected nick name.
|
||||
*/
|
||||
extern void hub_send_password_challenge(struct hub_info* hub, struct user* u);
|
||||
extern void hub_send_password_challenge(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* Sends a status_message to a user.
|
||||
*/
|
||||
extern void hub_send_status(struct hub_info*, struct user* user, enum status_message msg, enum msg_status_level level);
|
||||
extern void hub_send_status(struct hub_info*, struct hub_user* user, enum status_message msg, enum msg_status_level level);
|
||||
|
||||
/**
|
||||
* Allocates memory, initializes the hub based on the configuration,
|
||||
@ -324,12 +324,12 @@ extern void hub_event_loop(struct hub_info* hub);
|
||||
/**
|
||||
* Schedule destroying a user.
|
||||
*/
|
||||
extern void hub_schedule_destroy_user(struct hub_info* hub, struct user* user);
|
||||
extern void hub_schedule_destroy_user(struct hub_info* hub, struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Disconnect a user from the hub.
|
||||
*/
|
||||
extern void hub_disconnect_user(struct hub_info* hub, struct user* user, int reason);
|
||||
extern void hub_disconnect_user(struct hub_info* hub, struct hub_user* user, int reason);
|
||||
|
||||
|
||||
#endif /* HAVE_UHUB_HUB_H */
|
||||
|
@ -19,27 +19,27 @@
|
||||
|
||||
#include "uhub.h"
|
||||
|
||||
static void log_user_login(struct user* u)
|
||||
static void log_user_login(struct hub_user* u)
|
||||
{
|
||||
const char* cred = get_user_credential_string(u->credentials);
|
||||
const char* addr = ip_convert_to_string(&u->net.ipaddr);
|
||||
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 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.ipaddr);
|
||||
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);
|
||||
}
|
||||
|
||||
static void log_user_logout(struct 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.ipaddr);
|
||||
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 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.ipaddr);
|
||||
LOG_USER("NickChange %s/%s %s \"%s\" -> \"%s\"", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, nick);
|
||||
@ -47,7 +47,7 @@ static void log_user_nick_change(struct user* u, const char* nick)
|
||||
|
||||
|
||||
/* Send MOTD, do logging etc */
|
||||
void on_login_success(struct hub_info* hub, struct user* u)
|
||||
void on_login_success(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
/* Send user list of all existing users */
|
||||
if (!uman_send_user_list(hub, u))
|
||||
@ -72,14 +72,14 @@ void on_login_success(struct hub_info* hub, struct user* u)
|
||||
user_set_timeout(u, TIMEOUT_IDLE);
|
||||
}
|
||||
|
||||
void on_login_failure(struct hub_info* hub, struct user* u, enum status_message msg)
|
||||
void on_login_failure(struct hub_info* hub, struct hub_user* u, enum status_message msg)
|
||||
{
|
||||
log_user_login_error(u, msg);
|
||||
hub_send_status(hub, u, msg, status_level_fatal);
|
||||
hub_disconnect_user(hub, u, quit_logon_error);
|
||||
}
|
||||
|
||||
void on_nick_change(struct hub_info* hub, struct user* u, const char* nick)
|
||||
void on_nick_change(struct hub_info* hub, struct hub_user* u, const char* nick)
|
||||
{
|
||||
if (user_is_logged_in(u))
|
||||
{
|
||||
@ -87,7 +87,7 @@ void on_nick_change(struct hub_info* hub, struct user* u, const char* nick)
|
||||
}
|
||||
}
|
||||
|
||||
void on_logout_user(struct hub_info* hub, struct user* user)
|
||||
void on_logout_user(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
const char* reason = "";
|
||||
|
||||
|
@ -23,22 +23,22 @@
|
||||
/**
|
||||
* This event is triggered whenever a user successfully logs in to the hub.
|
||||
*/
|
||||
extern void on_login_success(struct hub_info* hub, struct user* u);
|
||||
extern void on_login_success(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* This event is triggered whenever a user failed to log in to the hub.
|
||||
*/
|
||||
extern void on_login_failure(struct hub_info* hub, struct user* u, enum status_message msg);
|
||||
extern void on_login_failure(struct hub_info* hub, struct hub_user* u, enum status_message msg);
|
||||
|
||||
/**
|
||||
* This event is triggered whenever a previously logged in user leaves the hub.
|
||||
*/
|
||||
extern void on_logout_user(struct hub_info* hub, struct user* u);
|
||||
extern void on_logout_user(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* This event is triggered whenever a user changes his/her nickname.
|
||||
*/
|
||||
extern void on_nick_change(struct hub_info* hub, struct user* u, const char* nick);
|
||||
extern void on_nick_change(struct hub_info* hub, struct hub_user* u, const char* nick);
|
||||
|
||||
|
||||
#endif /* HAVE_UHUB_HUB_EVENT_H */
|
||||
|
@ -39,7 +39,7 @@ static void remove_server_restricted_flags(struct adc_message* cmd)
|
||||
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_REFERER);
|
||||
}
|
||||
|
||||
static int set_feature_cast_supports(struct user* u, struct adc_message* cmd)
|
||||
static int set_feature_cast_supports(struct hub_user* u, struct adc_message* cmd)
|
||||
{
|
||||
char *it, *tmp;
|
||||
|
||||
@ -87,7 +87,7 @@ static int check_hash_tiger(const char* cid, const char* pid)
|
||||
/*
|
||||
* FIXME: Only works for tiger hash. If a client doesnt support tiger we cannot let it in!
|
||||
*/
|
||||
static int check_cid(struct hub_info* hub, struct user* user, struct adc_message* cmd)
|
||||
static int check_cid(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
size_t pos;
|
||||
char* cid = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_CLIENT_ID);
|
||||
@ -148,7 +148,7 @@ static int check_cid(struct hub_info* hub, struct user* user, struct adc_message
|
||||
}
|
||||
|
||||
|
||||
static int check_required_login_flags(struct hub_info* hub, struct user* user, struct adc_message* cmd)
|
||||
static int check_required_login_flags(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
int num = 0;
|
||||
|
||||
@ -184,7 +184,7 @@ static int check_required_login_flags(struct hub_info* hub, struct user* user, s
|
||||
* remove any wrong address, and replace it with the correct one
|
||||
* as seen by the hub.
|
||||
*/
|
||||
int check_network(struct hub_info* hub, struct 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.ipaddr);
|
||||
|
||||
@ -220,7 +220,7 @@ int check_network(struct hub_info* hub, struct user* user, struct adc_message* c
|
||||
return 0;
|
||||
}
|
||||
|
||||
void strip_network(struct user* user, struct adc_message* cmd)
|
||||
void strip_network(struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV6_ADDR);
|
||||
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV6_UDP_PORT);
|
||||
@ -274,7 +274,7 @@ static int nick_is_utf8(const char* nick)
|
||||
}
|
||||
|
||||
|
||||
static int check_nick(struct hub_info* hub, struct user* user, struct adc_message* cmd)
|
||||
static int check_nick(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
char* nick;
|
||||
char* tmp;
|
||||
@ -322,10 +322,10 @@ static int check_nick(struct hub_info* hub, struct user* user, struct adc_messag
|
||||
}
|
||||
|
||||
|
||||
static int check_logged_in(struct hub_info* hub, struct user* user, struct adc_message* cmd)
|
||||
static int check_logged_in(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
struct user* lookup1 = uman_get_user_by_nick(hub, user->id.nick);
|
||||
struct user* lookup2 = uman_get_user_by_cid(hub, user->id.cid);
|
||||
struct hub_user* lookup1 = uman_get_user_by_nick(hub, user->id.nick);
|
||||
struct hub_user* lookup2 = uman_get_user_by_cid(hub, user->id.cid);
|
||||
|
||||
if (lookup1 == user)
|
||||
{
|
||||
@ -363,7 +363,7 @@ static int check_logged_in(struct hub_info* hub, struct user* user, struct adc_m
|
||||
* But this is not something we want to do, and is deprecated in the ADC specification.
|
||||
* One should rather look at capabilities/features.
|
||||
*/
|
||||
static int check_user_agent(struct hub_info* hub, struct user* user, struct adc_message* cmd)
|
||||
static int check_user_agent(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
char* ua_encoded = 0;
|
||||
char* ua = 0;
|
||||
@ -384,7 +384,7 @@ static int check_user_agent(struct hub_info* hub, struct user* user, struct adc_
|
||||
}
|
||||
|
||||
|
||||
static int check_acl(struct hub_info* hub, struct user* user, struct adc_message* cmd)
|
||||
static int check_acl(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
if (acl_is_cid_banned(hub->acl, user->id.cid))
|
||||
{
|
||||
@ -404,7 +404,7 @@ static int check_acl(struct hub_info* hub, struct user* user, struct adc_message
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_limits(struct hub_info* hub, struct user* user, struct adc_message* cmd)
|
||||
static int check_limits(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
char* arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_SHARED_SIZE);
|
||||
if (arg)
|
||||
@ -530,10 +530,10 @@ static int check_limits(struct hub_info* hub, struct user* user, struct adc_mess
|
||||
* If the hub is configured to allow only registered users and the user
|
||||
* is not recognized this will return 1.
|
||||
*/
|
||||
static int set_credentials(struct hub_info* hub, struct user* user, struct adc_message* cmd)
|
||||
static int set_credentials(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
int ret = 0;
|
||||
struct user_access_info* info = acl_get_access_info(hub->acl, user->id.nick);
|
||||
struct hub_user_access_info* info = acl_get_access_info(hub->acl, user->id.nick);
|
||||
|
||||
if (info)
|
||||
{
|
||||
@ -583,7 +583,7 @@ static int set_credentials(struct hub_info* hub, struct user* user, struct adc_m
|
||||
|
||||
|
||||
|
||||
static int check_is_hub_full(struct hub_info* hub, struct user* user)
|
||||
static int check_is_hub_full(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
/*
|
||||
* If hub is full, don't let users in, but we still want to allow
|
||||
@ -597,7 +597,7 @@ static int check_is_hub_full(struct hub_info* hub, struct user* user)
|
||||
}
|
||||
|
||||
|
||||
static int check_registered_users_only(struct hub_info* hub, struct user* user)
|
||||
static int check_registered_users_only(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
if (hub->config->registered_users_only && !user_is_registered(user))
|
||||
{
|
||||
@ -606,7 +606,7 @@ static int check_registered_users_only(struct hub_info* hub, struct user* user)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hub_handle_info_common(struct user* user, struct adc_message* cmd)
|
||||
static int hub_handle_info_common(struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
/* Remove server restricted flags */
|
||||
remove_server_restricted_flags(cmd);
|
||||
@ -617,7 +617,7 @@ static int hub_handle_info_common(struct user* user, struct adc_message* cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hub_handle_info_low_bandwidth(struct hub_info* hub, struct user* user, struct adc_message* cmd)
|
||||
static int hub_handle_info_low_bandwidth(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
if (hub->config->low_bandwidth_mode)
|
||||
{
|
||||
@ -645,7 +645,7 @@ static int hub_handle_info_low_bandwidth(struct hub_info* hub, struct user* user
|
||||
return ret; \
|
||||
} while(0)
|
||||
|
||||
int hub_perform_login_checks(struct hub_info* hub, struct user* user, struct adc_message* cmd)
|
||||
int hub_perform_login_checks(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
/* Make syntax checks. */
|
||||
INF_CHECK(check_required_login_flags, hub, user, cmd);
|
||||
@ -664,7 +664,7 @@ int hub_perform_login_checks(struct hub_info* hub, struct user* user, struct adc
|
||||
*
|
||||
* @return 0 if success, <0 if error, >0 if authentication needed.
|
||||
*/
|
||||
int hub_handle_info_login(struct hub_info* hub, struct user* user, struct adc_message* cmd)
|
||||
int hub_handle_info_login(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
int code = 0;
|
||||
|
||||
@ -711,7 +711,7 @@ int hub_handle_info_login(struct hub_info* hub, struct user* user, struct adc_me
|
||||
* - CID/PID (valid, not taken, etc).
|
||||
* - IP addresses (IPv4 and IPv6)
|
||||
*/
|
||||
int hub_handle_info(struct hub_info* hub, struct user* user, const struct adc_message* cmd_unmodified)
|
||||
int hub_handle_info(struct hub_info* hub, struct hub_user* user, const struct adc_message* cmd_unmodified)
|
||||
{
|
||||
struct adc_message* cmd = adc_msg_copy(cmd_unmodified);
|
||||
if (!cmd) return -1; /* OOM */
|
||||
|
@ -47,7 +47,7 @@ enum nick_status
|
||||
*
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
extern int hub_handle_info(struct hub_info* hub, struct user* u, const struct adc_message* cmd);
|
||||
extern int hub_handle_info(struct hub_info* hub, struct hub_user* u, const struct adc_message* cmd);
|
||||
|
||||
|
||||
#endif /* HAVE_UHUB_INF_PARSER_H */
|
||||
|
@ -24,7 +24,7 @@
|
||||
extern struct hub_info* g_hub;
|
||||
|
||||
#ifdef DEBUG_SENDQ
|
||||
void debug_sendq_send(struct user* user, int sent, int total)
|
||||
void debug_sendq_send(struct hub_user* user, int sent, int total)
|
||||
{
|
||||
LOG_DUMP("SEND: sd=%d, %d/%d bytes\n", user->net.sd, sent, total);
|
||||
if (sent == -1)
|
||||
@ -34,7 +34,7 @@ void debug_sendq_send(struct user* user, int sent, int total)
|
||||
}
|
||||
}
|
||||
|
||||
void debug_sendq_recv(struct user* user, int received, int max, const char* buffer)
|
||||
void debug_sendq_recv(struct hub_user* user, int received, int max, const char* buffer)
|
||||
{
|
||||
LOG_DUMP("RECV: %d/%d bytes\n", received, (int) max);
|
||||
if (received == -1)
|
||||
@ -54,7 +54,7 @@ void debug_sendq_recv(struct user* user, int received, int max, const char* buff
|
||||
|
||||
int net_user_send(void* ptr, const void* buf, size_t len)
|
||||
{
|
||||
struct user* user = (struct user*) ptr;
|
||||
struct hub_user* user = (struct hub_user*) ptr;
|
||||
int ret = net_send(user->net.sd, buf, len, UHUB_SEND_SIGNAL);
|
||||
#ifdef DEBUG_SENDQ
|
||||
debug_sendq_send(user, ret, len);
|
||||
@ -78,7 +78,7 @@ int net_user_send(void* ptr, const void* buf, size_t len)
|
||||
#ifdef SSL_SUPPORT
|
||||
int net_user_send_ssl(void* ptr, const void* buf, size_t len)
|
||||
{
|
||||
struct user* user = (struct user*) ptr;
|
||||
struct hub_user* user = (struct hub_user*) ptr;
|
||||
int ret = SSL_write(user->net.ssl, buf, (int) len);
|
||||
#ifdef DEBUG_SENDQ
|
||||
debug_sendq_send(user, ret, len);
|
||||
@ -102,7 +102,7 @@ int net_user_send_ssl(void* ptr, const void* buf, size_t len)
|
||||
|
||||
int net_user_recv(void* ptr, void* buf, size_t len)
|
||||
{
|
||||
struct user* user = (struct user*) ptr;
|
||||
struct hub_user* user = (struct hub_user*) ptr;
|
||||
int ret = net_recv(user->net.sd, buf, len, 0);
|
||||
if (ret > 0)
|
||||
{
|
||||
@ -118,7 +118,7 @@ int net_user_recv(void* ptr, void* buf, size_t len)
|
||||
#ifdef SSL_SUPPORT
|
||||
int net_user_recv_ssl(void* ptr, void* buf, size_t len)
|
||||
{
|
||||
struct user* user = (struct user*) ptr;
|
||||
struct hub_user* user = (struct hub_user*) ptr;
|
||||
int ret = SSL_read(user->net.ssl, buf, len);
|
||||
if (ret > 0)
|
||||
{
|
||||
@ -131,7 +131,7 @@ int net_user_recv_ssl(void* ptr, void* buf, size_t len)
|
||||
}
|
||||
#endif
|
||||
|
||||
int handle_net_read(struct user* user)
|
||||
int handle_net_read(struct hub_user* user)
|
||||
{
|
||||
static char buf[MAX_RECV_BUF];
|
||||
struct hub_recvq* q = user->net.recv_queue;
|
||||
@ -210,7 +210,7 @@ int handle_net_read(struct user* user)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_net_write(struct user* user)
|
||||
int handle_net_write(struct hub_user* user)
|
||||
{
|
||||
while (hub_sendq_get_bytes(user->net.send_queue))
|
||||
{
|
||||
@ -235,7 +235,7 @@ int handle_net_write(struct user* user)
|
||||
|
||||
void net_event(int fd, short ev, void *arg)
|
||||
{
|
||||
struct user* user = (struct user*) arg;
|
||||
struct hub_user* user = (struct hub_user*) arg;
|
||||
int flag_close = 0;
|
||||
|
||||
#ifdef DEBUG_SENDQ
|
||||
@ -272,7 +272,7 @@ void net_event(int fd, short ev, void *arg)
|
||||
}
|
||||
|
||||
|
||||
static void prepare_user_net(struct hub_info* hub, struct user* user)
|
||||
static void prepare_user_net(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
int fd = user->net.sd;
|
||||
|
||||
@ -300,7 +300,7 @@ static void prepare_user_net(struct hub_info* hub, struct user* user)
|
||||
void net_on_accept(int server_fd, short ev, void *arg)
|
||||
{
|
||||
struct hub_info* hub = (struct hub_info*) arg;
|
||||
struct user* user = 0;
|
||||
struct hub_user* user = 0;
|
||||
struct ip_addr_encap ipaddr;
|
||||
const char* addr;
|
||||
|
||||
|
@ -27,8 +27,8 @@ extern void net_on_accept(int fd, short ev, void *arg);
|
||||
|
||||
extern void net_event(int fd, short ev, void *arg);
|
||||
|
||||
extern int handle_net_read(struct user* user);
|
||||
extern int handle_net_write(struct user* user);
|
||||
extern int handle_net_read(struct hub_user* user);
|
||||
extern int handle_net_write(struct hub_user* user);
|
||||
|
||||
|
||||
#endif /* HAVE_UHUB_NET_EVENT_H */
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
#include "uhub.h"
|
||||
|
||||
int route_message(struct hub_info* hub, struct user* u, struct adc_message* msg)
|
||||
int route_message(struct hub_info* hub, struct hub_user* u, struct adc_message* msg)
|
||||
{
|
||||
struct user* target = NULL;
|
||||
struct hub_user* target = NULL;
|
||||
|
||||
switch (msg->cache[0])
|
||||
{
|
||||
@ -75,7 +75,7 @@ static inline size_t get_max_send_queue_soft(struct hub_info* hub)
|
||||
* -1 if send queue is overflowed
|
||||
* 0 if soft send queue is overflowed (not implemented at the moment)
|
||||
*/
|
||||
static inline int check_send_queue(struct hub_info* hub, struct user* user, struct adc_message* msg)
|
||||
static inline int check_send_queue(struct hub_info* hub, struct hub_user* user, struct adc_message* msg)
|
||||
{
|
||||
if (user_flag_get(user, flag_user_list))
|
||||
return 1;
|
||||
@ -89,7 +89,7 @@ static inline int check_send_queue(struct hub_info* hub, struct user* user, stru
|
||||
return 1;
|
||||
}
|
||||
|
||||
int route_to_user(struct hub_info* hub, struct user* user, struct adc_message* msg)
|
||||
int route_to_user(struct hub_info* hub, struct hub_user* user, struct adc_message* msg)
|
||||
{
|
||||
#ifdef DEBUG_SENDQ
|
||||
char* data = strndup(msg->cache, msg->length-1);
|
||||
@ -115,7 +115,7 @@ int route_to_user(struct hub_info* hub, struct user* user, struct adc_message* m
|
||||
return 1;
|
||||
}
|
||||
|
||||
int route_flush_pipeline(struct hub_info* hub, struct user* u)
|
||||
int route_flush_pipeline(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
if (hub_sendq_is_empty(u->net.send_queue))
|
||||
return 0;
|
||||
@ -128,11 +128,11 @@ int route_flush_pipeline(struct hub_info* hub, struct user* u)
|
||||
|
||||
int route_to_all(struct hub_info* hub, struct adc_message* command) /* iterate users */
|
||||
{
|
||||
struct user* user = (struct user*) list_get_first(hub->users->list);
|
||||
struct hub_user* user = (struct hub_user*) list_get_first(hub->users->list);
|
||||
while (user)
|
||||
{
|
||||
route_to_user(hub, user, command);
|
||||
user = (struct user*) list_get_next(hub->users->list);
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -143,7 +143,7 @@ int route_to_subscribers(struct hub_info* hub, struct adc_message* command) /* i
|
||||
int do_send;
|
||||
char* tmp;
|
||||
|
||||
struct user* user = (struct user*) list_get_first(hub->users->list);
|
||||
struct hub_user* user = (struct hub_user*) list_get_first(hub->users->list);
|
||||
while (user)
|
||||
{
|
||||
if (user->feature_cast)
|
||||
@ -162,7 +162,7 @@ int route_to_subscribers(struct hub_info* hub, struct adc_message* command) /* i
|
||||
}
|
||||
|
||||
if (!do_send) {
|
||||
user = (struct user*) list_get_next(hub->users->list);
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -182,13 +182,13 @@ int route_to_subscribers(struct hub_info* hub, struct adc_message* command) /* i
|
||||
route_to_user(hub, user, command);
|
||||
}
|
||||
}
|
||||
user = (struct user*) list_get_next(hub->users->list);
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int route_info_message(struct hub_info* hub, struct user* u)
|
||||
int route_info_message(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
if (!user_is_nat_override(u))
|
||||
{
|
||||
@ -198,12 +198,12 @@ int route_info_message(struct hub_info* hub, struct user* u)
|
||||
{
|
||||
struct adc_message* cmd = adc_msg_copy(u->info);
|
||||
const char* address = ip_convert_to_string(&u->net.ipaddr);
|
||||
struct user* user = 0;
|
||||
struct hub_user* user = 0;
|
||||
|
||||
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR);
|
||||
adc_msg_add_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR, address);
|
||||
|
||||
user = (struct user*) list_get_first(hub->users->list);
|
||||
user = (struct hub_user*) list_get_first(hub->users->list);
|
||||
while (user)
|
||||
{
|
||||
if (user_is_nat_override(user))
|
||||
@ -211,7 +211,7 @@ int route_info_message(struct hub_info* hub, struct user* u)
|
||||
else
|
||||
route_to_user(hub, user, u->info);
|
||||
|
||||
user = (struct user*) list_get_next(hub->users->list);
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
adc_msg_free(cmd);
|
||||
}
|
||||
|
@ -23,17 +23,17 @@
|
||||
/**
|
||||
* Route a message by sending it to it's final destination.
|
||||
*/
|
||||
extern int route_message(struct hub_info* hub, struct user* u, struct adc_message* msg);
|
||||
extern int route_message(struct hub_info* hub, struct hub_user* u, struct adc_message* msg);
|
||||
|
||||
/**
|
||||
* Send queued messages.
|
||||
*/
|
||||
extern int route_flush_pipeline(struct hub_info* hub, struct user* u);
|
||||
extern int route_flush_pipeline(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* Transmit message directly to one user.
|
||||
*/
|
||||
extern int route_to_user(struct hub_info* hub, struct user*, struct adc_message* command);
|
||||
extern int route_to_user(struct hub_info* hub, struct hub_user*, struct adc_message* command);
|
||||
|
||||
/**
|
||||
* Broadcast message to all users.
|
||||
@ -50,7 +50,7 @@ extern int route_to_subscribers(struct hub_info* hub, struct adc_message* comman
|
||||
* This will ensure the correct IP is seen by other users
|
||||
* in case nat override is in use.
|
||||
*/
|
||||
extern int route_info_message(struct hub_info* hub, struct user* user);
|
||||
extern int route_info_message(struct hub_info* hub, struct hub_user* user);
|
||||
|
||||
|
||||
#endif /* HAVE_UHUB_ROUTE_H */
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "uhub.h"
|
||||
|
||||
#ifdef DEBUG_SENDQ
|
||||
static const char* user_log_str(struct user* user)
|
||||
static const char* user_log_str(struct hub_user* user)
|
||||
{
|
||||
static char buf[128];
|
||||
if (user)
|
||||
@ -35,13 +35,13 @@ static const char* user_log_str(struct user* user)
|
||||
}
|
||||
#endif
|
||||
|
||||
struct user* user_create(struct hub_info* hub, int sd)
|
||||
struct hub_user* user_create(struct hub_info* hub, int sd)
|
||||
{
|
||||
struct user* user = NULL;
|
||||
struct hub_user* user = NULL;
|
||||
|
||||
LOG_TRACE("user_create(), hub=%p, sd=%d", hub, sd);
|
||||
|
||||
user = (struct user*) hub_malloc_zero(sizeof(struct user));
|
||||
user = (struct hub_user*) hub_malloc_zero(sizeof(struct hub_user));
|
||||
|
||||
if (user == NULL)
|
||||
return NULL; /* OOM */
|
||||
@ -66,7 +66,7 @@ struct user* user_create(struct hub_info* hub, int sd)
|
||||
}
|
||||
|
||||
|
||||
void user_destroy(struct user* user)
|
||||
void user_destroy(struct hub_user* user)
|
||||
{
|
||||
LOG_TRACE("user_destroy(), user=%p", user);
|
||||
|
||||
@ -82,7 +82,7 @@ void user_destroy(struct user* user)
|
||||
hub_free(user);
|
||||
}
|
||||
|
||||
void user_set_state(struct user* user, enum user_state state)
|
||||
void user_set_state(struct hub_user* user, enum user_state state)
|
||||
{
|
||||
if ((user->state == state_cleanup && state != state_disconnected) || (user->state == state_disconnected))
|
||||
{
|
||||
@ -92,13 +92,13 @@ void user_set_state(struct user* user, enum user_state state)
|
||||
user->state = state;
|
||||
}
|
||||
|
||||
void user_set_info(struct user* user, struct adc_message* cmd)
|
||||
void user_set_info(struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
adc_msg_free(user->info);
|
||||
user->info = adc_msg_incref(cmd);
|
||||
}
|
||||
|
||||
void user_update_info(struct user* u, struct adc_message* cmd)
|
||||
void user_update_info(struct hub_user* u, struct adc_message* cmd)
|
||||
{
|
||||
char prefix[2];
|
||||
char* argument;
|
||||
@ -178,50 +178,50 @@ static int convert_support_fourcc(int fourcc)
|
||||
}
|
||||
}
|
||||
|
||||
void user_support_add(struct user* user, int fourcc)
|
||||
void user_support_add(struct hub_user* user, int fourcc)
|
||||
{
|
||||
int feature_mask = convert_support_fourcc(fourcc);
|
||||
user->flags |= feature_mask;
|
||||
}
|
||||
|
||||
int user_flag_get(struct user* user, enum user_flags flag)
|
||||
int user_flag_get(struct hub_user* user, enum user_flags flag)
|
||||
{
|
||||
return user->flags & flag;
|
||||
}
|
||||
|
||||
void user_flag_set(struct user* user, enum user_flags flag)
|
||||
void user_flag_set(struct hub_user* user, enum user_flags flag)
|
||||
{
|
||||
user->flags |= flag;
|
||||
}
|
||||
|
||||
void user_flag_unset(struct user* user, enum user_flags flag)
|
||||
void user_flag_unset(struct hub_user* user, enum user_flags flag)
|
||||
{
|
||||
user->flags &= ~flag;
|
||||
}
|
||||
|
||||
void user_set_nat_override(struct user* user)
|
||||
void user_set_nat_override(struct hub_user* user)
|
||||
{
|
||||
user_flag_set(user, flag_nat);
|
||||
}
|
||||
|
||||
int user_is_nat_override(struct user* user)
|
||||
int user_is_nat_override(struct hub_user* user)
|
||||
{
|
||||
return user_flag_get(user, flag_nat);
|
||||
}
|
||||
|
||||
void user_support_remove(struct user* user, int fourcc)
|
||||
void user_support_remove(struct hub_user* user, int fourcc)
|
||||
{
|
||||
int feature_mask = convert_support_fourcc(fourcc);
|
||||
user->flags &= ~feature_mask;
|
||||
}
|
||||
|
||||
void user_disconnect(struct user* user, int reason)
|
||||
void user_disconnect(struct hub_user* user, int reason)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
int user_have_feature_cast_support(struct user* user, char feature[4])
|
||||
int user_have_feature_cast_support(struct hub_user* user, char feature[4])
|
||||
{
|
||||
char* tmp = list_get_first(user->feature_cast);
|
||||
while (tmp)
|
||||
@ -235,7 +235,7 @@ int user_have_feature_cast_support(struct user* user, char feature[4])
|
||||
return 0;
|
||||
}
|
||||
|
||||
int user_set_feature_cast_support(struct user* u, char feature[4])
|
||||
int user_set_feature_cast_support(struct hub_user* u, char feature[4])
|
||||
{
|
||||
if (!u->feature_cast)
|
||||
{
|
||||
@ -251,7 +251,7 @@ int user_set_feature_cast_support(struct user* u, char feature[4])
|
||||
return 1;
|
||||
}
|
||||
|
||||
void user_clear_feature_cast_support(struct user* u)
|
||||
void user_clear_feature_cast_support(struct hub_user* u)
|
||||
{
|
||||
if (u->feature_cast)
|
||||
{
|
||||
@ -261,35 +261,35 @@ void user_clear_feature_cast_support(struct user* u)
|
||||
}
|
||||
}
|
||||
|
||||
int user_is_logged_in(struct user* user)
|
||||
int user_is_logged_in(struct hub_user* user)
|
||||
{
|
||||
if (user->state == state_normal)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int user_is_connecting(struct user* user)
|
||||
int user_is_connecting(struct hub_user* user)
|
||||
{
|
||||
if (user->state == state_protocol || user->state == state_identify || user->state == state_verify)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int user_is_protocol_negotiating(struct user* user)
|
||||
int user_is_protocol_negotiating(struct hub_user* user)
|
||||
{
|
||||
if (user->state == state_protocol)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int user_is_disconnecting(struct user* user)
|
||||
int user_is_disconnecting(struct hub_user* user)
|
||||
{
|
||||
if (user->state == state_cleanup || user->state == state_disconnected)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int user_is_protected(struct user* user)
|
||||
int user_is_protected(struct hub_user* user)
|
||||
{
|
||||
switch (user->credentials)
|
||||
{
|
||||
@ -310,7 +310,7 @@ int user_is_protected(struct user* user)
|
||||
* Only registered users will be let in if the hub is configured for registered
|
||||
* users only.
|
||||
*/
|
||||
int user_is_registered(struct user* user)
|
||||
int user_is_registered(struct hub_user* user)
|
||||
{
|
||||
switch (user->credentials)
|
||||
{
|
||||
@ -327,7 +327,7 @@ int user_is_registered(struct user* user)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void user_net_io_want_write(struct user* user)
|
||||
void user_net_io_want_write(struct hub_user* user)
|
||||
{
|
||||
#ifdef DEBUG_SENDQ
|
||||
LOG_TRACE("user_net_io_want_write: %s (pending: %d)", user_log_str(user), event_pending(&user->net.event, EV_READ | EV_WRITE, 0));
|
||||
@ -339,7 +339,7 @@ void user_net_io_want_write(struct user* user)
|
||||
event_add(&user->net.event, 0);
|
||||
}
|
||||
|
||||
void user_net_io_want_read(struct user* user)
|
||||
void user_net_io_want_read(struct hub_user* user)
|
||||
{
|
||||
#ifdef DEBUG_SENDQ
|
||||
LOG_TRACE("user_net_io_want_read: %s (pending: %d)", user_log_str(user), event_pending(&user->net.event, EV_READ | EV_WRITE, 0));
|
||||
@ -351,17 +351,17 @@ void user_net_io_want_read(struct user* user)
|
||||
event_add(&user->net.event, 0);
|
||||
}
|
||||
|
||||
void user_reset_last_write(struct user* user)
|
||||
void user_reset_last_write(struct hub_user* user)
|
||||
{
|
||||
user->net.tm_last_write = time(NULL);
|
||||
}
|
||||
|
||||
void user_reset_last_read(struct user* user)
|
||||
void user_reset_last_read(struct hub_user* user)
|
||||
{
|
||||
user->net.tm_last_read = time(NULL);
|
||||
}
|
||||
|
||||
void user_set_timeout(struct user* user, int seconds)
|
||||
void user_set_timeout(struct hub_user* user, int seconds)
|
||||
{
|
||||
#ifdef DEBUG_SENDQ
|
||||
LOG_TRACE("user_set_timeout to %d seconds: %s", seconds, user_log_str(user));
|
||||
|
@ -70,7 +70,7 @@ enum user_quit_reason
|
||||
quit_ghost_timeout = 11, /** The user is a ghost, and trying to login from another connection */
|
||||
};
|
||||
|
||||
struct user_info
|
||||
struct hub_user_info
|
||||
{
|
||||
sid_t sid; /** session ID */
|
||||
char cid[MAX_CID_LEN+1]; /** global client ID */
|
||||
@ -82,7 +82,7 @@ struct user_info
|
||||
* as the number of bytes and files shared, and the number of hubs the
|
||||
* user is connected to, etc.
|
||||
*/
|
||||
struct user_limits
|
||||
struct hub_user_limits
|
||||
{
|
||||
uint64_t shared_size; /** Shared size in bytes */
|
||||
size_t shared_files; /** The number of shared files */
|
||||
@ -93,7 +93,7 @@ struct user_limits
|
||||
size_t hub_count_total; /** The number of hubs connected to in total */
|
||||
};
|
||||
|
||||
struct user_net_io
|
||||
struct hub_user_net_io
|
||||
{
|
||||
int sd; /** socket descriptor */
|
||||
struct event event; /** libevent struct for read/write events */
|
||||
@ -111,18 +111,18 @@ struct user_net_io
|
||||
#endif /* SSL_SUPPORT */
|
||||
};
|
||||
|
||||
struct user
|
||||
struct hub_user
|
||||
{
|
||||
struct user_net_io net; /** Network information data */
|
||||
struct hub_user_net_io net; /** Network information data */
|
||||
enum user_state state; /** see enum user_state */
|
||||
enum user_credentials credentials; /** see enum user_credentials */
|
||||
struct user_info id; /** Contains nick name and CID */
|
||||
struct hub_user_info id; /** Contains nick name and CID */
|
||||
int flags; /** see enum user_features */
|
||||
char user_agent[MAX_UA_LEN+1];/** User agent string */
|
||||
struct linked_list* feature_cast; /** Features supported by feature cast */
|
||||
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 user_limits limits; /** Data used for limitation */
|
||||
struct hub_user_limits limits; /** Data used for limitation */
|
||||
int quit_reason; /** Quit reason (see user_quit_reason) */
|
||||
|
||||
};
|
||||
@ -138,14 +138,14 @@ struct user
|
||||
* @param sd socket descriptor associated with the user
|
||||
* @return User object or NULL if not enough memory is available.
|
||||
*/
|
||||
extern struct user* user_create(struct hub_info* hub, int sd);
|
||||
extern struct hub_user* user_create(struct hub_info* hub, int sd);
|
||||
|
||||
/**
|
||||
* Delete a user.
|
||||
*
|
||||
* !WRONG! If the user is logged in a quit message is issued.
|
||||
*/
|
||||
extern void user_destroy(struct user* user);
|
||||
extern void user_destroy(struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Disconnect a user.
|
||||
@ -161,7 +161,7 @@ extern void user_destroy(struct user* user);
|
||||
* @param user User to disconnect
|
||||
* @param reason See enum user_quit_reason
|
||||
*/
|
||||
extern void user_disconnect(struct user* user, int reason);
|
||||
extern void user_disconnect(struct hub_user* user, int reason);
|
||||
|
||||
/**
|
||||
* This associates a INF message to the user.
|
||||
@ -170,53 +170,53 @@ extern void user_disconnect(struct user* user, int reason);
|
||||
*
|
||||
* @param info new inf message (can be NULL)
|
||||
*/
|
||||
extern void user_set_info(struct user* user, struct adc_message* info);
|
||||
extern void user_set_info(struct hub_user* user, struct adc_message* info);
|
||||
|
||||
/**
|
||||
* Update a user's INF message.
|
||||
* Will parse replace all ellements in the user's inf message with
|
||||
* the parameters from the cmd (merge operation).
|
||||
*/
|
||||
extern void user_update_info(struct user* user, struct adc_message* cmd);
|
||||
extern void user_update_info(struct hub_user* user, struct adc_message* cmd);
|
||||
|
||||
/**
|
||||
* Specify a user's state.
|
||||
* NOTE: DON'T, unless you know what you are doing.
|
||||
*/
|
||||
extern void user_set_state(struct user* user, enum user_state);
|
||||
extern void user_set_state(struct hub_user* user, enum user_state);
|
||||
|
||||
/**
|
||||
* Returns 1 if the user is in state state_normal, or 0 otherwise.
|
||||
*/
|
||||
extern int user_is_logged_in(struct user* user);
|
||||
extern int user_is_logged_in(struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Returns 1 if the user is in state_protocol.
|
||||
* Returns 0 otherwise.
|
||||
*/
|
||||
extern int user_is_protocol_negotiating(struct user* user);
|
||||
extern int user_is_protocol_negotiating(struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Returns 1 if the user is in state_protocol, state_identify or state_verify.
|
||||
* Returns 0 otherwise.
|
||||
*/
|
||||
extern int user_is_connecting(struct user* user);
|
||||
extern int user_is_connecting(struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Returns 1 only if the user is in state_cleanup or state_disconnected.
|
||||
*/
|
||||
extern int user_is_disconnecting(struct user* user);
|
||||
extern int user_is_disconnecting(struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Returns 1 if a user is protected, which includes users
|
||||
* having any form of elevated privileges.
|
||||
*/
|
||||
extern int user_is_protected(struct user* user);
|
||||
extern int user_is_protected(struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Returns 1 if a user is registered, with or without privileges.
|
||||
*/
|
||||
extern int user_is_registered(struct user* user);
|
||||
extern int user_is_registered(struct hub_user* user);
|
||||
|
||||
/**
|
||||
* User supports the protocol extension as given in fourcc.
|
||||
@ -226,7 +226,7 @@ extern int user_is_registered(struct user* user);
|
||||
*
|
||||
* @see enum user_flags
|
||||
*/
|
||||
extern void user_support_add(struct user* user, int fourcc);
|
||||
extern void user_support_add(struct hub_user* user, int fourcc);
|
||||
|
||||
/**
|
||||
* User no longer supports the protocol extension as given in fourcc.
|
||||
@ -234,26 +234,26 @@ extern void user_support_add(struct user* user, int fourcc);
|
||||
* the hub.
|
||||
* @see enum user_flags
|
||||
*/
|
||||
extern void user_support_remove(struct user* user, int fourcc);
|
||||
extern void user_support_remove(struct hub_user* user, int fourcc);
|
||||
|
||||
/**
|
||||
* Sets the nat override flag for a user, this allows users on the same
|
||||
* subnet as a natted hub to spoof their IP in order to use active mode
|
||||
* on a natted hub.
|
||||
*/
|
||||
extern void user_set_nat_override(struct user* user);
|
||||
extern int user_is_nat_override(struct user* user);
|
||||
extern void user_set_nat_override(struct hub_user* user);
|
||||
extern int user_is_nat_override(struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Set a flag. @see enum user_flags
|
||||
*/
|
||||
extern void user_flag_set(struct user* user, enum user_flags flag);
|
||||
extern void user_flag_unset(struct user* user, enum user_flags flag);
|
||||
extern void user_flag_set(struct hub_user* user, enum user_flags flag);
|
||||
extern void user_flag_unset(struct hub_user* user, enum user_flags flag);
|
||||
|
||||
/**
|
||||
* Get a flag. @see enum user_flags
|
||||
*/
|
||||
extern int user_flag_get(struct user* user, enum user_flags flag);
|
||||
extern int user_flag_get(struct hub_user* user, enum user_flags flag);
|
||||
|
||||
/**
|
||||
* Check if a user supports 'feature' for feature casting (basis for 'Fxxx' messages)
|
||||
@ -263,7 +263,7 @@ extern int user_flag_get(struct user* user, enum user_flags flag);
|
||||
* @param feature a feature to lookup (example: 'TCP4' or 'UDP4')
|
||||
* @return 1 if 'feature' supported, or 0 otherwise
|
||||
*/
|
||||
extern int user_have_feature_cast_support(struct user* user, char feature[4]);
|
||||
extern int user_have_feature_cast_support(struct hub_user* user, char feature[4]);
|
||||
|
||||
/**
|
||||
* Set feature cast support for feature.
|
||||
@ -271,38 +271,38 @@ extern int user_have_feature_cast_support(struct user* user, char feature[4]);
|
||||
* @param feature a feature to lookup (example: 'TCP4' or 'UDP4')
|
||||
* @return 1 if 'feature' supported, or 0 otherwise
|
||||
*/
|
||||
extern int user_set_feature_cast_support(struct user* u, char feature[4]);
|
||||
extern int user_set_feature_cast_support(struct hub_user* u, char feature[4]);
|
||||
|
||||
/**
|
||||
* Remove all feature cast support features.
|
||||
*/
|
||||
extern void user_clear_feature_cast_support(struct user* u);
|
||||
extern void user_clear_feature_cast_support(struct hub_user* u);
|
||||
|
||||
/**
|
||||
* Mark the user with a want-write flag, meaning it should poll for writability.
|
||||
*/
|
||||
extern void user_net_io_want_write(struct user* user);
|
||||
extern void user_net_io_want_write(struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Mark the user with a want read flag, meaning it should poll for readability.
|
||||
*/
|
||||
extern void user_net_io_want_read(struct user* user);
|
||||
extern void user_net_io_want_read(struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Set timeout for connetion.
|
||||
* @param seconds the number of seconds into the future.
|
||||
*/
|
||||
extern void user_set_timeout(struct user* user, int seconds);
|
||||
extern void user_set_timeout(struct hub_user* user, int seconds);
|
||||
|
||||
/**
|
||||
* Reset the last-write timer.
|
||||
*/
|
||||
extern void user_reset_last_write(struct user* user);
|
||||
extern void user_reset_last_write(struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Reset the last-write timer.
|
||||
*/
|
||||
extern void user_reset_last_read(struct user* user);
|
||||
extern void user_reset_last_read(struct hub_user* user);
|
||||
|
||||
#endif /* HAVE_UHUB_USER_H */
|
||||
|
||||
|
@ -29,7 +29,7 @@ static void clear_user_list_callback(void* ptr)
|
||||
{
|
||||
if (ptr)
|
||||
{
|
||||
struct user* u = (struct user*) ptr;
|
||||
struct hub_user* u = (struct hub_user*) ptr;
|
||||
|
||||
/* Mark the user as already being disconnected.
|
||||
* This prevents the hub from trying to send
|
||||
@ -85,14 +85,14 @@ static void timer_statistics(int fd, short ev, void *arg)
|
||||
|
||||
int uman_init(struct hub_info* hub)
|
||||
{
|
||||
struct user_manager* users = NULL;
|
||||
struct hub_user_manager* users = NULL;
|
||||
#ifdef USERMANAGER_TIMER
|
||||
struct timeval timeout = { TIMEOUT_STATS, 0 };
|
||||
#endif
|
||||
if (!hub)
|
||||
return -1;
|
||||
|
||||
users = (struct user_manager*) hub_malloc_zero(sizeof(struct user_manager));
|
||||
users = (struct hub_user_manager*) hub_malloc_zero(sizeof(struct hub_user_manager));
|
||||
if (!users)
|
||||
return -1;
|
||||
|
||||
@ -140,7 +140,7 @@ int uman_shutdown(struct hub_info* hub)
|
||||
}
|
||||
|
||||
|
||||
int uman_add(struct hub_info* hub, struct user* user)
|
||||
int uman_add(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
if (!hub || !user)
|
||||
return -1;
|
||||
@ -159,7 +159,7 @@ int uman_add(struct hub_info* hub, struct user* user)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uman_remove(struct hub_info* hub, struct user* user)
|
||||
int uman_remove(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
if (!hub || !user)
|
||||
return -1;
|
||||
@ -184,50 +184,50 @@ int uman_remove(struct hub_info* hub, struct user* user)
|
||||
}
|
||||
|
||||
|
||||
struct user* uman_get_user_by_sid(struct hub_info* hub, sid_t sid)
|
||||
struct hub_user* uman_get_user_by_sid(struct hub_info* hub, sid_t sid)
|
||||
{
|
||||
struct user* user = (struct user*) list_get_first(hub->users->list); /* iterate users */
|
||||
struct hub_user* user = (struct hub_user*) list_get_first(hub->users->list); /* iterate users */
|
||||
while (user)
|
||||
{
|
||||
if (user->id.sid == sid)
|
||||
return user;
|
||||
user = (struct user*) list_get_next(hub->users->list);
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
struct user* uman_get_user_by_cid(struct hub_info* hub, const char* cid)
|
||||
struct hub_user* uman_get_user_by_cid(struct hub_info* hub, const char* cid)
|
||||
{
|
||||
struct user* user = (struct 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)
|
||||
{
|
||||
if (strcmp(user->id.cid, cid) == 0)
|
||||
return user;
|
||||
user = (struct user*) list_get_next(hub->users->list);
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
struct user* uman_get_user_by_nick(struct hub_info* hub, const char* nick)
|
||||
struct hub_user* uman_get_user_by_nick(struct hub_info* hub, const char* nick)
|
||||
{
|
||||
struct user* user = (struct 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)
|
||||
{
|
||||
if (strcmp(user->id.nick, nick) == 0)
|
||||
return user;
|
||||
user = (struct user*) list_get_next(hub->users->list);
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int uman_send_user_list(struct hub_info* hub, struct user* target)
|
||||
int uman_send_user_list(struct hub_info* hub, struct hub_user* target)
|
||||
{
|
||||
int ret = 1;
|
||||
user_flag_set(target, flag_user_list);
|
||||
struct user* user = (struct user*) list_get_first(hub->users->list); /* iterate users - only on INF or PAS msg */
|
||||
struct hub_user* user = (struct hub_user*) list_get_first(hub->users->list); /* iterate users - only on INF or PAS msg */
|
||||
while (user)
|
||||
{
|
||||
if (user_is_logged_in(user))
|
||||
@ -236,7 +236,7 @@ int uman_send_user_list(struct hub_info* hub, struct user* target)
|
||||
if (!ret)
|
||||
break;
|
||||
}
|
||||
user = (struct user*) list_get_next(hub->users->list);
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -250,7 +250,7 @@ int uman_send_user_list(struct hub_info* hub, struct user* target)
|
||||
}
|
||||
|
||||
|
||||
void uman_send_quit_message(struct hub_info* hub, struct user* leaving)
|
||||
void uman_send_quit_message(struct hub_info* hub, struct hub_user* leaving)
|
||||
{
|
||||
struct adc_message* command = adc_msg_construct(ADC_CMD_IQUI, 6);
|
||||
adc_msg_add_argument(command, (const char*) sid_to_string(leaving->id.sid));
|
||||
@ -268,8 +268,8 @@ void uman_send_quit_message(struct hub_info* hub, struct user* leaving)
|
||||
sid_t uman_get_free_sid(struct hub_info* hub)
|
||||
{
|
||||
#if 0
|
||||
struct user* user;
|
||||
user = (struct user*) list_get_first(hub->users->list); /* iterate normal users */
|
||||
struct hub_user* user;
|
||||
user = (struct hub_user*) list_get_first(hub->users->list); /* iterate normal users */
|
||||
while (user)
|
||||
{
|
||||
if (user->sid == hub->users->free_sid)
|
||||
@ -278,7 +278,7 @@ sid_t uman_get_free_sid(struct hub_info* hub)
|
||||
if (hub->users->free_sid >= SID_MAX) hub->users->free_sid = 1;
|
||||
break;
|
||||
}
|
||||
user = (struct user*) list_get_next(hub->users->list);
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
#endif
|
||||
return hub->users->free_sid++;
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef HAVE_UHUB_USER_MANAGER_H
|
||||
#define HAVE_UHUB_USER_MANAGER_H
|
||||
|
||||
struct user_manager
|
||||
struct hub_user_manager
|
||||
{
|
||||
size_t count; /**<< "Number of all fully connected and logged in users" */
|
||||
size_t count_peak; /**<< "Peak number of users" */
|
||||
@ -56,7 +56,7 @@ extern void uman_print_stats(struct hub_info* hub);
|
||||
* @param hub The hub to add the user to
|
||||
* @param user The user to be added to the hub.
|
||||
*/
|
||||
extern int uman_add(struct hub_info* hub, struct user* user);
|
||||
extern int uman_add(struct hub_info* hub, struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Remove a user from the user manager.
|
||||
@ -65,7 +65,7 @@ extern int uman_add(struct hub_info* hub, struct user* user);
|
||||
*
|
||||
* @return 0 if successfully removed, -1 if error.
|
||||
*/
|
||||
extern int uman_remove(struct hub_info* hub, struct user* user);
|
||||
extern int uman_remove(struct hub_info* hub, struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Returns and allocates an unused session ID (SID).
|
||||
@ -85,19 +85,19 @@ extern sid_t uman_get_free_sid(struct hub_info* hub);
|
||||
*
|
||||
* @return a user if found, or NULL if not found
|
||||
*/
|
||||
extern struct user* uman_get_user_by_sid(struct hub_info* hub, sid_t sid);
|
||||
extern struct hub_user* uman_get_user_by_sid(struct hub_info* hub, sid_t sid);
|
||||
|
||||
/**
|
||||
* Lookup a user based on the client ID (CID).
|
||||
* @return a user if found, or NULL if not found
|
||||
*/
|
||||
extern struct user* uman_get_user_by_cid(struct hub_info* hub, const char* cid);
|
||||
extern struct hub_user* uman_get_user_by_cid(struct hub_info* hub, const char* cid);
|
||||
|
||||
/**
|
||||
* Lookup a user based on the nick name.
|
||||
* @return a user if found, or NULL if not found
|
||||
*/
|
||||
extern struct user* uman_get_user_by_nick(struct hub_info* hub, const char* nick);
|
||||
extern struct hub_user* uman_get_user_by_nick(struct hub_info* hub, const char* nick);
|
||||
|
||||
/**
|
||||
* Send the user list of connected clients to 'user'.
|
||||
@ -105,13 +105,13 @@ extern struct user* uman_get_user_by_nick(struct hub_info* hub, const char* nick
|
||||
*
|
||||
* @return 1 if sending the user list succeeded, 0 otherwise.
|
||||
*/
|
||||
extern int uman_send_user_list(struct hub_info* hub, struct user* user);
|
||||
extern int uman_send_user_list(struct hub_info* hub, struct hub_user* user);
|
||||
|
||||
/**
|
||||
* Send a quit message to all connected users when 'user' is
|
||||
* leaving the hub (for whatever reason).
|
||||
*/
|
||||
extern void uman_send_quit_message(struct hub_info* hub, struct user* user);
|
||||
extern void uman_send_quit_message(struct hub_info* hub, struct hub_user* user);
|
||||
|
||||
|
||||
#endif /* HAVE_UHUB_USER_MANAGER_H */
|
||||
|
Loading…
Reference in New Issue
Block a user