2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2002-01-07 19:16:03 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Ping Service
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2004-02-21 17:22:00 +00:00
|
|
|
* Copyright (C) 1997-2004
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MBSE BBS is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
2003-08-15 20:05:34 +00:00
|
|
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2001-08-17 05:46:24 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbselib.h"
|
2002-01-07 19:16:03 +00:00
|
|
|
#include "../lib/users.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/msg.h"
|
|
|
|
#include "../lib/msgtext.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbsedb.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "sendmail.h"
|
|
|
|
#include "postnetmail.h"
|
|
|
|
#include "ping.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* External declarations
|
|
|
|
*/
|
|
|
|
extern int do_quiet;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Global variables
|
|
|
|
*/
|
|
|
|
extern int net_in; /* Netmails received */
|
|
|
|
extern int net_out; /* Netmails forwarded */
|
|
|
|
extern int net_bad; /* Bad netmails (tracking errors */
|
|
|
|
extern char *msgid; /* Original message id */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ping(faddr *f, faddr *t, FILE *fp, int intransit)
|
|
|
|
{
|
2002-12-22 14:41:33 +00:00
|
|
|
int rc = 0;
|
|
|
|
char *Buf;
|
|
|
|
FILE *np;
|
|
|
|
time_t Now;
|
|
|
|
faddr *from;
|
|
|
|
|
|
|
|
Now = time(NULL);
|
|
|
|
if (SearchFidonet(f->zone))
|
|
|
|
f->domain = xstrcpy(fidonet.domain);
|
|
|
|
|
|
|
|
Syslog('+', "%s ping msg from %s", intransit ? "Intransit":"Final", ascfnode(f, 0xff));
|
2003-09-02 20:25:42 +00:00
|
|
|
Buf = calloc(MAX_LINE_LENGTH +1, sizeof(char));
|
2002-12-22 14:41:33 +00:00
|
|
|
rewind(fp);
|
|
|
|
|
|
|
|
np = tmpfile();
|
|
|
|
from = bestaka_s(f);
|
|
|
|
if (intransit) {
|
|
|
|
from->name = xstrcpy((char *)"Ping TRACE service");
|
|
|
|
} else {
|
|
|
|
from->zone = t->zone;
|
|
|
|
from->net = t->net;
|
|
|
|
from->node = t->node;
|
|
|
|
from->point = t->point;
|
|
|
|
from->name = xstrcpy((char *)"Ping service");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (f->point)
|
|
|
|
fprintf(np, "\001TOPT %d\r", f->point);
|
|
|
|
if (from->point)
|
|
|
|
fprintf(np, "\001FMPT %d\r", from->point);
|
|
|
|
fprintf(np, "\001INTL %d:%d/%d %d:%d/%d\r", f->zone, f->net, f->node, from->zone, from->net, from->node);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add MSGID, REPLY and PID
|
|
|
|
*/
|
2005-10-11 20:49:41 +00:00
|
|
|
fprintf(np, "\001MSGID: %s %08x\r", ascfnode(from, 0x1f), sequencer());
|
2003-09-02 20:25:42 +00:00
|
|
|
while ((fgets(Buf, MAX_LINE_LENGTH, fp)) != NULL) {
|
2002-12-22 14:41:33 +00:00
|
|
|
Striplf(Buf);
|
|
|
|
if (strncmp(Buf, "\001MSGID:", 7) == 0) {
|
|
|
|
fprintf(np, "\001REPLY:%s\r", Buf+7);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-12-22 14:41:33 +00:00
|
|
|
}
|
2004-02-23 16:22:38 +00:00
|
|
|
fprintf(np, "\001PID: MBSE-FIDO %s (%s-%s)\r", VERSION, OsName(), OsCPU());
|
2002-12-22 14:41:33 +00:00
|
|
|
fprintf(np, "\001TZUTC: %s\r", gmtoffset(Now));
|
|
|
|
|
|
|
|
fprintf(np, " Dear %s\r\r", MBSE_SS(f->name));
|
|
|
|
if (intransit) {
|
|
|
|
fprintf(np, "You did send a PING to %s\r", ascfnode(t, 0x1f));
|
|
|
|
fprintf(np, "This is a TRACE response from \"%s\" aka %s\r", CFG.bbs_name, ascfnode(from, 0x1f));
|
|
|
|
fprintf(np, "The time of arrival is %s\r", rfcdate(Now));
|
|
|
|
} else
|
|
|
|
fprintf(np, "Your Ping arrived here at %s\r", rfcdate(Now));
|
|
|
|
fprintf(np, "Here are all the detected Via lines of the message from you:\r\r");
|
|
|
|
fprintf(np, "======================================================================\r");
|
|
|
|
|
|
|
|
rewind(fp);
|
2003-09-02 20:25:42 +00:00
|
|
|
while ((fgets(Buf, MAX_LINE_LENGTH, fp)) != NULL) {
|
2002-12-22 14:41:33 +00:00
|
|
|
Striplf(Buf);
|
|
|
|
if (strncmp(Buf, "\1Via", 4) == 0) {
|
|
|
|
fprintf(np, "%s\r", Buf+1);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-12-22 14:41:33 +00:00
|
|
|
}
|
|
|
|
fprintf(np, "======================================================================\r");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-22 14:41:33 +00:00
|
|
|
fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name);
|
|
|
|
fprintf(np, "%s\r", TearLine());
|
|
|
|
Now = time(NULL) - (gmt_offset((time_t)0) * 60);
|
|
|
|
rc = postnetmail(np, from, f, NULL, (char *)"Re: Ping", Now, 0x0000, FALSE, from->zone, f->zone);
|
|
|
|
tidy_faddr(from);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-22 14:41:33 +00:00
|
|
|
fclose(np);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-22 14:41:33 +00:00
|
|
|
free(Buf);
|
|
|
|
return rc;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|