summaryrefslogtreecommitdiff
path: root/server_network.c
diff options
context:
space:
mode:
Diffstat (limited to 'server_network.c')
-rw-r--r--server_network.c98
1 files changed, 53 insertions, 45 deletions
diff --git a/server_network.c b/server_network.c
index eb9dbee..6fc84d7 100644
--- a/server_network.c
+++ b/server_network.c
@@ -405,36 +405,53 @@ int kill_handler(struct string sender, uint64_t argc, struct string *argv) {
// TODO: Get accurate list of what got killed, what to rejoin, etc
- struct string id = STRING("1HC000000");
- if (argv[0].len != id.len || memcmp(argv[0].data, id.data, id.len) != 0) {
- WRITES(2, STRING("Invalid KILL recieved! (Unknown user)\n"));
- return 1;
- }
-
- char current_time[21]; // C HaxServ will be deprecated long before we reach 20-digit timestamps
- snprintf(current_time, 21, "%ld", time(NULL));
- SEND(STRING("UID 1HC000000 "));
- SEND(((struct string){current_time, strlen(current_time)}));
- SEND(STRING(" "));
- SEND(nick);
- SEND(STRING(" "));
- SEND(hostmask);
- SEND(STRING(" "));
- SEND(hostmask);
- SEND(STRING(" HaxServ 192.168.1.1 "));
- SEND(((struct string){current_time, strlen(current_time)}));
- SEND(STRING(" +k :HaxServ\n:1HC000000 OPERTYPE "));
- SEND(opertype);
- SEND(STRING("\n"));
-
- for (uint64_t i = 0; i < num_prejoin_channels; i++) {
- SEND(STRING("FJOIN "));
- SEND(prejoin_channels[i]);
+ struct user_info *user = get_table_index(user_list, argv[0]);
+ if (!user)
+ return 0; // TODO: Currently not all local users are considered; fix that, then make this give an error
+
+ if (user->server.len == 3 && memcmp(user->server.data, "1HC", 3) == 0) {
+ char user_time[21];
+ snprintf(user_time, 21, "%ld", user->user_ts);
+ char nick_time[21];
+ snprintf(nick_time, 21, "%ld", user->nick_ts);
+ SEND(STRING("UID "));
+ SEND(argv[0]);
SEND(STRING(" "));
- SEND(((struct string){current_time, strlen(current_time)}));
- SEND(STRING(" + :,1HC000000\nMODE "));
- SEND(prejoin_channels[i]);
- SEND(STRING(" +o 1HC000000\n"));
+ SEND(NULSTR(user_time));
+ SEND(STRING(" "));
+ SEND(user->nick);
+ SEND(STRING(" "));
+ SEND(user->hostname);
+ SEND(STRING(" "));
+ SEND(user->vhost);
+ SEND(STRING(" "));
+ SEND(user->ident);
+ SEND(STRING(" "));
+ SEND(user->ip);
+ SEND(STRING(" "));
+ SEND(NULSTR(nick_time));
+ SEND(STRING(" +k :"));
+ SEND(user->realname);
+ SEND(STRING("\n:"));
+ SEND(argv[0]);
+ SEND(STRING(" OPERTYPE "));
+ SEND(opertype);
+ SEND(STRING("\n"));
+
+ for (uint64_t i = 0; i < channel_list.len; i++) {
+ struct channel_info *channel = channel_list.array[i].ptr;
+ if (has_table_index(channel->user_list, argv[0])) {
+ char timestamp[21];
+ SEND(STRING("FJOIN "));
+ SEND(channel_list.array[i].name);
+ SEND(STRING(" "));
+ snprintf(timestamp, 21, "%ld", channel->ts);
+ SEND(NULSTR(timestamp));
+ SEND(STRING(" + :,"));
+ SEND(argv[0]);
+ SEND(STRING("\n"));
+ }
+ }
}
return 0;
@@ -875,28 +892,19 @@ int initservernetwork(void) {
SEND(send_password);
SEND(STRING(" 0 1HC :HaxServ\n"));
SEND(STRING("BURST "));
- char current_time[21]; // C HaxServ will be deprecated long before we reach 20-digit timestamps
- snprintf(current_time, 21, "%ld", time(NULL));
- SEND(((struct string){current_time, strlen(current_time)}));
- SEND(STRING("\nUID 1HC000000 "));
- SEND(((struct string){current_time, strlen(current_time)}));
- SEND(STRING(" "));
- SEND(nick);
- SEND(STRING(" "));
- SEND(hostmask);
- SEND(STRING(" "));
- SEND(hostmask);
- SEND(STRING(" HaxServ 192.168.1.1 "));
- SEND(((struct string){current_time, strlen(current_time)}));
- SEND(STRING(" +k :HaxServ\n:1HC000000 OPERTYPE "));
- SEND(opertype);
+ time_t current_time = time(NULL);
+ char current_time_str[21]; // C HaxServ will be deprecated long before we reach 20-digit timestamps
+ snprintf(current_time_str, 21, "%ld", current_time);
+ SEND(NULSTR(current_time_str));
SEND(STRING("\n"));
+ if (add_local_client(STRING("1HC000000"), nick, hostmask, nick, nick, current_time) != 0)
+ return 1;
for (uint64_t i = 0; i < num_prejoin_channels; i++) {
SEND(STRING("FJOIN "));
SEND(prejoin_channels[i]);
SEND(STRING(" "));
- SEND(((struct string){current_time, strlen(current_time)}));
+ SEND(NULSTR(current_time_str));
SEND(STRING(" + :,1HC000000\nMODE "));
SEND(prejoin_channels[i]);
SEND(STRING(" +o 1HC000000\n"));