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
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 how long our session has been connected

View File

@ -241,6 +241,7 @@ abstract class Protocol
// If we are connecting to a node
if ($o->exists) {
Log::debug(sprintf('%s: + Originating a connection to [%s]',self::LOGKEY,$o->ftn));
$this->node->originate($o);
} else {

View File

@ -190,7 +190,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
// Site address, password and compatibility
$makedata .= sprintf('{EMSI}{%s}{%s}{%s}{%s}',
$this->our_addresses()->pluck('ftn')->join(' '),
$this->node->password == '-' ? '' : $this->node->password,
($this->node->password == '-') ? '' : $this->node->password,
join(',',$link_codes),
join(',',$compat_codes),
);
@ -668,7 +668,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
*/
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));
/* Step 1
@ -754,7 +754,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
$t2 = $this->client->timer_set($this->client->timer_rest($t2) >> 2);
} 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)) {
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
{
Log::debug(sprintf('%s:+ protocol_session',self::LOGKEY));
Log::debug(sprintf('%s:+ Starting EMSI Protocol Session',self::LOGKEY));
$was_req = 0;
$got_req = 0;
// Outbound session
if ($this->originate) {
Log::debug(sprintf('%s: - Outbound session',self::LOGKEY));
$this->optionSet(self::O_PUA);
//$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
} else {
Log::debug(sprintf('%s: - Inbound session',self::LOGKEY));
$rc = $this->emsi_recv(self::SM_INBOUND);
if ($rc < 0) {

View File

@ -494,7 +494,7 @@ class Address extends Model
public function check_activation(User $uo,string $code): bool
{
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));