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

Comparing ircd-hybrid-8/src/hostmask.c (file contents):
Revision 1371 by michael, Wed Apr 25 19:32:21 2012 UTC vs.
Revision 1372 by michael, Thu Apr 26 19:04:51 2012 UTC

# Line 28 | Line 28
28   #include "list.h"
29   #include "conf.h"
30   #include "hostmask.h"
31 #include "numeric.h"
31   #include "send.h"
32   #include "irc_string.h"
33   #include "ircd.h"
34  
36 #ifdef IPV6
37 static int try_parse_v6_netmask(const char *, struct irc_ssaddr *, int *);
38 static uint32_t hash_ipv6(struct irc_ssaddr *, int);
39 #endif
40 static int try_parse_v4_netmask(const char *, struct irc_ssaddr *, int *);
41 static uint32_t hash_ipv4(struct irc_ssaddr *, int);
35  
36   #define DigitParse(ch) do { \
37                         if (ch >= '0' && ch <= '9') \
# Line 288 | Line 281 | match_ipv6(struct irc_ssaddr *addr, stru
281    return 0;
282   }
283   #endif
284 +
285   /* int match_ipv4(struct irc_ssaddr *, struct irc_ssaddr *, int)
286   * Input: An IP address, an IP mask, the number of bits in the mask.
287   * Output: if match, -1 else 0
# Line 861 | Line 855 | hostmask_expire_temporary(void)
855        }
856      }
857    }
864 }
865
866 /*
867 * show_iline_prefix()
868 *
869 * inputs       - pointer to struct Client requesting output
870 *              - pointer to struct AccessItem
871 *              - name to which iline prefix will be prefixed to
872 * output       - pointer to static string with prefixes listed in ascii form
873 * side effects - NONE
874 */
875 char *
876 show_iline_prefix(struct Client *sptr, struct AccessItem *aconf, const char *name)
877 {
878  static char prefix_of_host[USERLEN + 14];
879  char *prefix_ptr = prefix_of_host;
880
881  if (IsNoTilde(aconf))
882    *prefix_ptr++ = '-';
883  if (IsLimitIp(aconf))
884    *prefix_ptr++ = '!';
885  if (IsNeedIdentd(aconf))
886    *prefix_ptr++ = '+';
887  if (!IsNeedPassword(aconf))
888    *prefix_ptr++ = '&';
889  if (IsConfExemptResv(aconf))
890    *prefix_ptr++ = '$';
891  if (IsNoMatchIp(aconf))
892    *prefix_ptr++ = '%';
893  if (IsConfDoSpoofIp(aconf))
894    *prefix_ptr++ = '=';
895  if (MyOper(sptr) && IsConfExemptKline(aconf))
896    *prefix_ptr++ = '^';
897  if (MyOper(sptr) && IsConfExemptGline(aconf))
898    *prefix_ptr++ = '_';
899  if (MyOper(sptr) && IsConfExemptLimits(aconf))
900    *prefix_ptr++ = '>';
901  if (IsConfCanFlood(aconf))
902    *prefix_ptr++ = '|';
903
904  strlcpy(prefix_ptr, name, USERLEN+1);
905
906  return prefix_of_host;
907 }
908
909 /* report_auth()
910 *
911 * Inputs: pointer to client to report to
912 * Output: None
913 * Side effects: Reports configured auth{} blocks to client_p
914 */
915 void
916 report_auth(struct Client *client_p)
917 {
918  struct ConfItem *conf;
919  struct AccessItem *aconf;
920  dlink_node *ptr = NULL;
921  unsigned int i;
922
923
924  for (i = 0; i < ATABLE_SIZE; ++i)
925  {
926    ptr = NULL;
927
928    DLINK_FOREACH(ptr, atable[i].head)
929    {
930      struct AddressRec *arec = ptr->data;
931
932      if (arec->type == CONF_CLIENT)
933      {
934        aconf = arec->aconf;
935
936        if (!MyOper(client_p) && IsConfDoSpoofIp(aconf))
937          continue;
938
939        conf = unmap_conf_item(aconf);
940
941        /* We are doing a partial list, based on what matches the u@h of the
942         * sender, so prepare the strings for comparing --fl_
943         */
944        if (ConfigFileEntry.hide_spoof_ips)
945          sendto_one(client_p, form_str(RPL_STATSILINE), me.name,
946                     client_p->name, 'I',
947                     conf->name == NULL ? "*" : conf->name,
948                     show_iline_prefix(client_p, aconf, aconf->user),
949                     IsConfDoSpoofIp(aconf) ? "255.255.255.255" :
950                     aconf->host, aconf->port,
951                     aconf->class_ptr ? aconf->class_ptr->name : "<default>");
952                    
953        else
954          sendto_one(client_p, form_str(RPL_STATSILINE), me.name,
955                     client_p->name, 'I',
956                     conf->name == NULL ? "*" : conf->name,
957                     show_iline_prefix(client_p, aconf, aconf->user),
958                     aconf->host, aconf->port,
959                     aconf->class_ptr ? aconf->class_ptr->name : "<default>");
960      }
961    }
962  }
963 }
964
965 /* report_Klines()
966 * Inputs: Client to report to,
967 *         type(==0 for perm, !=0 for temporary)
968 *         mask
969 * Output: None
970 * Side effects: Reports configured K(or k)-lines to client_p.
971 */
972 void
973 report_Klines(struct Client *client_p, int tkline)
974 {
975  struct AccessItem *aconf = NULL;
976  unsigned int i = 0;
977  const char *p = NULL;
978  dlink_node *ptr = NULL;
979
980  if (tkline)
981    p = "k";
982  else
983    p = "K";
984
985  for (i = 0; i < ATABLE_SIZE; ++i)
986  {
987    ptr = NULL;
988
989    DLINK_FOREACH(ptr, atable[i].head)
990    {
991      struct AddressRec *arec = ptr->data;
992
993      if (arec->type == CONF_KLINE)
994      {
995        if ((tkline && !((aconf = arec->aconf)->flags & CONF_FLAGS_TEMPORARY)) ||
996            (!tkline && ((aconf = arec->aconf)->flags & CONF_FLAGS_TEMPORARY)))
997          continue;
998
999        if (HasUMode(client_p, UMODE_OPER))
1000          sendto_one(client_p, form_str(RPL_STATSKLINE), me.name,
1001                     client_p->name, p, aconf->host, aconf->user,
1002                     aconf->reason, aconf->oper_reason ? aconf->oper_reason : "");
1003        else
1004          sendto_one(client_p, form_str(RPL_STATSKLINE), me.name,
1005                     client_p->name, p, aconf->host, aconf->user,
1006                     aconf->reason, "");
1007      }
1008    }
1009  }
858   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines