#!/bin/rc
#
#	usage: relay from_addr to_addr
#
#	Log is put into /sys/log/relay
#	Incomming call is relayed if and only if
#	the IP is in /sys/log/acceptdb
#
switch($#*){
case 1
	ifs='!
	' r=`{cat $net/remote} l=`{cat $net/local}{i=$r(1) p=$l(2)}
	# $i is remote ip
	# $p is local port
	logit -l relay $p $i
	if(grep -s $i /sys/log/acceptdb)
		exec connect -vK $1 |[2] logit -l relay
	echo Rejected
case 2
	exec aux/listen1 $1 /bin/relay $2
	# listen1: the network directory is passed in the environment as $net
}
