X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/55abcbb20aeabcf2e878a9c65c9697210dd10079..6a0074bfaa195daa621ec6348f2abc2720e65ab0:/modules/m_connect.c diff --git a/modules/m_connect.c b/modules/m_connect.c index 59919052..3f1db4dd 100644 --- a/modules/m_connect.c +++ b/modules/m_connect.c @@ -20,8 +20,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA - * - * $Id: m_connect.c 3161 2007-01-25 07:23:01Z nenolod $ */ #include "stdinc.h" @@ -40,16 +38,20 @@ #include "modules.h" #include "sslproc.h" -static int mo_connect(struct Client *, struct Client *, int, const char **); -static int ms_connect(struct Client *, struct Client *, int, const char **); +static const char connect_desc[] = + "Provides the CONNECT command to introduce servers to the network"; + +static void mo_connect(struct MsgBuf *, struct Client *, struct Client *, int, const char **); +static void ms_connect(struct MsgBuf *, struct Client *, struct Client *, int, const char **); struct Message connect_msgtab = { - "CONNECT", 0, 0, 0, MFLG_SLOW, + "CONNECT", 0, 0, 0, 0, {mg_unreg, mg_not_oper, {ms_connect, 4}, {ms_connect, 4}, mg_ignore, {mo_connect, 2}} }; mapi_clist_av1 connect_clist[] = { &connect_msgtab, NULL }; -DECLARE_MODULE_AV1(connect, NULL, NULL, connect_clist, NULL, NULL, "$Revision: 3161 $"); + +DECLARE_MODULE_AV2(connect, NULL, NULL, connect_clist, NULL, NULL, NULL, NULL, connect_desc); /* * mo_connect - CONNECT command handler @@ -61,8 +63,8 @@ DECLARE_MODULE_AV1(connect, NULL, NULL, connect_clist, NULL, NULL, "$Revision: 3 * parv[2] = port number * parv[3] = remote server */ -static int -mo_connect(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) +static void +mo_connect(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { int port; int tmpport; @@ -75,17 +77,17 @@ mo_connect(struct Client *client_p, struct Client *source_p, int parc, const cha { sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "remote"); - return 0; + return; } if(hunt_server(client_p, source_p, ":%s CONNECT %s %s :%s", 3, parc, parv) != HUNTED_ISME) - return 0; + return; if((target_p = find_server(source_p, parv[1]))) { sendto_one_notice(source_p, ":Connect: Server %s already exists from %s.", parv[1], target_p->from->name); - return 0; + return; } /* @@ -94,15 +96,15 @@ mo_connect(struct Client *client_p, struct Client *source_p, int parc, const cha if((server_p = find_server_conf(parv[1])) == NULL) { sendto_one_notice(source_p, ":Connect: Host %s not listed in ircd.conf", parv[1]); - return 0; + return; } - if(ServerConfSSL(server_p) && (!ssl_ok || !get_ssld_count())) + if(ServerConfSSL(server_p) && (!ircd_ssl_ok || !get_ssld_count())) { sendto_one_notice(source_p, ":Connect: Server %s is set to use SSL/TLS but SSL/TLS is not configured.", parv[1]); - return 0; + return; } /* @@ -110,27 +112,26 @@ mo_connect(struct Client *client_p, struct Client *source_p, int parc, const cha * use the default form configuration structure. If missing * from there, then use the precompiled default. */ - tmpport = port = server_p->port; + port = 0; if(parc > 2 && !EmptyString(parv[2])) + port = atoi(parv[2]); + if(port == 0 && server_p->port) + port = server_p->port; + else if(port <= 0) { - if((port = atoi(parv[2])) <= 0) - { - sendto_one_notice(source_p, ":Connect: Illegal port number"); - return 0; - } - } - else if(port <= 0 && (port = PORTNUM) <= 0) - { - sendto_one_notice(source_p, ":Connect: missing port number"); - return 0; + sendto_one_notice(source_p, ":Connect: illegal port number"); + return; } + /* * Notify all operators about remote connect requests */ ilog(L_SERVER, "CONNECT From %s : %s %s", source_p->name, parv[1], parc > 2 ? parv[2] : ""); + tmpport = server_p->port; server_p->port = port; + /* * at this point we should be calling connect_server with a valid * C:line and a valid port in the C:line @@ -148,10 +149,9 @@ mo_connect(struct Client *client_p, struct Client *source_p, int parc, const cha /* * client is either connecting with all the data it needs or has been - * destroyed + * destroyed, so reset it back to the configured settings */ server_p->port = tmpport; - return 0; } /* @@ -164,8 +164,8 @@ mo_connect(struct Client *client_p, struct Client *source_p, int parc, const cha * parv[2] = port number * parv[3] = remote server */ -static int -ms_connect(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) +static void +ms_connect(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { int port; int tmpport; @@ -173,13 +173,13 @@ ms_connect(struct Client *client_p, struct Client *source_p, int parc, const cha struct Client *target_p; if(hunt_server(client_p, source_p, ":%s CONNECT %s %s :%s", 3, parc, parv) != HUNTED_ISME) - return 0; + return; if((target_p = find_server(NULL, parv[1]))) { sendto_one_notice(source_p, ":Connect: Server %s already exists from %s.", parv[1], target_p->from->name); - return 0; + return; } /* @@ -189,15 +189,15 @@ ms_connect(struct Client *client_p, struct Client *source_p, int parc, const cha { sendto_one_notice(source_p, ":Connect: Host %s not listed in ircd.conf", parv[1]); - return 0; + return; } - if(ServerConfSSL(server_p) && (!ssl_ok || !get_ssld_count())) + if(ServerConfSSL(server_p) && (!ircd_ssl_ok || !get_ssld_count())) { sendto_one_notice(source_p, ":Connect: Server %s is set to use SSL/TLS but SSL/TLS is not configured.", parv[1]); - return 0; + return; } /* @@ -215,7 +215,7 @@ ms_connect(struct Client *client_p, struct Client *source_p, int parc, const cha else if(port <= 0) { sendto_one_notice(source_p, ":Connect: Illegal port number"); - return 0; + return; } /* @@ -246,5 +246,4 @@ ms_connect(struct Client *client_p, struct Client *source_p, int parc, const cha * destroyed */ server_p->port = tmpport; - return 0; }