How to test whether your proxy is really working or not?

First of all what is proxy?

Diagram of two computers connected only via a proxy server. The first computer says to the proxy server: "ask the second computer what the time is".Pin

Communication between two computers (shown in grey) connected through a third computer (shown in red) acting as a proxy. Bob does not know to whom the information is going, which is why proxies can be used to protect privacy.

In computer networks, a proxy server is a server (a computer system or an application) that acts as an intermediary for requests from clients seeking resources from other servers.[1] 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 and the proxy server evaluates the request as a way to simplify and control its complexity. Proxies were invented to add structure and encapsulation to distributed systems.[2]Today, most proxies are web proxies, facilitating access to content on the World Wide Web, providing anonymity and may be used to bypass IP address blocking.

I’ve currently these codes answered below to check the proxy:

 

2.Although somewhat old question, but it may be still have some value to provide another answer. So here is mine:

set_proxies() {
    export http_proxy=http://proxy.example.com:998
    export HTTP_PROXY=${http_proxy}
    export https_proxy=http://proxy.example.com:999
    export HTTPS_PROXY=${https_proxy}
    export ftp_proxy=http://proxy.example.com:998
    export FTP_PROXY=${ftp_proxy}
    export socks_proxy=socks://proxy.example.com:9999
    export SOCKS_PROXY=${socks_proxy}
    export no_proxy=localhost,127.0.0.1,.docker.io,192.168.9.100
    export NO_PROXY=${no_proxy}        
    export ALL_PROXY_NO_FALLBACK=1
    export all_proxy=socks5://proxy.example.com:9999   
}

URL='www.google.com'

curl -s -m 2 $URL > /dev/null

if [ $? == 0 ] then
    STATUS="No Corporate Proxy"
else
    set_proxies
    STATUS="Behind Corporate proxy"
fi
echo $STATUS

I have solved it this way :

export http_proxy='http://proxy.test.cz:1234/'
URL='www.google.com'

wget -q --proxy-user=test --proxy-password=test --spider $URL
if [ $? = 1 ]
then
    STATUS= echo "Proxy isn't working"

else
  STATUS="Proxy is working."
fi
echo $STATUS

Working? Well, you have to use them to see if they are working.

If you want to see if they are online, I guess ping is a first step.

There is a Ping class in .NET.

using System.Net.NetworkInformation;

private static bool CanPing(string address)
{
    Ping ping = new Ping();

    try
    {
        PingReply reply = ping.Send(address, 2000);
        if (reply == null) return false;

        return (reply.Status == IPStatus.Success);
    }
    catch (PingException e)
    {
        return false;
    }
}

I like to do a WhatIsMyIP check through a proxy as a test.

public static void TestProxies() {
  var lowp = new List<WebProxy> { new WebProxy("1.2.3.4", 8080), new WebProxy("5.6.7.8", 80) };

  Parallel.ForEach(lowp, wp => {
    var success = false;
    var errorMsg = "";
    var sw = new Stopwatch();
    try {
      sw.Start();
      var response = new RestClient {
        BaseUrl = "https://webapi.theproxisright.com/",
        Proxy = wp
      }.Execute(new RestRequest {
        Resource = "api/ip",
        Method = Method.GET,
        Timeout = 10000,
        RequestFormat = DataFormat.Json
      });
      if (response.ErrorException != null) {
        throw response.ErrorException;
      }
      success = (response.Content == wp.Address.Host);
    } catch (Exception ex) {
      errorMsg = ex.Message;
    } finally {
      sw.Stop();
      Console.WriteLine("Success:" + success.ToString() + "|Connection Time:" + sw.Elapsed.TotalSeconds + "|ErrorMsg" + errorMsg);
    }
  });
}

However, I might suggest testing explicitly for different types (ie http, https, socks4, socks5). The above only checks https. In building the ProxyChecker forhttps://theproxisright.com/#proxyChecker, I started w/ the code above, then eventually had to expand for other capabilities/types.

try this:

public static bool SoketConnect(string host, int port)
{
    var is_success = false;
    try
    {
        var connsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        connsock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 200);
        System.Threading.Thread.Sleep(500);
        var hip = IPAddress.Parse(host);
        var ipep = new IPEndPoint(hip, port);
        connsock.Connect(ipep);
        if (connsock.Connected)
        {
            is_success = true;
        }
        connsock.Close();
    }
    catch (Exception)
    {
        is_success = false;
    }
    return is_success;
}
string strIP = "10.0.0.0";
int intPort = 12345;

  public static bool PingHost(string strIP , int intPort )
    {
        bool blProxy= false;
        try
        {
            TcpClient client = new TcpClient(strIP ,intPort );

            blProxy = true;
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error pinging host:'" + strIP + ":" + intPort .ToString() + "'");
            return false;
        }
        return blProxy;
    }

    public void Proxy()
    {
        bool tt = PingHost(strIP ,intPort );
        if(tt == true)
        {
            MessageBox.Show("tt True");
        }
        else
        {
            MessageBox.Show("tt False");
        }

 

 

13 thoughts on “How to test whether your proxy is really working or not?”

  1. I need Kimber Firearms says:

    92438 789523Some truly great content on this web site , appreciate it for contribution. 679923

  2. Xiao Crossland says:

    I really glad to find this internet site on bing, just what I was searching for : D besides saved to my bookmarks .

Leave a Reply

Knowasiak

FREE
VIEW