#define __PROXYSCAN_H
#include "../nick/nick.h"
+#include "../lib/splitline.h"
#include <time.h>
+#include <stdint.h>
-#define MAGICSTRING "NOTICE AUTH :*** Looking up your hostname\r\n"
-#define MAGICSTRINGLENGTH 42
+#define MAGICSTRING "NOTICE AUTH :*** Looking up your hostname\r\n"
+#define MAGICSTRINGLENGTH 42
-#define PSCAN_MAXSCANS 50
-#define PSCAN_READBUFSIZE (MAGICSTRINGLENGTH * 2)
+#define MAGICIRCSTRING ".quakenet.org 451 * :Register first.\r\n"
+#define MAGICIRCSTRINGLENGTH 38
+
+#define MAGICROUTERSTRING "\r\nServer: Mikrotik HttpProxy\r\n"
+#define MAGICROUTERSTRINGLENGTH 30
+
+#define PSCAN_MAXSCANS 50
+#define PSCAN_READBUFSIZE (MAGICSTRINGLENGTH * 2)
#define SSTATE_CONNECTING 0
#define SSTATE_SENTREQUEST 1
#define STYPE_HTTP 2
#define STYPE_WINGATE 3
#define STYPE_CISCO 4
-#define STYPE_DIRECT 5
+#define STYPE_DIRECT 5 /* not sure what this is so I'm leaving it alone */
+#define STYPE_DIRECT_IRC 6
+#define STYPE_ROUTER 7
#define SOUTCOME_INPROGRESS 0
#define SOUTCOME_OPEN 1
int hits;
} scantype;
+typedef struct extrascan {
+ unsigned short port;
+ unsigned char type;
+ struct extrascan *next;
+ struct extrascan *nextbynode;
+} extrascan;
+
typedef struct pendingscan {
- unsigned int IP;
+ patricia_node_t *node;
unsigned short port;
unsigned char type;
unsigned char class;
} foundproxy;
typedef struct cachehost {
- unsigned long IP;
time_t lastscan;
foundproxy *proxies;
int glineid;
+ time_t lastgline;
unsigned char marker;
#if defined(PROXYSCAN_MAIL)
sstring *lasthostmask; /* Not saved to disk */
time_t lastconnect; /* Not saved to disk */
#endif
- struct cachehost *next;
+ struct cachehost *next;
} cachehost;
typedef struct scan {
int fd;
- unsigned int IP;
+ patricia_node_t *node;
short type;
unsigned short port;
unsigned short state;
extern int numscans;
extern scantype thescans[];
extern int brokendb;
+extern int ps_cache_ext;
+extern int ps_scan_ext;
+extern int ps_extscan_ext;
+extern int ps_ready;
+extern int rescaninterval;
extern unsigned int normalqueuedscans;
extern unsigned int prioqueuedscans;
+extern unsigned int ps_start_ts;
+
extern unsigned long countpendingscan;
extern unsigned long scanspermin;
/* proxyscancache.c */
-cachehost *addcleanhost(unsigned long IP, time_t timestamp);
-cachehost *findcachehost(unsigned long IP);
+cachehost *addcleanhost(time_t timestamp);
+cachehost *findcachehost(patricia_node_t *node);
void delcachehost(cachehost *);
void dumpcachehosts();
void loadcachehosts();
pendingscan *getpendingscan();
void freependingscan(pendingscan *psp);
void sfreeall();
+extrascan *getextrascan();
+void freeextrascan(extrascan *esp);
/* proxyscanlisten.c */
int openlistensocket(int portnum);
int createconnectsocket(long ip, int socknum);
/* proxyscandb.c */
-void loggline(cachehost *chp);
+void loggline(cachehost *chp, patricia_node_t *node);
void proxyscandbclose();
int proxyscandbinit();
-void proxyscandolistopen(nick *mynick, nick *usernick, time_t snce);
+int proxyscandolistopen(void *sender, int cargc, char **cargv);
void proxyscanspewip(nick *mynick, nick *usernick, unsigned long a, unsigned long b, unsigned long c, unsigned long d);
void proxyscanshowkill(nick *mynick, nick *usernick, unsigned long a);
const char *scantostr(int type);
#endif
/* proxyscanqueue.c */
-void queuescan(unsigned int IP, short scantype, unsigned short port, char class, time_t when);
+void queuescan(patricia_node_t *node, short scantype, unsigned short port, char class, time_t when);
void startqueuedscans();
/* proxyscan.c */
-void startscan(unsigned int IP, int type, int port, int class);
-
+void startscan(patricia_node_t *node, int type, int port, int class);
+void startnickscan(nick *nick);
+
+/* proxyscanext.c */
+unsigned int extrascancount();
+void loadextrascans();
+extrascan *findextrascan(patricia_node_t *node);
+void delextrascan(extrascan *esp);
+extrascan *addextrascan(unsigned short port, unsigned char type);
#endif