views:

497

answers:

1

I'm using WCF's netTcpBinding, which connects directly to an endpoint and doesn't seems to know anything about socks proxies.

I need to use a proxy because most of my clients won't allow direct outbound connections, and enforce the use of socks proxies at all times.

  • My first idea was to configure the .net framework to do that, so I edited the machine.config file as follows, but it seems it only works with http proxies (not socks)

    <system.net>
    <defaultProxy enabled="true">
      <proxy usesystemdefault="False" proxyaddress="foo:1080" bypassonlocal="True"/>
      <module />
    </defaultProxy>
    </system.net>
    
  • My second option was to implement a custom binding inheriting from netTcpBinding, and only overriding the connection logic to add the proxy code.

    I've dissasembled the System.ServiceModel assembly, and unfortunately, a lot of classes are marked as internal (including SocketConnectionInitiator, ConnectionPoolHelper, ClientFramingDuplexSessionChannel and FramingDuplexSessionChannel, and probably others aswell)

    This makes creating a custom netTcpBinding a huge work, and moreover could cause some problems as new versions of the .net framework are delivered.

  • Another idea is to inject some code directly into the Socket.Connect() method. This is quite easy to achieve, but I'm not very confident with modifying the inner code of the .net framework. Also, although the socket class isn't marked as sealed, I'm afraid of breaking something, especially in later relases of the framework.

  • Last idea I've got for now: I could create a little proxy tool, running on the same computer as my software, which would automatically connect to the corporate's socks proxy, and issue the good "connect server" command to the real socks proxy.

The latter option is in my opinion the better, but I'm curious to hear other people opinions.

What do you think?

A: 

Use SocksCap, WideCap, or something, if you can install it to client machines

Or implement/find some Socks->HTTP proxy and use that.

wizzard0