
SocksSvc
1.05 A collection of MFC classes to implement a Socks Server
Welcome to SocksSvc, a collection of MFC classes to
implement a simple Socks server.
The idea behind SocksSvc was originally to learn about the Socks protocol and
how it is implemented on Win32.
For detailed information about the
Socks
Protocol you should read RFC 1928
(Socks 5), RFC 1929 (Username / Password authentication for Socks 5) and the
Socks 4 specification, You can download these from
www.socks.permeo.com.
The classes which constitute SocksSvc are:
CSocksServerSettings: This class contains the settings which are
used to configure the Socks server. Example member variables in this class
include the port to listen on and the valid protocols to support. If you are
developing a stand alone socks server based on SocksSvc, you could for example
store all the variables for the CSocksServerSettings instance in an ini file or
in the registry.
CSocksServer: This is the actual class which implements the Socks
server. It has a number of very simple functions to allow you to control the
state of the socks server such as Start and Stop. Internally a background thread
is spun off to handle the client connections.
CSocksClient: This class is used in the CSocksServer class to handle
client connections. It handles the parsing of client requests and returning the
appropriate response. A number of virtual functions are provided to allow end
user customisation.
Various other help classes and structures are provided including a number of
classes I have already developed independent of SocksSvc.
The
enclosed zip file contains the SocksSvc
source code and a simple console based application which implements a simple
socks server.
Copyright
- You are allowed to include the source code in any product (commercial,
shareware, freeware or otherwise) when your product is released in binary
form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to
maintain a single distribution point for the source code.
Updates
V1.0 (19 February
2003)
V1.01 (3 March 2003)
- Fixed a bug in CSocksSocket::Read(CSocks5RequestDetails&,...) which was
causing the port details to be read incorrectly from clients.
V1.02 (13 January 2004)
- Used newer form of #pragma pack to avoid problems with non standard
packing sizes.
V1.03 (7 September 2005)
- Updated the code to compile cleanly using the latest version of CWSocket.
- Updated the copyright details.
- Addition of a "SOCKSSVC_EXT_CLASS" which allows the code to be easily
incorporated into an MFC extension DLL.
- Removed the m_bListenBind variable from the CSocksServerSettings as
m_bListenBindAddress on its own is sufficient to specify whether binding
should occur.
- Removed the m_bConnectBind variable from the CSocksServerSettings as
m_bConnectBindAddress on its own is sufficient to specify whether binding
should occur.
- Fixed a potential buffer overflow issue in the parsing of SOCKS4
connections requests.
- Fixed a typo in the logging of an error if socks 4 clients are not
allowed.
V1.04 (13 February 2006)
- Updated the documentation to use the same style as the web site.
- Updated the copyright details of each module.
- Fixed graceful disconnect issues in CSocksSocket::Read and
CSocksClient::Relay.
- Replaced all calls to CopyMemory with memcpy.
- Replaced all calls to ZeroMemory with memset.
V1.05 (15 January 2007)
- Updated copyright details.
- Removed CSocksClient destructor as it was not really required.
- Optimized CSocksClient constructor code
- Code now uses newer C++ style casts instead of C style casts.
- General review of code base for correctness.
- Removed unused code from CSocksClient::AllowThisOutboundConnection and CSocksClient::OnEndRelay
- Updates to allow the code to clean compile on VC 2005
- Optimized CSocksServerSettings constructor code
- Optimized CSocksServer constructor code
- Optimized CSocksConnectionRequest constructor code
- Optimized CSocks5RequestDetails constructor code
- Fixed a number of memory leaks in the CSocksSocket::Read methods
- Updated code to compile with latest version of the author's CWSocket
class