Skip to content
Snippets Groups Projects
Commit 68c39a08 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Save and restore the Telnet BINARY_TX option state separate for each direction

It's possible the client requested binary transmit in only one of the two
directions and if so, restore just the direction that was previously *not*
in binary transmit mode to NVT mode.
parent fa5321fe
No related branches found
No related tags found
No related merge requests found
Pipeline #7199 passed
...@@ -104,25 +104,23 @@ const char* sbbs_t::protcmdline(prot_t* prot, enum XFER_TYPE type) ...@@ -104,25 +104,23 @@ const char* sbbs_t::protcmdline(prot_t* prot, enum XFER_TYPE type)
return("invalid transfer type"); return("invalid transfer type");
} }
bool sbbs_t::data_transfer_begin() void sbbs_t::data_transfer_begin(uchar& local_binary_tx, uchar& remote_binary_tx)
{ {
sys_status|=SS_FILEXFER; /* disable spy during file xfer */ sys_status|=SS_FILEXFER; /* disable spy during file xfer */
bool telnet_was_nvt = telnet_is_nvt(); local_binary_tx = telnet_local_option[TELNET_BINARY_TX];
remote_binary_tx = telnet_remote_option[TELNET_BINARY_TX];
/* enable telnet binary transmission in both directions */ /* enable telnet binary transmission in both directions */
request_telnet_opt(TELNET_DO,TELNET_BINARY_TX); request_telnet_opt(TELNET_DO,TELNET_BINARY_TX);
request_telnet_opt(TELNET_WILL,TELNET_BINARY_TX); request_telnet_opt(TELNET_WILL,TELNET_BINARY_TX);
console |= CON_RAW_IN; console |= CON_RAW_IN;
return telnet_was_nvt;
} }
void sbbs_t::data_transfer_end(bool telnet_was_nvt) void sbbs_t::data_transfer_end(uchar local_binary_tx, uchar remote_binary_tx)
{ {
sys_status&=~SS_FILEXFER; sys_status&=~SS_FILEXFER;
if(telnet_was_nvt) { /* Got back to Text/NVT mode */
/* Got back to Text/NVT mode */ request_telnet_opt(local_binary_tx, TELNET_BINARY_TX);
request_telnet_opt(TELNET_DONT,TELNET_BINARY_TX); request_telnet_opt(remote_binary_tx, TELNET_BINARY_TX);
request_telnet_opt(TELNET_WONT,TELNET_BINARY_TX);
}
console &= ~CON_RAW_IN; console &= ~CON_RAW_IN;
} }
...@@ -168,11 +166,12 @@ int sbbs_t::protocol(prot_t* prot, enum XFER_TYPE type ...@@ -168,11 +166,12 @@ int sbbs_t::protocol(prot_t* prot, enum XFER_TYPE type
cmdline=cmdstr(protcmdline(prot,type), fpath, fspec, NULL, ex_mode); cmdline=cmdstr(protcmdline(prot,type), fpath, fspec, NULL, ex_mode);
SAFEPRINTF(msg,"Transferring %s",cmdline); SAFEPRINTF(msg,"Transferring %s",cmdline);
spymsg(msg); spymsg(msg);
bool was_nvt_mode = data_transfer_begin(); uchar local_binary_tx, remote_binary_tx;
data_transfer_begin(local_binary_tx, remote_binary_tx);
time_t start = time(NULL); time_t start = time(NULL);
i=external(cmdline,ex_mode,p); i=external(cmdline,ex_mode,p);
time_t end = time(NULL); time_t end = time(NULL);
data_transfer_end(was_nvt_mode); data_transfer_end(local_binary_tx, remote_binary_tx);
// Save DSZLOG to logfile // Save DSZLOG to logfile
if((stream=fnopen(NULL,protlog,O_RDONLY))!=NULL) { if((stream=fnopen(NULL,protlog,O_RDONLY))!=NULL) {
......
...@@ -539,11 +539,6 @@ public: ...@@ -539,11 +539,6 @@ public:
int telnet_rows = 0; int telnet_rows = 0;
int telnet_cols = 0; int telnet_cols = 0;
int telnet_speed = 0; int telnet_speed = 0;
bool telnet_is_nvt() {
return !(telnet_mode & TELNET_MODE_OFF)
&& telnet_local_option[TELNET_BINARY_TX] != TELNET_DO
&& telnet_remote_option[TELNET_BINARY_TX] != TELNET_WILL;
}
xpevent_t telnet_ack_event; xpevent_t telnet_ack_event;
...@@ -1174,8 +1169,8 @@ public: ...@@ -1174,8 +1169,8 @@ public:
bool bulkupload(int dirnum); bool bulkupload(int dirnum);
/* download.cpp */ /* download.cpp */
bool data_transfer_begin(void); void data_transfer_begin(uchar& local_binary_tx, uchar& remote_binary_tx);
void data_transfer_end(bool was_telnet_nvt_mode); void data_transfer_end(uchar local_binary_tx, uchar remote_binary_tx);
void downloadedfile(file_t* f); void downloadedfile(file_t* f);
void notdownloaded(off_t size, time_t elapsed); void notdownloaded(off_t size, time_t elapsed);
void downloadedbytes(off_t size, time_t elapsed); void downloadedbytes(off_t size, time_t elapsed);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment