Fix authentication for originating EMSI session with known systems

This commit is contained in:
Deon George 2023-02-11 23:06:13 +11:00
parent 0aad25c831
commit d949737608
4 changed files with 19 additions and 12 deletions

View File

@ -80,6 +80,10 @@ class Node
// The nodes password // The nodes password
case 'password': case 'password':
// If we have already authed, we'll use that password.
if ($this->ftns_authed->count())
return $this->ftns_authed->first()->session('sespass');
else
return ($this->ftns->count() && ($x=$this->ftns->first()->session('sespass'))) ? $x : '-'; return ($this->ftns->count() && ($x=$this->ftns->first()->session('sespass'))) ? $x : '-';
// Return how long our session has been connected // Return how long our session has been connected

View File

@ -241,6 +241,7 @@ abstract class Protocol
// If we are connecting to a node // If we are connecting to a node
if ($o->exists) { if ($o->exists) {
Log::debug(sprintf('%s: + Originating a connection to [%s]',self::LOGKEY,$o->ftn));
$this->node->originate($o); $this->node->originate($o);
} else { } else {
@ -259,7 +260,7 @@ abstract class Protocol
$rc = $this->protocol_init(); $rc = $this->protocol_init();
if ($rc < 0) { if ($rc < 0) {
Log::error(sprintf('%s: ! Unable to start EMSI [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:! Unable to start EMSI [%d]',self::LOGKEY,$rc));
return self::S_REDIAL | self::S_ADDTRY; return self::S_REDIAL | self::S_ADDTRY;
} }

View File

@ -190,7 +190,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
// Site address, password and compatibility // Site address, password and compatibility
$makedata .= sprintf('{EMSI}{%s}{%s}{%s}{%s}', $makedata .= sprintf('{EMSI}{%s}{%s}{%s}{%s}',
$this->our_addresses()->pluck('ftn')->join(' '), $this->our_addresses()->pluck('ftn')->join(' '),
$this->node->password == '-' ? '' : $this->node->password, ($this->node->password == '-') ? '' : $this->node->password,
join(',',$link_codes), join(',',$link_codes),
join(',',$compat_codes), join(',',$compat_codes),
); );
@ -668,7 +668,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
*/ */
private function emsi_send(): int private function emsi_send(): int
{ {
Log::debug(sprintf('%s:+ emsi_send',self::LOGKEY)); Log::debug(sprintf('%s:+ EMSI send',self::LOGKEY));
Log::debug(sprintf('%s: - STEP 1',self::LOGKEY)); Log::debug(sprintf('%s: - STEP 1',self::LOGKEY));
/* Step 1 /* Step 1
@ -723,7 +723,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
+-+------------------------------------------------------------------+ +-+------------------------------------------------------------------+
*/ */
Log::debug(sprintf('%s: - STEP 4',self::LOGKEY)); Log::debug(sprintf('%s: - STEP 4',self::LOGKEY));
while(! $this->client->timer_expired($t1)) { while (! $this->client->timer_expired($t1)) {
$ch = $this->client->read_ch(max( 1,min($this->client->timer_rest($t1),$this->client->timer_rest($t2)))); $ch = $this->client->read_ch(max( 1,min($this->client->timer_rest($t1),$this->client->timer_rest($t2))));
// Log::debug(sprintf('%s: - Got (%x) {%03d} (%c)',__METHOD__,$ch,$ch,$ch)); // Log::debug(sprintf('%s: - Got (%x) {%03d} (%c)',__METHOD__,$ch,$ch,$ch));
@ -754,7 +754,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
$t2 = $this->client->timer_set($this->client->timer_rest($t2) >> 2); $t2 = $this->client->timer_set($this->client->timer_rest($t2) >> 2);
} else if (! strncmp($p,self::EMSI_REQ,self::EMSI_SEQ_LEN)) { } else if (! strncmp($p,self::EMSI_REQ,self::EMSI_SEQ_LEN)) {
Log::notice(sprintf('%s: - Got EMSI_REQ - skipping...',self::LOGKEY)); Log::notice(sprintf('%s: - Got EMSI_REQ - skipping...',self::LOGKEY),['p'=>$p]);
} else if (! strncmp($p,self::EMSI_ACK,self::EMSI_SEQ_LEN)) { } else if (! strncmp($p,self::EMSI_ACK,self::EMSI_SEQ_LEN)) {
Log::debug(sprintf('%s: - Got EMSI_ACK',self::LOGKEY)); Log::debug(sprintf('%s: - Got EMSI_ACK',self::LOGKEY));
@ -951,13 +951,14 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
*/ */
protected function protocol_session(): int protected function protocol_session(): int
{ {
Log::debug(sprintf('%s:+ protocol_session',self::LOGKEY)); Log::debug(sprintf('%s:+ Starting EMSI Protocol Session',self::LOGKEY));
$was_req = 0; $was_req = 0;
$got_req = 0; $got_req = 0;
// Outbound session // Outbound session
if ($this->originate) { if ($this->originate) {
Log::debug(sprintf('%s: - Outbound session',self::LOGKEY));
$this->optionSet(self::O_PUA); $this->optionSet(self::O_PUA);
//$emsi_lo |= ($this->is_freq_available() <= self::FR_NOTAVAILABLE ) ? self::O_NRQ : $emsi_lo; //$emsi_lo |= ($this->is_freq_available() <= self::FR_NOTAVAILABLE ) ? self::O_NRQ : $emsi_lo;
@ -973,6 +974,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
// Inbound session // Inbound session
} else { } else {
Log::debug(sprintf('%s: - Inbound session',self::LOGKEY));
$rc = $this->emsi_recv(self::SM_INBOUND); $rc = $this->emsi_recv(self::SM_INBOUND);
if ($rc < 0) { if ($rc < 0) {

View File

@ -494,7 +494,7 @@ class Address extends Model
public function check_activation(User $uo,string $code): bool public function check_activation(User $uo,string $code): bool
{ {
try { try {
Log::info(sprintf('%s:Checking Activation code [%s] invalid for user [%d]',self::LOGKEY,$code,$uo->id)); Log::info(sprintf('%s:Checking Activation code [%s] is valid for user [%d]',self::LOGKEY,$code,$uo->id));
return ($code == $this->set_activation($uo)); return ($code == $this->set_activation($uo));