TCPTunnel for Win32 ver 0.5 2005/07/24 ver 0.4 2001/10/28 ver 0.3 2001/02/07 ver 0.2 2001/01/17 ver 0.1 2000/12/26 Tomoichi Ebata E-mail:See http://www.kobore.net/mailAddress.gif http://www.kobore.net/ 0. History ~~~~~~~~~~ ver 0.4 2005/07/24 - Added patches from Mr.Kenneth Golomb (Thank you so much!) ver 0.4 2001/10/28 - Reviewed the license(From GPL to BSD) ver 0.3 2001/02/07 - Added UDP port forward function - according to the above function, changed the formart of tcptunnel.cfg ver 0.2 2001/01/17 - A bug fix about thread release - Added the report for multi step's use ver 0.1 2000/12/26 - The first edition 1. Copyright ~~~~~~~~~~~~ Copyright (c) 2001,2002,2003,2004,2005 Tomoichi Ebata. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified. 2 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY Tomoichi Ebata ``AS IS'' AND ANY EXPRESS ORIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Tomoichi Ebata BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2. What is "TCPTunnel for Win32" ? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The concept and design of "TCPTunnel for Win32" came from "tcptunnel" that was developed by Mr.Takaaki Tateishi with Ruby language. According to "tcptunnel", please refer to Mr.Tateishi's following page. http://kt-www.jaist.ac.jp:8000/~ttate/ftp/README.tcptunnel ----- +-------+ +------+ +-------+ +-|Various| | TCP | +-|Various| | | |<------>|Tunnel|<------>| |BackEnd| | |clients| |Server| | |Servers| | +-------+ +------+ | +-------+ +------+ Windows box +-------+ "TCPTunnel for Win32" makes a connection between the above the Windows box and a back-end server when a client request a TCP connection to the "TCPTunnel for Win32" on Windows Box. This software will be helpful for the following cases. - Load distribution of server by using more than one BackEnd server - Offering many kinds of service with one domain name (or IP address) - Firewall against the attack to the backend servers However, as far as I am concerned, I have the following background. - I was provided only one IP address for a windows NT box. However, I have to provide some Linux server applications to our project members. ----- "TCPTunnel for Win32" has no functions that "tcptunnel" presents. - to specify IP addresses that are allowed and/or denied to access the backend server. - to specify the timeout about clients and servers Without these functions, there might happen some security problems, however I didn't need them, so I didn't make them. If you need them, please add and/or modify the source codes by yourself, or send me your patch file. On the other hand, there are some additional function as follows. - to forward plural ports to plural back-end servers. - not only TCP ports but also UDP ports are available. ----- There are two types of "TCPTunnel for Win32" (1)NT/2000 Service version "TCPTunnel for NT Service" tcptunnel4nts.exe (2)Executable version "TCPTunnel for Windows" tcptunnel4win.exe I will explain about them from the next chapter. 3.How to use "TCPTunnel for NT Service" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3.1 Preparation Put "tcptunnel4nts.exe" on the appropriate directory (for example, "c:\bin\tcptunnel"), and make "tcptunnel.cfg" on the directory of %SystemRoot%system32(for example,"c:\WINNT\system32") The following is the sample of "tcptunnel.cfg". tcp 2744 192.168.0.1 2744 tcp 2674 192.168.0.1 2674 tcp 23 erukan.kobore.com 23 udp 123 erukan.kobore.com 123 ^ ^ ^ ^ (3)Port number of BackEnd | | | Server | | | | | |(2) Name of BackEnd server(or IP address) | | | |(1)Listen Port number of TCPTunnel server(tcptunnel4nts.exe) | |(0) TCP or UDP The delimiter of (0)(1)(2) and(3)should be [TAB]. The back of (3) should be [CR]. Comments are not available for the present version. The number os the combination of (0)(1)(2) and(3) should be less than thirty. 3.2 Installation and start of "TCPTunnel for NT Service" From DOS window, input tcptunnel4nts.exe -install After that, you can see "TCPTunnel" in Service window ([Start] -> [Control Panel] -> [Services]). You choose this, and push the start button. "TCPTunnel for NT Service" will start as a "NT service". 3.3 Uninstallation of "TCPTunnel for NT Service" From DOS window, input tcptunnel4nts.exe -remove You can confirm to delete "TCPTunnel" in Service window. 4. How to use "TCPTunnel for Windows" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4.1 Preparation Put "tcptunnel4win.exe" on the appropriate directory (for example, "c:\bin\tcptunnel"), and make "tcptunnel.cfg" on the same directory. According to "tcptunnel.cfg", refer to the above 3.1. 4.2 Start of "TCPTunnel for Windows" From DOS window, input tcptunnel4win.exe 4.3 Termination of "TCPTunnel for Windows" Use Ctrl-C. 5. Others ~~~~~~~~~ I would really appreciate it if you send me some bug reports and/or patch file for new functions. I confirmed that there was no problem about the following environment(Multi tunnels). +-------+ +------+ +------+ +-------+ +-|Various| | TCP | | TCP | +-|Various| | | |<------>|Tunnel|<------>|Tunnel|<------>| |BackEnd| | |clients| |Server| |Server| | |Servers| | +-------+ +------+ +------+ | +-------+ +------+ Windows box Windows box +-------+ TCPTunnel Mechanism (Step.2) (Step.1)+---------+ Request by "connect()" Request |TCPTunnel|--------------> ------------>| Server |<------------- Wait +---------+|| by +---------+| "accept()"+---------+ :(Step.3) :digTunnel - - - - -:- - - - - || V || From client +-----------+ To BackEndServer ---------||->| TCPTunnel |--||---------> +-----------+ || :(Step.4)|| : || V || To Client +-----------+ From BackEndServer <--------||--| ReturnWay |<-||---------- +-----------+ || || - - - - - - - - - - ClientSocket ServerSocket UDPTunnel Mechanism (Step.2) Store the source address - - - - -:- - - - - (Step.1) || V || (Step.3) From client +-----------+ To BackEndServer ---------||->| |--||---------> (Step.5) | UDPTunnel | (Step.4) <--------||--| |<-||---------- To Client +-----------+ From BackEndServer || || - - - - - - - - - - ClientSocket ServerSocket * Timeout mechanism should be needed.