add all the basic aranea routing + local configuration broadcasts
[spider.git] / perl / Thingy / Bye.pm
1 #
2 # Bye Thingy handling
3 #
4 # $Id$
5 #
6 # Copyright (c) 2005 Dirk Koopman G1TLH
7 #
8
9 use strict;
10
11 package Thingy::Bye;
12
13 use vars qw($VERSION $BRANCH);
14
15 main::mkver($VERSION = q$Revision$);
16
17 use DXChannel;
18 use DXDebug;
19 use Verify;
20 use Thingy;
21 use Thingy::RouteFilter;
22
23 use vars qw(@ISA);
24 @ISA = qw(Thingy Thingy::RouteFilter);
25
26 sub gen_Aranea
27 {
28         my $thing = shift;
29         unless ($thing->{Aranea}) {
30                 $thing->{Aranea} = Aranea::genmsg($thing, [qw(s auth)]);
31         }
32         return $thing->{Aranea};
33 }
34
35 sub handle
36 {
37         my $thing = shift;
38         my $dxchan = shift;
39
40         # fix the interface routing
41         my $intcall = $thing->{user} || $thing->{origin};
42         if ($dxchan->{call} eq $thing->{origin}) {
43                 RouteDB::delete_interface($intcall);
44         } else {
45                 RouteDB::delete($intcall, $dxchan->{call});
46         }
47
48         # pc prot generation
49         my @pc21;
50         if (my $user = $thing->{user}) {
51                 my $parent = Route::Node->get($thing->{origin});
52                 my $uref = Route::get($user);
53                 if ($parent && $uref) {
54                         if ($uref->isa('Route::Node')) {
55                                 @pc21 = $parent->del($uref);
56                         } else {
57                                 $parent->del_user($uref);
58                                 $thing->{pc17n} = $thing->{origin};
59                                 $thing->{pc17u} = $user;
60                         }
61                 }
62         } else {
63                 my $parent = Route::get($thing->{origin});
64                 @pc21 = $parent->del_nodes if $parent;
65         }
66
67         $thing->{pc21n} = \@pc21 if @pc21;
68                 
69         $thing->broadcast($dxchan);
70 }
71
72 1;