213 lines
5.5 KiB
Perl
213 lines
5.5 KiB
Perl
|
# Local defines
|
||
|
|
||
|
# The filter_hub() subroutine should
|
||
|
#
|
||
|
# usage example:
|
||
|
# ==============
|
||
|
# BEGIN{ require "filter-hub.pl" }
|
||
|
# sub filter() {
|
||
|
# my $r=filter_hub();
|
||
|
# return $r if( length($r)>0 );
|
||
|
# ...some other functions...
|
||
|
# }
|
||
|
# sub process_pkt{}
|
||
|
# sub after_unpack{}
|
||
|
# sub before_pack{}
|
||
|
# sub pkt_done{}
|
||
|
# sub scan{}
|
||
|
# sub route{}
|
||
|
# sub hpt_exit{}
|
||
|
# ==============
|
||
|
|
||
|
#use strict;
|
||
|
|
||
|
# predefined variables
|
||
|
#my($fromname, $toname, $fromaddr, $toaddr, $subject, $date, $text, $attr);
|
||
|
#my($secure, $pktname, $rc, $res, $area, $pktfrom, $addr, $from);
|
||
|
#my($kill, $change, $flavour);
|
||
|
|
||
|
# My global variables
|
||
|
|
||
|
sub filter_hub
|
||
|
{
|
||
|
if ($DEBUG_MODE==1) {
|
||
|
w_log('1','filter-hub.pl: filter_hub()');
|
||
|
}
|
||
|
|
||
|
# EchoMail Processing
|
||
|
if (defined($area)) {
|
||
|
w_log('J','No checking for echomail!');
|
||
|
return '';
|
||
|
}
|
||
|
|
||
|
# Validate netmail routing
|
||
|
w_log('L',"Netmail: From [$fromaddr] to [$toaddr]");
|
||
|
|
||
|
# Check if Netmail is to me or a point of mine
|
||
|
if (grep(/^$toaddr$/,@{$config{addr}}))
|
||
|
{
|
||
|
w_log('1',"Netmail: To the HUB address [$toaddr] (To:$toname <- From:$fromname).");
|
||
|
|
||
|
# Ping messages
|
||
|
if ($toname =~ /^ping$/i) {
|
||
|
w_log('L',"Netmail: PING from [$fromaddr].");
|
||
|
|
||
|
if ($attr & $MSG_RRCT) {
|
||
|
putMsgInArea('BADMAIL',$fromname,$toname,$fromaddr,$toaddr,$subject,$date,($MSG_SENT | $MSG_READ | $MSG_PRIVATE),
|
||
|
"hpt> Ping request with RRC\r".$text,0);
|
||
|
|
||
|
if ($DEBUG_MODE) {
|
||
|
return '';
|
||
|
}
|
||
|
|
||
|
$kill = 1;
|
||
|
return 'Ping request with RRC';
|
||
|
}
|
||
|
|
||
|
$text =~ s/\r\x01/\r\@/gs;
|
||
|
$text =~ s/^\x01/\@/s;
|
||
|
$time = localtime;
|
||
|
$text = <<EOF;
|
||
|
Hello $fromname,
|
||
|
|
||
|
Your PING message received by my system at $time.
|
||
|
|
||
|
Original message:
|
||
|
============================================================================
|
||
|
From : $fromname ($fromaddr)
|
||
|
To : $toname ($toaddr)
|
||
|
Subject: $subject
|
||
|
Date : $date
|
||
|
----------------------------------------------------------------------------
|
||
|
$text
|
||
|
============================================================================
|
||
|
EOF
|
||
|
|
||
|
putMsgInArea('',$FILTER_FROM,$fromname,$toaddr,$fromaddr,'Ping Reply','',($MSG_PRIVATE | $MSG_LOCAL | $MSG_RRCT),add_tz($text),1);
|
||
|
$newnet = 1;
|
||
|
|
||
|
if ($DEBUG_MODE) {
|
||
|
return '';
|
||
|
}
|
||
|
|
||
|
$kill = 1;
|
||
|
return "Ping from $fromaddr";
|
||
|
|
||
|
} elsif ($toname =~ /^(area|file)fix$/i) {
|
||
|
w_log('L',"Netmail: *FIX. [$fromaddr]");
|
||
|
|
||
|
if ($attr & $MSG_RRCT) {
|
||
|
putMsgInArea('BADMAIL',$fromname,$toname,$fromaddr,$toaddr,$subject,$date,($MSG_SENT | $MSG_READ | $MSG_PRIVATE),
|
||
|
"hpt> $toname request with RRC\r" . $text, 0);
|
||
|
|
||
|
if ($DEBUG_MODE) {
|
||
|
return '';
|
||
|
}
|
||
|
|
||
|
$kill = 1;
|
||
|
return "$toname request with RRC";
|
||
|
}
|
||
|
|
||
|
if (lc($toname) eq 'filefix')
|
||
|
{
|
||
|
putMsgInArea('robots',$fromname,$toname,$fromaddr,$toaddr,$subject,$date,($MSG_PRIVATE),
|
||
|
$text, 0);
|
||
|
w_log('L',"Netmail: *FIX. Copied to robots [$fromaddr]");
|
||
|
|
||
|
$newhtick = 1;
|
||
|
|
||
|
$kill = 1;
|
||
|
}
|
||
|
|
||
|
# Messages to *fix are OK
|
||
|
return '';
|
||
|
|
||
|
} elsif ($fromname =~ /^rexfix$/i) {
|
||
|
w_log('L',"Netmail: From REXFIX. [$fromaddr]");
|
||
|
|
||
|
# Messages from rexfix are OK
|
||
|
return '';
|
||
|
|
||
|
} elsif ($toname =~ /^(coordinator)$/i) {
|
||
|
w_log('L',"Netmail: MAKENL Processing. [$fromaddr] ($attr)");
|
||
|
|
||
|
if ($ROUTE_NOTICE) {
|
||
|
putMsgInArea($ROUTE_NOTICE,$fromname,$toname,$fromaddr,$toaddr,$subject,$date,($MSG_READ|$MSG_SENT),
|
||
|
add_tz("Unable to deliver Netmail\rhpt> Unprotected message from unlisted system.\r\r".$text),0);
|
||
|
$newecho = 1;
|
||
|
}
|
||
|
|
||
|
if ($DEBUG_MODE) {
|
||
|
return '';
|
||
|
}
|
||
|
|
||
|
$kill = 1;
|
||
|
return "$toname reply from MakeNL";
|
||
|
|
||
|
} elsif ($toname =~ /^$FILTER_FROM$/i) {
|
||
|
w_log('L',"Netmail: Message to me, how nice... [$fromaddr] ($attr)");
|
||
|
|
||
|
if ($ROUTE_NOTICE) {
|
||
|
putMsgInArea($ROUTE_NOTICE,$fromname,$toname,$fromaddr,$toaddr,$subject,$date,($MSG_READ|$MSG_SENT),
|
||
|
add_tz("I have friends!\rhpt> Netmail to me on the hub.\r\r".$text),0);
|
||
|
$newecho = 1;
|
||
|
}
|
||
|
|
||
|
# Messages to the Robot are OK
|
||
|
return '';
|
||
|
|
||
|
} else {
|
||
|
if (($attr & $MSG_RREQ) || ($attr & $MSG_RAUD)) {
|
||
|
w_log('L',"Netmail: RRQ ARQ.");
|
||
|
receipt($fromaddr, $toaddr, $fromname, $toname, $subject, $date);
|
||
|
}
|
||
|
|
||
|
w_log('L',"Netmail: To user on Hub - but nobody here? [$attr]");
|
||
|
bounce($fromname,$fromaddr,$toname,$toaddr,$date,$subject,$text,'Sorry, the HUB is unattended',$toaddr);
|
||
|
|
||
|
if ($DEBUG_MODE) {
|
||
|
return '';
|
||
|
}
|
||
|
|
||
|
$kill = 1;
|
||
|
return "Message to HUB";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return '';
|
||
|
}
|
||
|
|
||
|
# ========================================================================
|
||
|
# local functions
|
||
|
# ========================================================================
|
||
|
|
||
|
sub receipt
|
||
|
{
|
||
|
if ($DEBUG_MODE==1) {
|
||
|
w_log('1',"filter-hub.pl: receipt()");
|
||
|
}
|
||
|
|
||
|
my($fromaddr,$toaddr,$fromname,$toname,$subject,$date) = @_;
|
||
|
my($text);
|
||
|
$text = <<EOF;
|
||
|
Hello $fromname!
|
||
|
|
||
|
Your message to $toname successfully delivered.
|
||
|
|
||
|
Original message header:
|
||
|
=============================================================
|
||
|
From : $fromname ($fromaddr)
|
||
|
To : $toname ($toaddr)
|
||
|
Subject: $subject
|
||
|
Date : $date
|
||
|
=============================================================
|
||
|
EOF
|
||
|
|
||
|
putMsgInArea('',$FILTER_FROM,$fromname,$toaddr,$fromaddr,'Return Receipt Response','',($MSG_PRIVATE | $MSG_KILL | $MSG_LOCAL | $MSG_RRCT),
|
||
|
add_tz($text),1);
|
||
|
$newnet = 1;
|
||
|
}
|
||
|
|
||
|
w_log('U',"filter-hub is LOADED");
|
||
|
1;
|