/[svn]/hopm/branches/1.1.x/src/scan.c
ViewVC logotype

Diff of /hopm/branches/1.1.x/src/scan.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 8137 by michael, Mon Apr 3 18:52:16 2017 UTC revision 8138 by michael, Tue Apr 4 17:01:34 2017 UTC
# Line 48  Line 48 
48  #include "misc.h"  #include "misc.h"
49  #include "scan.h"  #include "scan.h"
50    
51  /* Libopm */  /* libopm includes */
   
52  #include "libopm/src/opm.h"  #include "libopm/src/opm.h"
53  #include "libopm/src/opm_common.h"  #include "libopm/src/opm_common.h"
54  #include "libopm/src/opm_error.h"  #include "libopm/src/opm_error.h"
# Line 205  void Line 204  void
204  scan_init(void)  scan_init(void)
205  {  {
206    node_t *p, *p2, *p3, *p4, *node;    node_t *p, *p2, *p3, *p4, *node;
   struct UserConf *uc;  
   struct ScannerConf *sc;  
   struct ProtocolConf *pc;  
   struct scanner_struct *scs;  
207    
208    SCANNERS = list_create();    SCANNERS = list_create();
209    MASKS    = list_create();    MASKS    = list_create();
# Line 216  scan_init(void) Line 211  scan_init(void)
211    /* Setup each individual scanner */    /* Setup each individual scanner */
212    LIST_FOREACH(p, ScannerItemList->head)    LIST_FOREACH(p, ScannerItemList->head)
213    {    {
214      sc = p->data;      struct ScannerConf *sc = p->data;
     scs = xcalloc(sizeof(*scs));  
215    
216      if (OPT_DEBUG)      if (OPT_DEBUG)
217        log_printf("SCAN -> Setting up scanner [%s]", sc->name);        log_printf("SCAN -> Setting up scanner [%s]", sc->name);
218    
219      /* Build the scanner */      /* Build the scanner */
220        struct scanner_struct *scs = xcalloc(sizeof(*scs));
221      scs->scanner = opm_create();      scs->scanner = opm_create();
222      scs->name = xstrdup(sc->name);      scs->name = xstrdup(sc->name);
223      scs->masks = list_create();      scs->masks = list_create();
# Line 249  scan_init(void) Line 244  scan_init(void)
244      /* Setup the protocols */      /* Setup the protocols */
245      LIST_FOREACH(p2, sc->protocols->head)      LIST_FOREACH(p2, sc->protocols->head)
246      {      {
247        pc = p2->data;        struct ProtocolConf *pc = p2->data;
248    
249        if (OPT_DEBUG >= 2)        if (OPT_DEBUG >= 2)
250          log_printf("SCAN -> Adding protocol %s:%d to scanner [%s]",          log_printf("SCAN -> Adding protocol %s:%d to scanner [%s]",
# Line 267  scan_init(void) Line 262  scan_init(void)
262    /* Give scanners a list of masks they scan */    /* Give scanners a list of masks they scan */
263    LIST_FOREACH(p, SCANNERS->head)    LIST_FOREACH(p, SCANNERS->head)
264    {    {
265      scs = p->data;      struct scanner_struct *scs = p->data;
266    
267      LIST_FOREACH(p2, UserItemList->head)      LIST_FOREACH(p2, UserItemList->head)
268      {      {
269        uc = p2->data;        struct UserConf *uc = p2->data;
270    
271        LIST_FOREACH(p3, uc->scanners->head)        LIST_FOREACH(p3, uc->scanners->head)
272        {        {
# Line 526  scan_positive(struct scan_struct *ss, co Line 521  scan_positive(struct scan_struct *ss, co
521      opm_end(scanner, ss->remote);      opm_end(scanner, ss->remote);
522    }    }
523    
524    /* Set it as a positive (to avoid a scan_negative call later on */    /* Set it as a positive to avoid a scan_negative call later on */
525    ss->positive = 1;    ss->positive = 1;
526  }  }
527    
# Line 543  scan_positive(struct scan_struct *ss, co Line 538  scan_positive(struct scan_struct *ss, co
538  static void  static void
539  scan_open_proxy(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *data)  scan_open_proxy(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *data)
540  {  {
541    struct scan_struct *ss;    struct scan_struct *ss = remote->data;
542    struct scanner_struct *scs;    struct scanner_struct *scs = data;
543    
544    /* Record that a scan happened */    /* Record that a scan happened */
545    scan_log(remote);    scan_log(remote);
546    
   scs = data;  
   ss = remote->data;  
   
547    if (ss->manual_target)    if (ss->manual_target)
548    {    {
549      irc_send("PRIVMSG %s :CHECK -> OPEN PROXY %s:%d (%s) [%s]",      irc_send("PRIVMSG %s :CHECK -> OPEN PROXY %s:%d (%s) [%s]",
# Line 644  scan_timeout(OPM_T *scanner, OPM_REMOTE_ Line 636  scan_timeout(OPM_T *scanner, OPM_REMOTE_
636  static void  static void
637  scan_end(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *data)  scan_end(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *data)
638  {  {
639    struct scan_struct *ss;    struct scan_struct *ss = remote->data;
640    struct scanner_struct *scs;    struct scanner_struct *scs = data;
   
   scs = data;  
   ss = remote->data;  
641    
642    if (OPT_DEBUG)    if (OPT_DEBUG)
643      log_printf("SCAN -> Scan %s [%s] completed", remote->ip, scs->name);      log_printf("SCAN -> Scan %s [%s] completed", remote->ip, scs->name);
# Line 672  scan_end(OPM_T *scanner, OPM_REMOTE_T *r Line 661  scan_end(OPM_T *scanner, OPM_REMOTE_T *r
661  static void  static void
662  scan_handle_error(OPM_T *scanner, OPM_REMOTE_T *remote, int err, void *data)  scan_handle_error(OPM_T *scanner, OPM_REMOTE_T *remote, int err, void *data)
663  {  {
664    struct scan_struct *ss;    struct scan_struct *ss = remote->data;
665    struct scanner_struct *scs;    struct scanner_struct *scs = data;
   
   scs = data;  
   ss = remote->data;  
666    
667    switch (err)    switch (err)
668    {    {
# Line 907  scan_manual(char *param, const struct Ch Line 893  scan_manual(char *param, const struct Ch
893    
894    if (scannername)    if (scannername)
895      irc_send("PRIVMSG %s :CHECK -> Checking '%s' for open proxies [%s]",      irc_send("PRIVMSG %s :CHECK -> Checking '%s' for open proxies [%s]",
896               target->name, ip, scannername);               target->name, ss->ip, scannername);
897    else    else
898      irc_send("PRIVMSG %s :CHECK -> Checking '%s' for open proxies on all scanners",      irc_send("PRIVMSG %s :CHECK -> Checking '%s' for open proxies on all scanners",
899               target->name, ip);               target->name, ss->ip);
900    
901    if (LIST_SIZE(OpmItem->blacklists))    if (LIST_SIZE(OpmItem->blacklists))
902      dnsbl_add(ss);      dnsbl_add(ss);
# Line 929  scan_manual(char *param, const struct Ch Line 915  scan_manual(char *param, const struct Ch
915          continue;          continue;
916    
917      if (OPT_DEBUG)      if (OPT_DEBUG)
918        log_printf("SCAN -> Passing %s to scanner [%s] (MANUAL SCAN)", ip, scs->name);        log_printf("SCAN -> Passing %s to scanner [%s] (MANUAL SCAN)", ss->ip, scs->name);
919    
920      if ((ret = opm_scan(scs->scanner, ss->remote)) != OPM_SUCCESS)      if ((ret = opm_scan(scs->scanner, ss->remote)) != OPM_SUCCESS)
921      {      {

Legend:
Removed from v.8137  
changed lines
  Added in v.8138

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28