/* * m_time * parv[1] = servername */ static int m_time(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { /* this is not rate limited, so end the grace period */ if(MyClient(source_p) && !IsFloodDone(source_p)) flood_endgrace(source_p); if(hunt_server(client_p, source_p, ":%s TIME :%s", 1, parc, parv) == HUNTED_ISME) sendto_one_numeric(source_p, RPL_TIME, form_str(RPL_TIME), me.name, date()); return 0; }
/* * mo_version - VERSION command handler * parv[1] = remote server */ static int mo_version(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { if(hunt_server(client_p, source_p, ":%s VERSION :%s", 1, parc, parv) == HUNTED_ISME) { sendto_one_numeric(source_p, RPL_VERSION, form_str(RPL_VERSION), ircd_version, serno, me.name, confopts(source_p), TS_CURRENT, ServerInfo.sid); show_isupport(source_p); } return 0; }
/* * mo_version - VERSION command handler * parv[0] = sender prefix * parv[1] = remote server */ static void mo_version(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { if (hunt_server(client_p, source_p, ":%s VERSION :%s", 1, parc, parv) != HUNTED_ISME) return; sendto_one(source_p, form_str(RPL_VERSION), me.name, parv[0], ircd_version, serno, me.name, confopts(source_p), serveropts); show_isupport(source_p); }
/* ** mo_motd ** parv[0] = sender prefix ** parv[1] = servername */ static void mo_motd(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { if (!IsClient(source_p)) return; if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1,parc,parv)!=HUNTED_ISME) return; motd_spy(source_p); send_message_file(source_p,&ConfigFileEntry.motd); }
/* * ms_lusers - LUSERS message handler for servers and opers * parv[0] = sender * parv[1] = host/server mask. * parv[2] = server to query * * 199970918 JRL hacked to ignore parv[1] completely and require parc > 3 * to cause a force */ static int ms_lusers(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { if(parc > 2) { if(hunt_server(client_p, source_p, ":%s LUSERS %s :%s", 2, parc, parv) != HUNTED_ISME) return 0; } show_lusers(source_p); return 0; }
/* ms_lusers - LUSERS message handler for servers and opers * parv[0] = sender * parv[1] = host/server mask. * parv[2] = server to query */ static void ms_lusers(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { if (parc > 2) { if(hunt_server(client_p, source_p, ":%s LUSERS %s :%s", 2, parc, parv) != HUNTED_ISME) return; } if (IsClient(source_p)) show_lusers(source_p); }
/*! \brief TIME command handler * * \param source_p Pointer to allocated Client struct from which the message * originally comes from. This can be a local or remote client. * \param parc Integer holding the number of supplied arguments. * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL * pointers. * \note Valid arguments for this command are: * - parv[0] = command * - parv[1] = nickname/servername */ static int m_time(struct Client *source_p, int parc, char *parv[]) { /* This is not rate limited, so end the grace period */ if (!IsFloodDone(source_p)) flood_endgrace(source_p); /* This is safe enough to use during non hidden server mode */ if (!ConfigServerHide.disable_remote_commands) if (hunt_server(source_p, ":%s TIME :%s", 1, parc, parv) != HUNTED_ISME) return 0; sendto_one_numeric(source_p, &me, RPL_TIME, me.name, date(0)); return 0; }
/*! \brief WHOWAS command handler * * \param source_p Pointer to allocated Client struct from which the message * originally comes from. This can be a local or remote client. * \param parc Integer holding the number of supplied arguments. * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL * pointers. * \note Valid arguments for this command are: * - parv[0] = command * - parv[1] = nickname * - parv[2] = count * - parv[3] = nickname/servername */ static int ms_whowas(struct Client *source_p, int parc, char *parv[]) { if (parc < 2 || EmptyString(parv[1])) { sendto_one_numeric(source_p, &me, ERR_NONICKNAMEGIVEN); return 0; } if (hunt_server(source_p, ":%s WHOWAS %s %s :%s", 3, parc, parv) != HUNTED_ISME) return 0; do_whowas(source_p, parc, parv); return 0; }
/* * mo_users * parv[0] = sender prefix * parv[1] = servername */ static void mo_users(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { if(hunt_server(client_p, source_p, ":%s USERS :%s", 1, parc, parv) == HUNTED_ISME) { if(!IsOper(source_p) && ConfigServerHide.hide_servers) sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, parv[0], Count.total, Count.max_tot); else sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, parv[0], Count.local, Count.max_loc); sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, parv[0], Count.total, Count.max_tot); } }
/* ** mo_info() ** parv[0] = sender prefix ** parv[1] = servername */ static void mo_info(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { if (hunt_server(client_p, source_p, ":%s INFO :%s", 1, parc, parv) == HUNTED_ISME) { info_spy(source_p); send_info_text(source_p); send_conf_options(source_p); send_birthdate_online_time(source_p); sendto_one(source_p, form_str(RPL_ENDOFINFO), me.name, source_p->name); } }
/* * m_time * parv[0] = sender prefix * parv[1] = servername */ static int m_time(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { /* this is not rate limited, so end the grace period */ char buf[80]; if (MyClient(source_p) && !IsFloodDone(source_p)) flood_endgrace(source_p); if (hunt_server(client_p, source_p, ":%s TIME :%s", 1, parc, parv) == HUNTED_ISME) { sendto_one_numeric(source_p, RPL_TIME, form_str(RPL_TIME), me.name, rb_date(rb_current_time(), buf, sizeof(buf))); } return 0; }
/* * m_users * parv[0] = sender prefix * parv[1] = servername */ static void m_users(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { if(!ConfigServerHide.disable_remote) { if(hunt_server(client_p, source_p, ":%s USERS :%s", 1, parc, parv) != HUNTED_ISME) return; } sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, parv[0], ConfigServerHide.hide_servers ? Count.total : Count.local, ConfigServerHide.hide_servers ? Count.max_tot : Count.max_loc); sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, parv[0], Count.total, Count.max_tot); }
/* * Heavily modified from the ircu m_motd by codemastr * Also svsmotd support added */ DLLFUNC CMD_FUNC(m_rules) { ConfigItem_tld *ptr; aMotdLine *temp; char userhost[USERLEN + HOSTLEN + 6]; temp = NULL; if (IsServer(sptr)) return 0; if (hunt_server(cptr, sptr, ":%s RULES :%s", 1, parc, parv) != HUNTED_ISME) return 0; #ifndef TLINE_Remote if (!MyConnect(sptr)) { temp = rules.lines; goto playrules; } #endif strlcpy(userhost,make_user_host(cptr->user->username, cptr->user->realhost), sizeof userhost); ptr = Find_tld(sptr, userhost); if (ptr) temp = ptr->rules.lines; if(!temp) temp = rules.lines; playrules: if (temp == NULL) { sendto_one(sptr, err_str(ERR_NORULES), me.name, parv[0]); return 0; } sendto_one(sptr, rpl_str(RPL_RULESSTART), me.name, parv[0], me.name); while (temp) { sendto_one(sptr, rpl_str(RPL_RULES), me.name, parv[0], temp->line); temp = temp->next; } sendto_one(sptr, rpl_str(RPL_ENDOFRULES), me.name, parv[0]); return 0; }
/* * m_users * parv[0] = sender prefix * parv[1] = servername */ static int m_users(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { if(hunt_server(client_p, source_p, ":%s USERS :%s", 1, parc, parv) == HUNTED_ISME) { sendto_one_numeric(source_p, RPL_LOCALUSERS, form_str(RPL_LOCALUSERS), dlink_list_length(&lclient_list), Count.max_loc); sendto_one_numeric(source_p, RPL_GLOBALUSERS, form_str(RPL_GLOBALUSERS), Count.total, Count.max_tot); } return 0; }
/* * m_time * parv[0] = sender prefix * parv[1] = servername */ static void m_time(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { /* this is not rate limited, so end the grace period */ if(MyClient(source_p) && !IsFloodDone(source_p)) flood_endgrace(source_p); /* This is safe enough to use during non hidden server mode */ if(!ConfigServerHide.disable_remote) { if (hunt_server(client_p,source_p,":%s TIME :%s",1,parc,parv) != HUNTED_ISME) return; } sendto_one(source_p, form_str(RPL_TIME), me.name, parv[0], me.name, date(0)); }
/* ** m_svsnick ** parv[0] = sender ** parv[1] = old nickname ** parv[2] = new nickname ** parv[3] = timestamp */ int m_svsnick(aClient *cptr, aClient *sptr, int parc, char *parv[]) { aClient *acptr; aClient *ocptr; /* Other client */ if (!IsULine(sptr) || parc < 4 || (strlen(parv[2]) > NICKLEN)) return -1; /* This looks like an error anyway -Studded */ if (hunt_server(cptr, sptr, ":%s SVSNICK %s %s :%s", 1, parc, parv) != HUNTED_ISME) return 0; /* Forwarded, done */ if (do_nick_name(parv[2]) == 0) return 0; if (!(acptr = find_person(parv[1], NULL))) return 0; /* User not found, bail out */ if ((ocptr = find_client(parv[2], NULL)) && ocptr != acptr) /* Collision */ { exit_client(acptr, acptr, sptr, "Nickname collision due to Services enforced " "nickname change, your nick was overruled"); return 0; } if (acptr != ocptr) acptr->umodes &= ~UMODE_REGNICK; acptr->lastnick = atol(parv[3]); sendto_common_channels(acptr, ":%s NICK :%s", parv[1], parv[2]); add_history(acptr, 1); sendto_server(NULL, 0, 0, ":%s NICK %s :%ld", parv[1], parv[2], atol(parv[3])); (void)del_from_client_hash_table(acptr->name, acptr); hash_check_watch(acptr, RPL_LOGOFF); sendto_snomask(SNO_NICKCHANGE, "*** Notice -- %s (%s@%s) has been forced to change their nickname to %s", acptr->name, acptr->user->username, acptr->user->realhost, parv[2]); RunHook2(HOOKTYPE_LOCAL_NICKCHANGE, acptr, parv[2]); strlcpy(acptr->name, parv[2], sizeof acptr->name); add_to_client_hash_table(parv[2], acptr); hash_check_watch(acptr, RPL_LOGON); return 0; }
/* * mo_users * parv[0] = sender prefix * parv[1] = servername */ static void mo_users(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { if (hunt_server(client_p, source_p, ":%s USERS :%s", 1, parc, parv) != HUNTED_ISME) return; if (!HasUMode(source_p, UMODE_OPER) && ConfigServerHide.hide_servers) sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name, Count.total, Count.max_tot); else sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name, Count.local, Count.max_loc); sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, source_p->name, Count.total, Count.max_tot); }
/* ** mo_info ** parv[0] = sender prefix ** parv[1] = servername */ static int mo_info(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { if(hunt_server(client_p, source_p, ":%s INFO :%s", 1, parc, parv) == HUNTED_ISME) { info_spy(source_p); send_info_text(source_p); if(IsOper(source_p)) send_conf_options(source_p); send_birthdate_online_time(source_p); sendto_one_numeric(source_p, RPL_ENDOFINFO, form_str(RPL_ENDOFINFO)); } return 0; }
/* ** m_motd ** parv[1] = servername */ static int m_motd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { static time_t last_used = 0; if ((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) { /* safe enough to give this on a local connect only */ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name, "MOTD"); sendto_one(source_p, form_str(RPL_ENDOFMOTD), me.name, source_p->name); return 0; } else last_used = rb_current_time(); if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME) return 0; motd_spy(source_p); send_user_motd(source_p); return 0; }
/*! \brief MOTD command handler * * \param source_p Pointer to allocated Client struct from which the message * originally comes from. This can be a local or remote client. * \param parc Integer holding the number of supplied arguments. * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL * pointers. * \note Valid arguments for this command are: * - parv[0] = command * - parv[1] = nickname/servername */ static int m_motd(struct Client *source_p, int parc, char *parv[]) { static time_t last_used = 0; if ((last_used + ConfigGeneral.pace_wait) > CurrentTime) { sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "MOTD"); return 0; } last_used = CurrentTime; if (!ConfigServerHide.disable_remote_commands) if (hunt_server(source_p, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME) return 0; do_motd(source_p); return 0; }
/* ** m_motd ** parv[0] = sender prefix ** parv[1] = servername */ static void m_motd(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { static time_t last_used = 0; if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) { /* safe enough to give this on a local connect only */ sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,source_p->name); return; } else last_used = CurrentTime; if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1,parc,parv)!=HUNTED_ISME) return; motd_spy(source_p); send_message_file(source_p,&ConfigFileEntry.motd); }
/* * m_admin - ADMIN command handler * parv[1] = servername */ static int m_admin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { static time_t last_used = 0L; if(parc > 1) { if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) { sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name, "ADMIN"); return 0; } else last_used = rb_current_time(); if(hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME) return 0; } do_admin(source_p); return 0; }
/* * m_admin - ADMIN command handler * parv[0] = sender prefix * parv[1] = servername */ static void m_admin(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { static time_t last_used=0L; if((last_used + ConfigFileEntry.pace_wait) > CurrentTime) { sendto_one(source_p,form_str(source_p,RPL_LOAD2HI),me.name,parv[0]); return; } else last_used = CurrentTime; if (!ConfigServerHide.disable_remote) { if (hunt_server(client_p,source_p,":%s ADMIN :%s",1,parc,parv) != HUNTED_ISME) return; } do_admin(source_p); }
/* ** ms_info() ** parv[0] = sender prefix ** parv[1] = servername */ static void ms_info(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { if (!IsClient(source_p)) return; if (hunt_server(client_p, source_p, ":%s INFO :%s", 1, parc, parv) == HUNTED_ISME) { info_spy(source_p); send_info_text(source_p); if (IsOper(source_p)) send_conf_options(source_p); send_birthdate_online_time(source_p); sendto_one(source_p, form_str(RPL_ENDOFINFO), ID_or_name(&me, client_p), ID_or_name(source_p, client_p)); } }
/*! \brief VERSION command handler * * \param source_p Pointer to allocated Client struct from which the message * originally comes from. This can be a local or remote client. * \param parc Integer holding the number of supplied arguments. * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL * pointers. * \note Valid arguments for this command are: * - parv[0] = command * - parv[1] = nickname/servername */ static int m_version(struct Client *source_p, int parc, char *parv[]) { static time_t last_used = 0; if ((last_used + ConfigGeneral.pace_wait_simple) > CurrentTime) { sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "VERSION"); return 0; } last_used = CurrentTime; if (!ConfigServerHide.disable_remote_commands) if (hunt_server(source_p, ":%s VERSION :%s", 1, parc, parv) != HUNTED_ISME) return 0; sendto_one_numeric(source_p, &me, RPL_VERSION, ircd_version, serno, me.name, serveropts); isupport_show(source_p); return 0; }
/* ** m_info ** parv[0] = sender prefix ** parv[1] = servername */ static int m_info(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { static time_t last_used = 0L; static int count; if (!check_limit(source_p, &last_used, &count, "INFO")) { sendto_one_numeric(source_p, RPL_ENDOFINFO, form_str(RPL_ENDOFINFO)); return 0; } if(hunt_server(client_p, source_p, ":%s INFO :%s", 1, parc, parv) != HUNTED_ISME) return 0; info_spy(source_p); SetCork(source_p); send_info_text(source_p); send_birthdate_online_time(source_p); ClearCork(source_p); sendto_one_numeric(source_p, RPL_ENDOFINFO, form_str(RPL_ENDOFINFO)); return 0; }
/* * m_version - VERSION command handler * parv[1] = remote server */ static int m_version(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { static time_t last_used = 0L; if (parc > 1) { if ((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) { /* safe enough to give this on a local connect only */ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name, "VERSION"); return 0; } else last_used = rb_current_time(); if (hunt_server(client_p, source_p, ":%s VERSION :%s", 1, parc, parv) != HUNTED_ISME) return 0; } sendto_one_numeric(source_p, RPL_VERSION, form_str(RPL_VERSION), ircd_version, serno, me.name, confopts(source_p), TS_CURRENT, ServerInfo.sid); show_isupport(source_p); return 0; }
/* * Modified from comstud by codemastr */ DLLFUNC CMD_FUNC(m_botmotd) { aMotdLine *motdline; ConfigItem_tld *tld; char userhost[HOSTLEN + USERLEN + 6]; if (hunt_server(cptr, sptr, ":%s BOTMOTD :%s", 1, parc, parv) != HUNTED_ISME) return 0; if (!IsPerson(sptr)) return 0; strlcpy(userhost, make_user_host(sptr->user->username, sptr->user->realhost), sizeof(userhost)); tld = Find_tld(sptr, userhost); motdline = NULL; if (tld) motdline = tld->botmotd.lines; if (!motdline) motdline = botmotd.lines; if (!motdline) { sendto_one(sptr, ":%s NOTICE %s :BOTMOTD File not found", me.name, sptr->name); return 0; } sendto_one(sptr, ":%s NOTICE %s :- %s Bot Message of the Day - ", me.name, sptr->name, me.name); while (motdline) { sendto_one(sptr, ":%s NOTICE %s :- %s", me.name, sptr->name, motdline->line); motdline = motdline->next; } sendto_one(sptr, ":%s NOTICE %s :End of /BOTMOTD command.", me.name, sptr->name); return 0; }
/* * m_rnotice (send notice to all users on a given server) * parv[0] = sender prefix * parv[1] = target server * parv[2] = message */ int m_rnotice(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) { char* message; struct Client *acptr; /* firs check if user has enough privileges */ if (MyClient(sptr) && !IsAnOper(sptr)) { sendto_one(sptr, form_str(ERR_NOPRIVILEGES), me.name, parv[0]); return(0); } message = parv[2]; /* now check if sufficiente parameters */ if (EmptyString(message) || parc<3 ) { if(MyClient(sptr)) sendto_one(sptr, form_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "RNOTICE"); return 0; } /* check we are the hunted server (send to server if not) */ if(hunt_server (cptr, sptr, ":%s RNOTICE %s :%s", 1, parc, parv) != HUNTED_ISME) return 0; for(acptr = local_cptr_list; acptr; acptr = acptr->next_local_client) { sendto_one(acptr,":%s NOTICE %s :%s", me.name, acptr->name, message); } sendto_ops("RNOTICE sent by \2%s\2",parv[0]); sendto_serv_butone(&me, ":%s GLOBOPS :LNOTICE to %s :%s", sptr->name, parv[1], parv[2]); return 0; }
/* * m_lusers - LUSERS message handler * parv[0] = sender * parv[1] = host/server mask. * parv[2] = server to query * * 199970918 JRL hacked to ignore parv[1] completely and require parc > 3 * to cause a force */ static void m_lusers(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { static time_t last_used = 0; if (parc > 2 && !ConfigServerHide.disable_remote) { if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) { /* safe enough to give this on a local connect only */ sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, parv[0], "LUSERS"); return; } else last_used = CurrentTime; if (hunt_server(client_p, source_p, ":%s LUSERS %s :%s", 2, parc, parv) != HUNTED_ISME) return; } show_lusers(source_p); }