This is a migrated thread and some comments may be shown as answers.

How do I use Telerik.NetworkConnections.NetworkConnectionsManager?

3 Answers 666 Views
FiddlerCore
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 13 Feb 2019, 03:30 PM

Using the latest version of FiddlerCore, I'm getting some compiler warnings using several proxy methods like FiddlerApplication.oProxy.Detach(), CONFIG.sHostsThatBypassFiddler, and FiddlerCoreStartupSettingsBuilder().RegisterAsSystemProxy().MonitorAllConnections() saying they are obselete and I should use Telerik.NetworkConnections.NetworkConnectionsManager. I've added the two assemblies as references, but the NetworkConnectionsManager class is sealed and has a private constructor and I can't figure out how I'm supposed to use that class to replace these methods. It is not used in the included SampleApp and there doesn't seem to be any documentation on your site that shows how to use it (at least not that I could find). 

Can you please direct me how I'm supposed to use that class to replace those methods above?

Thanks

3 Answers, 1 is accepted

Sort by
0
Simeon
Telerik team
answered on 14 Feb 2019, 04:16 PM
Hi Patrik,

Thank you, for asking this question. This gives me the opportunity to describe here the reasoning and the usage about the new Telerik.NetworkConnections.* assemblies before the docs are ready.

Since the first release of FiddlerCore, we have noticed from the feedback of our customers that they use it in various ways, many of which do not involve dealing with the proxy settings of the Operating System, hence - the proxy settings of the apps which obey them (pro tip: there are many apps which don't care about the proxy settings of the Operating System). This is the reason why we decided to separate this concern from the core proxy logic into a separate project.

We also got many questions about why Fiddler(Core) is not capturing the traffic from a particular application and what the solution is. Most of the time, the answer was that this is one of those apps which have their own proxy settings and the user have to change them manually. Here we thought that the new solution must be extensible, so that the clients could automate the process for themselves and we decided to use the Managed Extensibility Framework (MEF) because it is available in the .NET Framework since 4.0 and in the .NET Standard 2.0.

Regarding how to use the NetworkConnectionsManager, here is a sniped how it is used in Fiddler and FiddlerCore:
using System.ComponentModel.Composition.Hosting;

using Telerik.NetworkConnections;
// ...
 
namespace Fiddler
{
    public class Proxy : IDisposable
    {
        // ...
 
        internal Proxy(bool isPrimary, ProxySettings upstreamProxySettings)
        {
            this.upstreamProxySettings = upstreamProxySettings;
 
            string location = Assembly.GetExecutingAssembly().Location;
            string directoryName = Path.GetDirectoryName(location);
            using (DirectoryCatalog catalog = new DirectoryCatalog(directoryName, "Telerik.NetworkConnections*"))
            {
                this.container = new CompositionContainer(catalog);
                this.connectionsManager = this.container.GetExportedValue<NetworkConnectionsManager>();
            }
 
            // ...
        }
 
        public void Dispose()
        {
            if (!ReferenceEquals(this.container, null))
            {
                this.container.Dispose();
            }
 
            // ...
        }
    }
}

The MEF takes care to initialize the NetworkConnectionsManager and it also takes care to provide it with all the NetworkConnectionsDetectors which it finds. The purpose of the NetworkConnectionsDetector is to give the NetworkConnectionsManager all NetworkConnections which it knows about and which are present. These NetworkConnections have get/set methods for the ProxySettings. We have already implemented NetworkConnections which could get/set the Operating Systems' proxy settings of Windows, Mac and Linux. Now the users have the possibility to implement NetworkConnections and the corresponding INetworkConnectionsDetectors for any app which allows its proxy settings to be changed programmatically. They have to export them with the NetworkConnectionsDetectorExportAttribute in order to be discovered by the MEF.

In a future version of FiddlerCore, it will stop using the NetworkConnectionsManager internally and it will depend on the user to provide the FiddlerCoreStartupSettings.UpstreamProxySettings if Fiddler has to forward the requests to any corporate proxies etc.

In general, the workflow should be something like this:
- on startup:
1. The user obtains (or initializes) the upstream ProxySettings with the NetworkConnectionManager.GetCurrentProxySettingsForConnection method.
2. The user starts FiddlerCore with these ProxySettings.
3. The user sets the proxy settings for those NetworkConnections which have to use FiddlerCore as proxy with the NetworkConnectionManager.SetProxySettingsForConnections method passing a ProxySettings instance pointing to FiddlerCore (127.0.0.1:8866 etc.)
- on shutdown:
1. The user sets the proxy settings for the NetworkConnections to the initial ones with the NetworkConnectionManager.SetProxySettingsForConnections method.
2. The user shutdowns FiddlerCore.

Of course, we are going to implement this logic in Fiddler and FiddlerEverywhere so it is possible that soon we will provide this as a package, as well. And the best part is that there is a real chance that these NetworkConnections projects could become open sourced :)

Of course any feedback about this is welcome.

Regards,
Simeon
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
David
Top achievements
Rank 1
answered on 20 Jun 2019, 02:32 PM

Hi @Simeon,

Where do I get Telerik.NetworkConnections from?  I've referenced FiddlerCore4.dll, when I run

var fiddlerCoreStartupSettings = new FiddlerCoreStartupSettingsBuilder()
                            .ListenOnPort(fiddlerPort)
                          .Build();
FiddlerApplication.Startup(fiddlerCoreStartupSettings);

I get the following exception:

System.IO.FileNotFoundException
  HResult=0x80070002
  Message=Could not load file or assembly 'Telerik.NetworkConnections, Version=0.1.1.0, Culture=neutral, PublicKeyToken=67cb91587178ac5a'. The system cannot find the file specified.
  Source=FiddlerCore4
0
Simeon
Telerik team
answered on 21 Jun 2019, 02:34 PM
Hi David,

The Telerik.NetworkConnections.dll should be inside the installation folder on FiddlerCore next to the FiddlerCore4.dll

Regards,
Simeon
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
FiddlerCore
Asked by
Patrick
Top achievements
Rank 1
Answers by
Simeon
Telerik team
David
Top achievements
Rank 1
Share this question
or