From 4e820a26d221945b6277028f24c41393661e9124 Mon Sep 17 00:00:00 2001 From: Test_User Date: Sat, 15 Jun 2024 05:29:40 -0400 Subject: Commands and stuff --- protocols/inspircd2.c | 37 +++++++++++++++++++++++++++++++++++++ protocols/inspircd2.h | 4 ++++ 2 files changed, 41 insertions(+) (limited to 'protocols') diff --git a/protocols/inspircd2.c b/protocols/inspircd2.c index 5f546c7..688fb02 100644 --- a/protocols/inspircd2.c +++ b/protocols/inspircd2.c @@ -138,6 +138,7 @@ int init_inspircd2_protocol(void) { set_table_index(&inspircd2_protocol_commands, STRING("NICK"), &inspircd2_protocol_handle_nick); set_table_index(&inspircd2_protocol_commands, STRING("QUIT"), &inspircd2_protocol_handle_quit); set_table_index(&inspircd2_protocol_commands, STRING("KILL"), &inspircd2_protocol_handle_kill); + set_table_index(&inspircd2_protocol_commands, STRING("OPERTYPE"), &inspircd2_protocol_handle_opertype); set_table_index(&inspircd2_protocol_commands, STRING("FJOIN"), &inspircd2_protocol_handle_fjoin); set_table_index(&inspircd2_protocol_commands, STRING("PART"), &inspircd2_protocol_handle_part); @@ -489,6 +490,7 @@ void inspircd2_protocol_propagate(struct string from, struct server_info *self, } } +// [:source] SERVER void inspircd2_protocol_propagate_new_server(struct string from, struct string attached_to, struct server_info *info) { struct server_info *self = get_table_index(server_list, SID); @@ -527,6 +529,7 @@ void inspircd2_protocol_propagate_new_server(struct string from, struct string a inspircd2_protocol_propagate(from, self, STRING(" ENDBURST\n")); } +// [:source] SQUIT [?] void inspircd2_protocol_propagate_unlink_server(struct string from, struct server_info *a, struct server_info *b, size_t protocol) { struct server_info *source; struct server_info *target; @@ -616,6 +619,17 @@ void inspircd2_protocol_propagate_kill_user(struct string from, struct string so inspircd2_protocol_propagate(from, self, STRING("\n")); } +// :source OPERTYPE +void inspircd2_protocol_propagate_oper_user(struct string from, struct user_info *user, struct string type) { + struct server_info *self = get_table_index(server_list, SID); + + inspircd2_protocol_propagate(from, self, STRING(":")); + inspircd2_protocol_propagate(from, self, user->uid); + inspircd2_protocol_propagate(from, self, STRING(" OPERTYPE :")); + inspircd2_protocol_propagate(from, self, type); + inspircd2_protocol_propagate(from, self, STRING("\n")); +} + // [:source] FJOIN [] void inspircd2_protocol_propagate_set_channel(struct string from, struct channel_info *channel, char is_new_server, size_t user_count, struct user_info **users) { struct server_info *self = get_table_index(server_list, SID); @@ -1014,6 +1028,10 @@ int inspircd2_protocol_handle_ping(struct string source, size_t argc, struct str } } + struct server_info *reply = get_table_index(server_list, argv[0]); + if (!reply || !STRING_EQ(reply->next, config->sid)) + return 0; + networks[net].send(handle, STRING(":")); networks[net].send(handle, argv[1]); networks[net].send(handle, STRING(" PONG ")); @@ -1299,6 +1317,25 @@ int inspircd2_protocol_handle_kill(struct string source, size_t argc, struct str return 0; } +// :source OPERTYPE +int inspircd2_protocol_handle_opertype(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming) { + if (argc < 1) { + WRITES(2, STRING("[InspIRCd v2] Invalid OPERTYPE recieved! (Missing parameters)\r\n")); + return -1; + } + + struct user_info *user = get_table_index(user_list, source); + if (!user) + return 0; + + if (oper_user(config->sid, user, argv[0]) != 0) { + WRITES(2, STRING("[InspIRCd v2] ERROR: Unable to set oper type!\r\n")); + return -1; + } + + return 0; +} + // [:source] FJOIN [] int inspircd2_protocol_handle_fjoin(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming) { if (argc < 4) { diff --git a/protocols/inspircd2.h b/protocols/inspircd2.h index a7ac588..3309582 100644 --- a/protocols/inspircd2.h +++ b/protocols/inspircd2.h @@ -41,6 +41,8 @@ void * inspircd2_protocol_connection(void *type); void * inspircd2_protocol_autoconnect(void *type); void inspircd2_protocol_update_propagations(void); +void inspircd2_protocol_propagate(struct string from, struct server_info *self, struct string msg); + void inspircd2_protocol_propagate_new_server(struct string from, struct string attached_to, struct server_info *info); void inspircd2_protocol_propagate_unlink_server(struct string from, struct server_info *a, struct server_info *b, size_t protocol); @@ -48,6 +50,7 @@ void inspircd2_protocol_propagate_new_user(struct string from, struct user_info void inspircd2_protocol_propagate_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str); void inspircd2_protocol_propagate_remove_user(struct string from, struct user_info *info, struct string reason); void inspircd2_protocol_propagate_kill_user(struct string from, struct string source, struct user_info *info, struct string reason); +void inspircd2_protocol_propagate_oper_user(struct string from, struct user_info *info, struct string type); void inspircd2_protocol_propagate_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); void inspircd2_protocol_propagate_join_channel(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users); @@ -77,6 +80,7 @@ int inspircd2_protocol_handle_uid(struct string source, size_t argc, struct stri int inspircd2_protocol_handle_nick(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming); int inspircd2_protocol_handle_quit(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming); int inspircd2_protocol_handle_kill(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming); +int inspircd2_protocol_handle_opertype(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming); int inspircd2_protocol_handle_fjoin(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming); int inspircd2_protocol_handle_part(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming); -- cgit v1.2.3