[srvx-commits] CVS: services/src proto_ircu_p10.c,1.14,1.15 proto_bahamut.h,1.2,1.3 proto_bahamut.c,
Brought to you by:
entrope
From: Entrope <en...@us...> - 2001-08-11 02:33:34
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv5103/src Modified Files: proto_ircu_p10.c proto_bahamut.h proto_bahamut.c log.c hash.h hash.c Log Message: let's burst nicks to bahamut, at least :) Index: proto_ircu_p10.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_ircu_p10.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** proto_ircu_p10.c 2001/08/08 15:45:50 1.14 --- proto_ircu_p10.c 2001/08/11 02:33:31 1.15 *************** *** 329,336 **** /* we don't need to put the + in modes because it's in the format string. */ ! putsock("%s %s %s %d %li %s %s +%s %s %s :%s", user->uplink->proto.numeric, CMD_NICK, user->nick, user->uplink->hops+1, user->timestamp, user->username, user->hostname, modes, b64ip, user->proto.numeric, user->info); } else { ! putsock("%s %s %s %d %li %s %s %s %s :%s", user->uplink->proto.numeric, CMD_NICK, user->nick, user->uplink->hops+1, user->timestamp, user->username, user->hostname, b64ip, user->proto.numeric, user->info); } --- 329,336 ---- /* we don't need to put the + in modes because it's in the format string. */ ! putsock("%s %s %s %d "FMT_TIME_T" %s %s +%s %s %s :%s", user->uplink->proto.numeric, CMD_NICK, user->nick, user->uplink->hops+1, user->timestamp, user->username, user->hostname, modes, b64ip, user->proto.numeric, user->info); } else { ! putsock("%s %s %s %d "FMT_TIME_T" %s %s %s %s :%s", user->uplink->proto.numeric, CMD_NICK, user->nick, user->uplink->hops+1, user->timestamp, user->username, user->hostname, b64ip, user->proto.numeric, user->info); } Index: proto_bahamut.h =================================================================== RCS file: /cvsroot/srvx/services/src/proto_bahamut.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** proto_bahamut.h 2001/08/09 12:41:40 1.2 --- proto_bahamut.h 2001/08/11 02:33:31 1.3 *************** *** 22,25 **** --- 22,27 ---- #define PROTO_BAHAMUT_H + #include "dict.h" + #define SERVER_NUMERIC_LEN 1 #define USER_NUMERIC_LEN 2 *************** *** 38,41 **** --- 40,44 ---- struct serverNode_proto { + dict_t clients; }; Index: proto_bahamut.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto_bahamut.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** proto_bahamut.c 2001/08/09 12:41:40 1.4 --- proto_bahamut.c 2001/08/11 02:33:31 1.5 *************** *** 214,238 **** irc_user(struct userNode *user) { ! char b64ip[7]; ! if (user->modes) { ! int modelen = 0; ! char modes[9]; ! if (IsOper(user)) modes[modelen++] = 'o'; ! if (IsInvisible(user)) modes[modelen++] = 'i'; ! if (IsWallOp(user)) modes[modelen++] = 'w'; ! if (IsService(user)) modes[modelen++] = 'k'; ! if (IsServNotice(user)) modes[modelen++] = 's'; ! if (IsDeaf(user)) modes[modelen++] = 'd'; ! if (IsGlobal(user)) modes[modelen++] = 'g'; ! if (IsHelper(user)) modes[modelen++] = 'h'; ! modes[modelen] = 0; ! ! /* we don't need to put the + in modes because it's in the format string. */ ! putsock("%s %s %s %d %li %s %s +%s %s :%s", ! user->uplink->name, CMD_NICK, user->nick, user->uplink->hops+1, user->timestamp, user->username, user->hostname, modes, b64ip, user->info); ! } else { ! putsock("%s %s %s %d %li %s %s %s :%s", ! user->uplink->name, CMD_NICK, user->nick, user->uplink->hops+1, user->timestamp, user->username, user->hostname, b64ip, user->info); ! } } --- 214,235 ---- irc_user(struct userNode *user) { ! int modelen; ! char modes[9]; ! ! modelen = 0; ! if (IsOper(user)) modes[modelen++] = 'o'; ! if (IsInvisible(user)) modes[modelen++] = 'i'; ! if (IsWallOp(user)) modes[modelen++] = 'w'; ! if (IsService(user)) modes[modelen++] = 'k'; ! if (IsServNotice(user)) modes[modelen++] = 's'; ! if (IsDeaf(user)) modes[modelen++] = 'd'; ! if (IsGlobal(user)) modes[modelen++] = 'g'; ! if (IsHelper(user)) modes[modelen++] = 'h'; ! modes[modelen] = 0; ! ! /* we don't need to put the + in modes because it is in this format string. */ ! putsock("%s %s %d "FMT_TIME_T" +%s %s %s %s %lu :%s", ! CMD_NICK, user->nick, user->uplink->hops+1, user->timestamp, modes, ! user->username, user->hostname, user->uplink->name, user->ip, user->info); } *************** *** 486,501 **** static void ! send_burst(void) { ! /* burst servers, closest first (don't need to burst this ! * server, it was introduced during link authentication) ! */ ! /* TODO */ ! /* burst local nicks */ ! /* TODO */ ! /* burst channels */ ! /* TODO */ } --- 483,552 ---- static void ! bahamut_new_server(struct server *server) { ! server->proto.clients = dict_new(); ! } ! ! static int ! bahamut_del_server_client(const char *key, void *data, void *extra) ! { ! struct userNode *user = data; ! (void)key; (void)extra; ! printf("in bahamut_del_server_client(\"%s\", ....)\n", key); ! DelUser(user, NULL, false, "Server delinked"); ! return 0; ! } ! ! static void ! bahamut_del_server(struct server *server) ! { ! printf("in bahamut_del_server(\"%s\")\n", server->name); ! dict_foreach(server->proto.clients, bahamut_del_server_client, NULL); ! dict_delete(server->proto.clients); ! } ! ! static int ! bahamut_new_user(struct userNode *user) ! { ! dict_insert(user->uplink->proto.clients, user->nick, user); ! return 0; ! } ! ! static void ! bahamut_del_user(struct userNode *user) ! { ! dict_remove(user->uplink->proto.clients, user->nick); ! } ! ! static int ! burst_send_nick(const char *key, void *data, void *extra) ! { ! struct userNode *user = data; ! (void)key; (void)extra; ! irc_user(user); ! return 0; ! } ! ! static int ! burst_send_channel(const char *key, void *data, void *extra) ! { ! (void)key; (void)data; (void)extra; ! /* TODO */ ! return 0; ! } ! ! static void ! burst_send(void) ! { ! /* burst servers, closest first (we do not need to burst this ! * server; it was introduced during link authentication) ! */ ! /* TODO */ ! /* burst local nicks */ ! dict_foreach(self->proto.clients, burst_send_nick, 0); ! /* burst channels */ ! dict_foreach(channels, burst_send_channel, 0); } *************** *** 597,601 **** if (uplink_check_password(argv[1])) { uplink_set_state(BURSTING); ! send_burst(); } else { /* It might be good to mark the uplink as unavailable when --- 648,652 ---- if (uplink_check_password(argv[1])) { uplink_set_state(BURSTING); ! burst_send(); } else { /* It might be good to mark the uplink as unavailable when *************** *** 661,665 **** } ! /* NICK <nick> <hops> <timestamp> <modes> <username> <hostname> <server> <?> :<Clientinfo> */ static CMD_FUNC(cmd_nick) { --- 712,716 ---- } ! /* NICK <nick> <hops> <timestamp> <modes> <username> <hostname> <server> <ip> :<Clientinfo> */ static CMD_FUNC(cmd_nick) { *************** *** 678,681 **** --- 729,733 ---- } user = AddUser(uplink, argv[1], argv[5], argv[6], argv[4], argv[9], atoi(argv[3])); + if (user) user->ip = atoi(argv[8]); return 1; } *************** *** 854,857 **** --- 906,947 ---- } + static CMD_FUNC(cmd_pong) + { + void received_ping(void); + if (argc < 3) return 0; + if (!strcasecmp(argv[1], self->name) && !strcasecmp(argv[2], self->uplink->name)) { + timeq_del(0, timed_send_ping, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); + timeq_del(0, timed_ping_timeout, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); + timeq_add(now + ping_freq, timed_send_ping, 0); + received_ping(); + } + return 1; + } + + static CMD_FUNC(cmd_quit) + { + struct userNode *user; + if (argc < 2) return 0; + user = GetUser(argv[-1]); + /* Sometimes we get a KILL then a QUIT or the like, so we don't want to + * call DelUser unless we have the user in our grasp. */ + if (user) DelUser(user, NULL, false, argv[1]); + return 1; + } + + static CMD_FUNC(cmd_privmsg) + { + struct privmsg_desc pd; + if (argc != 3) return 0; + pd.user = GetUser(argv[-1]); + /* The gag flag is never applied to userNodes it does not belong on, + so no worries. */ + if (IsGagged(pd.user)) return 1; + pd.is_notice = 0; + pd.text = argv[2]; + parse_foreach(argv[1], privmsg_chan_helper, NULL, privmsg_user_helper, NULL, &pd); + return 1; + } + /* Not-yet-ported functions live below here. */ *************** *** 948,965 **** } - static CMD_FUNC(cmd_pong) - { - void received_ping(void); - if (argc < 4) return 0; - if (!strcmp(argv[3], self->name)) { - timeq_del(0, timed_send_ping, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); - timeq_del(0, timed_ping_timeout, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); - timeq_add(now + ping_freq, timed_send_ping, 0); - - received_ping(); - } - return 1; - } - static struct userNode * bahamut_add_user(struct server *uplink, const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp) --- 1038,1041 ---- *************** *** 969,972 **** --- 1045,1050 ---- uNode = AddUser(uplink, nick, ident, hostname, modes, userinfo, timestamp); if (uNode) { + /* This doesn't get called by AddUser if uplink == self */ + bahamut_new_user(uNode); if (uplink == self) irc_user(uNode); } else { *************** *** 1021,1038 **** } - static CMD_FUNC(cmd_quit) - { - struct userNode *user; - if (argc < 3) return 0; - user = GetUser(argv[0]); - /* Sometimes we get a KILL then a QUIT or the like, so we don't want to - * call DelUser unless we have the user in our grasp. - */ - if (user) { - DelUser(user, NULL, false, argv[2]); - } - return 1; - } - static CMD_FUNC(cmd_kill) { --- 1099,1102 ---- *************** *** 1132,1149 **** } - static CMD_FUNC(cmd_privmsg) - { - struct privmsg_desc pd; - if (argc != 4) return 0; - pd.user = GetUser(argv[0]); - /* The gag flag is never applied to userNodes it does not belong on, - so no worries. */ - if (IsGagged(pd.user)) return 1; - pd.is_notice = 0; - pd.text = argv[3]; - parse_foreach(argv[2], privmsg_chan_helper, NULL, privmsg_user_helper, NULL, &pd); - return 1; - } - static CMD_FUNC(cmd_away) { --- 1196,1199 ---- *************** *** 1190,1196 **** extern time_t boot_time; - /* create self server */ - self = AddServer(NULL, conf_server_name(), 0, boot_time, now, conf_server_desc()); - /* set up command dictionary */ irc_func_dict = dict_new(); --- 1240,1243 ---- *************** *** 1246,1251 **** memset(notice_funcs, 0, sizeof(privmsg_func_t)*num_notice_funcs); ! /* register exit functions */ reg_exit_func(free_parse_misc); }; --- 1293,1305 ---- memset(notice_funcs, 0, sizeof(privmsg_func_t)*num_notice_funcs); ! /* register callbacks to us */ ! reg_new_server_func(bahamut_new_server); ! reg_del_server_func(bahamut_del_server); ! reg_new_user_func(bahamut_new_user); ! reg_del_user_func(bahamut_del_user); reg_exit_func(free_parse_misc); + + /* create self server */ + self = AddServer(NULL, conf_server_name(), 0, boot_time, now, conf_server_desc()); }; Index: log.c =================================================================== RCS file: /cvsroot/srvx/services/src/log.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** log.c 2001/08/01 22:14:35 1.33 --- log.c 2001/08/11 02:33:31 1.34 *************** *** 151,157 **** } fputs(sev, logs[lt].file); - #ifdef DEBUG fflush(logs[lt].file); - #endif va_start(arg_list, text); --- 151,155 ---- Index: hash.h =================================================================== RCS file: /cvsroot/srvx/services/src/hash.h,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -r1.64 -r1.65 *** hash.h 2001/07/15 16:23:29 1.64 --- hash.h 2001/08/11 02:33:31 1.65 *************** *** 159,168 **** extern struct userList curr_opers, curr_helpers; ! struct server *GetServer(const char *name); /* using name */ ! struct userNode *GetUser(const char *nick); /* using nick */ struct chanNode *GetChannel(const char *name); struct modeNode *GetUserMode(struct chanNode *channel, struct userNode *user); typedef void (*server_link_func_t) (struct server *server); void reg_server_link_func(server_link_func_t handler); --- 159,169 ---- extern struct userList curr_opers, curr_helpers; ! struct server *GetServer(const char *name); ! struct userNode *GetUser(const char *nick); struct chanNode *GetChannel(const char *name); struct modeNode *GetUserMode(struct chanNode *channel, struct userNode *user); typedef void (*server_link_func_t) (struct server *server); + void reg_new_server_func(server_link_func_t handler); void reg_server_link_func(server_link_func_t handler); Index: hash.c =================================================================== RCS file: /cvsroot/srvx/services/src/hash.c,v retrieving revision 1.139 retrieving revision 1.140 diff -C2 -r1.139 -r1.140 *** hash.c 2001/08/01 22:14:35 1.139 --- hash.c 2001/08/11 02:33:31 1.140 *************** *** 74,77 **** --- 74,95 ---- } + static server_link_func_t *ns_list; + static unsigned int ns_size, ns_used; + + void + reg_new_server_func(server_link_func_t handler) + { + if (ns_used == ns_size) { + if (ns_size) { + ns_size <<= 1; + ns_list = realloc(ns_list, ns_size*sizeof(server_link_func_t)); + } else { + ns_size = 8; + ns_list = malloc(ns_size*sizeof(server_link_func_t)); + } + } + ns_list[ns_used++] = handler; + } + static server_link_func_t *slf_list; static unsigned int slf_size, slf_used; *************** *** 96,99 **** --- 114,118 ---- { struct server* sNode; + unsigned int nn; sNode = malloc(sizeof(*sNode)); *************** *** 108,111 **** --- 127,131 ---- serverList_init(&sNode->children); safestrncpy(sNode->description, description, sizeof(sNode->description)); + if (!self) { /* We don't exist yet, so this must be us. *************** *** 124,135 **** sNode->in_burst = 1; } if (uplink) { serverList_append(&uplink->children, sNode); } if (hops && !self->uplink->in_burst) { ! unsigned int n; ! for (n=0; n<slf_used; n++) { ! slf_list[n](sNode); } } --- 144,159 ---- sNode->in_burst = 1; } + if (uplink) { serverList_append(&uplink->children, sNode); } + for (nn=0; nn<ns_used; nn++) { + ns_list[nn](sNode); + } + if (hops && !self->uplink->in_burst) { ! for (nn=0; nn<slf_used; nn++) { ! slf_list[nn](sNode); } } *************** *** 199,203 **** AddService(const char *nick, const char *desc) { ! return add_local_user(nick, nick, self->name, "+oik", desc, 0); } --- 223,227 ---- AddService(const char *nick, const char *desc) { ! return add_local_user(nick, nick, self->name, "+oik", desc, now); } |