Skip to content

Instantly share code, notes, and snippets.

@phm200
Created September 11, 2013 01:39
Show Gist options
  • Save phm200/6518350 to your computer and use it in GitHub Desktop.
Save phm200/6518350 to your computer and use it in GitHub Desktop.
Fiddler Round Robin Load Balancing
public long numberOfRedirects = 1;
private string redirectHost = "192.168.100.57";
private int hostPort = 9999;
private string destinationOne = "192.168.100.57";
private int destOnePort = 8100;
private string destinationTwo = "192.168.100.57";
private int destTwoPort = 8101;
public void AutoTamperRequestBefore(Session oSession)
{
oSession.oRequest["RH-LookingFor"] = "Looking for hostname " + redirectHost + ":" + hostPort;
oSession.oRequest["RH-HostName"] = "HostName is " + oSession.hostname + ":" + oSession.port;
if (oSession.HostnameIs(redirectHost) && oSession.port == hostPort)
{
if (numberOfRedirects % 2 == 0)
{
oSession.hostname = destinationOne;
oSession.port = destOnePort;
}
else
{
oSession.hostname = destinationTwo;
oSession.port = destTwoPort;
}
numberOfRedirects++;
if (numberOfRedirects > long.MaxValue - 10000) numberOfRedirects = 1;
oSession.oRequest["RH-Redirect"] = "Redirected to " + oSession.hostname + ":" + oSession.port;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment