diff options
author | Test_User <hax@andrewyu.org> | 2024-07-18 20:12:29 -0400 |
---|---|---|
committer | Test_User <hax@andrewyu.org> | 2024-07-18 20:32:10 -0400 |
commit | e755e8b341eea1b37ef82584cd65a05edf8fdbaa (patch) | |
tree | 63862f2609e7470ec3cb432b416626b90fe6f3f8 /protocols | |
parent | 925da4ee0c7364900e67c1c6ce4a1323166d5198 (diff) | |
download | haxircd-e755e8b341eea1b37ef82584cd65a05edf8fdbaa.tar.gz haxircd-e755e8b341eea1b37ef82584cd65a05edf8fdbaa.zip |
Partial nickname enforcement implemented
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/inspircd2.c | 42 | ||||
-rw-r--r-- | protocols/inspircd2.h | 6 |
2 files changed, 34 insertions, 14 deletions
diff --git a/protocols/inspircd2.c b/protocols/inspircd2.c index b19960e..c11577e 100644 --- a/protocols/inspircd2.c +++ b/protocols/inspircd2.c @@ -639,14 +639,34 @@ void inspircd2_protocol_propagate_new_user(struct string from, struct user_info } // :source NICK <nick> <timestamp> -void inspircd2_protocol_propagate_rename_user(struct string from, struct user_info *user, struct string nick, size_t timestamp, struct string timestamp_str) { - inspircd2_protocol_propagate(from, STRING(":")); - inspircd2_protocol_propagate(from, user->uid); - inspircd2_protocol_propagate(from, STRING(" NICK ")); - inspircd2_protocol_propagate(from, nick); - inspircd2_protocol_propagate(from, STRING(" ")); - inspircd2_protocol_propagate(from, timestamp_str); - inspircd2_protocol_propagate(from, STRING("\n")); +void inspircd2_protocol_propagate_rename_user(struct string from, struct user_info *user, struct string nick, size_t timestamp, struct string timestamp_str, char forced, char immediate) { + if (forced) { + if (STRING_EQ(user->uid, nick)) { + inspircd2_protocol_propagate(from, STRING(":")); + inspircd2_protocol_propagate(from, from); + inspircd2_protocol_propagate(from, STRING(" SAVE ")); + inspircd2_protocol_propagate(from, user->uid); + inspircd2_protocol_propagate(from, STRING(" :")); + inspircd2_protocol_propagate(from, user->nick_ts_str); + inspircd2_protocol_propagate(from, STRING("\n")); + } else { + inspircd2_protocol_propagate(from, STRING(":")); + inspircd2_protocol_propagate(from, from); + inspircd2_protocol_propagate(from, STRING(" SANICK ")); + inspircd2_protocol_propagate(from, user->uid); + inspircd2_protocol_propagate(from, STRING(" :")); + inspircd2_protocol_propagate(from, nick); + inspircd2_protocol_propagate(from, STRING("\n")); + } + } else { + inspircd2_protocol_propagate(from, STRING(":")); + inspircd2_protocol_propagate(from, user->uid); + inspircd2_protocol_propagate(from, STRING(" NICK ")); + inspircd2_protocol_propagate(from, nick); + inspircd2_protocol_propagate(from, STRING(" ")); + inspircd2_protocol_propagate(from, timestamp_str); + inspircd2_protocol_propagate(from, STRING("\n")); + } } // :source QUIT [<reason>?] @@ -860,7 +880,7 @@ int inspircd2_protocol_handle_new_user(struct string from, struct user_info *inf return 0; } -int inspircd2_protocol_handle_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str) { +int inspircd2_protocol_handle_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str, char forced, char immediate) { return 0; } @@ -908,7 +928,7 @@ void inspircd2_protocol_fail_new_user(struct string from, struct user_info *info return; } -void inspircd2_protocol_fail_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str) { +void inspircd2_protocol_fail_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str, char forced, char immediate) { return; } @@ -1404,7 +1424,7 @@ int inspircd2_protocol_handle_nick(struct string source, size_t argc, struct str if (!user) return 0; // KILL timings, etc - if (rename_user(config->sid, user, argv[0], nick_ts) != 0) + if (rename_user(config->sid, user, argv[0], nick_ts, 0, 1) != 0) return -1; return 0; diff --git a/protocols/inspircd2.h b/protocols/inspircd2.h index 7c5bc99..144ba15 100644 --- a/protocols/inspircd2.h +++ b/protocols/inspircd2.h @@ -49,7 +49,7 @@ void inspircd2_protocol_propagate_new_server(struct string from, struct string a void inspircd2_protocol_propagate_unlink_server(struct string from, struct server_info *a, struct server_info *b, size_t protocol); void inspircd2_protocol_propagate_new_user(struct string from, struct user_info *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_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str, char forced, char immediate); 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, struct string source); @@ -69,7 +69,7 @@ int inspircd2_protocol_handle_new_server(struct string from, struct string attac void inspircd2_protocol_handle_unlink_server(struct string from, struct server_info *a, struct server_info *b, size_t protocol); int inspircd2_protocol_handle_new_user(struct string from, struct user_info *info); -int inspircd2_protocol_handle_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str); +int inspircd2_protocol_handle_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str, char forced, char immediate); void inspircd2_protocol_handle_remove_user(struct string from, struct user_info *info, struct string reason, char propagate); void inspircd2_protocol_handle_kill_user(struct string from, struct string source, struct user_info *info, struct string reason); int inspircd2_protocol_handle_oper_user(struct string from, struct user_info *info, struct string type, struct string source); @@ -85,7 +85,7 @@ void inspircd2_protocol_handle_kick_channel(struct string from, struct string so void inspircd2_protocol_fail_new_server(struct string from, struct string attached_to, struct server_info *info); void inspircd2_protocol_fail_new_user(struct string from, struct user_info *info); -void inspircd2_protocol_fail_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str); +void inspircd2_protocol_fail_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str, char forced, char immediate); void inspircd2_protocol_fail_oper_user(struct string from, struct user_info *info, struct string type, struct string source); void inspircd2_protocol_fail_set_account(struct string from, struct user_info *info, struct string account, struct string source); |