Added mbtask command to update the MIB counters

This commit is contained in:
Michiel Broek 2007-04-30 19:04:15 +00:00
parent 77d8ffb751
commit 6a5eb09a43
11 changed files with 111 additions and 39 deletions

View File

@ -6,6 +6,9 @@ v0.91.8 26-Apr-2007
upgrade:
Make sure mbtask is restarted.
mbcico:
Added mbtask command to update the MIB counters.
mbnewusr:
Fixed loading default language for new user.

View File

@ -76,6 +76,7 @@ extern struct sockaddr_in peeraddr;
extern int most_debug;
extern int laststat;
extern int crashme;
extern int session_state;
int gotblock = 0;
@ -359,6 +360,8 @@ binkpend:
free(z_obuf);
#endif
rc = abs(rc);
if (rc)
session_state = STATE_BAD;
Syslog('+', "Binkp: session finished, rc=%d", rc);
return rc;
@ -605,8 +608,11 @@ SM_STATE(WaitOk)
if (cmd) {
if (bp.rxbuf[0] == MM_OK) {
Syslog('b', "Binkp: M_OK \"%s\"", printable(bp.rxbuf +1, 0));
if (SendPass)
if (SendPass) {
bp.Secure = TRUE;
session_state = STATE_SECURE;
} else
session_state = STATE_UNSECURE;
Syslog('+', "Binkp: %s%sprotected session", bp.CRAMflag ? "MD5 ":"", bp.Secure ? "":"un");
SM_PROCEED(Opts)
@ -902,6 +908,11 @@ SM_STATE(PwdAck)
SM_ERROR;
}
free(pw);
if (bp.Secure)
session_state = STATE_SECURE;
else
session_state = STATE_UNSECURE;
Syslog('+', "Binkp: %s%sprotected session", bp.CRAMflag ? "MD5 ":"", bp.Secure ? "":"un");
inbound_open(remote->addr, bp.Secure, TRUE);
binkp_send_command(MM_OK, "%ssecure", bp.Secure ? "":"non-");

View File

@ -4,7 +4,7 @@
* Purpose ...............: Fidonet mailer
*
*****************************************************************************
* Copyright (C) 1997-2005
* Copyright (C) 1997-2007
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -57,6 +57,7 @@ static int caller;
extern int laststat;
extern int most_debug;
extern pid_t mypid;
extern int session_state;
int emsi_local_lcodes;
int emsi_remote_lcodes;
@ -186,6 +187,11 @@ int rx_emsi(char *data)
return 0;
}
if (protect)
session_state = STATE_SECURE;
else
session_state = STATE_UNSECURE;
IsDoing("EMSI %s inb", ascfnode(remote->addr, 0x0f));
if ((emsi_remote_opts & OPT_NRQ) == 0)
@ -252,6 +258,7 @@ int tx_emsi(char *data)
}
IsDoing("EMSI %s out", ascfnode(remote->addr, 0x0f));
session_state = STATE_SECURE;
emsi_local_protos &= emsi_remote_protos;
if ((emsi_remote_opts & OPT_NRQ) == 0)

View File

