Multiplexing socket ?

Multiplexing socket ?

Post by Tristan Tarran » Tue, 22 Jul 1997 04:00:00



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 ?

Thanks

Tristan

--

Il mondo si divide in due categorie: chi ha la pistola carica e chi scava.
Tu scavi.
                              Il buono, il brutto e il cattivo

 
 
 

Multiplexing socket ?

Post by Sascha Bohnenka » Tue, 22 Jul 1997 04:00:00


|> 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?)        

 
 
 

Multiplexing socket ?

Post by Tristan Tarran » Tue, 22 Jul 1997 04:00:00



> 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

For example:

Sendmail:
The first command must be a HELO or EHLO followed by hostname

FTP:
I think the first command would be a USER followed by a PASS.

WWW:
GET, POST, not many others probably.

RLOGIN+TELNET:
Hmmm, these are complex, but I don't really need them if I have the above
three.

If nothing like what has been described, I'll write one myself. Does anyone
else need anything even remotely like this ?

Tristan
--

Quando ti svegli al mattino, sorridi. Domani sara' peggio.
                                   Ramon Montoro

 
 
 

1. Multiplexing socket I/O across threads

Do sockets allow one thread to do send operation while another thread is
blocking on a read on the same socket?

The Solaris manual does not mention anything about this, except that it
seems to suggest that file I/O can be split across threads
(reads/writes) and that sockets I/o is more or less treated like file
I/o? Any gurus who can give me some insights, relate their experience
etc on this topic?

Thanks in Advance,

--
Nagesh Chintada   Sr. Software Engineer, Newbridge Networks, Inc.

http://www.vivid.newbridge.com
VIVID: No more routing bottlenecks....

2. Problems with LinuxConf

3. getting destination IP address from multiplexed socket

4. "free" command equivalent

5. Trying to write multiplexing UDP socket program.

6. Saving the GL window to an image file

7. BSD sockets - I/O Multiplexing

8. stderr and stdout: displaying and capturing to separate files

9. Message Queue + Sockets Multiplexing

10. socket io multiplexing

11. Passing multiplexed devices through Unix-domain sockets

12. Nice multiplexing w/ IPC and sockets ??

13. Easy multiplexing with sockets