- # here's a bit of fun, convert incoming ann with a callsign in the first word
- # or one saying 'to <call>' to a talk if we can route to the recipient
- if ($ann_to_talk) {
- my $call = AnnTalk::is_talk_candidate($field[1], $field[3]);
- if ($call) {
- my $ref = Route::get($call);
- if ($ref) {
- my $dxchan = $ref->dxchan;
- $dxchan->talk($field[1], $call, undef, $field[3], $field[5]) if $dxchan != $self;
- return;
- }
- }
- }
+ my $node = Route::Node::get($ncall);
+ unless ($node) {
+ dbg("PCPROT: Node $ncall not in config") if isdbg('chanerr');
+ return;
+ }
+
+ # dedupe only that which we potentially process
+ if (eph_dup($line)) {
+ dbg("PCPROT: dup PC16 detected") if isdbg('chanerr');
+ return;
+ }
+
+ my $i;
+ my @rout;
+ my @new;
+ for ($i = 2; $i < $#_; $i++) {
+ my ($call, $conf, $here) = $_[$i] =~ /^(\S+) (\S) (\d)/o;
+ next unless $call && $conf && defined $here && is_callsign($call);
+ next if $call eq $main::mycall;
+
+ eph_del_regex("^PC17\\^$call\\^$ncall");
+
+ $conf = $conf eq '*';
+
+ # reject this if we think it is a node already
+ my $r = Route::Node::get($call);
+ my $u = DXUser->get_current($call) unless $r;
+ if ($r || ($u && $u->is_node)) {
+ dbg("PCPROT: $call is a node") if isdbg('chanerr');
+ next;
+ }
+
+ $r = Route::User::get($call) || Route::User::get($call);
+ $r->here($here);
+ $r->conf($conf);
+ $node->lastseen($main::systime);
+
+ push @new, $node->add_user($r);
+
+ # add this station to the user database, if required
+ $call =~ s/-\d+$//o; # remove ssid for users
+ my $user = DXUser->get_current($call);
+ $user = DXUser->new($call) if !$user;
+ $user->homenode($node->call) if !$user->homenode;
+ $user->node($node->call);
+ $user->lastin($main::systime) unless DXChannel->get($call);
+ $user->put;
+ }
+ $self->route_pc16($origin, $line, $node, @new) if @new;
+}
+
+# remove a user
+sub handle_17
+{
+ my $self = shift;
+ my $pcno = shift;
+ my $line = shift;
+ my $origin = shift;
+ my $dxchan;
+ my $ncall = $_[2];
+ my $ucall = $_[1];
+
+ eph_del_regex("^PC16\\^$ncall.*$ucall");
+
+ # do I want users from this channel?
+ unless ($self->user->wantpc16) {
+ dbg("PCPROT: don't send users to $self->{call}") if isdbg('chanerr');
+ return;
+ }
+ if ($ncall eq $main::mycall) {
+ dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr');
+ return;
+ }
+
+ # do we believe this call?
+ next unless $ncall eq $self->{call} || $self->is_believed($ncall);
+
+ my $uref = Route::User::get($ucall);
+ unless ($uref) {
+ dbg("PCPROT: Route::User $ucall not in config") if isdbg('chanerr');
+ }
+ my $node = Route::Node::get($ncall);
+ unless ($node) {
+ dbg("PCPROT: Route::Node $ncall not in config") if isdbg('chanerr');
+ }
+
+ return unless $node && $uref;