+sub process_rcmd
+{
+ my ($self, $tonode, $fromnode, $user, $cmd) = @_;
+ if ($tonode eq $main::mycall) {
+ my $ref = DXUser->get_current($fromnode);
+ my $cref = Route::Node::get($fromnode);
+ Log('rcmd', 'in', $ref->{priv}, $fromnode, $cmd);
+ if ($cmd !~ /^\s*rcmd/i && $cref && $ref && $cref->call eq $ref->homenode) { # not allowed to relay RCMDS!
+ if ($ref->{priv}) { # you have to have SOME privilege, the commands have further filtering
+ $self->{remotecmd} = 1; # for the benefit of any command that needs to know
+ my $oldpriv = $self->{priv};
+ $self->{priv} = $ref->{priv}; # assume the user's privilege level
+ my @in = (DXCommandmode::run_cmd($self, $cmd));
+ $self->{priv} = $oldpriv;
+ $self->send_rcmd_reply($main::mycall, $fromnode, $user, @in);
+ delete $self->{remotecmd};
+ } else {
+ $self->send_rcmd_reply($main::mycall, $fromnode, $user, "sorry...!");
+ }
+ } else {
+ $self->send_rcmd_reply($main::mycall, $fromnode, $user, "your attempt is logged, Tut tut tut...!");
+ }
+ } else {
+ my $ref = DXUser->get_current($tonode);
+ if ($ref && $ref->is_clx) {
+ $self->route($tonode, pc84($fromnode, $tonode, $user, $cmd));
+ } else {
+ $self->route($tonode, pc34($fromnode, $tonode, $cmd));
+ }
+ }
+}
+
+sub process_rcmd_reply
+{
+ my ($self, $tonode, $fromnode, $user, $line) = @_;
+ if ($tonode eq $main::mycall) {
+ my $s = $rcmds{$fromnode};
+ if ($s) {
+ my $dxchan = DXChannel->get($s->{call});
+ my $ref = DXChannel->get($user) || $dxchan;
+ $ref->send($line) if $ref;
+ delete $rcmds{$fromnode} if !$dxchan;
+ } else {
+ # send unsolicited ones to the sysop
+ my $dxchan = DXChannel->get($main::myalias);
+ $dxchan->send($line) if $dxchan;
+ }
+ } else {
+ my $ref = DXUser->get_current($tonode);
+ if ($ref && $ref->is_clx) {
+ $self->route($tonode, pc85($fromnode, $tonode, $user, $line));
+ } else {
+ $self->route($tonode, pc35($fromnode, $tonode, $line));
+ }
+ }
+}
+
+sub send_rcmd_reply
+{
+ my $self = shift;
+ my $tonode = shift;
+ my $fromnode = shift;
+ my $user = shift;
+ while (@_) {
+ my $line = shift;
+ $line =~ s/\s*$//;
+ Log('rcmd', 'out', $fromnode, $line);
+ if ($self->is_clx) {
+ $self->send(pc85($main::mycall, $fromnode, $user, "$main::mycall:$line"));
+ } else {
+ $self->send(pc35($main::mycall, $fromnode, "$main::mycall:$line"));
+ }
+ }
+}
+