diff --git a/app/Classes/Protocol/Binkp.php b/app/Classes/Protocol/Binkp.php index 790139e..e337627 100644 --- a/app/Classes/Protocol/Binkp.php +++ b/app/Classes/Protocol/Binkp.php @@ -489,6 +489,11 @@ final class Binkp extends BaseProtocol $rc = $this->M_get($data); break; + case self::BPM_SKIP: + Log::debug(sprintf('%s:- SKIP:Remote requested to skip file [%s]',self::LOGKEY,$data)); + $rc = $this->M_skip($data); + break; + case self::BPM_GOTSKIP: Log::debug(sprintf('%s:- GOT:Remote received, or already has a file [%s]',self::LOGKEY,$data)); $rc = $this->M_gotskip($data); @@ -1008,7 +1013,45 @@ final class Binkp extends BaseProtocol } /** - * M_GOT/M_SKIP commands + * M_SKIP commands + * + * @param string $buf + * @return bool + * @throws \Exception + */ + private function M_skip(string $buf): bool + { + Log::info(sprintf('%s:+ Remote request to skip the file for now [%s]',self::LOGKEY,$buf)); + + if ($file = $this->file_parse($buf)) { + if ($this->send->nameas + && ! strncasecmp(Arr::get($file,'file.name'),$this->send->nameas,self::MAX_PATH) + && $this->send->mtime === Arr::get($file,'file.mtime') + && $this->send->size === Arr::get($file,'file.size')) + { + if ((! $this->sessionGet(self::SE_SENDFILE)) && (! $this->sessionGet(self::SE_WAITGOT))) { + Log::error(sprintf('%s:! M_skip for unknown file [%s]',self::LOGKEY,$buf)); + + } else { + Log::info(sprintf('%s:= Packet/File [%s], type [%d] skipped.',self::LOGKEY,$this->send->nameas,$this->send->type)); + $this->sessionClear(self::SE_WAITGOT|self::SE_SENDFILE); + + $this->send->close(FALSE,$this->node); + } + + } else { + Log::error(sprintf('%s:! M_skip not for our file? [%s]',self::LOGKEY,$buf)); + } + + } else { + Log::error(sprintf('%s:! UNPARSABLE file info [%s]',self::LOGKEY,$buf)); + } + + return TRUE; + } + + /** + * M_GOTSKIP command * * @param string $buf * @return bool