add localhost client aliasing on spots and PC92A
[spider.git] / perl / DXCommandmode.pm
index 01395c9052a52c429b2a27e547b608a575294689..3226399746a15385b4582544994e4c0f7b959ba9 100644 (file)
@@ -74,8 +74,11 @@ sub new
        # routing, this must go out here to prevent race condx
        my $pkg = shift;
        my $call = shift;
-#      my @rout = $main::routeroot->add_user($call, Route::here(1));
-       DXProt::_add_thingy($main::routeroot, [$call, 0, 0, 1, undef, undef, $self->hostname], );
+       #       my @rout = $main::routeroot->add_user($call, Route::here(1));
+       my $ipaddr = $self->hostname;
+       $ipaddr = $main::localhost_alias_ipv6 if $ipaddr eq '::1' && $main::localhost_alias_ipv6;
+       $ipaddr = $main::localhost_alias_ipv4 if $ipaddr =~ /^127\./ && $main::localhost_alias_ipv4;
+       DXProt::_add_thingy($main::routeroot, [$call, 0, 0, 1, undef, undef, $ipaddr], );
 
        # ALWAYS output the user
        my $ref = Route::User::get($call);
@@ -259,6 +262,7 @@ sub normal
        my $self = shift;
        my $cmdline = shift;
        my @ans;
+       my @bad;
 
        # save this for them's that need it
        my $rawline = $cmdline;
@@ -345,15 +349,14 @@ sub normal
                } elsif ($cmdline =~ m|^/+\w+|) {
                        $cmdline =~ s|^/||;
                        my $sendit = $cmdline =~ s|^/+||;
-                       my @in = $self->run_cmd($cmdline);
-                       $self->send_ans(@in);
-                       if ($sendit && $self->{talklist} && @{$self->{talklist}}) {
-                               foreach my $l (@in) {
-                                       my @bad;
-                                       if (@bad = BadWords::check($l)) {
-                                               $self->badcount(($self->badcount||0) + @bad);
-                                               LogDbg('DXCommand', "$self->{call} swore: $l with words:" . join(',', @bad) . ")");
-                                       } else {
+                       if (@bad = BadWords::check($cmdline)) {
+                               $self->badcount(($self->badcount||0) + @bad);
+                               LogDbg('DXCommand', "$self->{call} swore: '$cmdline' with badwords: '" . join(',', @bad) . "'");
+                       } else {
+                               my @in = $self->run_cmd($cmdline);
+                               $self->send_ans(@in);
+                               if ($sendit && $self->{talklist} && @{$self->{talklist}}) {
+                                       foreach my $l (@in) {
                                                for (@{$self->{talklist}}) {
                                                        if ($self->{state} eq 'talk') {
                                                                $self->send_talks($_, $l);
@@ -367,10 +370,9 @@ sub normal
                        $self->send($self->{state} eq 'talk' ? $self->talk_prompt : $self->chat_prompt);
                } elsif ($self->{talklist} && @{$self->{talklist}}) {
                        # send what has been said to whoever is in this person's talk list
-                       my @bad;
                        if (@bad = BadWords::check($cmdline)) {
                                $self->badcount(($self->badcount||0) + @bad);
-                               LogDbg('DXCommand', "$self->{call} swore: $cmdline with words:" . join(',', @bad) . ")");
+                               LogDbg('DXCommand', "$self->{call} swore: '$cmdline' with badwords: '" . join(',', @bad) . "'");
                        } else {
                                for (@{$self->{talklist}}) {
                                        if ($self->{state} eq 'talk') {
@@ -402,7 +404,12 @@ sub normal
                }
                $self->send_ans(@ans);
        } else {
-               $self->send_ans(run_cmd($self, $cmdline));
+#              if (@bad = BadWords::check($cmdline)) {
+#                      $self->badcount(($self->badcount||0) + @bad);
+#                      LogDbg('DXCommand', "$self->{call} swore: '$cmdline' with badwords: '" . join(',', @bad) . "'");
+#              } else {
+                       $self->send_ans(run_cmd($self, $cmdline));
+#              }
        } 
 
        # check for excessive swearing