Click here to Skip to main content
15,883,886 members
Articles / Programming Languages / C# 4.0

Golabi Proxy Server

Rate me:
Please Sign up or sign in to vote.
4.79/5 (10 votes)
20 Sep 2011CPOL2 min read 65.7K   3.7K   21  
This is a proxy server with a client that can encrypt your browser request.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace GolabiProxyServer
{
    public partial class GolabiServerUI : Form
    {
        public GolabiServerUI()
        {
            InitializeComponent();
        }

        ProxyTCPListener proxyListener;
        delegate void SetTextCallback(string msg);
        Thread StartListenApp;

        private void startAcc()
        {
            ConnectionInfo info = new ConnectionInfo(ListenIP.Text, ListenPort.Text, KeyInput.Text, this, Encrypt.Checked);

            proxyListener = new ProxyTCPListener(info);

            proxyListener.StartServer(this, KeyInput.Text);

            while (true)
            {
                proxyListener.AcceptConnection();
            }
        }

        

        public void setMessage(string msg)
        {
            if (this.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(setMessage);
                this.Invoke(d, new object[] { msg });
                return;
            }

            Messages.Text += msg + "\r\n";
        }

        private void Start_Click(object sender, EventArgs e)
        {
            if (StartListenApp == null || StartListenApp.ThreadState == ThreadState.Stopped)
            {
                StartListenApp = new Thread(new ThreadStart(startAcc));
                StartListenApp.Start();
            }
            else
            {
                setMessage("Cannot start again...");
            }
        }

        private void Stop_Click(object sender, EventArgs e)
        {
            if (StartListenApp != null)
                StartListenApp.Abort();
        }

        private void Exit_Click(object sender, EventArgs e)
        {
            Stop.PerformClick();
            this.Close();
            this.Dispose();
        }

        private void Encrypt_CheckedChanged(object sender, EventArgs e)
        {
            KeyInput.Enabled = Encrypt.Checked;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer رایان پایا داده محاسب
Iran (Islamic Republic of) Iran (Islamic Republic of)
Bachelor of computer software engineer at Urmia University of Technology,

Masters of computer software engineer at Shahid Beheshti University,

Microsoft Certified Solution Developer : Web Applications,

Microsoft Specialist : HTML5 , CSS3 , javascript,

MCTS at Mojtame Fanni Tehran (MFT)


My Server Solution Blog

Comments and Discussions