aboutsummaryrefslogtreecommitdiff
path: root/general_network.c
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2024-06-24 11:08:29 -0400
committerTest_User <hax@andrewyu.org>2024-06-24 11:08:50 -0400
commitd095efe06273ec29bdc07c2cc522d6fe5a793550 (patch)
tree0eab2d9999ae71d5cff1ae682b54d17ad8aa98b5 /general_network.c
parent7b3767d3988c3bb9c96f049ca8e5a829917c8426 (diff)
downloadhaxircd-d095efe06273ec29bdc07c2cc522d6fe5a793550.tar.gz
haxircd-d095efe06273ec29bdc07c2cc522d6fe5a793550.zip
The start of some services, inspircd3 support extra broken for now
Diffstat (limited to 'general_network.c')
-rw-r--r--general_network.c65
1 files changed, 49 insertions, 16 deletions
diff --git a/general_network.c b/general_network.c
index 9501ea4..f6c264a 100644
--- a/general_network.c
+++ b/general_network.c
@@ -322,11 +322,8 @@ int add_user(struct string from, struct string attached_to, struct string uid, s
if (str_clone(&(new_info->address), address) != 0)
goto add_user_free_host;
- if (str_clone(&(new_info->oper_type), STRING("")) != 0)
- goto add_user_free_address;
-
if (set_table_index(&user_list, uid, new_info) != 0)
- goto add_user_free_oper_type;
+ goto add_user_free_address;
if (set_table_index(&(attached->user_list), uid, new_info) != 0)
goto add_user_remove_user_list;
@@ -334,6 +331,9 @@ int add_user(struct string from, struct string attached_to, struct string uid, s
new_info->channel_list.array = malloc(0);
new_info->channel_list.len = 0;
+ new_info->account_name = (struct string){.data = malloc(0), .len = 0};
+ new_info->oper_type = (struct string){.data = malloc(0), .len = 0};
+
#ifdef USE_SERVER
if (protocols_handle_new_user(from, new_info) != 0)
goto add_user_free_channel_list;
@@ -348,8 +348,6 @@ int add_user(struct string from, struct string attached_to, struct string uid, s
remove_table_index(&(attached->user_list), uid);
add_user_remove_user_list:
remove_table_index(&user_list, uid);
- add_user_free_oper_type:
- free(new_info->oper_type.data);
add_user_free_address:
free(new_info->address.data);
add_user_free_host:
@@ -436,22 +434,15 @@ void remove_user(struct string from, struct user_info *user, struct string reaso
free(user->host.data);
free(user->address.data);
free(user->oper_type.data);
+ free(user->account_name.data);
free(user);
}
int kill_user(struct string from, struct string source, struct user_info *user, struct string reason) {
#ifdef USE_PSEUDOCLIENTS
if (user->is_pseudoclient) {
- switch (user->pseudoclient) {
-#ifdef USE_HAXSERV_PSEUDOCLIENT
- case HAXSERV_PSEUDOCLIENT:
- if (!pseudoclients[HAXSERV_PSEUDOCLIENT].allow_kill(from, source, user, reason))
- return 1;
- break;
-#endif
- default:
- break;
- }
+ if (!pseudoclients[user->pseudoclient].allow_kill(from, source, user, reason))
+ return 1;
}
#endif
@@ -489,6 +480,29 @@ int oper_user(struct string from, struct user_info *user, struct string type, st
return 0;
}
+int set_account(struct string from, struct user_info *user, struct string account, struct string source) {
+ if (STRING_EQ(user->account_name, account))
+ return 0;
+
+ struct string tmp;
+ if (str_clone(&tmp, account) != 0)
+ return 1;
+
+#ifdef USE_SERVER
+ if (protocols_handle_set_account(from, user, account, source) != 0) {
+ free(tmp.data);
+ return 1;
+ }
+
+ protocols_propagate_set_account(from, user, account, source);
+#endif
+
+ free(user->account_name.data);
+ user->account_name = tmp;
+
+ return 0;
+}
+
int set_channel(struct string from, struct string name, size_t timestamp, size_t user_count, struct user_info **users) {
char is_new_channel;
struct channel_info *channel = get_table_index(channel_list, name);
@@ -773,6 +787,25 @@ int do_trivial_reloads(void) {
reload_pseudoclients[HAXSERV_PSEUDOCLIENT] = 0;
}
#endif
+#ifdef USE_SERVICES_PSEUDOCLIENT
+ if (reload_pseudoclients[SERVICES_PSEUDOCLIENT]) {
+ if (pseudoclients[SERVICES_PSEUDOCLIENT].pre_reload() != 0)
+ return 1;
+ dlclose(pseudoclients[SERVICES_PSEUDOCLIENT].dl_handle);
+ pseudoclients[SERVICES_PSEUDOCLIENT].dl_handle = dlopen("pseudoclients/services.so", RTLD_NOW | RTLD_LOCAL);
+ if (!pseudoclients[SERVICES_PSEUDOCLIENT].dl_handle) {
+ puts(dlerror());
+ abort(); // TODO: Ugh...
+ }
+
+ pseudoclients[SERVICES_PSEUDOCLIENT].post_reload = dlsym(pseudoclients[SERVICES_PSEUDOCLIENT].dl_handle, "services_pseudoclient_post_reload");
+ if (pseudoclients[SERVICES_PSEUDOCLIENT].post_reload() != 0) {
+ abort(); // TODO: Ugh...
+ }
+
+ reload_pseudoclients[SERVICES_PSEUDOCLIENT] = 0;
+ }
+#endif
#endif
return 0;
}