]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_connect.c
Allow /ojoin !#channel/%#channel, if admin/halfop are enabled.
[irc/rqf/shadowircd.git] / modules / m_connect.c
index 6615c5df2334104675399e2c517482e8c484cfdb..cf89756033a16fc930b47836efd63de27c575665 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: m_connect.c 254 2005-09-21 23:35:12Z nenolod $
+ *  $Id: m_connect.c 3161 2007-01-25 07:23:01Z nenolod $
  */
 
 #include "stdinc.h"
 #include "client.h"
 #include "ircd.h"
-#include "irc_string.h"
+#include "match.h"
 #include "numeric.h"
-#include "commio.h"
 #include "s_conf.h"
 #include "s_newconf.h"
-#include "s_log.h"
+#include "logger.h"
 #include "s_serv.h"
 #include "send.h"
 #include "msg.h"
 #include "parse.h"
 #include "hash.h"
 #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 **);
@@ -49,7 +49,7 @@ struct Message connect_msgtab = {
 };
 
 mapi_clist_av1 connect_clist[] = { &connect_msgtab, NULL };
-DECLARE_MODULE_AV1(connect, NULL, NULL, connect_clist, NULL, NULL, "$Revision: 254 $");
+DECLARE_MODULE_AV1(connect, NULL, NULL, connect_clist, NULL, NULL, "$Revision: 3161 $");
 
 /*
  * mo_connect - CONNECT command handler
@@ -57,7 +57,6 @@ DECLARE_MODULE_AV1(connect, NULL, NULL, connect_clist, NULL, NULL, "$Revision: 2
  * Added by Jto 11 Feb 1989
  *
  * m_connect
- *      parv[0] = sender prefix
  *      parv[1] = servername
  *      parv[2] = port number
  *      parv[3] = remote server
@@ -84,8 +83,8 @@ mo_connect(struct Client *client_p, struct Client *source_p, int parc, const cha
 
        if((target_p = find_server(source_p, parv[1])))
        {
-               sendto_one(source_p, ":%s NOTICE %s :Connect: Server %s already exists from %s.",
-                          me.name, parv[0], parv[1], target_p->from->name);
+               sendto_one_notice(source_p, ":Connect: Server %s already exists from %s.", parv[1], 
+                       target_p->from->name);
                return 0;
        }
 
@@ -94,9 +93,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(source_p,
-                          "NOTICE %s :Connect: Host %s not listed in ircd.conf",
-                          parv[0], parv[1]);
+               sendto_one_notice(source_p, ":Connect: Host %s not listed in ircd.conf", parv[1]);
+               return 0;
+       }
+
+       if(ServerConfSSL(server_p) && (!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;
        }
 
@@ -110,21 +115,20 @@ mo_connect(struct Client *client_p, struct Client *source_p, int parc, const cha
        {
                if((port = atoi(parv[2])) <= 0)
                {
-                       sendto_one(source_p, "NOTICE %s :Connect: Illegal port number", parv[0]);
+                       sendto_one_notice(source_p, ":Connect: Illegal port number");
                        return 0;
                }
        }
        else if(port <= 0 && (port = PORTNUM) <= 0)
        {
-               sendto_one(source_p, ":%s NOTICE %s :Connect: missing port number",
-                          me.name, parv[0]);
+               sendto_one_notice(source_p, ":Connect: missing port number");
                return 0;
        }
        /*
         * Notify all operators about remote connect requests
         */
 
-       ilog(L_SERVER, "CONNECT From %s : %s %s", parv[0], parv[1], parc > 2 ? parv[2] : "");
+       ilog(L_SERVER, "CONNECT From %s : %s %s", source_p->name, parv[1], parc > 2 ? parv[2] : "");
 
        server_p->port = port;
        /*
@@ -133,20 +137,13 @@ mo_connect(struct Client *client_p, struct Client *source_p, int parc, const cha
         */
        if(serv_connect(server_p, source_p))
        {
-#ifndef HIDE_SERVERS_IPS
-                       sendto_one(source_p, ":%s NOTICE %s :*** Connecting to %s[%s].%d",
-                                  me.name, parv[0], server_p->host, server_p->name, server_p->port);
-#else
-                       sendto_one(source_p, ":%s NOTICE %s :*** Connecting to %s.%d",
-                                  me.name, parv[0], server_p->name, server_p->port);
-#endif
-
+                       sendto_one_notice(source_p, ":*** Connecting to %s.%d",
+                               server_p->name, server_p->port);
        }
        else
        {
-               sendto_one(source_p, ":%s NOTICE %s :*** Couldn't connect to %s.%d",
-                          me.name, parv[0], server_p->name, server_p->port);
-
+               sendto_one_notice(source_p, ":*** Couldn't connect to %s.%d",
+                       server_p->name, server_p->port);
        }
 
        /*
@@ -163,7 +160,6 @@ mo_connect(struct Client *client_p, struct Client *source_p, int parc, const cha
  * Added by Jto 11 Feb 1989
  *
  * m_connect
- *      parv[0] = sender prefix
  *      parv[1] = servername
  *      parv[2] = port number
  *      parv[3] = remote server
@@ -196,6 +192,14 @@ ms_connect(struct Client *client_p, struct Client *source_p, int parc, const cha
                return 0;
        }
 
+       if(ServerConfSSL(server_p) && (!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;
+       }
+
        /*
         * Get port number from user, if given. If not specified,
         * use the default form configuration structure. If missing
@@ -223,9 +227,6 @@ ms_connect(struct Client *client_p, struct Client *source_p, int parc, const cha
        sendto_server(NULL, NULL, CAP_TS6, NOCAPS,
                      ":%s WALLOPS :Remote CONNECT %s %d from %s",
                      me.id, parv[1], port, source_p->name);
-       sendto_server(NULL, NULL, NOCAPS, CAP_TS6,
-                     ":%s WALLOPS :Remote CONNECT %s %d from %s",
-                     me.name, parv[1], port, source_p->name);
 
        ilog(L_SERVER, "CONNECT From %s : %s %d", source_p->name, parv[1], port);