@ -4,7 +4,7 @@
* Purpose ...............: Fidonet mailer
*
*****************************************************************************
* Copyright (C) 1997-2005
* Copyright (C) 1997-2007
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -55,7 +55,7 @@ static file_list *tosend;
extern int Loaded;
extern pid_t mypid;
extern char *tempinbound;
extern int session_state;
int rx_ftsc(void)
@ -286,6 +286,7 @@ SM_STATE(send_req)
Syslog('x', "rxftsc SEND_REQ count=%d", count);
if (didwazoo) {
session_state = STATE_UNSECURE;
SM_SUCCESS;
}
@ -333,11 +334,13 @@ SM_STATE(recv_req)
if (recvbark()) {
if (sentmail && rcvdmail) {
Syslog('+', "Consider session OK");
session_state = STATE_SECURE;
SM_SUCCESS;
} else {
SM_ERROR;
}
} else {
session_state = STATE_SECURE;
SM_SUCCESS;
}
@ -462,9 +465,11 @@ SM_STATE(scan_packet)
if (ghc == 0) {
Syslog('+', "Password correct, protected FTS-0001 session");
inbound_open(remote->addr, TRUE, FALSE);
session_state = STATE_SECURE;
} else {
Syslog('+', "Unsecure FTS-0001 session");
inbound_open(remote->addr, FALSE, FALSE);
session_state = STATE_UNSECURE;
}
/*
* Move the packet to the temp inbound so the we can later

View File

@ -4,7 +4,7 @@
* Purpose: Fidonet mailer
*
*****************************************************************************
* Copyright (C) 1997-2005
* Copyright (C) 1997-2007
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -73,7 +73,10 @@ char *phone;
char *flags;
extern int gotfiles;
extern int mypid;
extern unsigned int report_count;
extern int session_type;
extern int session_state;
void usage(void)
{
@ -111,6 +114,7 @@ void free_mem(void)
void die(int onsig)
{
int total = 0;
unsigned int rcvd = 0, sent = 0;
signal(onsig, SIG_IGN);
@ -127,8 +131,16 @@ void die(int onsig)
if (total < 1)
total = 1;
Syslog('+', "Sent %lu bytes, received %lu bytes, avg %d cps", sentbytes, rcvdbytes, (sentbytes + rcvdbytes) / total);
sent = sentbytes / 1024;
if (sentbytes && !sent)
sent = 1; /* If something, at least 1 KByte */
rcvd = rcvdbytes / 1024;
if (rcvdbytes && !rcvd)
rcvd = 1;
}
SockS("MSMS:6,%d,%d,%d,%d,%d,%d;", rcvd, sent, master, session_state, session_type, report_count);
if (online)
Syslog('+', "Connected %s", str_time(online));

View File

@ -4,7 +4,7 @@
* Purpose ...............: Fidonet mailer - respond to filerequests
*
*****************************************************************************
* Copyright (C) 1997-2005
* Copyright (C) 1997-2007
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -56,7 +56,7 @@ static void attach_report(file_list**);
static void add_report(char *, ...);
static char *report_text = NULL;
static unsigned int report_total = 0L;
static unsigned int report_count = 0L;
unsigned int report_count = 0L;
static int no_more = FALSE;

View File

