From c1b9677bfb0617f02e81cb1e409ef322e5753eb3 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Tue, 6 Aug 2013 02:01:24 +0000 Subject: [PATCH] Merged 79's rlogin_gate() with telnet_gate(). Added new telgate flag: TG_NOLF. --- src/sbbs3/sbbs.h | 5 ++--- src/sbbs3/sbbsdefs.h | 4 +++- src/sbbs3/telgate.cpp | 40 +++++++++++++++++++++++++--------------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index 25e31e1d79..62f9af34cf 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2012 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2013 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -938,8 +938,7 @@ public: void catsyslog(int crash); /* telgate.cpp */ - void telnet_gate(char* addr, ulong mode); // See TG_* for mode bits - void rlogin_gate(char* addr, char* alias, char* pw, ulong mode); // See TG_* for mode bits + void telnet_gate(char* addr, ulong mode, char* name=NULL, char* passwd=NULL); // See TG_* for mode bits }; diff --git a/src/sbbs3/sbbsdefs.h b/src/sbbs3/sbbsdefs.h index 0dc8a81caa..9dd270e75d 100644 --- a/src/sbbs3/sbbsdefs.h +++ b/src/sbbs3/sbbsdefs.h @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2012 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2013 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -777,6 +777,8 @@ enum { /* readmail and delmailidx which types */ #define TG_RLOGIN (1<<6) /* Use BSD RLogin protocol */ #define TG_NOCHKTIME (1<<7) /* Don't check time left while gated */ #define TG_NOTERMTYPE (1<<8) /* Request client "DONT TERM_TYPE" */ +#define TG_SENDPASS (1<<9) /* Send password instead of real name (RLogin) */ +#define TG_NOLF (1<<10) /* Do not send line-feeds (opposite of TG_CRLF) */ enum { /* Values for 'mode' in listfileinfo */ FI_INFO /* Just list file information */ diff --git a/src/sbbs3/telgate.cpp b/src/sbbs3/telgate.cpp index ad8ece6908..a4fb9409c5 100644 --- a/src/sbbs3/telgate.cpp +++ b/src/sbbs3/telgate.cpp @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2013 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -38,7 +38,7 @@ #include "sbbs.h" #include "telnet.h" -void sbbs_t::telnet_gate(char* destaddr, ulong mode) +void sbbs_t::telnet_gate(char* destaddr, ulong mode, char* name, char* passwd) { char* p; uchar buf[512]; @@ -121,9 +121,15 @@ void sbbs_t::telnet_gate(char* destaddr, ulong mode) if(mode&TG_RLOGIN) { p=(char*)buf; *(p++)=0; - p+=sprintf(p,"%s",useron.alias); + p+=sprintf(p,"%s",name==NULL ? useron.alias : name); p++; // Add NULL - p+=sprintf(p,"%s",useron.pass); + if(passwd!=NULL) + p+=sprintf(p,"%s",passwd); + else if(mode&TG_SENDPASS) { + p+=sprintf(p,"%s",useron.pass); + } else { + p+=sprintf(p,"%s",useron.name); + } p++; // Add NULL p+=sprintf(p,"%s/57600",terminal); p++; // Add NULL @@ -205,21 +211,25 @@ void sbbs_t::telnet_gate(char* destaddr, ulong mode) } if(mode&TG_CRLF && buf[rd-1]=='\r') buf[rd++]='\n'; - if(!gotline && mode&TG_ECHO) { + else if(mode&TG_NOLF && buf[rd-1]=='\n') + rd--; + if(!gotline && (mode&TG_ECHO) && rd) { RingBufWrite(&outbuf,buf,rd); } } - for(attempts=0;attempts<60 && online; attempts++) /* added retry loop here, Jan-20-2003 */ - { - if((i=sendsocket(remote_socket,(char*)buf,rd))>=0) - break; - if(ERROR_VALUE!=EWOULDBLOCK) + if(rd > 0) { + for(attempts=0;attempts<60 && online; attempts++) /* added retry loop here, Jan-20-2003 */ + { + if((i=sendsocket(remote_socket,(char*)buf,rd))>=0) + break; + if(ERROR_VALUE!=EWOULDBLOCK) + break; + mswait(500); + } + if(i<0) { + lprintf(LOG_NOTICE,"!TELGATE ERROR %d sending on socket %d",ERROR_VALUE,remote_socket); break; - mswait(500); - } - if(i<0) { - lprintf(LOG_NOTICE,"!TELGATE ERROR %d sending on socket %d",ERROR_VALUE,remote_socket); - break; + } } } rd=recv(remote_socket,(char*)buf,sizeof(buf),0); -- GitLab