Click here to Skip to main content
16,019,140 members
Articles / Programming Languages / C#

Internet Magic (Proxy Server) Windows Application

Rate me:
Please Sign up or sign in to vote.
3.00/5 (8 votes)
10 Apr 2010CPOL3 min read 69.9K   8.8K   38   18
Windows application which creates a proxy server to share Internet over any TCP/IP network

Project code

Class architecture

1.jpg

Introduction

In any network, each system has a unique IP address which identifies the system in the network. This application aims at distributing the internet over a network, based on the IP address. Administrator registers the IP addresses of the client in the application (proxy server), which then allows access to the various services provided by the server on the systems identified by these IP addresses.

This project is being developed using C# .NET in Visual Studio 2005.

Feature Set

  • IP address based internet sharing
  • Network monitoring to monitor online client activity
  • Web filter which can be used to block specified web sites
  • Time scheduling to limit client’s on-line time
  • Bandwidth usage statistics to monitor the bandwidth
  • Account authentication for Socks protocol
  • Socks support allows various internet messengers and FTP downloaders
  • Portmap maps a port on a specific IP address to another port on another IP address
  • This application also supports HTTP/FTP

Background

In computer networks, a proxy server is a server (a computer system or an application program) that services the requests of its clients by forwarding requests to other servers. A client connects to the proxy server, requesting some service, such as a file, connection, web page, or other resource, available from a different server. The proxy server provides the resource by connecting to the specified server and requesting the service on behalf of the client. A proxy server may optionally alter the client's request or the server's response, and sometimes it may serve the request without contacting the specified server. In this case, it would 'cache' the first request to the remote server, so it could save the information for later, and make everything as fast as possible. A proxy server that passes all requests and replies unmodified is usually called a gateway or sometimes tunnelling proxy. A proxy server can be placed in the user's local computer or at various points between the user and the destination servers or the Internet.

Using the Code

This application created using VS2005 code can directly open in Visual Studio using its Solution file.

The language used is C# using .NET 2.0, executable file will be created on program execution.

C#
//SAMPLE OF THE CODE
int Ret;
try  {
    Ret = ClientSocket.EndReceive(ar);
} catch {
    Ret = -1;
}
if (Ret <= 0) { //Connection is dead :(
    Dispose();
    return;
}
HttpQuery += Encoding.ASCII.GetString(Buffer, 0, Ret);
/******************For Authentication************************/
HeaderFields = ParseQuery(HttpQuery);
if (HeaderFields == null || !HeaderFields.ContainsKey("Host"))
{
    SendBadRequest();
    return;
}
int Port;
string Host;

if (HttpRequestType.ToUpper().Equals("CONNECT"))
{ //HTTPS
    Ret = RequestedPath.IndexOf(":");
    if (Ret >= 0)
    {
        Host = RequestedPath.Substring(0, Ret);
        if (RequestedPath.Length > Ret + 1)
            Port = int.Parse(RequestedPath.Substring(Ret + 1));
        else
            Port = 443;
    }
    else
    {
        Host = RequestedPath;
        Port = 443;
    }
}
else
{ //Normal HTTP
    Ret = ((string)HeaderFields["Host"]).IndexOf(":");
    if (Ret > 0)
    {
        Host = ((string)HeaderFields["Host"]).Substring(0, Ret);
        Port = int.Parse(((string)HeaderFields["Host"]).Substring(Ret + 1));
    }
    else
    {
        Host = (string)HeaderFields["Host"];
        Port = 80;
    }
    if (HttpRequestType.ToUpper().Equals("POST"))
    {
        int index = HttpQuery.IndexOf("\r\n\r\n");
        m_HttpPost = HttpQuery.Substring(index + 4);
    }
}
string dir = Environment.CurrentDirectory;
if (!dir.Substring(dir.Length - 1, 1).Equals(@"\"))
    dir += @"\";
Program prx = Program.obj;

//

Points of Interest

The product is a very low cost system with a Windows application, where a system in which application is installed has a purpose to provide web services over the connected network. The administrator controlling this server has to give details of the client about their authorization to access these services and until when they can access it. The system then automatically generates a request window on client requesting access to the services which, if registered by administrator of server, then client can fully utilize the services provided by serve. Then system automatically controls the access time and monitors the client for their activity in the internet. After the validity period of the client has expired, then the client will be automatically barred from accessing these services.

History

  • 10th April, 2010: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionHow can Test this Application Pin
Kaps Panwar3-Feb-17 0:50
Kaps Panwar3-Feb-17 0:50 
QuestionOutdated? 1/2 Not working Pin
Dylan Hunt12-Nov-14 19:49
Dylan Hunt12-Nov-14 19:49 
QuestionERROR Pin
osmo3323-Feb-14 20:59
osmo3323-Feb-14 20:59 
AnswerRe: ERROR Pin
Dylan Hunt12-Nov-14 19:50
Dylan Hunt12-Nov-14 19:50 
QuestionUser authentication Pin
nitin-aem25-Apr-13 23:39
nitin-aem25-Apr-13 23:39 
GeneralMy vote of 1 Pin
Syed J Hashmi16-Dec-11 6:44
Syed J Hashmi16-Dec-11 6:44 
QuestionWorks with proxy checkers? Pin
jp7315-Aug-11 12:34
jp7315-Aug-11 12:34 
GeneralMy vote of 1 Pin
MChris200611-May-11 8:43
MChris200611-May-11 8:43 
GeneralMy vote of 1 Pin
aldycool6-Jan-11 4:34
aldycool6-Jan-11 4:34 
GeneralRe: My vote of 1 Pin
shi1234565-Mar-11 5:08
shi1234565-Mar-11 5:08 
GeneralRe: My vote of 1 Pin
Chris G.4-Aug-13 23:32
Chris G.4-Aug-13 23:32 
QuestionMentalis? Pin
aldycool6-Jan-11 4:32
aldycool6-Jan-11 4:32 
GeneralMy vote of 1 Pin
Syed J Hashmi7-Aug-10 18:15
Syed J Hashmi7-Aug-10 18:15 
GeneralMy vote of 1 Pin
Syed J Hashmi14-Jul-10 17:01
Syed J Hashmi14-Jul-10 17:01 
poor
GeneralRe: My vote of 1 Pin
shi1234567-Aug-10 13:43
shi1234567-Aug-10 13:43 
GeneralMore explanation Pin
Artem S. Dmitriev10-Apr-10 9:49
Artem S. Dmitriev10-Apr-10 9:49 
GeneralRe: More explanation Pin
shi12345610-Apr-10 11:23
shi12345610-Apr-10 11:23 
GeneralRe: More explanation Pin
Artem S. Dmitriev10-Apr-10 19:56
Artem S. Dmitriev10-Apr-10 19:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.