core support for looking up a users ip address when they sign on. Now to modify StatServ
This commit is contained in:
parent
68eb681fc8
commit
f219bcd664
13 changed files with 88 additions and 3 deletions
|
@ -64,6 +64,9 @@
|
|||
#define GOTSVSKILL
|
||||
/* we don't have automatic host cloaking support via Umode */
|
||||
#undef GOTUMODECLOAKING
|
||||
/* we have nickip */
|
||||
#define GOTNICKIP
|
||||
|
||||
|
||||
/* buffer sizes */
|
||||
#define MAXHOST (128 + 1)
|
||||
|
|
2
Ircu.h
2
Ircu.h
|
@ -66,6 +66,8 @@
|
|||
#undef GOTSVSKILL
|
||||
/* we don't have automatic host cloaking support via Umode */
|
||||
#undef GOTUMODECLOAKING
|
||||
/* we have nickip support */
|
||||
#define GOTNICKIP
|
||||
|
||||
/* Override NeoStats core splitbuf function */
|
||||
/* #define IRCD_SPLITBUF */
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
#define GOTSVSKILL
|
||||
/* we don't have automatic host cloaking support via Umode */
|
||||
#undef GOTUMODECLOAKING
|
||||
/* we have nickip support */
|
||||
#define GOTNICKIP
|
||||
|
||||
/* buffer sizes */
|
||||
#define MAXHOST (128 + 1)
|
||||
|
|
|
@ -60,6 +60,8 @@
|
|||
#define GOTSVSKILL
|
||||
/* we don't have automatic host cloaking support via Umode */
|
||||
#undef GOTUMODECLOAKING
|
||||
/* we dont have a nickip field in the nick message */
|
||||
#undef GOTNICKIP
|
||||
|
||||
#else /* !ULTIMATE3 */
|
||||
|
||||
|
@ -91,6 +93,8 @@
|
|||
#undef GOTUSERSMODES
|
||||
/* we don't have automatic host cloaking support via Umode */
|
||||
#undef GOTUMODECLOAKING
|
||||
/* we dont have a nickip field in the nick message */
|
||||
#undef GOTNICKIP
|
||||
|
||||
#endif /* ULTIMATE3 */
|
||||
|
||||
|
|
5
Unreal.h
5
Unreal.h
|
@ -63,6 +63,11 @@
|
|||
#define GOTSVSKILL
|
||||
/* we have automatic host cloaking support via Umode */
|
||||
#define GOTUMODECLOAKING
|
||||
/* we dont have a nickip field in the nick message */
|
||||
#undef GOTNICKIP
|
||||
|
||||
|
||||
|
||||
|
||||
/* buffer sizes */
|
||||
#define MAXHOST (128 + 1)
|
||||
|
|
12
events.h
12
events.h
|
@ -267,3 +267,15 @@
|
|||
*/
|
||||
#define EVENT_DELBAN "DELBAN"
|
||||
|
||||
/* EVENT_GOTNICKIP
|
||||
* fired when we get the IP address of a user
|
||||
* only fired if me.want_nickip = 1 and:
|
||||
* the ircd sends the nickip as part of the connect message
|
||||
* or
|
||||
* a dns lookup completes and is successfull
|
||||
*
|
||||
* Parameters:
|
||||
* av[0] nick
|
||||
*/
|
||||
|
||||
#define EVENT_GOTNICKIP "NICKIP"
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
#undef GOTSVSKILL
|
||||
/* we don't have automatic host cloaking support via Umode */
|
||||
#undef GOTUMODECLOAKING
|
||||
/* we dont' ahve nickip support */
|
||||
#undef GOTNICKIP
|
||||
|
||||
/* buffer sizes */
|
||||
#define MAXHOST (128 + 1)
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
#define GOTSVSKILL
|
||||
/* we don't have automatic host cloaking support via Umode */
|
||||
#undef GOTUMODECLOAKING
|
||||
/* we have NICKIP suport */
|
||||
#define GOTNICKIP
|
||||
|
||||
/* buffer sizes */
|
||||
#define MAXHOST (128 + 1)
|
||||
|
|
1
main.c
1
main.c
|
@ -121,6 +121,7 @@ main (int argc, char *argv[])
|
|||
me.now = time(NULL);
|
||||
ircsnprintf (me.strnow, STR_TIME_T_SIZE, "%ld", (long)me.now);
|
||||
me.want_privmsg = 0;
|
||||
me.want_nickip = 0;
|
||||
me.die = 0;
|
||||
me.local[0] = '\0';
|
||||
me.debug_mode = 0;
|
||||
|
|
2
mystic.h
2
mystic.h
|
@ -64,6 +64,8 @@
|
|||
#define GOTSVSKILL
|
||||
/* we don't have automatic host cloaking support via Umode */
|
||||
#undef GOTUMODECLOAKING
|
||||
/* we dont have nickip */
|
||||
#undef GOTNICKIP
|
||||
|
||||
/* buffer sizes */
|
||||
#define MAXHOST (75 + 1)
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
#undef GOTSVSKILL
|
||||
/* we don't have automatic host cloaking support via Umode */
|
||||
#undef GOTUMODECLOAKING
|
||||
/* we dont have nickip support */
|
||||
#undef GOTNICKIP
|
||||
|
||||
/* buffer sizes */
|
||||
#define MAXHOST (128 + 1)
|
||||
|
|
3
stats.h
3
stats.h
|
@ -228,7 +228,7 @@
|
|||
#define T_TABLE_SIZE 300 /* Number of Timers */
|
||||
#define B_TABLE_SIZE 100 /* Number of Bots */
|
||||
#define MAXMODES -1
|
||||
#define DNS_QUEUE_SIZE 100 /* number on concurrent DNS lookups */
|
||||
#define DNS_QUEUE_SIZE 300 /* number on concurrent DNS lookups */
|
||||
#define MAX_TRANSFERS 10 /* number of curl transfers */
|
||||
|
||||
#define bzero(x, y) memset(x, '\0', y);
|
||||
|
@ -375,6 +375,7 @@ struct me {
|
|||
unsigned int onlyopers:1;
|
||||
unsigned int die:1;
|
||||
unsigned int debug_mode:1;
|
||||
unsigned int want_nickip:1;
|
||||
#if defined(ULTIMATE3) || defined(QUANTUM)
|
||||
unsigned int client:1;
|
||||
#endif
|
||||
|
|
49
users.c
49
users.c
|
@ -36,6 +36,11 @@
|
|||
#ifdef SQLSRV
|
||||
#include "sqlsrv/rta.h"
|
||||
#endif
|
||||
#ifndef GOTNICKIP
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
hash_t *uh;
|
||||
|
||||
|
@ -68,6 +73,21 @@ new_user (const char *nick)
|
|||
return (u);
|
||||
}
|
||||
|
||||
static void
|
||||
lookupnickip(char *data, adns_answer *a) {
|
||||
User *u;
|
||||
char **av;
|
||||
int ac = 0;
|
||||
|
||||
u = finduser((char *)data);
|
||||
if (a && a->nrrs > 0 && u && a->status == adns_s_ok) {
|
||||
u->ipaddr.s_addr = a->rrs.addr->addr.inet.sin_addr.s_addr;
|
||||
printf("%s\n", inet_ntoa(u->ipaddr));
|
||||
AddStringToList (&av, u->nick, &ac);
|
||||
ModuleEvent (EVENT_GOTNICKIP, av, ac);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AddUser (const char *nick, const char *user, const char *host, const char *realname, const char *server, const char*ip, const char* TS, const char* numeric)
|
||||
{
|
||||
|
@ -77,6 +97,10 @@ AddUser (const char *nick, const char *user, const char *host, const char *realn
|
|||
int ac = 0;
|
||||
User *u;
|
||||
int i;
|
||||
#ifndef GOTNICKIP
|
||||
struct in_addr *ipad;
|
||||
int res;
|
||||
#endif
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
u = finduser (nick);
|
||||
|
@ -85,11 +109,30 @@ AddUser (const char *nick, const char *user, const char *host, const char *realn
|
|||
return;
|
||||
}
|
||||
|
||||
if(ip) {
|
||||
if(0) {
|
||||
ipaddress = strtoul (ip, NULL, 10);
|
||||
} else {
|
||||
#ifndef GOTNICKIP
|
||||
if (me.want_nickip == 1) {
|
||||
/* first, if the u->host is a ip address, just convert it */
|
||||
ipad = malloc(sizeof(struct in_addr));
|
||||
res = inet_aton(host, ipad);
|
||||
if (res > 0) {
|
||||
/* its valid */
|
||||
ipaddress = ipad->s_addr;
|
||||
free(ipad);
|
||||
} else {
|
||||
/* kick of a dns reverse lookup for this host */
|
||||
dns_lookup((char *)host, adns_r_addr, lookupnickip, (void *)nick);
|
||||
ipaddress = 0;
|
||||
}
|
||||
} else {
|
||||
ipaddress = 0;
|
||||
}
|
||||
#else
|
||||
ipaddress = 0;
|
||||
#endif
|
||||
}
|
||||
if(TS) {
|
||||
time = strtoul (TS, NULL, 10);
|
||||
} else {
|
||||
|
@ -139,6 +182,10 @@ AddUser (const char *nick, const char *user, const char *host, const char *realn
|
|||
|
||||
AddStringToList (&av, u->nick, &ac);
|
||||
ModuleEvent (EVENT_SIGNON, av, ac);
|
||||
if (me.want_nickip == 1 && ipaddress != 0) {
|
||||
/* only fire this event if we have the nickip and some module wants it */
|
||||
ModuleEvent (EVENT_GOTNICKIP, av, ac);
|
||||
}
|
||||
free (av);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue