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

Comparing:
ircd-hybrid/src/client.c (file contents), Revision 31 by knight, Sun Oct 2 20:34:05 2005 UTC vs.
ircd-hybrid-7.2/src/client.c (file contents), Revision 992 by michael, Mon Aug 17 19:19:16 2009 UTC

# Line 53 | Line 53
53   #include "listener.h"
54   #include "irc_res.h"
55   #include "userhost.h"
56 + #include "watch.h"
57  
58   dlink_list listing_client_list = { NULL, NULL, 0 };
59   /* Pointer to beginning of Client list */
# Line 122 | Line 123 | make_client(struct Client *from)
123      client_p->since = client_p->lasttime = client_p->firsttime = CurrentTime;
124  
125      client_p->localClient = BlockHeapAlloc(lclient_heap);
126 +    client_p->localClient->registration = REG_INIT;
127      /* as good a place as any... */
128      dlinkAdd(client_p, make_dlink_node(), &unknown_list);
129    }
# Line 148 | Line 150 | free_client(struct Client *client_p)
150    assert(client_p != NULL);
151    assert(client_p != &me);
152    assert(client_p->hnext == client_p);
151  assert(client_p->invited.head == NULL);
153    assert(client_p->channel.head == NULL);
153  assert(dlink_list_length(&client_p->invited) == 0);
154    assert(dlink_list_length(&client_p->channel) == 0);
155  
156    MyFree(client_p->away);
# Line 158 | Line 158 | free_client(struct Client *client_p)
158  
159    if (MyConnect(client_p))
160    {
161 +    assert(client_p->localClient->invited.head == NULL);
162 +    assert(dlink_list_length(&client_p->localClient->invited) == 0);
163      assert(IsClosing(client_p) && IsDead(client_p));
164  
165      MyFree(client_p->localClient->response);
# Line 316 | Line 318 | check_pings_list(dlink_list *list)
318              ilog(L_NOTICE, "No response from %s, closing link",
319                   get_client_name(client_p, HIDE_IP));
320            }
321 +
322            ircsprintf(scratch, "Ping timeout: %d seconds",
323                       (int)(CurrentTime - client_p->lasttime));
321
324            exit_client(client_p, &me, scratch);
325          }
326          else if (!IsPingWarning(client_p) && pingwarn > 0 &&
# Line 362 | Line 364 | check_unknowns_list(void)
364      if (client_p->localClient->reject_delay > 0)
365      {
366        if (client_p->localClient->reject_delay <= CurrentTime)
367 <        exit_client(client_p, &me, "Rejected");
367 >        exit_client(client_p, &me, "Rejected");
368        continue;
369      }
370  
371 <    /* Check UNKNOWN connections - if they have been in this state
371 >    /*
372 >     * Check UNKNOWN connections - if they have been in this state
373       * for > 30s, close them.
374       */
375 <    if (client_p->firsttime ? ((CurrentTime - client_p->firsttime) > 30) : 0)
376 <      exit_client(client_p, &me, "Connection timed out");
375 >    if (IsAuthFinished(client_p) && (CurrentTime - client_p->firsttime) > 30)
376 >      exit_client(client_p, &me, "Registration timed out");
377    }
378   }
379  
# Line 694 | Line 697 | get_client_name(struct Client *client, i
697   void
698   free_exited_clients(void)
699   {
700 <  dlink_node *ptr, *next;
698 <  struct Client *target_p;
700 >  dlink_node *ptr = NULL, *next = NULL;
701    
702    DLINK_FOREACH_SAFE(ptr, next, dead_list.head)
703    {
704 <    target_p = ptr->data;
703 <
704 <    if (ptr->data == NULL)
705 <    {
706 <      sendto_realops_flags(UMODE_ALL, L_ALL,
707 <                           "Warning: null client on dead_list!");
708 <      dlinkDelete(ptr, &dead_list);
709 <      free_dlink_node(ptr);
710 <      continue;
711 <    }
712 <
713 <    free_client(target_p);
704 >    free_client(ptr->data);
705      dlinkDelete(ptr, &dead_list);
706      free_dlink_node(ptr);
707    }
# Line 731 | Line 722 | exit_one_client(struct Client *source_p,
722  
723    if (IsServer(source_p))
724    {
725 <    dlinkDelete(&source_p->lnode, &source_p->servptr->serv->servers);
725 >    dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list);
726  
727      if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL)
728        free_dlink_node(lp);
738
739    if (!MyConnect(source_p))
740    {
741      source_p->from->serv->dep_servers--;
742      assert(source_p->from->serv->dep_servers > 0);
743    }
729    }
730    else if (IsClient(source_p))
731    {
732      if (source_p->servptr->serv != NULL)
733 <      dlinkDelete(&source_p->lnode, &source_p->servptr->serv->users);
733 >      dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list);
734  
735      /* If a person is on a channel, send a QUIT notice
736      ** to every client (person) on the same channel (so
# Line 758 | Line 743 | exit_one_client(struct Client *source_p,
743      DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head)
744        remove_user_from_channel(lp->data);
745  
761    /* Clean up invitefield */
762    DLINK_FOREACH_SAFE(lp, next_lp, source_p->invited.head)
763      del_invite(lp->data, source_p);
764
765    /* Clean up allow lists */
766    del_all_accepts(source_p);
746      add_history(source_p, 0);
747      off_history(source_p);
748  
749 <    if (!MyConnect(source_p))
749 >    watch_check_hash(source_p, RPL_LOGOFF);
750 >
751 >    if (MyConnect(source_p))
752      {
753 <      source_p->from->serv->dep_users--;
754 <      assert(source_p->from->serv->dep_users >= 0);
753 >      /* Clean up invitefield */
754 >      DLINK_FOREACH_SAFE(lp, next_lp, source_p->localClient->invited.head)
755 >        del_invite(lp->data, source_p);
756 >
757 >      del_all_accepts(source_p);
758      }
759    }
760  
# Line 827 | Line 811 | recurse_send_quits(struct Client *origin
811     * hidden behind fakename. If so, send out the QUITs -adx
812     */
813    if (hidden || !IsCapable(to, CAP_QS))
814 <    DLINK_FOREACH_SAFE(ptr, next, source_p->serv->users.head)
814 >    DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head)
815      {
816        target_p = ptr->data;
817        sendto_one(to, ":%s QUIT :%s", target_p->name, splitstr);
818      }
819  
820 <  DLINK_FOREACH_SAFE(ptr, next, source_p->serv->servers.head)
820 >  DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head)
821      recurse_send_quits(original_source_p, ptr->data, from, to,
822                         comment, splitstr, myname);
823  
# Line 857 | Line 841 | recurse_remove_clients(struct Client *so
841   {
842    dlink_node *ptr, *next;
843  
844 <  DLINK_FOREACH_SAFE(ptr, next, source_p->serv->users.head)
844 >  DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head)
845      exit_one_client(ptr->data, quitmsg);
846  
847 <  DLINK_FOREACH_SAFE(ptr, next, source_p->serv->servers.head)
847 >  DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head)
848    {
849      recurse_remove_clients(ptr->data, quitmsg);
850      exit_one_client(ptr->data, quitmsg);
851    }
868
869  assert(source_p->serv->dep_servers == 1);
870  assert(source_p->serv->dep_users == 0);
852   }
853  
854   /*
# Line 935 | Line 916 | exit_client(struct Client *source_p, str
916      if (IsIpHash(source_p))
917        remove_one_ip(&source_p->localClient->ip);
918  
919 <    delete_auth(source_p);
919 >    if (source_p->localClient->auth)
920 >    {
921 >      delete_auth(source_p->localClient->auth);
922 >      source_p->localClient->auth = NULL;
923 >    }
924  
925      /* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING
926       * STAT_HANDSHAKE or STAT_UNKNOWN
# Line 962 | Line 947 | exit_client(struct Client *source_p, str
947        if (source_p->localClient->list_task != NULL)
948          free_list_task(source_p->localClient->list_task, source_p);
949  
950 +      watch_del_watch_list(source_p);
951        sendto_realops_flags(UMODE_CCONN, L_ALL, "Client exiting: %s (%s@%s) [%s] [%s]",
952                             source_p->name, source_p->username, source_p->host, comment,
953                             ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
954                             "255.255.255.255" : source_p->sockhost);
955 +      sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, "CLIEXIT: %s %s %s %s 0 %s",
956 +                           source_p->name,
957 +                           source_p->username,
958 +                           source_p->host,
959 +
960 +                           ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
961 +                           "255.255.255.255" : source_p->sockhost,
962 +                           comment);
963      }
964  
965      /* As soon as a client is known to be a server of some sort
# Line 982 | Line 976 | exit_client(struct Client *source_p, str
976        }
977  
978        if (IsServer(source_p))
985      {
979          Count.myserver--;
987        if (ServerInfo.hub)
988          remove_lazylink_flags(source_p->localClient->serverMask);
989        else
990          uplink = NULL;
991      }
980      }
981  
982      log_user_exit(source_p);
# Line 1028 | Line 1016 | exit_client(struct Client *source_p, str
1016      assert(source_p->serv != NULL && source_p->servptr != NULL);
1017  
1018      if (ConfigServerHide.hide_servers)
1019 <      /* set netsplit message to "*.net *.split" to still show
1019 >      /*
1020 >       * Set netsplit message to "*.net *.split" to still show
1021         * that its a split, but hide the servers splitting
1022         */
1023        strcpy(splitstr, "*.net *.split");
# Line 1053 | Line 1042 | exit_client(struct Client *source_p, str
1042    }
1043    else if (IsClient(source_p) && !IsKilled(source_p))
1044    {
1045 <    sendto_server(NULL, source_p, NULL, CAP_TS6, NOCAPS, NOFLAGS,
1045 >    sendto_server(from->from, NULL, CAP_TS6, NOCAPS,
1046                    ":%s QUIT :%s", ID(source_p), comment);
1047 <    sendto_server(NULL, source_p, NULL, NOCAPS, CAP_TS6, NOFLAGS,
1047 >    sendto_server(from->from, NULL, NOCAPS, CAP_TS6,
1048                    ":%s QUIT :%s", source_p->name, comment);
1049    }
1050  
# Line 1133 | Line 1122 | dead_link_on_read(struct Client *client_
1122      }
1123      else
1124      {
1125 <      report_error(L_ADMIN, "Lost connection to %s: %d",
1125 >      report_error(L_ADMIN, "Lost connection to %s: %s",
1126                     get_client_name(client_p, SHOW_IP), current_error);
1127 <      report_error(L_OPER, "Lost connection to %s: %d",
1127 >      report_error(L_OPER, "Lost connection to %s: %s",
1128                     get_client_name(client_p, MASK_IP), current_error);
1129      }
1130  
# Line 1192 | Line 1181 | exit_aborted_clients(void)
1181  
1182   /*
1183   * accept processing, this adds a form of "caller ID" to ircd
1184 < *
1184 > *
1185   * If a client puts themselves into "caller ID only" mode,
1186 < * only clients that match a client pointer they have put on
1186 > * only clients that match a client pointer they have put on
1187   * the accept list will be allowed to message them.
1188   *
1189 < * [ source.on_allow_list ] -> [ target1 ] -> [ target2 ]
1201 < *
1202 < * [target.allow_list] -> [ source1 ] -> [source2 ]
1203 < *
1204 < * i.e. a target will have a link list of source pointers it will allow
1205 < * each source client then has a back pointer pointing back
1206 < * to the client that has it on its accept list.
1207 < * This allows for exit_one_client to remove these now bogus entries
1208 < * from any client having an accept on them.
1189 > * Diane Bruce, "Dianora" db@db.net
1190   */
1191  
1192 < /* accept_message()
1193 < *
1213 < * inputs       - pointer to source client
1214 < *              - pointer to target client
1215 < * output       - 1 if accept this message 0 if not
1216 < * side effects - See if source is on target's allow list
1217 < */
1218 < int
1219 < accept_message(struct Client *source, struct Client *target)
1192 > void
1193 > del_accept(struct split_nuh_item *accept_p, struct Client *client_p)
1194   {
1195 <  dlink_node *ptr;
1195 >  dlinkDelete(&accept_p->node, &client_p->localClient->acceptlist);
1196  
1197 <  DLINK_FOREACH(ptr, target->allow_list.head)
1198 <  {
1199 <    struct Client *target_p = ptr->data;
1197 >  MyFree(accept_p->nickptr);
1198 >  MyFree(accept_p->userptr);
1199 >  MyFree(accept_p->hostptr);
1200 >  MyFree(accept_p);
1201 > }
1202  
1203 <    if (source == target_p)
1204 <      return (1);
1205 <  }
1203 > struct split_nuh_item *
1204 > find_accept(const char *nick, const char *user,
1205 >            const char *host, struct Client *client_p, int do_match)
1206 > {
1207 >  dlink_node *ptr = NULL;
1208 >  /* XXX We wouldn't need that if match() would return 0 on match */
1209 >  int (*cmpfunc)(const char *, const char *) = do_match ? match : irccmp;
1210  
1211 <  if (IsSoftCallerId(target))
1211 >  DLINK_FOREACH(ptr, client_p->localClient->acceptlist.head)
1212    {
1213 <    DLINK_FOREACH(ptr, target->channel.head)
1214 <      if (IsMember(source, ptr->data))
1215 <        return (1);
1213 >    struct split_nuh_item *accept_p = ptr->data;
1214 >
1215 >    if (cmpfunc(accept_p->nickptr, nick) == do_match &&
1216 >        cmpfunc(accept_p->userptr, user) == do_match &&
1217 >        cmpfunc(accept_p->hostptr, host) == do_match)
1218 >      return accept_p;
1219    }
1220  
1221 <  return (0);
1221 >  return NULL;
1222   }
1223  
1224 < /* del_from_accept()
1242 < *
1243 < * inputs       - pointer to source client
1244 < *              - pointer to target client
1245 < * output       - NONE
1246 < * side effects - Delete's source pointer to targets allow list
1224 > /* accept_message()
1225   *
1226 < * Walk through the target's accept list, remove if source is found,
1227 < * Then walk through the source's on_accept_list remove target if found.
1226 > * inputs       - pointer to source client
1227 > *              - pointer to target client
1228 > * output       - 1 if accept this message 0 if not
1229 > * side effects - See if source is on target's allow list
1230   */
1231 < void
1232 < del_from_accept(struct Client *source, struct Client *target)
1231 > int
1232 > accept_message(struct Client *source,
1233 >               struct Client *target)
1234   {
1235 <  dlink_node *ptr;
1255 <  dlink_node *ptr2;
1256 <  dlink_node *next_ptr;
1257 <  dlink_node *next_ptr2;
1258 <  struct Client *target_p;
1235 >  dlink_node *ptr = NULL;
1236  
1237 <  DLINK_FOREACH_SAFE(ptr, next_ptr, target->allow_list.head)
1238 <  {
1239 <    target_p = ptr->data;
1237 >  if (source == target || find_accept(source->name, source->username,
1238 >                                      source->host, target, 1))
1239 >    return 1;
1240  
1241 <    if (source == target_p)
1242 <    {
1243 <      dlinkDelete(ptr, &target->allow_list);
1244 <      free_dlink_node(ptr);
1268 <
1269 <      DLINK_FOREACH_SAFE(ptr2, next_ptr2, source->on_allow_list.head)
1270 <      {
1271 <        target_p = ptr2->data;
1241 >  if (IsSoftCallerId(target))
1242 >    DLINK_FOREACH(ptr, target->channel.head)
1243 >      if (IsMember(source, ((struct Membership *)ptr->data)->chptr))
1244 >        return 1;
1245  
1246 <        if (target == target_p)
1274 <        {
1275 <          dlinkDelete(ptr2, &source->on_allow_list);
1276 <          free_dlink_node(ptr2);
1277 <        }
1278 <      }
1279 <    }
1280 <  }
1246 >  return 0;
1247   }
1248  
1249   /* del_all_accepts()
1250   *
1251 < * inputs       - pointer to exiting client
1252 < * output       - NONE
1253 < * side effects - Walk through given clients allow_list and on_allow_list
1288 < *                remove all references to this client
1251 > * inputs       - pointer to exiting client
1252 > * output       - NONE
1253 > * side effects - Walk through given clients acceptlist and remove all entries
1254   */
1255   void
1256   del_all_accepts(struct Client *client_p)
1257   {
1258 <  dlink_node *ptr, *next_ptr;
1294 <
1295 <  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->allow_list.head)
1296 <    del_from_accept(ptr->data, client_p);
1297 <
1298 <  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head)
1299 <    del_from_accept(client_p, ptr->data);
1300 < }
1301 <
1302 < /* del_all_their_accepts()
1303 < *
1304 < * inputs       - pointer to exiting client
1305 < * output       - NONE
1306 < * side effects - Walk through given clients on_allow_list
1307 < *                remove all references to this client,
1308 < *                allow this client to keep their own allow_list
1309 < */
1310 < void
1311 < del_all_their_accepts(struct Client *client_p)
1312 < {
1313 <  dlink_node *ptr, *next_ptr;
1258 >  dlink_node *ptr = NULL, *next_ptr = NULL;
1259  
1260 <  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head)
1261 <    del_from_accept(client_p, ptr->data);
1260 >  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->acceptlist.head)
1261 >    del_accept(ptr->data, client_p);
1262   }
1263  
1264   /* set_initial_nick()
# Line 1335 | Line 1280 | set_initial_nick(struct Client *client_p
1280    
1281    /* This had to be copied here to avoid problems.. */
1282    source_p->tsinfo = CurrentTime;
1283 +  source_p->localClient->registration &= ~REG_NEED_NICK;
1284  
1285    if (source_p->name[0])
1286      hash_del_client(source_p);
# Line 1345 | Line 1291 | set_initial_nick(struct Client *client_p
1291    /* fd_desc is long enough */
1292    fd_note(&client_p->localClient->fd, "Nick: %s", nick);
1293    
1294 <  /* They have the nick they want now.. */
1349 <  client_p->llname[0] = '\0';
1350 <
1351 <  if (source_p->flags & FLAGS_GOTUSER)
1294 >  if (!source_p->localClient->registration)
1295    {
1296      strlcpy(buf, source_p->username, sizeof(buf));
1297  
# Line 1375 | Line 1318 | set_initial_nick(struct Client *client_p
1318   void
1319   change_local_nick(struct Client *client_p, struct Client *source_p, const char *nick)
1320   {
1321 +  int samenick = 0;
1322 +
1323 +  assert(source_p->name[0] && !EmptyString(nick));
1324 +
1325    /*
1326 <  ** Client just changing his/her nick. If he/she is
1327 <  ** on a channel, send note of change to all clients
1328 <  ** on that channel. Propagate notice to other servers.
1329 <  */
1326 >   * Client just changing his/her nick. If he/she is
1327 >   * on a channel, send note of change to all clients
1328 >   * on that channel. Propagate notice to other servers.
1329 >   */
1330    if ((source_p->localClient->last_nick_change +
1331         ConfigFileEntry.max_nick_time) < CurrentTime)
1332      source_p->localClient->number_of_nick_changes = 0;
# Line 1392 | Line 1339 | change_local_nick(struct Client *client_
1339       !ConfigFileEntry.anti_nick_flood ||
1340       (IsOper(source_p) && ConfigFileEntry.no_oper_flood))
1341    {
1342 <    if (irccmp(source_p->name, nick))
1342 >    samenick = !irccmp(source_p->name, nick);
1343 >
1344 >    if (!samenick)
1345 >    {
1346        source_p->tsinfo = CurrentTime;
1347 +      clear_ban_cache_client(source_p);
1348 +      watch_check_hash(source_p, RPL_LOGOFF);
1349 +    }
1350  
1351      /* XXX - the format of this notice should eventually be changed
1352       * to either %s[%s@%s], or even better would be get_client_name() -bill
# Line 1403 | Line 1356 | change_local_nick(struct Client *client_
1356      sendto_common_channels_local(source_p, 1, ":%s!%s@%s NICK :%s",
1357                                   source_p->name, source_p->username,
1358                                   source_p->host, nick);
1406
1359      add_history(source_p, 1);
1360 <          
1361 <         /* Only hubs care about lazy link nicks not being sent on yet
1410 <           * lazylink leafs/leafs always send their nicks up to hub,
1411 <           * hence must always propagate nick changes.
1412 <           * hubs might not propagate a nick change, if the leaf
1413 <           * does not know about that client yet.
1414 <           */
1415 <    sendto_server(client_p, source_p, NULL, CAP_TS6, NOCAPS, NOFLAGS,
1360 >
1361 >    sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
1362                    ":%s NICK %s :%lu",
1363                    ID(source_p), nick, (unsigned long)source_p->tsinfo);
1364 <    sendto_server(client_p, source_p, NULL, NOCAPS, CAP_TS6, NOFLAGS,
1364 >    sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
1365                    ":%s NICK %s :%lu",
1366                    source_p->name, nick, (unsigned long)source_p->tsinfo);
1367 +
1368 +    hash_del_client(source_p);
1369 +    strcpy(source_p->name, nick);
1370 +    hash_add_client(source_p);
1371 +
1372 +    if (!samenick)
1373 +      watch_check_hash(source_p, RPL_LOGON);
1374 +
1375 +    /* fd_desc is long enough */
1376 +    fd_note(&client_p->localClient->fd, "Nick: %s", nick);
1377    }
1378    else
1423  {
1379      sendto_one(source_p, form_str(ERR_NICKTOOFAST),
1380                 me.name, source_p->name, source_p->name,
1381                 nick, ConfigFileEntry.max_nick_time);
1427    return;
1428  }
1429
1430  /* Finally, add to hash */
1431  if (source_p->name[0])
1432    hash_del_client(source_p);
1433
1434  strcpy(source_p->name, nick);
1435  hash_add_client(source_p);
1436
1437  /* Make sure everyone that has this client on its accept list
1438   * loses that reference.
1439   */
1440  del_all_their_accepts(source_p);
1441
1442  /* fd_desc is long enough */
1443  fd_note(&client_p->localClient->fd, "Nick: %s", nick);
1382   }

Comparing:
ircd-hybrid/src/client.c (property svn:keywords), Revision 31 by knight, Sun Oct 2 20:34:05 2005 UTC vs.
ircd-hybrid-7.2/src/client.c (property svn:keywords), Revision 992 by michael, Mon Aug 17 19:19:16 2009 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

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