@ -4,7 +4,7 @@
* Purpose ...............: Fidonet mailer
*
*****************************************************************************
* Copyright (C) 1997-2005
* Copyright (C) 1997-2007
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -58,7 +58,9 @@ int laststat = 0; /* Last session status with remote */
int tx_define_type(void);
int rx_define_type(void);
static int type;
int session_type = SESSION_UNKNOWN;
int session_state = STATE_BAD;
static char *data=NULL;
struct sockaddr_in peeraddr;
@ -86,7 +88,7 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
pid_t ipid, opid;
session_flags = 0;
type = tp;
session_type = tp;
nlent = nl;
if (getpeername(0,(struct sockaddr*)&peeraddr,&addrlen) == 0) {
@ -220,10 +222,10 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
remote_flags=SESSION_FNC;
if (role) {
if (type == SESSION_UNKNOWN)
if (session_type == SESSION_UNKNOWN)
(void)tx_define_type();
Syslog('+', "Start outbound %s session with %s", typestr(type), ascfnode(a,0x1f));
switch(type) {
Syslog('+', "Start outbound %s session with %s", typestr(session_type), ascfnode(a,0x1f));
switch(session_type) {
case SESSION_UNKNOWN: rc = MBERR_UNKNOWN_SESSION; break;
case SESSION_FTSC: rc = tx_ftsc(); break;
case SESSION_YOOHOO: rc = tx_yoohoo(); break;
@ -231,12 +233,12 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
case SESSION_BINKP: rc = binkp(role); break;
}
} else {
if (type == SESSION_FTSC)
if (session_type == SESSION_FTSC)
session_flags |= FTSC_XMODEM_CRC;
if (type == SESSION_UNKNOWN)
if (session_type == SESSION_UNKNOWN)
(void)rx_define_type();
Syslog('+', "Start inbound %s session", typestr(type));
switch(type) {
Syslog('+', "Start inbound %s session", typestr(session_type));
switch(session_type) {
case SESSION_UNKNOWN: rc = MBERR_UNKNOWN_SESSION; break;
case SESSION_FTSC: rc = rx_ftsc(); break;
case SESSION_YOOHOO: rc = rx_yoohoo(); break;
@ -257,6 +259,9 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
putstatus(tmpl->addr, 0, 0);
}
if (rc)
session_state = STATE_BAD;
/*
* If the socket for the telnet filter is open, close it so that the telnet filters exit.
* After that wait a little while to let the filter childs die before the main program
@ -312,7 +317,7 @@ SM_EDECL
int maybeftsc=0;
int maybeyoohoo=0;
type = SESSION_UNKNOWN;
session_type = SESSION_UNKNOWN;
ebuf[0] = '\0';
ep = ebuf;
buf[0] = '\0';
@ -382,12 +387,12 @@ SM_STATE(nextchar)
maybeyoohoo++;
if (((localoptions & NOWAZOO) == 0) && (maybeyoohoo > 1)) {
type = SESSION_YOOHOO;
session_type = SESSION_YOOHOO;
SM_SUCCESS;
}
if (maybeftsc > 1) {
type = SESSION_FTSC;
session_type = SESSION_FTSC;
SM_SUCCESS;
}
@ -441,7 +446,7 @@ SM_STATE(checkintro)
Syslog('i', "Check \"%s\" for being EMSI request",ebuf);
if (((localoptions & NOEMSI) == 0) && (strncasecmp(ebuf,"EMSI_REQA77E",12) == 0)) {
type = SESSION_EMSI;
session_type = SESSION_EMSI;
data = xstrcpy((char *)"**EMSI_REQA77E");
Syslog('i', "Sending **EMSI_INQC816 (2 times)");
PUTSTR((char *)"\r**EMSI_INQC816\r**EMSI_INQC816\r\021");
@ -495,7 +500,7 @@ SM_EDECL
int standby=0;
int datasize;
type=SESSION_UNKNOWN;
session_type=SESSION_UNKNOWN;
session_flags|=FTSC_XMODEM_CRC;
ebuf[0]='\0';
ep=ebuf;
@ -581,7 +586,7 @@ SM_STATE(nextchar)
ep = ebuf;
ebuf[0] = '\0';
if (++maybeftsc > 1) {
type = SESSION_FTSC;
session_type = SESSION_FTSC;
SM_SUCCESS;
} else {
SM_PROCEED(waitchar);
@ -591,7 +596,7 @@ SM_STATE(nextchar)
ep = ebuf;
ebuf[0] = '\0';
if (++maybeyoohoo > 1) {
type = SESSION_YOOHOO;
session_type = SESSION_YOOHOO;
SM_SUCCESS;
} else {
SM_PROCEED(waitchar);
@ -637,7 +642,7 @@ SM_STATE(checkemsi)
}
if (strncasecmp(ebuf, "EMSI_INQC816", 12) == 0) {
type = SESSION_EMSI;
session_type = SESSION_EMSI;
data = xstrcpy((char *)"**EMSI_INQC816");
SM_SUCCESS;
} else if (strncasecmp(ebuf, "EMSI_HBT", 8) == 0) {
@ -676,7 +681,7 @@ SM_STATE(getdat)
Syslog('+', "Error while reading EMSI_DAT from the caller");
SM_ERROR;
}
type = SESSION_EMSI;
session_type = SESSION_EMSI;
SM_SUCCESS;
SM_END

View File

@ -17,6 +17,10 @@
#define SESSION_SLAVE 0
#define SESSION_MASTER 1
#define STATE_SECURE 0
#define STATE_UNSECURE 1
#define STATE_BAD 2
extern node *nlent;
extern fa_list *remote;

View File

@ -4,7 +4,7 @@
* Purpose ...............: Fidonet mailer
*
*****************************************************************************
* Copyright (C) 1997-2005
* Copyright (C) 1997-2007
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -115,6 +115,8 @@ typedef struct _Hello {
extern int Loaded;
extern pid_t mypid;
extern int laststat;
extern int session_state;
Hello hello2;
Hello gethello2(unsigned char[]);
@ -214,6 +216,11 @@ int rx_yoohoo(void)
IsDoing("Inbound %s", ascfnode(remote->addr, 0x0f));
if (protect)
session_state = STATE_SECURE;
else
session_state = STATE_UNSECURE;
session_flags |= SESSION_WAZOO;
if (localcaps & DOES_HYDRA)
return hydra(0);
@ -282,6 +289,7 @@ int tx_yoohoo(void)
return MBERR_YOOHOO;
IsDoing("Outbound %s", ascfnode(remote->addr, 0x0f));
session_state = STATE_SECURE;
session_flags |= SESSION_WAZOO;
if (capabilities & DOES_HYDRA)

View File

@ -550,13 +550,14 @@ char *exe_cmd(char *in)
/*
* MIB Set Mailer Session
*
* MSMS:5,kbrcvd,kbsent,direction,state,freqs;
* MSMS:6,kbrcvd,kbsent,direction,state,freqs;
* 100:0;
*
* kbrcvd Kbytes received
* kbsent KBytes sent
* direction 0=inbount, 1=outbound
* state 0=secure, 1=unsecure, 2=badd session
* state 0=secure, 1=unsecure, 2=bad session
* type 0=unknown, 1=ftsc, 2=yoohoo, 3=emsi, 4=binkp
* freqs nr of file requests
*/
if (strncmp(cmd, "MSMS", 4) == 0) {

View File

@ -4,7 +4,7 @@
* Purpose ...............: Keep track of server status
*
*****************************************************************************
* Copyright (C) 1997-2006
* Copyright (C) 1997-2007
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -88,6 +88,10 @@ typedef struct {
unsigned int msesssecure; /* MIB mailer secure sessions */
unsigned int msessunsec; /* MIB mailer unsecure sessions */
unsigned int msessbad; /* MIB mailer bad sessions */
unsigned int mftsc; /* MIB mailer FTSC sessions */
unsigned int myoohoo; /* MIB mailer YooHoo sessions */
unsigned int memsi; /* MIB mailer EMSI sessions */
unsigned int mbinkp; /* MIB mailer Binkp sessions */
unsigned int mfreqs; /* MIB mailer file requests */
unsigned int tmsgsin; /* MIB tosser messages in */
@ -503,7 +507,7 @@ void sem_remove_r(char *data, char *buf)
void mib_set_mailer(char *data)
{
unsigned int kbrcvd, kbsent, direction, state, freqs;
unsigned int kbrcvd, kbsent, direction, state, type, freqs;
Syslog('m', "MIB set mailer %s", data);
strtok(data, ",");
@ -511,6 +515,7 @@ void mib_set_mailer(char *data)
kbsent = atoi(strtok(NULL, ","));
direction = atoi(strtok(NULL, ","));
state = atoi(strtok(NULL, ","));
type = atoi(strtok(NULL, ","));
freqs = atoi(strtok(NULL, ";"));
status.mkbrcvd += kbrcvd;
@ -524,9 +529,17 @@ void mib_set_mailer(char *data)
case 1: status.msessunsec++; break;
case 2: status.msessbad++; break;
}
switch (type) {
case 1: status.mftsc++; break;
case 2: status.myoohoo++; break;
case 3: status.memsi++; break;
case 4: status.mbinkp++; break;
}
status.mfreqs += freqs;
Syslog('m', "MIB mailer: %d %d %d %d %d %d %d %d", status.mkbrcvd, status.mkbsent, status.msessin,
status.msessout, status.msesssecure, status.msessunsec, status.msessbad, status.mfreqs);
Syslog('m', "MIB mailer: rcvd=%d sent=%d in=%d out=%d sec=%d unsec=%d bad=%d ftsc=%d yoohoo=%d emsi=%d binkp=%d freq=%d",
status.mkbrcvd, status.mkbsent, status.msessin,
status.msessout, status.msesssecure, status.msessunsec, status.msessbad,
status.mftsc, status.myoohoo, status.memsi, status.mbinkp, status.mfreqs);
status_write();
}
@ -549,7 +562,7 @@ void mib_set_netmail(char *data)
status.tnetout += out;
status.tmsgsbad += bad;
status.tnetbad += bad;
Syslog('m', "MIB netmail: %d %d %d %d %d %d", status.tmsgsin, status.tmsgsout, status.tmsgsbad,
Syslog('m', "MIB netmail: in=%d out=%d bad=%d in=%d out=%d bad=%d", status.tmsgsin, status.tmsgsout, status.tmsgsbad,
status.tnetin, status.tnetout, status.tnetbad);
status_write();
@ -574,7 +587,7 @@ void mib_set_email(char *data)
status.tmsgsbad += bad;
status.temailbad += bad;
Syslog('m', "MIB netmail: %d %d %d %d %d %d", status.tmsgsin, status.tmsgsout, status.tmsgsbad,
Syslog('m', "MIB netmail: in=%d out=%d bad=%d in=%d out=%d bad=%d", status.tmsgsin, status.tmsgsout, status.tmsgsbad,
status.temailin, status.temailout, status.temailbad);
status_write();
@ -603,7 +616,8 @@ void mib_set_news(char *data)
status.tmsgsdupe += dupe;
status.tnewsdupe += dupe;
Syslog('m', "MIB news: %d %d %d %d %d %d %d %d", status.tmsgsin, status.tmsgsout, status.tmsgsbad, status.tmsgsdupe,
Syslog('m', "MIB news: in=%d out=%d bad=%d dupe=%d in=%d out=%d bad=%d dupe=%d",
status.tmsgsin, status.tmsgsout, status.tmsgsbad, status.tmsgsdupe,
status.tnewsin, status.tnewsout, status.tnewsbad, status.tnewsdupe);
status_write();
@ -631,7 +645,8 @@ void mib_set_echo(char *data)
status.tmsgsdupe += dupe;
status.techodupe += dupe;
Syslog('m', "MIB echo: %d %d %d %d %d %d %d %d", status.tmsgsin, status.tmsgsout, status.tmsgsbad, status.tmsgsdupe,
Syslog('m', "MIB echo: in=%d out=%d bad=%d dupe=%d in=%d out=%d bad=%d dupe=%d",
status.tmsgsin, status.tmsgsout, status.tmsgsbad, status.tmsgsdupe,
status.techoin, status.techoout, status.techobad, status.techodupe);
status_write();
@ -659,7 +674,8 @@ void mib_set_files(char *data)
status.tfilesmagic += magics;
status.tfileshatched += hatched;
Syslog('m', "MIB files: %d %d %d %d %d %d", status.tfilesin, status.tfilesout, status.tfilesbad, status.tfilesdupe,
Syslog('m', "MIB files: in=%d out=%d bad=%d dupe=%d magic=%d hatch=%d",
status.tfilesin, status.tfilesout, status.tfilesbad, status.tfilesdupe,
status.tfilesmagic, status.tfileshatched);
status_write();