mirror of
https://github.com/EnergyMech/energymech.git
synced 2025-12-17 15:36:50 +00:00
Merge pull request #22 from joonicks/dev
random cumulative fixes and changes
This commit is contained in:
commit
f9ac463c2a
6
.gitignore
vendored
6
.gitignore
vendored
@ -17,8 +17,10 @@ src/*.o
|
||||
src/lib/*.o
|
||||
src/gencmd
|
||||
src/aliastest
|
||||
src/calctest
|
||||
src/safepathtest
|
||||
trivia/mkindex
|
||||
src/musl.c
|
||||
|
||||
# mech typical user config files
|
||||
*~
|
||||
@ -35,7 +37,9 @@ trivia/megatrivia.txt
|
||||
conf
|
||||
debug*
|
||||
src/calc.c
|
||||
src/nostdlib
|
||||
src/x
|
||||
src/y
|
||||
src/z
|
||||
|
||||
randdata
|
||||
test.conf
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
As I see it, yes.
|
||||
Definitly!
|
||||
Definitely!
|
||||
I'm leaning toward yes.
|
||||
It is certain.
|
||||
It is decidedly so.
|
||||
@ -8,18 +8,19 @@ It's likely.
|
||||
Most likely.
|
||||
My sources say yes.
|
||||
Outlook good.
|
||||
Signs point to yes.
|
||||
All signs point to yes.
|
||||
Without a doubt.
|
||||
Yes
|
||||
Yes
|
||||
Yes definitly.
|
||||
Yes definitly.
|
||||
Yes definitely.
|
||||
Yes definitely.
|
||||
You may rely on it.
|
||||
Dont count on it.
|
||||
I'm leaning toward no.
|
||||
My reply is no.
|
||||
My reply is no.
|
||||
My sources say no.
|
||||
All signs point to no.
|
||||
No
|
||||
No
|
||||
No chance at all!
|
||||
@ -33,5 +34,7 @@ Dont ask me, ask yourself that one.
|
||||
I better not tell you now.
|
||||
I think you should ask yourself that question.
|
||||
Maybe
|
||||
Reply hazy try agian.
|
||||
Reply is hazy please try again.
|
||||
Reply hazy, try again.
|
||||
Reply is hazy, please try again.
|
||||
Definitely maybe.
|
||||
As certain as death and taxes.
|
||||
|
||||
@ -103,7 +103,7 @@ wishing you and yours a very merry christmas and a happy new year!!
|
||||
worf! still struggling up that evolutionary ladder?--q
|
||||
you are someone else i am still right here
|
||||
you call this a storm??!! lt. dan on hurricane carmen
|
||||
you idiots! you've captured they're stunt doubles!
|
||||
you idiots! you've captured their stunt doubles!
|
||||
you see the nipples on that dog?!? - tom
|
||||
you're stinking on purpose, anrn't you?
|
||||
your mother is so fat, she jumped for joy and got stuck.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#
|
||||
# EnergyMech, IRC bot software
|
||||
# Copyright (c) 1997-2018 proton
|
||||
# Copyright (c) 1997-2021 proton
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -45,14 +45,14 @@ CHMOD = chmod
|
||||
BASEINCLUDES = config.h defines.h structs.h global.h h.h
|
||||
INCS = $(BASEINCLUDES) mcmd.h text.h usercombo.h
|
||||
|
||||
TESTFILES = aliastest safepathtest
|
||||
TESTFILES = aliastest calctest safepathtest
|
||||
|
||||
OFILES = alias.o auth.o bounce.o channel.o core.o ctcp.o debug.o dns.o function.o greet.o \
|
||||
OFILES = alias.o auth.o bounce.o calc.o channel.o core.o ctcp.o debug.o dns.o function.o greet.o \
|
||||
help.o hostinfo.o io.o irc.o main.o net.o note.o ons.o parse.o partyline.o \
|
||||
perl.o prot.o python.o reset.o seen.o shit.o spy.o tcl.o toybox.o \
|
||||
uptime.o user.o vars.o web.o lib/string.o @MD5_O@ @SHA_O@
|
||||
|
||||
SRCFILES = alias.c auth.c bounce.c channel.c core.c ctcp.c debug.c dns.c function.c greet.c \
|
||||
SRCFILES = alias.c auth.c bounce.c calc.c channel.c core.c ctcp.c debug.c dns.c function.c greet.c \
|
||||
help.c hostinfo.c io.c irc.c main.c net.c note.c ons.c parse.c partyline.c \
|
||||
perl.c prot.c python.c reset.c seen.c shit.c spy.c tcl.c toybox.c \
|
||||
uptime.c user.c vars.c web.c lib/string.c @MD5_C@ @SHA_C@
|
||||
@ -124,13 +124,17 @@ mega-static: $(SRCFILES) $(INCS) usage.h
|
||||
|
||||
test: $(TESTFILES)
|
||||
./aliastest
|
||||
./calctest
|
||||
./safepathtest
|
||||
|
||||
aliastest: alias.c
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o aliastest $< $(LPROF) $(LIBS) $(LDSCRIPT) -DTEST
|
||||
aliastest: alias.c githash.h lib/string.o
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o aliastest $< lib/string.o $(LPROF) $(LIBS) -DTEST
|
||||
|
||||
safepathtest: function.c
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o safepathtest $< $(LPROF) $(LIBS) $(LDSCRIPT) -DTEST
|
||||
calctest: calc.c githash.h mcmd.h lib/string.o
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o calctest $< lib/string.o $(LPROF) $(LIBS) -DTEST
|
||||
|
||||
safepathtest: function.c githash.h lib/string.o
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o safepathtest $< lib/string.o $(LPROF) $(LIBS) -DTEST
|
||||
|
||||
commands:
|
||||
grep -E '(void do_.*\(COMMAND_ARGS\)|/*---Help:)' *c
|
||||
@ -157,6 +161,9 @@ auth.o: auth.c $(INCS)
|
||||
bounce.o: bounce.c $(INCS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
||||
|
||||
calc.o: calc.c $(INCS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
||||
|
||||
channel.o: channel.c $(INCS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
||||
|
||||
|
||||
11
src/alias.c
11
src/alias.c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Copyright (c) 1997-2018 proton
|
||||
Copyright (c) 1997-2020 proton
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -38,6 +38,11 @@
|
||||
char result[MSGLEN];
|
||||
char *input = "alias one two three four five six seven eight nine ten";
|
||||
|
||||
void *Calloc(int size)
|
||||
{
|
||||
return(calloc(1,size));
|
||||
}
|
||||
|
||||
void testcase(const char *test, const char *expect)
|
||||
{
|
||||
afmt(result,test,input);
|
||||
@ -45,12 +50,12 @@ void testcase(const char *test, const char *expect)
|
||||
else debug("testcase FAIL: test \"%s\", expected \"%s\", got \"%s\"\n",test,expect,result);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
char *format = argv[1];
|
||||
|
||||
dodebug = 1;
|
||||
strcpy(CurrentNick,"noob");
|
||||
stringcpy(CurrentNick,"noob");
|
||||
if (format == NULL)
|
||||
{
|
||||
/* testcases */
|
||||
|
||||
@ -376,7 +376,7 @@ void channel_massmode(const Chan *chan, char *pattern, int filtmode, char mode,
|
||||
s = deopstring;
|
||||
while(*s) s++;
|
||||
debug("(...) deopstring "mx_pfmt" uh "mx_pfmt" ("mx_pfmt")\n",(mx_ptr)deopstring,(mx_ptr)uh,(mx_ptr)s);
|
||||
s = strchr(deopstring,0);
|
||||
s = STRCHR(deopstring,0);
|
||||
debug("(...) deopstring "mx_pfmt" uh "mx_pfmt" ("mx_pfmt")\n",(mx_ptr)deopstring,(mx_ptr)uh,(mx_ptr)s);
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
@ -520,6 +520,13 @@ const char __mx_opts[] = ""
|
||||
#undef OPT_COREONLY
|
||||
#endif /* BOTNET */
|
||||
|
||||
#ifdef HOSTINFO
|
||||
OPT_COMMA "hostinfo"
|
||||
#undef OPT_COMMA
|
||||
#define OPT_COMMA ", "
|
||||
#undef OPT_COREONLY
|
||||
#endif /* HOSTINFO */
|
||||
|
||||
#ifdef NETCFG
|
||||
OPT_COMMA "netcfg"
|
||||
#undef OPT_COMMA
|
||||
|
||||
10
src/debug.c
10
src/debug.c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Copyright (c) 1997-2018 proton
|
||||
Copyright (c) 1997-2021 proton
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -182,6 +182,9 @@ LS struct
|
||||
{ cfg_greet, "cfg_greet" },
|
||||
{ do_greet, "do_greet" },
|
||||
#endif /* GREET */
|
||||
#ifdef HOSTINFO
|
||||
{ monitor_fs, "monitor_fs" },
|
||||
#endif /* HOSTINFO */
|
||||
#ifdef NOTE
|
||||
{ catch_note, "catch_note" },
|
||||
{ do_note, "do_note" },
|
||||
@ -200,6 +203,9 @@ LS struct
|
||||
{ parse_query, "parse_query" },
|
||||
{ read_dnsroot, "read_dnsroot" },
|
||||
#endif /* RAWDNS */
|
||||
#ifdef REDIRECT
|
||||
{ begin_redirect, "begin_redirect" },
|
||||
#endif /* REDIRECT */
|
||||
#ifdef SEEN
|
||||
{ make_seen, "make_seen" },
|
||||
#endif /* SEEN */
|
||||
@ -927,7 +933,7 @@ void debug_core(void)
|
||||
debug(" ; next\t\t"mx_pfmt"\n",(mx_ptr)spy->next);
|
||||
debug(" ; t_src\t\t%i\n",spy->t_src);
|
||||
debug(" ; t_dest\t\t%i\n",spy->t_dest);
|
||||
debug(" ; dcc\t\t"mx_pfmt"\n",(mx_ptr)spy->dcc);
|
||||
debug(" ; dcc\t\t"mx_pfmt"\n",(mx_ptr)spy->data.dcc);
|
||||
debug(" ; src\t\t"mx_pfmt" \"%s\"\n",(mx_ptr)spy->src,nullstr(spy->src));
|
||||
debug(" ; dest\t\t"mx_pfmt" \"%s\"\n",(mx_ptr)spy->dest,nullstr(spy->dest));
|
||||
debug(" ; ---\n");
|
||||
|
||||
@ -421,6 +421,7 @@ enum {
|
||||
#ifdef HOSTINFO
|
||||
#define SPY_SYSMON 9
|
||||
#endif /* HOSTINFO */
|
||||
#define SPY_RANDSRC 10
|
||||
|
||||
#define SPYF_ANY 1
|
||||
#define SPYF_CHANNEL (1 << SPY_CHANNEL)
|
||||
@ -429,7 +430,7 @@ enum {
|
||||
#define SPYF_RAWIRC (1 << SPY_RAWIRC)
|
||||
#define SPYF_BOTNET (1 << SPY_BOTNET)
|
||||
#define SPYF_URL (1 << SPY_URL)
|
||||
|
||||
#define SPYF_RANDSRC (1 << SPY_RANDSRC)
|
||||
/*
|
||||
* notify defines
|
||||
*/
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Parts Copyright (c) 1997-2018 proton
|
||||
Parts Copyright (c) 1997-2020 proton
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -729,9 +729,10 @@ int is_nick(const char *nick)
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* asc2int requires the whole string *anum to be a valid numeric */
|
||||
int asc2int(const char *anum)
|
||||
{
|
||||
int res = 0,neg;
|
||||
int res = 0, neg;
|
||||
|
||||
errno = EINVAL;
|
||||
|
||||
@ -751,6 +752,7 @@ int asc2int(const char *anum)
|
||||
return((neg) ? -res : res);
|
||||
}
|
||||
|
||||
/* get_number returns as soon as a non numeric character is encountered */
|
||||
int get_number(const char *rest)
|
||||
{
|
||||
const char *src = NULL;
|
||||
@ -758,7 +760,7 @@ int get_number(const char *rest)
|
||||
|
||||
while(*rest)
|
||||
{
|
||||
if (*rest >= '0' && *rest <= '9')
|
||||
if (0 == (attrtab[(uchar)*rest] & NUM))
|
||||
n = (n * 10) + (*(src = rest) - '0');
|
||||
else
|
||||
if (src)
|
||||
@ -944,6 +946,11 @@ int is_safepath(const char *path, int filemustexist)
|
||||
|
||||
char *tostr[] = { "ZERO", "FILE_MUST_EXIST", "FILE_MAY_EXIST", "FILE_MUST_NOTEXIST" };
|
||||
|
||||
void *Calloc(int size)
|
||||
{
|
||||
return(calloc(1,size));
|
||||
}
|
||||
|
||||
void testcase(const char *str, int expected, int filemustexist)
|
||||
{
|
||||
int r;
|
||||
@ -987,7 +994,7 @@ void teststring(void)
|
||||
debug("teststring SUCCESS: stringcat(str,%s) == %s\n","free","dingxofree");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Copyright (c) 1997-2018 proton
|
||||
Copyright (c) 1997-2020 proton
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -69,6 +69,7 @@ struct
|
||||
{ 0, "8BALL", "do_8ball", 0 | CBANG | SUPRES },
|
||||
{ 0, "RAND", "do_rand", 0 | CBANG | SUPRES },
|
||||
#endif /* TOYBOX */
|
||||
{ 0, "CV", "do_convert", 0 | CBANG | SUPRES },
|
||||
|
||||
/*
|
||||
* Level 10
|
||||
@ -240,6 +241,7 @@ struct
|
||||
{ 0, "HOSTINFO", "do_hostinfo", 100 | CCPW | GAXS },
|
||||
{ 0, "MEMINFO", "do_meminfo", 100 | CCPW | GAXS },
|
||||
{ 0, "CPUINFO", "do_cpuinfo", 100 | CCPW | GAXS },
|
||||
{ 0, "FILEMON", "do_filemon", 100 | CCPW | GAXS | CARGS },
|
||||
#endif /* HOSTINFO */
|
||||
#ifdef RAWDNS
|
||||
{ 0, "DNSSERVER", "do_dnsserver", 100 | CCPW | GAXS },
|
||||
|
||||
13
src/global.h
13
src/global.h
@ -71,6 +71,7 @@ BEG const char SPYSTR_URL[] MDEF("url");
|
||||
#if defined URLCAPTURE || defined HOSTINFO
|
||||
BEG const char SPYSTR_SYSMON[] MDEF("sysmon");
|
||||
#endif /* URLCAPTURE */
|
||||
BEG const char SPYSTR_RANDSRC[] MDEF("randsrc");
|
||||
|
||||
BEG const char STR_MECHRESET[] MDEF("MECHRESET=");
|
||||
|
||||
@ -191,6 +192,10 @@ BEG void *mallocdoer;
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
#ifdef HOSTINFO
|
||||
BEG FileMon *filemonlist MDEF(NULL);
|
||||
#endif /* HOSTINFO */
|
||||
|
||||
#ifdef NOTE
|
||||
|
||||
BEG Note *notelist MDEF(NULL);
|
||||
@ -211,7 +216,7 @@ BEG Strp *dnsrootfiles MDEF(NULL);
|
||||
|
||||
#ifdef REDIRECT
|
||||
|
||||
LS struct
|
||||
BEG struct
|
||||
{
|
||||
char *to;
|
||||
int method;
|
||||
@ -297,7 +302,7 @@ BEG int spawning_lamer MDEF(0);
|
||||
#define FNICK (NICK|FIRST)
|
||||
#define NNICK (NICK|NUM)
|
||||
|
||||
#ifdef MAIN_C
|
||||
#if defined(MAIN_C) || defined(MAKETABLES)
|
||||
|
||||
/*
|
||||
* tolowertab blatantly ripped from ircu2.9.32
|
||||
@ -413,6 +418,10 @@ LS const uchar attrtab[256] =
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0xF8 - 0xFF */
|
||||
};
|
||||
|
||||
#endif /* MAIN_C || MAKETABLES */
|
||||
|
||||
#ifdef MAIN_C
|
||||
|
||||
/*
|
||||
* user struct for the core client
|
||||
*/
|
||||
|
||||
11
src/h.h
11
src/h.h
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Copyright (c) 1997-2018 proton
|
||||
Copyright (c) 1997-2020 proton
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -136,6 +136,10 @@ void new_port_bounce(const struct Setting *);
|
||||
void select_bounce(void);
|
||||
void process_bounce(void);
|
||||
|
||||
/* calc.c */
|
||||
|
||||
LS void do_convert(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
|
||||
/* channel.c */
|
||||
|
||||
void check_idlekick(void);
|
||||
@ -326,7 +330,7 @@ void do_usage(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
|
||||
/* hostinfo.c */
|
||||
|
||||
void monitor_fs(const char *);
|
||||
int monitor_fs(const char *);
|
||||
void select_monitor();
|
||||
void process_monitor();
|
||||
int parse_proc_status(char *line) __page(CMD1_SEG);
|
||||
@ -334,6 +338,7 @@ int parse_proc_cpuinfo(char *line) __page(CMD1_SEG);
|
||||
void do_hostinfo(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
void do_meminfo(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
void do_cpuinfo(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
void do_filemon(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
|
||||
/* io.c */
|
||||
|
||||
@ -787,7 +792,7 @@ void web_raw(WebSock *, char *);
|
||||
void web_botstatus(WebSock *, char *);
|
||||
void web_debug(WebSock *, char *);
|
||||
void web_404(WebSock *, char *);
|
||||
void parse(WebSock *, char *);
|
||||
void parse_web(WebSock *, char *);
|
||||
void select_web(void);
|
||||
void process_web(void);
|
||||
|
||||
|
||||
253
src/hostinfo.c
253
src/hostinfo.c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Copyright (c) 2018 proton
|
||||
Copyright (c) 2020 proton
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -65,6 +65,74 @@ struct /* statusvalues */
|
||||
{ NULL, 0, NULL }
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
struct
|
||||
{
|
||||
int value;
|
||||
char *str;
|
||||
|
||||
} in2str[] =
|
||||
{
|
||||
{ IN_ACCESS, "IN_ACCESS" }, /* File was accessed (read) */
|
||||
{ IN_ATTRIB, "IN_ATTRIB" }, /* Metadata changed, e.g., permissions, timestamps, extended attributes, link count, UID, GID, etc. */
|
||||
{ IN_CLOSE_WRITE, "IN_CLOSE_WRITE" }, /* File opened for writing was closed */
|
||||
{ IN_CLOSE_NOWRITE, "IN_CLOSE_NOWRITE" }, /* File not opened for writing was closed */
|
||||
{ IN_CREATE, "IN_CREATE" }, /* File/directory created in watched directory */
|
||||
{ IN_DELETE, "IN_DELETE" }, /* File/directory deleted from watched directory */
|
||||
{ IN_DELETE_SELF, "IN_DELETE_SELF" }, /* Watched file/directory was itself deleted */
|
||||
{ IN_MODIFY, "IN_MODIFY" }, /* File was modified */
|
||||
{ IN_MOVE_SELF, "IN_MOVE_SELF" }, /* Watched file/directory was itself moved */
|
||||
{ IN_MOVED_FROM, "IN_MOVED_FROM" }, /* Generated for the directory containing the old filename when a file is renamed */
|
||||
{ IN_MOVED_TO, "IN_MOVED_TO" }, /* Generated for the directory containing the new filename when a file is renamed */
|
||||
{ IN_OPEN, "IN_OPEN" }, /* File was opened */
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
char *inomask2str(uint32_t mask, char *dst)
|
||||
{
|
||||
const char *src;
|
||||
int i,n = 0;
|
||||
|
||||
for(i=0;in2str[i].str;i++)
|
||||
{
|
||||
if ((mask & in2str[i].value) == in2str[i].value)
|
||||
{
|
||||
if (n)
|
||||
dst[n++] = '|';
|
||||
src = in2str[i].str;
|
||||
for(;src[n];n++)
|
||||
dst[n] = src[n];
|
||||
}
|
||||
}
|
||||
dst[n] = 0;
|
||||
return(dst);
|
||||
}
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
int monitor_fs(const char *file)
|
||||
{
|
||||
FileMon *fmon,*fnew;
|
||||
int ino;
|
||||
|
||||
if ((ino = inotify_init()) < 0)
|
||||
return(-1);
|
||||
inotify_add_watch(ino,file,IN_ALL_EVENTS);
|
||||
#ifdef DEBUG
|
||||
debug("(monitor_fs) added notifier on %s [fd %i]\n",file,ino);
|
||||
#endif
|
||||
set_mallocdoer(monitor_fs);
|
||||
fnew = Calloc(sizeof(FileMon) + strlen(file));
|
||||
fnew->fd = ino;
|
||||
fnew->nospam = now;
|
||||
stringcpy(fnew->filename,file);
|
||||
|
||||
fnew->next = filemonlist;
|
||||
filemonlist = fnew;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int parse_proc_status(char *line)
|
||||
{
|
||||
const char *key;
|
||||
@ -182,6 +250,57 @@ int parse_proc_cpuinfo(char *line)
|
||||
return(FALSE); /* return false to continue reading lines */
|
||||
}
|
||||
|
||||
void select_monitor()
|
||||
{
|
||||
FileMon *fmon;
|
||||
|
||||
for(fmon=filemonlist;fmon;fmon=fmon->next)
|
||||
if (fmon->fd >= 0)
|
||||
{
|
||||
FD_SET(fmon->fd,&read_fds);
|
||||
chkhigh(fmon->fd);
|
||||
}
|
||||
}
|
||||
|
||||
void process_monitor()
|
||||
{
|
||||
FileMon *fmon;
|
||||
struct inotify_event *ivent;
|
||||
char tmp[256];
|
||||
int n;
|
||||
|
||||
for(fmon=filemonlist;fmon;fmon=fmon->next)
|
||||
{
|
||||
if (fmon->fd >= 0 && FD_ISSET(fmon->fd,&read_fds))
|
||||
{
|
||||
ivent = (struct inotify_event *)&globaldata;
|
||||
|
||||
n = read(fmon->fd,globaldata,sizeof(struct inotify_event));
|
||||
if (ivent->len > 0)
|
||||
read(fmon->fd,ivent->name,ivent->len);
|
||||
else
|
||||
*ivent->name = 0;
|
||||
#ifdef DEBUG
|
||||
debug("ino %i, n %i, sz %i\n",fmon->fd,n,sizeof(in2str));
|
||||
debug("wd %i, mask %lu, cookie %lu, len %lu, name %s\n",
|
||||
ivent->wd,ivent->mask,ivent->cookie,ivent->len,ivent->name);
|
||||
debug("%s\n",inomask2str(ivent->mask,tmp));
|
||||
debug("(process_monitor) ino %i bytes read, int wd = %i, uint32_t mask = %s (%lu), "
|
||||
"uint32_t cookie = %lu, uint32_t len = %lu, char name = %s\n",
|
||||
n,ivent->wd,inomask2str(ivent->mask,tmp),ivent->mask,ivent->cookie,ivent->len,ivent->name);
|
||||
#endif
|
||||
if ((ivent->mask & IN_CLOSE_WRITE) == IN_CLOSE_WRITE)
|
||||
return;
|
||||
if (fmon->nospam > now-30)
|
||||
return;
|
||||
fmon->nospam = now;
|
||||
send_global(SPYSTR_SYSMON,"Alert: file ``%s'' was touched",fmon->filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
help:HOSTINFO:(no arguments)
|
||||
|
||||
@ -191,10 +310,17 @@ See also: meminfo, cpuinfo
|
||||
*/
|
||||
void do_hostinfo(COMMAND_ARGS)
|
||||
{
|
||||
char *h,hostname[256];
|
||||
struct utsname un;
|
||||
|
||||
hostname[255] = 0;
|
||||
if (gethostname(hostname,250) < 0)
|
||||
h = "(hostname error)";
|
||||
else
|
||||
h = hostname;
|
||||
|
||||
if (uname(&un) == 0)
|
||||
to_user_q(from,"%s %s %s",un.sysname,un.release,un.machine);
|
||||
to_user_q(from,"%s %s %s %s",h,un.sysname,un.release,un.machine);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -240,6 +366,7 @@ void do_cpuinfo(COMMAND_ARGS)
|
||||
char bogostr[64],cpustr[64];
|
||||
char *a1,*a2,*a3,*dst;
|
||||
int fd,n;
|
||||
double loads[3];
|
||||
|
||||
#ifdef DEVELOPING
|
||||
a1 = chop(&rest);
|
||||
@ -271,25 +398,7 @@ void do_cpuinfo(COMMAND_ARGS)
|
||||
omni[1] = 0;
|
||||
readline(fd,&parse_proc_cpuinfo); /* readline closes fd */
|
||||
|
||||
if ((fd = open("/proc/loadavg",O_RDONLY)) < 0)
|
||||
#ifdef DEBUG
|
||||
{
|
||||
debug("(do_cpuinfo) /proc/loadavg: %s\n",strerror(errno));
|
||||
return;
|
||||
}
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
n = read(fd,globaldata,MSGLEN-2);
|
||||
globaldata[n] = 0;
|
||||
close(fd);
|
||||
|
||||
rest = globaldata;
|
||||
a1 = chop(&rest);
|
||||
a2 = chop(&rest);
|
||||
a3 = chop(&rest);
|
||||
|
||||
if (!a3 || !*a3)
|
||||
if (getloadavg(loads,3) < 3)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -313,103 +422,29 @@ void do_cpuinfo(COMMAND_ARGS)
|
||||
if (cores)
|
||||
sprintf(STREND(cpustr),", %i core%s",cores,(cores == 1) ? "" : "s");
|
||||
}
|
||||
to_user_q(from,"%s%s%s, loadavg: %s(1m) %s(5m) %s(15m)",
|
||||
omni+1,bogostr,cpustr,a1,a2,a3);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
struct
|
||||
{
|
||||
int value;
|
||||
char *str;
|
||||
|
||||
} in2str[] =
|
||||
{
|
||||
{ IN_ACCESS, "IN_ACCESS" }, /* File was accessed (read) */
|
||||
{ IN_ATTRIB, "IN_ATTRIB" }, /* Metadata changed, e.g., permissions, timestamps, extended attributes, link count, UID, GID, etc. */
|
||||
{ IN_CLOSE_WRITE, "IN_CLOSE_WRITE" }, /* File opened for writing was closed */
|
||||
{ IN_CLOSE_NOWRITE, "IN_CLOSE_NOWRITE" }, /* File not opened for writing was closed */
|
||||
{ IN_CREATE, "IN_CREATE" }, /* File/directory created in watched directory */
|
||||
{ IN_DELETE, "IN_DELETE" }, /* File/directory deleted from watched directory */
|
||||
{ IN_DELETE_SELF, "IN_DELETE_SELF" }, /* Watched file/directory was itself deleted */
|
||||
{ IN_MODIFY, "IN_MODIFY" }, /* File was modified */
|
||||
{ IN_MOVE_SELF, "IN_MOVE_SELF" }, /* Watched file/directory was itself moved */
|
||||
{ IN_MOVED_FROM, "IN_MOVED_FROM" }, /* Generated for the directory containing the old filename when a file is renamed */
|
||||
{ IN_MOVED_TO, "IN_MOVED_TO" }, /* Generated for the directory containing the new filename when a file is renamed */
|
||||
{ IN_OPEN, "IN_OPEN" }, /* File was opened */
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
char *inomask2str(uint32_t mask, char *dst)
|
||||
{
|
||||
const char *src;
|
||||
int i,n = 0;
|
||||
|
||||
for(i=0;in2str[i].str;i++)
|
||||
{
|
||||
if ((mask & in2str[i].value) == in2str[i].value)
|
||||
{
|
||||
if (n)
|
||||
dst[n++] = '|';
|
||||
src = in2str[i].str;
|
||||
for(;src[n];n++)
|
||||
dst[n] = src[n];
|
||||
}
|
||||
}
|
||||
dst[n] = 0;
|
||||
return(dst);
|
||||
}
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
int ino;
|
||||
|
||||
void monitor_fs(const char *file)
|
||||
{
|
||||
struct inotify_event *ivent;
|
||||
|
||||
ino = inotify_init();
|
||||
inotify_add_watch(ino,file,IN_ALL_EVENTS);
|
||||
#ifdef DEBUG
|
||||
debug("(monitor_fs) added notifier on %s [fd %i]\n",file,ino);
|
||||
debug("(do_cpuinfo) %s%s%s, loadavg: %.2f(1m) %.2f(5m) %.2f(15m)",
|
||||
omni+1,bogostr,cpustr,(loads[0]),(loads[1]),(loads[2]));
|
||||
#endif
|
||||
to_user_q(from,"%s%s%s, loadavg: %.2f(1m) %.2f(5m) %.2f(15m)",
|
||||
omni+1,bogostr,cpustr,(loads[0]),(loads[1]),(loads[2]));
|
||||
}
|
||||
|
||||
void select_monitor()
|
||||
void do_filemon(COMMAND_ARGS)
|
||||
{
|
||||
FD_SET(ino,&read_fds);
|
||||
}
|
||||
struct stat st;
|
||||
|
||||
void process_monitor()
|
||||
{
|
||||
struct inotify_event *ivent;
|
||||
char tmp[256];
|
||||
int n;
|
||||
|
||||
if (FD_ISSET(ino,&read_fds))
|
||||
{
|
||||
ivent = (struct inotify_event *)&globaldata;
|
||||
|
||||
n = read(ino,globaldata,sizeof(struct inotify_event));
|
||||
if (ivent->len > 0)
|
||||
read(ino,ivent->name,ivent->len);
|
||||
else
|
||||
*ivent->name = 0;
|
||||
#ifdef DEBUG
|
||||
debug("ino %i, n %i, sz %i\n",ino,n,sizeof(in2str));
|
||||
debug("wd %i, mask %lu, cookie %lu, len %lu, name %s\n",
|
||||
ivent->wd,ivent->mask,ivent->cookie,ivent->len,ivent->name);
|
||||
debug("%s\n",inomask2str(ivent->mask,tmp));
|
||||
debug("(process_monitor) ino %i bytes read, int wd = %i, uint32_t mask = %s (%lu), uint32_t cookie = %lu, uint32_t len = %lu, char name = %s\n",
|
||||
n,ivent->wd,inomask2str(ivent->mask,tmp),ivent->mask,ivent->cookie,ivent->len,ivent->name);
|
||||
debug("(do_filemon) rest = '%s'\n",rest);
|
||||
#endif
|
||||
if ((ivent->mask & IN_CLOSE_WRITE) == IN_CLOSE_WRITE)
|
||||
return;
|
||||
send_global(SPYSTR_SYSMON,"Alert: Executable was touched");
|
||||
|
||||
if (stat(rest,&st) < 0 || monitor_fs(rest) < 0)
|
||||
{
|
||||
to_user_q(from,"Unable to add file monitor for: ``%s''",rest);
|
||||
return;
|
||||
}
|
||||
to_user_q(from,"File monitor added.");
|
||||
}
|
||||
|
||||
#endif /* HOSTINFO */
|
||||
|
||||
|
||||
4
src/io.c
4
src/io.c
@ -501,6 +501,10 @@ void to_user(const char *target, const char *format, ...)
|
||||
/*
|
||||
* Read any data waiting on a socket or file descriptor
|
||||
* and return any complete lines to the caller
|
||||
*
|
||||
* 1: Try to get a whole line from <rest> data
|
||||
* 2: If <rest> data is insufficient, try to read in more
|
||||
* 3: Try again to make a whole line
|
||||
*/
|
||||
char *sockread(int s, char *rest, char *line)
|
||||
{
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#include "alias.c"
|
||||
#include "auth.c"
|
||||
#include "bounce.c"
|
||||
#include "calc.c"
|
||||
#include "channel.c"
|
||||
#include "core.c"
|
||||
#include "ctcp.c"
|
||||
|
||||
@ -664,6 +664,7 @@ recheck_alias:
|
||||
{
|
||||
if (mcmd[i].lbuf && ischannel(orig_to))
|
||||
{
|
||||
set_mallocdoer(on_msg);
|
||||
redirect.to = stringdup(to);
|
||||
redirect.method = R_PRIVMSG;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Parts Copyright (c) 1997-2018 proton
|
||||
Parts Copyright (c) 1997-2021 proton
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -1468,8 +1468,8 @@ void parse_server_input(char *rest)
|
||||
uint32_t cmdhash;
|
||||
int i;
|
||||
|
||||
if (current->spy & SPYF_RAWIRC)
|
||||
send_spy(SPYSTR_RAWIRC,FMT_PLAIN,rest);
|
||||
if (current->spy & (SPYF_RAWIRC|SPYF_RANDSRC))
|
||||
send_spy(SPYSTR_RAWIRC,rest);
|
||||
|
||||
/*new undernet amusements */
|
||||
/*(in) {5} NOTICE AUTH :*** You have identd disabled (or broken), to continue to connect you must type /QUOTE PASS 17071 */
|
||||
|
||||
145
src/spy.c
145
src/spy.c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Parts Copyright (c) 1997-2018 proton
|
||||
Parts Copyright (c) 1997-2021 proton
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -45,10 +45,31 @@ LS const char SPY_DEFS[][12] =
|
||||
"SPY_BOTNET",
|
||||
"SPY_URL",
|
||||
"SPY_SYSMON",
|
||||
"SPY_RANDSRC",
|
||||
};
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
static int basepos(char c)
|
||||
{
|
||||
/*
|
||||
-lcrypt converts to [a-zA-Z0-9./]
|
||||
included sha1 converts to hex
|
||||
included md5 converts to [./0-9A-Za-z]
|
||||
*/
|
||||
if (c >= 'a' && c <= 'z')
|
||||
return(c - 'a');
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
return(c - 'A' + 26);
|
||||
if (c >= '0' && c <= '9')
|
||||
return(c - '0' + 52);
|
||||
if (c == '.')
|
||||
return(62);
|
||||
if (c == '/')
|
||||
return(63);
|
||||
return(0);
|
||||
}
|
||||
|
||||
void send_spy(const char *src, const char *format, ...)
|
||||
{
|
||||
Chan *chan;
|
||||
@ -56,11 +77,26 @@ void send_spy(const char *src, const char *format, ...)
|
||||
Spy *spy;
|
||||
va_list msg;
|
||||
const char *tempsrc;
|
||||
char tempdata[MAXLEN];
|
||||
int fd;
|
||||
const char *printmsg;
|
||||
char tempdata[MAXLEN],*rnd,*dst,*end;
|
||||
int fd,a,b,c,d;
|
||||
int printed = FALSE;
|
||||
|
||||
tempsrc = (src == SPYSTR_STATUS) ? time2medium(now) : src;
|
||||
if (src == SPYSTR_RAWIRC)
|
||||
{
|
||||
tempsrc = printmsg = format;
|
||||
printed = TRUE;
|
||||
format = FMT_PLAIN;
|
||||
}
|
||||
else
|
||||
if (src == SPYSTR_STATUS)
|
||||
{
|
||||
tempsrc = time2medium(now);
|
||||
}
|
||||
else
|
||||
{
|
||||
tempsrc = src;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
debug("(send_spy) src %s format = '%s'\n",src,format);
|
||||
@ -68,6 +104,72 @@ void send_spy(const char *src, const char *format, ...)
|
||||
|
||||
for(spy=current->spylist;spy;spy=spy->next)
|
||||
{
|
||||
if (spy->t_src == SPY_RANDSRC)
|
||||
{
|
||||
if (src != SPYSTR_RAWIRC)
|
||||
continue;
|
||||
/* dont use four char server messages such as "PING :..." */
|
||||
if (tempsrc[5] == ':')
|
||||
#ifdef DEBUG
|
||||
{
|
||||
debug("(send_spy) RANDSRC: skipping four char server message\n");
|
||||
#endif /* DEBUG */
|
||||
continue;
|
||||
#ifdef DEBUG
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
if (spy->data.delay > now)
|
||||
continue;
|
||||
spy->data.delay = now + 10 + RANDOM(0,9); /* make it unpredictable which messages will be sourced */
|
||||
|
||||
/*
|
||||
$6$ for sha512, $1$ for MD5
|
||||
MD5 | 22 characters
|
||||
SHA-512 | 86 characters
|
||||
*/
|
||||
#ifdef SHACRYPT
|
||||
sprintf(tempdata,"$6$%04x",(now & 0xFFFF));
|
||||
rnd = CRYPT_FUNC(tempsrc,tempdata);
|
||||
#endif /* SHACRYPT */
|
||||
|
||||
#if !defined(SHACRYPT) && defined(MD5CRYPT)
|
||||
sprintf(tempdata,"$1$%04x",(now & 0xFFFF));
|
||||
rnd = CRYPT_FUNC(tempsrc,tempdata);
|
||||
#endif /* !SHACRYPT && MD5CRYPT */
|
||||
|
||||
dst = tempdata;
|
||||
end = STREND(rnd);
|
||||
#if defined(SHACRYPT) || defined(MD5CRYPT)
|
||||
rnd += 8; /* skip salt */
|
||||
#endif
|
||||
while(rnd < (end - 3))
|
||||
{
|
||||
/* base64 to bin, 4 chars to 3 */
|
||||
a = basepos(rnd[0]);
|
||||
b = basepos(rnd[1]);
|
||||
dst[0] = (a << 2) | (b >> 4); /* aaaaaabb */
|
||||
c = basepos(rnd[2]);
|
||||
dst[1] = (b << 4) | (c >> 2); /* bbbbcccc */
|
||||
d = basepos(rnd[3]);
|
||||
dst[2] = (c << 6) | (d); /* ccdddddd */
|
||||
dst += 3;
|
||||
rnd += 4;
|
||||
}
|
||||
if ((dst - tempdata) > 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
debug("(send_spy) randsrc got %i bytes\n",dst - tempdata);
|
||||
#endif /* DEBUG */
|
||||
if ((fd = open(spy->dest,O_WRONLY|O_CREAT|O_APPEND,NEWFILEMODE)) >= 0)
|
||||
{
|
||||
write(fd,tempdata,dst - tempdata);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((*src == '#' || *src == '*') && spy->t_src == SPY_CHANNEL)
|
||||
{
|
||||
if ((*src != '*') && stringcasecmp(spy->src,src))
|
||||
@ -91,22 +193,23 @@ void send_spy(const char *src, const char *format, ...)
|
||||
va_start(msg,format);
|
||||
vsprintf(tempdata,format,msg);
|
||||
va_end(msg);
|
||||
printmsg = tempdata;
|
||||
}
|
||||
|
||||
switch(spy->t_dest)
|
||||
{
|
||||
case SPY_DCC:
|
||||
to_file(spy->dcc->sock,"[%s] %s\n",tempsrc,tempdata);
|
||||
to_file(spy->data.dcc->sock,"[%s] %s\n",tempsrc,printmsg);
|
||||
break;
|
||||
case SPY_CHANNEL:
|
||||
if (spy->destbot >= 0)
|
||||
if (spy->data.destbot >= 0)
|
||||
{
|
||||
backup = current;
|
||||
for(current=botlist;current;current=current->next)
|
||||
{
|
||||
if (current->guid == spy->destbot)
|
||||
if (current->guid == spy->data.destbot)
|
||||
{
|
||||
to_server("PRIVMSG %s :[%s] %s\n",spy->dest,tempsrc,tempdata);
|
||||
to_server("PRIVMSG %s :[%s] %s\n",spy->dest,tempsrc,printmsg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -114,13 +217,13 @@ void send_spy(const char *src, const char *format, ...)
|
||||
}
|
||||
else
|
||||
{
|
||||
to_user(spy->dest,"[%s] %s",tempsrc,tempdata);
|
||||
to_user(spy->dest,"[%s] %s",tempsrc,printmsg);
|
||||
}
|
||||
break;
|
||||
case SPY_FILE:
|
||||
if ((fd = open(spy->dest,O_WRONLY|O_CREAT|O_APPEND,NEWFILEMODE)) >= 0)
|
||||
{
|
||||
to_file(fd,"[%s] %s\n",logtime(now),tempdata);
|
||||
to_file(fd,"[%s] %s\n",logtime(now),printmsg);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
@ -182,6 +285,7 @@ struct
|
||||
#ifdef HOSTINFO
|
||||
{ SPYSTR_SYSMON, SPY_SYSMON },
|
||||
#endif
|
||||
{ SPYSTR_RANDSRC, SPY_RANDSRC },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
@ -238,6 +342,7 @@ int begin_redirect(char *from, char *args)
|
||||
{
|
||||
if (find_channel_ac(nick))
|
||||
{
|
||||
set_mallocdoer(begin_redirect);
|
||||
redirect.to = stringdup(nick);
|
||||
redirect.method = R_PRIVMSG;
|
||||
return(0);
|
||||
@ -263,12 +368,14 @@ int begin_redirect(char *from, char *args)
|
||||
to_user(from,"Bad filename.");
|
||||
return(-1);
|
||||
}
|
||||
set_mallocdoer(begin_redirect);
|
||||
redirect.to = stringdup(nick);
|
||||
redirect.method = R_FILE;
|
||||
return(0);
|
||||
}
|
||||
if ((pt = find_nuh(nick)))
|
||||
{
|
||||
set_mallocdoer(begin_redirect);
|
||||
redirect.to = stringdup(nick);
|
||||
redirect.method = R_NOTICE;
|
||||
return(0);
|
||||
@ -488,7 +595,7 @@ void stats_plusminususer(Chan *chan, int plusminus)
|
||||
*/
|
||||
|
||||
/*
|
||||
help:SPY:[STATUS|MESSAGE|RAWIRC|URL|[guid:|botnick:] [channel|> filename]
|
||||
help:SPY:[STATUS|MESSAGE|RAWIRC|URL|RANDSRC|[guid:|botnick:] [channel|> filename]
|
||||
|
||||
Spy on a certain source of messages. When you join DCC chat,
|
||||
the STATUS source is added by default as a spy source for you.
|
||||
@ -501,6 +608,7 @@ excess flood if not careful.
|
||||
MESSAGE Pivate messages that the bot receives.
|
||||
RAWIRC Lines received from irc server before processing.
|
||||
URL URLs seen by the bot.
|
||||
RANDSRC Produce random data from <RAWIRC>, can only output to file.
|
||||
guid: Messages from a bot specified by guid.
|
||||
botnick: Messages from a bot specified by nick.
|
||||
channel Activities on the specified channel.
|
||||
@ -509,7 +617,6 @@ excess flood if not careful.
|
||||
(none) Send output to you (default).
|
||||
channel Send output to the specified channel.
|
||||
>file Send output to file. Lines are appended to the end of the file.
|
||||
This file needs to exist before logging to it.
|
||||
|
||||
See also: rspy
|
||||
*/
|
||||
@ -682,6 +789,12 @@ spy_dest_ok:
|
||||
}
|
||||
}
|
||||
|
||||
if (t_src == SPY_RANDSRC && t_dest != SPY_FILE)
|
||||
{
|
||||
to_user(from,"Randsrc data can only be written to a file.");
|
||||
return;
|
||||
}
|
||||
|
||||
set_mallocdoer(do_spy);
|
||||
|
||||
sz = sizeof(Spy);
|
||||
@ -702,7 +815,7 @@ spy_dest_ok:
|
||||
else
|
||||
{
|
||||
spy->dest = CurrentDCC->user->name;
|
||||
spy->dcc = CurrentDCC;
|
||||
spy->data.dcc = CurrentDCC;
|
||||
spy->src = spy->p;
|
||||
}
|
||||
|
||||
@ -726,7 +839,7 @@ spy_dest_ok:
|
||||
{
|
||||
if (destbot)
|
||||
{
|
||||
spy->destbot = current->guid;
|
||||
spy->data.destbot = current->guid;
|
||||
spy->next = destbot->spylist;
|
||||
destbot->spylist = spy;
|
||||
spy_typecount(destbot);
|
||||
@ -734,11 +847,13 @@ spy_dest_ok:
|
||||
}
|
||||
else
|
||||
{
|
||||
spy->destbot = -1;
|
||||
spy->data.destbot = -1;
|
||||
spy->next = current->spylist;
|
||||
current->spylist = spy;
|
||||
spy_typecount(current);
|
||||
}
|
||||
if (t_src == SPY_RANDSRC)
|
||||
spy->data.delay = 0;
|
||||
|
||||
switch(t_src)
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Parts Copyright (c) 1997-2018 proton
|
||||
Parts Copyright (c) 1997-2020 proton
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -477,8 +477,13 @@ typedef struct Spy
|
||||
int t_src;
|
||||
int t_dest;
|
||||
|
||||
Client *dcc;
|
||||
int destbot;
|
||||
union
|
||||
{
|
||||
Client *dcc; /* DCC */
|
||||
int destbot; /* botnet */
|
||||
time_t delay; /* randsrc */
|
||||
|
||||
} data;
|
||||
|
||||
const char *src;
|
||||
char *dest;
|
||||
@ -514,6 +519,15 @@ typedef struct ServerGroup
|
||||
|
||||
} ServerGroup;
|
||||
|
||||
typedef struct FileMon
|
||||
{
|
||||
struct FileMon *next;
|
||||
int fd;
|
||||
time_t nospam;
|
||||
char filename[1];
|
||||
|
||||
} FileMon;
|
||||
|
||||
typedef struct Mech
|
||||
{
|
||||
struct Mech *next;
|
||||
@ -559,17 +573,14 @@ typedef struct Mech
|
||||
Shit *shitlist;
|
||||
KickSay *kicklist;
|
||||
IReq *parselist;
|
||||
|
||||
#ifdef NOTIFY
|
||||
Notify *notifylist;
|
||||
#endif /* NOTIFY */
|
||||
|
||||
Spy *spylist;
|
||||
int spy;
|
||||
|
||||
#ifdef NOTIFY
|
||||
Notify *notifylist;
|
||||
time_t lastnotify; /* ... */
|
||||
#endif /* NOTIFY */
|
||||
|
||||
time_t lastreset; /* last time bot was reset */
|
||||
time_t lastantiidle; /* avoid showing large idle times */
|
||||
time_t lastrejoin; /* last time channels were reset */
|
||||
|
||||
12
src/web.c
12
src/web.c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Copyright (c) 1997-2001 proton
|
||||
Copyright (c) 1997-2021 proton
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -291,6 +291,7 @@ void web_raw(WebSock *client, char *url)
|
||||
#ifdef DEBUG
|
||||
debug("(web_raw) file open for reading `%s'\n",path);
|
||||
#endif /* DEBUG */
|
||||
set_mallocdoer(web_raw);
|
||||
src = Calloc(sz+1);
|
||||
read(fd,src,sz);
|
||||
if (eml)
|
||||
@ -390,7 +391,7 @@ void web_404(WebSock *client, char *url)
|
||||
url);
|
||||
}
|
||||
|
||||
void parse(WebSock *client, char *rest)
|
||||
void parse_web(WebSock *client, char *rest)
|
||||
{
|
||||
char *method,*url,*proto;
|
||||
int i;
|
||||
@ -415,6 +416,7 @@ void parse(WebSock *client, char *rest)
|
||||
break;
|
||||
}
|
||||
}
|
||||
set_mallocdoer(parse_web);
|
||||
client->url = stringdup(url);
|
||||
client->status = WEB_WAITCR;
|
||||
break;
|
||||
@ -422,7 +424,7 @@ void parse(WebSock *client, char *rest)
|
||||
if (*rest == 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
debug("(web.c->parse) web document output\n");
|
||||
debug("(parse_web) web document output\n");
|
||||
#endif /* DEBUG */
|
||||
if (client->docptr)
|
||||
client->docptr->proc(client,client->url);
|
||||
@ -441,7 +443,7 @@ void select_web(void)
|
||||
websock = SockListener(webport);
|
||||
#ifdef DEBUG
|
||||
if (websock != -1)
|
||||
debug("(web_select) websock is active (%i)\n",webport);
|
||||
debug("(select_web) websock is active (%i)\n",webport);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
@ -487,7 +489,7 @@ read_again:
|
||||
rest = webread(client->sock,client->sockdata,linebuf);
|
||||
if (rest)
|
||||
{
|
||||
parse(client,rest);
|
||||
parse_web(client,rest);
|
||||
goto read_again;
|
||||
}
|
||||
switch(errno)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user