From d4439a6b589b4eba76c238c4b28de730ffd6009c Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 9 Jul 2023 11:18:57 +1000 Subject: [PATCH] Dont send an M_GET when we are not in NR mode, or we are offered a file from a zero offset. --- app/Classes/File/Receive.php | 1 + app/Classes/Protocol/Binkp.php | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/Classes/File/Receive.php b/app/Classes/File/Receive.php index f6909fe..d7fd882 100644 --- a/app/Classes/File/Receive.php +++ b/app/Classes/File/Receive.php @@ -261,6 +261,7 @@ final class Receive extends Item return Protocol::FOP_SUSPEND; } else { + // @todo I dont think we are enabling resumable sessions - need to check Log::debug(sprintf('%s:- Opening [%s]',self::LOGKEY,$this->file)); } diff --git a/app/Classes/Protocol/Binkp.php b/app/Classes/Protocol/Binkp.php index c338ed3..6cde6ab 100644 --- a/app/Classes/Protocol/Binkp.php +++ b/app/Classes/Protocol/Binkp.php @@ -247,8 +247,10 @@ final class Binkp extends BaseProtocol */ // No dupes mode is preferred on BINKP 1.1 - if ($this->capGet(self::F_NODUPE,self::O_WE) || ($this->originate && $this->capGet(self::F_NOREL,self::O_WANT) && $this->node->get_versionint() > 100)) + if ($this->capGet(self::F_NODUPE,self::O_WE) || ($this->originate && $this->capGet(self::F_NOREL,self::O_WANT) && $this->node->get_versionint() > 100)) { + Log::debug(sprintf('%s:/ NR mode enabled, because we are in NDA mode, or I want NDA and the remote is version [%d]',self::LOGKEY,$this->node->get_versionint())); $this->capSet(self::F_NOREL,self::O_YES); + } $this->capSet(self::F_MULTIBATCH,(($this->node->get_versionint() > 100) || $this->capGet(self::F_MULTIBATCH,self::O_WE)) ? self::O_YES : self::O_NO); @@ -896,14 +898,14 @@ final class Binkp extends BaseProtocol case self::FOP_OK: Log::debug(sprintf('%s:- Getting file from offset [%ld]',self::LOGKEY,$file['offs'])); - $this->msgs(self::BPM_GET,sprintf('%s %ld',$this->recv->name_size_time,($file['offs'] < 0) ? 0 : $file['offs'])); + //$this->msgs(self::BPM_GET,sprintf('%s %ld',$this->recv->name_size_time,($file['offs'] < 0) ? 0 : $file['offs'])); - if ((int)$file['offs'] !== -1) { - if (! $this->capGet(self::F_NOREL,self::O_THEY)) - $this->capSet(self::F_NOREL,self::O_THEY); - - break; + if (((int)$file['offs'] !== -1) && (! $this->capGet(self::F_NOREL,self::O_THEY))) { + Log::debug(sprintf('%s:- Assuming the remote wants NR mode, since offset is [%d] and they didnt specify an OPT with it',self::LOGKEY,$file['offs'])); + $this->capSet(self::F_NOREL,self::O_THEY); } + + break; } } catch (\Exception $e) { @@ -976,7 +978,7 @@ final class Binkp extends BaseProtocol { // @todo Commit our mail transaction if the remote end confirmed receipt of the file. if ($this->sessionGet(self::SE_SENDFILE)) { - Log::debug(sprintf('%s:Packet/File [%s] sent. (%s)',self::LOGKEY,$this->send->sendas,$this->send->name)); + Log::info(sprintf('%s:= Packet/File [%s] sent.',self::LOGKEY,$this->send->name)); $this->sessionClear(self::SE_SENDFILE); $this->send->close(TRUE); @@ -984,7 +986,7 @@ final class Binkp extends BaseProtocol } if ($this->sessionGet(self::SE_WAITGOT)) { - Log::debug(sprintf('%s:Packet/File [%s] sent. (%s)',self::LOGKEY,$this->send->sendas,$this->send->name)); + Log::info(sprintf('%s:= Packet/File [%s] sent.',self::LOGKEY,$this->send->name)); $this->sessionClear(self::SE_WAITGOT); $this->send->close(TRUE); @@ -1234,7 +1236,7 @@ final class Binkp extends BaseProtocol } // We dont use crypt if we dont have an MD5 sessions - if (! $have_pwd || (! $this->capGet(self::F_MD,self::O_YES))) { + if (! $have_pwd && (! $this->capGet(self::F_MD,self::O_YES))) { Log::notice(sprintf('%s:= CRYPT disabled, since we have no password or not MD5',self::LOGKEY)); $this->capSet(self::F_CRYPT,self::O_NO); }