mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
remove obsolete smtpap
svn:r219
This commit is contained in:
parent
96e5f776d6
commit
76e1a66196
@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
@ -1,9 +0,0 @@
|
||||
|
||||
bin_PROGRAMS = smtpap
|
||||
|
||||
smtpap_LDADD = -L../common -lor
|
||||
|
||||
smtpap_SOURCES = smtpap.c io.c
|
||||
|
||||
noinst_HEADERS = smtpap.h io.h
|
||||
|
134
src/smtpap/io.c
134
src/smtpap/io.c
@ -1,134 +0,0 @@
|
||||
#include <sys/time.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../common/log.h"
|
||||
#include "../common/utils.h"
|
||||
|
||||
#include "smtpap.h"
|
||||
#include "io.h"
|
||||
|
||||
/* connection timeout */
|
||||
extern struct timeval *conn_toutp;
|
||||
|
||||
/* printf-like function used to send messages to a socket */
|
||||
int sendmessage(int s, char *buf, size_t buflen, const char *format, ...)
|
||||
{
|
||||
int retval = 0;
|
||||
va_list ap;
|
||||
|
||||
if (!buf)
|
||||
return -1;
|
||||
|
||||
va_start(ap,format);
|
||||
retval = vsnprintf(buf,buflen, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
log(LOG_DEBUG,"sendmessage() : could not print to buffer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
log(LOG_DEBUG,"sendmessage() : printed this to buffer : %s",buf);
|
||||
|
||||
retval = write_tout(s,buf,(size_t)retval, conn_toutp);
|
||||
if (retval < 0)
|
||||
{
|
||||
log(LOG_DEBUG,"sendmessage() : could not send");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* receive a response from the recipient SMTP server into *op_in
|
||||
* Can handle multi-line responses. */
|
||||
int receive(int s, char **inbuf,size_t *inbuflen, int flags)
|
||||
{
|
||||
int inputlen = 0; /* running total length of the input */
|
||||
int inputerror = 0; /* has an error occured? */
|
||||
int retval = 0; /* used for saving function return values */
|
||||
|
||||
/* for processing multi-line responses */
|
||||
int i=0;
|
||||
|
||||
/* storing old values of *inbuf and *inbuflen */
|
||||
char *inbuf_old = NULL;
|
||||
size_t inbuflen_old=0;
|
||||
|
||||
if ((!inbuf) || (!*inbuf) || (!inbuflen))
|
||||
return -1;
|
||||
|
||||
/* saving old values in case we need to restore them */
|
||||
inbuf_old = *inbuf;
|
||||
inbuflen_old = *inbuflen;
|
||||
|
||||
do
|
||||
{
|
||||
if (inputlen == *inbuflen-1) /* we need to increase the buffer size */
|
||||
{
|
||||
/* increase the size of the buffer */
|
||||
*inbuflen += 512;
|
||||
|
||||
*inbuf = (char *)realloc(*inbuf,(size_t)*inbuflen);
|
||||
if (!*inbuf)
|
||||
{
|
||||
log(LOG_ERR,"Could not allocate memory.");
|
||||
*inbuf = inbuf_old;
|
||||
*inbuflen = inbuflen_old;
|
||||
inputerror = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
retval=read_tout(s,*inbuf+inputlen,(size_t)(*inbuflen-inputlen-1),flags, conn_toutp); /* subtract 1 from inbuflen to leave space for \0 */
|
||||
if (retval <= 0)
|
||||
{
|
||||
log(LOG_ERR,"Error occured while receiving data.");
|
||||
inputerror = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
inputerror = 0;
|
||||
inputlen += retval;
|
||||
|
||||
/* exit clause if we have received CRLF, otherwise we need to keep reading*/
|
||||
/* also keep on reading if it's a multi-line response */
|
||||
if (inputlen >= SMTPAP_CRLF_LEN)
|
||||
{
|
||||
if (!strncmp(*inbuf+inputlen-SMTPAP_CRLF_LEN,SMTPAP_CRLF,SMTPAP_CRLF_LEN)) /* entire line received */
|
||||
{
|
||||
/* now check wether we should expect more lines */
|
||||
/* find the <CRLF> sequence which occurs one before last */
|
||||
for(i=inputlen-SMTPAP_CRLF_LEN-1; i > 0; i--) /* move backwards, start just before the final CRLF */
|
||||
{
|
||||
if ((*inbuf)[i] == SMTPAP_LF) /* got a LF */
|
||||
{
|
||||
/* check for a CR preceding it */
|
||||
if ((*inbuf)[i-1] == SMTPAP_CR) /* got a CR */
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i==0) /* correct the offset if no CRLF found */
|
||||
i=-1;
|
||||
|
||||
/* check the 4th character after the <CRLF> to see if it is - or <SP> */
|
||||
if ((*inbuf)[i+4] != '-') /* no more lines */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(1);
|
||||
|
||||
if (!inputerror)
|
||||
{
|
||||
(*inbuf)[inputlen]=0; /* add the terminating NULL character */
|
||||
return inputlen;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
int sendmessage(int s, char *buf, size_t buflen, const char *format, ...);
|
||||
int receive(int s, char **inbuf,size_t *inbuflen, int flags);
|
1422
src/smtpap/smtpap.c
1422
src/smtpap/smtpap.c
File diff suppressed because it is too large
Load Diff
@ -1,90 +0,0 @@
|
||||
/**
|
||||
* smtpap.h
|
||||
* SMTP Application Proxy for Onion Routing
|
||||
*
|
||||
* Matej Pfajfar <mp292@cam.ac.uk>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changes :
|
||||
* $Log$
|
||||
* Revision 1.1 2002/06/26 22:45:50 arma
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.12 2002/01/29 01:00:10 mp292
|
||||
* All network operations are now timeoutable.
|
||||
*
|
||||
* Revision 1.11 2002/01/26 21:50:17 mp292
|
||||
* Reviewed according to Secure-Programs-HOWTO. Still need to deal with network
|
||||
* timeouts.
|
||||
*
|
||||
* Revision 1.10 2001/12/18 14:56:29 badbytes
|
||||
* *** empty log message ***
|
||||
*
|
||||
* Revision 1.9 2001/12/18 14:43:19 badbytes
|
||||
* Added DEFAULT_SMTP_PORT.
|
||||
*
|
||||
* Revision 1.8 2001/12/12 16:02:29 badbytes
|
||||
* Testing completed.
|
||||
*
|
||||
* Revision 1.7 2001/12/11 10:43:21 badbytes
|
||||
* MAIL and RCPT handling completed. Still coding connection to Onion Proxy.
|
||||
*
|
||||
* Revision 1.6 2001/12/10 16:10:35 badbytes
|
||||
* Wrote a tokenize() function to help with parsing input from SMTP clients.
|
||||
*
|
||||
* Revision 1.5 2001/12/07 15:02:43 badbytes
|
||||
* Server setup code completed.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SMTPAP_H
|
||||
|
||||
#define __SMTPAP_H
|
||||
|
||||
#define SMTPAP_CRLF "\015\012"
|
||||
#define SMTPAP_CRLF_LEN 2
|
||||
|
||||
#define SMTPAP_CR '\015'
|
||||
#define SMTPAP_LF '\012'
|
||||
|
||||
/* terminator for DATA input */
|
||||
#define SMTPAP_ENDDATA "\015\012.\015\012"
|
||||
#define SMTPAP_ENDDATA_LEN 5
|
||||
|
||||
/* characters that separate tokens in SMTPAP commands */
|
||||
#define SMTPAP_SEPCHARS " \t\015\012" /* for general commands */
|
||||
#define SMTPAP_PATH_SEPCHARS " \t\015\012<>" /* for forward and reverse path */
|
||||
|
||||
/* default listening port */
|
||||
#define SMTPAP_LISTEN_PORT 25
|
||||
|
||||
/* default SMTP port */
|
||||
#define SMTPAP_DEFAULT_SMTP_PORT 25
|
||||
|
||||
/* default connection timeout */
|
||||
#define SMTPAP_DEFAULT_CONN_TIMEOUT 120; /* 120s */
|
||||
|
||||
/* SMTP commands and their lengths */
|
||||
#define SMTPAP_QUIT "quit"
|
||||
#define SMTPAP_QUIT_LEN 4
|
||||
|
||||
#define SMTPAP_HELO "helo"
|
||||
#define SMTPAP_HELO_LEN 4
|
||||
#define SMTPAP_EHLO "ehlo"
|
||||
#define SMTPAP_EHLO_LEN 4
|
||||
|
||||
#define SMTPAP_MAIL "mail"
|
||||
#define SMTPAP_MAIL_LEN 4
|
||||
|
||||
#define SMTPAP_RSET "rset"
|
||||
#define SMTPAP_RSET_LEN 4
|
||||
|
||||
#define SMTPAP_RCPT "rcpt"
|
||||
#define SMTPAP_RCPT_LEN 4
|
||||
|
||||
#define SMTPAP_DATA "data"
|
||||
#define SMTPAP_DATA_LEN 4
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user