Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are real and transparent proxies

Tags:

c#

In .NET remoting, there are two kind of proxies:

  1. Transparent Proxies
  2. Real Proxies

What is the difference between them?

like image 623
Saveen Avatar asked Oct 08 '13 09:10

Saveen


People also ask

Are transparent proxies good?

To the end user, a transparent proxy is basically malware. It intercepts internet traffic and redirects it to another destination without the end user's consent. This essentially describes a man-in-the-middle (MITM) attack. However, transparent proxies are not always malicious.

What are the two types of proxies?

There are two types of proxies: forward proxies (or tunnel, or gateway) and reverse proxies (used to control and protect access to a server for load-balancing, authentication, decryption or caching).

What is transparent and non-transparent proxy?

A transparent proxy (also called inline proxy, intercepting proxy, or forced proxy) is a server that sits between your computer and the internet and redirects your requests and responses without modifying them. A proxy server that does modify your requests and responses is defined as a non-transparent proxy.

Does a transparent proxy hide your IP?

The proxy remembers your private IP address so that once the answer is sent back, it will recognize that you requested this information and will send it back to you. Such proxies are usually accessed via specific software or a browser extension.


1 Answers

From MSDN:

The TransparentProxy is an internal class that cannot be replaced or extended. On the other hand, the RealProxy and ObjRef classes are public and can be extended and customized when necessary. The RealProxy class is an ideal candidate for performing load balancing for example, since it handles all function calls on a remote object. When Invoke is called, a class derived from RealProxy can obtain load information about servers on the network and route the call to an appropriate server. Simply request a MessageSink for the required ObjectURI from the Channel and call SyncProcessMessage or AsyncProcessMessage to forward the call to the required remote object. When the call returns, the RealProxy automatically handles the return parameter.

Here's a code snippet that shows how to use a derived RealProxy class.

MyRealProxy proxy = new MyRealProxy(typeof(Foo));
Foo obj = (Foo)proxy.GetTransparentProxy();
int result = obj.CallSomeMethod();

The TransparentProxy obtained above can be forwarded to another application domain. When the second client attempts to call a method on the proxy, the remoting framework will attempt to create an instance of MyRealProxy, and if the assembly is available, all calls will be routed through this instance. If the assembly is not available, calls will be routed through the default remoting RealProxy.

An ObjRef can easily be customized by providing replacements for default ObjRef properties TypeInfo, EnvoyInfo, and ChannelInfo. The following code shows how this can be done.

public class ObjRef {
  public virtual IRemotingTypeInfo TypeInfo 
  {
    get { return typeInfo;}
    set { typeInfo = value;}
  }

  public virtual IEnvoyInfo EnvoyInfo
  {
    get { return envoyInfo;}
    set { envoyInfo = value;}
  }

  public virtual IChannelInfo ChannelInfo 
  {
    get { return channelInfo;}
    set { channelInfo = value;}
  }
}
like image 177
Rahul Tripathi Avatar answered Sep 24 '22 21:09

Rahul Tripathi