aboutsummaryrefslogtreecommitdiff
path: root/server_network.c
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2024-06-10 23:20:14 -0400
committerTest_User <hax@andrewyu.org>2024-06-10 23:20:14 -0400
commit47d7e30f6acb1c170c8e5e15f2656b89a33384f7 (patch)
treed5b8c7e0641b77647b6e44c4c37ed4664e468299 /server_network.c
parent5534441086cee3130c95460e22ed29bff44cbaef (diff)
downloadhaxircd-47d7e30f6acb1c170c8e5e15f2656b89a33384f7.tar.gz
haxircd-47d7e30f6acb1c170c8e5e15f2656b89a33384f7.zip
Mostly complete user tracking added
Diffstat (limited to 'server_network.c')
-rw-r--r--server_network.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/server_network.c b/server_network.c
index 7f481ec..ea92d3c 100644
--- a/server_network.c
+++ b/server_network.c
@@ -53,25 +53,6 @@ int init_server_network(void) {
}
}
- server_list.array = malloc(0);
-
- struct server_info *own_info;
- own_info = malloc(sizeof(*own_info));
- own_info->sid.data = malloc(SID.len);
- if (!own_info->sid.data)
- return 1;
- memcpy(own_info->sid.data, SID.data, SID.len);
- own_info->sid.len = SID.len;
-
- own_info->next = SID;
- own_info->connected_to = (struct table){.array = malloc(0), .len = 0};
- own_info->user_list = (struct table){.array = malloc(0), .len = 0};
- own_info->distance = 0;
- own_info->net = 0;
- own_info->protocol = 0;
- if (set_table_index(&server_list, SID, own_info) != 0)
- return 1;
-
return 0;
}
@@ -241,10 +222,10 @@ int add_server(struct string from, struct string attached_to, struct string sid,
protocols[protocol].update_propagations();
#ifdef USE_HAXIRCD_PROTOCOL
- protocols[HAXIRCD_PROTOCOL].propagate_new_server(from, attached_to, sid, new_info);
+ protocols[HAXIRCD_PROTOCOL].propagate_new_server(from, attached_to, new_info);
#endif
#ifdef USE_INSPIRCD2_PROTOCOL
- protocols[INSPIRCD2_PROTOCOL].propagate_new_server(from, attached_to, sid, new_info);
+ protocols[INSPIRCD2_PROTOCOL].propagate_new_server(from, attached_to, new_info);
#endif
return 0;
@@ -267,6 +248,8 @@ int add_server(struct string from, struct string attached_to, struct string sid,
void free_server(struct server_info *server) {
free(server->sid.data);
+ free(server->name.data);
+ free(server->fullname.data);
clear_table(&(server->connected_to));
free(server->connected_to.array);
clear_table(&(server->user_list));
@@ -275,6 +258,21 @@ void free_server(struct server_info *server) {
free(server);
}
+void remove_server(struct string from, struct server_info *server, struct string reason) {
+ while (server->user_list.len != 0) {
+ remove_user(from, server->user_list.array[0].ptr, reason, 0);
+ }
+
+ for (size_t i = 0; i < server->connected_to.len; i++) {
+ struct server_info *adjacent = server->connected_to.array[i].ptr;
+ remove_table_index(&(adjacent->connected_to), server->sid);
+ }
+
+ remove_table_index(&(server_list), server->sid);
+
+ free_server(server);
+}
+
void update_all_propagations(void) {
#ifdef USE_HAXIRCD_PROTOCOL
protocols[HAXIRCD_PROTOCOL].update_propagations();
@@ -300,5 +298,5 @@ void unlink_server(struct string from, struct server_info *a, struct server_info
protocols[INSPIRCD2_PROTOCOL].propagate_unlink(from, a, b, protocol);
#endif
- protocols[protocol].do_unlink(a, b);
+ protocols[protocol].do_unlink(from, a, b);
}