diff options
author | Test_User <hax@andrewyu.org> | 2024-06-24 11:08:29 -0400 |
---|---|---|
committer | Test_User <hax@andrewyu.org> | 2024-06-24 11:08:50 -0400 |
commit | d095efe06273ec29bdc07c2cc522d6fe5a793550 (patch) | |
tree | 0eab2d9999ae71d5cff1ae682b54d17ad8aa98b5 | |
parent | 7b3767d3988c3bb9c96f049ca8e5a829917c8426 (diff) | |
download | haxircd-d095efe06273ec29bdc07c2cc522d6fe5a793550.tar.gz haxircd-d095efe06273ec29bdc07c2cc522d6fe5a793550.zip |
The start of some services, inspircd3 support extra broken for now
-rw-r--r-- | Makefile | 19 | ||||
-rw-r--r-- | config.h | 12 | ||||
-rw-r--r-- | general_network.c | 65 | ||||
-rw-r--r-- | general_network.h | 3 | ||||
-rw-r--r-- | protocols.c | 50 | ||||
-rw-r--r-- | protocols.h | 12 | ||||
-rw-r--r-- | protocols/inspircd2.c | 45 | ||||
-rw-r--r-- | protocols/inspircd2.h | 8 | ||||
-rw-r--r-- | protocols/inspircd3.h | 6 | ||||
-rw-r--r-- | pseudoclients.c | 15 | ||||
-rw-r--r-- | pseudoclients.h | 7 | ||||
-rw-r--r-- | pseudoclients/services.c | 83 | ||||
-rw-r--r-- | pseudoclients/services.h | 48 |
13 files changed, 356 insertions, 17 deletions
@@ -48,6 +48,7 @@ LDFLAGS = -lpthread printf '%s\n' 'LAST_INSPIRCD2_PROTOCOL = $(INSPIRCD2_PROTOCOL)' >> .makeopts printf '%s\n' 'LAST_INSPIRCD3_PROTOCOL = $(INSPIRCD3_PROTOCOL)' >> .makeopts printf '%s\n' 'LAST_HAXSERV_PSEUDOCLIENT = $(HAXSERV_PSEUDOCLIENT)' >> .makeopts + printf '%s\n' 'LAST_SERVICES_PSEUDOCLIENT = $(SERVICES_PSEUDOCLIENT)' >> .makeopts printf '%s\n' 'LAST_SAFE_STACK = $(SAFE_STACK)' >> .makeopts printf '%s\n' 'LAST_FUTEX = $(FUTEX)' >> .makeopts printf '%s\n' 'LAST_ATOMICS = $(ATOMICS)' >> .makeopts @@ -181,6 +182,14 @@ else HAXSERV_PSEUDOCLIENT := $(LAST_HAXSERV_PSEUDOCLIENT) endif +ifneq ($(SERVICES_PSEUDOCLIENT),) +ifneq ($(SERVICES_PSEUDOCLIENT),$(LAST_SERVICES_PSEUDOCLIENT)) +rebuild = 1 +endif +else +SERVICES_PSEUDOCLIENT := $(LAST_SERVICES_PSEUDOCLIENT) +endif + ifneq ($(SAFE_STACK),) ifneq ($(SAFE_STACK),$(LAST_SAFE_STACK)) rebuild = 1 @@ -330,6 +339,12 @@ CFLAGS += -DUSE_HAXSERV_PSEUDOCLIENT USE_PSEUDOCLIENTS = 1 endif +ifeq ($(SERVICES_PSEUDOCLIENT),1) +SOFILES += pseudoclients/services.so +CFLAGS += -DUSE_SERVICES_PSEUDOCLIENT +USE_PSEUDOCLIENTS = 1 +endif + ifeq ($(USE_CLIENT),1) @@ -497,6 +512,10 @@ ifeq ($(HAXSERV_PSEUDOCLIENT),1) $(call DEPS,pseudoclients/haxserv,so) endif +ifeq ($(SERVICES_PSEUDOCLIENT),1) +$(call DEPS,pseudoclients/services,so) +endif + clean: $(RM) HaxIRCd for file in `find . -name '*.so'`; do $(RM) $$file; done @@ -116,3 +116,15 @@ extern struct string HAXSERV_REQUIRED_OPER_TYPE; // = STRING("Admin"); extern struct string HAXSERV_LOG_CHANNEL; // = STRING("#services"); #endif + +#ifdef USE_SERVICES_PSEUDOCLIENT +extern struct string NICKSERV_UID; // = STRING("200000001"); +extern struct string NICKSERV_NICK; // = STRING("NickServ"); +extern struct string NICKSERV_FULLNAME; // = STRING("Nickname Services"); +extern struct string NICKSERV_IDENT; // = STRING("NickServ"); +extern struct string NICKSERV_VHOST; // = STRING("services/NickServ"); +extern struct string NICKSERV_HOST; // = STRING("localhost"); +extern struct string NICKSERV_ADDRESS; // = STRING("/dev/null"); + +extern struct string SERVICES_CHANNEL; // = STRING("#services"); +#endif diff --git a/general_network.c b/general_network.c index 9501ea4..f6c264a 100644 --- a/general_network.c +++ b/general_network.c @@ -322,11 +322,8 @@ int add_user(struct string from, struct string attached_to, struct string uid, s if (str_clone(&(new_info->address), address) != 0) goto add_user_free_host; - if (str_clone(&(new_info->oper_type), STRING("")) != 0) - goto add_user_free_address; - if (set_table_index(&user_list, uid, new_info) != 0) - goto add_user_free_oper_type; + goto add_user_free_address; if (set_table_index(&(attached->user_list), uid, new_info) != 0) goto add_user_remove_user_list; @@ -334,6 +331,9 @@ int add_user(struct string from, struct string attached_to, struct string uid, s new_info->channel_list.array = malloc(0); new_info->channel_list.len = 0; + new_info->account_name = (struct string){.data = malloc(0), .len = 0}; + new_info->oper_type = (struct string){.data = malloc(0), .len = 0}; + #ifdef USE_SERVER if (protocols_handle_new_user(from, new_info) != 0) goto add_user_free_channel_list; @@ -348,8 +348,6 @@ int add_user(struct string from, struct string attached_to, struct string uid, s remove_table_index(&(attached->user_list), uid); add_user_remove_user_list: remove_table_index(&user_list, uid); - add_user_free_oper_type: - free(new_info->oper_type.data); add_user_free_address: free(new_info->address.data); add_user_free_host: @@ -436,22 +434,15 @@ void remove_user(struct string from, struct user_info *user, struct string reaso free(user->host.data); free(user->address.data); free(user->oper_type.data); + free(user->account_name.data); free(user); } int kill_user(struct string from, struct string source, struct user_info *user, struct string reason) { #ifdef USE_PSEUDOCLIENTS if (user->is_pseudoclient) { - switch (user->pseudoclient) { -#ifdef USE_HAXSERV_PSEUDOCLIENT - case HAXSERV_PSEUDOCLIENT: - if (!pseudoclients[HAXSERV_PSEUDOCLIENT].allow_kill(from, source, user, reason)) - return 1; - break; -#endif - default: - break; - } + if (!pseudoclients[user->pseudoclient].allow_kill(from, source, user, reason)) + return 1; } #endif @@ -489,6 +480,29 @@ int oper_user(struct string from, struct user_info *user, struct string type, st return 0; } +int set_account(struct string from, struct user_info *user, struct string account, struct string source) { + if (STRING_EQ(user->account_name, account)) + return 0; + + struct string tmp; + if (str_clone(&tmp, account) != 0) + return 1; + +#ifdef USE_SERVER + if (protocols_handle_set_account(from, user, account, source) != 0) { + free(tmp.data); + return 1; + } + + protocols_propagate_set_account(from, user, account, source); +#endif + + free(user->account_name.data); + user->account_name = tmp; + + return 0; +} + int set_channel(struct string from, struct string name, size_t timestamp, size_t user_count, struct user_info **users) { char is_new_channel; struct channel_info *channel = get_table_index(channel_list, name); @@ -773,6 +787,25 @@ int do_trivial_reloads(void) { reload_pseudoclients[HAXSERV_PSEUDOCLIENT] = 0; } #endif +#ifdef USE_SERVICES_PSEUDOCLIENT + if (reload_pseudoclients[SERVICES_PSEUDOCLIENT]) { + if (pseudoclients[SERVICES_PSEUDOCLIENT].pre_reload() != 0) + return 1; + dlclose(pseudoclients[SERVICES_PSEUDOCLIENT].dl_handle); + pseudoclients[SERVICES_PSEUDOCLIENT].dl_handle = dlopen("pseudoclients/services.so", RTLD_NOW | RTLD_LOCAL); + if (!pseudoclients[SERVICES_PSEUDOCLIENT].dl_handle) { + puts(dlerror()); + abort(); // TODO: Ugh... + } + + pseudoclients[SERVICES_PSEUDOCLIENT].post_reload = dlsym(pseudoclients[SERVICES_PSEUDOCLIENT].dl_handle, "services_pseudoclient_post_reload"); + if (pseudoclients[SERVICES_PSEUDOCLIENT].post_reload() != 0) { + abort(); // TODO: Ugh... + } + + reload_pseudoclients[SERVICES_PSEUDOCLIENT] = 0; + } +#endif #endif return 0; } diff --git a/general_network.h b/general_network.h index d75e4f6..eccfe8e 100644 --- a/general_network.h +++ b/general_network.h @@ -91,6 +91,7 @@ struct user_info { size_t nick_ts; struct string oper_type; + struct string account_name; struct string server; @@ -133,6 +134,8 @@ void remove_user(struct string from, struct user_info *user, struct string reaso int kill_user(struct string from, struct string source, struct user_info *user, struct string reason); int oper_user(struct string from, struct user_info *user, struct string type, struct string source); +int set_account(struct string from, struct user_info *user, struct string account, struct string source); + int set_channel(struct string from, struct string name, size_t timestamp, size_t user_count, struct user_info **users); int join_channel(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users, char propagate); void part_channel(struct string from, struct channel_info *channel, struct user_info *user, struct string reason, char propagate); diff --git a/protocols.c b/protocols.c index 1eb1786..d27386a 100644 --- a/protocols.c +++ b/protocols.c @@ -56,6 +56,8 @@ struct protocol protocols[NUM_PROTOCOLS] = { .propagate_kill_user = inspircd2_protocol_propagate_kill_user, .propagate_oper_user = inspircd2_protocol_propagate_oper_user, + .propagate_set_account = inspircd2_protocol_propagate_set_account, + .propagate_set_channel = inspircd2_protocol_propagate_set_channel, .propagate_join_channel = inspircd2_protocol_propagate_join_channel, .propagate_part_channel = inspircd2_protocol_propagate_part_channel, @@ -73,6 +75,8 @@ struct protocol protocols[NUM_PROTOCOLS] = { .handle_kill_user = inspircd2_protocol_handle_kill_user, .handle_oper_user = inspircd2_protocol_handle_oper_user, + .handle_set_account = inspircd2_protocol_handle_set_account, + .handle_set_channel = inspircd2_protocol_handle_set_channel, .handle_join_channel = inspircd2_protocol_handle_join_channel, .handle_part_channel = inspircd2_protocol_handle_part_channel, @@ -84,6 +88,8 @@ struct protocol protocols[NUM_PROTOCOLS] = { .fail_rename_user = inspircd2_protocol_fail_rename_user, .fail_oper_user = inspircd2_protocol_fail_oper_user, + .fail_set_account = inspircd2_protocol_fail_set_account, + .fail_set_channel = inspircd2_protocol_fail_set_channel, .fail_join_channel = inspircd2_protocol_fail_join_channel, @@ -110,6 +116,8 @@ struct protocol protocols[NUM_PROTOCOLS] = { .propagate_kill_user = inspircd3_protocol_propagate_kill_user, .propagate_oper_user = inspircd3_protocol_propagate_oper_user, + .propagate_set_account = inspircd3_protocol_propagate_set_account, + .propagate_set_channel = inspircd3_protocol_propagate_set_channel, .propagate_join_channel = inspircd3_protocol_propagate_join_channel, .propagate_part_channel = inspircd3_protocol_propagate_part_channel, @@ -127,6 +135,8 @@ struct protocol protocols[NUM_PROTOCOLS] = { .handle_kill_user = inspircd3_protocol_handle_kill_user, .handle_oper_user = inspircd3_protocol_handle_oper_user, + .handle_set_account = inspircd3_protocol_handle_set_account, + .handle_set_channel = inspircd3_protocol_handle_set_channel, .handle_join_channel = inspircd3_protocol_handle_join_channel, .handle_part_channel = inspircd3_protocol_handle_part_channel, @@ -138,6 +148,8 @@ struct protocol protocols[NUM_PROTOCOLS] = { .fail_rename_user = inspircd3_protocol_fail_rename_user, .fail_oper_user = inspircd3_protocol_fail_oper_user, + .fail_set_account = inspircd3_protocol_fail_set_account, + .fail_set_channel = inspircd3_protocol_fail_set_channel, .fail_join_channel = inspircd3_protocol_fail_join_channel, @@ -240,6 +252,14 @@ void protocols_propagate_oper_user(struct string from, struct user_info *info, s } } +void protocols_propagate_set_account(struct string from, struct user_info *info, struct string account, struct string source) { + for (size_t i = 0; i < NUM_PROTOCOLS; i++) { + if (!active_protocols[i]) + continue; + protocols[i].propagate_set_account(from, info, account, source); + } +} + void protocols_propagate_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users) { for (size_t i = 0; i < NUM_PROTOCOLS; i++) { if (!active_protocols[i]) @@ -400,6 +420,28 @@ int protocols_handle_oper_user(struct string from, struct user_info *info, struc return 1; } +int protocols_handle_set_account(struct string from, struct user_info *info, struct string account, struct string source) { + size_t i; + for (i = 0; i < NUM_PROTOCOLS; i++) { + if (!active_protocols[i]) + continue; + if (protocols[i].handle_set_account(from, info, account, source) != 0) + goto protocols_handle_set_account_fail; + } + + return 0; + + protocols_handle_set_account_fail: + while (i > 0) { + i--; + if (!active_protocols[i]) + continue; + protocols[i].fail_set_account(from, info, account, source); + } + + return 1; +} + int protocols_handle_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users) { size_t i; for (i = 0; i < NUM_PROTOCOLS; i++) { @@ -492,6 +534,14 @@ void protocols_fail_oper_user(struct string from, struct user_info *info, struct } } +void protocols_fail_set_account(struct string from, struct user_info *info, struct string account, struct string source) { + for (size_t i = 0; i < NUM_PROTOCOLS; i++) { + if (!active_protocols[i]) + continue; + protocols[i].fail_set_account(from, info, account, source); + } +} + void protocols_fail_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users) { for (size_t i = 0; i < NUM_PROTOCOLS; i++) { if (!active_protocols[i]) diff --git a/protocols.h b/protocols.h index 7f84e63..e17db75 100644 --- a/protocols.h +++ b/protocols.h @@ -52,6 +52,8 @@ struct protocol { void (*propagate_kill_user)(struct string from, struct string source, struct user_info *info, struct string reason); void (*propagate_oper_user)(struct string from, struct user_info *info, struct string type, struct string reason); + void (*propagate_set_account)(struct string from, struct user_info *info, struct string account, struct string source); + void (*propagate_set_channel)(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); void (*propagate_join_channel)(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users); void (*propagate_part_channel)(struct string from, struct channel_info *channel, struct user_info *user, struct string reason); @@ -70,6 +72,8 @@ struct protocol { void (*handle_kill_user)(struct string from, struct string source, struct user_info *info, struct string reason); int (*handle_oper_user)(struct string from, struct user_info *info, struct string type, struct string reason); + int (*handle_set_account)(struct string from, struct user_info *info, struct string account, struct string source); + int (*handle_set_channel)(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); int (*handle_join_channel)(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users, char propagate); void (*handle_part_channel)(struct string from, struct channel_info *channel, struct user_info *user, struct string reason); @@ -83,6 +87,8 @@ struct protocol { void (*fail_rename_user)(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str); void (*fail_oper_user)(struct string from, struct user_info *info, struct string type, struct string source); + void (*fail_set_account)(struct string from, struct user_info *info, struct string account, struct string source); + void (*fail_set_channel)(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); void (*fail_join_channel)(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users, char propagate); // ^^^^ @@ -103,6 +109,8 @@ void protocols_propagate_remove_user(struct string from, struct user_info *info, void protocols_propagate_kill_user(struct string from, struct string source, struct user_info *info, struct string reason); void protocols_propagate_oper_user(struct string from, struct user_info *info, struct string type, struct string source); +void protocols_propagate_set_account(struct string from, struct user_info *info, struct string account, struct string source); + void protocols_propagate_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); void protocols_propagate_join_channel(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users, char propagate); void protocols_propagate_part_channel(struct string from, struct channel_info *channel, struct user_info *user, struct string reason); @@ -120,6 +128,8 @@ void protocols_handle_remove_user(struct string from, struct user_info *info, st void protocols_handle_kill_user(struct string from, struct string source, struct user_info *info, struct string reason); int protocols_handle_oper_user(struct string from, struct user_info *info, struct string type, struct string source); +int protocols_handle_set_account(struct string from, struct user_info *info, struct string account, struct string source); + int protocols_handle_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); int protocols_handle_join_channel(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users, char propagate); void protocols_handle_part_channel(struct string from, struct channel_info *channel, struct user_info *user, struct string reason); @@ -131,6 +141,8 @@ void protocols_fail_new_user(struct string from, struct user_info *info); void protocols_fail_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str); void protocols_fail_oper_user(struct string from, struct user_info *info, struct string type, struct string source); +void protocols_fail_set_account(struct string from, struct user_info *info, struct string account, struct string source); + void protocols_fail_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); void protocols_fail_join_channel(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users, char propagate); diff --git a/protocols/inspircd2.c b/protocols/inspircd2.c index 5a017af..17dc726 100644 --- a/protocols/inspircd2.c +++ b/protocols/inspircd2.c @@ -151,6 +151,8 @@ int init_inspircd2_protocol(void) { set_table_index(&inspircd2_protocol_commands, STRING("MODE"), &inspircd2_protocol_handle_mode); set_table_index(&inspircd2_protocol_commands, STRING("FMODE"), &inspircd2_protocol_handle_fmode); + set_table_index(&inspircd2_protocol_commands, STRING("METADATA"), &inspircd2_protocol_handle_metadata); + set_table_index(&inspircd2_protocol_commands, STRING("DUMP"), &inspircd2_protocol_handle_dump); return 0; @@ -684,6 +686,17 @@ void inspircd2_protocol_propagate_oper_user(struct string from, struct user_info } } +// [:source] METADATA <user> accountname <account> +void inspircd2_protocol_propagate_set_account(struct string from, struct user_info *user, struct string account, struct string source) { + inspircd2_protocol_propagate(from, STRING(":")); + inspircd2_protocol_propagate(from, source); + inspircd2_protocol_propagate(from, STRING(" METADATA ")); + inspircd2_protocol_propagate(from, user->uid); + inspircd2_protocol_propagate(from, STRING(" accountname :")); + inspircd2_protocol_propagate(from, account); + inspircd2_protocol_propagate(from, STRING("\n")); +} + // [:source] FJOIN <channel> <timestamp> <modes> [<mode args>] <userlist: modes,uid [...]> 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) { inspircd2_protocol_propagate(from, STRING(":")); @@ -848,6 +861,10 @@ int inspircd2_protocol_handle_oper_user(struct string from, struct user_info *in return 0; } +int inspircd2_protocol_handle_set_account(struct string from, struct user_info *info, struct string account, struct string source) { + return 0; +} + int inspircd2_protocol_handle_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users) { return 0; } @@ -880,6 +897,10 @@ void inspircd2_protocol_fail_oper_user(struct string from, struct user_info *inf return; } +void inspircd2_protocol_fail_set_account(struct string from, struct user_info *info, struct string account, struct string source) { + return; +} + void inspircd2_protocol_fail_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users) { return; } @@ -1788,6 +1809,30 @@ int inspircd2_protocol_handle_fmode(struct string source, size_t argc, struct st return 0; } +// [:source] METADATA <target> <key> <value> +int inspircd2_protocol_handle_metadata(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming) { + if (argc < 3) { + WRITES(2, STRING("[InspIRCd v2] Invalid METADATA received! (Missing parameters)\r\n")); + return -1; + } + + struct user_info *info; + do { + info = get_table_index(user_list, argv[0]); + if (info) + break; + + return 0; + } while (0); + + if (STRING_EQ(argv[1], STRING("accountname"))) { + if (set_account(config->sid, info, argv[2], source) != 0) + return -1; + } + + return 0; +} + int inspircd2_protocol_handle_dump(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming) { for (size_t arg = 0; arg < argc; arg++) { if (STRING_EQ(argv[arg], STRING("LATENCIES"))) { diff --git a/protocols/inspircd2.h b/protocols/inspircd2.h index dc8ff32..b8e7cda 100644 --- a/protocols/inspircd2.h +++ b/protocols/inspircd2.h @@ -54,6 +54,8 @@ void inspircd2_protocol_propagate_remove_user(struct string from, struct user_in 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); +void inspircd2_protocol_propagate_set_account(struct string from, struct user_info *info, struct string account, struct string source); + 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); void inspircd2_protocol_propagate_part_channel(struct string from, struct channel_info *channel, struct user_info *user, struct string reason); @@ -71,6 +73,8 @@ void inspircd2_protocol_handle_remove_user(struct string from, struct user_info 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); +int inspircd2_protocol_handle_set_account(struct string from, struct user_info *info, struct string account, struct string source); + int inspircd2_protocol_handle_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); int inspircd2_protocol_handle_join_channel(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users, char propagate); void inspircd2_protocol_handle_part_channel(struct string from, struct channel_info *channel, struct user_info *user, struct string reason); @@ -82,6 +86,8 @@ 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_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); + void inspircd2_protocol_fail_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); void inspircd2_protocol_fail_join_channel(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users, char propagate); @@ -117,6 +123,8 @@ int inspircd2_protocol_handle_notice(struct string source, size_t argc, struct s int inspircd2_protocol_handle_mode(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_fmode(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_metadata(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_dump(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming); extern char inspircd2_protocol_user_mode_types[UCHAR_MAX+1]; diff --git a/protocols/inspircd3.h b/protocols/inspircd3.h index 86339c2..daea5e0 100644 --- a/protocols/inspircd3.h +++ b/protocols/inspircd3.h @@ -63,6 +63,8 @@ void inspircd3_protocol_propagate_remove_user(struct string from, struct user_in void inspircd3_protocol_propagate_kill_user(struct string from, struct string source, struct user_info *info, struct string reason); void inspircd3_protocol_propagate_oper_user(struct string from, struct user_info *info, struct string type, struct string source); +void inspircd3_protocol_propagate_set_account(struct string from, struct user_info *info, struct string account); + void inspircd3_protocol_propagate_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); void inspircd3_protocol_propagate_join_channel(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users); void inspircd3_protocol_propagate_part_channel(struct string from, struct channel_info *channel, struct user_info *user, struct string reason); @@ -80,6 +82,8 @@ void inspircd3_protocol_handle_remove_user(struct string from, struct user_info void inspircd3_protocol_handle_kill_user(struct string from, struct string source, struct user_info *info, struct string reason); int inspircd3_protocol_handle_oper_user(struct string from, struct user_info *info, struct string type, struct string source); +int inspircd3_protocol_handle_set_account(struct string from, struct user_info *info, struct string account); + int inspircd3_protocol_handle_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); int inspircd3_protocol_handle_join_channel(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users, char propagate); void inspircd3_protocol_handle_part_channel(struct string from, struct channel_info *channel, struct user_info *user, struct string reason); @@ -91,6 +95,8 @@ void inspircd3_protocol_fail_new_user(struct string from, struct user_info *info void inspircd3_protocol_fail_rename_user(struct string from, struct user_info *info, struct string nick, size_t timestamp, struct string timestamp_str); void inspircd3_protocol_fail_oper_user(struct string from, struct user_info *info, struct string type, struct string source); +void inspircd3_protocol_fail_set_account(struct string from, struct user_info *info, struct string account); + void inspircd3_protocol_fail_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); void inspircd3_protocol_fail_join_channel(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users, char propagate); diff --git a/pseudoclients.c b/pseudoclients.c index b65a96d..8234180 100644 --- a/pseudoclients.c +++ b/pseudoclients.c @@ -52,6 +52,21 @@ int init_pseudoclients(void) { return 1; } #endif +#ifdef USE_SERVICES_PSEUDOCLIENT + { + void *dl_handle = dlopen("pseudoclients/services.so", RTLD_NOW | RTLD_LOCAL); + if (!dl_handle) { + puts(dlerror()); + return 1; + } + + pseudoclients[SERVICES_PSEUDOCLIENT].dl_handle = dl_handle; + pseudoclients[SERVICES_PSEUDOCLIENT].init = dlsym(dl_handle, "services_pseudoclient_init"); + + if (pseudoclients[SERVICES_PSEUDOCLIENT].init() != 0) + return 1; + } +#endif return 0; } diff --git a/pseudoclients.h b/pseudoclients.h index 050c1a0..78bf8c0 100644 --- a/pseudoclients.h +++ b/pseudoclients.h @@ -48,9 +48,14 @@ int init_pseudoclients(void); #ifdef USE_HAXSERV_PSEUDOCLIENT #define HAXSERV_PSEUDOCLIENT 0 #endif +#ifdef USE_SERVICES_PSEUDOCLIENT +#define SERVICES_PSEUDOCLIENT 1 +#endif -#define NUM_PSEUDOCLIENTS 1 +#define NUM_PSEUDOCLIENTS 2 extern struct pseudoclient pseudoclients[NUM_PSEUDOCLIENTS]; extern char reload_pseudoclients[NUM_PSEUDOCLIENTS]; + +void pseudoclients_handle_privmsg(struct string from, struct string source, struct string target, struct string msg); diff --git a/pseudoclients/services.c b/pseudoclients/services.c new file mode 100644 index 0000000..8fadca4 --- /dev/null +++ b/pseudoclients/services.c @@ -0,0 +1,83 @@ +// Written by: Test_User <hax@andrewyu.org> +// +// This is free and unencumbered software released into the public +// domain. +// +// Anyone is free to copy, modify, publish, use, compile, sell, or +// distribute this software, either in source code form or as a compiled +// binary, for any purpose, commercial or non-commercial, and by any +// means. +// +// In jurisdictions that recognize copyright laws, the author or authors +// of this software dedicate any and all copyright interest in the +// software to the public domain. We make this dedication for the benefit +// of the public at large and to the detriment of our heirs and +// successors. We intend this dedication to be an overt act of +// relinquishment in perpetuity of all present and future rights to this +// software under copyright law. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#include "../config.h" +#include "../haxstring.h" +#include "../general_network.h" +#include "../pseudoclients.h" +#include "services.h" + +int services_pseudoclient_init(void) { + return services_pseudoclient_post_reload(); +} + +int services_pseudoclient_post_reload(void) { + size_t now; + { + time_t tmp = time(0); + if (tmp < 0) { + WRITES(2, STRING("Please check your clock.\r\n")); + return 1; + } + + now = (size_t)tmp; + } + + if (!has_table_index(user_list, NICKSERV_UID)) { + if (add_user(SID, SID, NICKSERV_UID, NICKSERV_NICK, NICKSERV_FULLNAME, NICKSERV_IDENT, NICKSERV_VHOST, NICKSERV_HOST, NICKSERV_ADDRESS, now, now, 0, 0, 0, 1, SERVICES_PSEUDOCLIENT) != 0) + return 1; + struct user_info *user = get_table_index(user_list, NICKSERV_UID); + if (set_channel(SID, SERVICES_CHANNEL, now, 1, &user) != 0) + return 1; + } + + pseudoclients[SERVICES_PSEUDOCLIENT].init = services_pseudoclient_init; + + pseudoclients[SERVICES_PSEUDOCLIENT].post_reload = services_pseudoclient_post_reload; + pseudoclients[SERVICES_PSEUDOCLIENT].pre_reload = services_pseudoclient_pre_reload; + + pseudoclients[SERVICES_PSEUDOCLIENT].allow_kill = services_pseudoclient_allow_kill; + pseudoclients[SERVICES_PSEUDOCLIENT].allow_kick = services_pseudoclient_allow_kick; + + pseudoclients[SERVICES_PSEUDOCLIENT].handle_privmsg = services_pseudoclient_handle_privmsg; + + return 0; +} + +int services_pseudoclient_pre_reload(void) { + return 0; +} + +int services_pseudoclient_allow_kill(struct string from, struct string source, struct user_info *user, struct string reason) { + return 0; +} + +int services_pseudoclient_allow_kick(struct string from, struct string source, struct channel_info *channel, struct user_info *user, struct string reason) { + return 0; +} + +void services_pseudoclient_handle_privmsg(struct string from, struct string source, struct string target, struct string msg) { +} diff --git a/pseudoclients/services.h b/pseudoclients/services.h new file mode 100644 index 0000000..10317d7 --- /dev/null +++ b/pseudoclients/services.h @@ -0,0 +1,48 @@ +// Written by: Test_User <hax@andrewyu.org> +// +// This is free and unencumbered software released into the public +// domain. +// +// Anyone is free to copy, modify, publish, use, compile, sell, or +// distribute this software, either in source code form or as a compiled +// binary, for any purpose, commercial or non-commercial, and by any +// means. +// +// In jurisdictions that recognize copyright laws, the author or authors +// of this software dedicate any and all copyright interest in the +// software to the public domain. We make this dedication for the benefit +// of the public at large and to the detriment of our heirs and +// successors. We intend this dedication to be an overt act of +// relinquishment in perpetuity of all present and future rights to this +// software under copyright law. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once + +#include "../haxstring.h" +#include "../general_network.h" + +struct command_def { + int (*func)(struct string from, struct string sender, struct string original_message, struct string respond_to, size_t argc, struct string *argv); + struct string privs; + struct string summary; + struct string aligned_name; + struct string name; +}; + +int services_pseudoclient_init(void); + +int services_pseudoclient_post_reload(void); +int services_pseudoclient_pre_reload(void); + +int services_pseudoclient_allow_kill(struct string from, struct string source, struct user_info *user, struct string reason); +int services_pseudoclient_allow_kick(struct string from, struct string source, struct channel_info *channel, struct user_info *user, struct string reason); + +void services_pseudoclient_handle_privmsg(struct string from, struct string source, struct string target, struct string msg); |