|> Hi all,
|>
|> I have a machine which is behind a firewall. However I can have one port of
|> the machine (any) visible to the outside. Is there a way to setup a listener
|> on that port which will connect the socket to the appropriate daemon,
|> i.e. if I receive a HELO or EHLO I would fire off sendmail on that port,
|> if a USER then connect ftpd and so on ?
|>
Well, yes of course you could set up a listener-process to wait on that port and that
listener would be able to forward its data to other 'inside'-daemons.
The main-problem is, how to figure out where to post the data to ... how do you
recognize ftp,www,telnet requests? If you know that it will be trivial ... something
like this (pseudo-c):
main()
{
l_socket = create a socket with socket();
bind l_socket to the unhidden port;
tell you os that you want to recieve some data;
endless loop
{
wait for data;
fork a new process;
if the new process {
analyse the data and decide for the right service
{
if ftp: connect to real-ftp demon
if telnet: connect to real-telnet demon
}
while there is more data in the socket
{
read from l_socket;
write to real-demon;
}
close the copy of the socket and exit;
}
close the copy of the socket and go to sleep again;
}
Quote:}
this should be easy to transfer to c, but as I said it is not trivial to
get the wanted service (okok www is easy, but the rest?)