basic raw PC base NP added
[spider.git] / perl / QXProt.pm
index 82cb2075d8f8196edf32524b048b96dbc7ca445c..38d878ed3b73be1ffcac23e0807a319219af0952 100644 (file)
@@ -149,15 +149,29 @@ sub frame
        return "$line^$cs";
 }
 
+sub send_frame
+{
+       my $self = shift;
+       my $origin = shift;
+       for (@_) {
+               $self->send(frame('X', undef, $origin == $main::me || $origin->is_user ? '' : $origin->call, $_));
+       }
+}
+
 sub handleI
 {
        my $self = shift;
        
        my @f = split /\^/, $_[3];
-       my $inv = Verify->new($f[7]);
-       unless ($inv->verify($f[8], $main::me->user->passphrase, $main::mycall, $self->call)) {
-               $self->sendnow('D','Sorry...');
-               $self->disconnect;
+       if ($self->passphrase && $f[7] && $f[8]) {
+               my $inv = Verify->new($f[7]);
+               unless ($inv->verify($f[8], $main::me->user->passphrase, $main::mycall, $self->call)) {
+                       $self->sendnow('D','Sorry...');
+                       $self->disconnect;
+               }
+               $self->{verified} = 1;
+       } else {
+               $self->{verified} = 0;
        }
        if ($self->{outbound}) {
                $self->send($self->genI);
@@ -175,8 +189,12 @@ sub handleI
 sub genI
 {
        my $self = shift;
-       my $inp = Verify->new;
-       return frame('I', $self->call, "DXSpider", ($main::version + 53) * 100, $main::build, $inp->challenge, $inp->response($self->user->passphrase, $self->call, $main::mycall));
+       my @out = ('I', $self->call, "DXSpider", ($main::version + 53) * 100, $main::build);
+       if (my $pass = $self->user->passphrase) {
+               my $inp = Verify->new;
+               push @out, $inp->challenge, $inp->response($pass, $self->call, $main::mycall);
+       }
+       return frame(@out);
 }
 
 sub handleR
@@ -199,39 +217,17 @@ sub genP
 
 }
 
-sub gen2
+sub handleX
 {
        my $self = shift;
-       
-       my $node = shift;
-       my $sort = shift;
-       my @out;
-       my $dxchan;
-       
-       while (@_) {
-               my $str = '';
-               for (; @_ && length $str <= 230;) {
-                       my $ref = shift;
-                       my $call = $ref->call;
-                       my $flag = 0;
-                       
-                       $flag += 1 if $ref->here;
-                       $flag += 2 if $ref->conf;
-                       if ($ref->is_node) {
-                               my $ping = int($ref->pingave * 10);
-                               $str .= "^N$flag$call,$ping";
-                               my $v = $ref->build || $ref->version;
-                               $str .= ",$v" if defined $v;
-                       } else {
-                               $str .= "^U$flag$call";
-                       }
-               }
-               push @out, $str if $str;
+       my ($tonode, $fromnode, $msgid, $line) = @_[0..3];
+       my ($origin, $l) = split /\^/, $line, 2;
+
+       my ($pcno) = $l =~ /^PC(\d\d)/;
+       if ($pcno) {
+               DXProt::normal($self, $l);
        }
-       my $n = @out;
-       my $h = get_hops(90);
-       @out = map { sprintf "PC90^%s^%X^%s%d%s^%s^", $node->call, $main::systime, $sort, --$n, $_, $h } @out;
-       return @out;
 }
 
+
 1;