This is a Proof-of-Concept for hosting multiple TCP protocols on the same port.
This does not require any modifications of the actual HTTPd, IRCd, etc.
NOTE: About 6 months after creating this, I was pointed to what seems to be a more mature version of this same concept at http://www.rutschle.net/tech/sslh.shtml
Supported Protocols: HTTP, IRC, SSH (as a fall-back)
Unconfirmed Protocols: One SSL/TLS based protocol (ie HTTPS, FTPS, etc), TFTP, Socks4/4a, SMTP, POP3, rlogin
Fallback Protocols: Theoretically, any TCP/IP based protocol because on fall-back, the protoRouter simply becomes a tunnel
The router listens to connecting clients, waits for the client to send some data that indicates
which protocol it is using. Based on this, the router will:
A) Connect the client to the proper destination host:port
OR
B) Connect the client to the fallback host:port (if the client does not speak, it can fall back to a “server-talks-first” protocol)
OR
C) Drop the connection (Does not match any routes, or no fallback connection configured)
protoRouter.php.txt is an example setting the routes, fallback, timeouts, etc
[ 2.3 KB ]
protoRouter.class.php.txt is the PHP class for the router itself
[ 13.5 KB ]
This is only a Proof-of-Concept, and has several pitfalls which would be solved by writing this as a kernel module or similar.
1) Should be implemented using a NAT type setup (at least for internal IPs & loopback). Currently, connections to servers show the IP of the server the PHP script is running on instead of the originating client.
2) A more definitive list of applicable protocols. This list only has 3 confirmed (HTTP, IRC, SSH as a fall-back), and the other protocols listed are based on protocol documentation.
3) Written in a compiled language such as C or C++