Deflect OS traffic
Fluxy.Core
provides APIs to automatically deflects OS traffic to itself. This feature is only available on Desktop environment (Windows, macOS and Gnome based Linux).
The static method SystemProxyRegistrationHelper.Create
is the entry point to enable this feature. It takes endpoints returned by Proxy.Start()
as argument and register the first available endpoint as the system proxy. The call returns an IAsyncDisposable
that can be used to revert the system proxy to its previous state.
using Fluxzy;
using Fluxzy.Core;
// Create a new proxy instance
await using var proxy = new Proxy(FluxzySetting.CreateDefault());
// Proxy run will returns the endpoints that the proxy is listening on
var endPoints = proxy.Run();
// Pick an endpoint and register it as the system proxy
var proxyRegistration = await SystemProxyRegistrationHelper.Create(endPoints.First());
// System proxy is now set
// Call DisposeAsync() to unregister the proxy
await proxyRegistration.DisposeAsync();
Note
The automatic proxy doesn't affect environment variables related to proxying (such as HTTP_PROXY variable available on unix-like system)