ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_connect.c
(Generate patch)

Comparing:
ircd-hybrid-8/modules/m_connect.c (file contents), Revision 1178 by michael, Mon Aug 15 08:11:31 2011 UTC vs.
ircd-hybrid/trunk/modules/m_connect.c (file contents), Revision 2012 by michael, Sun May 12 14:47:26 2013 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 – #include "handlers.h"
26   #include "client.h"
27   #include "ircd.h"
28   #include "irc_string.h"
29   #include "numeric.h"
30   #include "fdlist.h"
31   #include "s_bsd.h"
32 < #include "s_conf.h"
33 < #include "s_log.h"
32 > #include "conf.h"
33 > #include "log.h"
34   #include "s_serv.h"
35   #include "send.h"
37 – #include "msg.h"
36   #include "parse.h"
37   #include "hash.h"
38   #include "modules.h"
39  
42 – static void mo_connect(struct Client *, struct Client *, int, char *[]);
43 – static void ms_connect(struct Client *, struct Client *, int, char *[]);
44 –
45 – struct Message connect_msgtab = {
46 –  "CONNECT", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
47 –  { m_unregistered, m_not_oper, ms_connect, m_ignore, mo_connect, m_ignore }
48 – };
49 –
50 – void
51 – _modinit(void)
52 – {
53 –  mod_add_cmd(&connect_msgtab);
54 – }
55 –
56 – void
57 – _moddeinit(void)
58 – {
59 –  mod_del_cmd(&connect_msgtab);
60 – }
61 –
62 – const char *_version = "$Revision$";
40  
41   /*
42   * mo_connect - CONNECT command handler
# Line 78 | Line 55 | mo_connect(struct Client *client_p, stru
55   {
56    int port;
57    int tmpport;
58 <  struct ConfItem *conf = NULL;
82 <  struct AccessItem *aconf = NULL;
58 >  struct MaskItem *conf = NULL;
59    const struct Client *target_p = NULL;
60  
61    if (EmptyString(parv[1]))
# Line 91 | Line 67 | mo_connect(struct Client *client_p, stru
67  
68    if (parc > 3)
69    {
70 <    if (!IsOperRemote(source_p))
70 >    if (!HasOFlag(source_p, OPER_FLAG_CONNECT_REMOTE))
71      {
72        sendto_one(source_p, form_str(ERR_NOPRIVS),
73                   me.name, source_p->name, "connect");
# Line 102 | Line 78 | mo_connect(struct Client *client_p, stru
78                      parc, parv) != HUNTED_ISME)
79        return;
80    }
81 +  else if (!HasOFlag(source_p, OPER_FLAG_CONNECT))
82 +  {
83 +    sendto_one(source_p, form_str(ERR_NOPRIVS),
84 +               me.name, source_p->name, "connect");
85 +    return;
86 +  }
87  
88    if ((target_p = hash_find_server(parv[1])))
89    {
# Line 114 | Line 96 | mo_connect(struct Client *client_p, stru
96    /*
97     * try to find the name, then host, if both fail notify ops and bail
98     */
99 <  if ((conf = find_matching_name_conf(SERVER_TYPE,
118 <                                      parv[1], NULL, NULL, 0)) != NULL)
119 <    aconf = (struct AccessItem *)map_to_conf(conf);
120 <  else if ((conf = find_matching_name_conf(SERVER_TYPE,
121 <                                           NULL, NULL, parv[1], 0)) != NULL)
122 <    aconf = (struct AccessItem *)map_to_conf(conf);
123 <  
124 <  if (conf == NULL || aconf == NULL)
99 >  if (!(conf = find_matching_name_conf(CONF_SERVER, parv[1], NULL, NULL, 0)))
100    {
101 <    sendto_one(source_p,
102 <               ":%s NOTICE %s :Connect: Host %s not listed in ircd.conf",
103 <               me.name, source_p->name, parv[1]);
104 <    return;
101 >    if  (!(conf = find_matching_name_conf(CONF_SERVER,  NULL, NULL, parv[1], 0)))
102 >    {
103 >      sendto_one(source_p,
104 >                 ":%s NOTICE %s :Connect: Host %s not listed in ircd.conf",
105 >                 me.name, source_p->name, parv[1]);
106 >      return;
107 >    }
108    }
109  
110    /* Get port number from user, if given. If not specified,
111     * use the default form configuration structure. If missing
112     * from there, then use the precompiled default.
113     */
114 <  tmpport = port = aconf->port;
114 >  tmpport = port = conf->port;
115  
116    if (parc > 2 && !EmptyString(parv[2]))
117    {
# Line 161 | Line 139 | mo_connect(struct Client *client_p, stru
139    /*
140     * Notify all operators about remote connect requests
141     */
142 <  ilog(L_TRACE, "CONNECT From %s : %s %s",
142 >  ilog(LOG_TYPE_IRCD, "CONNECT From %s : %s %s",
143         source_p->name, parv[1], parv[2] ? parv[2] : "");
144  
145 <  aconf->port = port;
145 >  conf->port = port;
146  
147    /* at this point we should be calling connect_server with a valid
148     * C:line and a valid port in the C:line
149     */
150 <  if (serv_connect(aconf, source_p))
150 >  if (serv_connect(conf, source_p))
151    {
152 <    if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))
152 >    if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
153        sendto_one(source_p, ":%s NOTICE %s :*** Connecting to %s[%s].%d",
154 <                 me.name, source_p->name, aconf->host,
155 <                 conf->name, aconf->port);
154 >                 me.name, source_p->name, conf->host,
155 >                 conf->name, conf->port);
156      else
157        sendto_one(source_p, ":%s NOTICE %s :*** Connecting to %s.%d",
158 <                 me.name, source_p->name, conf->name, aconf->port);
158 >                 me.name, source_p->name, conf->name, conf->port);
159    }
160    else
161    {
162      sendto_one(source_p, ":%s NOTICE %s :*** Couldn't connect to %s.%d",
163 <               me.name, source_p->name, conf->name, aconf->port);
163 >               me.name, source_p->name, conf->name, conf->port);
164    }
165  
166    /* client is either connecting with all the data it needs or has been
167     * destroyed
168     */
169 <  aconf->port = tmpport;
169 >  conf->port = tmpport;
170   }
171  
172   /*
# Line 208 | Line 186 | ms_connect(struct Client *client_p, stru
186   {
187    int port;
188    int tmpport;
189 <  struct ConfItem *conf = NULL;
212 <  struct AccessItem *aconf = NULL;
189 >  struct MaskItem *conf = NULL;
190    const struct Client *target_p = NULL;
191  
192    if (hunt_server(client_p, source_p,
193                    ":%s CONNECT %s %s :%s", 3, parc, parv) != HUNTED_ISME)
194      return;
195  
196 <  if (*parv[1] == '\0')
196 >  if (EmptyString(parv[1]))
197    {
198      sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
199                 me.name, source_p->name, "CONNECT");
# Line 234 | Line 211 | ms_connect(struct Client *client_p, stru
211    /*
212     * try to find the name, then host, if both fail notify ops and bail
213     */
214 <  if ((conf = find_matching_name_conf(SERVER_TYPE,
215 <                                      parv[1], NULL, NULL, 0)) != NULL)
216 <    aconf = map_to_conf(conf);
217 <  else if ((conf = find_matching_name_conf(SERVER_TYPE,
218 <                                           NULL, NULL, parv[1], 0)) != NULL)
219 <    aconf = map_to_conf(conf);
220 <
221 <  if (conf == NULL || aconf == NULL)
222 <  {
246 <    sendto_one(source_p,
247 <               ":%s NOTICE %s :Connect: Host %s not listed in ircd.conf",
248 <               me.name, source_p->name, parv[1]);
249 <    return;
214 >  if (!(conf = find_matching_name_conf(CONF_SERVER, parv[1], NULL, NULL, 0)))
215 >  {
216 >    if  (!(conf = find_matching_name_conf(CONF_SERVER,  NULL, NULL, parv[1], 0)))
217 >    {
218 >      sendto_one(source_p,
219 >                 ":%s NOTICE %s :Connect: Host %s not listed in ircd.conf",
220 >                 me.name, source_p->name, parv[1]);
221 >      return;
222 >    }
223    }
224  
225    /* Get port number from user, if given. If not specified,
226     * use the default form configuration structure. If missing
227     * from there, then use the precompiled default.
228     */
229 <  tmpport = port = aconf->port;
229 >  tmpport = port = conf->port;
230  
231    if (parc > 2 && !EmptyString(parv[2]))
232    {
233      port = atoi(parv[2]);
234  
235      /* if someone sends port 0, and we have a config port.. use it */
236 <    if (port == 0 && aconf->port)
237 <      port = aconf->port;
236 >    if (port == 0 && conf->port)
237 >      port = conf->port;
238      else if (port <= 0)
239      {
240        sendto_one(source_p, ":%s NOTICE %s :Connect: Illegal port number",
# Line 288 | Line 261 | ms_connect(struct Client *client_p, stru
261     */
262    sendto_wallops_flags(UMODE_WALLOP, &me, "Remote CONNECT %s %d from %s",
263                         parv[1], port, source_p->name);
264 <  sendto_server(NULL, NULL, NOCAPS, NOCAPS,
264 >  sendto_server(NULL, NOCAPS, CAP_TS6,
265                  ":%s WALLOPS :Remote CONNECT %s %d from %s",
266                  me.name, parv[1], port, source_p->name);
267 +  sendto_server(NULL, CAP_TS6, NOCAPS,
268 +                ":%s WALLOPS :Remote CONNECT %s %d from %s",
269 +                me.id, parv[1], port, source_p->name);
270  
271 <  ilog(L_TRACE, "CONNECT From %s : %s %d",
271 >  ilog(LOG_TYPE_IRCD, "CONNECT From %s : %s %d",
272         source_p->name, parv[1], port);
273  
274 <  aconf->port = port;
274 >  conf->port = port;
275  
276    /*
277     * At this point we should be calling connect_server with a valid
278     * C:line and a valid port in the C:line
279     */
280 <  if (serv_connect(aconf, source_p))
280 >  if (serv_connect(conf, source_p))
281      sendto_one(source_p, ":%s NOTICE %s :*** Connecting to %s.%d",
282 <               me.name, source_p->name, conf->name, aconf->port);
282 >               me.name, source_p->name, conf->name, conf->port);
283    else
284      sendto_one(source_p, ":%s NOTICE %s :*** Couldn't connect to %s.%d",
285 <               me.name, source_p->name, conf->name, aconf->port);
285 >               me.name, source_p->name, conf->name, conf->port);
286    /*
287     * Client is either connecting with all the data it needs or has been
288     * destroyed
289     */
290 <  aconf->port = tmpport;
290 >  conf->port = tmpport;
291 > }
292 >
293 > static struct Message connect_msgtab = {
294 >  "CONNECT", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
295 >  { m_unregistered, m_not_oper, ms_connect, m_ignore, mo_connect, m_ignore }
296 > };
297 >
298 > static void
299 > module_init(void)
300 > {
301 >  mod_add_cmd(&connect_msgtab);
302   }
303  
304 + static void
305 + module_exit(void)
306 + {
307 +  mod_del_cmd(&connect_msgtab);
308 + }
309 +
310 + struct module module_entry = {
311 +  .node    = { NULL, NULL, NULL },
312 +  .name    = NULL,
313 +  .version = "$Revision$",
314 +  .handle  = NULL,
315 +  .modinit = module_init,
316 +  .modexit = module_exit,
317 +  .flags   = 0
318 + };

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)