Code cleanup, no functional changes
This commit is contained in:
@@ -180,7 +180,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:+ binkp_hsdone',self::LOGKEY));
|
||||
|
||||
if (($this->setup->opt_nd == self::O_WE) || ($this->setup->opt_nd == self::O_THEY))
|
||||
if (($this->setup->opt_nd === self::O_WE) || ($this->setup->opt_nd === self::O_THEY))
|
||||
$this->setup->opt_nd = self::O_NO;
|
||||
|
||||
if (! $this->setup->phone)
|
||||
@@ -319,7 +319,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->rx_buf .= $this->client->read(0,$blksz-$this->rx_ptr);
|
||||
|
||||
} catch (SocketException $e) {
|
||||
if ($e->getCode() == 11) {
|
||||
if ($e->getCode() === 11) {
|
||||
// @todo We maybe should count these and abort if there are too many?
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - binkp_recv Socket EAGAIN',self::LOGKEY));
|
||||
@@ -343,7 +343,7 @@ final class Binkp extends BaseProtocol
|
||||
}
|
||||
|
||||
/*
|
||||
if ($this->setup->opt_cr == self::O_YES ) {
|
||||
if ($this->setup->opt_cr === self::O_YES ) {
|
||||
//decrypt_buf( (void *) &bp->rx_buf[bp->rx_ptr], (size_t) readsz, bp->keys_in );
|
||||
}
|
||||
*/
|
||||
@@ -357,7 +357,7 @@ final class Binkp extends BaseProtocol
|
||||
/* Received complete block */
|
||||
if ($this->rx_ptr === $blksz) {
|
||||
/* Header */
|
||||
if ($this->rx_size == -1 ) {
|
||||
if ($this->rx_size === -1 ) {
|
||||
$this->is_msg = ord(substr($this->rx_buf,0,1)) >> 7;
|
||||
$this->rx_size = ((ord(substr($this->rx_buf,0,1))&0x7f) << 8 )+ord(substr($this->rx_buf,1,1));
|
||||
$this->rx_ptr = 0;
|
||||
@@ -365,7 +365,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - binkp_recv HEADER, is_msg [%d], rx_size [%d]',self::LOGKEY,$this->is_msg,$this->rx_size));
|
||||
|
||||
if ($this->rx_size == 0)
|
||||
if ($this->rx_size === 0)
|
||||
goto ZeroLen;
|
||||
|
||||
$rc = 1;
|
||||
@@ -380,7 +380,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->mib++;
|
||||
|
||||
/* Handle zero length block */
|
||||
if ($this->rx_size == 0 ) {
|
||||
if ($this->rx_size === 0 ) {
|
||||
Log::debug(sprintf('%s:- binkp_recv Zero length msg - dropped',self::LOGKEY));
|
||||
$this->rx_size = -1;
|
||||
$this->rx_ptr = 0;
|
||||
@@ -461,7 +461,7 @@ final class Binkp extends BaseProtocol
|
||||
$rc = 1;
|
||||
}
|
||||
|
||||
if ($this->recv->filepos == $this->recv->size) {
|
||||
if ($this->recv->filepos === $this->recv->size) {
|
||||
Log::info(sprintf('%s: - Finished receiving file [%s] with size [%d]',self::LOGKEY,$this->recv->name,$this->recv->size));
|
||||
|
||||
$this->msgs(self::BPM_GOT,$this->recv->name_size_time);
|
||||
@@ -499,13 +499,13 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:+ binkp_send - tx_left [%d]',self::LOGKEY,$this->tx_left));
|
||||
|
||||
if ($this->tx_left === 0 ) { /* tx buffer is empty */
|
||||
if ($this->tx_left === 0 ) { /* tx buffer is empty */
|
||||
$this->tx_ptr = $this->tx_left = 0;
|
||||
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - binkp_send msgs [%d]',self::LOGKEY,$this->mqueue->count()));
|
||||
|
||||
if ($this->mqueue->count()) { /* there are unsent messages */
|
||||
if ($this->mqueue->count()) { /* there are unsent messages */
|
||||
while ($msg = $this->mqueue->shift()) {
|
||||
if (($msg->len+$this->tx_left) > self::MAX_BLKSIZE) {
|
||||
break;
|
||||
@@ -534,7 +534,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->tx_buf .= $data;
|
||||
|
||||
/*
|
||||
if ($this->setup->opt_cr == self::O_YES) {
|
||||
if ($this->setup->opt_cr === self::O_YES) {
|
||||
encrypt_buf($this->tx_buf,($data + BinkpMessage::BLK_HDR_SIZE),$this->keys_out);
|
||||
}
|
||||
*/
|
||||
@@ -543,11 +543,11 @@ final class Binkp extends BaseProtocol
|
||||
}
|
||||
|
||||
// @todo should this be less than BP_BLKSIZE? Since a read could return a blocksize and it could be the end of the file?
|
||||
if ($data < self::BP_BLKSIZE && $this->send->filepos == $this->send->size) {
|
||||
if (($data < self::BP_BLKSIZE) && ($this->send->filepos === $this->send->size)) {
|
||||
$this->sessionSet(self::SE_WAITGOT);
|
||||
$this->sessionClear(self::SE_SENDFILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
@@ -560,7 +560,7 @@ final class Binkp extends BaseProtocol
|
||||
Log::debug(sprintf('%s:+ sent [%d]',self::LOGKEY,$rc));
|
||||
|
||||
} catch (Exception $e) {
|
||||
if ($e->getCode() == 11)
|
||||
if ($e->getCode() === 11)
|
||||
return 1;
|
||||
|
||||
$this->socket_error = $e->getMessage();
|
||||
@@ -580,7 +580,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:= binkp_send [1]',self::LOGKEY));
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function file_parse(string $str): ?array
|
||||
@@ -589,9 +589,9 @@ final class Binkp extends BaseProtocol
|
||||
Log::debug(sprintf('%s:+ file_parse [%s]',self::LOGKEY,$str));
|
||||
|
||||
$name = $this->strsep($str,' ');
|
||||
$size = $this->strsep($str,' ');
|
||||
$time = $this->strsep($str,' ');
|
||||
$offs = $this->strsep($str,' ');
|
||||
$size = (int)$this->strsep($str,' ');
|
||||
$time = (int)$this->strsep($str,' ');
|
||||
$offs = (int)$this->strsep($str,' ');
|
||||
|
||||
if ($name && $size && $time) {
|
||||
return [
|
||||
@@ -618,7 +618,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->mqueue->push(new BinkpMessage($id,$msg_body));
|
||||
|
||||
/*
|
||||
if ($this->setup->opt_cr == self::O_YES) {
|
||||
if ($this->setup->opt_cr === self::O_YES) {
|
||||
//$this->encrypt_buf($this->bps->mqueue[$this->nmsgs]->msg,$this->bps->mqueue[$this->nmsgs]->len,$this->bps->keys_out);
|
||||
}
|
||||
*/
|
||||
@@ -634,7 +634,7 @@ final class Binkp extends BaseProtocol
|
||||
Log::debug(sprintf('%s:+ M_adr [%s]',self::LOGKEY,$buf));
|
||||
|
||||
$buf = $this->skip_blanks($buf);
|
||||
$rc = 0;
|
||||
$rc = 0;
|
||||
|
||||
while(($rem_aka = $this->strsep($buf,' '))) {
|
||||
Log::info(sprintf('%s: - Parsing AKA [%s]',self::LOGKEY,$rem_aka));
|
||||
@@ -672,7 +672,7 @@ final class Binkp extends BaseProtocol
|
||||
$rc = $this->node->aka_num;
|
||||
}
|
||||
|
||||
if ($rc == 0) {
|
||||
if ($rc === 0) {
|
||||
Log::error(sprintf('%s: ! All AKAs [%d] are busy',self::LOGKEY,$this->node->aka_num));
|
||||
|
||||
$this->msgs( self::BPM_BSY,'All AKAs are busy');
|
||||
@@ -694,7 +694,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->md_challenge) {
|
||||
$this->msgs(self::BPM_PWD,sprintf('CRAM-MD5-%s',$this->node->get_md5chal($this->md_challenge)));
|
||||
|
||||
} elseif ($this->setup->opt_md == self::O_YES ) {
|
||||
} elseif ($this->setup->opt_md === self::O_YES) {
|
||||
$this->msgs(self::BPM_ERR,'Can\'t use plaintext password');
|
||||
$this->rc = self::S_FAILURE|self::S_ADDTRY;
|
||||
|
||||
@@ -714,14 +714,14 @@ final class Binkp extends BaseProtocol
|
||||
if (! $this->originate)
|
||||
$this->msgs(self::BPM_ADR,$this->our_addresses()->pluck('ftn')->join(' '));
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function M_chat(string $buf): int
|
||||
{
|
||||
Log::debug(sprintf('%s:+ M_chat [%s]',self::LOGKEY,$buf));
|
||||
|
||||
if ($this->setup->opt_cht == self::O_YES) {
|
||||
if ($this->setup->opt_cht === self::O_YES) {
|
||||
Log::error(sprintf('%s: ! We cannot do chat',self::LOGKEY));
|
||||
|
||||
} else {
|
||||
@@ -804,9 +804,9 @@ final class Binkp extends BaseProtocol
|
||||
|
||||
// In NR mode, when we got -1 for the file offsite, the reply to our get will confirm our requested offset.
|
||||
if ($this->recv->name && ! strncasecmp(Arr::get($file,'file.name'),$this->recv->name,self::MAX_PATH)
|
||||
&& $this->recv->mtime == Arr::get($file,'file.mtime')
|
||||
&& $this->recv->size == Arr::get($file,'file.size')
|
||||
&& $this->recv->filepos == $file['offs'])
|
||||
&& $this->recv->mtime === Arr::get($file,'file.mtime')
|
||||
&& $this->recv->size === Arr::get($file,'file.size')
|
||||
&& $this->recv->filepos === $file['offs'])
|
||||
{
|
||||
$this->recv->open($this->node->address,$file['offs']<0);
|
||||
|
||||
@@ -875,8 +875,8 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->sessionGet(self::SE_SENDFILE)
|
||||
&& $this->send->sendas
|
||||
&& ! strncasecmp(Arr::get($file,'file.name'),$this->send->sendas,self::MAX_PATH)
|
||||
&& $this->send->mtime == Arr::get($file,'file.mtime')
|
||||
&& $this->send->size == Arr::get($file,'file.size'))
|
||||
&& $this->send->mtime === Arr::get($file,'file.mtime')
|
||||
&& $this->send->size === Arr::get($file,'file.size'))
|
||||
{
|
||||
if (! $this->send->seek($file['offs'])) {
|
||||
Log::error(sprintf('%s: ! Cannot send file from requested offset [%d]',self::LOGKEY,$file['offs']));
|
||||
@@ -916,8 +916,8 @@ final class Binkp extends BaseProtocol
|
||||
if ($file = $this->file_parse($buf)) {
|
||||
if ($this->send->sendas
|
||||
&& ! strncasecmp(Arr::get($file,'file.name'),$this->send->sendas,self::MAX_PATH)
|
||||
&& $this->send->mtime == Arr::get($file,'file.mtime')
|
||||
&& $this->send->size == Arr::get($file,'file.size'))
|
||||
&& $this->send->mtime === Arr::get($file,'file.mtime')
|
||||
&& $this->send->size === Arr::get($file,'file.size'))
|
||||
{
|
||||
// @todo Commit our mail transaction if the remote end confirmed receipt of the file.
|
||||
if ($this->sessionGet(self::SE_SENDFILE)) {
|
||||
@@ -983,10 +983,10 @@ final class Binkp extends BaseProtocol
|
||||
if (! $comma) {
|
||||
$this->client->speed = SocketClient::TCP_SPEED;
|
||||
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) == 'k') {
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) === 'k') {
|
||||
$this->client->speed = $spd * 1024;
|
||||
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) == 'm') {
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) === 'm') {
|
||||
$this->client->speed = $spd * 1024 * 1024;
|
||||
|
||||
} else {
|
||||
@@ -1059,7 +1059,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->setup->opt_md |= self::O_THEY;
|
||||
}
|
||||
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT)) == (self::O_THEY|self::O_WANT))
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT)) === (self::O_THEY|self::O_WANT))
|
||||
$this->setup->opt_md = self::O_YES;
|
||||
|
||||
} else { /* if ( strcmp( p, "GZ" ) || strcmp( p, "BZ2" ) || strcmp( p, "EXTCMD" )) */
|
||||
@@ -1094,7 +1094,7 @@ final class Binkp extends BaseProtocol
|
||||
|
||||
if ($this->optionGet(self::O_PWD) && $buf) {
|
||||
while (($t = $this->strsep($buf," \t")))
|
||||
if (strcmp($t,'non-secure') == 0) {
|
||||
if (strcmp($t,'non-secure') === 0) {
|
||||
Log::debug(sprintf('%s: - Non Secure',self::LOGKEY));
|
||||
|
||||
$this->setup->opt_cr = self::O_NO;
|
||||
@@ -1172,7 +1172,7 @@ final class Binkp extends BaseProtocol
|
||||
Log::notice(sprintf('%s: - Remote proposed password for us [%s]',self::LOGKEY,$buf));
|
||||
}
|
||||
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT )) == (self::O_THEY|self::O_WANT))
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT )) === (self::O_THEY|self::O_WANT))
|
||||
$this->setup->opt_md = self::O_YES;
|
||||
|
||||
if (!$have_pwd || $this->setup->opt_md != self::O_YES)
|
||||
@@ -1292,7 +1292,7 @@ final class Binkp extends BaseProtocol
|
||||
|
||||
$this->rc = ($this->originate ? (self::S_REDIAL|self::S_ADDTRY) : self::S_BUSY);
|
||||
|
||||
if ($rc == 0) {
|
||||
if ($rc === 0) {
|
||||
$this->error_close();
|
||||
$this->error = -1;
|
||||
|
||||
@@ -1309,7 +1309,7 @@ final class Binkp extends BaseProtocol
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->error == -1)
|
||||
if ($this->error === -1)
|
||||
Log::error(sprintf('%s: ! protocol_session TIMEOUT',self::LOGKEY));
|
||||
|
||||
elseif ($this->error > 0)
|
||||
@@ -1329,7 +1329,7 @@ final class Binkp extends BaseProtocol
|
||||
break;
|
||||
}
|
||||
|
||||
if (strlen($buf) == 0)
|
||||
if (strlen($buf) === 0)
|
||||
break;
|
||||
|
||||
Log::warning(sprintf('%s: - Purged (%s) [%d] bytes from input stream',self::LOGKEY,hex_dump($buf),strlen($buf)));
|
||||
@@ -1355,7 +1355,7 @@ final class Binkp extends BaseProtocol
|
||||
while ($this->isSpace(substr($str,$c,1)))
|
||||
$c++;
|
||||
|
||||
return substr($str,$c);
|
||||
return substr($str,$c);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user