diff options
Diffstat (limited to '')
-rw-r--r-- | client_network.c | 24 | ||||
-rw-r--r-- | commands.c | 22 | ||||
-rw-r--r-- | config.h | 1 | ||||
-rw-r--r-- | general_network.c | 12 | ||||
-rw-r--r-- | main.c | 6 | ||||
-rw-r--r-- | server_network.c | 40 |
6 files changed, 53 insertions, 52 deletions
diff --git a/client_network.c b/client_network.c index bdca265..a347888 100644 --- a/client_network.c +++ b/client_network.c @@ -62,7 +62,7 @@ int add_local_client(struct string uid, struct string nick_arg, struct string vh if (!server.data) goto add_local_client_fail_server; - memcpy(server.data, "1HC", 3); + memcpy(server.data, SID, 3); struct string hostname = { .data = malloc(vhost_arg.len), @@ -158,7 +158,7 @@ int add_local_client(struct string uid, struct string nick_arg, struct string vh SEND(uid); SEND(STRING(" OPERTYPE ")); SEND(opertype); - SEND(STRING("\n:1HC METADATA ")); + SEND(STRING("\n:"SID" METADATA ")); SEND(uid); SEND(STRING(" ssl_cert :vTrse ")); SEND(client_cert); @@ -210,7 +210,7 @@ int client_nick_handler(uint64_t argc, struct string *argv) { client_nick.len = argv[0].len; if (client_connected) { - SEND(STRING(":1HC000001 NICK ")); + SEND(STRING(":"SID"000001 NICK ")); SEND(client_nick); SEND(STRING(" ")); char current_time[22]; @@ -229,7 +229,7 @@ int client_user_handler(uint64_t argc, struct string *argv) { if (client_nick.len == 0) return 1; - if (add_local_client(STRING("1HC000001"), client_nick, client_hostmask, argv[0], argv[3], time(NULL)) != 0) + if (add_local_client(STRING(SID"000001"), client_nick, client_hostmask, argv[0], argv[3], time(NULL)) != 0) return 1; SENDCLIENT(STRING(":")); @@ -357,13 +357,13 @@ int client_join_handler(uint64_t argc, struct string *argv) { SENDCLIENT(channels); SENDCLIENT(STRING(" :End of /NAMES list.\r\n")); - SEND(STRING(":1HC FJOIN ")); + SEND(STRING(":"SID" FJOIN ")); SEND(channels); SEND(STRING(" ")); SEND(NULSTR(current_time_nulstr)); - SEND(STRING(" + :,1HC000001\n")); + SEND(STRING(" + :,"SID"000001\n")); - set_table_index(&(channel_info->user_list), STRING("1HC000001"), get_table_index(user_list, STRING("1HC000001"))); // TODO: Actually add local users to user_list + set_table_index(&(channel_info->user_list), STRING(SID"000001"), get_table_index(user_list, STRING(SID"000001"))); // TODO: Actually add local users to user_list channels.len = oldlen; @@ -381,7 +381,7 @@ int client_privmsg_handler(uint64_t argc, struct string *argv) { if (argc < 2) return 1; - SEND(STRING(":1HC000001 PRIVMSG ")); + SEND(STRING(":"SID"000001 PRIVMSG ")); SEND(argv[0]); SEND(STRING(" :")); SEND(argv[1]); @@ -443,9 +443,9 @@ int client_privmsg_handler(uint64_t argc, struct string *argv) { STRING("'\n"), }; - privmsg(STRING("1HC000000"), log_channel, sizeof(message)/sizeof(*message), message); + privmsg(STRING(SID"000000"), log_channel, sizeof(message)/sizeof(*message), message); - return cmd->func(STRING("1HC000001"), argv[1], argv[0], command_argc, command_argv); + return cmd->func(STRING(SID"000001"), argv[1], argv[0], command_argc, command_argv); } else { // TODO: complain about remote access WRITES(1, STRING("Not executing local-only command from a remote source!\n")); @@ -453,7 +453,7 @@ int client_privmsg_handler(uint64_t argc, struct string *argv) { } } else { if (argv[0].data[0] == '#') { - SEND(STRING(":1HC000000 NOTICE ")); + SEND(STRING(":"SID"000000 NOTICE ")); SEND(argv[0]); SEND(STRING(" :Unknown command: " "\x03" "04")); SEND(command_argv[0]); @@ -492,7 +492,7 @@ int client_mode_handler(uint64_t argc, struct string *argv) { if (argc < 2) return 0; // Mode querying not supported yet - SEND(STRING(":1HC000001 MODE ")); + SEND(STRING(":"SID"000001 MODE ")); for (uint64_t i = 0; i < argc - 1; i++) { SEND(argv[i]); SEND(STRING(" ")); @@ -50,7 +50,7 @@ int help_command(struct string sender, struct string original_message, struct st def->summary, }; - privmsg(STRING("1HC000000"), to, sizeof(message)/sizeof(*message), message); + privmsg(STRING(SID"000000"), to, sizeof(message)/sizeof(*message), message); } return 0; @@ -84,17 +84,17 @@ static struct pref_type_suff { uint8_t type; struct string suff; } sus_strings[] = { - {STRING(":1HC000000 PRIVMSG "), 0, STRING(" :Andrew is very sus.\n")}, - {STRING(":1HC000000 PRIVMSG "), 0, STRING(" :I was the impostor, but you only know because I killed you.\n")}, - {STRING(":1HC000000 PRIVMSG "), 0, STRING(" :\x1b(0\n")}, - {STRING(":1HC000000 KILL "), 1, STRING(" :Ejected (1 Impostor remains)\n")}, - {STRING(":1HC000000 KILL "), 1, STRING(" :Ejected, and the crewmates have won.\n")}, + {STRING(":"SID"000000 PRIVMSG "), 0, STRING(" :Andrew is very sus.\n")}, + {STRING(":"SID"000000 PRIVMSG "), 0, STRING(" :I was the impostor, but you only know because I killed you.\n")}, + {STRING(":"SID"000000 PRIVMSG "), 0, STRING(" :\x1b(0\n")}, + {STRING(":"SID"000000 KILL "), 1, STRING(" :Ejected (1 Impostor remains)\n")}, + {STRING(":"SID"000000 KILL "), 1, STRING(" :Ejected, and the crewmates have won.\n")}, }, cr_strings[] = { - {STRING(":1HC000000 PRIVMSG "), 0, STRING(" :You are now a cruxian toxicpod, kill the sharded crewmates.\n")}, - {STRING(":1HC000000 PRIVMSG "), 0, STRING(" :You are now a cruxian omura, kill the sharded crewmates.\n")}, - {STRING(":1HC000000 PRIVMSG "), 0, STRING(" :You are now a cruxian oct, but you ran out of reactors.\n")}, - {STRING(":1HC000000 KILL "), 1, STRING(" :Eliminated (You became a cruxian eclipse, but were drawn to my bait reactor)\n")}, - {STRING(":1HC000000 PRIVMSG "), 0, STRING(" :You attempted to change into a cruxian navanax, but were caught in the act.\n")}, + {STRING(":"SID"000000 PRIVMSG "), 0, STRING(" :You are now a cruxian toxicpod, kill the sharded crewmates.\n")}, + {STRING(":"SID"000000 PRIVMSG "), 0, STRING(" :You are now a cruxian omura, kill the sharded crewmates.\n")}, + {STRING(":"SID"000000 PRIVMSG "), 0, STRING(" :You are now a cruxian oct, but you ran out of reactors.\n")}, + {STRING(":"SID"000000 KILL "), 1, STRING(" :Eliminated (You became a cruxian eclipse, but were drawn to my bait reactor)\n")}, + {STRING(":"SID"000000 PRIVMSG "), 0, STRING(" :You attempted to change into a cruxian navanax, but were caught in the act.\n")}, }; int sus_command(struct string sender, struct string original_message, struct string to, uint64_t argc, struct string *argv) { @@ -36,6 +36,7 @@ extern struct string address; // = STRING("irc.nowhere.net"); extern struct string port; // = STRING("1234"); extern struct string nick; // = STRING("HaxServ"); extern struct string server_name; // = STRING("hax.irc.nowhere.net"); +#define SID "1HC" extern struct string log_channel; // = STRING("#logs"); extern struct string recv_password; // = STRING("password we should get back from the other server"); diff --git a/general_network.c b/general_network.c index 9676c2b..7944d21 100644 --- a/general_network.c +++ b/general_network.c @@ -83,7 +83,7 @@ char channel_mode_types[UCHAR_MAX] = { }; int privmsg(struct string source, struct string target, size_t num_message_parts, struct string message[num_message_parts]) { - if (!STRING_EQ(target, STRING("1HC000001"))) { // if not sending to our one local user + if (!STRING_EQ(target, STRING(SID"000001"))) { // if not sending to our one local user if (source.len != 0) { SEND(STRING(":")); SEND(source); @@ -103,7 +103,7 @@ int privmsg(struct string source, struct string target, size_t num_message_parts if (target.data[0] == '#') { struct channel_info *channel = get_table_index(channel_list, target); - if (channel && has_table_index(channel->user_list, STRING("1HC000001"))) + if (channel && has_table_index(channel->user_list, STRING(SID"000001"))) goto privmsg_client; } @@ -114,13 +114,13 @@ int privmsg(struct string source, struct string target, size_t num_message_parts if (source.len != 0) { SENDCLIENT(STRING(":")); // TODO: Proper lookups of users and such - if (STRING_EQ(source, STRING("1HC000000"))) { + if (STRING_EQ(source, STRING(SID"000000"))) { SENDCLIENT(nick); SENDCLIENT(STRING("!")); SENDCLIENT(nick); SENDCLIENT(STRING("@")); SENDCLIENT(hostmask); - } else if (STRING_EQ(source, STRING("1HC"))) { + } else if (STRING_EQ(source, STRING(SID))) { SENDCLIENT(server_name); } else { SENDCLIENT(source); @@ -132,7 +132,7 @@ int privmsg(struct string source, struct string target, size_t num_message_parts SENDCLIENT(STRING(" PRIVMSG ")); } - if (STRING_EQ(target, STRING("1HC000001"))) + if (STRING_EQ(target, STRING(SID"000001"))) SENDCLIENT(client_nick); else SENDCLIENT(target); @@ -154,7 +154,7 @@ int remove_user(struct string uid, struct string reason) { // If disconnecting t for (uint64_t i = 0; i < channel_list.len; i++) { // TODO: Use channel list attached to the user (doesn't exist yet) struct channel_info *chan_info = channel_list.array[i].ptr; if (has_table_index(chan_info->user_list, uid)) { - if (send_client && has_table_index(chan_info->user_list, STRING("1HC000001"))) { + if (send_client && has_table_index(chan_info->user_list, STRING(SID"000001"))) { SENDCLIENT(STRING(":")); SENDCLIENT(info->nick); SENDCLIENT(STRING("!")); @@ -228,9 +228,9 @@ void *client_loop(void *ign) { } disconnect_client: if (client_connected) { - SEND(STRING(":1HC000001 QUIT :Ping timeout: -240 seconds\n")); + SEND(STRING(":"SID"000001 QUIT :Ping timeout: -240 seconds\n")); client_connected = 0; - remove_user(STRING("1HC000001"), STRING("Ping timeout: -240 seconds\n")); + remove_user(STRING(SID"000001"), STRING("Ping timeout: -240 seconds\n")); } close(client_fd); @@ -260,7 +260,7 @@ int main(void) { if (!timeout) break; - SEND(STRING("")); + SEND(STRING()); } if (new_len == 0) { diff --git a/server_network.c b/server_network.c index 3e8e6dd..a49e775 100644 --- a/server_network.c +++ b/server_network.c @@ -374,7 +374,7 @@ int kill_handler(struct string sender, uint64_t argc, struct string *argv) { if (!user) return 0; // TODO: Currently not all local users are considered; fix that, then make this give an error - if (STRING_EQ(user->server, STRING("1HC"))) { + if (STRING_EQ(user->server, STRING(SID))) { char user_time[21]; snprintf(user_time, 21, "%ld", user->user_ts); char nick_time[21]; @@ -438,7 +438,7 @@ int nick_handler(struct string sender, uint64_t argc, struct string *argv) { for (uint64_t i = 0; i < channel_list.len; i++) { // TODO: More efficient way of doing this struct channel_info *channel = channel_list.array[i].ptr; - if (has_table_index(channel->user_list, sender) && has_table_index(channel->user_list, STRING("1HC000001"))) { + if (has_table_index(channel->user_list, sender) && has_table_index(channel->user_list, STRING(SID"000001"))) { SENDCLIENT(STRING(":")); SENDCLIENT(info->nick); SENDCLIENT(STRING("!")); @@ -543,7 +543,7 @@ int fjoin_handler(struct string sender, uint64_t argc, struct string *argv) { if (userlist.len < 10) // Not enough for any users return 0; - uint8_t sendclient = has_table_index(channel->user_list, STRING("1HC000001")); + uint8_t sendclient = has_table_index(channel->user_list, STRING(SID"000001")); uint64_t offset = 0; while (1) { @@ -625,7 +625,7 @@ int privmsg_handler(struct string sender, uint64_t argc, struct string *argv) { server = 0; if (argv[0].data[0] == '#') { struct channel_info *channel = get_table_index(channel_list, argv[0]); - if (channel && has_table_index(channel->user_list, STRING("1HC000001"))) { + if (channel && has_table_index(channel->user_list, STRING(SID"000001"))) { SENDCLIENT(STRING(":")); SENDCLIENT(user->nick); SENDCLIENT(STRING("!")); @@ -638,7 +638,7 @@ int privmsg_handler(struct string sender, uint64_t argc, struct string *argv) { SENDCLIENT(argv[1]); SENDCLIENT(STRING("\r\n")); } - } else if (STRING_EQ(argv[0], STRING("1HC000001"))) { + } else if (STRING_EQ(argv[0], STRING(SID"000001"))) { SENDCLIENT(STRING(":")); SENDCLIENT(user->nick); SENDCLIENT(STRING("!")); @@ -656,7 +656,7 @@ int privmsg_handler(struct string sender, uint64_t argc, struct string *argv) { if (server) { if (argv[0].data[0] == '#') { struct channel_info *channel = get_table_index(channel_list, argv[0]); - if (channel && has_table_index(channel->user_list, STRING("1HC000001"))) { + if (channel && has_table_index(channel->user_list, STRING(SID"000001"))) { SENDCLIENT(STRING(":")); SENDCLIENT(server->address); SENDCLIENT(STRING(" PRIVMSG ")); @@ -665,7 +665,7 @@ int privmsg_handler(struct string sender, uint64_t argc, struct string *argv) { SENDCLIENT(argv[1]); SENDCLIENT(STRING("\r\n")); } - } else if (STRING_EQ(argv[0], STRING("1HC000001"))) { + } else if (STRING_EQ(argv[0], STRING(SID"000001"))) { SENDCLIENT(STRING(":")); SENDCLIENT(server->address); SENDCLIENT(STRING(" PRIVMSG ")); @@ -683,7 +683,7 @@ int privmsg_handler(struct string sender, uint64_t argc, struct string *argv) { return 0; offset = command_prefix.len; - } else if (STRING_EQ(argv[0], STRING("1HC000000"))) { + } else if (STRING_EQ(argv[0], STRING(SID"000000"))) { offset = 0; } else { return 0; @@ -731,7 +731,7 @@ int privmsg_handler(struct string sender, uint64_t argc, struct string *argv) { if (!user) { WRITES(2, STRING("User is unknown!\n")); - SEND(STRING(":1HC000000 NOTICE ")); + SEND(STRING(":"SID"000000 NOTICE ")); if (argv[0].data[0] == '#') SEND(argv[0]); else @@ -743,7 +743,7 @@ int privmsg_handler(struct string sender, uint64_t argc, struct string *argv) { if (user->opertype.len != cmd->privs.len || memcmp(user->opertype.data, cmd->privs.data, cmd->privs.len)) { // TODO: complain about missing privs - SEND(STRING(":1HC000000 NOTICE ")); + SEND(STRING(":"SID"000000 NOTICE ")); if (argv[0].data[0] == '#') SEND(argv[0]); else @@ -756,13 +756,13 @@ int privmsg_handler(struct string sender, uint64_t argc, struct string *argv) { struct string message[] = { user ? STRING("User ") : (server ? STRING("Server ") : STRING("An unknown user (something desycned... this shouldn't happen)")), - user ? user->nick : (server ? server->address : STRING("")), + user ? user->nick : (server ? server->address : STRING()), STRING(" executes `"), argv[1], STRING("'\n"), }; - privmsg(STRING("1HC000000"), log_channel, sizeof(message)/sizeof(*message), message); + privmsg(STRING(SID"000000"), log_channel, sizeof(message)/sizeof(*message), message); return cmd->func(sender, argv[1], argv[0], command_argc, command_argv); } else { @@ -771,7 +771,7 @@ int privmsg_handler(struct string sender, uint64_t argc, struct string *argv) { return 0; } } else { - SEND(STRING(":1HC000000 NOTICE ")); + SEND(STRING(":"SID"000000 NOTICE ")); if (argv[0].data[0] == '#') SEND(argv[0]); else @@ -791,7 +791,7 @@ int part_handler(struct string sender, uint64_t argc, struct string *argv) { struct channel_info *channel = get_table_index(channel_list, argv[0]); struct user_info *user = get_table_index(user_list, sender); - if (user && channel && has_table_index(channel->user_list, STRING("1HC000001"))) { + if (user && channel && has_table_index(channel->user_list, STRING(SID"000001"))) { SENDCLIENT(STRING(":")); SENDCLIENT(user->nick); SENDCLIENT(STRING("!")); @@ -833,7 +833,7 @@ int notice_handler(struct string sender, uint64_t argc, struct string *argv) { if (argv[0].data[0] == '#') { struct channel_info *channel = get_table_index(channel_list, argv[0]); - if (channel && has_table_index(channel->user_list, STRING("1HC000001"))) { + if (channel && has_table_index(channel->user_list, STRING(SID"000001"))) { SENDCLIENT(STRING(":")); if (user) { SENDCLIENT(user->nick); @@ -851,7 +851,7 @@ int notice_handler(struct string sender, uint64_t argc, struct string *argv) { SENDCLIENT(argv[1]); SENDCLIENT(STRING("\r\n")); } - } else if (STRING_EQ(argv[0], STRING("1HC000001"))) { + } else if (STRING_EQ(argv[0], STRING(SID"000001"))) { SENDCLIENT(STRING(":")); if (user) { SENDCLIENT(user->nick); @@ -905,14 +905,14 @@ int initservernetwork(void) { SEND(server_name); SEND(STRING(" ")); SEND(send_password); - SEND(STRING(" 0 1HC :HaxServ\n")); + SEND(STRING(" 0 "SID" :HaxServ\n")); SEND(STRING("BURST ")); 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) + if (add_local_client(STRING(SID"000000"), nick, hostmask, nick, nick, current_time) != 0) return 1; for (uint64_t i = 0; i < num_prejoin_channels; i++) { @@ -920,9 +920,9 @@ int initservernetwork(void) { SEND(prejoin_channels[i]); SEND(STRING(" ")); SEND(NULSTR(current_time_str)); - SEND(STRING(" + :,1HC000000\nMODE ")); + SEND(STRING(" + :,"SID"000000\nMODE ")); SEND(prejoin_channels[i]); - SEND(STRING(" +o 1HC000000\n")); + SEND(STRING(" +o "SID"000000\n")); } SEND(STRING("ENDBURST\n")); |